1 | var A3=Object.create;var Rm=Object.defineProperty;var _3=Object.getOwnPropertyDescriptor;var E3=Object.getOwnPropertyNames;var M3=Object.getPrototypeOf,T3=Object.prototype.hasOwnProperty;var C3=(i,t,e)=>t in i?Rm(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Gn=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),P3=(i,t)=>{for(var e in t)Rm(i,e,{get:t[e],enumerable:!0})},D3=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of E3(t))!T3.call(i,n)&&n!==e&&Rm(i,n,{get:()=>t[n],enumerable:!(r=_3(t,n))||r.enumerable});return i};var pn=(i,t,e)=>(e=i!=null?A3(M3(i)):{},D3(t||!i||!i.__esModule?Rm(e,"default",{value:i,enumerable:!0}):e,i));var mn=(i,t,e)=>(C3(i,typeof t!="symbol"?t+"":t,e),e);var F2=Gn((bS,B2)=>{(function(i,t){typeof bS=="object"?B2.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(bS,function(){"use strict";return i.importState=function(e){var r=new i;return r.importState(e),r},i;function i(){return function(e){var r=0,n=0,s=0,o=1;e.length==0&&(e=[+new Date]);var a=t();r=a(" "),n=a(" "),s=a(" ");for(var l=0;l<e.length;l++)r-=a(e[l]),r<0&&(r+=1),n-=a(e[l]),n<0&&(n+=1),s-=a(e[l]),s<0&&(s+=1);a=null;var u=function(){var c=2091639*r+o*23283064365386963e-26;return r=n,n=s,s=c-(o=c|0)};return u.next=u,u.uint32=function(){return u()*4294967296},u.fract53=function(){return u()+(u()*2097152|0)*11102230246251565e-32},u.version="Alea 0.9",u.args=e,u.exportState=function(){return[r,n,s,o]},u.importState=function(c){r=+c[0]||0,n=+c[1]||0,s=+c[2]||0,o=+c[3]||0},u}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(n){n=n.toString();for(var s=0;s<n.length;s++){e+=n.charCodeAt(s);var o=.02519603282416938*e;e=o>>>0,o-=e,o*=e,e=o>>>0,o-=e,e+=o*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var SS=Gn((gv,U2)=>{(function(i,t){typeof gv=="object"&&typeof U2<"u"?t(gv):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(gv,function(i){"use strict";i.SVD=function(t,e,r,n,s){if(e=e===void 0||e,r=r===void 0||r,s=1e-64/(n=n||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var o,a,l,u,c,h,d,f,p,m,g,y,v=t[0].length,x=t.length;if(x<v)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],A=[],E=e==="f"?x:v,b=m=d=0;b<x;b++)S[b]=new Array(E).fill(0);for(b=0;b<v;b++)A[b]=new Array(v).fill(0);var M,T=new Array(v).fill(0);for(b=0;b<x;b++)for(o=0;o<v;o++)S[b][o]=t[b][o];for(b=0;b<v;b++){for(w[b]=d,p=0,l=b+1,o=b;o<x;o++)p+=Math.pow(S[o][b],2);if(p<s)d=0;else for(f=(h=S[b][b])*(d=h<0?Math.sqrt(p):-Math.sqrt(p))-p,S[b][b]=h-d,o=l;o<v;o++){for(p=0,a=b;a<x;a++)p+=S[a][b]*S[a][o];for(h=p/f,a=b;a<x;a++)S[a][o]=S[a][o]+h*S[a][b]}for(T[b]=d,p=0,o=l;o<v;o++)p+=Math.pow(S[b][o],2);if(p<s)d=0;else{for(f=(h=S[b][b+1])*(d=h<0?Math.sqrt(p):-Math.sqrt(p))-p,S[b][b+1]=h-d,o=l;o<v;o++)w[o]=S[b][o]/f;for(o=l;o<x;o++){for(p=0,a=l;a<v;a++)p+=S[o][a]*S[b][a];for(a=l;a<v;a++)S[o][a]=S[o][a]+p*w[a]}}m<(g=Math.abs(T[b])+Math.abs(w[b]))&&(m=g)}if(r)for(b=v-1;0<=b;b--){if(d!==0){for(f=S[b][b+1]*d,o=l;o<v;o++)A[o][b]=S[b][o]/f;for(o=l;o<v;o++){for(p=0,a=l;a<v;a++)p+=S[b][a]*A[a][o];for(a=l;a<v;a++)A[a][o]=A[a][o]+p*A[a][b]}}for(o=l;o<v;o++)A[b][o]=0,A[o][b]=0;A[b][b]=1,d=w[b],l=b}if(e){if(e==="f")for(b=v;b<x;b++){for(o=v;o<x;o++)S[b][o]=0;S[b][b]=1}for(b=v-1;0<=b;b--){for(l=b+1,d=T[b],o=l;o<E;o++)S[b][o]=0;if(d!==0){for(f=S[b][b]*d,o=l;o<E;o++){for(p=0,a=l;a<x;a++)p+=S[a][b]*S[a][o];for(h=p/f,a=b;a<x;a++)S[a][o]=S[a][o]+h*S[a][b]}for(o=b;o<x;o++)S[o][b]=S[o][b]/d}else for(o=b;o<x;o++)S[o][b]=0;S[b][b]=S[b][b]+1}}for(n*=m,a=v-1;0<=a;a--)for(var C=0;C<50;C++){for(M=!1,l=a;0<=l;l--){if(Math.abs(w[l])<=n){M=!0;break}if(Math.abs(T[l-1])<=n)break}if(!M){for(c=0,u=l-(p=1),b=l;b<a+1&&(h=p*w[b],w[b]=c*w[b],!(Math.abs(h)<=n));b++)if(d=T[b],T[b]=Math.sqrt(h*h+d*d),c=d/(f=T[b]),p=-h/f,e)for(o=0;o<x;o++)g=S[o][u],y=S[o][b],S[o][u]=g*c+y*p,S[o][b]=-g*p+y*c}if(y=T[a],l===a){if(y<0&&(T[a]=-y,r))for(o=0;o<v;o++)A[o][a]=-A[o][a];break}for(m=T[l],h=(((g=T[a-1])-y)*(g+y)+((d=w[a-1])-(f=w[a]))*(d+f))/(2*f*g),d=Math.sqrt(h*h+1),h=((m-y)*(m+y)+f*(g/(h<0?h-d:h+d)-f))/m,b=l+(p=c=1);b<a+1;b++){if(d=w[b],g=T[b],f=p*d,d*=c,y=Math.sqrt(h*h+f*f),h=m*(c=h/(w[b-1]=y))+d*(p=f/y),d=-m*p+d*c,f=g*p,g*=c,r)for(o=0;o<v;o++)m=A[o][b-1],y=A[o][b],A[o][b-1]=m*c+y*p,A[o][b]=-m*p+y*c;if(y=Math.sqrt(h*h+f*f),h=(c=h/(T[b-1]=y))*d+(p=f/y)*g,m=-p*d+c*g,e)for(o=0;o<x;o++)g=S[o][b-1],y=S[o][b],S[o][b-1]=g*c+y*p,S[o][b]=-g*p+y*c}w[l]=0,w[a]=h,T[a]=m}for(b=0;b<v;b++)T[b]<n&&(T[b]=0);return{u:S,q:T,v:A}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var pD=Gn((zS,US)=>{(function(i,t){typeof zS=="object"&&typeof US<"u"?US.exports=t():typeof define=="function"&&define.amd?define(t):(i=i||self,i.TinyQueue=t())})(zS,function(){"use strict";var i=function(r,n){if(r===void 0&&(r=[]),n===void 0&&(n=t),this.data=r,this.length=this.data.length,this.compare=n,this.length>0)for(var s=(this.length>>1)-1;s>=0;s--)this._down(s)};i.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},i.prototype.pop=function(){if(this.length!==0){var r=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),r}},i.prototype.peek=function(){return this.data[0]},i.prototype._up=function(r){for(var n=this,s=n.data,o=n.compare,a=s[r];r>0;){var l=r-1>>1,u=s[l];if(o(a,u)>=0)break;s[r]=u,r=l}s[r]=a},i.prototype._down=function(r){for(var n=this,s=n.data,o=n.compare,a=this.length>>1,l=s[r];r<a;){var u=(r<<1)+1,c=s[u],h=u+1;if(h<this.length&&o(s[h],c)<0&&(u=h,c=s[h]),o(c,l)>=0)break;s[r]=c,r=u}s[r]=l};function t(e,r){return e<r?-1:e>r?1:0}return i})});var gD=Gn((Vfe,GS)=>{"use strict";var Sv=pD();Sv.default&&(Sv=Sv.default);GS.exports=mD;GS.exports.default=mD;function mD(i,t,e){t=t||1;for(var r,n,s,o,a=0;a<i[0].length;a++){var l=i[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<n)&&(n=l[1]),(!a||l[0]>s)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var u=s-r,c=o-n,h=Math.min(u,c),d=h/2;if(h===0){var f=[r,n];return f.distance=0,f}for(var p=new Sv(void 0,U8),m=r;m<s;m+=h)for(var g=n;g<o;g+=h)p.push(new ll(m+d,g+d,d,i));var y=H8(i),v=new ll(r+u/2,n+c/2,0,i);v.d>y.d&&(y=v);for(var x=p.length;p.length;){var w=p.pop();w.d>y.d&&(y=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,x)),!(w.max-y.d<=t)&&(d=w.h/2,p.push(new ll(w.x-d,w.y-d,d,i)),p.push(new ll(w.x+d,w.y-d,d,i)),p.push(new ll(w.x-d,w.y+d,d,i)),p.push(new ll(w.x+d,w.y+d,d,i)),x+=4)}e&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var S=[y.x,y.y];return S.distance=y.d,S}function U8(i,t){return t.max-i.max}function ll(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=G8(i,t,r),this.max=this.d+this.h*Math.SQRT2}function G8(i,t,e){for(var r=!1,n=1/0,s=0;s<e.length;s++)for(var o=e[s],a=0,l=o.length,u=l-1;a<l;u=a++){var c=o[a],h=o[u];c[1]>t!=h[1]>t&&i<(h[0]-c[0])*(t-c[1])/(h[1]-c[1])+c[0]&&(r=!r),n=Math.min(n,j8(i,t,c,h))}return n===0?0:(r?1:-1)*Math.sqrt(n)}function H8(i){for(var t=0,e=0,r=0,n=i[0],s=0,o=n.length,a=o-1;s<o;a=s++){var l=n[s],u=n[a],c=l[0]*u[1]-u[0]*l[1];e+=(l[0]+u[0])*c,r+=(l[1]+u[1])*c,t+=c*3}return t===0?new ll(n[0][0],n[0][1],0,i):new ll(e/t,r/t,0,i)}function j8(i,t,e,r){var n=e[0],s=e[1],o=r[0]-n,a=r[1]-s;if(o!==0||a!==0){var l=((i-n)*o+(t-s)*a)/(o*o+a*a);l>1?(n=r[0],s=r[1]):l>0&&(n+=o*l,s+=a*l)}return o=i-n,a=t-s,o*o+a*a}});var fI=Gn((Yv,dI)=>{"use strict";Object.defineProperty(Yv,"__esModule",{value:!0});Yv.default=Uq;function Uq(i){if(i===null||i===!0||i===!1)return NaN;var t=Number(i);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}dI.exports=Yv.default});var mI=Gn((Xv,pI)=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});Xv.default=Gq;function Gq(i){var t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds()));return t.setUTCFullYear(i.getFullYear()),i.getTime()-t.getTime()}pI.exports=Xv.default});var EI=Gn(Zv=>{(function(){"use strict";var i=function(){this.init()};i.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var h=this||t;if(c=parseFloat(c),h.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(h._volume=c,h._muted)return h;h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),p=0;p<f.length;p++){var m=h._howls[d]._soundById(f[p]);m&&m._node&&(m._node.volume=m._volume*c)}return h}return h._volume},mute:function(c){var h=this||t;h.ctx||u(),h._muted=c,h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c?0:h._volume,t.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),p=0;p<f.length;p++){var m=h._howls[d]._soundById(f[p]);m&&m._node&&(m._node.muted=c?!0:m._muted)}return h},stop:function(){for(var c=this||t,h=0;h<c._howls.length;h++)c._howls[h].stop();return c},unload:function(){for(var c=this||t,h=c._howls.length-1;h>=0;h--)c._howls[h].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var h=new Audio;typeof h.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var h=new Audio;h.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,h=null;try{h=typeof Audio<"u"?new Audio:null}catch{return c}if(!h||typeof h.canPlayType!="function")return c;var d=h.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",p=f.match(/OPR\/([0-6].)/g),m=p&&parseInt(p[0].split("/")[1],10)<33,g=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,y=f.match(/Version\/(.*?) /),v=g&&y&&parseInt(y[1],10)<15;return c._codecs={mp3:!!(!m&&(d||h.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!h.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(h.canPlayType('audio/wav; codecs="1"')||h.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!h.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!h.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(h.canPlayType("audio/x-m4b;")||h.canPlayType("audio/m4b;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(h.canPlayType("audio/x-mp4;")||h.canPlayType("audio/mp4;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!v&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!h.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(h.canPlayType("audio/x-flac;")||h.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var h=function(d){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var p=0;p<c._howls.length;p++)if(!c._howls[p]._webAudio)for(var m=c._howls[p]._getSoundIds(),g=0;g<m.length;g++){var y=c._howls[p]._soundById(m[g]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}c._autoResume();var v=c.ctx.createBufferSource();v.buffer=c._scratchBuffer,v.connect(c.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),v.onended=function(){v.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",h,!0),document.removeEventListener("touchend",h,!0),document.removeEventListener("click",h,!0),document.removeEventListener("keydown",h,!0);for(var x=0;x<c._howls.length;x++)c._howls[x]._emit("unlock")}};return document.addEventListener("touchstart",h,!0),document.addEventListener("touchend",h,!0),document.addEventListener("click",h,!0),document.addEventListener("keydown",h,!0),c}},_obtainHtml5Audio:function(){var c=this||t;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var h=new Audio().play();return h&&typeof Promise<"u"&&(h instanceof Promise||typeof h.then=="function")&&h.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var h=this||t;return c._unlocked&&h._html5AudioPool.push(c),h},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!t.usingWebAudio)){for(var h=0;h<c._howls.length;h++)if(c._howls[h]._webAudio){for(var d=0;d<c._howls[h]._sounds.length;d++)if(!c._howls[h]._sounds[d]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var h=0;h<c._howls.length;h++)c._howls[h]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var t=new i,e=function(c){var h=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}h.init(c)};e.prototype={init:function(c){var h=this;return t.ctx||u(),h._autoplay=c.autoplay||!1,h._format=typeof c.format!="string"?c.format:[c.format],h._html5=c.html5||!1,h._muted=c.mute||!1,h._loop=c.loop||!1,h._pool=c.pool||5,h._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,h._rate=c.rate||1,h._sprite=c.sprite||{},h._src=typeof c.src!="string"?c.src:[c.src],h._volume=c.volume!==void 0?c.volume:1,h._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},h._duration=0,h._state="unloaded",h._sounds=[],h._endTimers={},h._queue=[],h._playLock=!1,h._onend=c.onend?[{fn:c.onend}]:[],h._onfade=c.onfade?[{fn:c.onfade}]:[],h._onload=c.onload?[{fn:c.onload}]:[],h._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],h._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],h._onpause=c.onpause?[{fn:c.onpause}]:[],h._onplay=c.onplay?[{fn:c.onplay}]:[],h._onstop=c.onstop?[{fn:c.onstop}]:[],h._onmute=c.onmute?[{fn:c.onmute}]:[],h._onvolume=c.onvolume?[{fn:c.onvolume}]:[],h._onrate=c.onrate?[{fn:c.onrate}]:[],h._onseek=c.onseek?[{fn:c.onseek}]:[],h._onunlock=c.onunlock?[{fn:c.onunlock}]:[],h._onresume=[],h._webAudio=t.usingWebAudio&&!h._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(h),h._autoplay&&h._queue.push({event:"play",action:function(){h.play()}}),h._preload&&h._preload!=="none"&&h.load(),h},load:function(){var c=this,h=null;if(t.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var d=0;d<c._src.length;d++){var f,p;if(c._format&&c._format[d])f=c._format[d];else{if(p=c._src[d],typeof p!="string"){c._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(p),f||(f=/\.([^.]+)$/.exec(p.split("?",1)[0])),f&&(f=f[1].toLowerCase())}if(f||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),f&&t.codecs(f)){h=c._src[d];break}}if(!h){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=h,c._state="loading",window.location.protocol==="https:"&&h.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new r(c),c._webAudio&&s(c),c},play:function(c,h){var d=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&d._state==="loaded"&&!d._sprite[c])return null;if(typeof c>"u"&&(c="__default",!d._playLock)){for(var p=0,m=0;m<d._sounds.length;m++)d._sounds[m]._paused&&!d._sounds[m]._ended&&(p++,f=d._sounds[m]._id);p===1?c=null:f=null}}var g=f?d._soundById(f):d._inactiveSound();if(!g)return null;if(f&&!c&&(c=g._sprite||"__default"),d._state!=="loaded"){g._sprite=c,g._ended=!1;var y=g._id;return d._queue.push({event:"play",action:function(){d.play(y)}}),y}if(f&&!g._paused)return h||d._loadQueue("play"),g._id;d._webAudio&&t._autoResume();var v=Math.max(0,g._seek>0?g._seek:d._sprite[c][0]/1e3),x=Math.max(0,(d._sprite[c][0]+d._sprite[c][1])/1e3-v),w=x*1e3/Math.abs(g._rate),S=d._sprite[c][0]/1e3,A=(d._sprite[c][0]+d._sprite[c][1])/1e3;g._sprite=c,g._ended=!1;var E=function(){g._paused=!1,g._seek=v,g._start=S,g._stop=A,g._loop=!!(g._loop||d._sprite[c][2])};if(v>=A){d._ended(g);return}var b=g._node;if(d._webAudio){var M=function(){d._playLock=!1,E(),d._refreshBuffer(g);var D=g._muted||d._muted?0:g._volume;b.gain.setValueAtTime(D,t.ctx.currentTime),g._playStart=t.ctx.currentTime,typeof b.bufferSource.start>"u"?g._loop?b.bufferSource.noteGrainOn(0,v,86400):b.bufferSource.noteGrainOn(0,v,x):g._loop?b.bufferSource.start(0,v,86400):b.bufferSource.start(0,v,x),w!==1/0&&(d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w)),h||setTimeout(function(){d._emit("play",g._id),d._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?M():(d._playLock=!0,d.once("resume",M),d._clearTimer(g._id))}else{var T=function(){b.currentTime=v,b.muted=g._muted||d._muted||t._muted||b.muted,b.volume=g._volume*t.volume(),b.playbackRate=g._rate;try{var D=b.play();if(D&&typeof Promise<"u"&&(D instanceof Promise||typeof D.then=="function")?(d._playLock=!0,E(),D.then(function(){d._playLock=!1,b._unlocked=!0,h?d._loadQueue():d._emit("play",g._id)}).catch(function(){d._playLock=!1,d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),g._ended=!0,g._paused=!0})):h||(d._playLock=!1,E(),d._emit("play",g._id)),b.playbackRate=g._rate,b.paused){d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||g._loop?d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w):(d._endTimers[g._id]=function(){d._ended(g),b.removeEventListener("ended",d._endTimers[g._id],!1)},b.addEventListener("ended",d._endTimers[g._id],!1))}catch(I){d._emit("playerror",g._id,I)}};b.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(b.src=d._src,b.load());var C=window&&window.ejecta||!b.readyState&&t._navigator.isCocoonJS;if(b.readyState>=3||C)T();else{d._playLock=!0,d._state="loading";var P=function(){d._state="loaded",T(),b.removeEventListener(t._canPlayEvent,P,!1)};b.addEventListener(t._canPlayEvent,P,!1),d._clearTimer(g._id)}}return g._id},pause:function(c){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"pause",action:function(){h.pause(c)}}),h;for(var d=h._getSoundIds(c),f=0;f<d.length;f++){h._clearTimer(d[f]);var p=h._soundById(d[f]);if(p&&!p._paused&&(p._seek=h.seek(d[f]),p._rateSeek=0,p._paused=!0,h._stopFade(d[f]),p._node))if(h._webAudio){if(!p._node.bufferSource)continue;typeof p._node.bufferSource.stop>"u"?p._node.bufferSource.noteOff(0):p._node.bufferSource.stop(0),h._cleanBuffer(p._node)}else(!isNaN(p._node.duration)||p._node.duration===1/0)&&p._node.pause();arguments[1]||h._emit("pause",p?p._id:null)}return h},stop:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(c)}}),d;for(var f=d._getSoundIds(c),p=0;p<f.length;p++){d._clearTimer(f[p]);var m=d._soundById(f[p]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,d._stopFade(f[p]),m._node&&(d._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&d._clearSound(m._node))),h||d._emit("stop",m._id))}return d},mute:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(c,h)}}),d;if(typeof h>"u")if(typeof c=="boolean")d._muted=c;else return d._muted;for(var f=d._getSoundIds(h),p=0;p<f.length;p++){var m=d._soundById(f[p]);m&&(m._muted=c,m._interval&&d._stopFade(m._id),d._webAudio&&m._node?m._node.gain.setValueAtTime(c?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:c),d._emit("mute",m._id))}return d},volume:function(){var c=this,h=arguments,d,f;if(h.length===0)return c._volume;if(h.length===1||h.length===2&&typeof h[1]>"u"){var p=c._getSoundIds(),m=p.indexOf(h[0]);m>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length>=2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d<"u"&&d>=0&&d<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,h)}}),c;typeof f>"u"&&(c._volume=d),f=c._getSoundIds(f);for(var y=0;y<f.length;y++)g=c._soundById(f[y]),g&&(g._volume=d,h[2]||c._stopFade(f[y]),c._webAudio&&g._node&&!g._muted?g._node.gain.setValueAtTime(d,t.ctx.currentTime):g._node&&!g._muted&&(g._node.volume=d*t.volume()),c._emit("volume",g._id))}else return g=f?c._soundById(f):c._sounds[0],g?g._volume:0;return c},fade:function(c,h,d,f){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"fade",action:function(){p.fade(c,h,d,f)}}),p;c=Math.min(Math.max(0,parseFloat(c)),1),h=Math.min(Math.max(0,parseFloat(h)),1),d=parseFloat(d),p.volume(c,f);for(var m=p._getSoundIds(f),g=0;g<m.length;g++){var y=p._soundById(m[g]);if(y){if(f||p._stopFade(m[g]),p._webAudio&&!y._muted){var v=t.ctx.currentTime,x=v+d/1e3;y._volume=c,y._node.gain.setValueAtTime(c,v),y._node.gain.linearRampToValueAtTime(h,x)}p._startFadeInterval(y,c,h,d,m[g],typeof f>"u")}}return p},_startFadeInterval:function(c,h,d,f,p,m){var g=this,y=h,v=d-h,x=Math.abs(v/.01),w=Math.max(4,x>0?f/x:f),S=Date.now();c._fadeTo=d,c._interval=setInterval(function(){var A=(Date.now()-S)/f;S=Date.now(),y+=v*A,y=Math.round(y*100)/100,v<0?y=Math.max(d,y):y=Math.min(d,y),g._webAudio?c._volume=y:g.volume(y,c._id,!0),m&&(g._volume=y),(d<h&&y<=d||d>h&&y>=d)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,g.volume(d,c._id),g._emit("fade",c._id))},w)},_stopFade:function(c){var h=this,d=h._soundById(c);return d&&d._interval&&(h._webAudio&&d._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(d._interval),d._interval=null,h.volume(d._fadeTo,c),d._fadeTo=null,h._emit("fade",c)),h},loop:function(){var c=this,h=arguments,d,f,p;if(h.length===0)return c._loop;if(h.length===1)if(typeof h[0]=="boolean")d=h[0],c._loop=d;else return p=c._soundById(parseInt(h[0],10)),p?p._loop:!1;else h.length===2&&(d=h[0],f=parseInt(h[1],10));for(var m=c._getSoundIds(f),g=0;g<m.length;g++)p=c._soundById(m[g]),p&&(p._loop=d,c._webAudio&&p._node&&p._node.bufferSource&&(p._node.bufferSource.loop=d,d&&(p._node.bufferSource.loopStart=p._start||0,p._node.bufferSource.loopEnd=p._stop,c.playing(m[g])&&(c.pause(m[g],!0),c.play(m[g],!0)))));return c},rate:function(){var c=this,h=arguments,d,f;if(h.length===0)f=c._sounds[0]._id;else if(h.length===1){var p=c._getSoundIds(),m=p.indexOf(h[0]);m>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,h)}}),c;typeof f>"u"&&(c._rate=d),f=c._getSoundIds(f);for(var y=0;y<f.length;y++)if(g=c._soundById(f[y]),g){c.playing(f[y])&&(g._rateSeek=c.seek(f[y]),g._playStart=c._webAudio?t.ctx.currentTime:g._playStart),g._rate=d,c._webAudio&&g._node&&g._node.bufferSource?g._node.bufferSource.playbackRate.setValueAtTime(d,t.ctx.currentTime):g._node&&(g._node.playbackRate=d);var v=c.seek(f[y]),x=(c._sprite[g._sprite][0]+c._sprite[g._sprite][1])/1e3-v,w=x*1e3/Math.abs(g._rate);(c._endTimers[f[y]]||!g._paused)&&(c._clearTimer(f[y]),c._endTimers[f[y]]=setTimeout(c._ended.bind(c,g),w)),c._emit("rate",g._id)}}else return g=c._soundById(f),g?g._rate:c._rate;return c},seek:function(){var c=this,h=arguments,d,f;if(h.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(h.length===1){var p=c._getSoundIds(),m=p.indexOf(h[0]);m>=0?f=parseInt(h[0],10):c._sounds.length&&(f=c._sounds[0]._id,d=parseFloat(h[0]))}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));if(typeof f>"u")return 0;if(typeof d=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,h)}}),c;var g=c._soundById(f);if(g)if(typeof d=="number"&&d>=0){var y=c.playing(f);y&&c.pause(f,!0),g._seek=d,g._ended=!1,c._clearTimer(f),!c._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=d);var v=function(){y&&c.play(f,!0),c._emit("seek",f)};if(y&&!c._webAudio){var x=function(){c._playLock?setTimeout(x,0):v()};setTimeout(x,0)}else v()}else if(c._webAudio){var w=c.playing(f)?t.ctx.currentTime-g._playStart:0,S=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(S+w*Math.abs(g._rate))}else return g._node.currentTime;return c},playing:function(c){var h=this;if(typeof c=="number"){var d=h._soundById(c);return d?!d._paused:!1}for(var f=0;f<h._sounds.length;f++)if(!h._sounds[f]._paused)return!0;return!1},duration:function(c){var h=this,d=h._duration,f=h._soundById(c);return f&&(d=h._sprite[f._sprite][1]/1e3),d},state:function(){return this._state},unload:function(){for(var c=this,h=c._sounds,d=0;d<h.length;d++)h[d]._paused||c.stop(h[d]._id),c._webAudio||(c._clearSound(h[d]._node),h[d]._node.removeEventListener("error",h[d]._errorFn,!1),h[d]._node.removeEventListener(t._canPlayEvent,h[d]._loadFn,!1),h[d]._node.removeEventListener("ended",h[d]._endFn,!1),t._releaseHtml5Audio(h[d]._node)),delete h[d]._node,c._clearTimer(h[d]._id);var f=t._howls.indexOf(c);f>=0&&t._howls.splice(f,1);var p=!0;for(d=0;d<t._howls.length;d++)if(t._howls[d]._src===c._src||c._src.indexOf(t._howls[d]._src)>=0){p=!1;break}return n&&p&&delete n[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,h,d,f){var p=this,m=p["_on"+c];return typeof h=="function"&&m.push(f?{id:d,fn:h,once:f}:{id:d,fn:h}),p},off:function(c,h,d){var f=this,p=f["_on"+c],m=0;if(typeof h=="number"&&(d=h,h=null),h||d)for(m=0;m<p.length;m++){var g=d===p[m].id;if(h===p[m].fn&&g||!h&&g){p.splice(m,1);break}}else if(c)f["_on"+c]=[];else{var y=Object.keys(f);for(m=0;m<y.length;m++)y[m].indexOf("_on")===0&&Array.isArray(f[y[m]])&&(f[y[m]]=[])}return f},once:function(c,h,d){var f=this;return f.on(c,h,d,1),f},_emit:function(c,h,d){for(var f=this,p=f["_on"+c],m=p.length-1;m>=0;m--)(!p[m].id||p[m].id===h||c==="load")&&(setTimeout(function(g){g.call(this,h,d)}.bind(f,p[m].fn),0),p[m].once&&f.off(c,p[m].fn,p[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var h=this;if(h._queue.length>0){var d=h._queue[0];d.event===c&&(h._queue.shift(),h._loadQueue()),c||d.action()}return h},_ended:function(c){var h=this,d=c._sprite;if(!h._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(h._ended.bind(h,c),100),h;var f=!!(c._loop||h._sprite[d][2]);if(h._emit("end",c._id),!h._webAudio&&f&&h.stop(c._id,!0).play(c._id),h._webAudio&&f){h._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=t.ctx.currentTime;var p=(c._stop-c._start)*1e3/Math.abs(c._rate);h._endTimers[c._id]=setTimeout(h._ended.bind(h,c),p)}return h._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,h._clearTimer(c._id),h._cleanBuffer(c._node),t._autoSuspend()),!h._webAudio&&!f&&h.stop(c._id,!0),h},_clearTimer:function(c){var h=this;if(h._endTimers[c]){if(typeof h._endTimers[c]!="function")clearTimeout(h._endTimers[c]);else{var d=h._soundById(c);d&&d._node&&d._node.removeEventListener("ended",h._endTimers[c],!1)}delete h._endTimers[c]}return h},_soundById:function(c){for(var h=this,d=0;d<h._sounds.length;d++)if(c===h._sounds[d]._id)return h._sounds[d];return null},_inactiveSound:function(){var c=this;c._drain();for(var h=0;h<c._sounds.length;h++)if(c._sounds[h]._ended)return c._sounds[h].reset();return new r(c)},_drain:function(){var c=this,h=c._pool,d=0,f=0;if(!(c._sounds.length<h)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&d++;for(f=c._sounds.length-1;f>=0;f--){if(d<=h)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),d--)}}},_getSoundIds:function(c){var h=this;if(typeof c>"u"){for(var d=[],f=0;f<h._sounds.length;f++)d.push(h._sounds[f]._id);return d}else return[c]},_refreshBuffer:function(c){var h=this;return c._node.bufferSource=t.ctx.createBufferSource(),c._node.bufferSource.buffer=n[h._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,t.ctx.currentTime),h},_cleanBuffer:function(c){var h=this,d=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),d))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,h},_clearSound:function(c){var h=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);h||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,h._sounds.push(c),c.create(),c},create:function(){var c=this,h=c._parent,d=t._muted||c._muted||c._parent._muted?0:c._volume;return h._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(d,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=h._src,c._node.preload=h._preload===!0?"auto":h._preload,c._node.volume=d*t.volume(),c._node.load()),c},reset:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,h=c._parent;h._duration=Math.ceil(c._node.duration*10)/10,Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,h._duration*1e3]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,h=c._parent;h._duration===1/0&&(h._duration=Math.ceil(c._node.duration*10)/10,h._sprite.__default[1]===1/0&&(h._sprite.__default[1]=h._duration*1e3),h._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var n={},s=function(c){var h=c._src;if(n[h]){c._duration=n[h].duration,l(c);return}if(/^data:[^;]+;base64,/.test(h)){for(var d=atob(h.split(",")[1]),f=new Uint8Array(d.length),p=0;p<d.length;++p)f[p]=d.charCodeAt(p);a(f.buffer,c)}else{var m=new XMLHttpRequest;m.open(c._xhr.method,h,!0),m.withCredentials=c._xhr.withCredentials,m.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(g){m.setRequestHeader(g,c._xhr.headers[g])}),m.onload=function(){var g=(m.status+"")[0];if(g!=="0"&&g!=="2"&&g!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}a(m.response,c)},m.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete n[h],c.load())},o(m)}},o=function(c){try{c.send()}catch{c.onerror()}},a=function(c,h){var d=function(){h._emit("loaderror",null,"Decoding audio data failed.")},f=function(p){p&&h._sounds.length>0?(n[h._src]=p,l(h,p)):d()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(d):t.ctx.decodeAudioData(c,f,d)},l=function(c,h){h&&!c._duration&&(c._duration=h.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),h=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=h?parseInt(h[1],10):null;if(c&&d&&d<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof Zv<"u"&&(Zv.Howler=t,Zv.Howl=e),typeof global<"u"?(global.HowlerGlobal=i,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=i,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var n=this;if(!n.ctx||!n.ctx.listener)return n;if(e=typeof e!="number"?n._pos[1]:e,r=typeof r!="number"?n._pos[2]:r,typeof t=="number")n._pos=[t,e,r],typeof n.ctx.listener.positionX<"u"?(n.ctx.listener.positionX.setTargetAtTime(n._pos[0],Howler.ctx.currentTime,.1),n.ctx.listener.positionY.setTargetAtTime(n._pos[1],Howler.ctx.currentTime,.1),n.ctx.listener.positionZ.setTargetAtTime(n._pos[2],Howler.ctx.currentTime,.1)):n.ctx.listener.setPosition(n._pos[0],n._pos[1],n._pos[2]);else return n._pos;return n},HowlerGlobal.prototype.orientation=function(t,e,r,n,s,o){var a=this;if(!a.ctx||!a.ctx.listener)return a;var l=a._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,n=typeof n!="number"?l[3]:n,s=typeof s!="number"?l[4]:s,o=typeof o!="number"?l[5]:o,typeof t=="number")a._orientation=[t,e,r,n,s,o],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(o,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(t,e,r,n,s,o);else return l;return a},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var n=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var s=r._getSoundIds(e),o=0;o<s.length;o++){var a=r._soundById(s[o]);if(a)if(typeof t=="number")a._stereo=t,a._pos=[t,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&i(a,n),n==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(t,0,0):a._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),r._emit("stereo",a._id);else return a._stereo}return r},Howl.prototype.pos=function(t,e,r,n){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"pos",action:function(){s.pos(t,e,r,n)}}),s;if(e=typeof e!="number"?0:e,r=typeof r!="number"?-.5:r,typeof n>"u")if(typeof t=="number")s._pos=[t,e,r];else return s._pos;for(var o=s._getSoundIds(n),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof t=="number")l._pos=[t,e,r],l._node&&((!l._panner||l._panner.pan)&&i(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(t,e,r)),s._emit("pos",l._id);else return l._pos}return s},Howl.prototype.orientation=function(t,e,r,n){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"orientation",action:function(){s.orientation(t,e,r,n)}}),s;if(e=typeof e!="number"?s._orientation[1]:e,r=typeof r!="number"?s._orientation[2]:r,typeof n>"u")if(typeof t=="number")s._orientation=[t,e,r];else return s._orientation;for(var o=s._getSoundIds(n),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof t=="number")l._orientation=[t,e,r],l._node&&(l._panner||(l._pos||(l._pos=s._pos||[0,0,-.5]),i(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(t,e,r)),s._emit("orientation",l._id);else return l._orientation}return s},Howl.prototype.pannerAttr=function(){var t=this,e=arguments,r,n,s;if(!t._webAudio)return t;if(e.length===0)return t._pannerAttr;if(e.length===1)if(typeof e[0]=="object")r=e[0],typeof n>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return s=t._soundById(parseInt(e[0],10)),s?s._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],n=parseInt(e[1],10));for(var o=t._getSoundIds(n),a=0;a<o.length;a++)if(s=t._soundById(o[a]),s){var l=s._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=s._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(s._pos||(s._pos=t._pos||[0,0,-.5]),i(s,"spatial"))}return t},Sound.prototype.init=function(t){return function(){var e=this,r=e._parent;e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,t.call(this),e._stereo?r.stereo(e._stereo):e._pos&&r.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var e=this,r=e._parent;return e._orientation=r._orientation,e._stereo=r._stereo,e._pos=r._pos,e._pannerAttr=r._pannerAttr,e._stereo?r.stereo(e._stereo):e._pos?r.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,r._refreshBuffer(e)),t.call(this)}}(Sound.prototype.reset);var i=function(t,e){e=e||"spatial",e==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()});var JO=Gn((XOe,ZO)=>{"use strict";function v7(i){for(var t=new Array(i),e=0;e<i;++e)t[e]=e;return t}ZO.exports=v7});var tR=Gn((QOe,eR)=>{eR.exports=function(i){return i!=null&&($O(i)||x7(i)||!!i._isBuffer)};function $O(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function x7(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&$O(i.slice(0,0))}});var Kd=Gn((KOe,rR)=>{var b7=JO(),w7=tR(),S7=typeof Float64Array<"u";function A7(i,t){return i[0]-t[0]}function _7(){var i=this.stride,t=new Array(i.length),e;for(e=0;e<t.length;++e)t[e]=[Math.abs(i[e]),e];t.sort(A7);var r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=t[e][1];return r}function E7(i,t){var e=["View",t,"d",i].join("");t<0&&(e="View_Nil"+i);var r=i==="generic";if(t===-1){var n="function "+e+"(a){this.data=a;};var proto="+e+".prototype;proto.dtype='"+i+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+e+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+e+"(a){return new "+e+"(a);}",m=new Function(n);return m()}else if(t===0){var n="function "+e+"(a,d) {this.data = a;this.offset = d};var proto="+e+".prototype;proto.dtype='"+i+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+e+"_copy() {return new "+e+"(this.data,this.offset)};proto.pick=function "+e+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+e+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+e+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+e+"(a,b,c,d){return new "+e+"(a,d)}",m=new Function("TrivialArray",n);return m(O0[i][0])}var n=["'use strict'"],s=b7(t),o=s.map(function(g){return"i"+g}),a="this.offset+"+s.map(function(g){return"this.stride["+g+"]*i"+g}).join("+"),l=s.map(function(g){return"b"+g}).join(","),u=s.map(function(g){return"c"+g}).join(",");n.push("function "+e+"(a,"+l+","+u+",d){this.data=a","this.shape=["+l+"]","this.stride=["+u+"]","this.offset=d|0}","var proto="+e+".prototype","proto.dtype='"+i+"'","proto.dimension="+t),n.push("Object.defineProperty(proto,'size',{get:function "+e+"_size(){return "+s.map(function(g){return"this.shape["+g+"]"}).join("*"),"}})"),t===1?n.push("proto.order=[0]"):(n.push("Object.defineProperty(proto,'order',{get:"),t<4?(n.push("function "+e+"_order(){"),t===2?n.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&n.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):n.push("ORDER})")),n.push("proto.set=function "+e+"_set("+o.join(",")+",v){"),r?n.push("return this.data.set("+a+",v)}"):n.push("return this.data["+a+"]=v}"),n.push("proto.get=function "+e+"_get("+o.join(",")+"){"),r?n.push("return this.data.get("+a+")}"):n.push("return this.data["+a+"]}"),n.push("proto.index=function "+e+"_index(",o.join(),"){return "+a+"}"),n.push("proto.hi=function "+e+"_hi("+o.join(",")+"){return new "+e+"(this.data,"+s.map(function(g){return["(typeof i",g,"!=='number'||i",g,"<0)?this.shape[",g,"]:i",g,"|0"].join("")}).join(",")+","+s.map(function(g){return"this.stride["+g+"]"}).join(",")+",this.offset)}");var c=s.map(function(g){return"a"+g+"=this.shape["+g+"]"}),h=s.map(function(g){return"c"+g+"=this.stride["+g+"]"});n.push("proto.lo=function "+e+"_lo("+o.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var d=0;d<t;++d)n.push("if(typeof i"+d+"==='number'&&i"+d+">=0){d=i"+d+"|0;b+=c"+d+"*d;a"+d+"-=d}");n.push("return new "+e+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"c"+g}).join(",")+",b)}"),n.push("proto.step=function "+e+"_step("+o.join(",")+"){var "+s.map(function(g){return"a"+g+"=this.shape["+g+"]"}).join(",")+","+s.map(function(g){return"b"+g+"=this.stride["+g+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var d=0;d<t;++d)n.push("if(typeof i"+d+"==='number'){d=i"+d+"|0;if(d<0){c+=b"+d+"*(a"+d+"-1);a"+d+"=ceil(-a"+d+"/d)}else{a"+d+"=ceil(a"+d+"/d)}b"+d+"*=d}");n.push("return new "+e+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"b"+g}).join(",")+",c)}");for(var f=new Array(t),p=new Array(t),d=0;d<t;++d)f[d]="a[i"+d+"]",p[d]="b[i"+d+"]";n.push("proto.transpose=function "+e+"_transpose("+o+"){"+o.map(function(g,y){return g+"=("+g+"===undefined?"+y+":"+g+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+e+"(this.data,"+f.join(",")+","+p.join(",")+",this.offset)}"),n.push("proto.pick=function "+e+"_pick("+o+"){var a=[],b=[],c=this.offset");for(var d=0;d<t;++d)n.push("if(typeof i"+d+"==='number'&&i"+d+">=0){c=(c+this.stride["+d+"]*i"+d+")|0}else{a.push(this.shape["+d+"]);b.push(this.stride["+d+"])}");n.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),n.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+s.map(function(g){return"shape["+g+"]"}).join(",")+","+s.map(function(g){return"stride["+g+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",n.join(`
|
2 | `));return m(O0[i],_7)}function M7(i){if(w7(i))return"buffer";if(S7)switch(Object.prototype.toString.call(i)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(i)?"array":"generic"}var O0={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function T7(i,t,e,r){if(i===void 0){var u=O0.array[0];return u([])}else typeof i=="number"&&(i=[i]);t===void 0&&(t=[i.length]);var n=t.length;if(e===void 0){e=new Array(n);for(var s=n-1,o=1;s>=0;--s)e[s]=o,o*=t[s]}if(r===void 0){r=0;for(var s=0;s<n;++s)e[s]<0&&(r-=(t[s]-1)*e[s])}for(var a=M7(i),l=O0[a];l.length<=n+1;)l.push(E7(a,l.length-1));var u=l[n+1];return u(i,t,e,r)}rR.exports=T7});var iR=Gn((ZOe,nR)=>{"use strict";function C7(i,t){for(var e=1,r=i.length,n=i[0],s=i[0],o=1;o<r;++o)if(s=n,n=i[o],t(n,s)){if(o===e){e++;continue}i[e++]=n}return i.length=e,i}function P7(i){for(var t=1,e=i.length,r=i[0],n=i[0],s=1;s<e;++s,n=r)if(n=r,r=i[s],r!==n){if(s===t){t++;continue}i[t++]=r}return i.length=t,i}function D7(i,t,e){return i.length===0?i:t?(e||i.sort(t),C7(i,t)):(e||i.sort(),P7(i))}nR.exports=D7});var aR=Gn((JOe,oR)=>{"use strict";var I7=iR();function sR(i,t,e){var r=i.length,n=t.arrayArgs.length,s=t.indexArgs.length>0,o=[],a=[],l=0,u=0,c,h;for(c=0;c<r;++c)a.push(["i",c,"=0"].join(""));for(h=0;h<n;++h)for(c=0;c<r;++c)u=l,l=i[c],c===0?a.push(["d",h,"s",c,"=t",h,"p",l].join("")):a.push(["d",h,"s",c,"=(t",h,"p",l,"-s",u,"*t",h,"p",u,")"].join(""));for(a.length>0&&o.push("var "+a.join(",")),c=r-1;c>=0;--c)l=i[c],o.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(o.push(e),c=0;c<r;++c){for(u=l,l=i[c],h=0;h<n;++h)o.push(["p",h,"+=d",h,"s",c].join(""));s&&(c>0&&o.push(["index[",u,"]-=s",u].join("")),o.push(["++index[",l,"]"].join(""))),o.push("}")}return o.join(`
|
3 | `)}function O7(i,t,e,r){for(var n=t.length,s=e.arrayArgs.length,o=e.blockSize,a=e.indexArgs.length>0,l=[],u=0;u<s;++u)l.push(["var offset",u,"=p",u].join(""));for(var u=i;u<n;++u)l.push(["for(var j"+u+"=SS[",t[u],"]|0;j",u,">0;){"].join("")),l.push(["if(j",u,"<",o,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",o].join("")),l.push(["j",u,"-=",o,"}"].join("")),a&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u<s;++u){for(var c=["offset"+u],h=i;h<n;++h)c.push(["j",h,"*t",u,"p",t[h]].join(""));l.push(["p",u,"=(",c.join("+"),")"].join(""))}l.push(sR(t,e,r));for(var u=i;u<n;++u)l.push("}");return l.join(`
|
4 | `)}function R7(i){for(var t=0,e=i[0].length;t<e;){for(var r=1;r<i.length;++r)if(i[r][t]!==i[0][t])return t;++t}return t}function a1(i,t,e){for(var r=i.body,n=[],s=[],o=0;o<i.args.length;++o){var a=i.args[o];if(!(a.count<=0)){var l=new RegExp(a.name,"g"),u="",c=t.arrayArgs.indexOf(o);switch(t.argTypes[o]){case"offset":var h=t.offsetArgIndex.indexOf(o),d=t.offsetArgs[h];c=d.array,u="+q"+h;case"array":u="p"+c+u;var f="l"+o,p="a"+c;if(t.arrayBlockIndices[c]===0)a.count===1?e[c]==="generic"?a.lvalue?(n.push(["var ",f,"=",p,".get(",u,")"].join("")),r=r.replace(l,f),s.push([p,".set(",u,",",f,")"].join(""))):r=r.replace(l,[p,".get(",u,")"].join("")):r=r.replace(l,[p,"[",u,"]"].join("")):e[c]==="generic"?(n.push(["var ",f,"=",p,".get(",u,")"].join("")),r=r.replace(l,f),a.lvalue&&s.push([p,".set(",u,",",f,")"].join(""))):(n.push(["var ",f,"=",p,"[",u,"]"].join("")),r=r.replace(l,f),a.lvalue&&s.push([p,"[",u,"]=",f].join("")));else{for(var m=[a.name],g=[u],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),g.push("$"+(y+1)+"*t"+c+"b"+y);if(l=new RegExp(m.join(""),"g"),u=g.join("+"),e[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");r=r.replace(l,[p,"[",u,"]"].join(""))}break;case"scalar":r=r.replace(l,"Y"+t.scalarArgs.indexOf(o));break;case"index":r=r.replace(l,"index");break;case"shape":r=r.replace(l,"shape");break}}}return[n.join(`
|
5 | `),r,s.join(`
|
6 | `)].join(`
|
7 | `).trim()}function L7(i){for(var t=new Array(i.length),e=!0,r=0;r<i.length;++r){var n=i[r],s=n.match(/\d+/);s?s=s[0]:s="",n.charAt(0)===0?t[r]="u"+n.charAt(1)+s:t[r]=n.charAt(0)+s,r>0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function N7(i,t){for(var e=t[1].length-Math.abs(i.arrayBlockIndices[0])|0,r=new Array(i.arrayArgs.length),n=new Array(i.arrayArgs.length),s=0;s<i.arrayArgs.length;++s)n[s]=t[2*s],r[s]=t[2*s+1];for(var o=[],a=[],l=[],u=[],c=[],s=0;s<i.arrayArgs.length;++s){i.arrayBlockIndices[s]<0?(l.push(0),u.push(e),o.push(e),a.push(e+i.arrayBlockIndices[s])):(l.push(i.arrayBlockIndices[s]),u.push(i.arrayBlockIndices[s]+e),o.push(0),a.push(i.arrayBlockIndices[s]));for(var h=[],d=0;d<r[s].length;d++)l[s]<=r[s][d]&&r[s][d]<u[s]&&h.push(r[s][d]-l[s]);c.push(h)}for(var f=["SS"],p=["'use strict'"],m=[],d=0;d<e;++d)m.push(["s",d,"=SS[",d,"]"].join(""));for(var s=0;s<i.arrayArgs.length;++s){f.push("a"+s),f.push("t"+s),f.push("p"+s);for(var d=0;d<e;++d)m.push(["t",s,"p",d,"=t",s,"[",l[s]+d,"]"].join(""));for(var d=0;d<Math.abs(i.arrayBlockIndices[s]);++d)m.push(["t",s,"b",d,"=t",s,"[",o[s]+d,"]"].join(""))}for(var s=0;s<i.scalarArgs.length;++s)f.push("Y"+s);if(i.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),i.indexArgs.length>0){for(var g=new Array(e),s=0;s<e;++s)g[s]="0";m.push(["index=[",g.join(","),"]"].join(""))}for(var s=0;s<i.offsetArgs.length;++s){for(var y=i.offsetArgs[s],v=[],d=0;d<y.offset.length;++d)y.offset[d]!==0&&(y.offset[d]===1?v.push(["t",y.array,"p",d].join("")):v.push([y.offset[d],"*t",y.array,"p",d].join("")));v.length===0?m.push("q"+s+"=0"):m.push(["q",s,"=",v.join("+")].join(""))}var x=I7([].concat(i.pre.thisVars).concat(i.body.thisVars).concat(i.post.thisVars));m=m.concat(x),m.length>0&&p.push("var "+m.join(","));for(var s=0;s<i.arrayArgs.length;++s)p.push("p"+s+"|=0");i.pre.body.length>3&&p.push(a1(i.pre,i,n));var w=a1(i.body,i,n),S=R7(c);S<e?p.push(O7(S,c[0],i,w)):p.push(sR(c[0],i,w)),i.post.body.length>3&&p.push(a1(i.post,i,n)),i.debug&&console.log("-----Generated cwise routine for ",t,`:
|
8 | `+p.join(`
|
9 | `)+`
|
10 | ----------`);var A=[i.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,L7(n)].join(""),E=new Function(["function ",A,"(",f.join(","),"){",p.join(`
|
11 | `),"} return ",A].join(""));return E()}oR.exports=N7});var cR=Gn(($Oe,lR)=>{"use strict";var B7=aR();function F7(i){var t=["'use strict'","var CACHED={}"],e=[],r=i.funcName+"_cwise_thunk";t.push(["return function ",r,"(",i.shimArgs.join(","),"){"].join(""));for(var n=[],s=[],o=[["array",i.arrayArgs[0],".shape.slice(",Math.max(0,i.arrayBlockIndices[0]),i.arrayBlockIndices[0]<0?","+i.arrayBlockIndices[0]+")":")"].join("")],a=[],l=[],u=0;u<i.arrayArgs.length;++u){var c=i.arrayArgs[u];e.push(["t",c,"=array",c,".dtype,","r",c,"=array",c,".order"].join("")),n.push("t"+c),n.push("r"+c),s.push("t"+c),s.push("r"+c+".join()"),o.push("array"+c+".data"),o.push("array"+c+".stride"),o.push("array"+c+".offset|0"),u>0&&(a.push("array"+i.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(i.arrayBlockIndices[0])-Math.abs(i.arrayBlockIndices[u]))),l.push("array"+i.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,i.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,i.arrayBlockIndices[u])+"]"))}i.arrayArgs.length>1&&(t.push("if (!("+a.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+i.arrayArgs[0]+".shape.length-"+Math.abs(i.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u<i.scalarArgs.length;++u)o.push("scalar"+i.scalarArgs[u]);e.push(["type=[",s.join(","),"].join()"].join("")),e.push("proc=CACHED[type]"),t.push("var "+e.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",n.join(","),"])}","return proc(",o.join(","),")}"].join("")),i.debug&&console.log(`-----Generated thunk:
|
12 | `+t.join(`
|
13 | `)+`
|
14 | ----------`);var h=new Function("compile",t.join(`
|
15 | `));return h(B7.bind(void 0,i))}lR.exports=F7});var hR=Gn((eRe,uR)=>{"use strict";var k7=cR();function V7(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function z7(i){var t=new V7;t.pre=i.pre,t.body=i.body,t.post=i.post;var e=i.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var n=e[r];if(n==="array"||typeof n=="object"&&n.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(n.blockIndices?n.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(n==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(n==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(n==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof n=="object"&&n.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:n.array,offset:n.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!i.printCode||!!i.debug,t.funcName=i.funcName||"cwise",t.blockSize=i.blockSize||64,k7(t)}uR.exports=z7});var Zd=Gn(bt=>{"use strict";var Ai=hR(),R0={body:"",args:[],thisVars:[],localVars:[]};function l1(i){if(!i)return R0;for(var t=0;t<i.args.length;++t){var e=i.args[t];t===0?i.args[t]={name:e,lvalue:!0,rvalue:!!i.rvalue,count:i.count||1}:i.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return i.thisVars||(i.thisVars=[]),i.localVars||(i.localVars=[]),i}function U7(i){return Ai({args:i.args,pre:l1(i.pre),body:l1(i.body),post:l1(i.proc),funcName:i.funcName})}function Sr(i){for(var t=[],e=0;e<i.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",i.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(U7(i))}var dR={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var i in dR){var t=dR[i];bt[i]=Sr({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:i}),bt[i+"eq"]=Sr({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:i+"eq"}),bt[i+"s"]=Sr({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:i+"s"}),bt[i+"seq"]=Sr({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:i+"seq"})}})();var fR={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var i in fR){var t=fR[i];bt[i]=Sr({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:i}),bt[i+"eq"]=Sr({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:i+"eq"})}})();var pR={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var i in pR){var t=pR[i];bt[i]=Sr({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:i}),bt[i+"s"]=Sr({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:i+"s"}),bt[i+"eq"]=Sr({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:i+"eq"}),bt[i+"seq"]=Sr({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:i+"seq"})}})();var mR=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;i<mR.length;++i){var t=mR[i];bt[t]=Sr({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),bt[t+"eq"]=Sr({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var gR=["max","min","atan2","pow"];(function(){for(var i=0;i<gR.length;++i){var t=gR[i];bt[t]=Sr({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),bt[t+"s"]=Sr({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),bt[t+"eq"]=Sr({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),bt[t+"seq"]=Sr({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var yR=["atan2","pow"];(function(){for(var i=0;i<yR.length;++i){var t=yR[i];bt[t+"op"]=Sr({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),bt[t+"ops"]=Sr({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),bt[t+"opeq"]=Sr({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),bt[t+"opseq"]=Sr({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();bt.any=Ai({args:["array"],pre:R0,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});bt.all=Ai({args:["array"],pre:R0,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});bt.sum=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});bt.prod=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});bt.norm2squared=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});bt.norm2=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});bt.norminf=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});bt.norm1=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});bt.sup=Ai({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});bt.inf=Ai({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});bt.argmin=Ai({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});bt.argmax=Ai({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});bt.random=Sr({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});bt.assign=Sr({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});bt.assigns=Sr({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});bt.equals=Ai({args:["array","array"],pre:R0,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var g3=Gn((RUe,m3)=>{m3.exports=function(t,e){for(var r=t.split("."),n=e.split("."),s=0;s<3;s++){var o=Number(r[s]),a=Number(n[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 Wo="149";var Oi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},I3=0,b_=1,O3=2;var Lg=1,R3=2,_f=3,Pi=0,Qr=1,Ln=2;var Vt=0,Aa=1,w_=2,S_=3,A_=4,L3=5,$c=100,N3=101,B3=102,__=103,E_=104,F3=200,k3=201,V3=202,z3=203,ZE=204,JE=205,U3=206,G3=207,H3=208,j3=209,W3=210,q3=0,Y3=1,X3=2,fb=3,Q3=4,K3=5,Z3=6,J3=7,$E=0,$3=1,eN=2,zo=0,tN=1,rN=2,nN=3,iN=4,sN=5,eM=300,Ea=301,Ma=302,pb=303,mb=304,Tu=306,ps=1e3,sr=1001,gb=1002,kt=1003,M_=1004;var Dx=1005;var Je=1006,oN=1007;var zl=1008;var lr=1009,aN=1010,lN=1011,tM=1012,cN=1013,fs=1014,Xr=1015,Uo=1016,uN=1017,hN=1018,_a=1020,dN=1021,$n=1023,fN=1024,pN=1025,kl=1026,Ta=1027,mN=1028,gN=1029,Cu=1030,yN=1031,Xb=1033,Ix=33776,Ox=33777,Rx=33778,Lx=33779,T_=35840,C_=35841,P_=35842,D_=35843,vN=36196,I_=37492,O_=37496,R_=37808,L_=37809,N_=37810,B_=37811,F_=37812,k_=37813,V_=37814,z_=37815,U_=37816,G_=37817,H_=37818,j_=37819,W_=37820,q_=37821,Nx=36492,xN=36283,Y_=36284,X_=36285,Q_=36286,Qb=2200,Kb=2201,qf=2202,lg=2300,cg=2301,Bx=2302,eu=2400,tu=2401,ug=2402,Zb=2500,bN=2501;var Di=3e3,et=3001,vn=3200,Jb=3201,wN=0,SN=1;var Us="srgb",If="srgb-linear";var Fx=7680;var AN=519,yb=35044,rM=35048;var K_="300 es",vb=1035,Yt=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 n=this._listeners[t];if(n!==void 0){let s=n.indexOf(e);s!==-1&&n.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 n=r.slice(0);for(let s=0,o=n.length;s<o;s++)n[s].call(this,t);t.target=null}}},Hn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Z_=1234567,Mf=Math.PI/180,Of=180/Math.PI;function Ui(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Hn[i&255]+Hn[i>>8&255]+Hn[i>>16&255]+Hn[i>>24&255]+"-"+Hn[t&255]+Hn[t>>8&255]+"-"+Hn[t>>16&15|64]+Hn[t>>24&255]+"-"+Hn[e&63|128]+Hn[e>>8&255]+"-"+Hn[e>>16&255]+Hn[e>>24&255]+Hn[r&255]+Hn[r>>8&255]+Hn[r>>16&255]+Hn[r>>24&255]).toLowerCase()}function Yr(i,t,e){return Math.max(t,Math.min(e,i))}function $b(i,t){return(i%t+t)%t}function _N(i,t,e,r,n){return r+(i-t)*(n-r)/(e-t)}function EN(i,t,e){return i!==t?(e-i)/(t-i):0}function Tf(i,t,e){return(1-e)*i+e*t}function MN(i,t,e,r){return Tf(i,t,1-Math.exp(-e*r))}function TN(i,t=1){return t-Math.abs($b(i,t*2)-t)}function CN(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function PN(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function DN(i,t){return i+Math.floor(Math.random()*(t-i+1))}function IN(i,t){return i+Math.random()*(t-i)}function ON(i){return i*(.5-Math.random())}function RN(i){i!==void 0&&(Z_=i);let t=Z_+=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 LN(i){return i*Mf}function NN(i){return i*Of}function xb(i){return(i&i-1)===0&&i!==0}function nM(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function hg(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function BN(i,t,e,r,n){let s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),u=s((t+r)/2),c=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(n){case"XYX":i.set(a*c,l*h,l*d,a*u);break;case"YZY":i.set(l*d,a*c,l*h,a*u);break;case"ZXZ":i.set(l*h,l*d,a*c,a*u);break;case"XZX":i.set(a*c,l*p,l*f,a*u);break;case"YXY":i.set(l*f,a*c,l*p,a*u);break;case"ZYZ":i.set(l*p,l*f,a*c,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Vo(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Kt(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Se=Object.freeze({__proto__:null,DEG2RAD:Mf,RAD2DEG:Of,ceilPowerOfTwo:nM,clamp:Yr,damp:MN,degToRad:LN,denormalize:Vo,euclideanModulo:$b,floorPowerOfTwo:hg,generateUUID:Ui,inverseLerp:EN,isPowerOfTwo:xb,lerp:Tf,mapLinear:_N,normalize:Kt,pingpong:TN,radToDeg:NN,randFloat:IN,randFloatSpread:ON,randInt:DN,seededRandom:RN,setQuaternionFromProperEuler:BN,smootherstep:PN,smoothstep:CN}),N=class{constructor(t=0,e=0){N.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,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[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),n=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*n+t.x,this.y=s*n+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Gt=class{constructor(){Gt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,r,n,s,o,a,l,u){let c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=u,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,n=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],u=r[1],c=r[4],h=r[7],d=r[2],f=r[5],p=r[8],m=n[0],g=n[3],y=n[6],v=n[1],x=n[4],w=n[7],S=n[2],A=n[5],E=n[8];return s[0]=o*m+a*v+l*S,s[3]=o*g+a*x+l*A,s[6]=o*y+a*w+l*E,s[1]=u*m+c*v+h*S,s[4]=u*g+c*x+h*A,s[7]=u*y+c*w+h*E,s[2]=d*m+f*v+p*S,s[5]=d*g+f*x+p*A,s[8]=d*y+f*w+p*E,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],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8];return e*o*c-e*a*u-r*s*c+r*a*l+n*s*u-n*o*l}invert(){let t=this.elements,e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=c*o-a*u,d=a*l-c*s,f=u*s-o*l,p=e*h+r*d+n*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]=(n*u-c*r)*m,t[2]=(a*r-n*o)*m,t[3]=d*m,t[4]=(c*e-n*l)*m,t[5]=(n*s-a*e)*m,t[6]=f*m,t[7]=(r*l-u*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,n,s,o,a){let l=Math.cos(s),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*o+u*a)+o+t,-n*u,n*l,-n*(-u*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(kx.makeScale(t,e)),this}rotate(t){return this.premultiply(kx.makeRotation(-t)),this}translate(t,e){return this.premultiply(kx.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 n=0;n<9;n++)if(e[n]!==r[n])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)}},kx=new Gt;function iM(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}var FN={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Lm(i,t){return new FN[i](t)}function dg(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Vl(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ag(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Vx={[Us]:{[If]:Vl},[If]:{[Us]:ag}},Kn={legacyMode:!0,get workingColorSpace(){return If},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.legacyMode||t===e||!t||!e)return i;if(Vx[t]&&Vx[t][e]!==void 0){let r=Vx[t][e];return i.r=r(i.r),i.g=r(i.g),i.b=r(i.b),i}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)}},sM={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},en={r:0,g:0,b:0},us={h:0,s:0,l:0},Nm={h:0,s:0,l:0};function zx(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}function Bm(i,t){return t.r=i.r,t.g=i.g,t.b=i.b,t}var Re=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=Us){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kn.toWorkingColorSpace(this,e),this}setRGB(t,e,r,n=Kn.workingColorSpace){return this.r=t,this.g=e,this.b=r,Kn.toWorkingColorSpace(this,n),this}setHSL(t,e,r,n=Kn.workingColorSpace){if(t=$b(t,1),e=Yr(e,0,1),r=Yr(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=zx(o,s,t+1/3),this.g=zx(o,s,t),this.b=zx(o,s,t-1/3)}return Kn.toWorkingColorSpace(this,n),this}setStyle(t,e=Us){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let s,o=n[1],a=n[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,Kn.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,Kn.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,u=parseFloat(s[2])/100,c=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,u,c,e)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=n[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,Kn.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,Kn.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=Us){let r=sM[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=Vl(t.r),this.g=Vl(t.g),this.b=Vl(t.b),this}copyLinearToSRGB(t){return this.r=ag(t.r),this.g=ag(t.g),this.b=ag(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Us){return Kn.fromWorkingColorSpace(Bm(this,en),t),Yr(en.r*255,0,255)<<16^Yr(en.g*255,0,255)<<8^Yr(en.b*255,0,255)<<0}getHexString(t=Us){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kn.workingColorSpace){Kn.fromWorkingColorSpace(Bm(this,en),e);let r=en.r,n=en.g,s=en.b,o=Math.max(r,n,s),a=Math.min(r,n,s),l,u,c=(a+o)/2;if(a===o)l=0,u=0;else{let h=o-a;switch(u=c<=.5?h/(o+a):h/(2-o-a),o){case r:l=(n-s)/h+(n<s?6:0);break;case n:l=(s-r)/h+2;break;case s:l=(r-n)/h+4;break}l/=6}return t.h=l,t.s=u,t.l=c,t}getRGB(t,e=Kn.workingColorSpace){return Kn.fromWorkingColorSpace(Bm(this,en),e),t.r=en.r,t.g=en.g,t.b=en.b,t}getStyle(t=Us){return Kn.fromWorkingColorSpace(Bm(this,en),t),t!==Us?`color(${t} ${en.r} ${en.g} ${en.b})`:`rgb(${en.r*255|0},${en.g*255|0},${en.b*255|0})`}offsetHSL(t,e,r){return this.getHSL(us),us.h+=t,us.s+=e,us.l+=r,this.setHSL(us.h,us.s,us.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(us),t.getHSL(Nm);let r=Tf(us.h,Nm.h,e),n=Tf(us.s,Nm.s,e),s=Tf(us.l,Nm.l,e);return this.setHSL(r,n,s),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Re.NAMES=sM;var Vc,fg=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Vc===void 0&&(Vc=dg("canvas")),Vc.width=t.width,Vc.height=t.height;let r=Vc.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=Vc}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=dg("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);let n=r.getImageData(0,0,t.width,t.height),s=n.data;for(let o=0;o<s.length;o++)s[o]=Vl(s[o]/255)*255;return r.putImageData(n,0,0),e}else if(t.data){let e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(Vl(e[r]/255)*255):e[r]=Vl(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},pg=class{constructor(t=null){this.isSource=!0,this.uuid=Ui(),this.data=t,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let r={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?s.push(Ux(n[o].image)):s.push(Ux(n[o]))}else s=Ux(n);r.url=s}return e||(t.images[this.uuid]=r),r}};function Ux(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?fg.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var kN=0,or=class extends Yt{constructor(t=or.DEFAULT_IMAGE,e=or.DEFAULT_MAPPING,r=sr,n=sr,s=Je,o=zl,a=$n,l=lr,u=or.DEFAULT_ANISOTROPY,c=Di){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kN++}),this.uuid=Ui(),this.name="",this.source=new pg(t),this.mipmaps=[],this.mapping=e,this.wrapS=r,this.wrapT=n,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=l,this.offset=new N(0,0),this.repeat=new N(1,1),this.center=new N(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Gt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==eM)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ps:t.x=t.x-Math.floor(t.x);break;case sr:t.x=t.x<0?0:1;break;case gb: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 ps:t.y=t.y-Math.floor(t.y);break;case sr:t.y=t.y<0?0:1;break;case gb: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)}};or.DEFAULT_IMAGE=null;or.DEFAULT_MAPPING=eM;or.DEFAULT_ANISOTROPY=1;var Xe=class{constructor(t=0,e=0,r=0,n=1){Xe.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=n}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,n){return this.x=t,this.y=e,this.z=r,this.w=n,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,n=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*n+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,n,s,l=t.elements,u=l[0],c=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(c-d)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(u+f+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let x=(u+1)/2,w=(f+1)/2,S=(y+1)/2,A=(c+d)/4,E=(h+m)/4,b=(p+g)/4;return x>w&&x>S?x<.01?(r=0,n=.707106781,s=.707106781):(r=Math.sqrt(x),n=A/r,s=E/r):w>S?w<.01?(r=.707106781,n=0,s=.707106781):(n=Math.sqrt(w),r=A/n,s=b/n):S<.01?(r=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),r=E/s,n=b/s),this.set(r,n,s,e),this}let v=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(h-m)/v,this.z=(d-c)/v,this.w=Math.acos((u+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}},ht=class extends Yt{constructor(t=1,e=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Xe(0,0,t,e),this.scissorTest=!1,this.viewport=new Xe(0,0,t,e);let n={width:t,height:e,depth:1};this.texture=new or(n,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:Je,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 pg(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"})}},mg=class extends or{constructor(t=null,e=1,r=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:r,depth:n},this.magFilter=kt,this.minFilter=kt,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var gg=class extends or{constructor(t=null,e=1,r=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:r,depth:n},this.magFilter=kt,this.minFilter=kt,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var yg=class extends ht{constructor(t=1,e=1,r=1,n={}){super(t,e,n),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let o=0;o<r;o++)this.texture[o]=s.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(t,e,r=1){if(this.width!==t||this.height!==e||this.depth!==r){this.width=t,this.height=e,this.depth=r;for(let n=0,s=this.texture.length;n<s;n++)this.texture[n].image.width=t,this.texture[n].image.height=e,this.texture[n].image.depth=r;this.dispose()}return this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e),this}copy(t){this.dispose(),this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,r=t.texture.length;e<r;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}},He=class{constructor(t=0,e=0,r=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=n}static slerpFlat(t,e,r,n,s,o,a){let l=r[n+0],u=r[n+1],c=r[n+2],h=r[n+3],d=s[o+0],f=s[o+1],p=s[o+2],m=s[o+3];if(a===0){t[e+0]=l,t[e+1]=u,t[e+2]=c,t[e+3]=h;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=m;return}if(h!==m||l!==d||u!==f||c!==p){let g=1-a,y=l*d+u*f+c*p+h*m,v=y>=0?1:-1,x=1-y*y;if(x>Number.EPSILON){let S=Math.sqrt(x),A=Math.atan2(S,y*v);g=Math.sin(g*A)/S,a=Math.sin(a*A)/S}let w=a*v;if(l=l*g+d*w,u=u*g+f*w,c=c*g+p*w,h=h*g+m*w,g===1-a){let S=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=S,u*=S,c*=S,h*=S}}t[e]=l,t[e+1]=u,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,n,s,o){let a=r[n],l=r[n+1],u=r[n+2],c=r[n+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+c*h+l*f-u*d,t[e+1]=l*p+c*d+u*h-a*f,t[e+2]=u*p+c*f+a*d-l*h,t[e+3]=c*p-a*h-l*d-u*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,n){return this._x=t,this._y=e,this._z=r,this._w=n,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,n=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,u=a(r/2),c=a(n/2),h=a(s/2),d=l(r/2),f=l(n/2),p=l(s/2);switch(o){case"XYZ":this._x=d*c*h+u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*h-d*f*p;break;case"YXZ":this._x=d*c*h+u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h+d*f*p;break;case"ZXY":this._x=d*c*h-u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*h-d*f*p;break;case"ZYX":this._x=d*c*h-u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h+d*f*p;break;case"YZX":this._x=d*c*h+u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h-d*f*p;break;case"XZY":this._x=d*c*h-u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*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,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],n=e[4],s=e[8],o=e[1],a=e[5],l=e[9],u=e[2],c=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=(c-l)*f,this._y=(s-u)*f,this._z=(o-n)*f}else if(r>a&&r>h){let f=2*Math.sqrt(1+r-a-h);this._w=(c-l)/f,this._x=.25*f,this._y=(n+o)/f,this._z=(s+u)/f}else if(a>h){let f=2*Math.sqrt(1+a-r-h);this._w=(s-u)/f,this._x=(n+o)/f,this._y=.25*f,this._z=(l+c)/f}else{let f=2*Math.sqrt(1+h-r-a);this._w=(o-n)/f,this._x=(s+u)/f,this._y=(l+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<Number.EPSILON?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Yr(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let n=Math.min(1,e/r);return this.slerp(t,n),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,n=t._y,s=t._z,o=t._w,a=e._x,l=e._y,u=e._z,c=e._w;return this._x=r*c+o*a+n*u-s*l,this._y=n*c+o*l+s*a-r*u,this._z=s*c+o*u+r*l-n*a,this._w=o*c-r*a-n*l-s*u,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,n=this._y,s=this._z,o=this._w,a=o*t._w+r*t._x+n*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=n,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*n+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,a),h=Math.sin((1-e)*c)/u,d=Math.sin(e*c)/u;return this._w=o*h+this._w*d,this._x=r*h+this._x*d,this._y=n*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),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(n),r*Math.sin(s),r*Math.cos(s),e*Math.sin(n))}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}},_=class{constructor(t=0,e=0,r=0){_.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(J_.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(J_.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,r=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*n,this.y=s[1]*e+s[4]*r+s[7]*n,this.z=s[2]*e+s[5]*r+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,r=this.y,n=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*n+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*n+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*n+s[14])*o,this}applyQuaternion(t){let e=this.x,r=this.y,n=this.z,s=t.x,o=t.y,a=t.z,l=t.w,u=l*e+o*n-a*r,c=l*r+a*e-s*n,h=l*n+s*r-o*e,d=-s*e-o*r-a*n;return this.x=u*l+d*-s+c*-a-h*-o,this.y=c*l+d*-o+h*-s-u*-a,this.z=h*l+d*-a+u*-o-c*-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,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*n,this.y=s[1]*e+s[5]*r+s[9]*n,this.z=s[2]*e+s[6]*r+s[10]*n,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,n=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=n*l-s*a,this.y=s*o-r*l,this.z=r*a-n*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 Gx.copy(this).projectOnVector(t),this.sub(Gx)}reflect(t){return this.sub(Gx.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(Yr(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}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 n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*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(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,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}},Gx=new _,J_=new He,Pt=class{constructor(t=new _(1/0,1/0,1/0),e=new _(-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,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=t.length;l<u;l+=3){let c=t[l],h=t[l+1],d=t[l+2];c<e&&(e=c),h<r&&(r=h),d<n&&(n=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,n),this.max.set(s,o,a),this}setFromBufferAttribute(t){let e=1/0,r=1/0,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=t.count;l<u;l++){let c=t.getX(l),h=t.getY(l),d=t.getZ(l);c<e&&(e=c),h<r&&(r=h),d<n&&(n=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,n),this.max.set(s,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=Rl.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let r=t.geometry;if(r!==void 0)if(e&&r.attributes!=null&&r.attributes.position!==void 0){let s=r.attributes.position;for(let o=0,a=s.count;o<a;o++)Rl.fromBufferAttribute(s,o).applyMatrix4(t.matrixWorld),this.expandByPoint(Rl)}else r.boundingBox===null&&r.computeBoundingBox(),Hx.copy(r.boundingBox),Hx.applyMatrix4(t.matrixWorld),this.union(Hx);let n=t.children;for(let s=0,o=n.length;s<o;s++)this.expandByObject(n[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Rl),Rl.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(gf),Fm.subVectors(this.max,gf),zc.subVectors(t.a,gf),Uc.subVectors(t.b,gf),Gc.subVectors(t.c,gf),va.subVectors(Uc,zc),xa.subVectors(Gc,Uc),Ll.subVectors(zc,Gc);let e=[0,-va.z,va.y,0,-xa.z,xa.y,0,-Ll.z,Ll.y,va.z,0,-va.x,xa.z,0,-xa.x,Ll.z,0,-Ll.x,-va.y,va.x,0,-xa.y,xa.x,0,-Ll.y,Ll.x,0];return!jx(e,zc,Uc,Gc,Fm)||(e=[1,0,0,0,1,0,0,0,1],!jx(e,zc,Uc,Gc,Fm))?!1:(km.crossVectors(va,xa),e=[km.x,km.y,km.z],jx(e,zc,Uc,Gc,Fm))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Rl.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=this.getSize(Rl).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:(Oo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Oo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Oo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Oo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Oo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Oo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Oo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Oo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Oo),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)}},Oo=[new _,new _,new _,new _,new _,new _,new _,new _],Rl=new _,Hx=new Pt,zc=new _,Uc=new _,Gc=new _,va=new _,xa=new _,Ll=new _,gf=new _,Fm=new _,km=new _,Nl=new _;function jx(i,t,e,r,n){for(let s=0,o=i.length-3;s<=o;s+=3){Nl.fromArray(i,s);let a=n.x*Math.abs(Nl.x)+n.y*Math.abs(Nl.y)+n.z*Math.abs(Nl.z),l=t.dot(Nl),u=e.dot(Nl),c=r.dot(Nl);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>a)return!1}return!0}var VN=new Pt,yf=new _,Wx=new _,fr=class{constructor(t=new _,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):VN.setFromPoints(t).getCenter(r);let n=0;for(let s=0,o=t.length;s<o;s++)n=Math.max(n,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;yf.subVectors(t,this.center);let e=yf.lengthSq();if(e>this.radius*this.radius){let r=Math.sqrt(e),n=(r-this.radius)*.5;this.center.addScaledVector(yf,n/r),this.radius+=n}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):(Wx.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(yf.copy(t.center).add(Wx)),this.expandByPoint(yf.copy(t.center).sub(Wx))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Ro=new _,qx=new _,Vm=new _,ba=new _,Yx=new _,zm=new _,Xx=new _,ms=class{constructor(t=new _,e=new _(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,Ro)),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=Ro.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ro.copy(this.direction).multiplyScalar(e).add(this.origin),Ro.distanceToSquared(t))}distanceSqToSegment(t,e,r,n){qx.copy(t).add(e).multiplyScalar(.5),Vm.copy(e).sub(t).normalize(),ba.copy(this.origin).sub(qx);let s=t.distanceTo(e)*.5,o=-this.direction.dot(Vm),a=ba.dot(this.direction),l=-ba.dot(Vm),u=ba.lengthSq(),c=Math.abs(1-o*o),h,d,f,p;if(c>0)if(h=o*l-a,d=o*a-l,p=s*c,h>=0)if(d>=-p)if(d<=p){let m=1/c;h*=m,d*=m,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+u}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;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)+u):d<=p?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+u):(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)+u);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;return r&&r.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(Vm).multiplyScalar(d).add(qx),f}intersectSphere(t,e){Ro.subVectors(t.center,this.origin);let r=Ro.dot(this.direction),n=Ro.dot(Ro)-r*r,s=t.radius*t.radius;if(n>s)return null;let o=Math.sqrt(s-n),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,n,s,o,a,l,u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return u>=0?(r=(t.min.x-d.x)*u,n=(t.max.x-d.x)*u):(r=(t.max.x-d.x)*u,n=(t.min.x-d.x)*u),c>=0?(s=(t.min.y-d.y)*c,o=(t.max.y-d.y)*c):(s=(t.max.y-d.y)*c,o=(t.min.y-d.y)*c),r>o||s>n||((s>r||isNaN(r))&&(r=s),(o<n||isNaN(n))&&(n=o),h>=0?(a=(t.min.z-d.z)*h,l=(t.max.z-d.z)*h):(a=(t.max.z-d.z)*h,l=(t.min.z-d.z)*h),r>l||a>n)||((a>r||r!==r)&&(r=a),(l<n||n!==n)&&(n=l),n<0)?null:this.at(r>=0?r:n,e)}intersectsBox(t){return this.intersectBox(t,Ro)!==null}intersectTriangle(t,e,r,n,s){Yx.subVectors(e,t),zm.subVectors(r,t),Xx.crossVectors(Yx,zm);let o=this.direction.dot(Xx),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ba.subVectors(this.origin,t);let l=a*this.direction.dot(zm.crossVectors(ba,zm));if(l<0)return null;let u=a*this.direction.dot(Yx.cross(ba));if(u<0||l+u>o)return null;let c=-a*ba.dot(Xx);return c<0?null:this.at(c/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)}},ie=class{constructor(){ie.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,n,s,o,a,l,u,c,h,d,f,p,m,g){let y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=n,y[1]=s,y[5]=o,y[9]=a,y[13]=l,y[2]=u,y[6]=c,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 ie().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,n=1/Hc.setFromMatrixColumn(t,0).length(),s=1/Hc.setFromMatrixColumn(t,1).length(),o=1/Hc.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,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,n=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(n),u=Math.sin(n),c=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*c,f=o*h,p=a*c,m=a*h;e[0]=l*c,e[4]=-l*h,e[8]=u,e[1]=f+p*u,e[5]=d-m*u,e[9]=-a*l,e[2]=m-d*u,e[6]=p+f*u,e[10]=o*l}else if(t.order==="YXZ"){let d=l*c,f=l*h,p=u*c,m=u*h;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*u,e[1]=o*h,e[5]=o*c,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*c,f=l*h,p=u*c,m=u*h;e[0]=d-m*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*c,e[9]=m-d*a,e[2]=-o*u,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){let d=o*c,f=o*h,p=a*c,m=a*h;e[0]=l*c,e[4]=p*u-f,e[8]=d*u+m,e[1]=l*h,e[5]=m*u+d,e[9]=f*u-p,e[2]=-u,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){let d=o*l,f=o*u,p=a*l,m=a*u;e[0]=l*c,e[4]=m-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*c,e[9]=-a*c,e[2]=-u*c,e[6]=f*h+p,e[10]=d-m*h}else if(t.order==="XZY"){let d=o*l,f=o*u,p=a*l,m=a*u;e[0]=l*c,e[4]=-h,e[8]=u*c,e[1]=d*h+m,e[5]=o*c,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*c,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(zN,t,UN)}lookAt(t,e,r){let n=this.elements;return Ti.subVectors(t,e),Ti.lengthSq()===0&&(Ti.z=1),Ti.normalize(),wa.crossVectors(r,Ti),wa.lengthSq()===0&&(Math.abs(r.z)===1?Ti.x+=1e-4:Ti.z+=1e-4,Ti.normalize(),wa.crossVectors(r,Ti)),wa.normalize(),Um.crossVectors(Ti,wa),n[0]=wa.x,n[4]=Um.x,n[8]=Ti.x,n[1]=wa.y,n[5]=Um.y,n[9]=Ti.y,n[2]=wa.z,n[6]=Um.z,n[10]=Ti.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,n=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],u=r[12],c=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],w=r[11],S=r[15],A=n[0],E=n[4],b=n[8],M=n[12],T=n[1],C=n[5],P=n[9],D=n[13],I=n[2],R=n[6],V=n[10],k=n[14],z=n[3],G=n[7],H=n[11],Q=n[15];return s[0]=o*A+a*T+l*I+u*z,s[4]=o*E+a*C+l*R+u*G,s[8]=o*b+a*P+l*V+u*H,s[12]=o*M+a*D+l*k+u*Q,s[1]=c*A+h*T+d*I+f*z,s[5]=c*E+h*C+d*R+f*G,s[9]=c*b+h*P+d*V+f*H,s[13]=c*M+h*D+d*k+f*Q,s[2]=p*A+m*T+g*I+y*z,s[6]=p*E+m*C+g*R+y*G,s[10]=p*b+m*P+g*V+y*H,s[14]=p*M+m*D+g*k+y*Q,s[3]=v*A+x*T+w*I+S*z,s[7]=v*E+x*C+w*R+S*G,s[11]=v*b+x*P+w*V+S*H,s[15]=v*M+x*D+w*k+S*Q,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],n=t[8],s=t[12],o=t[1],a=t[5],l=t[9],u=t[13],c=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-n*u*h-s*a*d+r*u*d+n*a*f-r*l*f)+m*(+e*l*f-e*u*d+s*o*d-n*o*f+n*u*c-s*l*c)+g*(+e*u*h-e*a*f-s*o*h+r*o*f+s*a*c-r*u*c)+y*(-n*a*c-e*l*h+e*a*d+n*o*h-r*o*d+r*l*c)}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 n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){let t=this.elements,e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=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*u-m*d*u+m*l*f-a*g*f-h*l*y+a*d*y,x=p*d*u-c*g*u-p*l*f+o*g*f+c*l*y-o*d*y,w=c*m*u-p*h*u+p*a*f-o*m*f-c*a*y+o*h*y,S=p*h*l-c*m*l-p*a*d+o*m*d+c*a*g-o*h*g,A=e*v+r*x+n*w+s*S;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/A;return t[0]=v*E,t[1]=(m*d*s-h*g*s-m*n*f+r*g*f+h*n*y-r*d*y)*E,t[2]=(a*g*s-m*l*s+m*n*u-r*g*u-a*n*y+r*l*y)*E,t[3]=(h*l*s-a*d*s-h*n*u+r*d*u+a*n*f-r*l*f)*E,t[4]=x*E,t[5]=(c*g*s-p*d*s+p*n*f-e*g*f-c*n*y+e*d*y)*E,t[6]=(p*l*s-o*g*s-p*n*u+e*g*u+o*n*y-e*l*y)*E,t[7]=(o*d*s-c*l*s+c*n*u-e*d*u-o*n*f+e*l*f)*E,t[8]=w*E,t[9]=(p*h*s-c*m*s-p*r*f+e*m*f+c*r*y-e*h*y)*E,t[10]=(o*m*s-p*a*s+p*r*u-e*m*u-o*r*y+e*a*y)*E,t[11]=(c*a*s-o*h*s-c*r*u+e*h*u+o*r*f-e*a*f)*E,t[12]=S*E,t[13]=(c*m*n-p*h*n+p*r*d-e*m*d-c*r*g+e*h*g)*E,t[14]=(p*a*n-o*m*n-p*r*l+e*m*l+o*r*g-e*a*g)*E,t[15]=(o*h*n-c*a*n+c*r*l-e*h*l-o*r*d+e*a*d)*E,this}scale(t){let e=this.elements,r=t.x,n=t.y,s=t.z;return e[0]*=r,e[4]*=n,e[8]*=s,e[1]*=r,e[5]*=n,e[9]*=s,e[2]*=r,e[6]*=n,e[10]*=s,e[3]*=r,e[7]*=n,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],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}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),n=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,u=s*o,c=s*a;return this.set(u*o+r,u*a-n*l,u*l+n*a,0,u*a+n*l,c*a+r,c*l-n*o,0,u*l-n*a,c*l+n*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,n,s,o){return this.set(1,r,s,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){let n=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,u=s+s,c=o+o,h=a+a,d=s*u,f=s*c,p=s*h,m=o*c,g=o*h,y=a*h,v=l*u,x=l*c,w=l*h,S=r.x,A=r.y,E=r.z;return n[0]=(1-(m+y))*S,n[1]=(f+w)*S,n[2]=(p-x)*S,n[3]=0,n[4]=(f-w)*A,n[5]=(1-(d+y))*A,n[6]=(g+v)*A,n[7]=0,n[8]=(p+x)*E,n[9]=(g-v)*E,n[10]=(1-(d+m))*E,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){let n=this.elements,s=Hc.set(n[0],n[1],n[2]).length(),o=Hc.set(n[4],n[5],n[6]).length(),a=Hc.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],hs.copy(this);let u=1/s,c=1/o,h=1/a;return hs.elements[0]*=u,hs.elements[1]*=u,hs.elements[2]*=u,hs.elements[4]*=c,hs.elements[5]*=c,hs.elements[6]*=c,hs.elements[8]*=h,hs.elements[9]*=h,hs.elements[10]*=h,e.setFromRotationMatrix(hs),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,n,s,o){let a=this.elements,l=2*s/(e-t),u=2*s/(r-n),c=(e+t)/(e-t),h=(r+n)/(r-n),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=u,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,n,s,o){let a=this.elements,l=1/(e-t),u=1/(r-n),c=1/(o-s),h=(e+t)*l,d=(r+n)*u,f=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*u,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,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 n=0;n<16;n++)if(e[n]!==r[n])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}},Hc=new _,hs=new ie,zN=new _(0,0,0),UN=new _(1,1,1),wa=new _,Um=new _,Ti=new _,$_=new ie,eE=new He,Zt=class{constructor(t=0,e=0,r=0,n=Zt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}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,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,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 n=t.elements,s=n[0],o=n[4],a=n[8],l=n[1],u=n[5],c=n[9],h=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(Yr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Yr(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Yr(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Yr(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,u));break;case"YZX":this._z=Math.asin(Yr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Yr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,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 $_.makeRotationFromQuaternion(t),this.setFromRotationMatrix($_,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return eE.setFromEuler(this),this.setFromQuaternion(eE,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}};Zt.DEFAULT_ORDER="XYZ";var Rf=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},GN=0,tE=new _,jc=new He,Lo=new ie,Gm=new _,vf=new _,HN=new _,jN=new He,rE=new _(1,0,0),nE=new _(0,1,0),iE=new _(0,0,1),WN={type:"added"},sE={type:"removed"},gt=class extends Yt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:GN++}),this.uuid=Ui(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let t=new _,e=new Zt,r=new He,n=new _(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new ie},normalMatrix:{value:new Gt}}),this.matrix=new ie,this.matrixWorld=new ie,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Rf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return jc.setFromAxisAngle(t,e),this.quaternion.multiply(jc),this}rotateOnWorldAxis(t,e){return jc.setFromAxisAngle(t,e),this.quaternion.premultiply(jc),this}rotateX(t){return this.rotateOnAxis(rE,t)}rotateY(t){return this.rotateOnAxis(nE,t)}rotateZ(t){return this.rotateOnAxis(iE,t)}translateOnAxis(t,e){return tE.copy(t).applyQuaternion(this.quaternion),this.position.add(tE.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(rE,t)}translateY(t){return this.translateOnAxis(nE,t)}translateZ(t){return this.translateOnAxis(iE,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Lo.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?Gm.copy(t):Gm.set(t,e,r);let n=this.parent;this.updateWorldMatrix(!0,!1),vf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Lo.lookAt(vf,Gm,this.up):Lo.lookAt(Gm,vf,this.up),this.quaternion.setFromRotationMatrix(Lo),n&&(Lo.extractRotation(n.matrixWorld),jc.setFromRotationMatrix(Lo),this.quaternion.premultiply(jc.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(WN)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(sE)),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){let e=this.children[t];e.parent=null,e.dispatchEvent(sE)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),Lo.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Lo.multiply(t.parent.matrixWorld)),t.applyMatrix4(Lo),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,n=this.children.length;r<n;r++){let o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e){let r=[];this[t]===e&&r.push(this);for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectsByProperty(t,e);o.length>0&&(r=r.concat(o))}return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vf,t,HN),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vf,jN,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,n=e.length;r<n;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let r=0,n=e.length;r<n;r++)e[r].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let r=0,n=e.length;r<n;r++){let s=e[r];(s.matrixWorldAutoUpdate===!0||t===!0)&&s.updateMatrixWorld(t)}}updateWorldMatrix(t,e){let r=this.parent;if(t===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){let n=this.children;for(let s=0,o=n.length;s<o;s++){let a=n[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){let e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.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?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.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 u=0,c=l.length;u<c;u++){let h=l[u];s(t.shapes,h)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,u=this.material.length;l<u;l++)a.push(s(t.materials,this.material[l]));n.material=a}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];n.animations.push(s(t.animations,l))}}if(e){let a=o(t.geometries),l=o(t.materials),u=o(t.textures),c=o(t.images),h=o(t.shapes),d=o(t.skeletons),f=o(t.animations),p=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),c.length>0&&(r.images=c),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=n,r;function o(a){let l=[];for(let u in a){let c=a[u];delete c.metadata,l.push(c)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){let n=t.children[r];this.add(n.clone())}return this}};gt.DEFAULT_UP=new _(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var ds=new _,No=new _,Qx=new _,Bo=new _,Wc=new _,qc=new _,oE=new _,Kx=new _,Zx=new _,Jx=new _,dr=class{constructor(t=new _,e=new _,r=new _){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,n){n.subVectors(r,e),ds.subVectors(t,e),n.cross(ds);let s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,r,n,s){ds.subVectors(n,e),No.subVectors(r,e),Qx.subVectors(t,e);let o=ds.dot(ds),a=ds.dot(No),l=ds.dot(Qx),u=No.dot(No),c=No.dot(Qx),h=o*u-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(u*l-a*c)*d,p=(o*c-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,r,n){return this.getBarycoord(t,e,r,n,Bo),Bo.x>=0&&Bo.y>=0&&Bo.x+Bo.y<=1}static getUV(t,e,r,n,s,o,a,l){return this.getBarycoord(t,e,r,n,Bo),l.set(0,0),l.addScaledVector(s,Bo.x),l.addScaledVector(o,Bo.y),l.addScaledVector(a,Bo.z),l}static isFrontFacing(t,e,r,n){return ds.subVectors(r,e),No.subVectors(t,e),ds.cross(No).dot(n)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,r,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,n),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 ds.subVectors(this.c,this.b),No.subVectors(this.a,this.b),ds.cross(No).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return dr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return dr.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,n,s){return dr.getUV(t,this.a,this.b,this.c,e,r,n,s)}containsPoint(t){return dr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return dr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let r=this.a,n=this.b,s=this.c,o,a;Wc.subVectors(n,r),qc.subVectors(s,r),Kx.subVectors(t,r);let l=Wc.dot(Kx),u=qc.dot(Kx);if(l<=0&&u<=0)return e.copy(r);Zx.subVectors(t,n);let c=Wc.dot(Zx),h=qc.dot(Zx);if(c>=0&&h<=c)return e.copy(n);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return o=l/(l-c),e.copy(r).addScaledVector(Wc,o);Jx.subVectors(t,s);let f=Wc.dot(Jx),p=qc.dot(Jx);if(p>=0&&f<=p)return e.copy(s);let m=f*u-l*p;if(m<=0&&u>=0&&p<=0)return a=u/(u-p),e.copy(r).addScaledVector(qc,a);let g=c*p-f*h;if(g<=0&&h-c>=0&&f-p>=0)return oE.subVectors(s,n),a=(h-c)/(h-c+(f-p)),e.copy(n).addScaledVector(oE,a);let y=1/(g+m+d);return o=m*y,a=d*y,e.copy(r).addScaledVector(Wc,o).addScaledVector(qc,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},qN=0,Ul=class extends Yt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:qN++}),this.uuid=Ui(),this.name="",this.type="Material",this.blending=Aa,this.side=Pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=ZE,this.blendDst=JE,this.blendEquation=$c,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=fb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AN,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Fx,this.stencilZFail=Fx,this.stencilZPass=Fx,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 n=this[e];if(n===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.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!==Aa&&(r.blending=this.blending),this.side!==Pi&&(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 n(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(e){let s=n(t.textures),o=n(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 n=e.length;r=new Array(n);for(let s=0;s!==n;++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++}},Go=class extends Ul{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Re(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=$E,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}},qr=new _,Hm=new N,Ge=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=yb,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 n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[r+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)Hm.fromBufferAttribute(this,e),Hm.applyMatrix3(t),this.setXY(e,Hm.x,Hm.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)qr.fromBufferAttribute(this,e),qr.applyMatrix3(t),this.setXYZ(e,qr.x,qr.y,qr.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)qr.fromBufferAttribute(this,e),qr.applyMatrix4(t),this.setXYZ(e,qr.x,qr.y,qr.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)qr.fromBufferAttribute(this,e),qr.applyNormalMatrix(t),this.setXYZ(e,qr.x,qr.y,qr.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)qr.fromBufferAttribute(this,e),qr.transformDirection(t),this.setXYZ(e,qr.x,qr.y,qr.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Vo(e,this.array)),e}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Vo(e,this.array)),e}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Vo(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Vo(e,this.array)),e}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,n){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array),s=Kt(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==yb&&(t.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(t.updateRange=this.updateRange),t}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}};var vg=class extends Ge{constructor(t,e,r){super(new Uint16Array(t),e,r)}};var js=class extends Ge{constructor(t,e,r){super(new Uint32Array(t),e,r)}};var be=class extends Ge{constructor(t,e,r){super(new Float32Array(t),e,r)}};var YN=0,zi=new ie,$x=new gt,Yc=new _,Ci=new Pt,xf=new Pt,gn=new _,Ae=class extends Yt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:YN++}),this.uuid=Ui(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(iM(t)?js:vg)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let r=this.attributes.normal;if(r!==void 0){let s=new Gt().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}let n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return zi.makeRotationFromQuaternion(t),this.applyMatrix4(zi),this}rotateX(t){return zi.makeRotationX(t),this.applyMatrix4(zi),this}rotateY(t){return zi.makeRotationY(t),this.applyMatrix4(zi),this}rotateZ(t){return zi.makeRotationZ(t),this.applyMatrix4(zi),this}translate(t,e,r){return zi.makeTranslation(t,e,r),this.applyMatrix4(zi),this}scale(t,e,r){return zi.makeScale(t,e,r),this.applyMatrix4(zi),this}lookAt(t){return $x.lookAt(t),$x.updateMatrix(),this.applyMatrix4($x.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yc).negate(),this.translate(Yc.x,Yc.y,Yc.z),this}setFromPoints(t){let e=[];for(let r=0,n=t.length;r<n;r++){let s=t[r];e.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new be(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pt);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new _(-1/0,-1/0,-1/0),new _(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,n=e.length;r<n;r++){let s=e[r];Ci.setFromBufferAttribute(s),this.morphTargetsRelative?(gn.addVectors(this.boundingBox.min,Ci.min),this.boundingBox.expandByPoint(gn),gn.addVectors(this.boundingBox.max,Ci.max),this.boundingBox.expandByPoint(gn)):(this.boundingBox.expandByPoint(Ci.min),this.boundingBox.expandByPoint(Ci.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fr);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new _,1/0);return}if(t){let r=this.boundingSphere.center;if(Ci.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){let a=e[s];xf.setFromBufferAttribute(a),this.morphTargetsRelative?(gn.addVectors(Ci.min,xf.min),Ci.expandByPoint(gn),gn.addVectors(Ci.max,xf.max),Ci.expandByPoint(gn)):(Ci.expandByPoint(xf.min),Ci.expandByPoint(xf.max))}Ci.getCenter(r);let n=0;for(let s=0,o=t.count;s<o;s++)gn.fromBufferAttribute(t,s),n=Math.max(n,r.distanceToSquared(gn));if(e)for(let s=0,o=e.length;s<o;s++){let a=e[s],l=this.morphTargetsRelative;for(let u=0,c=a.count;u<c;u++)gn.fromBufferAttribute(a,u),l&&(Yc.fromBufferAttribute(t,u),gn.add(Yc)),n=Math.max(n,r.distanceToSquared(gn))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let r=t.array,n=e.position.array,s=e.normal.array,o=e.uv.array,a=n.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ge(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,u=[],c=[];for(let T=0;T<a;T++)u[T]=new _,c[T]=new _;let h=new _,d=new _,f=new _,p=new N,m=new N,g=new N,y=new _,v=new _;function x(T,C,P){h.fromArray(n,T*3),d.fromArray(n,C*3),f.fromArray(n,P*3),p.fromArray(o,T*2),m.fromArray(o,C*2),g.fromArray(o,P*2),d.sub(h),f.sub(h),m.sub(p),g.sub(p);let D=1/(m.x*g.y-g.x*m.y);!isFinite(D)||(y.copy(d).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(D),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-g.x).multiplyScalar(D),u[T].add(y),u[C].add(y),u[P].add(y),c[T].add(v),c[C].add(v),c[P].add(v))}let w=this.groups;w.length===0&&(w=[{start:0,count:r.length}]);for(let T=0,C=w.length;T<C;++T){let P=w[T],D=P.start,I=P.count;for(let R=D,V=D+I;R<V;R+=3)x(r[R+0],r[R+1],r[R+2])}let S=new _,A=new _,E=new _,b=new _;function M(T){E.fromArray(s,T*3),b.copy(E);let C=u[T];S.copy(C),S.sub(E.multiplyScalar(E.dot(C))).normalize(),A.crossVectors(b,C);let D=A.dot(c[T])<0?-1:1;l[T*4]=S.x,l[T*4+1]=S.y,l[T*4+2]=S.z,l[T*4+3]=D}for(let T=0,C=w.length;T<C;++T){let P=w[T],D=P.start,I=P.count;for(let R=D,V=D+I;R<V;R+=3)M(r[R+0]),M(r[R+1]),M(r[R+2])}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ge(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let d=0,f=r.count;d<f;d++)r.setXYZ(d,0,0,0);let n=new _,s=new _,o=new _,a=new _,l=new _,u=new _,c=new _,h=new _;if(t)for(let d=0,f=t.count;d<f;d+=3){let p=t.getX(d+0),m=t.getX(d+1),g=t.getX(d+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),o.fromBufferAttribute(e,g),c.subVectors(o,s),h.subVectors(n,s),c.cross(h),a.fromBufferAttribute(r,p),l.fromBufferAttribute(r,m),u.fromBufferAttribute(r,g),a.add(c),l.add(c),u.add(c),r.setXYZ(p,a.x,a.y,a.z),r.setXYZ(m,l.x,l.y,l.z),r.setXYZ(g,u.x,u.y,u.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),c.subVectors(o,s),h.subVectors(n,s),c.cross(h),r.setXYZ(d+0,c.x,c.y,c.z),r.setXYZ(d+1,c.x,c.y,c.z),r.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),r.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){let t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)gn.fromBufferAttribute(t,e),gn.normalize(),t.setXYZ(e,gn.x,gn.y,gn.z)}toNonIndexed(){function t(a,l){let u=a.array,c=a.itemSize,h=a.normalized,d=new u.constructor(l.length*c),f=0,p=0;for(let m=0,g=l.length;m<g;m++){a.isInterleavedBufferAttribute?f=l[m]*a.data.stride+a.offset:f=l[m]*c;for(let y=0;y<c;y++)d[p++]=u[f++]}return new Ge(d,c,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new Ae,r=this.index.array,n=this.attributes;for(let a in n){let l=n[a],u=t(l,r);e.setAttribute(a,u)}let s=this.morphAttributes;for(let a in s){let l=[],u=s[a];for(let c=0,h=u.length;c<h;c++){let d=u[c],f=t(d,r);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let u=o[a];e.addGroup(u.start,u.count,u.materialIndex)}return e}toJSON(){let t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(t[u]=l[u]);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 u=r[l];t.data.attributes[l]=u.toJSON(t.data)}let n={},s=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],c=[];for(let h=0,d=u.length;h<d;h++){let f=u[h];c.push(f.toJSON(t.data))}c.length>0&&(n[l]=c,s=!0)}s&&(t.data.morphAttributes=n,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 n=t.attributes;for(let u in n){let c=n[u];this.setAttribute(u,c.clone(e))}let s=t.morphAttributes;for(let u in s){let c=[],h=s[u];for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone(e));this.morphAttributes[u]=c}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let u=0,c=o.length;u<c;u++){let h=o[u];this.addGroup(h.start,h.count,h.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,t.parameters!==void 0&&(this.parameters=Object.assign({},t.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},aE=new ie,Xc=new ms,eb=new fr,bf=new _,wf=new _,Sf=new _,tb=new _,jm=new _,Wm=new N,qm=new N,Ym=new N,rb=new _,Xm=new _,_r=class extends gt{constructor(t=new Ae,e=new Go){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){let r=this.geometry,n=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(n,t);let a=this.morphTargetInfluences;if(s&&a){jm.set(0,0,0);for(let l=0,u=s.length;l<u;l++){let c=a[l],h=s[l];c!==0&&(tb.fromBufferAttribute(h,t),o?jm.addScaledVector(tb,c):jm.addScaledVector(tb.sub(e),c))}e.add(jm)}return this.isSkinnedMesh&&this.boneTransform(t,e),e}raycast(t,e){let r=this.geometry,n=this.material,s=this.matrixWorld;if(n===void 0||(r.boundingSphere===null&&r.computeBoundingSphere(),eb.copy(r.boundingSphere),eb.applyMatrix4(s),t.ray.intersectsSphere(eb)===!1)||(aE.copy(s).invert(),Xc.copy(t.ray).applyMatrix4(aE),r.boundingBox!==null&&Xc.intersectsBox(r.boundingBox)===!1))return;let o,a=r.index,l=r.attributes.position,u=r.attributes.uv,c=r.attributes.uv2,h=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(n))for(let f=0,p=h.length;f<p;f++){let m=h[f],g=n[m.materialIndex],y=Math.max(m.start,d.start),v=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let x=y,w=v;x<w;x+=3){let S=a.getX(x),A=a.getX(x+1),E=a.getX(x+2);o=Qm(this,g,t,Xc,u,c,S,A,E),o&&(o.faceIndex=Math.floor(x/3),o.face.materialIndex=m.materialIndex,e.push(o))}}else{let f=Math.max(0,d.start),p=Math.min(a.count,d.start+d.count);for(let m=f,g=p;m<g;m+=3){let y=a.getX(m),v=a.getX(m+1),x=a.getX(m+2);o=Qm(this,n,t,Xc,u,c,y,v,x),o&&(o.faceIndex=Math.floor(m/3),e.push(o))}}else if(l!==void 0)if(Array.isArray(n))for(let f=0,p=h.length;f<p;f++){let m=h[f],g=n[m.materialIndex],y=Math.max(m.start,d.start),v=Math.min(l.count,Math.min(m.start+m.count,d.start+d.count));for(let x=y,w=v;x<w;x+=3){let S=x,A=x+1,E=x+2;o=Qm(this,g,t,Xc,u,c,S,A,E),o&&(o.faceIndex=Math.floor(x/3),o.face.materialIndex=m.materialIndex,e.push(o))}}else{let f=Math.max(0,d.start),p=Math.min(l.count,d.start+d.count);for(let m=f,g=p;m<g;m+=3){let y=m,v=m+1,x=m+2;o=Qm(this,n,t,Xc,u,c,y,v,x),o&&(o.faceIndex=Math.floor(m/3),e.push(o))}}}};function XN(i,t,e,r,n,s,o,a){let l;if(t.side===Qr?l=r.intersectTriangle(o,s,n,!0,a):l=r.intersectTriangle(n,s,o,t.side===Pi,a),l===null)return null;Xm.copy(a),Xm.applyMatrix4(i.matrixWorld);let u=e.ray.origin.distanceTo(Xm);return u<e.near||u>e.far?null:{distance:u,point:Xm.clone(),object:i}}function Qm(i,t,e,r,n,s,o,a,l){i.getVertexPosition(o,bf),i.getVertexPosition(a,wf),i.getVertexPosition(l,Sf);let u=XN(i,t,e,r,bf,wf,Sf,rb);if(u){n&&(Wm.fromBufferAttribute(n,o),qm.fromBufferAttribute(n,a),Ym.fromBufferAttribute(n,l),u.uv=dr.getUV(rb,bf,wf,Sf,Wm,qm,Ym,new N)),s&&(Wm.fromBufferAttribute(s,o),qm.fromBufferAttribute(s,a),Ym.fromBufferAttribute(s,l),u.uv2=dr.getUV(rb,bf,wf,Sf,Wm,qm,Ym,new N));let c={a:o,b:a,c:l,normal:new _,materialIndex:0};dr.getNormal(bf,wf,Sf,c.normal),u.face=c}return u}var yn=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o};let a=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=[],u=[],c=[],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,n,o,2),p("x","z","y",1,-1,t,r,-e,n,o,3),p("x","y","z",1,-1,t,e,r,n,s,4),p("x","y","z",-1,-1,t,e,-r,n,s,5),this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function p(m,g,y,v,x,w,S,A,E,b,M){let T=w/E,C=S/b,P=w/2,D=S/2,I=A/2,R=E+1,V=b+1,k=0,z=0,G=new _;for(let H=0;H<V;H++){let Q=H*C-D;for(let F=0;F<R;F++){let j=F*T-P;G[m]=j*v,G[g]=Q*x,G[y]=I,u.push(G.x,G.y,G.z),G[m]=0,G[g]=0,G[y]=A>0?1:-1,c.push(G.x,G.y,G.z),h.push(F/E),h.push(1-H/b),k+=1}}for(let H=0;H<b;H++)for(let Q=0;Q<E;Q++){let F=d+Q+R*H,j=d+Q+R*(H+1),Y=d+(Q+1)+R*(H+1),q=d+(Q+1)+R*H;l.push(F,j,q),l.push(j,Y,q),z+=6}a.addGroup(f,z,M),f+=z,d+=k}}static fromJSON(t){return new yn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function su(i){let t={};for(let e in i){t[e]={};for(let r in i[e]){let n=i[e][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)?t[e][r]=n.clone():Array.isArray(n)?t[e][r]=n.slice():t[e][r]=n}}return t}function Jn(i){let t={};for(let e=0;e<i.length;e++){let r=su(i[e]);for(let n in r)t[n]=r[n]}return t}function QN(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function oM(i){return i.getRenderTarget()===null&&i.outputEncoding===et?Us:If}var ys={clone:su,merge:Jn},KN=`void main() {
|
16 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
17 | }`,ZN=`void main() {
|
18 | gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
19 | }`,at=class extends Ul{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=KN,this.fragmentShader=ZN,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=su(t.uniforms),this.uniformsGroups=QN(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let n in this.uniforms){let o=this.uniforms[n].value;o&&o.isTexture?e.uniforms[n]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[n]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[n]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[n]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[n]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[n]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[n]={type:"m4",value:o.toArray()}:e.uniforms[n]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let r={};for(let n in this.extensions)this.extensions[n]===!0&&(r[n]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}},gs=class extends gt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ie,this.projectionMatrix=new ie,this.projectionMatrixInverse=new ie}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)}},Ir=class extends gs{constructor(t=50,e=1,r=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=n,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=Of*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Mf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Of*2*Math.atan(Math.tan(Mf*.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,n,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=n,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(Mf*.5*this.fov)/this.zoom,r=2*e,n=this.aspect*r,s=-.5*n,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,u=o.fullHeight;s+=o.offsetX*n/l,e-=o.offsetY*r/u,n*=o.width/l,r*=o.height/u}let a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,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}},Qc=-90,Kc=1,bb=class extends gt{constructor(t,e,r){super(),this.type="CubeCamera",this.renderTarget=r;let n=new Ir(Qc,Kc,t,e);n.layers=this.layers,n.up.set(0,1,0),n.lookAt(1,0,0),this.add(n);let s=new Ir(Qc,Kc,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let o=new Ir(Qc,Kc,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new Ir(Qc,Kc,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new Ir(Qc,Kc,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let u=new Ir(Qc,Kc,t,e);u.layers=this.layers,u.up.set(0,1,0),u.lookAt(0,0,-1),this.add(u)}update(t,e){this.parent===null&&this.updateMatrixWorld();let r=this.renderTarget,[n,s,o,a,l,u]=this.children,c=t.getRenderTarget(),h=t.toneMapping,d=t.xr.enabled;t.toneMapping=zo,t.xr.enabled=!1;let f=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,n),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,u),t.setRenderTarget(c),t.toneMapping=h,t.xr.enabled=d,r.texture.needsPMREMUpdate=!0}},ou=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){t=t!==void 0?t:[],e=e!==void 0?e:Ea,super(t,e,r,n,s,o,a,l,u,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},wb=class extends ht{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let r={width:t,height:t,depth:1},n=[r,r,r,r,r,r];this.texture=new ou(n,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:Je}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:`
|
20 |
|
21 | varying vec3 vWorldDirection;
|
22 |
|
23 | vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
24 |
|
25 | return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
26 |
|
27 | }
|
28 |
|
29 | void main() {
|
30 |
|
31 | vWorldDirection = transformDirection( position, modelMatrix );
|
32 |
|
33 | #include <begin_vertex>
|
34 | #include <project_vertex>
|
35 |
|
36 | }
|
37 | `,fragmentShader:`
|
38 |
|
39 | uniform sampler2D tEquirect;
|
40 |
|
41 | varying vec3 vWorldDirection;
|
42 |
|
43 | #include <common>
|
44 |
|
45 | void main() {
|
46 |
|
47 | vec3 direction = normalize( vWorldDirection );
|
48 |
|
49 | vec2 sampleUV = equirectUv( direction );
|
50 |
|
51 | gl_FragColor = texture2D( tEquirect, sampleUV );
|
52 |
|
53 | }
|
54 | `},n=new yn(5,5,5),s=new at({name:"CubemapFromEquirect",uniforms:su(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Qr,blending:Vt});s.uniforms.tEquirect.value=e;let o=new _r(n,s),a=e.minFilter;return e.minFilter===zl&&(e.minFilter=Je),new bb(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,r,n){let s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,r,n);t.setRenderTarget(s)}},nb=new _,JN=new _,$N=new Gt,Or=class{constructor(t=new _(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,n){return this.normal.set(t,e,r),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){let n=nb.subVectors(r,e).cross(JN.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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(nb),n=this.normal.dot(r);if(n===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let s=-(t.start.dot(this.normal)+this.constant)/n;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||$N.getNormalMatrix(t),n=this.coplanarPoint(nb).applyMatrix4(t),s=this.normal.applyMatrix3(r).normalize();return this.constant=-n.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)}},Zc=new fr,Km=new _,Lf=class{constructor(t=new Or,e=new Or,r=new Or,n=new Or,s=new Or,o=new Or){this.planes=[t,e,r,n,s,o]}set(t,e,r,n,s,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),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,n=r[0],s=r[1],o=r[2],a=r[3],l=r[4],u=r[5],c=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-n,h-l,m-d,x-g).normalize(),e[1].setComponents(a+n,h+l,m+d,x+g).normalize(),e[2].setComponents(a+s,h+u,m+f,x+y).normalize(),e[3].setComponents(a-s,h-u,m-f,x-y).normalize(),e[4].setComponents(a-o,h-c,m-p,x-v).normalize(),e[5].setComponents(a+o,h+c,m+p,x+v).normalize(),this}intersectsObject(t){let e=t.geometry;return e.boundingSphere===null&&e.computeBoundingSphere(),Zc.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Zc)}intersectsSprite(t){return Zc.center.set(0,0,0),Zc.radius=.7071067811865476,Zc.applyMatrix4(t.matrixWorld),this.intersectsSphere(Zc)}intersectsSphere(t){let e=this.planes,r=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(r)<n)return!1;return!0}intersectsBox(t){let e=this.planes;for(let r=0;r<6;r++){let n=e[r];if(Km.x=n.normal.x>0?t.max.x:t.min.x,Km.y=n.normal.y>0?t.max.y:t.min.y,Km.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Km)<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 aM(){let i=null,t=!1,e=null,r=null;function n(s,o){e(s,o),r=i.requestAnimationFrame(n)}return{start:function(){t!==!0&&e!==null&&(r=i.requestAnimationFrame(n),t=!0)},stop:function(){i.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function eB(i,t){let e=t.isWebGL2,r=new WeakMap;function n(u,c){let h=u.array,d=u.usage,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,h,d),u.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(u.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:u.version}}function s(u,c,h){let d=c.array,f=c.updateRange;i.bindBuffer(h,u),f.count===-1?i.bufferSubData(h,0,d):(e?i.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):i.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),c.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function a(u){u.isInterleavedBufferAttribute&&(u=u.data);let c=r.get(u);c&&(i.deleteBuffer(c.buffer),r.delete(u))}function l(u,c){if(u.isGLBufferAttribute){let d=r.get(u);(!d||d.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);let h=r.get(u);h===void 0?r.set(u,n(u,c)):h.version<u.version&&(s(h.buffer,u,c),h.version=u.version)}return{get:o,remove:a,update:l}}var Ho=class extends Ae{constructor(t=1,e=1,r=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:n};let s=t/2,o=e/2,a=Math.floor(r),l=Math.floor(n),u=a+1,c=l+1,h=t/a,d=e/l,f=[],p=[],m=[],g=[];for(let y=0;y<c;y++){let v=y*d-o;for(let x=0;x<u;x++){let w=x*h-s;p.push(w,-v,0),m.push(0,0,1),g.push(x/a),g.push(1-y/l)}}for(let y=0;y<l;y++)for(let v=0;v<a;v++){let x=v+u*y,w=v+u*(y+1),S=v+1+u*(y+1),A=v+1+u*y;f.push(x,w,A),f.push(w,S,A)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Ho(t.width,t.height,t.widthSegments,t.heightSegments)}},tB=`#ifdef USE_ALPHAMAP
|
55 | diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
56 | #endif`,rB=`#ifdef USE_ALPHAMAP
|
57 | uniform sampler2D alphaMap;
|
58 | #endif`,nB=`#ifdef USE_ALPHATEST
|
59 | if ( diffuseColor.a < alphaTest ) discard;
|
60 | #endif`,iB=`#ifdef USE_ALPHATEST
|
61 | uniform float alphaTest;
|
62 | #endif`,sB=`#ifdef USE_AOMAP
|
63 | float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
|
64 | reflectedLight.indirectDiffuse *= ambientOcclusion;
|
65 | #if defined( USE_ENVMAP ) && defined( STANDARD )
|
66 | float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
67 | reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
68 | #endif
|
69 | #endif`,oB=`#ifdef USE_AOMAP
|
70 | uniform sampler2D aoMap;
|
71 | uniform float aoMapIntensity;
|
72 | #endif`,aB="vec3 transformed = vec3( position );",lB=`vec3 objectNormal = vec3( normal );
|
73 | #ifdef USE_TANGENT
|
74 | vec3 objectTangent = vec3( tangent.xyz );
|
75 | #endif`,cB=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
76 | return RECIPROCAL_PI * diffuseColor;
|
77 | }
|
78 | vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
79 | float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
80 | return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
81 | }
|
82 | float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
83 | float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
84 | return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
85 | }
|
86 | vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
87 | float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
88 | float x2 = x * x;
|
89 | float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
90 | return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
91 | }
|
92 | float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
93 | float a2 = pow2( alpha );
|
94 | float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
95 | float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
96 | return 0.5 / max( gv + gl, EPSILON );
|
97 | }
|
98 | float D_GGX( const in float alpha, const in float dotNH ) {
|
99 | float a2 = pow2( alpha );
|
100 | float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
101 | return RECIPROCAL_PI * a2 / pow2( denom );
|
102 | }
|
103 | vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
|
104 | float alpha = pow2( roughness );
|
105 | vec3 halfDir = normalize( lightDir + viewDir );
|
106 | float dotNL = saturate( dot( normal, lightDir ) );
|
107 | float dotNV = saturate( dot( normal, viewDir ) );
|
108 | float dotNH = saturate( dot( normal, halfDir ) );
|
109 | float dotVH = saturate( dot( viewDir, halfDir ) );
|
110 | vec3 F = F_Schlick( f0, f90, dotVH );
|
111 | float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
112 | float D = D_GGX( alpha, dotNH );
|
113 | return F * ( V * D );
|
114 | }
|
115 | #ifdef USE_IRIDESCENCE
|
116 | vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {
|
117 | float alpha = pow2( roughness );
|
118 | vec3 halfDir = normalize( lightDir + viewDir );
|
119 | float dotNL = saturate( dot( normal, lightDir ) );
|
120 | float dotNV = saturate( dot( normal, viewDir ) );
|
121 | float dotNH = saturate( dot( normal, halfDir ) );
|
122 | float dotVH = saturate( dot( viewDir, halfDir ) );
|
123 | vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );
|
124 | float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
125 | float D = D_GGX( alpha, dotNH );
|
126 | return F * ( V * D );
|
127 | }
|
128 | #endif
|
129 | vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
130 | const float LUT_SIZE = 64.0;
|
131 | const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
132 | const float LUT_BIAS = 0.5 / LUT_SIZE;
|
133 | float dotNV = saturate( dot( N, V ) );
|
134 | vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
135 | uv = uv * LUT_SCALE + LUT_BIAS;
|
136 | return uv;
|
137 | }
|
138 | float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
139 | float l = length( f );
|
140 | return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
141 | }
|
142 | vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
143 | float x = dot( v1, v2 );
|
144 | float y = abs( x );
|
145 | float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
146 | float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
147 | float v = a / b;
|
148 | float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
149 | return cross( v1, v2 ) * theta_sintheta;
|
150 | }
|
151 | vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
152 | vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
153 | vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
154 | vec3 lightNormal = cross( v1, v2 );
|
155 | if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
156 | vec3 T1, T2;
|
157 | T1 = normalize( V - N * dot( V, N ) );
|
158 | T2 = - cross( N, T1 );
|
159 | mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
160 | vec3 coords[ 4 ];
|
161 | coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
162 | coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
163 | coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
164 | coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
165 | coords[ 0 ] = normalize( coords[ 0 ] );
|
166 | coords[ 1 ] = normalize( coords[ 1 ] );
|
167 | coords[ 2 ] = normalize( coords[ 2 ] );
|
168 | coords[ 3 ] = normalize( coords[ 3 ] );
|
169 | vec3 vectorFormFactor = vec3( 0.0 );
|
170 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
171 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
172 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
173 | vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
174 | float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
175 | return vec3( result );
|
176 | }
|
177 | float G_BlinnPhong_Implicit( ) {
|
178 | return 0.25;
|
179 | }
|
180 | float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
181 | return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
182 | }
|
183 | vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
184 | vec3 halfDir = normalize( lightDir + viewDir );
|
185 | float dotNH = saturate( dot( normal, halfDir ) );
|
186 | float dotVH = saturate( dot( viewDir, halfDir ) );
|
187 | vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
188 | float G = G_BlinnPhong_Implicit( );
|
189 | float D = D_BlinnPhong( shininess, dotNH );
|
190 | return F * ( G * D );
|
191 | }
|
192 | #if defined( USE_SHEEN )
|
193 | float D_Charlie( float roughness, float dotNH ) {
|
194 | float alpha = pow2( roughness );
|
195 | float invAlpha = 1.0 / alpha;
|
196 | float cos2h = dotNH * dotNH;
|
197 | float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
198 | return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
199 | }
|
200 | float V_Neubelt( float dotNV, float dotNL ) {
|
201 | return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
202 | }
|
203 | vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
204 | vec3 halfDir = normalize( lightDir + viewDir );
|
205 | float dotNL = saturate( dot( normal, lightDir ) );
|
206 | float dotNV = saturate( dot( normal, viewDir ) );
|
207 | float dotNH = saturate( dot( normal, halfDir ) );
|
208 | float D = D_Charlie( sheenRoughness, dotNH );
|
209 | float V = V_Neubelt( dotNV, dotNL );
|
210 | return sheenColor * ( D * V );
|
211 | }
|
212 | #endif`,uB=`#ifdef USE_IRIDESCENCE
|
213 | const mat3 XYZ_TO_REC709 = mat3(
|
214 | 3.2404542, -0.9692660, 0.0556434,
|
215 | -1.5371385, 1.8760108, -0.2040259,
|
216 | -0.4985314, 0.0415560, 1.0572252
|
217 | );
|
218 | vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
219 | vec3 sqrtF0 = sqrt( fresnel0 );
|
220 | return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
221 | }
|
222 | vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
223 | return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
224 | }
|
225 | float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
226 | return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
227 | }
|
228 | vec3 evalSensitivity( float OPD, vec3 shift ) {
|
229 | float phase = 2.0 * PI * OPD * 1.0e-9;
|
230 | vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
231 | vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
232 | vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
233 | vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
234 | 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 ) );
|
235 | xyz /= 1.0685e-7;
|
236 | vec3 rgb = XYZ_TO_REC709 * xyz;
|
237 | return rgb;
|
238 | }
|
239 | vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
240 | vec3 I;
|
241 | float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
242 | float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
243 | float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
244 | if ( cosTheta2Sq < 0.0 ) {
|
245 | return vec3( 1.0 );
|
246 | }
|
247 | float cosTheta2 = sqrt( cosTheta2Sq );
|
248 | float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
249 | float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
250 | float R21 = R12;
|
251 | float T121 = 1.0 - R12;
|
252 | float phi12 = 0.0;
|
253 | if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
254 | float phi21 = PI - phi12;
|
255 | vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
256 | vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
257 | vec3 phi23 = vec3( 0.0 );
|
258 | if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
259 | if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
260 | if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
261 | float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
262 | vec3 phi = vec3( phi21 ) + phi23;
|
263 | vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
264 | vec3 r123 = sqrt( R123 );
|
265 | vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
266 | vec3 C0 = R12 + Rs;
|
267 | I = C0;
|
268 | vec3 Cm = Rs - T121;
|
269 | for ( int m = 1; m <= 2; ++ m ) {
|
270 | Cm *= r123;
|
271 | vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
272 | I += Cm * Sm;
|
273 | }
|
274 | return max( I, vec3( 0.0 ) );
|
275 | }
|
276 | #endif`,hB=`#ifdef USE_BUMPMAP
|
277 | uniform sampler2D bumpMap;
|
278 | uniform float bumpScale;
|
279 | vec2 dHdxy_fwd() {
|
280 | vec2 dSTdx = dFdx( vUv );
|
281 | vec2 dSTdy = dFdy( vUv );
|
282 | float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
|
283 | float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
|
284 | float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
|
285 | return vec2( dBx, dBy );
|
286 | }
|
287 | vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
288 | vec3 vSigmaX = dFdx( surf_pos.xyz );
|
289 | vec3 vSigmaY = dFdy( surf_pos.xyz );
|
290 | vec3 vN = surf_norm;
|
291 | vec3 R1 = cross( vSigmaY, vN );
|
292 | vec3 R2 = cross( vN, vSigmaX );
|
293 | float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
294 | vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
295 | return normalize( abs( fDet ) * surf_norm - vGrad );
|
296 | }
|
297 | #endif`,dB=`#if NUM_CLIPPING_PLANES > 0
|
298 | vec4 plane;
|
299 | #pragma unroll_loop_start
|
300 | for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
301 | plane = clippingPlanes[ i ];
|
302 | if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
303 | }
|
304 | #pragma unroll_loop_end
|
305 | #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
306 | bool clipped = true;
|
307 | #pragma unroll_loop_start
|
308 | for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
309 | plane = clippingPlanes[ i ];
|
310 | clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
311 | }
|
312 | #pragma unroll_loop_end
|
313 | if ( clipped ) discard;
|
314 | #endif
|
315 | #endif`,fB=`#if NUM_CLIPPING_PLANES > 0
|
316 | varying vec3 vClipPosition;
|
317 | uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
318 | #endif`,pB=`#if NUM_CLIPPING_PLANES > 0
|
319 | varying vec3 vClipPosition;
|
320 | #endif`,mB=`#if NUM_CLIPPING_PLANES > 0
|
321 | vClipPosition = - mvPosition.xyz;
|
322 | #endif`,gB=`#if defined( USE_COLOR_ALPHA )
|
323 | diffuseColor *= vColor;
|
324 | #elif defined( USE_COLOR )
|
325 | diffuseColor.rgb *= vColor;
|
326 | #endif`,yB=`#if defined( USE_COLOR_ALPHA )
|
327 | varying vec4 vColor;
|
328 | #elif defined( USE_COLOR )
|
329 | varying vec3 vColor;
|
330 | #endif`,vB=`#if defined( USE_COLOR_ALPHA )
|
331 | varying vec4 vColor;
|
332 | #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
333 | varying vec3 vColor;
|
334 | #endif`,xB=`#if defined( USE_COLOR_ALPHA )
|
335 | vColor = vec4( 1.0 );
|
336 | #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
337 | vColor = vec3( 1.0 );
|
338 | #endif
|
339 | #ifdef USE_COLOR
|
340 | vColor *= color;
|
341 | #endif
|
342 | #ifdef USE_INSTANCING_COLOR
|
343 | vColor.xyz *= instanceColor.xyz;
|
344 | #endif`,bB=`#define PI 3.141592653589793
|
345 | #define PI2 6.283185307179586
|
346 | #define PI_HALF 1.5707963267948966
|
347 | #define RECIPROCAL_PI 0.3183098861837907
|
348 | #define RECIPROCAL_PI2 0.15915494309189535
|
349 | #define EPSILON 1e-6
|
350 | #ifndef saturate
|
351 | #define saturate( a ) clamp( a, 0.0, 1.0 )
|
352 | #endif
|
353 | #define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
354 | float pow2( const in float x ) { return x*x; }
|
355 | vec3 pow2( const in vec3 x ) { return x*x; }
|
356 | float pow3( const in float x ) { return x*x*x; }
|
357 | float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
358 | float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
359 | float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
360 | highp float rand( const in vec2 uv ) {
|
361 | const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
362 | highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
363 | return fract( sin( sn ) * c );
|
364 | }
|
365 | #ifdef HIGH_PRECISION
|
366 | float precisionSafeLength( vec3 v ) { return length( v ); }
|
367 | #else
|
368 | float precisionSafeLength( vec3 v ) {
|
369 | float maxComponent = max3( abs( v ) );
|
370 | return length( v / maxComponent ) * maxComponent;
|
371 | }
|
372 | #endif
|
373 | struct IncidentLight {
|
374 | vec3 color;
|
375 | vec3 direction;
|
376 | bool visible;
|
377 | };
|
378 | struct ReflectedLight {
|
379 | vec3 directDiffuse;
|
380 | vec3 directSpecular;
|
381 | vec3 indirectDiffuse;
|
382 | vec3 indirectSpecular;
|
383 | };
|
384 | struct GeometricContext {
|
385 | vec3 position;
|
386 | vec3 normal;
|
387 | vec3 viewDir;
|
388 | #ifdef USE_CLEARCOAT
|
389 | vec3 clearcoatNormal;
|
390 | #endif
|
391 | };
|
392 | vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
393 | return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
394 | }
|
395 | vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
396 | return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
397 | }
|
398 | mat3 transposeMat3( const in mat3 m ) {
|
399 | mat3 tmp;
|
400 | tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
401 | tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
402 | tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
403 | return tmp;
|
404 | }
|
405 | float luminance( const in vec3 rgb ) {
|
406 | const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
|
407 | return dot( weights, rgb );
|
408 | }
|
409 | bool isPerspectiveMatrix( mat4 m ) {
|
410 | return m[ 2 ][ 3 ] == - 1.0;
|
411 | }
|
412 | vec2 equirectUv( in vec3 dir ) {
|
413 | float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
414 | float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
415 | return vec2( u, v );
|
416 | }`,wB=`#ifdef ENVMAP_TYPE_CUBE_UV
|
417 | #define cubeUV_minMipLevel 4.0
|
418 | #define cubeUV_minTileSize 16.0
|
419 | float getFace( vec3 direction ) {
|
420 | vec3 absDirection = abs( direction );
|
421 | float face = - 1.0;
|
422 | if ( absDirection.x > absDirection.z ) {
|
423 | if ( absDirection.x > absDirection.y )
|
424 | face = direction.x > 0.0 ? 0.0 : 3.0;
|
425 | else
|
426 | face = direction.y > 0.0 ? 1.0 : 4.0;
|
427 | } else {
|
428 | if ( absDirection.z > absDirection.y )
|
429 | face = direction.z > 0.0 ? 2.0 : 5.0;
|
430 | else
|
431 | face = direction.y > 0.0 ? 1.0 : 4.0;
|
432 | }
|
433 | return face;
|
434 | }
|
435 | vec2 getUV( vec3 direction, float face ) {
|
436 | vec2 uv;
|
437 | if ( face == 0.0 ) {
|
438 | uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
439 | } else if ( face == 1.0 ) {
|
440 | uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
441 | } else if ( face == 2.0 ) {
|
442 | uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
443 | } else if ( face == 3.0 ) {
|
444 | uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
445 | } else if ( face == 4.0 ) {
|
446 | uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
447 | } else {
|
448 | uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
449 | }
|
450 | return 0.5 * ( uv + 1.0 );
|
451 | }
|
452 | vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
453 | float face = getFace( direction );
|
454 | float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
455 | mipInt = max( mipInt, cubeUV_minMipLevel );
|
456 | float faceSize = exp2( mipInt );
|
457 | highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
458 | if ( face > 2.0 ) {
|
459 | uv.y += faceSize;
|
460 | face -= 3.0;
|
461 | }
|
462 | uv.x += face * faceSize;
|
463 | uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
464 | uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
465 | uv.x *= CUBEUV_TEXEL_WIDTH;
|
466 | uv.y *= CUBEUV_TEXEL_HEIGHT;
|
467 | #ifdef texture2DGradEXT
|
468 | return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
469 | #else
|
470 | return texture2D( envMap, uv ).rgb;
|
471 | #endif
|
472 | }
|
473 | #define cubeUV_r0 1.0
|
474 | #define cubeUV_v0 0.339
|
475 | #define cubeUV_m0 - 2.0
|
476 | #define cubeUV_r1 0.8
|
477 | #define cubeUV_v1 0.276
|
478 | #define cubeUV_m1 - 1.0
|
479 | #define cubeUV_r4 0.4
|
480 | #define cubeUV_v4 0.046
|
481 | #define cubeUV_m4 2.0
|
482 | #define cubeUV_r5 0.305
|
483 | #define cubeUV_v5 0.016
|
484 | #define cubeUV_m5 3.0
|
485 | #define cubeUV_r6 0.21
|
486 | #define cubeUV_v6 0.0038
|
487 | #define cubeUV_m6 4.0
|
488 | float roughnessToMip( float roughness ) {
|
489 | float mip = 0.0;
|
490 | if ( roughness >= cubeUV_r1 ) {
|
491 | mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
492 | } else if ( roughness >= cubeUV_r4 ) {
|
493 | mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
494 | } else if ( roughness >= cubeUV_r5 ) {
|
495 | mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
496 | } else if ( roughness >= cubeUV_r6 ) {
|
497 | mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
498 | } else {
|
499 | mip = - 2.0 * log2( 1.16 * roughness ); }
|
500 | return mip;
|
501 | }
|
502 | vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
503 | float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
504 | float mipF = fract( mip );
|
505 | float mipInt = floor( mip );
|
506 | vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
507 | if ( mipF == 0.0 ) {
|
508 | return vec4( color0, 1.0 );
|
509 | } else {
|
510 | vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
511 | return vec4( mix( color0, color1, mipF ), 1.0 );
|
512 | }
|
513 | }
|
514 | #endif`,SB=`vec3 transformedNormal = objectNormal;
|
515 | #ifdef USE_INSTANCING
|
516 | mat3 m = mat3( instanceMatrix );
|
517 | transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
518 | transformedNormal = m * transformedNormal;
|
519 | #endif
|
520 | transformedNormal = normalMatrix * transformedNormal;
|
521 | #ifdef FLIP_SIDED
|
522 | transformedNormal = - transformedNormal;
|
523 | #endif
|
524 | #ifdef USE_TANGENT
|
525 | vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
526 | #ifdef FLIP_SIDED
|
527 | transformedTangent = - transformedTangent;
|
528 | #endif
|
529 | #endif`,AB=`#ifdef USE_DISPLACEMENTMAP
|
530 | uniform sampler2D displacementMap;
|
531 | uniform float displacementScale;
|
532 | uniform float displacementBias;
|
533 | #endif`,_B=`#ifdef USE_DISPLACEMENTMAP
|
534 | transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
|
535 | #endif`,EB=`#ifdef USE_EMISSIVEMAP
|
536 | vec4 emissiveColor = texture2D( emissiveMap, vUv );
|
537 | totalEmissiveRadiance *= emissiveColor.rgb;
|
538 | #endif`,MB=`#ifdef USE_EMISSIVEMAP
|
539 | uniform sampler2D emissiveMap;
|
540 | #endif`,TB="gl_FragColor = linearToOutputTexel( gl_FragColor );",CB=`vec4 LinearToLinear( in vec4 value ) {
|
541 | return value;
|
542 | }
|
543 | vec4 LinearTosRGB( in vec4 value ) {
|
544 | 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 );
|
545 | }`,PB=`#ifdef USE_ENVMAP
|
546 | #ifdef ENV_WORLDPOS
|
547 | vec3 cameraToFrag;
|
548 | if ( isOrthographic ) {
|
549 | cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
550 | } else {
|
551 | cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
552 | }
|
553 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
554 | #ifdef ENVMAP_MODE_REFLECTION
|
555 | vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
556 | #else
|
557 | vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
558 | #endif
|
559 | #else
|
560 | vec3 reflectVec = vReflect;
|
561 | #endif
|
562 | #ifdef ENVMAP_TYPE_CUBE
|
563 | vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
564 | #else
|
565 | vec4 envColor = vec4( 0.0 );
|
566 | #endif
|
567 | #ifdef ENVMAP_BLENDING_MULTIPLY
|
568 | outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
569 | #elif defined( ENVMAP_BLENDING_MIX )
|
570 | outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
571 | #elif defined( ENVMAP_BLENDING_ADD )
|
572 | outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
573 | #endif
|
574 | #endif`,DB=`#ifdef USE_ENVMAP
|
575 | uniform float envMapIntensity;
|
576 | uniform float flipEnvMap;
|
577 | #ifdef ENVMAP_TYPE_CUBE
|
578 | uniform samplerCube envMap;
|
579 | #else
|
580 | uniform sampler2D envMap;
|
581 | #endif
|
582 |
|
583 | #endif`,IB=`#ifdef USE_ENVMAP
|
584 | uniform float reflectivity;
|
585 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
586 | #define ENV_WORLDPOS
|
587 | #endif
|
588 | #ifdef ENV_WORLDPOS
|
589 | varying vec3 vWorldPosition;
|
590 | uniform float refractionRatio;
|
591 | #else
|
592 | varying vec3 vReflect;
|
593 | #endif
|
594 | #endif`,OB=`#ifdef USE_ENVMAP
|
595 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
596 | #define ENV_WORLDPOS
|
597 | #endif
|
598 | #ifdef ENV_WORLDPOS
|
599 |
|
600 | varying vec3 vWorldPosition;
|
601 | #else
|
602 | varying vec3 vReflect;
|
603 | uniform float refractionRatio;
|
604 | #endif
|
605 | #endif`,RB=`#ifdef USE_ENVMAP
|
606 | #ifdef ENV_WORLDPOS
|
607 | vWorldPosition = worldPosition.xyz;
|
608 | #else
|
609 | vec3 cameraToVertex;
|
610 | if ( isOrthographic ) {
|
611 | cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
612 | } else {
|
613 | cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
614 | }
|
615 | vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
616 | #ifdef ENVMAP_MODE_REFLECTION
|
617 | vReflect = reflect( cameraToVertex, worldNormal );
|
618 | #else
|
619 | vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
620 | #endif
|
621 | #endif
|
622 | #endif`,LB=`#ifdef USE_FOG
|
623 | vFogDepth = - mvPosition.z;
|
624 | #endif`,NB=`#ifdef USE_FOG
|
625 | varying float vFogDepth;
|
626 | #endif`,BB=`#ifdef USE_FOG
|
627 | #ifdef FOG_EXP2
|
628 | float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
629 | #else
|
630 | float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
631 | #endif
|
632 | gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
633 | #endif`,FB=`#ifdef USE_FOG
|
634 | uniform vec3 fogColor;
|
635 | varying float vFogDepth;
|
636 | #ifdef FOG_EXP2
|
637 | uniform float fogDensity;
|
638 | #else
|
639 | uniform float fogNear;
|
640 | uniform float fogFar;
|
641 | #endif
|
642 | #endif`,kB=`#ifdef USE_GRADIENTMAP
|
643 | uniform sampler2D gradientMap;
|
644 | #endif
|
645 | vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
646 | float dotNL = dot( normal, lightDirection );
|
647 | vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
648 | #ifdef USE_GRADIENTMAP
|
649 | return vec3( texture2D( gradientMap, coord ).r );
|
650 | #else
|
651 | vec2 fw = fwidth( coord ) * 0.5;
|
652 | return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
653 | #endif
|
654 | }`,VB=`#ifdef USE_LIGHTMAP
|
655 | vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
656 | vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
657 | reflectedLight.indirectDiffuse += lightMapIrradiance;
|
658 | #endif`,zB=`#ifdef USE_LIGHTMAP
|
659 | uniform sampler2D lightMap;
|
660 | uniform float lightMapIntensity;
|
661 | #endif`,UB=`LambertMaterial material;
|
662 | material.diffuseColor = diffuseColor.rgb;
|
663 | material.specularStrength = specularStrength;`,GB=`varying vec3 vViewPosition;
|
664 | struct LambertMaterial {
|
665 | vec3 diffuseColor;
|
666 | float specularStrength;
|
667 | };
|
668 | void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
669 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
670 | vec3 irradiance = dotNL * directLight.color;
|
671 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
672 | }
|
673 | void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
674 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
675 | }
|
676 | #define RE_Direct RE_Direct_Lambert
|
677 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,HB=`uniform bool receiveShadow;
|
678 | uniform vec3 ambientLightColor;
|
679 | uniform vec3 lightProbe[ 9 ];
|
680 | vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
681 | float x = normal.x, y = normal.y, z = normal.z;
|
682 | vec3 result = shCoefficients[ 0 ] * 0.886227;
|
683 | result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
684 | result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
685 | result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
686 | result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
687 | result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
688 | result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
689 | result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
690 | result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
691 | return result;
|
692 | }
|
693 | vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
694 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
695 | vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
696 | return irradiance;
|
697 | }
|
698 | vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
699 | vec3 irradiance = ambientLightColor;
|
700 | return irradiance;
|
701 | }
|
702 | float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
703 | #if defined ( PHYSICALLY_CORRECT_LIGHTS )
|
704 | float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
705 | if ( cutoffDistance > 0.0 ) {
|
706 | distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
707 | }
|
708 | return distanceFalloff;
|
709 | #else
|
710 | if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
711 | return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
712 | }
|
713 | return 1.0;
|
714 | #endif
|
715 | }
|
716 | float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
717 | return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
718 | }
|
719 | #if NUM_DIR_LIGHTS > 0
|
720 | struct DirectionalLight {
|
721 | vec3 direction;
|
722 | vec3 color;
|
723 | };
|
724 | uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
725 | void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
|
726 | light.color = directionalLight.color;
|
727 | light.direction = directionalLight.direction;
|
728 | light.visible = true;
|
729 | }
|
730 | #endif
|
731 | #if NUM_POINT_LIGHTS > 0
|
732 | struct PointLight {
|
733 | vec3 position;
|
734 | vec3 color;
|
735 | float distance;
|
736 | float decay;
|
737 | };
|
738 | uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
739 | void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
|
740 | vec3 lVector = pointLight.position - geometry.position;
|
741 | light.direction = normalize( lVector );
|
742 | float lightDistance = length( lVector );
|
743 | light.color = pointLight.color;
|
744 | light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
745 | light.visible = ( light.color != vec3( 0.0 ) );
|
746 | }
|
747 | #endif
|
748 | #if NUM_SPOT_LIGHTS > 0
|
749 | struct SpotLight {
|
750 | vec3 position;
|
751 | vec3 direction;
|
752 | vec3 color;
|
753 | float distance;
|
754 | float decay;
|
755 | float coneCos;
|
756 | float penumbraCos;
|
757 | };
|
758 | uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
759 | void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
|
760 | vec3 lVector = spotLight.position - geometry.position;
|
761 | light.direction = normalize( lVector );
|
762 | float angleCos = dot( light.direction, spotLight.direction );
|
763 | float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
764 | if ( spotAttenuation > 0.0 ) {
|
765 | float lightDistance = length( lVector );
|
766 | light.color = spotLight.color * spotAttenuation;
|
767 | light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
768 | light.visible = ( light.color != vec3( 0.0 ) );
|
769 | } else {
|
770 | light.color = vec3( 0.0 );
|
771 | light.visible = false;
|
772 | }
|
773 | }
|
774 | #endif
|
775 | #if NUM_RECT_AREA_LIGHTS > 0
|
776 | struct RectAreaLight {
|
777 | vec3 color;
|
778 | vec3 position;
|
779 | vec3 halfWidth;
|
780 | vec3 halfHeight;
|
781 | };
|
782 | uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
783 | uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
784 | #endif
|
785 | #if NUM_HEMI_LIGHTS > 0
|
786 | struct HemisphereLight {
|
787 | vec3 direction;
|
788 | vec3 skyColor;
|
789 | vec3 groundColor;
|
790 | };
|
791 | uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
792 | vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
793 | float dotNL = dot( normal, hemiLight.direction );
|
794 | float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
795 | vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
796 | return irradiance;
|
797 | }
|
798 | #endif`,jB=`#if defined( USE_ENVMAP )
|
799 | vec3 getIBLIrradiance( const in vec3 normal ) {
|
800 | #if defined( ENVMAP_TYPE_CUBE_UV )
|
801 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
802 | vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
803 | return PI * envMapColor.rgb * envMapIntensity;
|
804 | #else
|
805 | return vec3( 0.0 );
|
806 | #endif
|
807 | }
|
808 | vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
809 | #if defined( ENVMAP_TYPE_CUBE_UV )
|
810 | vec3 reflectVec = reflect( - viewDir, normal );
|
811 | reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
812 | reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
813 | vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
814 | return envMapColor.rgb * envMapIntensity;
|
815 | #else
|
816 | return vec3( 0.0 );
|
817 | #endif
|
818 | }
|
819 | #endif`,WB=`ToonMaterial material;
|
820 | material.diffuseColor = diffuseColor.rgb;`,qB=`varying vec3 vViewPosition;
|
821 | struct ToonMaterial {
|
822 | vec3 diffuseColor;
|
823 | };
|
824 | void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
825 | vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
826 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
827 | }
|
828 | void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
829 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
830 | }
|
831 | #define RE_Direct RE_Direct_Toon
|
832 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,YB=`BlinnPhongMaterial material;
|
833 | material.diffuseColor = diffuseColor.rgb;
|
834 | material.specularColor = specular;
|
835 | material.specularShininess = shininess;
|
836 | material.specularStrength = specularStrength;`,XB=`varying vec3 vViewPosition;
|
837 | struct BlinnPhongMaterial {
|
838 | vec3 diffuseColor;
|
839 | vec3 specularColor;
|
840 | float specularShininess;
|
841 | float specularStrength;
|
842 | };
|
843 | void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
844 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
845 | vec3 irradiance = dotNL * directLight.color;
|
846 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
847 | reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
848 | }
|
849 | void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
850 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
851 | }
|
852 | #define RE_Direct RE_Direct_BlinnPhong
|
853 | #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,QB=`PhysicalMaterial material;
|
854 | material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
855 | vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
856 | float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
857 | material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
858 | material.roughness = min( material.roughness, 1.0 );
|
859 | #ifdef IOR
|
860 | material.ior = ior;
|
861 | #ifdef SPECULAR
|
862 | float specularIntensityFactor = specularIntensity;
|
863 | vec3 specularColorFactor = specularColor;
|
864 | #ifdef USE_SPECULARINTENSITYMAP
|
865 | specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
|
866 | #endif
|
867 | #ifdef USE_SPECULARCOLORMAP
|
868 | specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
|
869 | #endif
|
870 | material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
871 | #else
|
872 | float specularIntensityFactor = 1.0;
|
873 | vec3 specularColorFactor = vec3( 1.0 );
|
874 | material.specularF90 = 1.0;
|
875 | #endif
|
876 | material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
877 | #else
|
878 | material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
879 | material.specularF90 = 1.0;
|
880 | #endif
|
881 | #ifdef USE_CLEARCOAT
|
882 | material.clearcoat = clearcoat;
|
883 | material.clearcoatRoughness = clearcoatRoughness;
|
884 | material.clearcoatF0 = vec3( 0.04 );
|
885 | material.clearcoatF90 = 1.0;
|
886 | #ifdef USE_CLEARCOATMAP
|
887 | material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
|
888 | #endif
|
889 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
890 | material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
|
891 | #endif
|
892 | material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
893 | material.clearcoatRoughness += geometryRoughness;
|
894 | material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
895 | #endif
|
896 | #ifdef USE_IRIDESCENCE
|
897 | material.iridescence = iridescence;
|
898 | material.iridescenceIOR = iridescenceIOR;
|
899 | #ifdef USE_IRIDESCENCEMAP
|
900 | material.iridescence *= texture2D( iridescenceMap, vUv ).r;
|
901 | #endif
|
902 | #ifdef USE_IRIDESCENCE_THICKNESSMAP
|
903 | material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
|
904 | #else
|
905 | material.iridescenceThickness = iridescenceThicknessMaximum;
|
906 | #endif
|
907 | #endif
|
908 | #ifdef USE_SHEEN
|
909 | material.sheenColor = sheenColor;
|
910 | #ifdef USE_SHEENCOLORMAP
|
911 | material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
|
912 | #endif
|
913 | material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
914 | #ifdef USE_SHEENROUGHNESSMAP
|
915 | material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
|
916 | #endif
|
917 | #endif`,KB=`struct PhysicalMaterial {
|
918 | vec3 diffuseColor;
|
919 | float roughness;
|
920 | vec3 specularColor;
|
921 | float specularF90;
|
922 | #ifdef USE_CLEARCOAT
|
923 | float clearcoat;
|
924 | float clearcoatRoughness;
|
925 | vec3 clearcoatF0;
|
926 | float clearcoatF90;
|
927 | #endif
|
928 | #ifdef USE_IRIDESCENCE
|
929 | float iridescence;
|
930 | float iridescenceIOR;
|
931 | float iridescenceThickness;
|
932 | vec3 iridescenceFresnel;
|
933 | vec3 iridescenceF0;
|
934 | #endif
|
935 | #ifdef USE_SHEEN
|
936 | vec3 sheenColor;
|
937 | float sheenRoughness;
|
938 | #endif
|
939 | #ifdef IOR
|
940 | float ior;
|
941 | #endif
|
942 | #ifdef USE_TRANSMISSION
|
943 | float transmission;
|
944 | float transmissionAlpha;
|
945 | float thickness;
|
946 | float attenuationDistance;
|
947 | vec3 attenuationColor;
|
948 | #endif
|
949 | };
|
950 | vec3 clearcoatSpecular = vec3( 0.0 );
|
951 | vec3 sheenSpecular = vec3( 0.0 );
|
952 | float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
953 | float dotNV = saturate( dot( normal, viewDir ) );
|
954 | float r2 = roughness * roughness;
|
955 | float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
956 | float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
957 | float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
958 | return saturate( DG * RECIPROCAL_PI );
|
959 | }
|
960 | vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
961 | float dotNV = saturate( dot( normal, viewDir ) );
|
962 | const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
963 | const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
964 | vec4 r = roughness * c0 + c1;
|
965 | float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
966 | vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
967 | return fab;
|
968 | }
|
969 | vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
970 | vec2 fab = DFGApprox( normal, viewDir, roughness );
|
971 | return specularColor * fab.x + specularF90 * fab.y;
|
972 | }
|
973 | #ifdef USE_IRIDESCENCE
|
974 | 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 ) {
|
975 | #else
|
976 | 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 ) {
|
977 | #endif
|
978 | vec2 fab = DFGApprox( normal, viewDir, roughness );
|
979 | #ifdef USE_IRIDESCENCE
|
980 | vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
981 | #else
|
982 | vec3 Fr = specularColor;
|
983 | #endif
|
984 | vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
985 | float Ess = fab.x + fab.y;
|
986 | float Ems = 1.0 - Ess;
|
987 | vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
988 | singleScatter += FssEss;
|
989 | multiScatter += Fms * Ems;
|
990 | }
|
991 | #if NUM_RECT_AREA_LIGHTS > 0
|
992 | void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
993 | vec3 normal = geometry.normal;
|
994 | vec3 viewDir = geometry.viewDir;
|
995 | vec3 position = geometry.position;
|
996 | vec3 lightPos = rectAreaLight.position;
|
997 | vec3 halfWidth = rectAreaLight.halfWidth;
|
998 | vec3 halfHeight = rectAreaLight.halfHeight;
|
999 | vec3 lightColor = rectAreaLight.color;
|
1000 | float roughness = material.roughness;
|
1001 | vec3 rectCoords[ 4 ];
|
1002 | rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
1003 | rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
1004 | rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
1005 | vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
1006 | vec4 t1 = texture2D( ltc_1, uv );
|
1007 | vec4 t2 = texture2D( ltc_2, uv );
|
1008 | mat3 mInv = mat3(
|
1009 | vec3( t1.x, 0, t1.y ),
|
1010 | vec3( 0, 1, 0 ),
|
1011 | vec3( t1.z, 0, t1.w )
|
1012 | );
|
1013 | vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
1014 | reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
1015 | reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
1016 | }
|
1017 | #endif
|
1018 | void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
1019 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
1020 | vec3 irradiance = dotNL * directLight.color;
|
1021 | #ifdef USE_CLEARCOAT
|
1022 | float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
1023 | vec3 ccIrradiance = dotNLcc * directLight.color;
|
1024 | clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
1025 | #endif
|
1026 | #ifdef USE_SHEEN
|
1027 | sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
1028 | #endif
|
1029 | #ifdef USE_IRIDESCENCE
|
1030 | reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
|
1031 | #else
|
1032 | reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
|
1033 | #endif
|
1034 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
1035 | }
|
1036 | void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
1037 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
1038 | }
|
1039 | 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) {
|
1040 | #ifdef USE_CLEARCOAT
|
1041 | clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
1042 | #endif
|
1043 | #ifdef USE_SHEEN
|
1044 | sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
1045 | #endif
|
1046 | vec3 singleScattering = vec3( 0.0 );
|
1047 | vec3 multiScattering = vec3( 0.0 );
|
1048 | vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
1049 | #ifdef USE_IRIDESCENCE
|
1050 | computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
1051 | #else
|
1052 | computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
1053 | #endif
|
1054 | vec3 totalScattering = singleScattering + multiScattering;
|
1055 | vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
1056 | reflectedLight.indirectSpecular += radiance * singleScattering;
|
1057 | reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
1058 | reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
1059 | }
|
1060 | #define RE_Direct RE_Direct_Physical
|
1061 | #define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
1062 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
1063 | #define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
1064 | float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
1065 | return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
1066 | }`,ZB=`
|
1067 | GeometricContext geometry;
|
1068 | geometry.position = - vViewPosition;
|
1069 | geometry.normal = normal;
|
1070 | geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
1071 | #ifdef USE_CLEARCOAT
|
1072 | geometry.clearcoatNormal = clearcoatNormal;
|
1073 | #endif
|
1074 | #ifdef USE_IRIDESCENCE
|
1075 | float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
1076 | if ( material.iridescenceThickness == 0.0 ) {
|
1077 | material.iridescence = 0.0;
|
1078 | } else {
|
1079 | material.iridescence = saturate( material.iridescence );
|
1080 | }
|
1081 | if ( material.iridescence > 0.0 ) {
|
1082 | material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
1083 | material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
1084 | }
|
1085 | #endif
|
1086 | IncidentLight directLight;
|
1087 | #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
1088 | PointLight pointLight;
|
1089 | #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
1090 | PointLightShadow pointLightShadow;
|
1091 | #endif
|
1092 | #pragma unroll_loop_start
|
1093 | for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
1094 | pointLight = pointLights[ i ];
|
1095 | getPointLightInfo( pointLight, geometry, directLight );
|
1096 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
1097 | pointLightShadow = pointLightShadows[ i ];
|
1098 | directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
1099 | #endif
|
1100 | RE_Direct( directLight, geometry, material, reflectedLight );
|
1101 | }
|
1102 | #pragma unroll_loop_end
|
1103 | #endif
|
1104 | #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
1105 | SpotLight spotLight;
|
1106 | vec4 spotColor;
|
1107 | vec3 spotLightCoord;
|
1108 | bool inSpotLightMap;
|
1109 | #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
1110 | SpotLightShadow spotLightShadow;
|
1111 | #endif
|
1112 | #pragma unroll_loop_start
|
1113 | for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
1114 | spotLight = spotLights[ i ];
|
1115 | getSpotLightInfo( spotLight, geometry, directLight );
|
1116 | #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
1117 | #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
1118 | #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
1119 | #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
1120 | #else
|
1121 | #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
1122 | #endif
|
1123 | #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
1124 | spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
1125 | inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
1126 | spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
1127 | directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
1128 | #endif
|
1129 | #undef SPOT_LIGHT_MAP_INDEX
|
1130 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
1131 | spotLightShadow = spotLightShadows[ i ];
|
1132 | directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
1133 | #endif
|
1134 | RE_Direct( directLight, geometry, material, reflectedLight );
|
1135 | }
|
1136 | #pragma unroll_loop_end
|
1137 | #endif
|
1138 | #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
1139 | DirectionalLight directionalLight;
|
1140 | #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
1141 | DirectionalLightShadow directionalLightShadow;
|
1142 | #endif
|
1143 | #pragma unroll_loop_start
|
1144 | for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
1145 | directionalLight = directionalLights[ i ];
|
1146 | getDirectionalLightInfo( directionalLight, geometry, directLight );
|
1147 | #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
1148 | directionalLightShadow = directionalLightShadows[ i ];
|
1149 | directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
1150 | #endif
|
1151 | RE_Direct( directLight, geometry, material, reflectedLight );
|
1152 | }
|
1153 | #pragma unroll_loop_end
|
1154 | #endif
|
1155 | #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
1156 | RectAreaLight rectAreaLight;
|
1157 | #pragma unroll_loop_start
|
1158 | for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
1159 | rectAreaLight = rectAreaLights[ i ];
|
1160 | RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
1161 | }
|
1162 | #pragma unroll_loop_end
|
1163 | #endif
|
1164 | #if defined( RE_IndirectDiffuse )
|
1165 | vec3 iblIrradiance = vec3( 0.0 );
|
1166 | vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
1167 | irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
1168 | #if ( NUM_HEMI_LIGHTS > 0 )
|
1169 | #pragma unroll_loop_start
|
1170 | for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
1171 | irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
1172 | }
|
1173 | #pragma unroll_loop_end
|
1174 | #endif
|
1175 | #endif
|
1176 | #if defined( RE_IndirectSpecular )
|
1177 | vec3 radiance = vec3( 0.0 );
|
1178 | vec3 clearcoatRadiance = vec3( 0.0 );
|
1179 | #endif`,JB=`#if defined( RE_IndirectDiffuse )
|
1180 | #ifdef USE_LIGHTMAP
|
1181 | vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
1182 | vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
1183 | irradiance += lightMapIrradiance;
|
1184 | #endif
|
1185 | #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
1186 | iblIrradiance += getIBLIrradiance( geometry.normal );
|
1187 | #endif
|
1188 | #endif
|
1189 | #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
1190 | radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
1191 | #ifdef USE_CLEARCOAT
|
1192 | clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
|
1193 | #endif
|
1194 | #endif`,$B=`#if defined( RE_IndirectDiffuse )
|
1195 | RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
1196 | #endif
|
1197 | #if defined( RE_IndirectSpecular )
|
1198 | RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
1199 | #endif`,eF=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
1200 | gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
1201 | #endif`,tF=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
1202 | uniform float logDepthBufFC;
|
1203 | varying float vFragDepth;
|
1204 | varying float vIsPerspective;
|
1205 | #endif`,rF=`#ifdef USE_LOGDEPTHBUF
|
1206 | #ifdef USE_LOGDEPTHBUF_EXT
|
1207 | varying float vFragDepth;
|
1208 | varying float vIsPerspective;
|
1209 | #else
|
1210 | uniform float logDepthBufFC;
|
1211 | #endif
|
1212 | #endif`,nF=`#ifdef USE_LOGDEPTHBUF
|
1213 | #ifdef USE_LOGDEPTHBUF_EXT
|
1214 | vFragDepth = 1.0 + gl_Position.w;
|
1215 | vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
1216 | #else
|
1217 | if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
1218 | gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
1219 | gl_Position.z *= gl_Position.w;
|
1220 | }
|
1221 | #endif
|
1222 | #endif`,iF=`#ifdef USE_MAP
|
1223 | vec4 sampledDiffuseColor = texture2D( map, vUv );
|
1224 | #ifdef DECODE_VIDEO_TEXTURE
|
1225 | 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 );
|
1226 | #endif
|
1227 | diffuseColor *= sampledDiffuseColor;
|
1228 | #endif`,sF=`#ifdef USE_MAP
|
1229 | uniform sampler2D map;
|
1230 | #endif`,oF=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
1231 | vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
1232 | #endif
|
1233 | #ifdef USE_MAP
|
1234 | diffuseColor *= texture2D( map, uv );
|
1235 | #endif
|
1236 | #ifdef USE_ALPHAMAP
|
1237 | diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
1238 | #endif`,aF=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
1239 | uniform mat3 uvTransform;
|
1240 | #endif
|
1241 | #ifdef USE_MAP
|
1242 | uniform sampler2D map;
|
1243 | #endif
|
1244 | #ifdef USE_ALPHAMAP
|
1245 | uniform sampler2D alphaMap;
|
1246 | #endif`,lF=`float metalnessFactor = metalness;
|
1247 | #ifdef USE_METALNESSMAP
|
1248 | vec4 texelMetalness = texture2D( metalnessMap, vUv );
|
1249 | metalnessFactor *= texelMetalness.b;
|
1250 | #endif`,cF=`#ifdef USE_METALNESSMAP
|
1251 | uniform sampler2D metalnessMap;
|
1252 | #endif`,uF=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
|
1253 | vColor *= morphTargetBaseInfluence;
|
1254 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
1255 | #if defined( USE_COLOR_ALPHA )
|
1256 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
1257 | #elif defined( USE_COLOR )
|
1258 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
1259 | #endif
|
1260 | }
|
1261 | #endif`,hF=`#ifdef USE_MORPHNORMALS
|
1262 | objectNormal *= morphTargetBaseInfluence;
|
1263 | #ifdef MORPHTARGETS_TEXTURE
|
1264 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
1265 | if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
1266 | }
|
1267 | #else
|
1268 | objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
1269 | objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
1270 | objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
1271 | objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
1272 | #endif
|
1273 | #endif`,dF=`#ifdef USE_MORPHTARGETS
|
1274 | uniform float morphTargetBaseInfluence;
|
1275 | #ifdef MORPHTARGETS_TEXTURE
|
1276 | uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
1277 | uniform sampler2DArray morphTargetsTexture;
|
1278 | uniform ivec2 morphTargetsTextureSize;
|
1279 | vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
1280 | int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
1281 | int y = texelIndex / morphTargetsTextureSize.x;
|
1282 | int x = texelIndex - y * morphTargetsTextureSize.x;
|
1283 | ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
1284 | return texelFetch( morphTargetsTexture, morphUV, 0 );
|
1285 | }
|
1286 | #else
|
1287 | #ifndef USE_MORPHNORMALS
|
1288 | uniform float morphTargetInfluences[ 8 ];
|
1289 | #else
|
1290 | uniform float morphTargetInfluences[ 4 ];
|
1291 | #endif
|
1292 | #endif
|
1293 | #endif`,fF=`#ifdef USE_MORPHTARGETS
|
1294 | transformed *= morphTargetBaseInfluence;
|
1295 | #ifdef MORPHTARGETS_TEXTURE
|
1296 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
1297 | if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
1298 | }
|
1299 | #else
|
1300 | transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
1301 | transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
1302 | transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
1303 | transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
1304 | #ifndef USE_MORPHNORMALS
|
1305 | transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
1306 | transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
1307 | transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
1308 | transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
1309 | #endif
|
1310 | #endif
|
1311 | #endif`,pF=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
1312 | #ifdef FLAT_SHADED
|
1313 | vec3 fdx = dFdx( vViewPosition );
|
1314 | vec3 fdy = dFdy( vViewPosition );
|
1315 | vec3 normal = normalize( cross( fdx, fdy ) );
|
1316 | #else
|
1317 | vec3 normal = normalize( vNormal );
|
1318 | #ifdef DOUBLE_SIDED
|
1319 | normal = normal * faceDirection;
|
1320 | #endif
|
1321 | #ifdef USE_TANGENT
|
1322 | vec3 tangent = normalize( vTangent );
|
1323 | vec3 bitangent = normalize( vBitangent );
|
1324 | #ifdef DOUBLE_SIDED
|
1325 | tangent = tangent * faceDirection;
|
1326 | bitangent = bitangent * faceDirection;
|
1327 | #endif
|
1328 | #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
|
1329 | mat3 vTBN = mat3( tangent, bitangent, normal );
|
1330 | #endif
|
1331 | #endif
|
1332 | #endif
|
1333 | vec3 geometryNormal = normal;`,mF=`#ifdef OBJECTSPACE_NORMALMAP
|
1334 | normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
1335 | #ifdef FLIP_SIDED
|
1336 | normal = - normal;
|
1337 | #endif
|
1338 | #ifdef DOUBLE_SIDED
|
1339 | normal = normal * faceDirection;
|
1340 | #endif
|
1341 | normal = normalize( normalMatrix * normal );
|
1342 | #elif defined( TANGENTSPACE_NORMALMAP )
|
1343 | vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
1344 | mapN.xy *= normalScale;
|
1345 | #ifdef USE_TANGENT
|
1346 | normal = normalize( vTBN * mapN );
|
1347 | #else
|
1348 | normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
|
1349 | #endif
|
1350 | #elif defined( USE_BUMPMAP )
|
1351 | normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
1352 | #endif`,gF=`#ifndef FLAT_SHADED
|
1353 | varying vec3 vNormal;
|
1354 | #ifdef USE_TANGENT
|
1355 | varying vec3 vTangent;
|
1356 | varying vec3 vBitangent;
|
1357 | #endif
|
1358 | #endif`,yF=`#ifndef FLAT_SHADED
|
1359 | varying vec3 vNormal;
|
1360 | #ifdef USE_TANGENT
|
1361 | varying vec3 vTangent;
|
1362 | varying vec3 vBitangent;
|
1363 | #endif
|
1364 | #endif`,vF=`#ifndef FLAT_SHADED
|
1365 | vNormal = normalize( transformedNormal );
|
1366 | #ifdef USE_TANGENT
|
1367 | vTangent = normalize( transformedTangent );
|
1368 | vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
1369 | #endif
|
1370 | #endif`,xF=`#ifdef USE_NORMALMAP
|
1371 | uniform sampler2D normalMap;
|
1372 | uniform vec2 normalScale;
|
1373 | #endif
|
1374 | #ifdef OBJECTSPACE_NORMALMAP
|
1375 | uniform mat3 normalMatrix;
|
1376 | #endif
|
1377 | #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
1378 | vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
|
1379 | vec3 q0 = dFdx( eye_pos.xyz );
|
1380 | vec3 q1 = dFdy( eye_pos.xyz );
|
1381 | vec2 st0 = dFdx( vUv.st );
|
1382 | vec2 st1 = dFdy( vUv.st );
|
1383 | vec3 N = surf_norm;
|
1384 | vec3 q1perp = cross( q1, N );
|
1385 | vec3 q0perp = cross( N, q0 );
|
1386 | vec3 T = q1perp * st0.x + q0perp * st1.x;
|
1387 | vec3 B = q1perp * st0.y + q0perp * st1.y;
|
1388 | float det = max( dot( T, T ), dot( B, B ) );
|
1389 | float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
|
1390 | return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
|
1391 | }
|
1392 | #endif`,bF=`#ifdef USE_CLEARCOAT
|
1393 | vec3 clearcoatNormal = geometryNormal;
|
1394 | #endif`,wF=`#ifdef USE_CLEARCOAT_NORMALMAP
|
1395 | vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
|
1396 | clearcoatMapN.xy *= clearcoatNormalScale;
|
1397 | #ifdef USE_TANGENT
|
1398 | clearcoatNormal = normalize( vTBN * clearcoatMapN );
|
1399 | #else
|
1400 | clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
|
1401 | #endif
|
1402 | #endif`,SF=`#ifdef USE_CLEARCOATMAP
|
1403 | uniform sampler2D clearcoatMap;
|
1404 | #endif
|
1405 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
1406 | uniform sampler2D clearcoatRoughnessMap;
|
1407 | #endif
|
1408 | #ifdef USE_CLEARCOAT_NORMALMAP
|
1409 | uniform sampler2D clearcoatNormalMap;
|
1410 | uniform vec2 clearcoatNormalScale;
|
1411 | #endif`,AF=`#ifdef USE_IRIDESCENCEMAP
|
1412 | uniform sampler2D iridescenceMap;
|
1413 | #endif
|
1414 | #ifdef USE_IRIDESCENCE_THICKNESSMAP
|
1415 | uniform sampler2D iridescenceThicknessMap;
|
1416 | #endif`,_F=`#ifdef OPAQUE
|
1417 | diffuseColor.a = 1.0;
|
1418 | #endif
|
1419 | #ifdef USE_TRANSMISSION
|
1420 | diffuseColor.a *= material.transmissionAlpha + 0.1;
|
1421 | #endif
|
1422 | gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,EF=`vec3 packNormalToRGB( const in vec3 normal ) {
|
1423 | return normalize( normal ) * 0.5 + 0.5;
|
1424 | }
|
1425 | vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
1426 | return 2.0 * rgb.xyz - 1.0;
|
1427 | }
|
1428 | const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
1429 | const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
1430 | const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
1431 | const float ShiftRight8 = 1. / 256.;
|
1432 | vec4 packDepthToRGBA( const in float v ) {
|
1433 | vec4 r = vec4( fract( v * PackFactors ), v );
|
1434 | r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
1435 | }
|
1436 | float unpackRGBAToDepth( const in vec4 v ) {
|
1437 | return dot( v, UnpackFactors );
|
1438 | }
|
1439 | vec2 packDepthToRG( in highp float v ) {
|
1440 | return packDepthToRGBA( v ).yx;
|
1441 | }
|
1442 | float unpackRGToDepth( const in highp vec2 v ) {
|
1443 | return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
|
1444 | }
|
1445 | vec4 pack2HalfToRGBA( vec2 v ) {
|
1446 | vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
1447 | return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
1448 | }
|
1449 | vec2 unpackRGBATo2Half( vec4 v ) {
|
1450 | return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
1451 | }
|
1452 | float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
1453 | return ( viewZ + near ) / ( near - far );
|
1454 | }
|
1455 | float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
|
1456 | return linearClipZ * ( near - far ) - near;
|
1457 | }
|
1458 | float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
1459 | return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
1460 | }
|
1461 | float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
|
1462 | return ( near * far ) / ( ( far - near ) * invClipZ - far );
|
1463 | }`,MF=`#ifdef PREMULTIPLIED_ALPHA
|
1464 | gl_FragColor.rgb *= gl_FragColor.a;
|
1465 | #endif`,TF=`vec4 mvPosition = vec4( transformed, 1.0 );
|
1466 | #ifdef USE_INSTANCING
|
1467 | mvPosition = instanceMatrix * mvPosition;
|
1468 | #endif
|
1469 | mvPosition = modelViewMatrix * mvPosition;
|
1470 | gl_Position = projectionMatrix * mvPosition;`,CF=`#ifdef DITHERING
|
1471 | gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
1472 | #endif`,PF=`#ifdef DITHERING
|
1473 | vec3 dithering( vec3 color ) {
|
1474 | float grid_position = rand( gl_FragCoord.xy );
|
1475 | vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
1476 | dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
1477 | return color + dither_shift_RGB;
|
1478 | }
|
1479 | #endif`,DF=`float roughnessFactor = roughness;
|
1480 | #ifdef USE_ROUGHNESSMAP
|
1481 | vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
1482 | roughnessFactor *= texelRoughness.g;
|
1483 | #endif`,IF=`#ifdef USE_ROUGHNESSMAP
|
1484 | uniform sampler2D roughnessMap;
|
1485 | #endif`,OF=`#if NUM_SPOT_LIGHT_COORDS > 0
|
1486 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
1487 | #endif
|
1488 | #if NUM_SPOT_LIGHT_MAPS > 0
|
1489 | uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
1490 | #endif
|
1491 | #ifdef USE_SHADOWMAP
|
1492 | #if NUM_DIR_LIGHT_SHADOWS > 0
|
1493 | uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
1494 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
1495 | struct DirectionalLightShadow {
|
1496 | float shadowBias;
|
1497 | float shadowNormalBias;
|
1498 | float shadowRadius;
|
1499 | vec2 shadowMapSize;
|
1500 | };
|
1501 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
1502 | #endif
|
1503 | #if NUM_SPOT_LIGHT_SHADOWS > 0
|
1504 | uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
1505 | struct SpotLightShadow {
|
1506 | float shadowBias;
|
1507 | float shadowNormalBias;
|
1508 | float shadowRadius;
|
1509 | vec2 shadowMapSize;
|
1510 | };
|
1511 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
1512 | #endif
|
1513 | #if NUM_POINT_LIGHT_SHADOWS > 0
|
1514 | uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
1515 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
1516 | struct PointLightShadow {
|
1517 | float shadowBias;
|
1518 | float shadowNormalBias;
|
1519 | float shadowRadius;
|
1520 | vec2 shadowMapSize;
|
1521 | float shadowCameraNear;
|
1522 | float shadowCameraFar;
|
1523 | };
|
1524 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
1525 | #endif
|
1526 | float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
1527 | return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
1528 | }
|
1529 | vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
1530 | return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
1531 | }
|
1532 | float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
1533 | float occlusion = 1.0;
|
1534 | vec2 distribution = texture2DDistribution( shadow, uv );
|
1535 | float hard_shadow = step( compare , distribution.x );
|
1536 | if (hard_shadow != 1.0 ) {
|
1537 | float distance = compare - distribution.x ;
|
1538 | float variance = max( 0.00000, distribution.y * distribution.y );
|
1539 | 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 );
|
1540 | }
|
1541 | return occlusion;
|
1542 | }
|
1543 | float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
1544 | float shadow = 1.0;
|
1545 | shadowCoord.xyz /= shadowCoord.w;
|
1546 | shadowCoord.z += shadowBias;
|
1547 | bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
1548 | bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
1549 | if ( frustumTest ) {
|
1550 | #if defined( SHADOWMAP_TYPE_PCF )
|
1551 | vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
1552 | float dx0 = - texelSize.x * shadowRadius;
|
1553 | float dy0 = - texelSize.y * shadowRadius;
|
1554 | float dx1 = + texelSize.x * shadowRadius;
|
1555 | float dy1 = + texelSize.y * shadowRadius;
|
1556 | float dx2 = dx0 / 2.0;
|
1557 | float dy2 = dy0 / 2.0;
|
1558 | float dx3 = dx1 / 2.0;
|
1559 | float dy3 = dy1 / 2.0;
|
1560 | shadow = (
|
1561 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
1562 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
1563 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
1564 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
1565 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
1566 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
1567 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
1568 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
1569 | texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
1570 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
1571 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
1572 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
1573 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
1574 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
1575 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
1576 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
1577 | texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
1578 | ) * ( 1.0 / 17.0 );
|
1579 | #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
1580 | vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
1581 | float dx = texelSize.x;
|
1582 | float dy = texelSize.y;
|
1583 | vec2 uv = shadowCoord.xy;
|
1584 | vec2 f = fract( uv * shadowMapSize + 0.5 );
|
1585 | uv -= f * texelSize;
|
1586 | shadow = (
|
1587 | texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
1588 | texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
1589 | texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
1590 | texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
1591 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
1592 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
1593 | f.x ) +
|
1594 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
1595 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
1596 | f.x ) +
|
1597 | mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
1598 | texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
1599 | f.y ) +
|
1600 | mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
1601 | texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
1602 | f.y ) +
|
1603 | mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
1604 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
1605 | f.x ),
|
1606 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
1607 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
1608 | f.x ),
|
1609 | f.y )
|
1610 | ) * ( 1.0 / 9.0 );
|
1611 | #elif defined( SHADOWMAP_TYPE_VSM )
|
1612 | shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
1613 | #else
|
1614 | shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
1615 | #endif
|
1616 | }
|
1617 | return shadow;
|
1618 | }
|
1619 | vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
1620 | vec3 absV = abs( v );
|
1621 | float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
1622 | absV *= scaleToCube;
|
1623 | v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
1624 | vec2 planar = v.xy;
|
1625 | float almostATexel = 1.5 * texelSizeY;
|
1626 | float almostOne = 1.0 - almostATexel;
|
1627 | if ( absV.z >= almostOne ) {
|
1628 | if ( v.z > 0.0 )
|
1629 | planar.x = 4.0 - v.x;
|
1630 | } else if ( absV.x >= almostOne ) {
|
1631 | float signX = sign( v.x );
|
1632 | planar.x = v.z * signX + 2.0 * signX;
|
1633 | } else if ( absV.y >= almostOne ) {
|
1634 | float signY = sign( v.y );
|
1635 | planar.x = v.x + 2.0 * signY + 2.0;
|
1636 | planar.y = v.z * signY - 2.0;
|
1637 | }
|
1638 | return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
1639 | }
|
1640 | float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
1641 | vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
1642 | vec3 lightToPosition = shadowCoord.xyz;
|
1643 | float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
1644 | vec3 bd3D = normalize( lightToPosition );
|
1645 | #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
1646 | vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
1647 | return (
|
1648 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
1649 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
1650 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
1651 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
1652 | texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
1653 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
1654 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
1655 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
1656 | texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
1657 | ) * ( 1.0 / 9.0 );
|
1658 | #else
|
1659 | return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
1660 | #endif
|
1661 | }
|
1662 | #endif`,RF=`#if NUM_SPOT_LIGHT_COORDS > 0
|
1663 | uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
1664 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
1665 | #endif
|
1666 | #ifdef USE_SHADOWMAP
|
1667 | #if NUM_DIR_LIGHT_SHADOWS > 0
|
1668 | uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
1669 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
1670 | struct DirectionalLightShadow {
|
1671 | float shadowBias;
|
1672 | float shadowNormalBias;
|
1673 | float shadowRadius;
|
1674 | vec2 shadowMapSize;
|
1675 | };
|
1676 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
1677 | #endif
|
1678 | #if NUM_SPOT_LIGHT_SHADOWS > 0
|
1679 | struct SpotLightShadow {
|
1680 | float shadowBias;
|
1681 | float shadowNormalBias;
|
1682 | float shadowRadius;
|
1683 | vec2 shadowMapSize;
|
1684 | };
|
1685 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
1686 | #endif
|
1687 | #if NUM_POINT_LIGHT_SHADOWS > 0
|
1688 | uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
1689 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
1690 | struct PointLightShadow {
|
1691 | float shadowBias;
|
1692 | float shadowNormalBias;
|
1693 | float shadowRadius;
|
1694 | vec2 shadowMapSize;
|
1695 | float shadowCameraNear;
|
1696 | float shadowCameraFar;
|
1697 | };
|
1698 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
1699 | #endif
|
1700 | #endif`,LF=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
1701 | vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
1702 | vec4 shadowWorldPosition;
|
1703 | #endif
|
1704 | #if defined( USE_SHADOWMAP )
|
1705 | #if NUM_DIR_LIGHT_SHADOWS > 0
|
1706 | #pragma unroll_loop_start
|
1707 | for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
1708 | shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
1709 | vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
1710 | }
|
1711 | #pragma unroll_loop_end
|
1712 | #endif
|
1713 | #if NUM_POINT_LIGHT_SHADOWS > 0
|
1714 | #pragma unroll_loop_start
|
1715 | for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
1716 | shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
1717 | vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
1718 | }
|
1719 | #pragma unroll_loop_end
|
1720 | #endif
|
1721 | #endif
|
1722 | #if NUM_SPOT_LIGHT_COORDS > 0
|
1723 | #pragma unroll_loop_start
|
1724 | for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
1725 | shadowWorldPosition = worldPosition;
|
1726 | #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
1727 | shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
1728 | #endif
|
1729 | vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
1730 | }
|
1731 | #pragma unroll_loop_end
|
1732 | #endif`,NF=`float getShadowMask() {
|
1733 | float shadow = 1.0;
|
1734 | #ifdef USE_SHADOWMAP
|
1735 | #if NUM_DIR_LIGHT_SHADOWS > 0
|
1736 | DirectionalLightShadow directionalLight;
|
1737 | #pragma unroll_loop_start
|
1738 | for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
1739 | directionalLight = directionalLightShadows[ i ];
|
1740 | shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
1741 | }
|
1742 | #pragma unroll_loop_end
|
1743 | #endif
|
1744 | #if NUM_SPOT_LIGHT_SHADOWS > 0
|
1745 | SpotLightShadow spotLight;
|
1746 | #pragma unroll_loop_start
|
1747 | for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
1748 | spotLight = spotLightShadows[ i ];
|
1749 | shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
1750 | }
|
1751 | #pragma unroll_loop_end
|
1752 | #endif
|
1753 | #if NUM_POINT_LIGHT_SHADOWS > 0
|
1754 | PointLightShadow pointLight;
|
1755 | #pragma unroll_loop_start
|
1756 | for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
1757 | pointLight = pointLightShadows[ i ];
|
1758 | shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
1759 | }
|
1760 | #pragma unroll_loop_end
|
1761 | #endif
|
1762 | #endif
|
1763 | return shadow;
|
1764 | }`,BF=`#ifdef USE_SKINNING
|
1765 | mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
1766 | mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
1767 | mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
1768 | mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
1769 | #endif`,FF=`#ifdef USE_SKINNING
|
1770 | uniform mat4 bindMatrix;
|
1771 | uniform mat4 bindMatrixInverse;
|
1772 | uniform highp sampler2D boneTexture;
|
1773 | uniform int boneTextureSize;
|
1774 | mat4 getBoneMatrix( const in float i ) {
|
1775 | float j = i * 4.0;
|
1776 | float x = mod( j, float( boneTextureSize ) );
|
1777 | float y = floor( j / float( boneTextureSize ) );
|
1778 | float dx = 1.0 / float( boneTextureSize );
|
1779 | float dy = 1.0 / float( boneTextureSize );
|
1780 | y = dy * ( y + 0.5 );
|
1781 | vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
1782 | vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
1783 | vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
1784 | vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
1785 | mat4 bone = mat4( v1, v2, v3, v4 );
|
1786 | return bone;
|
1787 | }
|
1788 | #endif`,kF=`#ifdef USE_SKINNING
|
1789 | vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
1790 | vec4 skinned = vec4( 0.0 );
|
1791 | skinned += boneMatX * skinVertex * skinWeight.x;
|
1792 | skinned += boneMatY * skinVertex * skinWeight.y;
|
1793 | skinned += boneMatZ * skinVertex * skinWeight.z;
|
1794 | skinned += boneMatW * skinVertex * skinWeight.w;
|
1795 | transformed = ( bindMatrixInverse * skinned ).xyz;
|
1796 | #endif`,VF=`#ifdef USE_SKINNING
|
1797 | mat4 skinMatrix = mat4( 0.0 );
|
1798 | skinMatrix += skinWeight.x * boneMatX;
|
1799 | skinMatrix += skinWeight.y * boneMatY;
|
1800 | skinMatrix += skinWeight.z * boneMatZ;
|
1801 | skinMatrix += skinWeight.w * boneMatW;
|
1802 | skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
1803 | objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
1804 | #ifdef USE_TANGENT
|
1805 | objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
1806 | #endif
|
1807 | #endif`,zF=`float specularStrength;
|
1808 | #ifdef USE_SPECULARMAP
|
1809 | vec4 texelSpecular = texture2D( specularMap, vUv );
|
1810 | specularStrength = texelSpecular.r;
|
1811 | #else
|
1812 | specularStrength = 1.0;
|
1813 | #endif`,UF=`#ifdef USE_SPECULARMAP
|
1814 | uniform sampler2D specularMap;
|
1815 | #endif`,GF=`#if defined( TONE_MAPPING )
|
1816 | gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
1817 | #endif`,HF=`#ifndef saturate
|
1818 | #define saturate( a ) clamp( a, 0.0, 1.0 )
|
1819 | #endif
|
1820 | uniform float toneMappingExposure;
|
1821 | vec3 LinearToneMapping( vec3 color ) {
|
1822 | return toneMappingExposure * color;
|
1823 | }
|
1824 | vec3 ReinhardToneMapping( vec3 color ) {
|
1825 | color *= toneMappingExposure;
|
1826 | return saturate( color / ( vec3( 1.0 ) + color ) );
|
1827 | }
|
1828 | vec3 OptimizedCineonToneMapping( vec3 color ) {
|
1829 | color *= toneMappingExposure;
|
1830 | color = max( vec3( 0.0 ), color - 0.004 );
|
1831 | return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
1832 | }
|
1833 | vec3 RRTAndODTFit( vec3 v ) {
|
1834 | vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
1835 | vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
1836 | return a / b;
|
1837 | }
|
1838 | vec3 ACESFilmicToneMapping( vec3 color ) {
|
1839 | const mat3 ACESInputMat = mat3(
|
1840 | vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
1841 | vec3( 0.04823, 0.01566, 0.83777 )
|
1842 | );
|
1843 | const mat3 ACESOutputMat = mat3(
|
1844 | vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
1845 | vec3( -0.07367, -0.00605, 1.07602 )
|
1846 | );
|
1847 | color *= toneMappingExposure / 0.6;
|
1848 | color = ACESInputMat * color;
|
1849 | color = RRTAndODTFit( color );
|
1850 | color = ACESOutputMat * color;
|
1851 | return saturate( color );
|
1852 | }
|
1853 | vec3 CustomToneMapping( vec3 color ) { return color; }`,jF=`#ifdef USE_TRANSMISSION
|
1854 | material.transmission = transmission;
|
1855 | material.transmissionAlpha = 1.0;
|
1856 | material.thickness = thickness;
|
1857 | material.attenuationDistance = attenuationDistance;
|
1858 | material.attenuationColor = attenuationColor;
|
1859 | #ifdef USE_TRANSMISSIONMAP
|
1860 | material.transmission *= texture2D( transmissionMap, vUv ).r;
|
1861 | #endif
|
1862 | #ifdef USE_THICKNESSMAP
|
1863 | material.thickness *= texture2D( thicknessMap, vUv ).g;
|
1864 | #endif
|
1865 | vec3 pos = vWorldPosition;
|
1866 | vec3 v = normalize( cameraPosition - pos );
|
1867 | vec3 n = inverseTransformDirection( normal, viewMatrix );
|
1868 | vec4 transmission = getIBLVolumeRefraction(
|
1869 | n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
1870 | pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
|
1871 | material.attenuationColor, material.attenuationDistance );
|
1872 | material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );
|
1873 | totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );
|
1874 | #endif`,WF=`#ifdef USE_TRANSMISSION
|
1875 | uniform float transmission;
|
1876 | uniform float thickness;
|
1877 | uniform float attenuationDistance;
|
1878 | uniform vec3 attenuationColor;
|
1879 | #ifdef USE_TRANSMISSIONMAP
|
1880 | uniform sampler2D transmissionMap;
|
1881 | #endif
|
1882 | #ifdef USE_THICKNESSMAP
|
1883 | uniform sampler2D thicknessMap;
|
1884 | #endif
|
1885 | uniform vec2 transmissionSamplerSize;
|
1886 | uniform sampler2D transmissionSamplerMap;
|
1887 | uniform mat4 modelMatrix;
|
1888 | uniform mat4 projectionMatrix;
|
1889 | varying vec3 vWorldPosition;
|
1890 | vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
1891 | vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
1892 | vec3 modelScale;
|
1893 | modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
1894 | modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
1895 | modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
1896 | return normalize( refractionVector ) * thickness * modelScale;
|
1897 | }
|
1898 | float applyIorToRoughness( const in float roughness, const in float ior ) {
|
1899 | return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
1900 | }
|
1901 | vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
1902 | float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
1903 | #ifdef texture2DLodEXT
|
1904 | return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
|
1905 | #else
|
1906 | return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
|
1907 | #endif
|
1908 | }
|
1909 | vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
1910 | if ( isinf( attenuationDistance ) ) {
|
1911 | return radiance;
|
1912 | } else {
|
1913 | vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
1914 | vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
|
1915 | }
|
1916 | }
|
1917 | vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
1918 | const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
1919 | const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
|
1920 | const in vec3 attenuationColor, const in float attenuationDistance ) {
|
1921 | vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
1922 | vec3 refractedRayExit = position + transmissionRay;
|
1923 | vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
1924 | vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
1925 | refractionCoords += 1.0;
|
1926 | refractionCoords /= 2.0;
|
1927 | vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
1928 | vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
|
1929 | vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
1930 | return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
|
1931 | }
|
1932 | #endif`,qF=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
|
1933 | varying vec2 vUv;
|
1934 | #endif`,YF=`#ifdef USE_UV
|
1935 | #ifdef UVS_VERTEX_ONLY
|
1936 | vec2 vUv;
|
1937 | #else
|
1938 | varying vec2 vUv;
|
1939 | #endif
|
1940 | uniform mat3 uvTransform;
|
1941 | #endif`,XF=`#ifdef USE_UV
|
1942 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
1943 | #endif`,QF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
1944 | varying vec2 vUv2;
|
1945 | #endif`,KF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
1946 | attribute vec2 uv2;
|
1947 | varying vec2 vUv2;
|
1948 | uniform mat3 uv2Transform;
|
1949 | #endif`,ZF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
1950 | vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
|
1951 | #endif`,JF=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
1952 | vec4 worldPosition = vec4( transformed, 1.0 );
|
1953 | #ifdef USE_INSTANCING
|
1954 | worldPosition = instanceMatrix * worldPosition;
|
1955 | #endif
|
1956 | worldPosition = modelMatrix * worldPosition;
|
1957 | #endif`,$F=`varying vec2 vUv;
|
1958 | uniform mat3 uvTransform;
|
1959 | void main() {
|
1960 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
1961 | gl_Position = vec4( position.xy, 1.0, 1.0 );
|
1962 | }`,ek=`uniform sampler2D t2D;
|
1963 | uniform float backgroundIntensity;
|
1964 | varying vec2 vUv;
|
1965 | void main() {
|
1966 | vec4 texColor = texture2D( t2D, vUv );
|
1967 | #ifdef DECODE_VIDEO_TEXTURE
|
1968 | 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 );
|
1969 | #endif
|
1970 | texColor.rgb *= backgroundIntensity;
|
1971 | gl_FragColor = texColor;
|
1972 | #include <tonemapping_fragment>
|
1973 | #include <encodings_fragment>
|
1974 | }`,tk=`varying vec3 vWorldDirection;
|
1975 | #include <common>
|
1976 | void main() {
|
1977 | vWorldDirection = transformDirection( position, modelMatrix );
|
1978 | #include <begin_vertex>
|
1979 | #include <project_vertex>
|
1980 | gl_Position.z = gl_Position.w;
|
1981 | }`,rk=`#ifdef ENVMAP_TYPE_CUBE
|
1982 | uniform samplerCube envMap;
|
1983 | #elif defined( ENVMAP_TYPE_CUBE_UV )
|
1984 | uniform sampler2D envMap;
|
1985 | #endif
|
1986 | uniform float flipEnvMap;
|
1987 | uniform float backgroundBlurriness;
|
1988 | uniform float backgroundIntensity;
|
1989 | varying vec3 vWorldDirection;
|
1990 | #include <cube_uv_reflection_fragment>
|
1991 | void main() {
|
1992 | #ifdef ENVMAP_TYPE_CUBE
|
1993 | vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
1994 | #elif defined( ENVMAP_TYPE_CUBE_UV )
|
1995 | vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
|
1996 | #else
|
1997 | vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
1998 | #endif
|
1999 | texColor.rgb *= backgroundIntensity;
|
2000 | gl_FragColor = texColor;
|
2001 | #include <tonemapping_fragment>
|
2002 | #include <encodings_fragment>
|
2003 | }`,nk=`varying vec3 vWorldDirection;
|
2004 | #include <common>
|
2005 | void main() {
|
2006 | vWorldDirection = transformDirection( position, modelMatrix );
|
2007 | #include <begin_vertex>
|
2008 | #include <project_vertex>
|
2009 | gl_Position.z = gl_Position.w;
|
2010 | }`,ik=`uniform samplerCube tCube;
|
2011 | uniform float tFlip;
|
2012 | uniform float opacity;
|
2013 | varying vec3 vWorldDirection;
|
2014 | void main() {
|
2015 | vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
2016 | gl_FragColor = texColor;
|
2017 | gl_FragColor.a *= opacity;
|
2018 | #include <tonemapping_fragment>
|
2019 | #include <encodings_fragment>
|
2020 | }`,sk=`#include <common>
|
2021 | #include <uv_pars_vertex>
|
2022 | #include <displacementmap_pars_vertex>
|
2023 | #include <morphtarget_pars_vertex>
|
2024 | #include <skinning_pars_vertex>
|
2025 | #include <logdepthbuf_pars_vertex>
|
2026 | #include <clipping_planes_pars_vertex>
|
2027 | varying vec2 vHighPrecisionZW;
|
2028 | void main() {
|
2029 | #include <uv_vertex>
|
2030 | #include <skinbase_vertex>
|
2031 | #ifdef USE_DISPLACEMENTMAP
|
2032 | #include <beginnormal_vertex>
|
2033 | #include <morphnormal_vertex>
|
2034 | #include <skinnormal_vertex>
|
2035 | #endif
|
2036 | #include <begin_vertex>
|
2037 | #include <morphtarget_vertex>
|
2038 | #include <skinning_vertex>
|
2039 | #include <displacementmap_vertex>
|
2040 | #include <project_vertex>
|
2041 | #include <logdepthbuf_vertex>
|
2042 | #include <clipping_planes_vertex>
|
2043 | vHighPrecisionZW = gl_Position.zw;
|
2044 | }`,ok=`#if DEPTH_PACKING == 3200
|
2045 | uniform float opacity;
|
2046 | #endif
|
2047 | #include <common>
|
2048 | #include <packing>
|
2049 | #include <uv_pars_fragment>
|
2050 | #include <map_pars_fragment>
|
2051 | #include <alphamap_pars_fragment>
|
2052 | #include <alphatest_pars_fragment>
|
2053 | #include <logdepthbuf_pars_fragment>
|
2054 | #include <clipping_planes_pars_fragment>
|
2055 | varying vec2 vHighPrecisionZW;
|
2056 | void main() {
|
2057 | #include <clipping_planes_fragment>
|
2058 | vec4 diffuseColor = vec4( 1.0 );
|
2059 | #if DEPTH_PACKING == 3200
|
2060 | diffuseColor.a = opacity;
|
2061 | #endif
|
2062 | #include <map_fragment>
|
2063 | #include <alphamap_fragment>
|
2064 | #include <alphatest_fragment>
|
2065 | #include <logdepthbuf_fragment>
|
2066 | float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
2067 | #if DEPTH_PACKING == 3200
|
2068 | gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
2069 | #elif DEPTH_PACKING == 3201
|
2070 | gl_FragColor = packDepthToRGBA( fragCoordZ );
|
2071 | #endif
|
2072 | }`,ak=`#define DISTANCE
|
2073 | varying vec3 vWorldPosition;
|
2074 | #include <common>
|
2075 | #include <uv_pars_vertex>
|
2076 | #include <displacementmap_pars_vertex>
|
2077 | #include <morphtarget_pars_vertex>
|
2078 | #include <skinning_pars_vertex>
|
2079 | #include <clipping_planes_pars_vertex>
|
2080 | void main() {
|
2081 | #include <uv_vertex>
|
2082 | #include <skinbase_vertex>
|
2083 | #ifdef USE_DISPLACEMENTMAP
|
2084 | #include <beginnormal_vertex>
|
2085 | #include <morphnormal_vertex>
|
2086 | #include <skinnormal_vertex>
|
2087 | #endif
|
2088 | #include <begin_vertex>
|
2089 | #include <morphtarget_vertex>
|
2090 | #include <skinning_vertex>
|
2091 | #include <displacementmap_vertex>
|
2092 | #include <project_vertex>
|
2093 | #include <worldpos_vertex>
|
2094 | #include <clipping_planes_vertex>
|
2095 | vWorldPosition = worldPosition.xyz;
|
2096 | }`,lk=`#define DISTANCE
|
2097 | uniform vec3 referencePosition;
|
2098 | uniform float nearDistance;
|
2099 | uniform float farDistance;
|
2100 | varying vec3 vWorldPosition;
|
2101 | #include <common>
|
2102 | #include <packing>
|
2103 | #include <uv_pars_fragment>
|
2104 | #include <map_pars_fragment>
|
2105 | #include <alphamap_pars_fragment>
|
2106 | #include <alphatest_pars_fragment>
|
2107 | #include <clipping_planes_pars_fragment>
|
2108 | void main () {
|
2109 | #include <clipping_planes_fragment>
|
2110 | vec4 diffuseColor = vec4( 1.0 );
|
2111 | #include <map_fragment>
|
2112 | #include <alphamap_fragment>
|
2113 | #include <alphatest_fragment>
|
2114 | float dist = length( vWorldPosition - referencePosition );
|
2115 | dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
2116 | dist = saturate( dist );
|
2117 | gl_FragColor = packDepthToRGBA( dist );
|
2118 | }`,ck=`varying vec3 vWorldDirection;
|
2119 | #include <common>
|
2120 | void main() {
|
2121 | vWorldDirection = transformDirection( position, modelMatrix );
|
2122 | #include <begin_vertex>
|
2123 | #include <project_vertex>
|
2124 | }`,uk=`uniform sampler2D tEquirect;
|
2125 | varying vec3 vWorldDirection;
|
2126 | #include <common>
|
2127 | void main() {
|
2128 | vec3 direction = normalize( vWorldDirection );
|
2129 | vec2 sampleUV = equirectUv( direction );
|
2130 | gl_FragColor = texture2D( tEquirect, sampleUV );
|
2131 | #include <tonemapping_fragment>
|
2132 | #include <encodings_fragment>
|
2133 | }`,hk=`uniform float scale;
|
2134 | attribute float lineDistance;
|
2135 | varying float vLineDistance;
|
2136 | #include <common>
|
2137 | #include <color_pars_vertex>
|
2138 | #include <fog_pars_vertex>
|
2139 | #include <morphtarget_pars_vertex>
|
2140 | #include <logdepthbuf_pars_vertex>
|
2141 | #include <clipping_planes_pars_vertex>
|
2142 | void main() {
|
2143 | vLineDistance = scale * lineDistance;
|
2144 | #include <color_vertex>
|
2145 | #include <morphcolor_vertex>
|
2146 | #include <begin_vertex>
|
2147 | #include <morphtarget_vertex>
|
2148 | #include <project_vertex>
|
2149 | #include <logdepthbuf_vertex>
|
2150 | #include <clipping_planes_vertex>
|
2151 | #include <fog_vertex>
|
2152 | }`,dk=`uniform vec3 diffuse;
|
2153 | uniform float opacity;
|
2154 | uniform float dashSize;
|
2155 | uniform float totalSize;
|
2156 | varying float vLineDistance;
|
2157 | #include <common>
|
2158 | #include <color_pars_fragment>
|
2159 | #include <fog_pars_fragment>
|
2160 | #include <logdepthbuf_pars_fragment>
|
2161 | #include <clipping_planes_pars_fragment>
|
2162 | void main() {
|
2163 | #include <clipping_planes_fragment>
|
2164 | if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
2165 | discard;
|
2166 | }
|
2167 | vec3 outgoingLight = vec3( 0.0 );
|
2168 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2169 | #include <logdepthbuf_fragment>
|
2170 | #include <color_fragment>
|
2171 | outgoingLight = diffuseColor.rgb;
|
2172 | #include <output_fragment>
|
2173 | #include <tonemapping_fragment>
|
2174 | #include <encodings_fragment>
|
2175 | #include <fog_fragment>
|
2176 | #include <premultiplied_alpha_fragment>
|
2177 | }`,fk=`#include <common>
|
2178 | #include <uv_pars_vertex>
|
2179 | #include <uv2_pars_vertex>
|
2180 | #include <envmap_pars_vertex>
|
2181 | #include <color_pars_vertex>
|
2182 | #include <fog_pars_vertex>
|
2183 | #include <morphtarget_pars_vertex>
|
2184 | #include <skinning_pars_vertex>
|
2185 | #include <logdepthbuf_pars_vertex>
|
2186 | #include <clipping_planes_pars_vertex>
|
2187 | void main() {
|
2188 | #include <uv_vertex>
|
2189 | #include <uv2_vertex>
|
2190 | #include <color_vertex>
|
2191 | #include <morphcolor_vertex>
|
2192 | #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
2193 | #include <beginnormal_vertex>
|
2194 | #include <morphnormal_vertex>
|
2195 | #include <skinbase_vertex>
|
2196 | #include <skinnormal_vertex>
|
2197 | #include <defaultnormal_vertex>
|
2198 | #endif
|
2199 | #include <begin_vertex>
|
2200 | #include <morphtarget_vertex>
|
2201 | #include <skinning_vertex>
|
2202 | #include <project_vertex>
|
2203 | #include <logdepthbuf_vertex>
|
2204 | #include <clipping_planes_vertex>
|
2205 | #include <worldpos_vertex>
|
2206 | #include <envmap_vertex>
|
2207 | #include <fog_vertex>
|
2208 | }`,pk=`uniform vec3 diffuse;
|
2209 | uniform float opacity;
|
2210 | #ifndef FLAT_SHADED
|
2211 | varying vec3 vNormal;
|
2212 | #endif
|
2213 | #include <common>
|
2214 | #include <dithering_pars_fragment>
|
2215 | #include <color_pars_fragment>
|
2216 | #include <uv_pars_fragment>
|
2217 | #include <uv2_pars_fragment>
|
2218 | #include <map_pars_fragment>
|
2219 | #include <alphamap_pars_fragment>
|
2220 | #include <alphatest_pars_fragment>
|
2221 | #include <aomap_pars_fragment>
|
2222 | #include <lightmap_pars_fragment>
|
2223 | #include <envmap_common_pars_fragment>
|
2224 | #include <envmap_pars_fragment>
|
2225 | #include <fog_pars_fragment>
|
2226 | #include <specularmap_pars_fragment>
|
2227 | #include <logdepthbuf_pars_fragment>
|
2228 | #include <clipping_planes_pars_fragment>
|
2229 | void main() {
|
2230 | #include <clipping_planes_fragment>
|
2231 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2232 | #include <logdepthbuf_fragment>
|
2233 | #include <map_fragment>
|
2234 | #include <color_fragment>
|
2235 | #include <alphamap_fragment>
|
2236 | #include <alphatest_fragment>
|
2237 | #include <specularmap_fragment>
|
2238 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
2239 | #ifdef USE_LIGHTMAP
|
2240 | vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
2241 | reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
2242 | #else
|
2243 | reflectedLight.indirectDiffuse += vec3( 1.0 );
|
2244 | #endif
|
2245 | #include <aomap_fragment>
|
2246 | reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
2247 | vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
2248 | #include <envmap_fragment>
|
2249 | #include <output_fragment>
|
2250 | #include <tonemapping_fragment>
|
2251 | #include <encodings_fragment>
|
2252 | #include <fog_fragment>
|
2253 | #include <premultiplied_alpha_fragment>
|
2254 | #include <dithering_fragment>
|
2255 | }`,mk=`#define LAMBERT
|
2256 | varying vec3 vViewPosition;
|
2257 | #include <common>
|
2258 | #include <uv_pars_vertex>
|
2259 | #include <uv2_pars_vertex>
|
2260 | #include <displacementmap_pars_vertex>
|
2261 | #include <envmap_pars_vertex>
|
2262 | #include <color_pars_vertex>
|
2263 | #include <fog_pars_vertex>
|
2264 | #include <normal_pars_vertex>
|
2265 | #include <morphtarget_pars_vertex>
|
2266 | #include <skinning_pars_vertex>
|
2267 | #include <shadowmap_pars_vertex>
|
2268 | #include <logdepthbuf_pars_vertex>
|
2269 | #include <clipping_planes_pars_vertex>
|
2270 | void main() {
|
2271 | #include <uv_vertex>
|
2272 | #include <uv2_vertex>
|
2273 | #include <color_vertex>
|
2274 | #include <morphcolor_vertex>
|
2275 | #include <beginnormal_vertex>
|
2276 | #include <morphnormal_vertex>
|
2277 | #include <skinbase_vertex>
|
2278 | #include <skinnormal_vertex>
|
2279 | #include <defaultnormal_vertex>
|
2280 | #include <normal_vertex>
|
2281 | #include <begin_vertex>
|
2282 | #include <morphtarget_vertex>
|
2283 | #include <skinning_vertex>
|
2284 | #include <displacementmap_vertex>
|
2285 | #include <project_vertex>
|
2286 | #include <logdepthbuf_vertex>
|
2287 | #include <clipping_planes_vertex>
|
2288 | vViewPosition = - mvPosition.xyz;
|
2289 | #include <worldpos_vertex>
|
2290 | #include <envmap_vertex>
|
2291 | #include <shadowmap_vertex>
|
2292 | #include <fog_vertex>
|
2293 | }`,gk=`#define LAMBERT
|
2294 | uniform vec3 diffuse;
|
2295 | uniform vec3 emissive;
|
2296 | uniform float opacity;
|
2297 | #include <common>
|
2298 | #include <packing>
|
2299 | #include <dithering_pars_fragment>
|
2300 | #include <color_pars_fragment>
|
2301 | #include <uv_pars_fragment>
|
2302 | #include <uv2_pars_fragment>
|
2303 | #include <map_pars_fragment>
|
2304 | #include <alphamap_pars_fragment>
|
2305 | #include <alphatest_pars_fragment>
|
2306 | #include <aomap_pars_fragment>
|
2307 | #include <lightmap_pars_fragment>
|
2308 | #include <emissivemap_pars_fragment>
|
2309 | #include <envmap_common_pars_fragment>
|
2310 | #include <envmap_pars_fragment>
|
2311 | #include <fog_pars_fragment>
|
2312 | #include <bsdfs>
|
2313 | #include <lights_pars_begin>
|
2314 | #include <normal_pars_fragment>
|
2315 | #include <lights_lambert_pars_fragment>
|
2316 | #include <shadowmap_pars_fragment>
|
2317 | #include <bumpmap_pars_fragment>
|
2318 | #include <normalmap_pars_fragment>
|
2319 | #include <specularmap_pars_fragment>
|
2320 | #include <logdepthbuf_pars_fragment>
|
2321 | #include <clipping_planes_pars_fragment>
|
2322 | void main() {
|
2323 | #include <clipping_planes_fragment>
|
2324 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2325 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
2326 | vec3 totalEmissiveRadiance = emissive;
|
2327 | #include <logdepthbuf_fragment>
|
2328 | #include <map_fragment>
|
2329 | #include <color_fragment>
|
2330 | #include <alphamap_fragment>
|
2331 | #include <alphatest_fragment>
|
2332 | #include <specularmap_fragment>
|
2333 | #include <normal_fragment_begin>
|
2334 | #include <normal_fragment_maps>
|
2335 | #include <emissivemap_fragment>
|
2336 | #include <lights_lambert_fragment>
|
2337 | #include <lights_fragment_begin>
|
2338 | #include <lights_fragment_maps>
|
2339 | #include <lights_fragment_end>
|
2340 | #include <aomap_fragment>
|
2341 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
2342 | #include <envmap_fragment>
|
2343 | #include <output_fragment>
|
2344 | #include <tonemapping_fragment>
|
2345 | #include <encodings_fragment>
|
2346 | #include <fog_fragment>
|
2347 | #include <premultiplied_alpha_fragment>
|
2348 | #include <dithering_fragment>
|
2349 | }`,yk=`#define MATCAP
|
2350 | varying vec3 vViewPosition;
|
2351 | #include <common>
|
2352 | #include <uv_pars_vertex>
|
2353 | #include <color_pars_vertex>
|
2354 | #include <displacementmap_pars_vertex>
|
2355 | #include <fog_pars_vertex>
|
2356 | #include <normal_pars_vertex>
|
2357 | #include <morphtarget_pars_vertex>
|
2358 | #include <skinning_pars_vertex>
|
2359 | #include <logdepthbuf_pars_vertex>
|
2360 | #include <clipping_planes_pars_vertex>
|
2361 | void main() {
|
2362 | #include <uv_vertex>
|
2363 | #include <color_vertex>
|
2364 | #include <morphcolor_vertex>
|
2365 | #include <beginnormal_vertex>
|
2366 | #include <morphnormal_vertex>
|
2367 | #include <skinbase_vertex>
|
2368 | #include <skinnormal_vertex>
|
2369 | #include <defaultnormal_vertex>
|
2370 | #include <normal_vertex>
|
2371 | #include <begin_vertex>
|
2372 | #include <morphtarget_vertex>
|
2373 | #include <skinning_vertex>
|
2374 | #include <displacementmap_vertex>
|
2375 | #include <project_vertex>
|
2376 | #include <logdepthbuf_vertex>
|
2377 | #include <clipping_planes_vertex>
|
2378 | #include <fog_vertex>
|
2379 | vViewPosition = - mvPosition.xyz;
|
2380 | }`,vk=`#define MATCAP
|
2381 | uniform vec3 diffuse;
|
2382 | uniform float opacity;
|
2383 | uniform sampler2D matcap;
|
2384 | varying vec3 vViewPosition;
|
2385 | #include <common>
|
2386 | #include <dithering_pars_fragment>
|
2387 | #include <color_pars_fragment>
|
2388 | #include <uv_pars_fragment>
|
2389 | #include <map_pars_fragment>
|
2390 | #include <alphamap_pars_fragment>
|
2391 | #include <alphatest_pars_fragment>
|
2392 | #include <fog_pars_fragment>
|
2393 | #include <normal_pars_fragment>
|
2394 | #include <bumpmap_pars_fragment>
|
2395 | #include <normalmap_pars_fragment>
|
2396 | #include <logdepthbuf_pars_fragment>
|
2397 | #include <clipping_planes_pars_fragment>
|
2398 | void main() {
|
2399 | #include <clipping_planes_fragment>
|
2400 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2401 | #include <logdepthbuf_fragment>
|
2402 | #include <map_fragment>
|
2403 | #include <color_fragment>
|
2404 | #include <alphamap_fragment>
|
2405 | #include <alphatest_fragment>
|
2406 | #include <normal_fragment_begin>
|
2407 | #include <normal_fragment_maps>
|
2408 | vec3 viewDir = normalize( vViewPosition );
|
2409 | vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
2410 | vec3 y = cross( viewDir, x );
|
2411 | vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
2412 | #ifdef USE_MATCAP
|
2413 | vec4 matcapColor = texture2D( matcap, uv );
|
2414 | #else
|
2415 | vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
2416 | #endif
|
2417 | vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
2418 | #include <output_fragment>
|
2419 | #include <tonemapping_fragment>
|
2420 | #include <encodings_fragment>
|
2421 | #include <fog_fragment>
|
2422 | #include <premultiplied_alpha_fragment>
|
2423 | #include <dithering_fragment>
|
2424 | }`,xk=`#define NORMAL
|
2425 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
2426 | varying vec3 vViewPosition;
|
2427 | #endif
|
2428 | #include <common>
|
2429 | #include <uv_pars_vertex>
|
2430 | #include <displacementmap_pars_vertex>
|
2431 | #include <normal_pars_vertex>
|
2432 | #include <morphtarget_pars_vertex>
|
2433 | #include <skinning_pars_vertex>
|
2434 | #include <logdepthbuf_pars_vertex>
|
2435 | #include <clipping_planes_pars_vertex>
|
2436 | void main() {
|
2437 | #include <uv_vertex>
|
2438 | #include <beginnormal_vertex>
|
2439 | #include <morphnormal_vertex>
|
2440 | #include <skinbase_vertex>
|
2441 | #include <skinnormal_vertex>
|
2442 | #include <defaultnormal_vertex>
|
2443 | #include <normal_vertex>
|
2444 | #include <begin_vertex>
|
2445 | #include <morphtarget_vertex>
|
2446 | #include <skinning_vertex>
|
2447 | #include <displacementmap_vertex>
|
2448 | #include <project_vertex>
|
2449 | #include <logdepthbuf_vertex>
|
2450 | #include <clipping_planes_vertex>
|
2451 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
2452 | vViewPosition = - mvPosition.xyz;
|
2453 | #endif
|
2454 | }`,bk=`#define NORMAL
|
2455 | uniform float opacity;
|
2456 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
2457 | varying vec3 vViewPosition;
|
2458 | #endif
|
2459 | #include <packing>
|
2460 | #include <uv_pars_fragment>
|
2461 | #include <normal_pars_fragment>
|
2462 | #include <bumpmap_pars_fragment>
|
2463 | #include <normalmap_pars_fragment>
|
2464 | #include <logdepthbuf_pars_fragment>
|
2465 | #include <clipping_planes_pars_fragment>
|
2466 | void main() {
|
2467 | #include <clipping_planes_fragment>
|
2468 | #include <logdepthbuf_fragment>
|
2469 | #include <normal_fragment_begin>
|
2470 | #include <normal_fragment_maps>
|
2471 | gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
2472 | #ifdef OPAQUE
|
2473 | gl_FragColor.a = 1.0;
|
2474 | #endif
|
2475 | }`,wk=`#define PHONG
|
2476 | varying vec3 vViewPosition;
|
2477 | #include <common>
|
2478 | #include <uv_pars_vertex>
|
2479 | #include <uv2_pars_vertex>
|
2480 | #include <displacementmap_pars_vertex>
|
2481 | #include <envmap_pars_vertex>
|
2482 | #include <color_pars_vertex>
|
2483 | #include <fog_pars_vertex>
|
2484 | #include <normal_pars_vertex>
|
2485 | #include <morphtarget_pars_vertex>
|
2486 | #include <skinning_pars_vertex>
|
2487 | #include <shadowmap_pars_vertex>
|
2488 | #include <logdepthbuf_pars_vertex>
|
2489 | #include <clipping_planes_pars_vertex>
|
2490 | void main() {
|
2491 | #include <uv_vertex>
|
2492 | #include <uv2_vertex>
|
2493 | #include <color_vertex>
|
2494 | #include <morphcolor_vertex>
|
2495 | #include <beginnormal_vertex>
|
2496 | #include <morphnormal_vertex>
|
2497 | #include <skinbase_vertex>
|
2498 | #include <skinnormal_vertex>
|
2499 | #include <defaultnormal_vertex>
|
2500 | #include <normal_vertex>
|
2501 | #include <begin_vertex>
|
2502 | #include <morphtarget_vertex>
|
2503 | #include <skinning_vertex>
|
2504 | #include <displacementmap_vertex>
|
2505 | #include <project_vertex>
|
2506 | #include <logdepthbuf_vertex>
|
2507 | #include <clipping_planes_vertex>
|
2508 | vViewPosition = - mvPosition.xyz;
|
2509 | #include <worldpos_vertex>
|
2510 | #include <envmap_vertex>
|
2511 | #include <shadowmap_vertex>
|
2512 | #include <fog_vertex>
|
2513 | }`,Sk=`#define PHONG
|
2514 | uniform vec3 diffuse;
|
2515 | uniform vec3 emissive;
|
2516 | uniform vec3 specular;
|
2517 | uniform float shininess;
|
2518 | uniform float opacity;
|
2519 | #include <common>
|
2520 | #include <packing>
|
2521 | #include <dithering_pars_fragment>
|
2522 | #include <color_pars_fragment>
|
2523 | #include <uv_pars_fragment>
|
2524 | #include <uv2_pars_fragment>
|
2525 | #include <map_pars_fragment>
|
2526 | #include <alphamap_pars_fragment>
|
2527 | #include <alphatest_pars_fragment>
|
2528 | #include <aomap_pars_fragment>
|
2529 | #include <lightmap_pars_fragment>
|
2530 | #include <emissivemap_pars_fragment>
|
2531 | #include <envmap_common_pars_fragment>
|
2532 | #include <envmap_pars_fragment>
|
2533 | #include <fog_pars_fragment>
|
2534 | #include <bsdfs>
|
2535 | #include <lights_pars_begin>
|
2536 | #include <normal_pars_fragment>
|
2537 | #include <lights_phong_pars_fragment>
|
2538 | #include <shadowmap_pars_fragment>
|
2539 | #include <bumpmap_pars_fragment>
|
2540 | #include <normalmap_pars_fragment>
|
2541 | #include <specularmap_pars_fragment>
|
2542 | #include <logdepthbuf_pars_fragment>
|
2543 | #include <clipping_planes_pars_fragment>
|
2544 | void main() {
|
2545 | #include <clipping_planes_fragment>
|
2546 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2547 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
2548 | vec3 totalEmissiveRadiance = emissive;
|
2549 | #include <logdepthbuf_fragment>
|
2550 | #include <map_fragment>
|
2551 | #include <color_fragment>
|
2552 | #include <alphamap_fragment>
|
2553 | #include <alphatest_fragment>
|
2554 | #include <specularmap_fragment>
|
2555 | #include <normal_fragment_begin>
|
2556 | #include <normal_fragment_maps>
|
2557 | #include <emissivemap_fragment>
|
2558 | #include <lights_phong_fragment>
|
2559 | #include <lights_fragment_begin>
|
2560 | #include <lights_fragment_maps>
|
2561 | #include <lights_fragment_end>
|
2562 | #include <aomap_fragment>
|
2563 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
2564 | #include <envmap_fragment>
|
2565 | #include <output_fragment>
|
2566 | #include <tonemapping_fragment>
|
2567 | #include <encodings_fragment>
|
2568 | #include <fog_fragment>
|
2569 | #include <premultiplied_alpha_fragment>
|
2570 | #include <dithering_fragment>
|
2571 | }`,Ak=`#define STANDARD
|
2572 | varying vec3 vViewPosition;
|
2573 | #ifdef USE_TRANSMISSION
|
2574 | varying vec3 vWorldPosition;
|
2575 | #endif
|
2576 | #include <common>
|
2577 | #include <uv_pars_vertex>
|
2578 | #include <uv2_pars_vertex>
|
2579 | #include <displacementmap_pars_vertex>
|
2580 | #include <color_pars_vertex>
|
2581 | #include <fog_pars_vertex>
|
2582 | #include <normal_pars_vertex>
|
2583 | #include <morphtarget_pars_vertex>
|
2584 | #include <skinning_pars_vertex>
|
2585 | #include <shadowmap_pars_vertex>
|
2586 | #include <logdepthbuf_pars_vertex>
|
2587 | #include <clipping_planes_pars_vertex>
|
2588 | void main() {
|
2589 | #include <uv_vertex>
|
2590 | #include <uv2_vertex>
|
2591 | #include <color_vertex>
|
2592 | #include <morphcolor_vertex>
|
2593 | #include <beginnormal_vertex>
|
2594 | #include <morphnormal_vertex>
|
2595 | #include <skinbase_vertex>
|
2596 | #include <skinnormal_vertex>
|
2597 | #include <defaultnormal_vertex>
|
2598 | #include <normal_vertex>
|
2599 | #include <begin_vertex>
|
2600 | #include <morphtarget_vertex>
|
2601 | #include <skinning_vertex>
|
2602 | #include <displacementmap_vertex>
|
2603 | #include <project_vertex>
|
2604 | #include <logdepthbuf_vertex>
|
2605 | #include <clipping_planes_vertex>
|
2606 | vViewPosition = - mvPosition.xyz;
|
2607 | #include <worldpos_vertex>
|
2608 | #include <shadowmap_vertex>
|
2609 | #include <fog_vertex>
|
2610 | #ifdef USE_TRANSMISSION
|
2611 | vWorldPosition = worldPosition.xyz;
|
2612 | #endif
|
2613 | }`,_k=`#define STANDARD
|
2614 | #ifdef PHYSICAL
|
2615 | #define IOR
|
2616 | #define SPECULAR
|
2617 | #endif
|
2618 | uniform vec3 diffuse;
|
2619 | uniform vec3 emissive;
|
2620 | uniform float roughness;
|
2621 | uniform float metalness;
|
2622 | uniform float opacity;
|
2623 | #ifdef IOR
|
2624 | uniform float ior;
|
2625 | #endif
|
2626 | #ifdef SPECULAR
|
2627 | uniform float specularIntensity;
|
2628 | uniform vec3 specularColor;
|
2629 | #ifdef USE_SPECULARINTENSITYMAP
|
2630 | uniform sampler2D specularIntensityMap;
|
2631 | #endif
|
2632 | #ifdef USE_SPECULARCOLORMAP
|
2633 | uniform sampler2D specularColorMap;
|
2634 | #endif
|
2635 | #endif
|
2636 | #ifdef USE_CLEARCOAT
|
2637 | uniform float clearcoat;
|
2638 | uniform float clearcoatRoughness;
|
2639 | #endif
|
2640 | #ifdef USE_IRIDESCENCE
|
2641 | uniform float iridescence;
|
2642 | uniform float iridescenceIOR;
|
2643 | uniform float iridescenceThicknessMinimum;
|
2644 | uniform float iridescenceThicknessMaximum;
|
2645 | #endif
|
2646 | #ifdef USE_SHEEN
|
2647 | uniform vec3 sheenColor;
|
2648 | uniform float sheenRoughness;
|
2649 | #ifdef USE_SHEENCOLORMAP
|
2650 | uniform sampler2D sheenColorMap;
|
2651 | #endif
|
2652 | #ifdef USE_SHEENROUGHNESSMAP
|
2653 | uniform sampler2D sheenRoughnessMap;
|
2654 | #endif
|
2655 | #endif
|
2656 | varying vec3 vViewPosition;
|
2657 | #include <common>
|
2658 | #include <packing>
|
2659 | #include <dithering_pars_fragment>
|
2660 | #include <color_pars_fragment>
|
2661 | #include <uv_pars_fragment>
|
2662 | #include <uv2_pars_fragment>
|
2663 | #include <map_pars_fragment>
|
2664 | #include <alphamap_pars_fragment>
|
2665 | #include <alphatest_pars_fragment>
|
2666 | #include <aomap_pars_fragment>
|
2667 | #include <lightmap_pars_fragment>
|
2668 | #include <emissivemap_pars_fragment>
|
2669 | #include <bsdfs>
|
2670 | #include <iridescence_fragment>
|
2671 | #include <cube_uv_reflection_fragment>
|
2672 | #include <envmap_common_pars_fragment>
|
2673 | #include <envmap_physical_pars_fragment>
|
2674 | #include <fog_pars_fragment>
|
2675 | #include <lights_pars_begin>
|
2676 | #include <normal_pars_fragment>
|
2677 | #include <lights_physical_pars_fragment>
|
2678 | #include <transmission_pars_fragment>
|
2679 | #include <shadowmap_pars_fragment>
|
2680 | #include <bumpmap_pars_fragment>
|
2681 | #include <normalmap_pars_fragment>
|
2682 | #include <clearcoat_pars_fragment>
|
2683 | #include <iridescence_pars_fragment>
|
2684 | #include <roughnessmap_pars_fragment>
|
2685 | #include <metalnessmap_pars_fragment>
|
2686 | #include <logdepthbuf_pars_fragment>
|
2687 | #include <clipping_planes_pars_fragment>
|
2688 | void main() {
|
2689 | #include <clipping_planes_fragment>
|
2690 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2691 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
2692 | vec3 totalEmissiveRadiance = emissive;
|
2693 | #include <logdepthbuf_fragment>
|
2694 | #include <map_fragment>
|
2695 | #include <color_fragment>
|
2696 | #include <alphamap_fragment>
|
2697 | #include <alphatest_fragment>
|
2698 | #include <roughnessmap_fragment>
|
2699 | #include <metalnessmap_fragment>
|
2700 | #include <normal_fragment_begin>
|
2701 | #include <normal_fragment_maps>
|
2702 | #include <clearcoat_normal_fragment_begin>
|
2703 | #include <clearcoat_normal_fragment_maps>
|
2704 | #include <emissivemap_fragment>
|
2705 | #include <lights_physical_fragment>
|
2706 | #include <lights_fragment_begin>
|
2707 | #include <lights_fragment_maps>
|
2708 | #include <lights_fragment_end>
|
2709 | #include <aomap_fragment>
|
2710 | vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
2711 | vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
2712 | #include <transmission_fragment>
|
2713 | vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
2714 | #ifdef USE_SHEEN
|
2715 | float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
2716 | outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
|
2717 | #endif
|
2718 | #ifdef USE_CLEARCOAT
|
2719 | float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
2720 | vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
2721 | outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
|
2722 | #endif
|
2723 | #include <output_fragment>
|
2724 | #include <tonemapping_fragment>
|
2725 | #include <encodings_fragment>
|
2726 | #include <fog_fragment>
|
2727 | #include <premultiplied_alpha_fragment>
|
2728 | #include <dithering_fragment>
|
2729 | }`,Ek=`#define TOON
|
2730 | varying vec3 vViewPosition;
|
2731 | #include <common>
|
2732 | #include <uv_pars_vertex>
|
2733 | #include <uv2_pars_vertex>
|
2734 | #include <displacementmap_pars_vertex>
|
2735 | #include <color_pars_vertex>
|
2736 | #include <fog_pars_vertex>
|
2737 | #include <normal_pars_vertex>
|
2738 | #include <morphtarget_pars_vertex>
|
2739 | #include <skinning_pars_vertex>
|
2740 | #include <shadowmap_pars_vertex>
|
2741 | #include <logdepthbuf_pars_vertex>
|
2742 | #include <clipping_planes_pars_vertex>
|
2743 | void main() {
|
2744 | #include <uv_vertex>
|
2745 | #include <uv2_vertex>
|
2746 | #include <color_vertex>
|
2747 | #include <morphcolor_vertex>
|
2748 | #include <beginnormal_vertex>
|
2749 | #include <morphnormal_vertex>
|
2750 | #include <skinbase_vertex>
|
2751 | #include <skinnormal_vertex>
|
2752 | #include <defaultnormal_vertex>
|
2753 | #include <normal_vertex>
|
2754 | #include <begin_vertex>
|
2755 | #include <morphtarget_vertex>
|
2756 | #include <skinning_vertex>
|
2757 | #include <displacementmap_vertex>
|
2758 | #include <project_vertex>
|
2759 | #include <logdepthbuf_vertex>
|
2760 | #include <clipping_planes_vertex>
|
2761 | vViewPosition = - mvPosition.xyz;
|
2762 | #include <worldpos_vertex>
|
2763 | #include <shadowmap_vertex>
|
2764 | #include <fog_vertex>
|
2765 | }`,Mk=`#define TOON
|
2766 | uniform vec3 diffuse;
|
2767 | uniform vec3 emissive;
|
2768 | uniform float opacity;
|
2769 | #include <common>
|
2770 | #include <packing>
|
2771 | #include <dithering_pars_fragment>
|
2772 | #include <color_pars_fragment>
|
2773 | #include <uv_pars_fragment>
|
2774 | #include <uv2_pars_fragment>
|
2775 | #include <map_pars_fragment>
|
2776 | #include <alphamap_pars_fragment>
|
2777 | #include <alphatest_pars_fragment>
|
2778 | #include <aomap_pars_fragment>
|
2779 | #include <lightmap_pars_fragment>
|
2780 | #include <emissivemap_pars_fragment>
|
2781 | #include <gradientmap_pars_fragment>
|
2782 | #include <fog_pars_fragment>
|
2783 | #include <bsdfs>
|
2784 | #include <lights_pars_begin>
|
2785 | #include <normal_pars_fragment>
|
2786 | #include <lights_toon_pars_fragment>
|
2787 | #include <shadowmap_pars_fragment>
|
2788 | #include <bumpmap_pars_fragment>
|
2789 | #include <normalmap_pars_fragment>
|
2790 | #include <logdepthbuf_pars_fragment>
|
2791 | #include <clipping_planes_pars_fragment>
|
2792 | void main() {
|
2793 | #include <clipping_planes_fragment>
|
2794 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2795 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
2796 | vec3 totalEmissiveRadiance = emissive;
|
2797 | #include <logdepthbuf_fragment>
|
2798 | #include <map_fragment>
|
2799 | #include <color_fragment>
|
2800 | #include <alphamap_fragment>
|
2801 | #include <alphatest_fragment>
|
2802 | #include <normal_fragment_begin>
|
2803 | #include <normal_fragment_maps>
|
2804 | #include <emissivemap_fragment>
|
2805 | #include <lights_toon_fragment>
|
2806 | #include <lights_fragment_begin>
|
2807 | #include <lights_fragment_maps>
|
2808 | #include <lights_fragment_end>
|
2809 | #include <aomap_fragment>
|
2810 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
2811 | #include <output_fragment>
|
2812 | #include <tonemapping_fragment>
|
2813 | #include <encodings_fragment>
|
2814 | #include <fog_fragment>
|
2815 | #include <premultiplied_alpha_fragment>
|
2816 | #include <dithering_fragment>
|
2817 | }`,Tk=`uniform float size;
|
2818 | uniform float scale;
|
2819 | #include <common>
|
2820 | #include <color_pars_vertex>
|
2821 | #include <fog_pars_vertex>
|
2822 | #include <morphtarget_pars_vertex>
|
2823 | #include <logdepthbuf_pars_vertex>
|
2824 | #include <clipping_planes_pars_vertex>
|
2825 | void main() {
|
2826 | #include <color_vertex>
|
2827 | #include <morphcolor_vertex>
|
2828 | #include <begin_vertex>
|
2829 | #include <morphtarget_vertex>
|
2830 | #include <project_vertex>
|
2831 | gl_PointSize = size;
|
2832 | #ifdef USE_SIZEATTENUATION
|
2833 | bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
2834 | if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
2835 | #endif
|
2836 | #include <logdepthbuf_vertex>
|
2837 | #include <clipping_planes_vertex>
|
2838 | #include <worldpos_vertex>
|
2839 | #include <fog_vertex>
|
2840 | }`,Ck=`uniform vec3 diffuse;
|
2841 | uniform float opacity;
|
2842 | #include <common>
|
2843 | #include <color_pars_fragment>
|
2844 | #include <map_particle_pars_fragment>
|
2845 | #include <alphatest_pars_fragment>
|
2846 | #include <fog_pars_fragment>
|
2847 | #include <logdepthbuf_pars_fragment>
|
2848 | #include <clipping_planes_pars_fragment>
|
2849 | void main() {
|
2850 | #include <clipping_planes_fragment>
|
2851 | vec3 outgoingLight = vec3( 0.0 );
|
2852 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2853 | #include <logdepthbuf_fragment>
|
2854 | #include <map_particle_fragment>
|
2855 | #include <color_fragment>
|
2856 | #include <alphatest_fragment>
|
2857 | outgoingLight = diffuseColor.rgb;
|
2858 | #include <output_fragment>
|
2859 | #include <tonemapping_fragment>
|
2860 | #include <encodings_fragment>
|
2861 | #include <fog_fragment>
|
2862 | #include <premultiplied_alpha_fragment>
|
2863 | }`,Pk=`#include <common>
|
2864 | #include <fog_pars_vertex>
|
2865 | #include <morphtarget_pars_vertex>
|
2866 | #include <skinning_pars_vertex>
|
2867 | #include <shadowmap_pars_vertex>
|
2868 | void main() {
|
2869 | #include <beginnormal_vertex>
|
2870 | #include <morphnormal_vertex>
|
2871 | #include <skinbase_vertex>
|
2872 | #include <skinnormal_vertex>
|
2873 | #include <defaultnormal_vertex>
|
2874 | #include <begin_vertex>
|
2875 | #include <morphtarget_vertex>
|
2876 | #include <skinning_vertex>
|
2877 | #include <project_vertex>
|
2878 | #include <worldpos_vertex>
|
2879 | #include <shadowmap_vertex>
|
2880 | #include <fog_vertex>
|
2881 | }`,Dk=`uniform vec3 color;
|
2882 | uniform float opacity;
|
2883 | #include <common>
|
2884 | #include <packing>
|
2885 | #include <fog_pars_fragment>
|
2886 | #include <bsdfs>
|
2887 | #include <lights_pars_begin>
|
2888 | #include <shadowmap_pars_fragment>
|
2889 | #include <shadowmask_pars_fragment>
|
2890 | void main() {
|
2891 | gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
2892 | #include <tonemapping_fragment>
|
2893 | #include <encodings_fragment>
|
2894 | #include <fog_fragment>
|
2895 | }`,Ik=`uniform float rotation;
|
2896 | uniform vec2 center;
|
2897 | #include <common>
|
2898 | #include <uv_pars_vertex>
|
2899 | #include <fog_pars_vertex>
|
2900 | #include <logdepthbuf_pars_vertex>
|
2901 | #include <clipping_planes_pars_vertex>
|
2902 | void main() {
|
2903 | #include <uv_vertex>
|
2904 | vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
2905 | vec2 scale;
|
2906 | scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
2907 | scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
2908 | #ifndef USE_SIZEATTENUATION
|
2909 | bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
2910 | if ( isPerspective ) scale *= - mvPosition.z;
|
2911 | #endif
|
2912 | vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
2913 | vec2 rotatedPosition;
|
2914 | rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
2915 | rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
2916 | mvPosition.xy += rotatedPosition;
|
2917 | gl_Position = projectionMatrix * mvPosition;
|
2918 | #include <logdepthbuf_vertex>
|
2919 | #include <clipping_planes_vertex>
|
2920 | #include <fog_vertex>
|
2921 | }`,Ok=`uniform vec3 diffuse;
|
2922 | uniform float opacity;
|
2923 | #include <common>
|
2924 | #include <uv_pars_fragment>
|
2925 | #include <map_pars_fragment>
|
2926 | #include <alphamap_pars_fragment>
|
2927 | #include <alphatest_pars_fragment>
|
2928 | #include <fog_pars_fragment>
|
2929 | #include <logdepthbuf_pars_fragment>
|
2930 | #include <clipping_planes_pars_fragment>
|
2931 | void main() {
|
2932 | #include <clipping_planes_fragment>
|
2933 | vec3 outgoingLight = vec3( 0.0 );
|
2934 | vec4 diffuseColor = vec4( diffuse, opacity );
|
2935 | #include <logdepthbuf_fragment>
|
2936 | #include <map_fragment>
|
2937 | #include <alphamap_fragment>
|
2938 | #include <alphatest_fragment>
|
2939 | outgoingLight = diffuseColor.rgb;
|
2940 | #include <output_fragment>
|
2941 | #include <tonemapping_fragment>
|
2942 | #include <encodings_fragment>
|
2943 | #include <fog_fragment>
|
2944 | }`,ut={alphamap_fragment:tB,alphamap_pars_fragment:rB,alphatest_fragment:nB,alphatest_pars_fragment:iB,aomap_fragment:sB,aomap_pars_fragment:oB,begin_vertex:aB,beginnormal_vertex:lB,bsdfs:cB,iridescence_fragment:uB,bumpmap_pars_fragment:hB,clipping_planes_fragment:dB,clipping_planes_pars_fragment:fB,clipping_planes_pars_vertex:pB,clipping_planes_vertex:mB,color_fragment:gB,color_pars_fragment:yB,color_pars_vertex:vB,color_vertex:xB,common:bB,cube_uv_reflection_fragment:wB,defaultnormal_vertex:SB,displacementmap_pars_vertex:AB,displacementmap_vertex:_B,emissivemap_fragment:EB,emissivemap_pars_fragment:MB,encodings_fragment:TB,encodings_pars_fragment:CB,envmap_fragment:PB,envmap_common_pars_fragment:DB,envmap_pars_fragment:IB,envmap_pars_vertex:OB,envmap_physical_pars_fragment:jB,envmap_vertex:RB,fog_vertex:LB,fog_pars_vertex:NB,fog_fragment:BB,fog_pars_fragment:FB,gradientmap_pars_fragment:kB,lightmap_fragment:VB,lightmap_pars_fragment:zB,lights_lambert_fragment:UB,lights_lambert_pars_fragment:GB,lights_pars_begin:HB,lights_toon_fragment:WB,lights_toon_pars_fragment:qB,lights_phong_fragment:YB,lights_phong_pars_fragment:XB,lights_physical_fragment:QB,lights_physical_pars_fragment:KB,lights_fragment_begin:ZB,lights_fragment_maps:JB,lights_fragment_end:$B,logdepthbuf_fragment:eF,logdepthbuf_pars_fragment:tF,logdepthbuf_pars_vertex:rF,logdepthbuf_vertex:nF,map_fragment:iF,map_pars_fragment:sF,map_particle_fragment:oF,map_particle_pars_fragment:aF,metalnessmap_fragment:lF,metalnessmap_pars_fragment:cF,morphcolor_vertex:uF,morphnormal_vertex:hF,morphtarget_pars_vertex:dF,morphtarget_vertex:fF,normal_fragment_begin:pF,normal_fragment_maps:mF,normal_pars_fragment:gF,normal_pars_vertex:yF,normal_vertex:vF,normalmap_pars_fragment:xF,clearcoat_normal_fragment_begin:bF,clearcoat_normal_fragment_maps:wF,clearcoat_pars_fragment:SF,iridescence_pars_fragment:AF,output_fragment:_F,packing:EF,premultiplied_alpha_fragment:MF,project_vertex:TF,dithering_fragment:CF,dithering_pars_fragment:PF,roughnessmap_fragment:DF,roughnessmap_pars_fragment:IF,shadowmap_pars_fragment:OF,shadowmap_pars_vertex:RF,shadowmap_vertex:LF,shadowmask_pars_fragment:NF,skinbase_vertex:BF,skinning_pars_vertex:FF,skinning_vertex:kF,skinnormal_vertex:VF,specularmap_fragment:zF,specularmap_pars_fragment:UF,tonemapping_fragment:GF,tonemapping_pars_fragment:HF,transmission_fragment:jF,transmission_pars_fragment:WF,uv_pars_fragment:qF,uv_pars_vertex:YF,uv_vertex:XF,uv2_pars_fragment:QF,uv2_pars_vertex:KF,uv2_vertex:ZF,worldpos_vertex:JF,background_vert:$F,background_frag:ek,backgroundCube_vert:tk,backgroundCube_frag:rk,cube_vert:nk,cube_frag:ik,depth_vert:sk,depth_frag:ok,distanceRGBA_vert:ak,distanceRGBA_frag:lk,equirect_vert:ck,equirect_frag:uk,linedashed_vert:hk,linedashed_frag:dk,meshbasic_vert:fk,meshbasic_frag:pk,meshlambert_vert:mk,meshlambert_frag:gk,meshmatcap_vert:yk,meshmatcap_frag:vk,meshnormal_vert:xk,meshnormal_frag:bk,meshphong_vert:wk,meshphong_frag:Sk,meshphysical_vert:Ak,meshphysical_frag:_k,meshtoon_vert:Ek,meshtoon_frag:Mk,points_vert:Tk,points_frag:Ck,shadow_vert:Pk,shadow_frag:Dk,sprite_vert:Ik,sprite_frag:Ok},we={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Gt},uv2Transform:{value:new Gt},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 N(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 Re(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 Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Gt}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new N(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Gt}}},Gs={basic:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.fog]),vertexShader:ut.meshbasic_vert,fragmentShader:ut.meshbasic_frag},lambert:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new Re(0)}}]),vertexShader:ut.meshlambert_vert,fragmentShader:ut.meshlambert_frag},phong:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:ut.meshphong_vert,fragmentShader:ut.meshphong_frag},standard:{uniforms:Jn([we.common,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.roughnessmap,we.metalnessmap,we.fog,we.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag},toon:{uniforms:Jn([we.common,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.gradientmap,we.fog,we.lights,{emissive:{value:new Re(0)}}]),vertexShader:ut.meshtoon_vert,fragmentShader:ut.meshtoon_frag},matcap:{uniforms:Jn([we.common,we.bumpmap,we.normalmap,we.displacementmap,we.fog,{matcap:{value:null}}]),vertexShader:ut.meshmatcap_vert,fragmentShader:ut.meshmatcap_frag},points:{uniforms:Jn([we.points,we.fog]),vertexShader:ut.points_vert,fragmentShader:ut.points_frag},dashed:{uniforms:Jn([we.common,we.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ut.linedashed_vert,fragmentShader:ut.linedashed_frag},depth:{uniforms:Jn([we.common,we.displacementmap]),vertexShader:ut.depth_vert,fragmentShader:ut.depth_frag},normal:{uniforms:Jn([we.common,we.bumpmap,we.normalmap,we.displacementmap,{opacity:{value:1}}]),vertexShader:ut.meshnormal_vert,fragmentShader:ut.meshnormal_frag},sprite:{uniforms:Jn([we.sprite,we.fog]),vertexShader:ut.sprite_vert,fragmentShader:ut.sprite_frag},background:{uniforms:{uvTransform:{value:new Gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ut.background_vert,fragmentShader:ut.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ut.backgroundCube_vert,fragmentShader:ut.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ut.cube_vert,fragmentShader:ut.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ut.equirect_vert,fragmentShader:ut.equirect_frag},distanceRGBA:{uniforms:Jn([we.common,we.displacementmap,{referencePosition:{value:new _},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ut.distanceRGBA_vert,fragmentShader:ut.distanceRGBA_frag},shadow:{uniforms:Jn([we.lights,we.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:ut.shadow_vert,fragmentShader:ut.shadow_frag}};Gs.physical={uniforms:Jn([Gs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new N(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 Re(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new N},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag};var Zm={r:0,b:0,g:0};function Rk(i,t,e,r,n,s,o){let a=new Re(0),l=s===!0?0:1,u,c,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 w=i.xr,S=w.getSession&&w.getSession();S&&S.environmentBlendMode==="additive"&&(x=null),x===null?m(a,l):x&&x.isColor&&(m(x,1),v=!0),(i.autoClear||v)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),x&&(x.isCubeTexture||x.mapping===Tu)?(c===void 0&&(c=new _r(new yn(1,1,1),new at({name:"BackgroundCubeMaterial",uniforms:su(Gs.backgroundCube.uniforms),vertexShader:Gs.backgroundCube.vertexShader,fragmentShader:Gs.backgroundCube.fragmentShader,side:Qr,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,E,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=x.encoding!==et,(h!==x||d!==x.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,f=i.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(u===void 0&&(u=new _r(new Ho(2,2),new at({name:"BackgroundMaterial",uniforms:su(Gs.background.uniforms),vertexShader:Gs.background.vertexShader,fragmentShader:Gs.background.fragmentShader,side:Pi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(u)),u.material.uniforms.t2D.value=x,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=x.encoding!==et,x.matrixAutoUpdate===!0&&x.updateMatrix(),u.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||f!==i.toneMapping)&&(u.material.needsUpdate=!0,h=x,d=x.version,f=i.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null))}function m(g,y){g.getRGB(Zm,oM(i)),r.buffers.color.setClear(Zm.r,Zm.g,Zm.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 Lk(i,t,e,r){let n=i.getParameter(34921),s=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=g(null),u=l,c=!1;function h(I,R,V,k,z){let G=!1;if(o){let H=m(k,V,R);u!==H&&(u=H,f(u.object)),G=y(I,k,V,z),G&&v(I,k,V,z)}else{let H=R.wireframe===!0;(u.geometry!==k.id||u.program!==V.id||u.wireframe!==H)&&(u.geometry=k.id,u.program=V.id,u.wireframe=H,G=!0)}z!==null&&e.update(z,34963),(G||c)&&(c=!1,b(I,R,V,k),z!==null&&i.bindBuffer(34963,e.get(z).buffer))}function d(){return r.isWebGL2?i.createVertexArray():s.createVertexArrayOES()}function f(I){return r.isWebGL2?i.bindVertexArray(I):s.bindVertexArrayOES(I)}function p(I){return r.isWebGL2?i.deleteVertexArray(I):s.deleteVertexArrayOES(I)}function m(I,R,V){let k=V.wireframe===!0,z=a[I.id];z===void 0&&(z={},a[I.id]=z);let G=z[R.id];G===void 0&&(G={},z[R.id]=G);let H=G[k];return H===void 0&&(H=g(d()),G[k]=H),H}function g(I){let R=[],V=[],k=[];for(let z=0;z<n;z++)R[z]=0,V[z]=0,k[z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:V,attributeDivisors:k,object:I,attributes:{},index:null}}function y(I,R,V,k){let z=u.attributes,G=R.attributes,H=0,Q=V.getAttributes();for(let F in Q)if(Q[F].location>=0){let Y=z[F],q=G[F];if(q===void 0&&(F==="instanceMatrix"&&I.instanceMatrix&&(q=I.instanceMatrix),F==="instanceColor"&&I.instanceColor&&(q=I.instanceColor)),Y===void 0||Y.attribute!==q||q&&Y.data!==q.data)return!0;H++}return u.attributesNum!==H||u.index!==k}function v(I,R,V,k){let z={},G=R.attributes,H=0,Q=V.getAttributes();for(let F in Q)if(Q[F].location>=0){let Y=G[F];Y===void 0&&(F==="instanceMatrix"&&I.instanceMatrix&&(Y=I.instanceMatrix),F==="instanceColor"&&I.instanceColor&&(Y=I.instanceColor));let q={};q.attribute=Y,Y&&Y.data&&(q.data=Y.data),z[F]=q,H++}u.attributes=z,u.attributesNum=H,u.index=k}function x(){let I=u.newAttributes;for(let R=0,V=I.length;R<V;R++)I[R]=0}function w(I){S(I,0)}function S(I,R){let V=u.newAttributes,k=u.enabledAttributes,z=u.attributeDivisors;V[I]=1,k[I]===0&&(i.enableVertexAttribArray(I),k[I]=1),z[I]!==R&&((r.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](I,R),z[I]=R)}function A(){let I=u.newAttributes,R=u.enabledAttributes;for(let V=0,k=R.length;V<k;V++)R[V]!==I[V]&&(i.disableVertexAttribArray(V),R[V]=0)}function E(I,R,V,k,z,G){r.isWebGL2===!0&&(V===5124||V===5125)?i.vertexAttribIPointer(I,R,V,z,G):i.vertexAttribPointer(I,R,V,k,z,G)}function b(I,R,V,k){if(r.isWebGL2===!1&&(I.isInstancedMesh||k.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;x();let z=k.attributes,G=V.getAttributes(),H=R.defaultAttributeValues;for(let Q in G){let F=G[Q];if(F.location>=0){let j=z[Q];if(j===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(j=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(j=I.instanceColor)),j!==void 0){let Y=j.normalized,q=j.itemSize,U=e.get(j);if(U===void 0)continue;let J=U.buffer,Z=U.type,K=U.bytesPerElement;if(j.isInterleavedBufferAttribute){let W=j.data,ye=W.stride,fe=j.offset;if(W.isInstancedInterleavedBuffer){for(let se=0;se<F.locationSize;se++)S(F.location+se,W.meshPerAttribute);I.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=W.meshPerAttribute*W.count)}else for(let se=0;se<F.locationSize;se++)w(F.location+se);i.bindBuffer(34962,J);for(let se=0;se<F.locationSize;se++)E(F.location+se,q/F.locationSize,Z,Y,ye*K,(fe+q/F.locationSize*se)*K)}else{if(j.isInstancedBufferAttribute){for(let W=0;W<F.locationSize;W++)S(F.location+W,j.meshPerAttribute);I.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let W=0;W<F.locationSize;W++)w(F.location+W);i.bindBuffer(34962,J);for(let W=0;W<F.locationSize;W++)E(F.location+W,q/F.locationSize,Z,Y,q*K,q/F.locationSize*W*K)}}else if(H!==void 0){let Y=H[Q];if(Y!==void 0)switch(Y.length){case 2:i.vertexAttrib2fv(F.location,Y);break;case 3:i.vertexAttrib3fv(F.location,Y);break;case 4:i.vertexAttrib4fv(F.location,Y);break;default:i.vertexAttrib1fv(F.location,Y)}}}}A()}function M(){P();for(let I in a){let R=a[I];for(let V in R){let k=R[V];for(let z in k)p(k[z].object),delete k[z];delete R[V]}delete a[I]}}function T(I){if(a[I.id]===void 0)return;let R=a[I.id];for(let V in R){let k=R[V];for(let z in k)p(k[z].object),delete k[z];delete R[V]}delete a[I.id]}function C(I){for(let R in a){let V=a[R];if(V[I.id]===void 0)continue;let k=V[I.id];for(let z in k)p(k[z].object),delete k[z];delete V[I.id]}}function P(){D(),c=!0,u!==l&&(u=l,f(u.object))}function D(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:P,resetDefaultState:D,dispose:M,releaseStatesOfGeometry:T,releaseStatesOfProgram:C,initAttributes:x,enableAttribute:w,disableUnusedAttributes:A}}function Nk(i,t,e,r){let n=r.isWebGL2,s;function o(u){s=u}function a(u,c){i.drawArrays(s,u,c),e.update(c,s,1)}function l(u,c,h){if(h===0)return;let d,f;if(n)d=i,f="drawArraysInstanced";else if(d=t.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,u,c,h),e.update(c,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function Bk(i,t,e){let r;function n(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let E=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(E){if(E==="highp"){if(i.getShaderPrecisionFormat(35633,36338).precision>0&&i.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";E="mediump"}return E==="mediump"&&i.getShaderPrecisionFormat(35633,36337).precision>0&&i.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&i 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 u=o||t.has("WEBGL_draw_buffers"),c=e.logarithmicDepthBuffer===!0,h=i.getParameter(34930),d=i.getParameter(35660),f=i.getParameter(3379),p=i.getParameter(34076),m=i.getParameter(34921),g=i.getParameter(36347),y=i.getParameter(36348),v=i.getParameter(36349),x=d>0,w=o||t.has("OES_texture_float"),S=x&&w,A=o?i.getParameter(36183):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:n,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:v,vertexTextures:x,floatFragmentTextures:w,floatVertexTextures:S,maxSamples:A}}function Fk(i){let t=this,e=null,r=0,n=!1,s=!1,o=new Or,a=new Gt,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||n;return n=d,r=h.length,f},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){e=c(h,d,0)},this.setState=function(h,d,f){let p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,y=i.get(h);if(!n||p===null||p.length===0||s&&!g)s?c(null):u();else{let v=s?0:r,x=v*4,w=y.clippingState||null;l.value=w,w=c(p,d,x,f);for(let S=0;S!==x;++S)w[S]=e[S];y.clippingState=w,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function u(){l.value!==e&&(l.value=e,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(h,d,f,p){let m=h!==null?h.length:0,g=null;if(m!==0){if(g=l.value,p!==!0||g===null){let y=f+m*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<y)&&(g=new Float32Array(y));for(let x=0,w=f;x!==m;++x,w+=4)o.copy(h[x]).applyMatrix4(v,a),o.normal.toArray(g,w),g[w+3]=o.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}function kk(i){let t=new WeakMap;function e(o,a){return a===pb?o.mapping=Ea:a===mb&&(o.mapping=Ma),o}function r(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===pb||a===mb)if(t.has(o)){let l=t.get(o).texture;return e(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let u=new wb(l.height/2);return u.fromEquirectangularTexture(i,o),t.set(o,u),o.addEventListener("dispose",n),e(u.texture,o.mapping)}else return null}}return o}function n(o){let a=o.target;a.removeEventListener("dispose",n);let l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function s(){t=new WeakMap}return{get:r,dispose:s}}var au=class extends gs{constructor(t=-1,e=1,r=1,n=-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=n,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,n,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=n,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,n=(this.top+this.bottom)/2,s=r-t,o=r+t,a=n+e,l=n-e;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,a-=c*this.view.offsetY,l=a-c*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}},ru=4,lE=[.125,.215,.35,.446,.526,.582],Fl=20,ib=new au,cE=new Re,sb=null,Bl=(1+Math.sqrt(5))/2,Jc=1/Bl,uE=[new _(1,1,1),new _(-1,1,1),new _(1,1,-1),new _(-1,1,-1),new _(0,Bl,Jc),new _(0,Bl,-Jc),new _(Jc,0,Bl),new _(-Jc,0,Bl),new _(Bl,Jc,0),new _(-Bl,Jc,0)],xg=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,n=100){sb=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,r,n,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=fE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=dE(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(sb),t.scissorTest=!1,Jm(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ea||t.mapping===Ma?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),sb=this._renderer.getRenderTarget();let r=e||this._allocateTargets();return this._textureToCubeUV(t,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,r={magFilter:Je,minFilter:Je,generateMipmaps:!1,type:Uo,format:$n,encoding:Di,depthBuffer:!1},n=hE(t,e,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=hE(t,e,r);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Vk(s)),this._blurMaterial=zk(s,t,e)}return n}_compileMaterial(t){let e=new _r(this._lodPlanes[0],t);this._renderer.compile(e,ib)}_sceneToCubeUV(t,e,r,n){let a=new Ir(90,1,e,r),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,d=c.toneMapping;c.getClearColor(cE),c.toneMapping=zo,c.autoClear=!1;let f=new Go({name:"PMREM.Background",side:Qr,depthWrite:!1,depthTest:!1}),p=new _r(new yn,f),m=!1,g=t.background;g?g.isColor&&(f.color.copy(g),t.background=null,m=!0):(f.color.copy(cE),m=!0);for(let y=0;y<6;y++){let v=y%3;v===0?(a.up.set(0,l[y],0),a.lookAt(u[y],0,0)):v===1?(a.up.set(0,0,l[y]),a.lookAt(0,u[y],0)):(a.up.set(0,l[y],0),a.lookAt(0,0,u[y]));let x=this._cubeSize;Jm(n,v*x,y>2?x:0,x,x),c.setRenderTarget(n),m&&c.render(p,a),c.render(t,a)}p.geometry.dispose(),p.material.dispose(),c.toneMapping=d,c.autoClear=h,t.background=g}_textureToCubeUV(t,e){let r=this._renderer,n=t.mapping===Ea||t.mapping===Ma;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=fE()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=dE());let s=n?this._cubemapMaterial:this._equirectMaterial,o=new _r(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;let l=this._cubeSize;Jm(e,0,0,3*l,2*l),r.setRenderTarget(e),r.render(o,ib)}_applyPMREM(t){let e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){let s=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=uE[(n-1)%uE.length];this._blur(t,n-1,n,s,o)}e.autoClear=r}_blur(t,e,r,n,s){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,r,n,"latitudinal",s),this._halfBlur(o,t,r,r,n,"longitudinal",s)}_halfBlur(t,e,r,n,s,o,a){let l=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let c=3,h=new _r(this._lodPlanes[n],u),d=u.uniforms,f=this._sizeLods[r]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Fl-1),m=s/p,g=isFinite(s)?1+Math.floor(c*m):Fl;g>Fl&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Fl}`);let y=[],v=0;for(let E=0;E<Fl;++E){let b=E/m,M=Math.exp(-b*b/2);y.push(M),E===0?v+=M:E<g&&(v+=2*M)}for(let E=0;E<y.length;E++)y[E]=y[E]/v;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=y,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:x}=this;d.dTheta.value=p,d.mipInt.value=x-r;let w=this._sizeLods[n],S=3*w*(n>x-ru?n-x+ru:0),A=4*(this._cubeSize-w);Jm(e,S,A,3*w,2*w),l.setRenderTarget(e),l.render(h,ib)}};function Vk(i){let t=[],e=[],r=[],n=i,s=i-ru+1+lE.length;for(let o=0;o<s;o++){let a=Math.pow(2,n);e.push(a);let l=1/a;o>i-ru?l=lE[o-i+ru-1]:o===0&&(l=0),r.push(l);let u=1/(a-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=6,p=6,m=3,g=2,y=1,v=new Float32Array(m*p*f),x=new Float32Array(g*p*f),w=new Float32Array(y*p*f);for(let A=0;A<f;A++){let E=A%3*2/3-1,b=A>2?0:-1,M=[E,b,0,E+2/3,b,0,E+2/3,b+1,0,E,b,0,E+2/3,b+1,0,E,b+1,0];v.set(M,m*p*A),x.set(d,g*p*A);let T=[A,A,A,A,A,A];w.set(T,y*p*A)}let S=new Ae;S.setAttribute("position",new Ge(v,m)),S.setAttribute("uv",new Ge(x,g)),S.setAttribute("faceIndex",new Ge(w,y)),t.push(S),n>ru&&n--}return{lodPlanes:t,sizeLods:e,sigmas:r}}function hE(i,t,e){let r=new ht(i,t,e);return r.texture.mapping=Tu,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Jm(i,t,e,r,n){i.viewport.set(t,e,r,n),i.scissor.set(t,e,r,n)}function zk(i,t,e){let r=new Float32Array(Fl),n=new _(0,1,0);return new at({name:"SphericalGaussianBlur",defines:{n:Fl,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:ew(),fragmentShader:`
|
2945 |
|
2946 | precision mediump float;
|
2947 | precision mediump int;
|
2948 |
|
2949 | varying vec3 vOutputDirection;
|
2950 |
|
2951 | uniform sampler2D envMap;
|
2952 | uniform int samples;
|
2953 | uniform float weights[ n ];
|
2954 | uniform bool latitudinal;
|
2955 | uniform float dTheta;
|
2956 | uniform float mipInt;
|
2957 | uniform vec3 poleAxis;
|
2958 |
|
2959 | #define ENVMAP_TYPE_CUBE_UV
|
2960 | #include <cube_uv_reflection_fragment>
|
2961 |
|
2962 | vec3 getSample( float theta, vec3 axis ) {
|
2963 |
|
2964 | float cosTheta = cos( theta );
|
2965 | // Rodrigues' axis-angle rotation
|
2966 | vec3 sampleDirection = vOutputDirection * cosTheta
|
2967 | + cross( axis, vOutputDirection ) * sin( theta )
|
2968 | + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
2969 |
|
2970 | return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
2971 |
|
2972 | }
|
2973 |
|
2974 | void main() {
|
2975 |
|
2976 | vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
2977 |
|
2978 | if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
2979 |
|
2980 | axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
2981 |
|
2982 | }
|
2983 |
|
2984 | axis = normalize( axis );
|
2985 |
|
2986 | gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
2987 | gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
2988 |
|
2989 | for ( int i = 1; i < n; i++ ) {
|
2990 |
|
2991 | if ( i >= samples ) {
|
2992 |
|
2993 | break;
|
2994 |
|
2995 | }
|
2996 |
|
2997 | float theta = dTheta * float( i );
|
2998 | gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
2999 | gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
3000 |
|
3001 | }
|
3002 |
|
3003 | }
|
3004 | `,blending:Vt,depthTest:!1,depthWrite:!1})}function dE(){return new at({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ew(),fragmentShader:`
|
3005 |
|
3006 | precision mediump float;
|
3007 | precision mediump int;
|
3008 |
|
3009 | varying vec3 vOutputDirection;
|
3010 |
|
3011 | uniform sampler2D envMap;
|
3012 |
|
3013 | #include <common>
|
3014 |
|
3015 | void main() {
|
3016 |
|
3017 | vec3 outputDirection = normalize( vOutputDirection );
|
3018 | vec2 uv = equirectUv( outputDirection );
|
3019 |
|
3020 | gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
3021 |
|
3022 | }
|
3023 | `,blending:Vt,depthTest:!1,depthWrite:!1})}function fE(){return new at({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ew(),fragmentShader:`
|
3024 |
|
3025 | precision mediump float;
|
3026 | precision mediump int;
|
3027 |
|
3028 | uniform float flipEnvMap;
|
3029 |
|
3030 | varying vec3 vOutputDirection;
|
3031 |
|
3032 | uniform samplerCube envMap;
|
3033 |
|
3034 | void main() {
|
3035 |
|
3036 | gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
3037 |
|
3038 | }
|
3039 | `,blending:Vt,depthTest:!1,depthWrite:!1})}function ew(){return`
|
3040 |
|
3041 | precision mediump float;
|
3042 | precision mediump int;
|
3043 |
|
3044 | attribute float faceIndex;
|
3045 |
|
3046 | varying vec3 vOutputDirection;
|
3047 |
|
3048 | // RH coordinate system; PMREM face-indexing convention
|
3049 | vec3 getDirection( vec2 uv, float face ) {
|
3050 |
|
3051 | uv = 2.0 * uv - 1.0;
|
3052 |
|
3053 | vec3 direction = vec3( uv, 1.0 );
|
3054 |
|
3055 | if ( face == 0.0 ) {
|
3056 |
|
3057 | direction = direction.zyx; // ( 1, v, u ) pos x
|
3058 |
|
3059 | } else if ( face == 1.0 ) {
|
3060 |
|
3061 | direction = direction.xzy;
|
3062 | direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
3063 |
|
3064 | } else if ( face == 2.0 ) {
|
3065 |
|
3066 | direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
3067 |
|
3068 | } else if ( face == 3.0 ) {
|
3069 |
|
3070 | direction = direction.zyx;
|
3071 | direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
3072 |
|
3073 | } else if ( face == 4.0 ) {
|
3074 |
|
3075 | direction = direction.xzy;
|
3076 | direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
3077 |
|
3078 | } else if ( face == 5.0 ) {
|
3079 |
|
3080 | direction.z *= -1.0; // ( u, v, -1 ) neg z
|
3081 |
|
3082 | }
|
3083 |
|
3084 | return direction;
|
3085 |
|
3086 | }
|
3087 |
|
3088 | void main() {
|
3089 |
|
3090 | vOutputDirection = getDirection( uv, faceIndex );
|
3091 | gl_Position = vec4( position, 1.0 );
|
3092 |
|
3093 | }
|
3094 | `}function Uk(i){let t=new WeakMap,e=null;function r(a){if(a&&a.isTexture){let l=a.mapping,u=l===pb||l===mb,c=l===Ea||l===Ma;if(u||c)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=t.get(a);return e===null&&(e=new xg(i)),h=u?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(u&&h&&h.height>0||c&&h&&n(h)){e===null&&(e=new xg(i));let d=u?e.fromEquirectangular(a):e.fromCubemap(a);return t.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,u=6;for(let c=0;c<u;c++)a[c]!==void 0&&l++;return l===u}function s(a){let l=a.target;l.removeEventListener("dispose",s);let u=t.get(l);u!==void 0&&(t.delete(l),u.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:r,dispose:o}}function Gk(i){let t={};function e(r){if(t[r]!==void 0)return t[r];let n;switch(r){case"WEBGL_depth_texture":n=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=i.getExtension(r)}return t[r]=n,n}return{has:function(r){return e(r)!==null},init:function(r){r.isWebGL2?e("EXT_color_buffer_float"):(e("WEBGL_depth_texture"),e("OES_texture_float"),e("OES_texture_half_float"),e("OES_texture_half_float_linear"),e("OES_standard_derivatives"),e("OES_element_index_uint"),e("OES_vertex_array_object"),e("ANGLE_instanced_arrays")),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture")},get:function(r){let n=e(r);return n===null&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),n}}}function Hk(i,t,e,r){let n={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&t.remove(d.index);for(let p in d.attributes)t.remove(d.attributes[p]);d.removeEventListener("dispose",o),delete n[d.id];let f=s.get(d);f&&(t.remove(f),s.delete(d)),r.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function a(h,d){return n[d.id]===!0||(d.addEventListener("dispose",o),n[d.id]=!0,e.memory.geometries++),d}function l(h){let d=h.attributes;for(let p in d)t.update(d[p],34962);let f=h.morphAttributes;for(let p in f){let m=f[p];for(let g=0,y=m.length;g<y;g++)t.update(m[g],34962)}}function u(h){let d=[],f=h.index,p=h.attributes.position,m=0;if(f!==null){let v=f.array;m=f.version;for(let x=0,w=v.length;x<w;x+=3){let S=v[x+0],A=v[x+1],E=v[x+2];d.push(S,A,A,E,E,S)}}else{let v=p.array;m=p.version;for(let x=0,w=v.length/3-1;x<w;x+=3){let S=x+0,A=x+1,E=x+2;d.push(S,A,A,E,E,S)}}let g=new(iM(d)?js:vg)(d,1);g.version=m;let y=s.get(h);y&&t.remove(y),s.set(h,g)}function c(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version<f.version&&u(h)}else u(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:c}}function jk(i,t,e,r){let n=r.isWebGL2,s;function o(d){s=d}let a,l;function u(d){a=d.type,l=d.bytesPerElement}function c(d,f){i.drawElements(s,f,a,d*l),e.update(f,s,1)}function h(d,f,p){if(p===0)return;let m,g;if(n)m=i,g="drawElementsInstanced";else if(m=t.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",m===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[g](s,f,a,d*l,p),e.update(f,s,p)}this.setMode=o,this.setIndex=u,this.render=c,this.renderInstances=h}function Wk(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,o,a){switch(e.calls++,o){case 4:e.triangles+=a*(s/3);break;case 1:e.lines+=a*(s/2);break;case 3:e.lines+=a*(s-1);break;case 2:e.lines+=a*s;break;case 0:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function n(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:n,update:r}}function qk(i,t){return i[0]-t[0]}function Yk(i,t){return Math.abs(t[1])-Math.abs(i[1])}function Xk(i,t,e){let r={},n=new Float32Array(8),s=new WeakMap,o=new Xe,a=[];for(let u=0;u<8;u++)a[u]=[u,0];function l(u,c,h,d){let f=u.morphTargetInfluences;if(t.isWebGL2===!0){let p=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,m=p!==void 0?p.length:0,g=s.get(c);if(g===void 0||g.count!==m){let R=function(){D.dispose(),s.delete(c),c.removeEventListener("dispose",R)};g!==void 0&&g.texture.dispose();let x=c.morphAttributes.position!==void 0,w=c.morphAttributes.normal!==void 0,S=c.morphAttributes.color!==void 0,A=c.morphAttributes.position||[],E=c.morphAttributes.normal||[],b=c.morphAttributes.color||[],M=0;x===!0&&(M=1),w===!0&&(M=2),S===!0&&(M=3);let T=c.attributes.position.count*M,C=1;T>t.maxTextureSize&&(C=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);let P=new Float32Array(T*C*4*m),D=new mg(P,T,C,m);D.type=Xr,D.needsUpdate=!0;let I=M*4;for(let V=0;V<m;V++){let k=A[V],z=E[V],G=b[V],H=T*C*4*V;for(let Q=0;Q<k.count;Q++){let F=Q*I;x===!0&&(o.fromBufferAttribute(k,Q),P[H+F+0]=o.x,P[H+F+1]=o.y,P[H+F+2]=o.z,P[H+F+3]=0),w===!0&&(o.fromBufferAttribute(z,Q),P[H+F+4]=o.x,P[H+F+5]=o.y,P[H+F+6]=o.z,P[H+F+7]=0),S===!0&&(o.fromBufferAttribute(G,Q),P[H+F+8]=o.x,P[H+F+9]=o.y,P[H+F+10]=o.z,P[H+F+11]=G.itemSize===4?o.w:1)}}g={count:m,texture:D,size:new N(T,C)},s.set(c,g),c.addEventListener("dispose",R)}let y=0;for(let x=0;x<f.length;x++)y+=f[x];let v=c.morphTargetsRelative?1:1-y;d.getUniforms().setValue(i,"morphTargetBaseInfluence",v),d.getUniforms().setValue(i,"morphTargetInfluences",f),d.getUniforms().setValue(i,"morphTargetsTexture",g.texture,e),d.getUniforms().setValue(i,"morphTargetsTextureSize",g.size)}else{let p=f===void 0?0:f.length,m=r[c.id];if(m===void 0||m.length!==p){m=[];for(let w=0;w<p;w++)m[w]=[w,0];r[c.id]=m}for(let w=0;w<p;w++){let S=m[w];S[0]=w,S[1]=f[w]}m.sort(Yk);for(let w=0;w<8;w++)w<p&&m[w][1]?(a[w][0]=m[w][0],a[w][1]=m[w][1]):(a[w][0]=Number.MAX_SAFE_INTEGER,a[w][1]=0);a.sort(qk);let g=c.morphAttributes.position,y=c.morphAttributes.normal,v=0;for(let w=0;w<8;w++){let S=a[w],A=S[0],E=S[1];A!==Number.MAX_SAFE_INTEGER&&E?(g&&c.getAttribute("morphTarget"+w)!==g[A]&&c.setAttribute("morphTarget"+w,g[A]),y&&c.getAttribute("morphNormal"+w)!==y[A]&&c.setAttribute("morphNormal"+w,y[A]),n[w]=E,v+=E):(g&&c.hasAttribute("morphTarget"+w)===!0&&c.deleteAttribute("morphTarget"+w),y&&c.hasAttribute("morphNormal"+w)===!0&&c.deleteAttribute("morphNormal"+w),n[w]=0)}let x=c.morphTargetsRelative?1:1-v;d.getUniforms().setValue(i,"morphTargetBaseInfluence",x),d.getUniforms().setValue(i,"morphTargetInfluences",n)}}return{update:l}}function Qk(i,t,e,r){let n=new WeakMap;function s(l){let u=r.render.frame,c=l.geometry,h=t.get(l,c);return n.get(h)!==u&&(t.update(h),n.set(h,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),e.update(l.instanceMatrix,34962),l.instanceColor!==null&&e.update(l.instanceColor,34962)),h}function o(){n=new WeakMap}function a(l){let u=l.target;u.removeEventListener("dispose",a),e.remove(u.instanceMatrix),u.instanceColor!==null&&e.remove(u.instanceColor)}return{update:s,dispose:o}}var lM=new or,cM=new mg,uM=new gg,hM=new ou,pE=[],mE=[],gE=new Float32Array(16),yE=new Float32Array(9),vE=new Float32Array(4);function Pu(i,t,e){let r=i[0];if(r<=0||r>0)return i;let n=t*e,s=pE[n];if(s===void 0&&(s=new Float32Array(n),pE[n]=s),t!==0){r.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function tn(i,t){if(i.length!==t.length)return!1;for(let e=0,r=i.length;e<r;e++)if(i[e]!==t[e])return!1;return!0}function rn(i,t){for(let e=0,r=t.length;e<r;e++)i[e]=t[e]}function Ng(i,t){let e=mE[t];e===void 0&&(e=new Int32Array(t),mE[t]=e);for(let r=0;r!==t;++r)e[r]=i.allocateTextureUnit();return e}function Kk(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Zk(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(tn(e,t))return;i.uniform2fv(this.addr,t),rn(e,t)}}function Jk(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(tn(e,t))return;i.uniform3fv(this.addr,t),rn(e,t)}}function $k(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(tn(e,t))return;i.uniform4fv(this.addr,t),rn(e,t)}}function eV(i,t){let e=this.cache,r=t.elements;if(r===void 0){if(tn(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),rn(e,t)}else{if(tn(e,r))return;vE.set(r),i.uniformMatrix2fv(this.addr,!1,vE),rn(e,r)}}function tV(i,t){let e=this.cache,r=t.elements;if(r===void 0){if(tn(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),rn(e,t)}else{if(tn(e,r))return;yE.set(r),i.uniformMatrix3fv(this.addr,!1,yE),rn(e,r)}}function rV(i,t){let e=this.cache,r=t.elements;if(r===void 0){if(tn(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),rn(e,t)}else{if(tn(e,r))return;gE.set(r),i.uniformMatrix4fv(this.addr,!1,gE),rn(e,r)}}function nV(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function iV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(tn(e,t))return;i.uniform2iv(this.addr,t),rn(e,t)}}function sV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(tn(e,t))return;i.uniform3iv(this.addr,t),rn(e,t)}}function oV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(tn(e,t))return;i.uniform4iv(this.addr,t),rn(e,t)}}function aV(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function lV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(tn(e,t))return;i.uniform2uiv(this.addr,t),rn(e,t)}}function cV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(tn(e,t))return;i.uniform3uiv(this.addr,t),rn(e,t)}}function uV(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(tn(e,t))return;i.uniform4uiv(this.addr,t),rn(e,t)}}function hV(i,t,e){let r=this.cache,n=e.allocateTextureUnit();r[0]!==n&&(i.uniform1i(this.addr,n),r[0]=n),e.setTexture2D(t||lM,n)}function dV(i,t,e){let r=this.cache,n=e.allocateTextureUnit();r[0]!==n&&(i.uniform1i(this.addr,n),r[0]=n),e.setTexture3D(t||uM,n)}function fV(i,t,e){let r=this.cache,n=e.allocateTextureUnit();r[0]!==n&&(i.uniform1i(this.addr,n),r[0]=n),e.setTextureCube(t||hM,n)}function pV(i,t,e){let r=this.cache,n=e.allocateTextureUnit();r[0]!==n&&(i.uniform1i(this.addr,n),r[0]=n),e.setTexture2DArray(t||cM,n)}function mV(i){switch(i){case 5126:return Kk;case 35664:return Zk;case 35665:return Jk;case 35666:return $k;case 35674:return eV;case 35675:return tV;case 35676:return rV;case 5124:case 35670:return nV;case 35667:case 35671:return iV;case 35668:case 35672:return sV;case 35669:case 35673:return oV;case 5125:return aV;case 36294:return lV;case 36295:return cV;case 36296:return uV;case 35678:case 36198:case 36298:case 36306:case 35682:return hV;case 35679:case 36299:case 36307:return dV;case 35680:case 36300:case 36308:case 36293:return fV;case 36289:case 36303:case 36311:case 36292:return pV}}function gV(i,t){i.uniform1fv(this.addr,t)}function yV(i,t){let e=Pu(t,this.size,2);i.uniform2fv(this.addr,e)}function vV(i,t){let e=Pu(t,this.size,3);i.uniform3fv(this.addr,e)}function xV(i,t){let e=Pu(t,this.size,4);i.uniform4fv(this.addr,e)}function bV(i,t){let e=Pu(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function wV(i,t){let e=Pu(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function SV(i,t){let e=Pu(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function AV(i,t){i.uniform1iv(this.addr,t)}function _V(i,t){i.uniform2iv(this.addr,t)}function EV(i,t){i.uniform3iv(this.addr,t)}function MV(i,t){i.uniform4iv(this.addr,t)}function TV(i,t){i.uniform1uiv(this.addr,t)}function CV(i,t){i.uniform2uiv(this.addr,t)}function PV(i,t){i.uniform3uiv(this.addr,t)}function DV(i,t){i.uniform4uiv(this.addr,t)}function IV(i,t,e){let r=this.cache,n=t.length,s=Ng(e,n);tn(r,s)||(i.uniform1iv(this.addr,s),rn(r,s));for(let o=0;o!==n;++o)e.setTexture2D(t[o]||lM,s[o])}function OV(i,t,e){let r=this.cache,n=t.length,s=Ng(e,n);tn(r,s)||(i.uniform1iv(this.addr,s),rn(r,s));for(let o=0;o!==n;++o)e.setTexture3D(t[o]||uM,s[o])}function RV(i,t,e){let r=this.cache,n=t.length,s=Ng(e,n);tn(r,s)||(i.uniform1iv(this.addr,s),rn(r,s));for(let o=0;o!==n;++o)e.setTextureCube(t[o]||hM,s[o])}function LV(i,t,e){let r=this.cache,n=t.length,s=Ng(e,n);tn(r,s)||(i.uniform1iv(this.addr,s),rn(r,s));for(let o=0;o!==n;++o)e.setTexture2DArray(t[o]||cM,s[o])}function NV(i){switch(i){case 5126:return gV;case 35664:return yV;case 35665:return vV;case 35666:return xV;case 35674:return bV;case 35675:return wV;case 35676:return SV;case 5124:case 35670:return AV;case 35667:case 35671:return _V;case 35668:case 35672:return EV;case 35669:case 35673:return MV;case 5125:return TV;case 36294:return CV;case 36295:return PV;case 36296:return DV;case 35678:case 36198:case 36298:case 36306:case 35682:return IV;case 35679:case 36299:case 36307:return OV;case 35680:case 36300:case 36308:case 36293:return RV;case 36289:case 36303:case 36311:case 36292:return LV}}var Sb=class{constructor(t,e,r){this.id=t,this.addr=r,this.cache=[],this.setValue=mV(e.type)}},Ab=class{constructor(t,e,r){this.id=t,this.addr=r,this.cache=[],this.size=e.size,this.setValue=NV(e.type)}},_b=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,r){let n=this.seq;for(let s=0,o=n.length;s!==o;++s){let a=n[s];a.setValue(t,e[a.id],r)}}},ob=/(\w+)(\])?(\[|\.)?/g;function xE(i,t){i.seq.push(t),i.map[t.id]=t}function BV(i,t,e){let r=i.name,n=r.length;for(ob.lastIndex=0;;){let s=ob.exec(r),o=ob.lastIndex,a=s[1],l=s[2]==="]",u=s[3];if(l&&(a=a|0),u===void 0||u==="["&&o+2===n){xE(e,u===void 0?new Sb(a,i,t):new Ab(a,i,t));break}else{let h=e.map[a];h===void 0&&(h=new _b(a),xE(e,h)),e=h}}}var iu=class{constructor(t,e){this.seq=[],this.map={};let r=t.getProgramParameter(e,35718);for(let n=0;n<r;++n){let s=t.getActiveUniform(e,n),o=t.getUniformLocation(e,s.name);BV(s,o,this)}}setValue(t,e,r,n){let s=this.map[e];s!==void 0&&s.setValue(t,r,n)}setOptional(t,e,r){let n=e[r];n!==void 0&&this.setValue(t,r,n)}static upload(t,e,r,n){for(let s=0,o=e.length;s!==o;++s){let a=e[s],l=r[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,n)}}static seqWithValue(t,e){let r=[];for(let n=0,s=t.length;n!==s;++n){let o=t[n];o.id in e&&r.push(o)}return r}};function bE(i,t,e){let r=i.createShader(t);return i.shaderSource(r,e),i.compileShader(r),r}var FV=0;function kV(i,t){let e=i.split(`
|
3095 | `),r=[],n=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=n;o<s;o++){let a=o+1;r.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return r.join(`
|
3096 | `)}function VV(i){switch(i){case Di:return["Linear","( value )"];case et:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",i),["Linear","( value )"]}}function wE(i,t,e){let r=i.getShaderParameter(t,35713),n=i.getShaderInfoLog(t).trim();if(r&&n==="")return"";let s=/ERROR: 0:(\d+)/.exec(n);if(s){let o=parseInt(s[1]);return e.toUpperCase()+`
|
3097 |
|
3098 | `+n+`
|
3099 |
|
3100 | `+kV(i.getShaderSource(t),o)}else return n}function zV(i,t){let e=VV(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function UV(i,t){let e;switch(t){case tN:e="Linear";break;case rN:e="Reinhard";break;case nN:e="OptimizedCineon";break;case iN:e="ACESFilmic";break;case sN:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function GV(i){return[i.extensionDerivatives||!!i.envMapCubeUVHeight||i.bumpMap||i.tangentSpaceNormalMap||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ef).join(`
|
3101 | `)}function HV(i){let t=[];for(let e in i){let r=i[e];r!==!1&&t.push("#define "+e+" "+r)}return t.join(`
|
3102 | `)}function jV(i,t){let e={},r=i.getProgramParameter(t,35721);for(let n=0;n<r;n++){let s=i.getActiveAttrib(t,n),o=s.name,a=1;s.type===35674&&(a=2),s.type===35675&&(a=3),s.type===35676&&(a=4),e[o]={type:s.type,location:i.getAttribLocation(t,o),locationSize:a}}return e}function Ef(i){return i!==""}function SE(i,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function AE(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var WV=/^[ \t]*#include +<([\w\d./]+)>/gm;function Eb(i){return i.replace(WV,qV)}function qV(i,t){let e=ut[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return Eb(e)}var YV=/#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 _E(i){return i.replace(YV,XV)}function XV(i,t,e,r){let n="";for(let s=parseInt(t);s<parseInt(e);s++)n+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function EE(i){let t="precision "+i.precision+` float;
|
3103 | precision `+i.precision+" int;";return i.precision==="highp"?t+=`
|
3104 | #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
|
3105 | #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
|
3106 | #define LOW_PRECISION`),t}function QV(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Lg?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===R3?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===_f&&(t="SHADOWMAP_TYPE_VSM"),t}function KV(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ea:case Ma:t="ENVMAP_TYPE_CUBE";break;case Tu:t="ENVMAP_TYPE_CUBE_UV";break}return t}function ZV(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Ma:t="ENVMAP_MODE_REFRACTION";break}return t}function JV(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case $E:t="ENVMAP_BLENDING_MULTIPLY";break;case $3:t="ENVMAP_BLENDING_MIX";break;case eN:t="ENVMAP_BLENDING_ADD";break}return t}function $V(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:r,maxMip:e}}function ez(i,t,e,r){let n=i.getContext(),s=e.defines,o=e.vertexShader,a=e.fragmentShader,l=QV(e),u=KV(e),c=ZV(e),h=JV(e),d=$V(e),f=e.isWebGL2?"":GV(e),p=HV(s),m=n.createProgram(),g,y,v=e.glslVersion?"#version "+e.glslVersion+`
|
3107 | `:"";e.isRawShaderMaterial?(g=[p].filter(Ef).join(`
|
3108 | `),g.length>0&&(g+=`
|
3109 | `),y=[f,p].filter(Ef).join(`
|
3110 | `),y.length>0&&(y+=`
|
3111 | `)):(g=[EE(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 "+c:"",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",`
|
3112 | `].filter(Ef).join(`
|
3113 | `),y=[f,EE(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 "+u:"",e.envMap?"#define "+c:"",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!==zo?"#define TONE_MAPPING":"",e.toneMapping!==zo?ut.tonemapping_pars_fragment:"",e.toneMapping!==zo?UV("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",ut.encodings_pars_fragment,zV("linearToOutputTexel",e.outputEncoding),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
3114 | `].filter(Ef).join(`
|
3115 | `)),o=Eb(o),o=SE(o,e),o=AE(o,e),a=Eb(a),a=SE(a,e),a=AE(a,e),o=_E(o),a=_E(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es
|
3116 | `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
|
3117 | `)+`
|
3118 | `+g,y=["#define varying in",e.glslVersion===K_?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===K_?"":"#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(`
|
3119 | `)+`
|
3120 | `+y);let x=v+g+o,w=v+y+a,S=bE(n,35633,x),A=bE(n,35632,w);if(n.attachShader(m,S),n.attachShader(m,A),e.index0AttributeName!==void 0?n.bindAttribLocation(m,0,e.index0AttributeName):e.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m),i.debug.checkShaderErrors){let M=n.getProgramInfoLog(m).trim(),T=n.getShaderInfoLog(S).trim(),C=n.getShaderInfoLog(A).trim(),P=!0,D=!0;if(n.getProgramParameter(m,35714)===!1){P=!1;let I=wE(n,S,"vertex"),R=wE(n,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,35715)+`
|
3121 |
|
3122 | Program Info Log: `+M+`
|
3123 | `+I+`
|
3124 | `+R)}else M!==""?console.warn("THREE.WebGLProgram: Program Info Log:",M):(T===""||C==="")&&(D=!1);D&&(this.diagnostics={runnable:P,programLog:M,vertexShader:{log:T,prefix:g},fragmentShader:{log:C,prefix:y}})}n.deleteShader(S),n.deleteShader(A);let E;this.getUniforms=function(){return E===void 0&&(E=new iu(n,m)),E};let b;return this.getAttributes=function(){return b===void 0&&(b=jV(n,m)),b},this.destroy=function(){r.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.name=e.shaderName,this.id=FV++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=S,this.fragmentShader=A,this}var tz=0,Mb=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,r=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(t);return o.has(n)===!1&&(o.add(n),n.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 Tb(t),e.set(t,r)),r}},Tb=class{constructor(t){this.id=tz++,this.code=t,this.usedTimes=0}};function rz(i,t,e,r,n,s,o){let a=new Rf,l=new Mb,u=[],c=n.isWebGL2,h=n.logarithmicDepthBuffer,d=n.vertexTextures,f=n.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,M,T,C,P){let D=C.fog,I=P.geometry,R=b.isMeshStandardMaterial?C.environment:null,V=(b.isMeshStandardMaterial?e:t).get(b.envMap||R),k=!!V&&V.mapping===Tu?V.image.height:null,z=p[b.type];b.precision!==null&&(f=n.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let G=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,H=G!==void 0?G.length:0,Q=0;I.morphAttributes.position!==void 0&&(Q=1),I.morphAttributes.normal!==void 0&&(Q=2),I.morphAttributes.color!==void 0&&(Q=3);let F,j,Y,q;if(z){let ye=Gs[z];F=ye.vertexShader,j=ye.fragmentShader}else F=b.vertexShader,j=b.fragmentShader,l.update(b),Y=l.getVertexShaderID(b),q=l.getFragmentShaderID(b);let U=i.getRenderTarget(),J=b.alphaTest>0,Z=b.clearcoat>0,K=b.iridescence>0;return{isWebGL2:c,shaderID:z,shaderName:b.type,vertexShader:F,fragmentShader:j,defines:b.defines,customVertexShaderID:Y,customFragmentShaderID:q,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,instancing:P.isInstancedMesh===!0,instancingColor:P.isInstancedMesh===!0&&P.instanceColor!==null,supportsVertexTextures:d,outputEncoding:U===null?i.outputEncoding:U.isXRRenderTarget===!0?U.texture.encoding:Di,map:!!b.map,matcap:!!b.matcap,envMap:!!V,envMapMode:V&&V.mapping,envMapCubeUVHeight:k,lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,objectSpaceNormalMap:b.normalMapType===SN,tangentSpaceNormalMap:b.normalMapType===wN,decodeVideoTexture:!!b.map&&b.map.isVideoTexture===!0&&b.map.encoding===et,clearcoat:Z,clearcoatMap:Z&&!!b.clearcoatMap,clearcoatRoughnessMap:Z&&!!b.clearcoatRoughnessMap,clearcoatNormalMap:Z&&!!b.clearcoatNormalMap,iridescence:K,iridescenceMap:K&&!!b.iridescenceMap,iridescenceThicknessMap:K&&!!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===Aa,alphaMap:!!b.alphaMap,alphaTest:J,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&&!!I.attributes.tangent,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!I.attributes.color&&I.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:!!D,useFog:b.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:!!b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:h,skinning:P.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Q,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:i.shadowMap.enabled&&T.length>0,shadowMapType:i.shadowMap.type,toneMapping:b.toneMapped?i.toneMapping:zo,physicallyCorrectLights:i.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Ln,flipSided:b.side===Qr,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:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:b.customProgramCacheKey()}}function g(b){let M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(let T in b.defines)M.push(T),M.push(b.defines[T]);return b.isRawShaderMaterial===!1&&(y(M,b),v(M,b),M.push(i.outputEncoding)),M.push(b.customProgramCacheKey),M.join()}function y(b,M){b.push(M.precision),b.push(M.outputEncoding),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.combine),b.push(M.vertexUvs),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function v(b,M){a.disableAll(),M.isWebGL2&&a.enable(0),M.supportsVertexTextures&&a.enable(1),M.instancing&&a.enable(2),M.instancingColor&&a.enable(3),M.map&&a.enable(4),M.matcap&&a.enable(5),M.envMap&&a.enable(6),M.lightMap&&a.enable(7),M.aoMap&&a.enable(8),M.emissiveMap&&a.enable(9),M.bumpMap&&a.enable(10),M.normalMap&&a.enable(11),M.objectSpaceNormalMap&&a.enable(12),M.tangentSpaceNormalMap&&a.enable(13),M.clearcoat&&a.enable(14),M.clearcoatMap&&a.enable(15),M.clearcoatRoughnessMap&&a.enable(16),M.clearcoatNormalMap&&a.enable(17),M.iridescence&&a.enable(18),M.iridescenceMap&&a.enable(19),M.iridescenceThicknessMap&&a.enable(20),M.displacementMap&&a.enable(21),M.specularMap&&a.enable(22),M.roughnessMap&&a.enable(23),M.metalnessMap&&a.enable(24),M.gradientMap&&a.enable(25),M.alphaMap&&a.enable(26),M.alphaTest&&a.enable(27),M.vertexColors&&a.enable(28),M.vertexAlphas&&a.enable(29),M.vertexUvs&&a.enable(30),M.vertexTangents&&a.enable(31),M.uvsVertexOnly&&a.enable(32),b.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.skinning&&a.enable(4),M.morphTargets&&a.enable(5),M.morphNormals&&a.enable(6),M.morphColors&&a.enable(7),M.premultipliedAlpha&&a.enable(8),M.shadowMapEnabled&&a.enable(9),M.physicallyCorrectLights&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.specularIntensityMap&&a.enable(15),M.specularColorMap&&a.enable(16),M.transmission&&a.enable(17),M.transmissionMap&&a.enable(18),M.thicknessMap&&a.enable(19),M.sheen&&a.enable(20),M.sheenColorMap&&a.enable(21),M.sheenRoughnessMap&&a.enable(22),M.decodeVideoTexture&&a.enable(23),M.opaque&&a.enable(24),b.push(a.mask)}function x(b){let M=p[b.type],T;if(M){let C=Gs[M];T=ys.clone(C.uniforms)}else T=b.uniforms;return T}function w(b,M){let T;for(let C=0,P=u.length;C<P;C++){let D=u[C];if(D.cacheKey===M){T=D,++T.usedTimes;break}}return T===void 0&&(T=new ez(i,M,b,s),u.push(T)),T}function S(b){if(--b.usedTimes===0){let M=u.indexOf(b);u[M]=u[u.length-1],u.pop(),b.destroy()}}function A(b){l.remove(b)}function E(){l.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:x,acquireProgram:w,releaseProgram:S,releaseShaderCache:A,programs:u,dispose:E}}function nz(){let i=new WeakMap;function t(s){let o=i.get(s);return o===void 0&&(o={},i.set(s,o)),o}function e(s){i.delete(s)}function r(s,o,a){i.get(s)[o]=a}function n(){i=new WeakMap}return{get:t,remove:e,update:r,dispose:n}}function iz(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function ME(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function TE(){let i=[],t=0,e=[],r=[],n=[];function s(){t=0,e.length=0,r.length=0,n.length=0}function o(h,d,f,p,m,g){let y=i[t];return y===void 0?(y={id:h.id,object:h,geometry:d,material:f,groupOrder:p,renderOrder:h.renderOrder,z:m,group:g},i[t]=y):(y.id=h.id,y.object=h,y.geometry=d,y.material=f,y.groupOrder=p,y.renderOrder=h.renderOrder,y.z=m,y.group=g),t++,y}function a(h,d,f,p,m,g){let y=o(h,d,f,p,m,g);f.transmission>0?r.push(y):f.transparent===!0?n.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?n.unshift(y):e.unshift(y)}function u(h,d){e.length>1&&e.sort(h||iz),r.length>1&&r.sort(d||ME),n.length>1&&n.sort(d||ME)}function c(){for(let h=t,d=i.length;h<d;h++){let f=i[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:r,transparent:n,init:s,push:a,unshift:l,finish:c,sort:u}}function sz(){let i=new WeakMap;function t(r,n){let s=i.get(r),o;return s===void 0?(o=new TE,i.set(r,[o])):n>=s.length?(o=new TE,s.push(o)):o=s[n],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function oz(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new _,color:new Re};break;case"SpotLight":e={position:new _,direction:new _,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new _,color:new Re,distance:0,decay:0};break;case"HemisphereLight":e={direction:new _,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":e={color:new Re,position:new _,halfWidth:new _,halfHeight:new _};break}return i[t.id]=e,e}}}function az(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var lz=0;function cz(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function uz(i,t){let e=new oz,r=az(),n={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 c=0;c<9;c++)n.probe.push(new _);let s=new _,o=new ie,a=new ie;function l(c,h){let d=0,f=0,p=0;for(let C=0;C<9;C++)n.probe[C].set(0,0,0);let m=0,g=0,y=0,v=0,x=0,w=0,S=0,A=0,E=0,b=0;c.sort(cz);let M=h!==!0?Math.PI:1;for(let C=0,P=c.length;C<P;C++){let D=c[C],I=D.color,R=D.intensity,V=D.distance,k=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)d+=I.r*R*M,f+=I.g*R*M,p+=I.b*R*M;else if(D.isLightProbe)for(let z=0;z<9;z++)n.probe[z].addScaledVector(D.sh.coefficients[z],R);else if(D.isDirectionalLight){let z=e.get(D);if(z.color.copy(D.color).multiplyScalar(D.intensity*M),D.castShadow){let G=D.shadow,H=r.get(D);H.shadowBias=G.bias,H.shadowNormalBias=G.normalBias,H.shadowRadius=G.radius,H.shadowMapSize=G.mapSize,n.directionalShadow[m]=H,n.directionalShadowMap[m]=k,n.directionalShadowMatrix[m]=D.shadow.matrix,w++}n.directional[m]=z,m++}else if(D.isSpotLight){let z=e.get(D);z.position.setFromMatrixPosition(D.matrixWorld),z.color.copy(I).multiplyScalar(R*M),z.distance=V,z.coneCos=Math.cos(D.angle),z.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),z.decay=D.decay,n.spot[y]=z;let G=D.shadow;if(D.map&&(n.spotLightMap[E]=D.map,E++,G.updateMatrices(D),D.castShadow&&b++),n.spotLightMatrix[y]=G.matrix,D.castShadow){let H=r.get(D);H.shadowBias=G.bias,H.shadowNormalBias=G.normalBias,H.shadowRadius=G.radius,H.shadowMapSize=G.mapSize,n.spotShadow[y]=H,n.spotShadowMap[y]=k,A++}y++}else if(D.isRectAreaLight){let z=e.get(D);z.color.copy(I).multiplyScalar(R),z.halfWidth.set(D.width*.5,0,0),z.halfHeight.set(0,D.height*.5,0),n.rectArea[v]=z,v++}else if(D.isPointLight){let z=e.get(D);if(z.color.copy(D.color).multiplyScalar(D.intensity*M),z.distance=D.distance,z.decay=D.decay,D.castShadow){let G=D.shadow,H=r.get(D);H.shadowBias=G.bias,H.shadowNormalBias=G.normalBias,H.shadowRadius=G.radius,H.shadowMapSize=G.mapSize,H.shadowCameraNear=G.camera.near,H.shadowCameraFar=G.camera.far,n.pointShadow[g]=H,n.pointShadowMap[g]=k,n.pointShadowMatrix[g]=D.shadow.matrix,S++}n.point[g]=z,g++}else if(D.isHemisphereLight){let z=e.get(D);z.skyColor.copy(D.color).multiplyScalar(R*M),z.groundColor.copy(D.groundColor).multiplyScalar(R*M),n.hemi[x]=z,x++}}v>0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=we.LTC_FLOAT_1,n.rectAreaLTC2=we.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(n.rectAreaLTC1=we.LTC_HALF_1,n.rectAreaLTC2=we.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),n.ambient[0]=d,n.ambient[1]=f,n.ambient[2]=p;let T=n.hash;(T.directionalLength!==m||T.pointLength!==g||T.spotLength!==y||T.rectAreaLength!==v||T.hemiLength!==x||T.numDirectionalShadows!==w||T.numPointShadows!==S||T.numSpotShadows!==A||T.numSpotMaps!==E)&&(n.directional.length=m,n.spot.length=y,n.rectArea.length=v,n.point.length=g,n.hemi.length=x,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=A+E-b,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=b,T.directionalLength=m,T.pointLength=g,T.spotLength=y,T.rectAreaLength=v,T.hemiLength=x,T.numDirectionalShadows=w,T.numPointShadows=S,T.numSpotShadows=A,T.numSpotMaps=E,n.version=lz++)}function u(c,h){let d=0,f=0,p=0,m=0,g=0,y=h.matrixWorldInverse;for(let v=0,x=c.length;v<x;v++){let w=c[v];if(w.isDirectionalLight){let S=n.directional[d];S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(y),d++}else if(w.isSpotLight){let S=n.spot[p];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(y),S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(y),p++}else if(w.isRectAreaLight){let S=n.rectArea[m];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(y),a.identity(),o.copy(w.matrixWorld),o.premultiply(y),a.extractRotation(o),S.halfWidth.set(w.width*.5,0,0),S.halfHeight.set(0,w.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),m++}else if(w.isPointLight){let S=n.point[f];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(y),f++}else if(w.isHemisphereLight){let S=n.hemi[g];S.direction.setFromMatrixPosition(w.matrixWorld),S.direction.transformDirection(y),g++}}}return{setup:l,setupView:u,state:n}}function CE(i,t){let e=new uz(i,t),r=[],n=[];function s(){r.length=0,n.length=0}function o(h){r.push(h)}function a(h){n.push(h)}function l(h){e.setup(r,h)}function u(h){e.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:n,lights:e},setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a}}function hz(i,t){let e=new WeakMap;function r(s,o=0){let a=e.get(s),l;return a===void 0?(l=new CE(i,t),e.set(s,[l])):o>=a.length?(l=new CE(i,t),a.push(l)):l=a[o],l}function n(){e=new WeakMap}return{get:r,dispose:n}}var Nf=class extends Ul{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=vn,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}},Cb=class extends Ul{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new _,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}},dz=`void main() {
|
3125 | gl_Position = vec4( position, 1.0 );
|
3126 | }`,fz=`uniform sampler2D shadow_pass;
|
3127 | uniform vec2 resolution;
|
3128 | uniform float radius;
|
3129 | #include <packing>
|
3130 | void main() {
|
3131 | const float samples = float( VSM_SAMPLES );
|
3132 | float mean = 0.0;
|
3133 | float squared_mean = 0.0;
|
3134 | float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
3135 | float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
3136 | for ( float i = 0.0; i < samples; i ++ ) {
|
3137 | float uvOffset = uvStart + i * uvStride;
|
3138 | #ifdef HORIZONTAL_PASS
|
3139 | vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
3140 | mean += distribution.x;
|
3141 | squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
3142 | #else
|
3143 | float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
3144 | mean += depth;
|
3145 | squared_mean += depth * depth;
|
3146 | #endif
|
3147 | }
|
3148 | mean = mean / samples;
|
3149 | squared_mean = squared_mean / samples;
|
3150 | float std_dev = sqrt( squared_mean - mean * mean );
|
3151 | gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
3152 | }`;function pz(i,t,e){let r=new Lf,n=new N,s=new N,o=new Xe,a=new Nf({depthPacking:Jb}),l=new Cb,u={},c=e.maxTextureSize,h={[Pi]:Qr,[Qr]:Pi,[Ln]:Ln},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new N},radius:{value:4}},vertexShader:dz,fragmentShader:fz}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new _r(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Lg,this.render=function(w,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let E=i.getRenderTarget(),b=i.getActiveCubeFace(),M=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Vt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let C=0,P=w.length;C<P;C++){let D=w[C],I=D.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",D,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;n.copy(I.mapSize);let R=I.getFrameExtents();if(n.multiply(R),s.copy(I.mapSize),(n.x>c||n.y>c)&&(n.x>c&&(s.x=Math.floor(c/R.x),n.x=s.x*R.x,I.mapSize.x=s.x),n.y>c&&(s.y=Math.floor(c/R.y),n.y=s.y*R.y,I.mapSize.y=s.y)),I.map===null){let k=this.type!==_f?{minFilter:kt,magFilter:kt}:{};I.map=new ht(n.x,n.y,k),I.map.texture.name=D.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let V=I.getViewportCount();for(let k=0;k<V;k++){let z=I.getViewport(k);o.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),T.viewport(o),I.updateMatrices(D,k),r=I.getFrustum(),x(S,A,I.camera,D,this.type)}I.isPointLightShadow!==!0&&this.type===_f&&y(I,A),I.needsUpdate=!1}g.needsUpdate=!1,i.setRenderTarget(E,b,M)};function y(w,S){let A=t.update(m);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new ht(n.x,n.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,A,d,m,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,A,f,m,null)}function v(w,S,A,E,b,M){let T=null,C=A.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0)T=C;else if(T=A.isPointLight===!0?l:a,i.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let P=T.uuid,D=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let R=I[D];R===void 0&&(R=T.clone(),I[D]=R),T=R}return T.visible=S.visible,T.wireframe=S.wireframe,M===_f?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:h[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,A.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(A.matrixWorld),T.nearDistance=E,T.farDistance=b),T}function x(w,S,A,E,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===_f)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let C=t.update(w),P=w.material;if(Array.isArray(P)){let D=C.groups;for(let I=0,R=D.length;I<R;I++){let V=D[I],k=P[V.materialIndex];if(k&&k.visible){let z=v(w,k,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,z,w,V)}}}else if(P.visible){let D=v(w,P,E,A.near,A.far,b);i.renderBufferDirect(A,null,C,D,w,null)}}let T=w.children;for(let C=0,P=T.length;C<P;C++)x(T[C],S,A,E,b)}}function mz(i,t,e){let r=e.isWebGL2;function n(){let X=!1,ce=new Xe,ve=null,Ve=new Xe(0,0,0,0);return{setMask:function(Fe){ve!==Fe&&!X&&(i.colorMask(Fe,Fe,Fe,Fe),ve=Fe)},setLocked:function(Fe){X=Fe},setClear:function(Fe,Et,Hr,Pr,Pl){Pl===!0&&(Fe*=Pr,Et*=Pr,Hr*=Pr),ce.set(Fe,Et,Hr,Pr),Ve.equals(ce)===!1&&(i.clearColor(Fe,Et,Hr,Pr),Ve.copy(ce))},reset:function(){X=!1,ve=null,Ve.set(-1,0,0,0)}}}function s(){let X=!1,ce=null,ve=null,Ve=null;return{setTest:function(Fe){Fe?J(2929):Z(2929)},setMask:function(Fe){ce!==Fe&&!X&&(i.depthMask(Fe),ce=Fe)},setFunc:function(Fe){if(ve!==Fe){switch(Fe){case q3:i.depthFunc(512);break;case Y3:i.depthFunc(519);break;case X3:i.depthFunc(513);break;case fb:i.depthFunc(515);break;case Q3:i.depthFunc(514);break;case K3:i.depthFunc(518);break;case Z3:i.depthFunc(516);break;case J3:i.depthFunc(517);break;default:i.depthFunc(515)}ve=Fe}},setLocked:function(Fe){X=Fe},setClear:function(Fe){Ve!==Fe&&(i.clearDepth(Fe),Ve=Fe)},reset:function(){X=!1,ce=null,ve=null,Ve=null}}}function o(){let X=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Pl=null;return{setTest:function(hr){X||(hr?J(2960):Z(2960))},setMask:function(hr){ce!==hr&&!X&&(i.stencilMask(hr),ce=hr)},setFunc:function(hr,Do,Vi){(ve!==hr||Ve!==Do||Fe!==Vi)&&(i.stencilFunc(hr,Do,Vi),ve=hr,Ve=Do,Fe=Vi)},setOp:function(hr,Do,Vi){(Et!==hr||Hr!==Do||Pr!==Vi)&&(i.stencilOp(hr,Do,Vi),Et=hr,Hr=Do,Pr=Vi)},setLocked:function(hr){X=hr},setClear:function(hr){Pl!==hr&&(i.clearStencil(hr),Pl=hr)},reset:function(){X=!1,ce=null,ve=null,Ve=null,Fe=null,Et=null,Hr=null,Pr=null,Pl=null}}}let a=new n,l=new s,u=new o,c=new WeakMap,h=new WeakMap,d={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,R=i.getParameter(35661),V=!1,k=0,z=i.getParameter(7938);z.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(z)[1]),V=k>=1):z.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),V=k>=2);let G=null,H={},Q=i.getParameter(3088),F=i.getParameter(2978),j=new Xe().fromArray(Q),Y=new Xe().fromArray(F);function q(X,ce,ve){let Ve=new Uint8Array(4),Fe=i.createTexture();i.bindTexture(X,Fe),i.texParameteri(X,10241,9728),i.texParameteri(X,10240,9728);for(let Et=0;Et<ve;Et++)i.texImage2D(ce+Et,0,6408,1,1,0,6408,5121,Ve);return Fe}let U={};U[3553]=q(3553,3553,1),U[34067]=q(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),J(2929),l.setFunc(fb),Oe(!1),Ie(b_),J(2884),_e(Vt);function J(X){d[X]!==!0&&(i.enable(X),d[X]=!0)}function Z(X){d[X]!==!1&&(i.disable(X),d[X]=!1)}function K(X,ce){return f[X]!==ce?(i.bindFramebuffer(X,ce),f[X]=ce,r&&(X===36009&&(f[36160]=ce),X===36160&&(f[36009]=ce)),!0):!1}function W(X,ce){let ve=m,Ve=!1;if(X)if(ve=p.get(ce),ve===void 0&&(ve=[],p.set(ce,ve)),X.isWebGLMultipleRenderTargets){let Fe=X.texture;if(ve.length!==Fe.length||ve[0]!==36064){for(let Et=0,Hr=Fe.length;Et<Hr;Et++)ve[Et]=36064+Et;ve.length=Fe.length,Ve=!0}}else ve[0]!==36064&&(ve[0]=36064,Ve=!0);else ve[0]!==1029&&(ve[0]=1029,Ve=!0);Ve&&(e.isWebGL2?i.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ye(X){return g!==X?(i.useProgram(X),g=X,!0):!1}let fe={[$c]:32774,[N3]:32778,[B3]:32779};if(r)fe[__]=32775,fe[E_]=32776;else{let X=t.get("EXT_blend_minmax");X!==null&&(fe[__]=X.MIN_EXT,fe[E_]=X.MAX_EXT)}let se={[F3]:0,[k3]:1,[V3]:768,[ZE]:770,[W3]:776,[H3]:774,[U3]:772,[z3]:769,[JE]:771,[j3]:775,[G3]:773};function _e(X,ce,ve,Ve,Fe,Et,Hr,Pr){if(X===Vt){y===!0&&(Z(3042),y=!1);return}if(y===!1&&(J(3042),y=!0),X!==L3){if(X!==v||Pr!==M){if((x!==$c||A!==$c)&&(i.blendEquation(32774),x=$c,A=$c),Pr)switch(X){case Aa:i.blendFuncSeparate(1,771,1,771);break;case w_:i.blendFunc(1,1);break;case S_:i.blendFuncSeparate(0,769,0,1);break;case A_:i.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}else switch(X){case Aa:i.blendFuncSeparate(770,771,1,771);break;case w_:i.blendFunc(770,1);break;case S_:i.blendFuncSeparate(0,769,0,1);break;case A_:i.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",X);break}w=null,S=null,E=null,b=null,v=X,M=Pr}return}Fe=Fe||ce,Et=Et||ve,Hr=Hr||Ve,(ce!==x||Fe!==A)&&(i.blendEquationSeparate(fe[ce],fe[Fe]),x=ce,A=Fe),(ve!==w||Ve!==S||Et!==E||Hr!==b)&&(i.blendFuncSeparate(se[ve],se[Ve],se[Et],se[Hr]),w=ve,S=Ve,E=Et,b=Hr),v=X,M=!1}function xe(X,ce){X.side===Ln?Z(2884):J(2884);let ve=X.side===Qr;ce&&(ve=!ve),Oe(ve),X.blending===Aa&&X.transparent===!1?_e(Vt):_e(X.blending,X.blendEquation,X.blendSrc,X.blendDst,X.blendEquationAlpha,X.blendSrcAlpha,X.blendDstAlpha,X.premultipliedAlpha),l.setFunc(X.depthFunc),l.setTest(X.depthTest),l.setMask(X.depthWrite),a.setMask(X.colorWrite);let Ve=X.stencilWrite;u.setTest(Ve),Ve&&(u.setMask(X.stencilWriteMask),u.setFunc(X.stencilFunc,X.stencilRef,X.stencilFuncMask),u.setOp(X.stencilFail,X.stencilZFail,X.stencilZPass)),Me(X.polygonOffset,X.polygonOffsetFactor,X.polygonOffsetUnits),X.alphaToCoverage===!0?J(32926):Z(32926)}function Oe(X){T!==X&&(X?i.frontFace(2304):i.frontFace(2305),T=X)}function Ie(X){X!==I3?(J(2884),X!==C&&(X===b_?i.cullFace(1029):X===O3?i.cullFace(1028):i.cullFace(1032))):Z(2884),C=X}function Pe(X){X!==P&&(V&&i.lineWidth(X),P=X)}function Me(X,ce,ve){X?(J(32823),(D!==ce||I!==ve)&&(i.polygonOffset(ce,ve),D=ce,I=ve)):Z(32823)}function ze(X){X?J(3089):Z(3089)}function Ue(X){X===void 0&&(X=33984+R-1),G!==X&&(i.activeTexture(X),G=X)}function L(X,ce,ve){ve===void 0&&(G===null?ve=33984+R-1:ve=G);let Ve=H[ve];Ve===void 0&&(Ve={type:void 0,texture:void 0},H[ve]=Ve),(Ve.type!==X||Ve.texture!==ce)&&(G!==ve&&(i.activeTexture(ve),G=ve),i.bindTexture(X,ce||U[X]),Ve.type=X,Ve.texture=ce)}function O(){let X=H[G];X!==void 0&&X.type!==void 0&&(i.bindTexture(X.type,null),X.type=void 0,X.texture=void 0)}function re(){try{i.compressedTexImage2D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ue(){try{i.compressedTexImage3D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function me(){try{i.texSubImage2D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function De(){try{i.texSubImage3D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Te(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ee(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function le(){try{i.texStorage2D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ke(){try{i.texStorage3D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function ke(){try{i.texImage2D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function Ne(){try{i.texImage3D.apply(i,arguments)}catch(X){console.error("THREE.WebGLState:",X)}}function We(X){j.equals(X)===!1&&(i.scissor(X.x,X.y,X.z,X.w),j.copy(X))}function $e(X){Y.equals(X)===!1&&(i.viewport(X.x,X.y,X.z,X.w),Y.copy(X))}function _t(X,ce){let ve=h.get(ce);ve===void 0&&(ve=new WeakMap,h.set(ce,ve));let Ve=ve.get(X);Ve===void 0&&(Ve=i.getUniformBlockIndex(ce,X.name),ve.set(X,Ve))}function ir(X,ce){let Ve=h.get(ce).get(X);c.get(ce)!==Ve&&(i.uniformBlockBinding(ce,Ve,X.__bindingPointIndex),c.set(ce,Ve))}function Gr(){i.disable(3042),i.disable(2884),i.disable(2929),i.disable(32823),i.disable(3089),i.disable(2960),i.disable(32926),i.blendEquation(32774),i.blendFunc(1,0),i.blendFuncSeparate(1,0,1,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(513),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(519,0,4294967295),i.stencilOp(7680,7680,7680),i.clearStencil(0),i.cullFace(1029),i.frontFace(2305),i.polygonOffset(0,0),i.activeTexture(33984),i.bindFramebuffer(36160,null),r===!0&&(i.bindFramebuffer(36009,null),i.bindFramebuffer(36008,null)),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},G=null,H={},f={},p=new WeakMap,m=[],g=null,y=!1,v=null,x=null,w=null,S=null,A=null,E=null,b=null,M=!1,T=null,C=null,P=null,D=null,I=null,j.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:J,disable:Z,bindFramebuffer:K,drawBuffers:W,useProgram:ye,setBlending:_e,setMaterial:xe,setFlipSided:Oe,setCullFace:Ie,setLineWidth:Pe,setPolygonOffset:Me,setScissorTest:ze,activeTexture:Ue,bindTexture:L,unbindTexture:O,compressedTexImage2D:re,compressedTexImage3D:ue,texImage2D:ke,texImage3D:Ne,updateUBOMapping:_t,uniformBlockBinding:ir,texStorage2D:le,texStorage3D:Ke,texSubImage2D:me,texSubImage3D:De,compressedTexSubImage2D:Te,compressedTexSubImage3D:Ee,scissor:We,viewport:$e,reset:Gr}}function gz(i,t,e,r,n,s,o){let a=n.isWebGL2,l=n.maxTextures,u=n.maxCubemapSize,c=n.maxTextureSize,h=n.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):dg("canvas")}function x(L,O,re,ue){let me=1;if((L.width>ue||L.height>ue)&&(me=ue/Math.max(L.width,L.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let De=O?hg:Math.floor,Te=De(me*L.width),Ee=De(me*L.height);m===void 0&&(m=v(Te,Ee));let le=re?v(Te,Ee):m;return le.width=Te,le.height=Ee,le.getContext("2d").drawImage(L,0,0,Te,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Te+"x"+Ee+")."),le}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function w(L){return xb(L.width)&&xb(L.height)}function S(L){return a?!1:L.wrapS!==sr||L.wrapT!==sr||L.minFilter!==kt&&L.minFilter!==Je}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==kt&&L.minFilter!==Je}function E(L){i.generateMipmap(L)}function b(L,O,re,ue,me=!1){if(a===!1)return O;if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let De=O;return O===6403&&(re===5126&&(De=33326),re===5131&&(De=33325),re===5121&&(De=33321)),O===33319&&(re===5126&&(De=33328),re===5131&&(De=33327),re===5121&&(De=33323)),O===6408&&(re===5126&&(De=34836),re===5131&&(De=34842),re===5121&&(De=ue===et&&me===!1?35907:32856),re===32819&&(De=32854),re===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function M(L,O,re){return A(L,re)===!0||L.isFramebufferTexture&&L.minFilter!==kt&&L.minFilter!==Je?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function T(L){return L===kt||L===M_||L===Dx?9728:9729}function C(L){let O=L.target;O.removeEventListener("dispose",C),D(O),O.isVideoTexture&&p.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function D(L){let O=r.get(L);if(O.__webglInit===void 0)return;let re=L.source,ue=g.get(re);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(L),Object.keys(ue).length===0&&g.delete(re)}r.remove(L)}function I(L){let O=r.get(L);i.deleteTexture(O.__webglTexture);let re=L.source,ue=g.get(re);delete ue[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,re=r.get(L),ue=r.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(re.__webglFramebuffer[me]),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(re.__webglFramebuffer),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer),re.__webglMultisampledFramebuffer&&i.deleteFramebuffer(re.__webglMultisampledFramebuffer),re.__webglColorRenderbuffer)for(let me=0;me<re.__webglColorRenderbuffer.length;me++)re.__webglColorRenderbuffer[me]&&i.deleteRenderbuffer(re.__webglColorRenderbuffer[me]);re.__webglDepthRenderbuffer&&i.deleteRenderbuffer(re.__webglDepthRenderbuffer)}if(L.isWebGLMultipleRenderTargets)for(let me=0,De=O.length;me<De;me++){let Te=r.get(O[me]);Te.__webglTexture&&(i.deleteTexture(Te.__webglTexture),o.memory.textures--),r.remove(O[me])}r.remove(O),r.remove(L)}let V=0;function k(){V=0}function z(){let L=V;return L>=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),V+=1,L}function G(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let re=r.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&re.__version!==L.version){let ue=L.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(re,L,O);return}}e.bindTexture(3553,re.__webglTexture,33984+O)}function Q(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(35866,re.__webglTexture,33984+O)}function F(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(32879,re.__webglTexture,33984+O)}function j(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){K(re,L,O);return}e.bindTexture(34067,re.__webglTexture,33984+O)}let Y={[ps]:10497,[sr]:33071,[gb]:33648},q={[kt]:9728,[M_]:9984,[Dx]:9986,[Je]:9729,[oN]:9985,[zl]:9987};function U(L,O,re){if(re?(i.texParameteri(L,10242,Y[O.wrapS]),i.texParameteri(L,10243,Y[O.wrapT]),(L===32879||L===35866)&&i.texParameteri(L,32882,Y[O.wrapR]),i.texParameteri(L,10240,q[O.magFilter]),i.texParameteri(L,10241,q[O.minFilter])):(i.texParameteri(L,10242,33071),i.texParameteri(L,10243,33071),(L===32879||L===35866)&&i.texParameteri(L,32882,33071),(O.wrapS!==sr||O.wrapT!==sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(L,10240,T(O.magFilter)),i.texParameteri(L,10241,T(O.minFilter)),O.minFilter!==kt&&O.minFilter!==Je&&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 ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Dx&&O.minFilter!==zl||O.type===Xr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Uo&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(i.texParameterf(L,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,n.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function J(L,O){let re=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=G(O);if(De!==L.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,re=!0),me[De].usedTimes++;let Te=me[L.__cacheKey];Te!==void 0&&(me[L.__cacheKey].usedTimes--,Te.usedTimes===0&&I(O)),L.__cacheKey=De,L.__webglTexture=me[De].texture}return re}function Z(L,O,re){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=J(L,O),De=O.source;e.bindTexture(ue,L.__webglTexture,33984+re);let Te=r.get(De);if(De.version!==Te.__version||me===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=S(O)&&w(O.image)===!1,le=x(O.image,Ee,!1,c);le=Ue(O,le);let Ke=w(le)||a,ke=s.convert(O.format,O.encoding),Ne=s.convert(O.type),We=b(O.internalFormat,ke,Ne,O.encoding,O.isVideoTexture);U(ue,O,Ke);let $e,_t=O.mipmaps,ir=a&&O.isVideoTexture!==!0,Gr=Te.__version===void 0||me===!0,X=M(O,le,Ke);if(O.isDepthTexture)We=6402,a?O.type===Xr?We=36012:O.type===fs?We=33190:O.type===_a?We=35056:We=33189:O.type===Xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===kl&&We===6402&&O.type!==tM&&O.type!==fs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=fs,Ne=s.convert(O.type)),O.format===Ta&&We===6402&&(We=34041,O.type!==_a&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=_a,Ne=s.convert(O.type))),Gr&&(ir?e.texStorage2D(3553,1,We,le.width,le.height):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,null));else if(O.isDataTexture)if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,X,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,X,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,le.width,le.height,ke,Ne,le.data)):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,le.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){ir&&Gr&&e.texStorage3D(35866,X,We,_t[0].width,_t[0].height,le.depth);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,$e.data,0,0):e.compressedTexImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,$e.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage3D(35866,ce,0,0,0,$e.width,$e.height,le.depth,ke,Ne,$e.data):e.texImage3D(35866,ce,We,$e.width,$e.height,le.depth,0,ke,Ne,$e.data)}else{ir&&Gr&&e.texStorage2D(3553,X,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],O.format!==$n?ke!==null?ir?e.compressedTexSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,$e.data):e.compressedTexImage2D(3553,ce,We,$e.width,$e.height,0,$e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ir?e.texSubImage2D(3553,ce,0,0,$e.width,$e.height,ke,Ne,$e.data):e.texImage2D(3553,ce,We,$e.width,$e.height,0,ke,Ne,$e.data)}else if(O.isDataArrayTexture)ir?(Gr&&e.texStorage3D(35866,X,We,le.width,le.height,le.depth),e.texSubImage3D(35866,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(35866,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isData3DTexture)ir?(Gr&&e.texStorage3D(32879,X,We,le.width,le.height,le.depth),e.texSubImage3D(32879,0,0,0,0,le.width,le.height,le.depth,ke,Ne,le.data)):e.texImage3D(32879,0,We,le.width,le.height,le.depth,0,ke,Ne,le.data);else if(O.isFramebufferTexture){if(Gr)if(ir)e.texStorage2D(3553,X,We,le.width,le.height);else{let ce=le.width,ve=le.height;for(let Ve=0;Ve<X;Ve++)e.texImage2D(3553,Ve,We,ce,ve,0,ke,Ne,null),ce>>=1,ve>>=1}}else if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,X,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce<ve;ce++)$e=_t[ce],ir?e.texSubImage2D(3553,ce,0,0,ke,Ne,$e):e.texImage2D(3553,ce,We,ke,Ne,$e);O.generateMipmaps=!1}else ir?(Gr&&e.texStorage2D(3553,X,We,le.width,le.height),e.texSubImage2D(3553,0,0,0,ke,Ne,le)):e.texImage2D(3553,0,We,ke,Ne,le);A(O,Ke)&&E(ue),Te.__version=De.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function K(L,O,re){if(O.image.length!==6)return;let ue=J(L,O),me=O.source;e.bindTexture(34067,L.__webglTexture,33984+re);let De=r.get(me);if(me.version!==De.__version||ue===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Te=O.isCompressedTexture||O.image[0].isCompressedTexture,Ee=O.image[0]&&O.image[0].isDataTexture,le=[];for(let ce=0;ce<6;ce++)!Te&&!Ee?le[ce]=x(O.image[ce],!1,!0,u):le[ce]=Ee?O.image[ce].image:O.image[ce],le[ce]=Ue(O,le[ce]);let Ke=le[0],ke=w(Ke)||a,Ne=s.convert(O.format,O.encoding),We=s.convert(O.type),$e=b(O.internalFormat,Ne,We,O.encoding),_t=a&&O.isVideoTexture!==!0,ir=De.__version===void 0||ue===!0,Gr=M(O,Ke,ke);U(34067,O,ke);let X;if(Te){_t&&ir&&e.texStorage2D(34067,Gr,$e,Ke.width,Ke.height);for(let ce=0;ce<6;ce++){X=le[ce].mipmaps;for(let ve=0;ve<X.length;ve++){let Ve=X[ve];O.format!==$n?Ne!==null?_t?e.compressedTexSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,Ve.data):e.compressedTexImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_t?e.texSubImage2D(34069+ce,ve,0,0,Ve.width,Ve.height,Ne,We,Ve.data):e.texImage2D(34069+ce,ve,$e,Ve.width,Ve.height,0,Ne,We,Ve.data)}}}else{X=O.mipmaps,_t&&ir&&(X.length>0&&Gr++,e.texStorage2D(34067,Gr,$e,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){_t?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Ne,We,le[ce].data):e.texImage2D(34069+ce,0,$e,le[ce].width,le[ce].height,0,Ne,We,le[ce].data);for(let ve=0;ve<X.length;ve++){let Fe=X[ve].image[ce].image;_t?e.texSubImage2D(34069+ce,ve+1,0,0,Fe.width,Fe.height,Ne,We,Fe.data):e.texImage2D(34069+ce,ve+1,$e,Fe.width,Fe.height,0,Ne,We,Fe.data)}}else{_t?e.texSubImage2D(34069+ce,0,0,0,Ne,We,le[ce]):e.texImage2D(34069+ce,0,$e,Ne,We,le[ce]);for(let ve=0;ve<X.length;ve++){let Ve=X[ve];_t?e.texSubImage2D(34069+ce,ve+1,0,0,Ne,We,Ve.image[ce]):e.texImage2D(34069+ce,ve+1,$e,Ne,We,Ve.image[ce])}}}A(O,ke)&&E(34067),De.__version=me.version,O.onUpdate&&O.onUpdate(O)}L.__version=O.version}function W(L,O,re,ue,me){let De=s.convert(re.format,re.encoding),Te=s.convert(re.type),Ee=b(re.internalFormat,De,Te,re.encoding);r.get(O).__hasExternalTextures||(me===32879||me===35866?e.texImage3D(me,0,Ee,O.width,O.height,O.depth,0,De,Te,null):e.texImage2D(me,0,Ee,O.width,O.height,0,De,Te,null)),e.bindFramebuffer(36160,L),Me(O)?d.framebufferTexture2DMultisampleEXT(36160,ue,me,r.get(re).__webglTexture,0,Pe(O)):(me===3553||me>=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,r.get(re).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(L,O,re){if(i.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(re||Me(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Xr?ue=36012:me.type===fs&&(ue=33190));let De=Pe(O);Me(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,L)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me<ue.length;me++){let De=ue[me],Te=s.convert(De.format,De.encoding),Ee=s.convert(De.type),le=b(De.internalFormat,Te,Ee,De.encoding),Ke=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,Ke,le,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,Ke,le,O.width,O.height):i.renderbufferStorage(36161,le,O.width,O.height)}}i.bindRenderbuffer(36161,null)}function fe(L,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,L),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),H(O.depthTexture,0);let ue=r.get(O.depthTexture).__webglTexture,me=Pe(O);if(O.depthTexture.format===kl)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,me):i.framebufferTexture2D(36160,36096,3553,ue,0);else if(O.depthTexture.format===Ta)Me(O)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,me):i.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function se(L){let O=r.get(L),re=L.isWebGLCubeRenderTarget===!0;if(L.depthTexture&&!O.__autoAllocateDepthBuffer){if(re)throw new Error("target.depthTexture not supported in Cube render targets");fe(O.__webglFramebuffer,L)}else if(re){O.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)e.bindFramebuffer(36160,O.__webglFramebuffer[ue]),O.__webglDepthbuffer[ue]=i.createRenderbuffer(),ye(O.__webglDepthbuffer[ue],L,!1)}else e.bindFramebuffer(36160,O.__webglFramebuffer),O.__webglDepthbuffer=i.createRenderbuffer(),ye(O.__webglDepthbuffer,L,!1);e.bindFramebuffer(36160,null)}function _e(L,O,re){let ue=r.get(L);O!==void 0&&W(ue.__webglFramebuffer,L,L.texture,36064,3553),re!==void 0&&se(L)}function xe(L){let O=L.texture,re=r.get(L),ue=r.get(O);L.addEventListener("dispose",P),L.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=i.createTexture()),ue.__version=O.version,o.memory.textures++);let me=L.isWebGLCubeRenderTarget===!0,De=L.isWebGLMultipleRenderTargets===!0,Te=w(L)||a;if(me){re.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)re.__webglFramebuffer[Ee]=i.createFramebuffer()}else{if(re.__webglFramebuffer=i.createFramebuffer(),De)if(n.drawBuffers){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=r.get(Ee[le]);ke.__webglTexture===void 0&&(ke.__webglTexture=i.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&L.samples>0&&Me(L)===!1){let Ee=De?O:[O];re.__webglMultisampledFramebuffer=i.createFramebuffer(),re.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,re.__webglMultisampledFramebuffer);for(let le=0;le<Ee.length;le++){let Ke=Ee[le];re.__webglColorRenderbuffer[le]=i.createRenderbuffer(),i.bindRenderbuffer(36161,re.__webglColorRenderbuffer[le]);let ke=s.convert(Ke.format,Ke.encoding),Ne=s.convert(Ke.type),We=b(Ke.internalFormat,ke,Ne,Ke.encoding,L.isXRRenderTarget===!0),$e=Pe(L);i.renderbufferStorageMultisample(36161,$e,We,L.width,L.height),i.framebufferRenderbuffer(36160,36064+le,36161,re.__webglColorRenderbuffer[le])}i.bindRenderbuffer(36161,null),L.depthBuffer&&(re.__webglDepthRenderbuffer=i.createRenderbuffer(),ye(re.__webglDepthRenderbuffer,L,!0)),e.bindFramebuffer(36160,null)}}if(me){e.bindTexture(34067,ue.__webglTexture),U(34067,O,Te);for(let Ee=0;Ee<6;Ee++)W(re.__webglFramebuffer[Ee],L,O,36064,34069+Ee);A(O,Te)&&E(34067),e.unbindTexture()}else if(De){let Ee=L.texture;for(let le=0,Ke=Ee.length;le<Ke;le++){let ke=Ee[le],Ne=r.get(ke);e.bindTexture(3553,Ne.__webglTexture),U(3553,ke,Te),W(re.__webglFramebuffer,L,ke,36064+le,3553),A(ke,Te)&&E(3553)}e.unbindTexture()}else{let Ee=3553;(L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(a?Ee=L.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Ee,ue.__webglTexture),U(Ee,O,Te),W(re.__webglFramebuffer,L,O,36064,Ee),A(O,Te)&&E(Ee),e.unbindTexture()}L.depthBuffer&&se(L)}function Oe(L){let O=w(L)||a,re=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ue=0,me=re.length;ue<me;ue++){let De=re[ue];if(A(De,O)){let Te=L.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(De).__webglTexture;e.bindTexture(Te,Ee),E(Te),e.unbindTexture()}}}function Ie(L){if(a&&L.samples>0&&Me(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],re=L.width,ue=L.height,me=16384,De=[],Te=L.stencilBuffer?33306:36096,Ee=r.get(L),le=L.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke<O.length;Ke++)e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,null),e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,null,0);e.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),e.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let Ke=0;Ke<O.length;Ke++){De.push(36064+Ke),L.depthBuffer&&De.push(Te);let ke=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(ke===!1&&(L.depthBuffer&&(me|=256),L.stencilBuffer&&(me|=1024)),le&&i.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[Ke]),ke===!0&&(i.invalidateFramebuffer(36008,[Te]),i.invalidateFramebuffer(36009,[Te])),le){let Ne=r.get(O[Ke]).__webglTexture;i.framebufferTexture2D(36009,36064,3553,Ne,0)}i.blitFramebuffer(0,0,re,ue,0,0,re,ue,me,9728),f&&i.invalidateFramebuffer(36008,De)}if(e.bindFramebuffer(36008,null),e.bindFramebuffer(36009,null),le)for(let Ke=0;Ke<O.length;Ke++){e.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(36160,36064+Ke,36161,Ee.__webglColorRenderbuffer[Ke]);let ke=r.get(O[Ke]).__webglTexture;e.bindFramebuffer(36160,Ee.__webglFramebuffer),i.framebufferTexture2D(36009,36064+Ke,3553,ke,0)}e.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function Pe(L){return Math.min(h,L.samples)}function Me(L){let O=r.get(L);return a&&L.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ze(L){let O=o.render.frame;p.get(L)!==O&&(p.set(L,O),L.update())}function Ue(L,O){let re=L.encoding,ue=L.format,me=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===vb||re!==Di&&(re===et?a===!1?t.has("EXT_sRGB")===!0&&ue===$n?(L.format=vb,L.minFilter=Je,L.generateMipmaps=!1):O=fg.sRGBToLinear(O):(ue!==$n||me!==lr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",re)),O}this.allocateTextureUnit=z,this.resetTextureUnits=k,this.setTexture2D=H,this.setTexture2DArray=Q,this.setTexture3D=F,this.setTextureCube=j,this.rebindTextures=_e,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Me}function yz(i,t,e){let r=e.isWebGL2;function n(s,o=null){let a;if(s===lr)return 5121;if(s===uN)return 32819;if(s===hN)return 32820;if(s===aN)return 5120;if(s===lN)return 5122;if(s===tM)return 5123;if(s===cN)return 5124;if(s===fs)return 5125;if(s===Xr)return 5126;if(s===Uo)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===dN)return 6406;if(s===$n)return 6408;if(s===fN)return 6409;if(s===pN)return 6410;if(s===kl)return 6402;if(s===Ta)return 34041;if(s===vb)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===mN)return 6403;if(s===gN)return 36244;if(s===Cu)return 33319;if(s===yN)return 33320;if(s===Xb)return 36249;if(s===Ix||s===Ox||s===Rx||s===Lx)if(o===et)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ix)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ix)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===T_||s===C_||s===P_||s===D_)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===T_)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===C_)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===P_)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===D_)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===vN)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===I_||s===O_)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===I_)return o===et?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===O_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===R_||s===L_||s===N_||s===B_||s===F_||s===k_||s===V_||s===z_||s===U_||s===G_||s===H_||s===j_||s===W_||s===q_)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===R_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===L_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===N_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===B_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===F_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===k_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===V_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===z_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===U_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===G_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===H_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===j_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===W_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===q_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Nx)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Nx)return o===et?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===xN||s===Y_||s===X_||s===Q_)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Y_)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===X_)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Q_)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===_a?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:n}}var Pb=class extends Ir{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Hs=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}},vz={type:"move"},Cf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hs,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 Hs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),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 n=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(u,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 c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.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&&(n=e.getPose(t.targetRaySpace,r),n===null&&s!==null&&(n=s),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(vz)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new Hs;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},Gi=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){if(c=c!==void 0?c:kl,c!==kl&&c!==Ta)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===kl&&(r=fs),r===void 0&&c===Ta&&(r=_a),super(null,n,s,o,a,l,c,r,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:kt,this.minFilter=l!==void 0?l:kt,this.flipY=!1,this.generateMipmaps=!1}},Db=class extends Yt{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,A=new Ir;A.layers.enable(1),A.viewport=new Xe;let E=new Ir;E.layers.enable(2),E.viewport=new Xe;let b=[A,E],M=new Pb;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let j=v[F];return j===void 0&&(j=new Cf,v[F]=j),j.getTargetRaySpace()},this.getControllerGrip=function(F){let j=v[F];return j===void 0&&(j=new Cf,v[F]=j),j.getGripSpace()},this.getHand=function(F){let j=v[F];return j===void 0&&(j=new Cf,v[F]=j),j.getHandSpace()};function P(F){let j=x.indexOf(F.inputSource);if(j===-1)return;let Y=v[j];Y!==void 0&&Y.dispatchEvent({type:F.type,data:F.inputSource})}function D(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",I);for(let F=0;F<v.length;F++){let j=x[F];j!==null&&(x[F]=null,v[F].disconnect(j))}T=null,C=null,t.setRenderTarget(g),f=null,d=null,h=null,n=null,y=null,Q.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(F){u=F},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(F){if(n=F,n!==null){if(g=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",D),n.addEventListener("inputsourceschange",I),m.xrCompatible!==!0&&await e.makeXRCompatible(),n.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let j={antialias:n.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,j),n.updateRenderState({baseLayer:f}),y=new ht(f.framebufferWidth,f.framebufferHeight,{format:$n,type:lr,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let j=null,Y=null,q=null;m.depth&&(q=m.stencil?35056:33190,j=m.stencil?Ta:kl,Y=m.stencil?_a:fs);let U={colorFormat:32856,depthFormat:q,scaleFactor:s};h=new XRWebGLBinding(n,e),d=h.createProjectionLayer(U),n.updateRenderState({layers:[d]}),y=new ht(d.textureWidth,d.textureHeight,{format:$n,type:lr,depthTexture:new Gi(d.textureWidth,d.textureHeight,Y,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});let J=t.properties.get(y);J.__ignoreDepthValues=d.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(l),u=null,o=await n.requestReferenceSpace(a),Q.setContext(n),Q.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};function I(F){for(let j=0;j<F.removed.length;j++){let Y=F.removed[j],q=x.indexOf(Y);q>=0&&(x[q]=null,v[q].disconnect(Y))}for(let j=0;j<F.added.length;j++){let Y=F.added[j],q=x.indexOf(Y);if(q===-1){for(let J=0;J<v.length;J++)if(J>=x.length){x.push(Y),q=J;break}else if(x[J]===null){x[J]=Y,q=J;break}if(q===-1)break}let U=v[q];U&&U.connect(Y)}}let R=new _,V=new _;function k(F,j,Y){R.setFromMatrixPosition(j.matrixWorld),V.setFromMatrixPosition(Y.matrixWorld);let q=R.distanceTo(V),U=j.projectionMatrix.elements,J=Y.projectionMatrix.elements,Z=U[14]/(U[10]-1),K=U[14]/(U[10]+1),W=(U[9]+1)/U[5],ye=(U[9]-1)/U[5],fe=(U[8]-1)/U[0],se=(J[8]+1)/J[0],_e=Z*fe,xe=Z*se,Oe=q/(-fe+se),Ie=Oe*-fe;j.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Ie),F.translateZ(Oe),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let Pe=Z+Oe,Me=K+Oe,ze=_e-Ie,Ue=xe+(q-Ie),L=W*K/Me*Pe,O=ye*K/Me*Pe;F.projectionMatrix.makePerspective(ze,Ue,L,O,Pe,Me)}function z(F,j){j===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(j.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(n===null)return;M.near=E.near=A.near=F.near,M.far=E.far=A.far=F.far,(T!==M.near||C!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);let j=F.parent,Y=M.cameras;z(M,j);for(let U=0;U<Y.length;U++)z(Y[U],j);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),F.matrix.copy(M.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale);let q=F.children;for(let U=0,J=q.length;U<J;U++)q[U].updateMatrixWorld(!0);Y.length===2?k(M,A,E):M.projectionMatrix.copy(A.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(F){l=F,d!==null&&(d.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.getPlanes=function(){return w};let G=null;function H(F,j){if(c=j.getViewerPose(u||o),p=j,c!==null){let Y=c.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let q=!1;Y.length!==M.cameras.length&&(M.cameras.length=0,q=!0);for(let U=0;U<Y.length;U++){let J=Y[U],Z=null;if(f!==null)Z=f.getViewport(J);else{let W=h.getViewSubImage(d,J);Z=W.viewport,U===0&&(t.setRenderTargetTextures(y,W.colorTexture,d.ignoreDepthValues?void 0:W.depthStencilTexture),t.setRenderTarget(y))}let K=b[U];K===void 0&&(K=new Ir,K.layers.enable(U),K.viewport=new Xe,b[U]=K),K.matrix.fromArray(J.transform.matrix),K.projectionMatrix.fromArray(J.projectionMatrix),K.viewport.set(Z.x,Z.y,Z.width,Z.height),U===0&&M.matrix.copy(K.matrix),q===!0&&M.cameras.push(K)}}for(let Y=0;Y<v.length;Y++){let q=x[Y],U=v[Y];q!==null&&U!==void 0&&U.update(q,j,u||o)}if(G&&G(F,j),j.detectedPlanes){r.dispatchEvent({type:"planesdetected",data:j.detectedPlanes});let Y=null;for(let q of w)j.detectedPlanes.has(q)||(Y===null&&(Y=[]),Y.push(q));if(Y!==null)for(let q of Y)w.delete(q),S.delete(q),r.dispatchEvent({type:"planeremoved",data:q});for(let q of j.detectedPlanes)if(!w.has(q))w.add(q),S.set(q,j.lastChangedTime),r.dispatchEvent({type:"planeadded",data:q});else{let U=S.get(q);q.lastChangedTime>U&&(S.set(q,q.lastChangedTime),r.dispatchEvent({type:"planechanged",data:q}))}}p=null}let Q=new aM;Q.setAnimationLoop(H),this.setAnimationLoop=function(F){G=F},this.dispose=function(){}}};function xz(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,oM(i)),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?n(m,g):g.isMeshToonMaterial?(n(m,g),c(m,g)):g.isMeshPhongMaterial?(n(m,g),u(m,g)):g.isMeshStandardMaterial?(n(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(n(m,g),f(m,g)):g.isMeshDepthMaterial?n(m,g):g.isMeshDistanceMaterial?(n(m,g),p(m,g)):g.isMeshNormalMaterial?n(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 n(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===Qr&&(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===Qr&&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 w=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*w}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 u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(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===Qr&&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 bz(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;r.uniformBlockBinding(v,w)}function u(v,x){let w=n[v.id];w===void 0&&(p(v),w=c(v),n[v.id]=w,v.addEventListener("dispose",g));let S=x.program;r.updateUBOMapping(v,S);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function c(v){let x=h();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,A=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,A),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=n[v.id],w=v.uniforms,S=v.__cache;i.bindBuffer(35345,x);for(let A=0,E=w.length;A<E;A++){let b=w[A];if(f(b,A,S)===!0){let M=b.__offset,T=Array.isArray(b.value)?b.value:[b.value],C=0;for(let P=0;P<T.length;P++){let D=T[P],I=m(D);typeof D=="number"?(b.__data[0]=D,i.bufferSubData(35345,M+C,b.__data)):D.isMatrix3?(b.__data[0]=D.elements[0],b.__data[1]=D.elements[1],b.__data[2]=D.elements[2],b.__data[3]=D.elements[0],b.__data[4]=D.elements[3],b.__data[5]=D.elements[4],b.__data[6]=D.elements[5],b.__data[7]=D.elements[0],b.__data[8]=D.elements[6],b.__data[9]=D.elements[7],b.__data[10]=D.elements[8],b.__data[11]=D.elements[0]):(D.toArray(b.__data,C),C+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(35345,M,b.__data)}}i.bindBuffer(35345,null)}function f(v,x,w){let S=v.value;if(w[x]===void 0){if(typeof S=="number")w[x]=S;else{let A=Array.isArray(S)?S:[S],E=[];for(let b=0;b<A.length;b++)E.push(A[b].clone());w[x]=E}return!0}else if(typeof S=="number"){if(w[x]!==S)return w[x]=S,!0}else{let A=Array.isArray(w[x])?w[x]:[w[x]],E=Array.isArray(S)?S:[S];for(let b=0;b<A.length;b++){let M=A[b];if(M.equals(E[b])===!1)return M.copy(E[b]),!0}}return!1}function p(v){let x=v.uniforms,w=0,S=16,A=0;for(let E=0,b=x.length;E<b;E++){let M=x[E],T={boundary:0,storage:0},C=Array.isArray(M.value)?M.value:[M.value];for(let P=0,D=C.length;P<D;P++){let I=C[P],R=m(I);T.boundary+=R.boundary,T.storage+=R.storage}if(M.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=w,E>0){A=w%S;let P=S-A;A!==0&&P-T.boundary<0&&(w+=S-A,M.__offset=w)}w+=T.storage}return A=w%S,A>0&&(w+=S-A),v.__size=w,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 w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function y(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:u,dispose:y}}function wz(){let i=dg("canvas");return i.style.display="block",i}function tw(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:wz(),e=i.context!==void 0?i.context:null,r=i.depth!==void 0?i.depth:!0,n=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.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=Di,this.physicallyCorrectLights=!1,this.toneMapping=zo,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,w=-1,S=null,A=new Xe,E=new Xe,b=null,M=t.width,T=t.height,C=1,P=null,D=null,I=new Xe(0,0,M,T),R=new Xe(0,0,M,T),V=!1,k=new Lf,z=!1,G=!1,H=null,Q=new ie,F=new N,j=new _,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let U=e;function J(B,te){for(let he=0;he<B.length;he++){let ee=B[he],pe=t.getContext(ee,te);if(pe!==null)return pe}return null}try{let B={alpha:!0,depth:r,stencil:n,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Wo}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",_t,!1),U===null){let te=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&te.shift(),U=J(te,B),U===null)throw J(te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let Z,K,W,ye,fe,se,_e,xe,Oe,Ie,Pe,Me,ze,Ue,L,O,re,ue,me,De,Te,Ee,le,Ke;function ke(){Z=new Gk(U),K=new Bk(U,Z,i),Z.init(K),Ee=new yz(U,Z,K),W=new mz(U,Z,K),ye=new Wk,fe=new nz,se=new gz(U,Z,W,fe,K,Ee,ye),_e=new kk(m),xe=new Uk(m),Oe=new eB(U,K),le=new Lk(U,Z,Oe,K),Ie=new Hk(U,Oe,ye,le),Pe=new Qk(U,Ie,Oe,ye),me=new Xk(U,K,se),O=new Fk(fe),Me=new rz(m,_e,xe,Z,K,le,O),ze=new xz(m,fe),Ue=new sz,L=new hz(Z,K),ue=new Rk(m,_e,xe,W,Pe,c,o),re=new pz(m,Pe,K),Ke=new bz(U,ye,K,W),De=new Nk(U,Z,ye,K),Te=new jk(U,Z,ye,K),ye.programs=Me.programs,m.capabilities=K,m.extensions=Z,m.properties=fe,m.renderLists=Ue,m.shadowMap=re,m.state=W,m.info=ye}ke();let Ne=new Db(m,U);this.xr=Ne,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let B=Z.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){let B=Z.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(B){B!==void 0&&(C=B,this.setSize(M,T,!1))},this.getSize=function(B){return B.set(M,T)},this.setSize=function(B,te,he){if(Ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=B,T=te,t.width=Math.floor(B*C),t.height=Math.floor(te*C),he!==!1&&(t.style.width=B+"px",t.style.height=te+"px"),this.setViewport(0,0,B,te)},this.getDrawingBufferSize=function(B){return B.set(M*C,T*C).floor()},this.setDrawingBufferSize=function(B,te,he){M=B,T=te,C=he,t.width=Math.floor(B*he),t.height=Math.floor(te*he),this.setViewport(0,0,B,te)},this.getCurrentViewport=function(B){return B.copy(A)},this.getViewport=function(B){return B.copy(I)},this.setViewport=function(B,te,he,ee){B.isVector4?I.set(B.x,B.y,B.z,B.w):I.set(B,te,he,ee),W.viewport(A.copy(I).multiplyScalar(C).floor())},this.getScissor=function(B){return B.copy(R)},this.setScissor=function(B,te,he,ee){B.isVector4?R.set(B.x,B.y,B.z,B.w):R.set(B,te,he,ee),W.scissor(E.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(B){W.setScissorTest(V=B)},this.setOpaqueSort=function(B){P=B},this.setTransparentSort=function(B){D=B},this.getClearColor=function(B){return B.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(B=!0,te=!0,he=!0){let ee=0;B&&(ee|=16384),te&&(ee|=256),he&&(ee|=1024),U.clear(ee)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",We,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),Ue.dispose(),L.dispose(),fe.dispose(),_e.dispose(),xe.dispose(),Pe.dispose(),le.dispose(),Ke.dispose(),Me.dispose(),Ne.dispose(),Ne.removeEventListener("sessionstart",Ve),Ne.removeEventListener("sessionend",Fe),H&&(H.dispose(),H=null),Et.stop()};function We(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function $e(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let B=ye.autoReset,te=re.enabled,he=re.autoUpdate,ee=re.needsUpdate,pe=re.type;ke(),ye.autoReset=B,re.enabled=te,re.autoUpdate=he,re.needsUpdate=ee,re.type=pe}function _t(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function ir(B){let te=B.target;te.removeEventListener("dispose",ir),Gr(te)}function Gr(B){X(B),fe.remove(B)}function X(B){let te=fe.get(B).programs;te!==void 0&&(te.forEach(function(he){Me.releaseProgram(he)}),B.isShaderMaterial&&Me.releaseShaderCache(B))}this.renderBufferDirect=function(B,te,he,ee,pe,st){te===null&&(te=Y);let dt=pe.isMesh&&pe.matrixWorld.determinant()<0,mt=x3(B,te,he,ee,pe);W.setMaterial(ee,dt);let xt=he.index,Lt=1;ee.wireframe===!0&&(xt=Ie.getWireframeAttribute(he),Lt=2);let Mt=he.drawRange,Tt=he.attributes.position,jr=Mt.start*Lt,Ei=(Mt.start+Mt.count)*Lt;st!==null&&(jr=Math.max(jr,st.start*Lt),Ei=Math.min(Ei,(st.start+st.count)*Lt)),xt!==null?(jr=Math.max(jr,0),Ei=Math.min(Ei,xt.count)):Tt!=null&&(jr=Math.max(jr,0),Ei=Math.min(Ei,Tt.count));let Io=Ei-jr;if(Io<0||Io===1/0)return;le.setup(pe,ee,mt,he,xt);let Dl,Wr=De;if(xt!==null&&(Dl=Oe.get(xt),Wr=Te,Wr.setIndex(Dl)),pe.isMesh)ee.wireframe===!0?(W.setLineWidth(ee.wireframeLinewidth*q()),Wr.setMode(1)):Wr.setMode(4);else if(pe.isLine){let Ct=ee.linewidth;Ct===void 0&&(Ct=1),W.setLineWidth(Ct*q()),pe.isLineSegments?Wr.setMode(1):pe.isLineLoop?Wr.setMode(2):Wr.setMode(3)}else pe.isPoints?Wr.setMode(0):pe.isSprite&&Wr.setMode(4);if(pe.isInstancedMesh)Wr.renderInstances(jr,Io,pe.count);else if(he.isInstancedBufferGeometry){let Ct=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Mx=Math.min(he.instanceCount,Ct);Wr.renderInstances(jr,Io,Mx)}else Wr.render(jr,Io)},this.compile=function(B,te){function he(ee,pe,st){ee.transparent===!0&&ee.side===Ln&&ee.forceSinglePass===!1?(ee.side=Qr,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Pi,ee.needsUpdate=!0,Vi(ee,pe,st),ee.side=Ln):Vi(ee,pe,st)}d=L.get(B),d.init(),p.push(d),B.traverseVisible(function(ee){ee.isLight&&ee.layers.test(te.layers)&&(d.pushLight(ee),ee.castShadow&&d.pushShadow(ee))}),d.setupLights(m.physicallyCorrectLights),B.traverse(function(ee){let pe=ee.material;if(pe)if(Array.isArray(pe))for(let st=0;st<pe.length;st++){let dt=pe[st];he(dt,B,ee)}else he(pe,B,ee)}),p.pop(),d=null};let ce=null;function ve(B){ce&&ce(B)}function Ve(){Et.stop()}function Fe(){Et.start()}let Et=new aM;Et.setAnimationLoop(ve),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(B){ce=B,Ne.setAnimationLoop(B),B===null?Et.stop():Et.start()},Ne.addEventListener("sessionstart",Ve),Ne.addEventListener("sessionend",Fe),this.render=function(B,te){if(te!==void 0&&te.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),te.parent===null&&te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(te),te=Ne.getCamera()),B.isScene===!0&&B.onBeforeRender(m,B,te,x),d=L.get(B,p.length),d.init(),p.push(d),Q.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),k.setFromProjectionMatrix(Q),G=this.localClippingEnabled,z=O.init(this.clippingPlanes,G),h=Ue.get(B,f.length),h.init(),f.push(h),Hr(B,te,0,m.sortObjects),h.finish(),m.sortObjects===!0&&h.sort(P,D),z===!0&&O.beginShadows();let he=d.state.shadowsArray;if(re.render(he,B,te),z===!0&&O.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(h,B),d.setupLights(m.physicallyCorrectLights),te.isArrayCamera){let ee=te.cameras;for(let pe=0,st=ee.length;pe<st;pe++){let dt=ee[pe];Pr(h,B,dt,dt.viewport)}}else Pr(h,B,te);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),B.isScene===!0&&B.onAfterRender(m,B,te),le.resetDefaultState(),w=-1,S=null,p.pop(),p.length>0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(B,te,he,ee){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)he=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||k.intersectsSprite(B)){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Q);let dt=Pe.update(B),mt=B.material;mt.visible&&h.push(B,dt,mt,he,j.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ye.render.frame&&(B.skeleton.update(),B.skeleton.frame=ye.render.frame),!B.frustumCulled||k.intersectsObject(B))){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Q);let dt=Pe.update(B),mt=B.material;if(Array.isArray(mt)){let xt=dt.groups;for(let Lt=0,Mt=xt.length;Lt<Mt;Lt++){let Tt=xt[Lt],jr=mt[Tt.materialIndex];jr&&jr.visible&&h.push(B,dt,jr,he,j.z,Tt)}}else mt.visible&&h.push(B,dt,mt,he,j.z,null)}}let st=B.children;for(let dt=0,mt=st.length;dt<mt;dt++)Hr(st[dt],te,he,ee)}function Pr(B,te,he,ee){let pe=B.opaque,st=B.transmissive,dt=B.transparent;d.setupLightsView(he),z===!0&&O.setGlobalState(m.clippingPlanes,he),st.length>0&&Pl(pe,te,he),ee&&W.viewport(A.copy(ee)),pe.length>0&&hr(pe,te,he),st.length>0&&hr(st,te,he),dt.length>0&&hr(dt,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Pl(B,te,he){let ee=K.isWebGL2;H===null&&(H=new ht(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Uo:lr,minFilter:zl,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(F),ee?H.setSize(F.x,F.y):H.setSize(hg(F.x),hg(F.y));let pe=m.getRenderTarget();m.setRenderTarget(H),m.clear();let st=m.toneMapping;m.toneMapping=zo,hr(B,te,he),m.toneMapping=st,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),m.setRenderTarget(pe)}function hr(B,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,st=B.length;pe<st;pe++){let dt=B[pe],mt=dt.object,xt=dt.geometry,Lt=ee===null?dt.material:ee,Mt=dt.group;mt.layers.test(he.layers)&&Do(mt,te,he,xt,Lt,Mt)}}function Do(B,te,he,ee,pe,st){B.onBeforeRender(m,te,he,ee,pe,st),B.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),pe.onBeforeRender(m,te,he,ee,B,st),pe.transparent===!0&&pe.side===Ln&&pe.forceSinglePass===!1?(pe.side=Qr,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Pi,pe.needsUpdate=!0,m.renderBufferDirect(he,te,ee,pe,B,st),pe.side=Ln):m.renderBufferDirect(he,te,ee,pe,B,st),B.onAfterRender(m,te,he,ee,pe,st)}function Vi(B,te,he){te.isScene!==!0&&(te=Y);let ee=fe.get(B),pe=d.state.lights,st=d.state.shadowsArray,dt=pe.state.version,mt=Me.getParameters(B,pe.state,st,te,he),xt=Me.getProgramCacheKey(mt),Lt=ee.programs;ee.environment=B.isMeshStandardMaterial?te.environment:null,ee.fog=te.fog,ee.envMap=(B.isMeshStandardMaterial?xe:_e).get(B.envMap||ee.environment),Lt===void 0&&(B.addEventListener("dispose",ir),Lt=new Map,ee.programs=Lt);let Mt=Lt.get(xt);if(Mt!==void 0){if(ee.currentProgram===Mt&&ee.lightsStateVersion===dt)return y_(B,mt),Mt}else mt.uniforms=Me.getUniforms(B),B.onBuild(he,mt,m),B.onBeforeCompile(mt,m),Mt=Me.acquireProgram(mt,xt),Lt.set(xt,Mt),ee.uniforms=mt.uniforms;let Tt=ee.uniforms;(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(Tt.clippingPlanes=O.uniform),y_(B,mt),ee.needsLights=w3(B),ee.lightsStateVersion=dt,ee.needsLights&&(Tt.ambientLightColor.value=pe.state.ambient,Tt.lightProbe.value=pe.state.probe,Tt.directionalLights.value=pe.state.directional,Tt.directionalLightShadows.value=pe.state.directionalShadow,Tt.spotLights.value=pe.state.spot,Tt.spotLightShadows.value=pe.state.spotShadow,Tt.rectAreaLights.value=pe.state.rectArea,Tt.ltc_1.value=pe.state.rectAreaLTC1,Tt.ltc_2.value=pe.state.rectAreaLTC2,Tt.pointLights.value=pe.state.point,Tt.pointLightShadows.value=pe.state.pointShadow,Tt.hemisphereLights.value=pe.state.hemi,Tt.directionalShadowMap.value=pe.state.directionalShadowMap,Tt.directionalShadowMatrix.value=pe.state.directionalShadowMatrix,Tt.spotShadowMap.value=pe.state.spotShadowMap,Tt.spotLightMatrix.value=pe.state.spotLightMatrix,Tt.spotLightMap.value=pe.state.spotLightMap,Tt.pointShadowMap.value=pe.state.pointShadowMap,Tt.pointShadowMatrix.value=pe.state.pointShadowMatrix);let jr=Mt.getUniforms(),Ei=iu.seqWithValue(jr.seq,Tt);return ee.currentProgram=Mt,ee.uniformsList=Ei,Mt}function y_(B,te){let he=fe.get(B);he.outputEncoding=te.outputEncoding,he.instancing=te.instancing,he.skinning=te.skinning,he.morphTargets=te.morphTargets,he.morphNormals=te.morphNormals,he.morphColors=te.morphColors,he.morphTargetsCount=te.morphTargetsCount,he.numClippingPlanes=te.numClippingPlanes,he.numIntersection=te.numClipIntersection,he.vertexAlphas=te.vertexAlphas,he.vertexTangents=te.vertexTangents,he.toneMapping=te.toneMapping}function x3(B,te,he,ee,pe){te.isScene!==!0&&(te=Y),se.resetTextureUnits();let st=te.fog,dt=ee.isMeshStandardMaterial?te.environment:null,mt=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Di,xt=(ee.isMeshStandardMaterial?xe:_e).get(ee.envMap||dt),Lt=ee.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,Mt=!!ee.normalMap&&!!he.attributes.tangent,Tt=!!he.morphAttributes.position,jr=!!he.morphAttributes.normal,Ei=!!he.morphAttributes.color,Io=ee.toneMapped?m.toneMapping:zo,Dl=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,Wr=Dl!==void 0?Dl.length:0,Ct=fe.get(ee),Mx=d.state.lights;if(z===!0&&(G===!0||B!==S)){let Mi=B===S&&ee.id===w;O.setState(ee,B,Mi)}let fn=!1;ee.version===Ct.__version?(Ct.needsLights&&Ct.lightsStateVersion!==Mx.state.version||Ct.outputEncoding!==mt||pe.isInstancedMesh&&Ct.instancing===!1||!pe.isInstancedMesh&&Ct.instancing===!0||pe.isSkinnedMesh&&Ct.skinning===!1||!pe.isSkinnedMesh&&Ct.skinning===!0||Ct.envMap!==xt||ee.fog===!0&&Ct.fog!==st||Ct.numClippingPlanes!==void 0&&(Ct.numClippingPlanes!==O.numPlanes||Ct.numIntersection!==O.numIntersection)||Ct.vertexAlphas!==Lt||Ct.vertexTangents!==Mt||Ct.morphTargets!==Tt||Ct.morphNormals!==jr||Ct.morphColors!==Ei||Ct.toneMapping!==Io||K.isWebGL2===!0&&Ct.morphTargetsCount!==Wr)&&(fn=!0):(fn=!0,Ct.__version=ee.version);let Il=Ct.currentProgram;fn===!0&&(Il=Vi(ee,te,pe));let v_=!1,mf=!1,Tx=!1,Rn=Il.getUniforms(),Ol=Ct.uniforms;if(W.useProgram(Il.program)&&(v_=!0,mf=!0,Tx=!0),ee.id!==w&&(w=ee.id,mf=!0),v_||S!==B){if(Rn.setValue(U,"projectionMatrix",B.projectionMatrix),K.logarithmicDepthBuffer&&Rn.setValue(U,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),S!==B&&(S=B,mf=!0,Tx=!0),ee.isShaderMaterial||ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshStandardMaterial||ee.envMap){let Mi=Rn.map.cameraPosition;Mi!==void 0&&Mi.setValue(U,j.setFromMatrixPosition(B.matrixWorld))}(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial)&&Rn.setValue(U,"isOrthographic",B.isOrthographicCamera===!0),(ee.isMeshPhongMaterial||ee.isMeshToonMaterial||ee.isMeshLambertMaterial||ee.isMeshBasicMaterial||ee.isMeshStandardMaterial||ee.isShaderMaterial||ee.isShadowMaterial||pe.isSkinnedMesh)&&Rn.setValue(U,"viewMatrix",B.matrixWorldInverse)}if(pe.isSkinnedMesh){Rn.setOptional(U,pe,"bindMatrix"),Rn.setOptional(U,pe,"bindMatrixInverse");let Mi=pe.skeleton;Mi&&(K.floatVertexTextures?(Mi.boneTexture===null&&Mi.computeBoneTexture(),Rn.setValue(U,"boneTexture",Mi.boneTexture,se),Rn.setValue(U,"boneTextureSize",Mi.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let Cx=he.morphAttributes;if((Cx.position!==void 0||Cx.normal!==void 0||Cx.color!==void 0&&K.isWebGL2===!0)&&me.update(pe,he,ee,Il),(mf||Ct.receiveShadow!==pe.receiveShadow)&&(Ct.receiveShadow=pe.receiveShadow,Rn.setValue(U,"receiveShadow",pe.receiveShadow)),ee.isMeshGouraudMaterial&&ee.envMap!==null&&(Ol.envMap.value=xt,Ol.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),mf&&(Rn.setValue(U,"toneMappingExposure",m.toneMappingExposure),Ct.needsLights&&b3(Ol,Tx),st&&ee.fog===!0&&ze.refreshFogUniforms(Ol,st),ze.refreshMaterialUniforms(Ol,ee,C,T,H),iu.upload(U,Ct.uniformsList,Ol,se)),ee.isShaderMaterial&&ee.uniformsNeedUpdate===!0&&(iu.upload(U,Ct.uniformsList,Ol,se),ee.uniformsNeedUpdate=!1),ee.isSpriteMaterial&&Rn.setValue(U,"center",pe.center),Rn.setValue(U,"modelViewMatrix",pe.modelViewMatrix),Rn.setValue(U,"normalMatrix",pe.normalMatrix),Rn.setValue(U,"modelMatrix",pe.matrixWorld),pe.previousModelViewMatrix&&Rn.setValue(U,"previousModelViewMatrix",pe.previousModelViewMatrix),B.previousProjectionMatrix&&Rn.setValue(U,"previousProjectionMatrix",B.previousProjectionMatrix),ee.isShaderMaterial||ee.isRawShaderMaterial){let Mi=ee.uniformsGroups;for(let Px=0,S3=Mi.length;Px<S3;Px++)if(K.isWebGL2){let x_=Mi[Px];Ke.update(x_,Il),Ke.bind(x_,Il)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Il}function b3(B,te){B.ambientLightColor.needsUpdate=te,B.lightProbe.needsUpdate=te,B.directionalLights.needsUpdate=te,B.directionalLightShadows.needsUpdate=te,B.pointLights.needsUpdate=te,B.pointLightShadows.needsUpdate=te,B.spotLights.needsUpdate=te,B.spotLightShadows.needsUpdate=te,B.rectAreaLights.needsUpdate=te,B.hemisphereLights.needsUpdate=te}function w3(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(B,te,he){fe.get(B.texture).__webglTexture=te,fe.get(B.depthTexture).__webglTexture=he;let ee=fe.get(B);ee.__hasExternalTextures=!0,ee.__hasExternalTextures&&(ee.__autoAllocateDepthBuffer=he===void 0,ee.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ee.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(B,te){let he=fe.get(B);he.__webglFramebuffer=te,he.__useDefaultFramebuffer=te===void 0},this.setRenderTarget=function(B,te=0,he=0){x=B,y=te,v=he;let ee=!0,pe=null,st=!1,dt=!1;if(B){let xt=fe.get(B);xt.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(36160,null),ee=!1):xt.__webglFramebuffer===void 0?se.setupRenderTarget(B):xt.__hasExternalTextures&&se.rebindTextures(B,fe.get(B.texture).__webglTexture,fe.get(B.depthTexture).__webglTexture);let Lt=B.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(dt=!0);let Mt=fe.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(pe=Mt[te],st=!0):K.isWebGL2&&B.samples>0&&se.useMultisampledRTT(B)===!1?pe=fe.get(B).__webglMultisampledFramebuffer:pe=Mt,A.copy(B.viewport),E.copy(B.scissor),b=B.scissorTest}else A.copy(I).multiplyScalar(C).floor(),E.copy(R).multiplyScalar(C).floor(),b=V;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(B,pe),W.viewport(A),W.scissor(E),W.setScissorTest(b),st){let xt=fe.get(B.texture);U.framebufferTexture2D(36160,36064,34069+te,xt.__webglTexture,he)}else if(dt){let xt=fe.get(B.texture),Lt=te||0;U.framebufferTextureLayer(36160,36064,xt.__webglTexture,he||0,Lt)}w=-1},this.readRenderTargetPixels=function(B,te,he,ee,pe,st,dt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let mt=fe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&dt!==void 0&&(mt=mt[dt]),mt){W.bindFramebuffer(36160,mt);try{let xt=B.texture,Lt=xt.format,Mt=xt.type;if(Lt!==$n&&Ee.convert(Lt)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Mt===Uo&&(Z.has("EXT_color_buffer_half_float")||K.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Mt!==lr&&Ee.convert(Mt)!==U.getParameter(35738)&&!(Mt===Xr&&(K.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ee&&he>=0&&he<=B.height-pe&&U.readPixels(te,he,ee,pe,Ee.convert(Lt),Ee.convert(Mt),st)}finally{let xt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,xt)}}},this.copyFramebufferToTexture=function(B,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),st=Math.floor(te.image.height*ee);se.setTexture2D(te,0),U.copyTexSubImage2D(3553,he,0,0,B.x,B.y,pe,st),W.unbindTexture()},this.copyTextureToTexture=function(B,te,he,ee=0){let pe=te.image.width,st=te.image.height,dt=Ee.convert(he.format),mt=Ee.convert(he.type);se.setTexture2D(he,0),U.pixelStorei(37440,he.flipY),U.pixelStorei(37441,he.premultiplyAlpha),U.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?U.texSubImage2D(3553,ee,B.x,B.y,pe,st,dt,mt,te.image.data):te.isCompressedTexture?U.compressedTexSubImage2D(3553,ee,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):U.texSubImage2D(3553,ee,B.x,B.y,dt,mt,te.image),ee===0&&he.generateMipmaps&&U.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(B,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=B.max.x-B.min.x+1,dt=B.max.y-B.min.y+1,mt=B.max.z-B.min.z+1,xt=Ee.convert(ee.format),Lt=Ee.convert(ee.type),Mt;if(ee.isData3DTexture)se.setTexture3D(ee,0),Mt=32879;else if(ee.isDataArrayTexture)se.setTexture2DArray(ee,0),Mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,ee.flipY),U.pixelStorei(37441,ee.premultiplyAlpha),U.pixelStorei(3317,ee.unpackAlignment);let Tt=U.getParameter(3314),jr=U.getParameter(32878),Ei=U.getParameter(3316),Io=U.getParameter(3315),Dl=U.getParameter(32877),Wr=he.isCompressedTexture?he.mipmaps[0]:he.image;U.pixelStorei(3314,Wr.width),U.pixelStorei(32878,Wr.height),U.pixelStorei(3316,B.min.x),U.pixelStorei(3315,B.min.y),U.pixelStorei(32877,B.min.z),he.isDataTexture||he.isData3DTexture?U.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Wr.data)):U.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr),U.pixelStorei(3314,Tt),U.pixelStorei(32878,jr),U.pixelStorei(3316,Ei),U.pixelStorei(3315,Io),U.pixelStorei(32877,Dl),pe===0&&ee.generateMipmaps&&U.generateMipmap(Mt),W.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?se.setTextureCube(B,0):B.isData3DTexture?se.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?se.setTexture2DArray(B,0):se.setTexture2D(B,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Ib=class extends tw{};Ib.prototype.isWebGL1Renderer=!0;var lu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=r}clone(){return new lu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Nn=class extends gt{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}},bg=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=yb,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}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 n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[r+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ui()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Zn=new _,Gl=class{constructor(t,e,r,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyMatrix4(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.applyNormalMatrix(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)Zn.fromBufferAttribute(this,e),Zn.transformDirection(t),this.setXYZ(e,Zn.x,Zn.y,Zn.z);return this}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Vo(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Vo(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Vo(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Vo(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),r=Kt(r,this.array),n=Kt(n,this.array),s=Kt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new Ge(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Gl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Bf=class extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}},li=class extends or{constructor(t=null,e=1,r=1,n,s,o,a,l,u=kt,c=kt,h,d){super(null,o,a,l,u,c,n,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},PE=new ie,Sz=new ie,Ca=class{constructor(t=[],e=[]){this.uuid=Ui(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,n=this.bones.length;r<n;r++)this.boneInverses.push(new ie)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ie;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:Sz;PE.multiplyMatrices(a,e[s]),PE.toArray(r,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new Ca(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=nM(t),t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new li(e,t,t,$n,Xr);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this.boneTextureSize=t,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,n=t.bones.length;r<n;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Bf),this.bones.push(o),this.boneInverses.push(new ie().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let n=0,s=e.length;n<s;n++){let o=e[n];t.bones.push(o.uuid);let a=r[n];t.boneInverses.push(a.toArray())}return t}},cu=class extends Ge{constructor(t,e,r,n=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}};var Hi=class extends Ul{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Re(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},DE=new _,IE=new _,OE=new ie,ab=new ms,$m=new fr,Hl=class extends gt{constructor(t=new Ae,e=new Hi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let n=1,s=e.count;n<s;n++)DE.fromBufferAttribute(e,n-1),IE.fromBufferAttribute(e,n),r[n]=r[n-1],r[n]+=DE.distanceTo(IE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),$m.copy(r.boundingSphere),$m.applyMatrix4(n),$m.radius+=s,t.ray.intersectsSphere($m)===!1)return;OE.copy(n).invert(),ab.copy(t.ray).applyMatrix4(OE);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new _,c=new _,h=new _,d=new _,f=this.isLineSegments?2:1,p=r.index,g=r.attributes.position;if(p!==null){let y=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){let S=p.getX(x),A=p.getX(x+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,A),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);b<t.near||b>t.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;x<w;x+=f){if(u.fromBufferAttribute(g,x),c.fromBufferAttribute(g,x+1),ab.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},RE=new _,LE=new _,Pa=class extends Hl{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let n=0,s=e.count;n<s;n+=2)RE.fromBufferAttribute(e,n),LE.fromBufferAttribute(e,n+1),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+RE.distanceTo(LE);t.setAttribute("lineDistance",new be(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var wg=class extends or{constructor(t,e,r,n,s,o,a,l,u){super(t,e,r,n,s,o,a,l,u),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Je,this.magFilter=s!==void 0?s:Je,this.generateMipmaps=!1;let c=this;function h(){c.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var ji=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,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,u;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),u=r[n]-o,u<0)a=n+1;else if(u>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let c=r[n],d=r[n+1]-c,f=(o-c)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new N:new _);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 _,n=[],s=[],o=[],a=new _,l=new ie;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);c<=u&&(u=c,r.set(1,0,0)),h<=u&&(u=h,r.set(0,1,0)),d<=u&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[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(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Yr(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(Yr(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,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}},jl=class extends ji{constructor(t=0,e=0,r=1,n=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=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new N,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return r.set(l,u)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},Ob=class extends jl{constructor(t,e,r,n,s,o){super(t,e,r,r,n,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function rw(){let i=0,t=0,e=0,r=0;function n(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){n(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,n(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+r*a}}}var eg=new _,lb=new rw,cb=new rw,ub=new rw,Rb=class extends ji{constructor(t=[],e=!1,r="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=n}getPoint(t,e=new _){let r=e,n=this.points,s=n.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=n[(a-1)%s]:(eg.subVectors(n[0],n[1]).add(n[0]),u=eg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?c=n[(a+2)%s]:(eg.subVectors(n[s-1],n[s-2]).add(n[s-1]),c=eg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(u.distanceToSquared(h),f),m=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),lb.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,p,m,g),cb.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,p,m,g),ub.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(lb.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),cb.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),ub.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return r.set(lb.calc(l),cb.calc(l),ub.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new _().fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function NE(i,t,e,r,n){let s=(r-t)*.5,o=(n-e)*.5,a=i*i,l=i*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*i+e}function Az(i,t){let e=1-i;return e*e*t}function _z(i,t){return 2*(1-i)*i*t}function Ez(i,t){return i*i*t}function Pf(i,t,e,r){return Az(i,t)+_z(i,e)+Ez(i,r)}function Mz(i,t){let e=1-i;return e*e*e*t}function Tz(i,t){let e=1-i;return 3*e*e*i*t}function Cz(i,t){return 3*(1-i)*i*i*t}function Pz(i,t){return i*i*i*t}function Df(i,t,e,r,n){return Mz(i,t)+Tz(i,e)+Cz(i,r)+Pz(i,n)}var jn=class extends ji{constructor(t=new N,e=new N,r=new N,n=new N){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Df(t,n.x,s.x,o.x,a.x),Df(t,n.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Wl=class extends ji{constructor(t=new _,e=new _,r=new _,n=new _){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Df(t,n.x,s.x,o.x,a.x),Df(t,n.y,s.y,o.y,a.y),Df(t,n.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Wn=class extends ji{constructor(t=new N,e=new N){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new N){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){let r=e||new N;return r.copy(this.v2).sub(this.v1).normalize(),r}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ff=class extends ji{constructor(t=new _,e=new _){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new _){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ii=class extends ji{constructor(t=new N,e=new N,r=new N){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new N){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(Pf(t,n.x,s.x,o.x),Pf(t,n.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Lb=class extends ji{constructor(t=new _,e=new _,r=new _){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new _){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(Pf(t,n.x,s.x,o.x),Pf(t,n.y,s.y,o.y),Pf(t,n.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},uu=class extends ji{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new N){let r=e,n=this.points,s=(n.length-1)*t,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],u=n[o],c=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(NE(a,l.x,u.x,c.x,h.x),NE(a,l.y,u.y,c.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new N().fromArray(n))}return this}},Dz=Object.freeze({__proto__:null,ArcCurve:Ob,CatmullRomCurve3:Rb,CubicBezierCurve:jn,CubicBezierCurve3:Wl,EllipseCurve:jl,LineCurve:Wn,LineCurve3:Ff,QuadraticBezierCurve:Ii,QuadraticBezierCurve3:Lb,SplineCurve:uu}),kf=class extends ji{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Wn(e,t))}getPoint(t,e){let r=t*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,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,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];r&&r.equals(c)||(e.push(c),r=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(new Dz[n.type]().fromJSON(n))}return this}},ql=class extends kf{constructor(t){super(),this.type="Path",this.currentPoint=new N,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new Wn(this.currentPoint.clone(),new N(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,n){let s=new Ii(this.currentPoint.clone(),new N(t,e),new N(r,n));return this.curves.push(s),this.currentPoint.set(r,n),this}bezierCurveTo(t,e,r,n,s,o){let a=new jn(this.currentPoint.clone(),new N(t,e),new N(r,n),new N(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new uu(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,n,s,o),this}absarc(t,e,r,n,s,o){return this.absellipse(t,e,r,r,n,s,o),this}ellipse(t,e,r,n,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+u,e+c,r,n,s,o,a,l),this}absellipse(t,e,r,n,s,o,a,l){let u=new jl(t,e,r,n,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),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}},hu=class extends Ae{constructor(t=[new N(0,-.5),new N(.5,0),new N(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=Yr(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new _,d=new N,f=new _,p=new _,m=new _,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*c*n,w=Math.sin(x),S=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*w,h.y=t[A].y,h.z=t[A].x*S,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 E=l[3*A+0]*w,b=l[3*A+1],M=l[3*A+0]*S;u.push(E,b,M)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let w=x+v*t.length,S=w,A=w+t.length,E=w+t.length+1,b=w+1;s.push(S,A,b),s.push(E,b,A)}this.setIndex(s),this.setAttribute("position",new be(o,3)),this.setAttribute("uv",new be(a,2)),this.setAttribute("normal",new be(u,3))}static fromJSON(t){return new hu(t.points,t.segments,t.phiStart,t.phiLength)}};var Yl=class extends Ae{constructor(t=1,e=1,r=1,n=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;n=Math.floor(n),s=Math.floor(s);let c=[],h=[],d=[],f=[],p=0,m=[],g=r/2,y=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let w=new _,S=new _,A=0,E=(e-t)/r;for(let b=0;b<=s;b++){let M=[],T=b/s,C=T*(e-t)+t;for(let P=0;P<=n;P++){let D=P/n,I=D*l+a,R=Math.sin(I),V=Math.cos(I);S.x=C*R,S.y=-T*r+g,S.z=C*V,h.push(S.x,S.y,S.z),w.set(R,E,V).normalize(),d.push(w.x,w.y,w.z),f.push(D,1-T),M.push(p++)}m.push(M)}for(let b=0;b<n;b++)for(let M=0;M<s;M++){let T=m[M][b],C=m[M+1][b],P=m[M+1][b+1],D=m[M][b+1];c.push(T,C,D),c.push(C,P,D),A+=6}u.addGroup(y,A,0),y+=A}function x(w){let S=p,A=new N,E=new _,b=0,M=w===!0?t:e,T=w===!0?1:-1;for(let P=1;P<=n;P++)h.push(0,g*T,0),d.push(0,T,0),f.push(.5,.5),p++;let C=p;for(let P=0;P<=n;P++){let I=P/n*l+a,R=Math.cos(I),V=Math.sin(I);E.x=M*V,E.y=g*T,E.z=M*R,h.push(E.x,E.y,E.z),d.push(0,T,0),A.x=R*.5+.5,A.y=V*.5*T+.5,f.push(A.x,A.y),p++}for(let P=0;P<n;P++){let D=S+P,I=C+P;w===!0?c.push(I,I+1,D):c.push(I+1,I,D),b+=3}u.addGroup(y,b,w===!0?1:2),y+=b}}static fromJSON(t){return new Yl(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},du=class extends Yl{constructor(t=1,e=1,r=32,n=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,n,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new du(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},fu=class extends Ae{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};let s=[],o=[];a(n),u(r),c(),this.setAttribute("position",new be(s,3)),this.setAttribute("normal",new be(s.slice(),3)),this.setAttribute("uv",new be(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new _,w=new _,S=new _;for(let A=0;A<e.length;A+=3)f(e[A+0],x),f(e[A+1],w),f(e[A+2],S),l(x,w,S,v)}function l(v,x,w,S){let A=S+1,E=[];for(let b=0;b<=A;b++){E[b]=[];let M=v.clone().lerp(w,b/A),T=x.clone().lerp(w,b/A),C=A-b;for(let P=0;P<=C;P++)P===0&&b===A?E[b][P]=M:E[b][P]=M.clone().lerp(T,P/C)}for(let b=0;b<A;b++)for(let M=0;M<2*(A-b)-1;M++){let T=Math.floor(M/2);M%2===0?(d(E[b][T+1]),d(E[b+1][T]),d(E[b][T])):(d(E[b][T+1]),d(E[b+1][T+1]),d(E[b+1][T]))}}function u(v){let x=new _;for(let w=0;w<s.length;w+=3)x.x=s[w+0],x.y=s[w+1],x.z=s[w+2],x.normalize().multiplyScalar(v),s[w+0]=x.x,s[w+1]=x.y,s[w+2]=x.z}function c(){let v=new _;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let w=g(v)/2/Math.PI+.5,S=y(v)/Math.PI+.5;o.push(w,1-S)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],w=o[v+2],S=o[v+4],A=Math.max(x,w,S),E=Math.min(x,w,S);A>.9&&E<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function p(){let v=new _,x=new _,w=new _,S=new _,A=new N,E=new N,b=new N;for(let M=0,T=0;M<s.length;M+=9,T+=6){v.set(s[M+0],s[M+1],s[M+2]),x.set(s[M+3],s[M+4],s[M+5]),w.set(s[M+6],s[M+7],s[M+8]),A.set(o[T+0],o[T+1]),E.set(o[T+2],o[T+3]),b.set(o[T+4],o[T+5]),S.copy(v).add(x).add(w).divideScalar(3);let C=g(S);m(A,T+0,v,C),m(E,T+2,x,C),m(b,T+4,w,C)}}function m(v,x,w,S){S<0&&v.x===1&&(o[x]=v.x-1),w.x===0&&w.z===0&&(o[x]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function y(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(t){return new fu(t.vertices,t.indices,t.radius,t.details)}},pu=class extends fu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=1/r,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new pu(t.radius,t.detail)}};var jo=class extends ql{constructor(t){super(t),this.uuid=Ui(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(new ql().fromJSON(n))}return this}},Iz={triangulate:function(i,t,e=2){let r=t&&t.length,n=r?t[0]*e:i.length,s=dM(i,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(r&&(s=Bz(i,t,s,e)),i.length>80*e){a=u=i[0],l=c=i[1];for(let p=e;p<n;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return Vf(s,o,e,a,l,f,0),o}};function dM(i,t,e,r,n){let s,o;if(n===Yz(i,t,e,r)>0)for(s=t;s<e;s+=r)o=BE(s,i[s],i[s+1],o);else for(s=e-r;s>=t;s-=r)o=BE(s,i[s],i[s+1],o);return o&&Bg(o,o.next)&&(Uf(o),o=o.next),o}function Xl(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(Bg(e,e.next)||vr(e.prev,e,e.next)===0)){if(Uf(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Vf(i,t,e,r,n,s,o){if(!i)return;!o&&s&&Uz(i,r,n,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?Rz(i,r,n,s):Oz(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Uf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=Lz(Xl(i),t,e),Vf(i,t,e,r,n,s,2)):o===2&&Nz(i,t,e,r,n,s):Vf(Xl(i),t,e,r,n,s,1);break}}}function Oz(i){let t=i.prev,e=i,r=i.next;if(vr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,u=r.y,c=n<s?n<o?n:o:s<o?s:o,h=a<l?a<u?a:u:l<u?l:u,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&nu(n,a,s,l,o,u,p.x,p.y)&&vr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Rz(i,t,e,r){let n=i.prev,s=i,o=i.next;if(vr(n,s,o)>=0)return!1;let a=n.x,l=s.x,u=o.x,c=n.y,h=s.y,d=o.y,f=a<l?a<u?a:u:l<u?l:u,p=c<h?c<d?c:d:h<d?h:d,m=a>l?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Nb(f,p,t,e,r),v=Nb(m,g,t,e,r),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&nu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&nu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&nu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&nu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Lz(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!Bg(n,s)&&fM(n,r,r.next,s)&&zf(n,s)&&zf(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Uf(r),Uf(r.next),r=i=s),r=r.next}while(r!==i);return Xl(r)}function Nz(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&jz(o,a)){let l=pM(o,a);o=Xl(o,o.next),l=Xl(l,l.next),Vf(o,t,e,r,n,s,0),Vf(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function Bz(i,t,e,r){let n=[],s,o,a,l,u;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:i.length,u=dM(i,a,l,r,!1),u===u.next&&(u.steiner=!0),n.push(Hz(u));for(n.sort(Fz),s=0;s<n.length;s++)e=kz(n[s],e);return e}function Fz(i,t){return i.x-t.x}function kz(i,t){let e=Vz(i,t);if(!e)return t;let r=pM(e,i);return Xl(r,r.next),Xl(e,e.next)}function Vz(i,t){let e=t,r=-1/0,n,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;let a=n,l=n.x,u=n.y,c=1/0,h;e=n;do s>=e.x&&e.x>=l&&s!==e.x&&nu(o<u?s:r,o,l,u,o<u?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),zf(e,i)&&(h<c||h===c&&(e.x>n.x||e.x===n.x&&zz(n,e)))&&(n=e,c=h)),e=e.next;while(e!==a);return n}function zz(i,t){return vr(i.prev,i,t.prev)<0&&vr(t.next,i,i.next)<0}function Uz(i,t,e,r){let n=i;do n.z===0&&(n.z=Nb(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,Gz(n)}function Gz(i){let t,e,r,n,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<u&&(a++,r=r.nextZ,!!r);t++);for(l=u;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,u*=2}while(o>1);return i}function Nb(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Hz(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function nu(i,t,e,r,n,s,o,a){return(n-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function jz(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Wz(i,t)&&(zf(i,t)&&zf(t,i)&&qz(i,t)&&(vr(i.prev,i,t.prev)||vr(i,t.prev,t))||Bg(i,t)&&vr(i.prev,i,i.next)>0&&vr(t.prev,t,t.next)>0)}function vr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Bg(i,t){return i.x===t.x&&i.y===t.y}function fM(i,t,e,r){let n=rg(vr(i,t,e)),s=rg(vr(i,t,r)),o=rg(vr(e,r,i)),a=rg(vr(e,r,t));return!!(n!==s&&o!==a||n===0&&tg(i,e,t)||s===0&&tg(i,r,t)||o===0&&tg(e,i,r)||a===0&&tg(e,t,r))}function tg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function rg(i){return i>0?1:i<0?-1:0}function Wz(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&fM(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function zf(i,t){return vr(i.prev,i,i.next)<0?vr(i,t,i.next)>=0&&vr(i,i.prev,t)>=0:vr(i,t,i.prev)<0||vr(i,i.next,t)<0}function qz(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function pM(i,t){let e=new Bb(i.i,i.x,i.y),r=new Bb(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function BE(i,t,e,r){let n=new Bb(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Uf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bb(i,t,e){this.i=i,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 Yz(i,t,e,r){let n=0;for(let s=t,o=e-r;s<e;s+=r)n+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return n}var mu=class{static area(t){let e=t.length,r=0;for(let n=e-1,s=0;s<e;n=s++)r+=t[n].x*t[s].y-t[s].x*t[n].y;return r*.5}static isClockWise(t){return mu.area(t)<0}static triangulateShape(t,e){let r=[],n=[],s=[];FE(t),kE(r,t);let o=t.length;e.forEach(FE);for(let l=0;l<e.length;l++)n.push(o),o+=e[l].length,kE(r,e[l]);let a=Iz.triangulate(r,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function FE(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function kE(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var gu=class extends fu{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(n,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new gu(t.radius,t.detail)}};var Ql=class extends Ae{constructor(t=1,e=32,r=16,n=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new _,d=new _,f=[],p=[],m=[],g=[];for(let y=0;y<=r;y++){let v=[],x=y/r,w=0;y==0&&o==0?w=.5/e:y==r&&l==Math.PI&&(w=-.5/e);for(let S=0;S<=e;S++){let A=S/e;h.x=-t*Math.cos(n+A*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(n+A*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(A+w,1-x),v.push(u++)}c.push(v)}for(let y=0;y<r;y++)for(let v=0;v<e;v++){let x=c[y][v+1],w=c[y][v],S=c[y+1][v],A=c[y+1][v+1];(y!==0||o>0)&&f.push(x,w,A),(y!==r-1||l<Math.PI)&&f.push(w,S,A)}this.setIndex(f),this.setAttribute("position",new be(p,3)),this.setAttribute("normal",new be(m,3)),this.setAttribute("uv",new be(g,2))}static fromJSON(t){return new Ql(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var yu=class extends Ae{constructor(t=1,e=.4,r=64,n=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o},r=Math.floor(r),n=Math.floor(n);let a=[],l=[],u=[],c=[],h=new _,d=new _,f=new _,p=new _,m=new _,g=new _,y=new _;for(let x=0;x<=r;++x){let w=x/r*s*Math.PI*2;v(w,s,o,t,f),v(w+.01,s,o,t,p),g.subVectors(p,f),y.addVectors(p,f),m.crossVectors(g,y),y.crossVectors(m,g),m.normalize(),y.normalize();for(let S=0;S<=n;++S){let A=S/n*Math.PI*2,E=-e*Math.cos(A),b=e*Math.sin(A);h.x=f.x+(E*y.x+b*m.x),h.y=f.y+(E*y.y+b*m.y),h.z=f.z+(E*y.z+b*m.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(x/r),c.push(S/n)}}for(let x=1;x<=r;x++)for(let w=1;w<=n;w++){let S=(n+1)*(x-1)+(w-1),A=(n+1)*x+(w-1),E=(n+1)*x+w,b=(n+1)*(x-1)+w;a.push(S,A,b),a.push(A,E,b)}this.setIndex(a),this.setAttribute("position",new be(l,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(c,2));function v(x,w,S,A,E){let b=Math.cos(x),M=Math.sin(x),T=S/w*x,C=Math.cos(T);E.x=A*(2+C)*.5*b,E.y=A*(2+C)*M*.5,E.z=A*Math.sin(T)*.5}}static fromJSON(t){return new yu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function Sa(i,t,e){return mM(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function ng(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function mM(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Xz(i){function t(n,s){return i[n]-i[s]}let e=i.length,r=new Array(e);for(let n=0;n!==e;++n)r[n]=n;return r.sort(t),r}function VE(i,t,e){let r=i.length,n=new i.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)n[o++]=i[a+l]}return n}function gM(i,t,e,r){let n=1,s=i[0];for(;s!==void 0&&s[r]===void 0;)s=i[n++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[n++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=i[n++];while(s!==void 0)}var vu=class{constructor(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,n=e[r],s=e[r-1];e:{t:{let o;r:{n:if(!(t<n)){for(let a=r+2;;){if(n===void 0){if(t<s)break n;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=n,n=e[++r],t<n)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(n=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(n=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,n)}return this.interpolate_(r,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Fb=class extends vu{constructor(t,e,r,n){super(t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:eu,endingEnd:eu}}intervalChanged_(t,e,r){let n=this.parameterPositions,s=t-2,o=t+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case tu:s=t,a=2*e-r;break;case ug:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case tu:o=t,l=2*r-e;break;case ug:o=1,l=r+n[1]-n[0];break;default:o=t-1,l=e}let u=(r-e)*.5,c=this.valueSize;this._weightPrev=u/(e-a),this._weightNext=u/(l-r),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(n-e),m=p*p,g=m*p,y=-d*g+2*d*m-d*p,v=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,x=(-1-f)*g+(1.5+f)*m+.5*p,w=f*g-f*m;for(let S=0;S!==a;++S)s[S]=y*o[c+S]+v*o[u+S]+x*o[l+S]+w*o[h+S];return s}},Sg=class extends vu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,u=l-a,c=(r-e)/(n-e),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},kb=class extends vu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t){return this.copySampleValue_(t-1)}},Wi=class{constructor(t,e,r,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ng(e,this.TimeBufferType),this.values=ng(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:ng(t.times,Array),values:ng(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(r.interpolation=n)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new kb(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Sg(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Fb(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case lg:e=this.InterpolantFactoryMethodDiscrete;break;case cg:e=this.InterpolantFactoryMethodLinear;break;case Bx:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return lg;case this.InterpolantFactoryMethodLinear:return cg;case this.InterpolantFactoryMethodSmooth:return Bx}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]*=t}return this}trim(t,e){let r=this.times,n=r.length,s=0,o=n-1;for(;s!==n&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Sa(r,s,o),this.values=Sa(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,n=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(n!==void 0&&mM(n))for(let a=0,l=n.length;a!==l;++a){let u=n[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Sa(this.times),e=Sa(this.values),r=this.getValueSize(),n=this.getInterpolation()===Bx,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=t[a],c=t[a+1];if(u!==c&&(a!==1||u!==t[0]))if(n)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let m=e[h+p];if(m!==e[d+p]||m!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,u=0;u!==r;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Sa(t,0,o),this.values=Sa(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Sa(this.times,0),e=Sa(this.values,0),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};Wi.prototype.TimeBufferType=Float32Array;Wi.prototype.ValueBufferType=Float32Array;Wi.prototype.DefaultInterpolation=cg;var Da=class extends Wi{};Da.prototype.ValueTypeName="bool";Da.prototype.ValueBufferType=Array;Da.prototype.DefaultInterpolation=lg;Da.prototype.InterpolantFactoryMethodLinear=void 0;Da.prototype.InterpolantFactoryMethodSmooth=void 0;var Ag=class extends Wi{};Ag.prototype.ValueTypeName="color";var xu=class extends Wi{};xu.prototype.ValueTypeName="number";var Vb=class extends vu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),u=t*a;for(let c=u+a;u!==c;u+=4)He.slerpFlat(s,0,o,u-a,o,u,l);return s}},Kl=class extends Wi{InterpolantFactoryMethodLinear(t){return new Vb(this.times,this.values,this.getValueSize(),t)}};Kl.prototype.ValueTypeName="quaternion";Kl.prototype.DefaultInterpolation=cg;Kl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ia=class extends Wi{};Ia.prototype.ValueTypeName="string";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=lg;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;var bu=class extends Wi{};bu.prototype.ValueTypeName="vector";var wu=class{constructor(t,e=-1,r,n=Zb){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=Ui(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Kz(r[o]).scale(n));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,n={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(Wi.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],u=[];l.push((a+s-1)%s,a,(a+1)%s),u.push(0,1,0);let c=Xz(l);l=VE(l,1,c),u=VE(u,1,c),!n&&l[0]===0&&(l.push(s),u.push(u[0])),o.push(new xu(".morphTargetInfluences["+e[a].name+"]",l,u).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let n=t;r=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<r.length;n++)if(r[n].name===e)return r[n];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let u=t[a],c=u.name.match(s);if(c&&c.length>1){let h=c[1],d=n[h];d||(n[h]=d=[]),d.push(u)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[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=[];gM(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h<u.length;h++){let d=u[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(let m in f){let g=[],y=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];g.push(x.time),y.push(x.morphTarget===m?1:0)}n.push(new xu(".morphTargetInfluence["+m+"]",g,y))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(bu,f+".position",d,"pos",n),r(Kl,f+".quaternion",d,"rot",n),r(bu,f+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,n=t.length;r!==n;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Qz(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return xu;case"vector":case"vector2":case"vector3":case"vector4":return bu;case"color":return Ag;case"quaternion":return Kl;case"bool":case"boolean":return Da;case"string":return Ia}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Kz(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Qz(i.type);if(i.times===void 0){let e=[],r=[];gM(i.keys,e,r,"value"),i.times=e,i.values=r}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var zE={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Gf=class{constructor(t,e,r){let n=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(c){a++,s===!1&&n.onStart!==void 0&&n.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,n.onProgress!==void 0&&n.onProgress(c,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(c){n.onError!==void 0&&n.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],p=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}},Zz=new Gf,Su=class{constructor(t){this.manager=t!==void 0?t:Zz,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(n,s){r.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}},Fo={},zb=class extends Error{constructor(t,e){super(t),this.response=e}},Au=class extends Su{constructor(t){super(t)}load(t,e,r,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=zE.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(Fo[t]!==void 0){Fo[t].push({onLoad:e,onProgress:r,onError:n});return}Fo[t]=[],Fo[t].push({onLoad:e,onProgress:r,onError:n});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(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=Fo[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.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:w})=>{if(x)y.close();else{m+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,E=c.length;A<E;A++){let b=c[A];b.onProgress&&b.onProgress(S)}y.enqueue(w),v()}})}}});return new Response(g)}else throw new zb(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{zE.add(t,u);let c=Fo[t];delete Fo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=Fo[t];if(c===void 0)throw this.manager.itemError(t),u;delete Fo[t];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Oa=class extends gt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(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}},_g=class extends Oa{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},hb=new ie,UE=new _,GE=new _,Hf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new N(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Lf,this._frameExtents=new N(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;UE.setFromMatrixPosition(t.matrixWorld),e.position.copy(UE),GE.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(GE),e.updateMatrixWorld(),hb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(hb)}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}},Ub=class extends Hf{constructor(){super(new Ir(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Of*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Eg=class extends Oa{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ub}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}},HE=new ie,Af=new _,db=new _,Gb=class extends Hf{constructor(){super(new Ir(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new N(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),Af.setFromMatrixPosition(t.matrixWorld),r.position.copy(Af),db.copy(r.position),db.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(db),r.updateMatrixWorld(),n.makeTranslation(-Af.x,-Af.y,-Af.z),HE.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HE)}},Mg=class extends Oa{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new Gb}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}},Hb=class extends Hf{constructor(){super(new au(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Tg=class extends Oa{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new Hb}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var jf=class extends Ae{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}},_u=class extends Su{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new Au(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){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=Lm(g.type,y),x=new bg(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 jf:new Ae,a=t.data.index;if(a!==void 0){let f=Lm(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=n(t.data,p.data);m=new Gl(g,p.itemSize,p.offset,p.normalized)}else{let g=Lm(p.type,p.array),y=p.isInstancedBufferAttribute?cu:Ge;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 u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g<y;g++){let v=p[g],x;if(v.isInterleavedBufferAttribute){let w=n(t.data,v.data);x=new Gl(w,v.itemSize,v.offset,v.normalized)}else{let w=Lm(v.type,v.array);x=new Ge(w,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),m.push(x)}o.morphAttributes[f]=m}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let m=h[f];o.addGroup(m.start,m.count,m.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new _;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new fr(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Cg=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=jE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=jE();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function jE(){return(typeof performance>"u"?Date:performance).now()}var jb=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,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,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=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,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,n,s){if(n>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){He.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;He.multiplyQuaternionsFlat(t,o,t,e,t,r),He.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},nw="\\[\\]\\.:\\/",Jz=new RegExp("["+nw+"]","g"),iw="[^"+nw+"]",$z="[^"+nw.replace("\\.","")+"]",eU=/((?:WC+[\/:])*)/.source.replace("WC",iw),tU=/(WCOD+)?/.source.replace("WCOD",$z),rU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",iw),nU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",iw),iU=new RegExp("^"+eU+tU+rU+nU+"$"),sU=["material","materials","bones","map"],Wb=class{constructor(t,e,r){let n=r||Ft.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].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()}},Ft=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Ft.parseTrackName(e),this.node=Ft.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 Ft.Composite(t,e,r):new Ft(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Jz,"")}static parseTrackName(t){let e=iU.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]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);sU.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},n=r(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)t[e++]=r[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,s=e.propertyIndex;if(t||(t=Ft.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(r){let u=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===u){u=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(u!==void 0){if(t[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[u]}}let o=t[n];if(o===void 0){let u=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ft.Composite=Wb;Ft.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ft.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ft.prototype.GetterByBindingType=[Ft.prototype._getValue_direct,Ft.prototype._getValue_array,Ft.prototype._getValue_arrayElement,Ft.prototype._getValue_toArray];Ft.prototype.SetterByBindingTypeAndVersioning=[[Ft.prototype._setValue_direct,Ft.prototype._setValue_direct_setNeedsUpdate,Ft.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_array,Ft.prototype._setValue_array_setNeedsUpdate,Ft.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_arrayElement,Ft.prototype._setValue_arrayElement_setNeedsUpdate,Ft.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ft.prototype._setValue_fromArray,Ft.prototype._setValue_fromArray_setNeedsUpdate,Ft.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var qb=class{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:eu,endingEnd:eu};for(let u=0;u!==o;++u){let c=s[u].createInterpolant(null);a[u]=c,c.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Kb,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let n=this._clip.duration,s=t._clip.duration,o=s/n,a=n/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,u=a.sampleValues;return l[0]=s,l[1]=s+r,u[0]=t/o,u[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case bN:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Zb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===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 n=r.evaluate(t)[0];e*=n,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,n=this.time+t,s=this._loopCount,o=r===qf;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,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)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=tu,n.endingEnd=tu):(t?n.endingStart=this.zeroSlopeAtStart?tu:eu:n.endingStart=ug,e?n.endingEnd=this.zeroSlopeAtEnd?tu:eu:n.endingEnd=ug)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._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}},oU=new Float32Array(1),Pg=class extends Yt{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,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=c[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 jb(Ft.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,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++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,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let n=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,u=l[l.length-1],c=t._byClipCacheIndex;u._byClipCacheIndex=c,l[c]=u,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let n=this._bindingsByRootAndName,s=this._bindings,o=n[e];o===void 0&&(o={},n[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,n=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[n],l=e[e.length-1],u=t._cacheIndex;l._cacheIndex=u,e[u]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Sg(new Float32Array(2),new Float32Array(2),1,oU),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let n=e||this._root,s=n.uuid,o=typeof t=="string"?wu.findByName(n,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],u=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Zb),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;u=l.knownActions[0],o===null&&(o=u._clip)}if(o===null)return null;let c=new qb(this,o,e,r);return this._bindAction(c,u),this._addInactiveAction(c,a,s),c}existingAction(t,e){let r=e||this._root,n=r.uuid,s=typeof t=="string"?wu.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==r;++u)e[u]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,n=this._actionsByClip,s=n[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let u=o[a];this._deactivateAction(u);let c=u._cacheIndex,h=e[e.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,h._cacheIndex=c,e[c]=h,e.pop(),this._removeInactiveBindingsForAction(u)}delete n[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},oe=class{constructor(t){this.value=t}clone(){return new oe(this.value.clone===void 0?this.value:this.value.clone())}};var Eu=class{constructor(t,e,r=0,n=1/0){this.ray=new ms(t,e),this.near=r,this.far=n,this.camera=null,this.layers=new Rf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,r=[]){return Yb(t,this,r,e),r.sort(WE),r}intersectObjects(t,e=!0,r=[]){for(let n=0,s=t.length;n<s;n++)Yb(t[n],this,r,e);return r.sort(WE),r}};function WE(i,t){return i.distance-t.distance}function Yb(i,t,e,r){if(i.layers.test(t.layers)&&i.raycast(t,e),r===!0){let n=i.children;for(let s=0,o=n.length;s<o;s++)Yb(n[s],t,e,!0)}}var Wf=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(Yr(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var qE=new N,Mu=class{constructor(t=new N(1/0,1/0),e=new N(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=qE.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return qE.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)}},YE=new _,ig=new _,nn=class{constructor(t=new _,e=new _){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){YE.subVectors(t,this.start),ig.subVectors(this.end,this.start);let r=ig.dot(ig),s=ig.dot(YE)/r;return e&&(s=Yr(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).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)}},XE=new _,Dg=class extends gt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ae,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;n.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}r.setAttribute("position",new be(n,3));let s=new Hi({fog:!1,toneMapped:!1});this.cone=new Pa(r,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),XE.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(XE),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Ig=class extends _r{constructor(t,e,r){let n=new Ql(e,4,2),s=new Go({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=t,this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var QE=new _,sg=new _,KE=new _,Og=class extends gt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let n=new Ae;n.setAttribute("position",new be([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new Hi({fog:!1,toneMapped:!1});this.lightPlane=new Hl(n,s),this.add(this.lightPlane),n=new Ae,n.setAttribute("position",new be([0,0,0,0,0,1],3)),this.targetLine=new Hl(n,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),QE.setFromMatrixPosition(this.light.matrixWorld),sg.setFromMatrixPosition(this.light.target.matrixWorld),KE.subVectors(sg,QE),this.lightPlane.lookAt(sg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(sg),this.targetLine.scale.z=KE.length()}},og=new _,Ar=new gs,Ra=class extends Pa{constructor(t){let e=new Ae,r=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){l(p),l(m)}function l(p){n.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(n.length/3-1)}e.setAttribute("position",new be(n,3)),e.setAttribute("color",new be(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Re(16755200),c=new Re(16711680),h=new Re(43775),d=new Re(16777215),f=new Re(3355443);this.setColors(u,c,h,d,f)}setColors(t,e,r,n,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,r=1,n=1;Ar.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Dr("c",e,t,Ar,0,0,-1),Dr("t",e,t,Ar,0,0,1),Dr("n1",e,t,Ar,-r,-n,-1),Dr("n2",e,t,Ar,r,-n,-1),Dr("n3",e,t,Ar,-r,n,-1),Dr("n4",e,t,Ar,r,n,-1),Dr("f1",e,t,Ar,-r,-n,1),Dr("f2",e,t,Ar,r,-n,1),Dr("f3",e,t,Ar,-r,n,1),Dr("f4",e,t,Ar,r,n,1),Dr("u1",e,t,Ar,r*.7,n*1.1,-1),Dr("u2",e,t,Ar,-r*.7,n*1.1,-1),Dr("u3",e,t,Ar,0,n*2,-1),Dr("cf1",e,t,Ar,-r,0,1),Dr("cf2",e,t,Ar,r,0,1),Dr("cf3",e,t,Ar,0,-n,1),Dr("cf4",e,t,Ar,0,n,1),Dr("cn1",e,t,Ar,-r,0,-1),Dr("cn2",e,t,Ar,r,0,-1),Dr("cn3",e,t,Ar,0,-n,-1),Dr("cn4",e,t,Ar,0,n,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Dr(i,t,e,r,n,s,o){og.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],og.x,og.y,og.z)}}var La=class extends Pa{constructor(t,e=16776960){let r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ae;s.setIndex(new Ge(r,1)),s.setAttribute("position",new be(n,3)),super(s,new Hi({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var Rg=class extends Pa{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Ae;n.setAttribute("position",new be(e,3)),n.setAttribute("color",new be(r,3));let s=new Hi({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(t,e,r){let n=new Re,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(r),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var ko=aU();function aU(){let i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),r=new Uint32Array(512),n=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(r[l]=0,r[l|256]=32768,n[l]=24,n[l|256]=24):u<-14?(r[l]=1024>>-u-14,r[l|256]=1024>>-u-14|32768,n[l]=-u-1,n[l|256]=-u-1):u<=15?(r[l]=u+15<<10,r[l|256]=u+15<<10|32768,n[l]=13,n[l|256]=13):u<128?(r[l]=31744,r[l|256]=64512,n[l]=24,n[l|256]=24):(r[l]=31744,r[l|256]=64512,n[l]=13,n[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}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:n,mantissaTable:s,exponentTable:o,offsetTable:a}}function lU(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Yr(i,-65504,65504),ko.floatView[0]=i;let t=ko.uint32View[0],e=t>>23&511;return ko.baseTable[e]+((t&8388607)>>ko.shiftTable[e])}function cU(i){let t=i>>10;return ko.uint32View[0]=ko.mantissaTable[ko.offsetTable[t]+(i&1023)]+ko.exponentTable[t],ko.floatView[0]}var yM=Object.freeze({__proto__:null,fromHalfFloat:cU,toHalfFloat:lU});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Wo);var Du=".",Yf=Symbol("target"),sw=Symbol("unsubscribe");function Xf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function vM(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Ri=Array.isArray;function Zl(i){return typeof i=="symbol"}var uU={after:(i,t)=>Ri(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Ri(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Du),Zl(t)?i+t.toString():i+t):i,initial:i=>{if(Ri(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Du);return t===-1?"":i.slice(0,t)},last:i=>{if(Ri(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Du);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Ri(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(Du);if(r===-1)t(i);else for(;e<i.length;)r===-1&&(r=i.length),t(i.slice(e,r)),e=r+1,r=i.indexOf(Du,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},ei=uU;function ow(i){return typeof i=="object"&&typeof i.next=="function"}function aw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[Yf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function Fg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Zl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Qf=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),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],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,ei.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,n,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,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.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 Iu(i){return toString.call(i)==="[object Object]"}function Ou(){return!0}function Na(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var kg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var hU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lw={push:Ou,pop:Ou,shift:Ou,unshift:Ou,copyWithin:Na,reverse:Na,sort:Na,splice:Na,flat:Na,fill:Na},xM=new Set([...kg,...hU,...Object.keys(lw)]);function Ru(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var cw=["keys","values","entries"],uw=new Set(["has","toString"]),hw={add:Ru,clear:Ru,delete:Ru,forEach:Ru},bM=new Set([...uw,...Object.keys(hw),...cw]);function Lu(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var dU=new Set([...uw,"get"]),dw={set:Lu,clear:Lu,delete:Lu,forEach:Lu},wM=new Set([...dU,...Object.keys(dw),...cw]);var xn=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return kg.has(t)}_shallowClone(t){let e=t;if(Iu(t))e={...t};else if(Ri(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,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Ri(n)?this._onIsChanged=lw[e]:n instanceof Set?this._onIsChanged=hw[e]:n instanceof Map&&(this._onIsChanged=dw[e]),n):r}update(t,e,r){let n=ei.after(t,this._path);if(e!=="length"){let s=this.clone;ei.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,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],ei.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Nu=class extends xn{static isHandledMethod(t){return xM.has(t)}};var Kf=class extends xn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Bu=class extends xn{static isHandledMethod(t){return bM.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 Fu=class extends xn{static isHandledMethod(t){return wM.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 Zf=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),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 Jf=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),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 vs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Iu(t)||Ri(t)||Xf(t)}static isHandledMethod(t,e){return Iu(t)?xn.isHandledMethod(e):Ri(t)?Nu.isHandledMethod(e):t instanceof Set?Bu.isHandledMethod(e):t instanceof Map?Fu.isHandledMethod(e):Xf(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=xn;Ri(t)?n=Nu:t instanceof Date?n=Kf:t instanceof Set?n=Bu:t instanceof Map?n=Fu:t instanceof WeakSet?n=Zf:t instanceof WeakMap&&(n=Jf),this._stack.push(new n(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:n}=t,s=vs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,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 fU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fw=(i,t,e={})=>{e={...fU,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Qf(n),u=typeof e.onValidate=="function",c=new vs(u),h=(v,x,w,S,A)=>!u||c.isCloning||e.onValidate(ei.concat(l.getPath(v),x),w,S,A)===!0,d=(v,x,w,S)=>{!Fg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,A)=>{c.isCloning?c.update(v,x,S):t(ei.concat(v,x),w,S,A)},p=v=>v&&(v[r]||v),m=(v,x,w,S)=>vM(v)||w==="constructor"||s&&!vs.isHandledMethod(x,w)||Fg(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,ei.concat(S,w),g,r)),g={get(v,x,w){if(Zl(x)){if(x===r||x===Yf)return v;if(x===sw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Xf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return m(S,v,x)},set(v,x,w,S){w=p(w);let A=v[r]||v,E=A[x];if(n(E,w)&&x in v)return!0;let b=h(v,x,w,E);return b&&l.setProperty(A,x,w,S,E)?(d(v,x,v[x],E),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];h(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&d(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=h(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(d(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&vs.isHandledType(S)){let A=ei.initial(l.getPath(v)),E=vs.isHandledMethod(S,v.name);c.start(S,A,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),E?w.map(C=>p(C)):w),M=c.isChanged(S,n),T=c.stop();if(vs.isHandledType(b)&&E&&(x instanceof Map&&v.name==="get"&&(A=ei.concat(A,w[0])),b=l.getProxy(b,A,g)),M){let C={name:v.name,args:w,result:b},P=c.isCloning?ei.initial(A):A,D=c.isCloning?ei.last(A):"";h(ei.get(i,P),D,S,T,C)?f(P,D,S,T,C):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ow(b)?aw(b,v,x,A,m):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fw.target=i=>i&&i[Yf]||i;fw.unsubscribe=i=>i[sw]||i;var pw=fw;var pU=typeof global=="object"&&global&&global.Object===Object&&global,Vg=pU;var mU=typeof self=="object"&&self&&self.Object===Object&&self,gU=Vg||mU||Function("return this")(),Er=gU;var yU=Er.Symbol,bn=yU;var SM=Object.prototype,vU=SM.hasOwnProperty,xU=SM.toString,$f=bn?bn.toStringTag:void 0;function bU(i){var t=vU.call(i,$f),e=i[$f];try{i[$f]=void 0;var r=!0}catch{}var n=xU.call(i);return r&&(t?i[$f]=e:delete i[$f]),n}var AM=bU;var wU=Object.prototype,SU=wU.toString;function AU(i){return SU.call(i)}var _M=AU;var _U="[object Null]",EU="[object Undefined]",EM=bn?bn.toStringTag:void 0;function MU(i){return i==null?i===void 0?EU:_U:EM&&EM in Object(i)?AM(i):_M(i)}var Li=MU;function TU(i){return i!=null&&typeof i=="object"}var Bn=TU;var CU="[object Symbol]";function PU(i){return typeof i=="symbol"||Bn(i)&&Li(i)==CU}var Ba=PU;function DU(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var zg=DU;var IU=Array.isArray,sn=IU;var OU=1/0,MM=bn?bn.prototype:void 0,TM=MM?MM.toString:void 0;function CM(i){if(typeof i=="string")return i;if(sn(i))return zg(i,CM)+"";if(Ba(i))return TM?TM.call(i):"";var t=i+"";return t=="0"&&1/i==-OU?"-0":t}var PM=CM;var RU=/\s/;function LU(i){for(var t=i.length;t--&&RU.test(i.charAt(t)););return t}var DM=LU;var NU=/^\s+/;function BU(i){return i&&i.slice(0,DM(i)+1).replace(NU,"")}var IM=BU;function FU(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Kr=FU;var OM=0/0,kU=/^[-+]0x[0-9a-f]+$/i,VU=/^0b[01]+$/i,zU=/^0o[0-7]+$/i,UU=parseInt;function GU(i){if(typeof i=="number")return i;if(Ba(i))return OM;if(Kr(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kr(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=IM(i);var e=VU.test(i);return e||zU.test(i)?UU(i.slice(2),e?2:8):kU.test(i)?OM:+i}var mw=GU;function HU(i){return i}var RM=HU;var jU="[object AsyncFunction]",WU="[object Function]",qU="[object GeneratorFunction]",YU="[object Proxy]";function XU(i){if(!Kr(i))return!1;var t=Li(i);return t==WU||t==qU||t==jU||t==YU}var Ug=XU;var QU=Er["__core-js_shared__"],Gg=QU;var LM=function(){var i=/[^.]+$/.exec(Gg&&Gg.keys&&Gg.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function KU(i){return!!LM&&LM in i}var NM=KU;var ZU=Function.prototype,JU=ZU.toString;function $U(i){if(i!=null){try{return JU.call(i)}catch{}try{return i+""}catch{}}return""}var qo=$U;var eG=/[\\^$.*+?()[\]{}|]/g,tG=/^\[object .+?Constructor\]$/,rG=Function.prototype,nG=Object.prototype,iG=rG.toString,sG=nG.hasOwnProperty,oG=RegExp("^"+iG.call(sG).replace(eG,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function aG(i){if(!Kr(i)||NM(i))return!1;var t=Ug(i)?oG:tG;return t.test(qo(i))}var BM=aG;function lG(i,t){return i?.[t]}var FM=lG;function cG(i,t){var e=FM(i,t);return BM(e)?e:void 0}var ci=cG;var uG=ci(Er,"WeakMap"),Hg=uG;var kM=Object.create,hG=function(){function i(){}return function(t){if(!Kr(t))return{};if(kM)return kM(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),VM=hG;function dG(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var zM=dG;function fG(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var UM=fG;var pG=800,mG=16,gG=Date.now;function yG(i){var t=0,e=0;return function(){var r=gG(),n=mG-(r-e);if(e=r,n>0){if(++t>=pG)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var GM=yG;function vG(i){return function(){return i}}var HM=vG;var xG=function(){try{var i=ci(Object,"defineProperty");return i({},"",{}),i}catch{}}(),ku=xG;var bG=ku?function(i,t){return ku(i,"toString",{configurable:!0,enumerable:!1,value:HM(t),writable:!0})}:RM,jM=bG;var wG=GM(jM),WM=wG;function SG(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var qM=SG;var AG=9007199254740991,_G=/^(?:0|[1-9]\d*)$/;function EG(i,t){var e=typeof i;return t=t??AG,!!t&&(e=="number"||e!="symbol"&&_G.test(i))&&i>-1&&i%1==0&&i<t}var Vu=EG;function MG(i,t,e){t=="__proto__"&&ku?ku(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var jg=MG;function TG(i,t){return i===t||i!==i&&t!==t}var zu=TG;var CG=Object.prototype,PG=CG.hasOwnProperty;function DG(i,t,e){var r=i[t];(!(PG.call(i,t)&&zu(r,e))||e===void 0&&!(t in i))&&jg(i,t,e)}var Uu=DG;function IG(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),n?jg(e,a,l):Uu(e,a,l)}return e}var Ws=IG;var YM=Math.max;function OG(i,t,e){return t=YM(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=YM(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),zM(i,this,a)}}var XM=OG;var RG=9007199254740991;function LG(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=RG}var Gu=LG;function NG(i){return i!=null&&Gu(i.length)&&!Ug(i)}var Wg=NG;var BG=Object.prototype;function FG(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||BG;return i===e}var Hu=FG;function kG(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var QM=kG;var VG="[object Arguments]";function zG(i){return Bn(i)&&Li(i)==VG}var gw=zG;var KM=Object.prototype,UG=KM.hasOwnProperty,GG=KM.propertyIsEnumerable,HG=gw(function(){return arguments}())?gw:function(i){return Bn(i)&&UG.call(i,"callee")&&!GG.call(i,"callee")},ju=HG;function jG(){return!1}var ZM=jG;var eT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,JM=eT&&typeof module=="object"&&module&&!module.nodeType&&module,WG=JM&&JM.exports===eT,$M=WG?Er.Buffer:void 0,qG=$M?$M.isBuffer:void 0,YG=qG||ZM,Jl=YG;var XG="[object Arguments]",QG="[object Array]",KG="[object Boolean]",ZG="[object Date]",JG="[object Error]",$G="[object Function]",e4="[object Map]",t4="[object Number]",r4="[object Object]",n4="[object RegExp]",i4="[object Set]",s4="[object String]",o4="[object WeakMap]",a4="[object ArrayBuffer]",l4="[object DataView]",c4="[object Float32Array]",u4="[object Float64Array]",h4="[object Int8Array]",d4="[object Int16Array]",f4="[object Int32Array]",p4="[object Uint8Array]",m4="[object Uint8ClampedArray]",g4="[object Uint16Array]",y4="[object Uint32Array]",cr={};cr[c4]=cr[u4]=cr[h4]=cr[d4]=cr[f4]=cr[p4]=cr[m4]=cr[g4]=cr[y4]=!0;cr[XG]=cr[QG]=cr[a4]=cr[KG]=cr[l4]=cr[ZG]=cr[JG]=cr[$G]=cr[e4]=cr[t4]=cr[r4]=cr[n4]=cr[i4]=cr[s4]=cr[o4]=!1;function v4(i){return Bn(i)&&Gu(i.length)&&!!cr[Li(i)]}var tT=v4;function x4(i){return function(t){return i(t)}}var Wu=x4;var rT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ep=rT&&typeof module=="object"&&module&&!module.nodeType&&module,b4=ep&&ep.exports===rT,yw=b4&&Vg.process,w4=function(){try{var i=ep&&ep.require&&ep.require("util").types;return i||yw&&yw.binding&&yw.binding("util")}catch{}}(),Yo=w4;var nT=Yo&&Yo.isTypedArray,S4=nT?Wu(nT):tT,qg=S4;var A4=Object.prototype,_4=A4.hasOwnProperty;function E4(i,t){var e=sn(i),r=!e&&ju(i),n=!e&&!r&&Jl(i),s=!e&&!r&&!n&&qg(i),o=e||r||n||s,a=o?QM(i.length,String):[],l=a.length;for(var u in i)(t||_4.call(i,u))&&!(o&&(u=="length"||n&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Vu(u,l)))&&a.push(u);return a}var Yg=E4;function M4(i,t){return function(e){return i(t(e))}}var Xg=M4;var T4=Xg(Object.keys,Object),iT=T4;var C4=Object.prototype,P4=C4.hasOwnProperty;function D4(i){if(!Hu(i))return iT(i);var t=[];for(var e in Object(i))P4.call(i,e)&&e!="constructor"&&t.push(e);return t}var sT=D4;function I4(i){return Wg(i)?Yg(i):sT(i)}var qu=I4;function O4(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var oT=O4;var R4=Object.prototype,L4=R4.hasOwnProperty;function N4(i){if(!Kr(i))return oT(i);var t=Hu(i),e=[];for(var r in i)r=="constructor"&&(t||!L4.call(i,r))||e.push(r);return e}var aT=N4;function B4(i){return Wg(i)?Yg(i,!0):aT(i)}var Yu=B4;var F4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k4=/^\w*$/;function V4(i,t){if(sn(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Ba(i)?!0:k4.test(i)||!F4.test(i)||t!=null&&i in Object(t)}var lT=V4;var z4=ci(Object,"create"),Xo=z4;function U4(){this.__data__=Xo?Xo(null):{},this.size=0}var cT=U4;function G4(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var uT=G4;var H4="__lodash_hash_undefined__",j4=Object.prototype,W4=j4.hasOwnProperty;function q4(i){var t=this.__data__;if(Xo){var e=t[i];return e===H4?void 0:e}return W4.call(t,i)?t[i]:void 0}var hT=q4;var Y4=Object.prototype,X4=Y4.hasOwnProperty;function Q4(i){var t=this.__data__;return Xo?t[i]!==void 0:X4.call(t,i)}var dT=Q4;var K4="__lodash_hash_undefined__";function Z4(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Xo&&t===void 0?K4:t,this}var fT=Z4;function Xu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Xu.prototype.clear=cT;Xu.prototype.delete=uT;Xu.prototype.get=hT;Xu.prototype.has=dT;Xu.prototype.set=fT;var vw=Xu;function J4(){this.__data__=[],this.size=0}var pT=J4;function $4(i,t){for(var e=i.length;e--;)if(zu(i[e][0],t))return e;return-1}var Fa=$4;var eH=Array.prototype,tH=eH.splice;function rH(i){var t=this.__data__,e=Fa(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():tH.call(t,e,1),--this.size,!0}var mT=rH;function nH(i){var t=this.__data__,e=Fa(t,i);return e<0?void 0:t[e][1]}var gT=nH;function iH(i){return Fa(this.__data__,i)>-1}var yT=iH;function sH(i,t){var e=this.__data__,r=Fa(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var vT=sH;function Qu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Qu.prototype.clear=pT;Qu.prototype.delete=mT;Qu.prototype.get=gT;Qu.prototype.has=yT;Qu.prototype.set=vT;var ka=Qu;var oH=ci(Er,"Map"),Va=oH;function aH(){this.size=0,this.__data__={hash:new vw,map:new(Va||ka),string:new vw}}var xT=aH;function lH(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var bT=lH;function cH(i,t){var e=i.__data__;return bT(t)?e[typeof t=="string"?"string":"hash"]:e.map}var za=cH;function uH(i){var t=za(this,i).delete(i);return this.size-=t?1:0,t}var wT=uH;function hH(i){return za(this,i).get(i)}var ST=hH;function dH(i){return za(this,i).has(i)}var AT=dH;function fH(i,t){var e=za(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var _T=fH;function Ku(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ku.prototype.clear=xT;Ku.prototype.delete=wT;Ku.prototype.get=ST;Ku.prototype.has=AT;Ku.prototype.set=_T;var $l=Ku;var pH="Expected a function";function xw(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(pH);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=e.cache;if(s.has(n))return s.get(n);var o=i.apply(this,r);return e.cache=s.set(n,o)||s,o};return e.cache=new(xw.Cache||$l),e}xw.Cache=$l;var ET=xw;var mH=500;function gH(i){var t=ET(i,function(r){return e.size===mH&&e.clear(),r}),e=t.cache;return t}var MT=gH;var yH=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vH=/\\(\\)?/g,xH=MT(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(yH,function(e,r,n,s){t.push(n?s.replace(vH,"$1"):r||e)}),t}),TT=xH;function bH(i){return i==null?"":PM(i)}var CT=bH;function wH(i,t){return sn(i)?i:lT(i,t)?[i]:TT(CT(i))}var qi=wH;var SH=1/0;function AH(i){if(typeof i=="string"||Ba(i))return i;var t=i+"";return t=="0"&&1/i==-SH?"-0":t}var Ua=AH;function _H(i,t){t=qi(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ua(t[e++])];return e&&e==r?i:void 0}var Qg=_H;function EH(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Zu=EH;var PT=bn?bn.isConcatSpreadable:void 0;function MH(i){return sn(i)||ju(i)||!!(PT&&i&&i[PT])}var DT=MH;function IT(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=DT),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?IT(a,t-1,e,r,n):Zu(n,a):r||(n[n.length]=a)}return n}var OT=IT;function TH(i){var t=i==null?0:i.length;return t?OT(i,1):[]}var RT=TH;function CH(i){return WM(XM(i,void 0,RT),i+"")}var Kg=CH;var PH=Xg(Object.getPrototypeOf,Object),Ju=PH;var DH="[object Object]",IH=Function.prototype,OH=Object.prototype,LT=IH.toString,RH=OH.hasOwnProperty,LH=LT.call(Object);function NH(i){if(!Bn(i)||Li(i)!=DH)return!1;var t=Ju(i);if(t===null)return!0;var e=RH.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&<.call(e)==LH}var NT=NH;function BH(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+t];return s}var BT=BH;function FH(){this.__data__=new ka,this.size=0}var FT=FH;function kH(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var kT=kH;function VH(i){return this.__data__.get(i)}var VT=VH;function zH(i){return this.__data__.has(i)}var zT=zH;var UH=200;function GH(i,t){var e=this.__data__;if(e instanceof ka){var r=e.__data__;if(!Va||r.length<UH-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new $l(r)}return e.set(i,t),this.size=e.size,this}var UT=GH;function $u(i){var t=this.__data__=new ka(i);this.size=t.size}$u.prototype.clear=FT;$u.prototype.delete=kT;$u.prototype.get=VT;$u.prototype.has=zT;$u.prototype.set=UT;var eh=$u;function HH(i,t){return i&&Ws(t,qu(t),i)}var GT=HH;function jH(i,t){return i&&Ws(t,Yu(t),i)}var HT=jH;var YT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jT=YT&&typeof module=="object"&&module&&!module.nodeType&&module,WH=jT&&jT.exports===YT,WT=WH?Er.Buffer:void 0,qT=WT?WT.allocUnsafe:void 0;function qH(i,t){if(t)return i.slice();var e=i.length,r=qT?qT(e):new i.constructor(e);return i.copy(r),r}var XT=qH;function YH(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var QT=YH;function XH(){return[]}var Zg=XH;var QH=Object.prototype,KH=QH.propertyIsEnumerable,KT=Object.getOwnPropertySymbols,ZH=KT?function(i){return i==null?[]:(i=Object(i),QT(KT(i),function(t){return KH.call(i,t)}))}:Zg,th=ZH;function JH(i,t){return Ws(i,th(i),t)}var ZT=JH;var $H=Object.getOwnPropertySymbols,e5=$H?function(i){for(var t=[];i;)Zu(t,th(i)),i=Ju(i);return t}:Zg,Jg=e5;function t5(i,t){return Ws(i,Jg(i),t)}var JT=t5;function r5(i,t,e){var r=t(i);return sn(i)?r:Zu(r,e(i))}var $g=r5;function n5(i){return $g(i,qu,th)}var tp=n5;function i5(i){return $g(i,Yu,Jg)}var ey=i5;var s5=ci(Er,"DataView"),ty=s5;var o5=ci(Er,"Promise"),ry=o5;var a5=ci(Er,"Set"),ny=a5;var $T="[object Map]",l5="[object Object]",eC="[object Promise]",tC="[object Set]",rC="[object WeakMap]",nC="[object DataView]",c5=qo(ty),u5=qo(Va),h5=qo(ry),d5=qo(ny),f5=qo(Hg),ec=Li;(ty&&ec(new ty(new ArrayBuffer(1)))!=nC||Va&&ec(new Va)!=$T||ry&&ec(ry.resolve())!=eC||ny&&ec(new ny)!=tC||Hg&&ec(new Hg)!=rC)&&(ec=function(i){var t=Li(i),e=t==l5?i.constructor:void 0,r=e?qo(e):"";if(r)switch(r){case c5:return nC;case u5:return $T;case h5:return eC;case d5:return tC;case f5:return rC}return t});var Qo=ec;var p5=Object.prototype,m5=p5.hasOwnProperty;function g5(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&m5.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var iC=g5;var y5=Er.Uint8Array,rh=y5;function v5(i){var t=new i.constructor(i.byteLength);return new rh(t).set(new rh(i)),t}var nh=v5;function x5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var sC=x5;var b5=/\w*$/;function w5(i){var t=new i.constructor(i.source,b5.exec(i));return t.lastIndex=i.lastIndex,t}var oC=w5;var aC=bn?bn.prototype:void 0,lC=aC?aC.valueOf:void 0;function S5(i){return lC?Object(lC.call(i)):{}}var cC=S5;function A5(i,t){var e=t?nh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var uC=A5;var _5="[object Boolean]",E5="[object Date]",M5="[object Map]",T5="[object Number]",C5="[object RegExp]",P5="[object Set]",D5="[object String]",I5="[object Symbol]",O5="[object ArrayBuffer]",R5="[object DataView]",L5="[object Float32Array]",N5="[object Float64Array]",B5="[object Int8Array]",F5="[object Int16Array]",k5="[object Int32Array]",V5="[object Uint8Array]",z5="[object Uint8ClampedArray]",U5="[object Uint16Array]",G5="[object Uint32Array]";function H5(i,t,e){var r=i.constructor;switch(t){case O5:return nh(i);case _5:case E5:return new r(+i);case R5:return sC(i,e);case L5:case N5:case B5:case F5:case k5:case V5:case z5:case U5:case G5:return uC(i,e);case M5:return new r;case T5:case D5:return new r(i);case C5:return oC(i);case P5:return new r;case I5:return cC(i)}}var hC=H5;function j5(i){return typeof i.constructor=="function"&&!Hu(i)?VM(Ju(i)):{}}var dC=j5;var W5="[object Map]";function q5(i){return Bn(i)&&Qo(i)==W5}var fC=q5;var pC=Yo&&Yo.isMap,Y5=pC?Wu(pC):fC,mC=Y5;var X5="[object Set]";function Q5(i){return Bn(i)&&Qo(i)==X5}var gC=Q5;var yC=Yo&&Yo.isSet,K5=yC?Wu(yC):gC,vC=K5;var Z5=1,J5=2,$5=4,xC="[object Arguments]",ej="[object Array]",tj="[object Boolean]",rj="[object Date]",nj="[object Error]",bC="[object Function]",ij="[object GeneratorFunction]",sj="[object Map]",oj="[object Number]",wC="[object Object]",aj="[object RegExp]",lj="[object Set]",cj="[object String]",uj="[object Symbol]",hj="[object WeakMap]",dj="[object ArrayBuffer]",fj="[object DataView]",pj="[object Float32Array]",mj="[object Float64Array]",gj="[object Int8Array]",yj="[object Int16Array]",vj="[object Int32Array]",xj="[object Uint8Array]",bj="[object Uint8ClampedArray]",wj="[object Uint16Array]",Sj="[object Uint32Array]",ar={};ar[xC]=ar[ej]=ar[dj]=ar[fj]=ar[tj]=ar[rj]=ar[pj]=ar[mj]=ar[gj]=ar[yj]=ar[vj]=ar[sj]=ar[oj]=ar[wC]=ar[aj]=ar[lj]=ar[cj]=ar[uj]=ar[xj]=ar[bj]=ar[wj]=ar[Sj]=!0;ar[nj]=ar[bC]=ar[hj]=!1;function iy(i,t,e,r,n,s){var o,a=t&Z5,l=t&J5,u=t&$5;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!Kr(i))return i;var c=sn(i);if(c){if(o=iC(i),!a)return UM(i,o)}else{var h=Qo(i),d=h==bC||h==ij;if(Jl(i))return XT(i,a);if(h==wC||h==xC||d&&!n){if(o=l||d?{}:dC(i),!a)return l?JT(i,HT(o,i)):ZT(i,GT(o,i))}else{if(!ar[h])return n?i:{};o=hC(i,h,a)}}s||(s=new eh);var f=s.get(i);if(f)return f;s.set(i,o),vC(i)?i.forEach(function(g){o.add(iy(g,t,e,g,i,s))}):mC(i)&&i.forEach(function(g,y){o.set(y,iy(g,t,e,y,i,s))});var p=u?l?ey:tp:l?Yu:qu,m=c?void 0:p(i);return qM(m||i,function(g,y){m&&(y=g,g=i[y]),Uu(o,y,iy(g,t,e,y,i,s))}),o}var sy=iy;var Aj=1,_j=4;function Ej(i){return sy(i,Aj|_j)}var Ko=Ej;var Mj="__lodash_hash_undefined__";function Tj(i){return this.__data__.set(i,Mj),this}var SC=Tj;function Cj(i){return this.__data__.has(i)}var AC=Cj;function oy(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new $l;++t<e;)this.add(i[t])}oy.prototype.add=oy.prototype.push=SC;oy.prototype.has=AC;var _C=oy;function Pj(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var EC=Pj;function Dj(i,t){return i.has(t)}var MC=Dj;var Ij=1,Oj=2;function Rj(i,t,e,r,n,s){var o=e&Ij,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&Oj?new _C:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],m=t[h];if(r)var g=o?r(m,p,h,t,i,s):r(p,m,h,i,t,s);if(g!==void 0){if(g)continue;d=!1;break}if(f){if(!EC(t,function(y,v){if(!MC(f,v)&&(p===y||n(p,y,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===m||n(p,m,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var ay=Rj;function Lj(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var TC=Lj;function Nj(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var CC=Nj;var Bj=1,Fj=2,kj="[object Boolean]",Vj="[object Date]",zj="[object Error]",Uj="[object Map]",Gj="[object Number]",Hj="[object RegExp]",jj="[object Set]",Wj="[object String]",qj="[object Symbol]",Yj="[object ArrayBuffer]",Xj="[object DataView]",PC=bn?bn.prototype:void 0,bw=PC?PC.valueOf:void 0;function Qj(i,t,e,r,n,s,o){switch(e){case Xj:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case Yj:return!(i.byteLength!=t.byteLength||!s(new rh(i),new rh(t)));case kj:case Vj:case Gj:return zu(+i,+t);case zj:return i.name==t.name&&i.message==t.message;case Hj:case Wj:return i==t+"";case Uj:var a=TC;case jj:var l=r&Bj;if(a||(a=CC),i.size!=t.size&&!l)return!1;var u=o.get(i);if(u)return u==t;r|=Fj,o.set(i,t);var c=ay(a(i),a(t),r,n,s,o);return o.delete(i),c;case qj:if(bw)return bw.call(i)==bw.call(t)}return!1}var DC=Qj;var Kj=1,Zj=Object.prototype,Jj=Zj.hasOwnProperty;function $j(i,t,e,r,n,s){var o=e&Kj,a=tp(i),l=a.length,u=tp(t),c=u.length;if(l!=c&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:Jj.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var m=!0;s.set(i,t),s.set(t,i);for(var g=o;++h<l;){d=a[h];var y=i[d],v=t[d];if(r)var x=o?r(v,y,d,t,i,s):r(y,v,d,i,t,s);if(!(x===void 0?y===v||n(y,v,e,r,s):x)){m=!1;break}g||(g=d=="constructor")}if(m&&!g){var w=i.constructor,S=t.constructor;w!=S&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(m=!1)}return s.delete(i),s.delete(t),m}var IC=$j;var eW=1,OC="[object Arguments]",RC="[object Array]",ly="[object Object]",tW=Object.prototype,LC=tW.hasOwnProperty;function rW(i,t,e,r,n,s){var o=sn(i),a=sn(t),l=o?RC:Qo(i),u=a?RC:Qo(t);l=l==OC?ly:l,u=u==OC?ly:u;var c=l==ly,h=u==ly,d=l==u;if(d&&Jl(i)){if(!Jl(t))return!1;o=!0,c=!1}if(d&&!c)return s||(s=new eh),o||qg(i)?ay(i,t,e,r,n,s):DC(i,t,l,e,r,n,s);if(!(e&eW)){var f=c&&LC.call(i,"__wrapped__"),p=h&&LC.call(t,"__wrapped__");if(f||p){var m=f?i.value():i,g=p?t.value():t;return s||(s=new eh),n(m,g,e,r,s)}}return d?(s||(s=new eh),IC(i,t,e,r,n,s)):!1}var NC=rW;function BC(i,t,e,r,n){return i===t?!0:i==null||t==null||!Bn(i)&&!Bn(t)?i!==i&&t!==t:NC(i,t,e,r,BC,n)}var FC=BC;function nW(i,t){return i!=null&&t in Object(i)}var kC=nW;function iW(i,t,e){t=qi(t,i);for(var r=-1,n=t.length,s=!1;++r<n;){var o=Ua(t[r]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++r!=n?s:(n=i==null?0:i.length,!!n&&Gu(n)&&Vu(o,n)&&(sn(i)||ju(i)))}var VC=iW;function sW(i,t){return i!=null&&VC(i,t,kC)}var zC=sW;var oW=function(){return Er.Date.now()},cy=oW;var aW="Expected a function",lW=Math.max,cW=Math.min;function uW(i,t,e){var r,n,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(aW);t=mw(t)||0,Kr(e)&&(c=!!e.leading,h="maxWait"in e,s=h?lW(mw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(A){var E=r,b=n;return r=n=void 0,u=A,o=i.apply(b,E),o}function p(A){return u=A,a=setTimeout(y,t),c?f(A):o}function m(A){var E=A-l,b=A-u,M=t-E;return h?cW(M,s-b):M}function g(A){var E=A-l,b=A-u;return l===void 0||E>=t||E<0||h&&b>=s}function y(){var A=cy();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,r=l=n=a=void 0}function w(){return a===void 0?o:v(cy())}function S(){var A=cy(),E=g(A);if(r=arguments,n=this,l=A,E){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 S.cancel=x,S.flush=w,S}var tc=uW;function hW(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var UC=hW;function dW(i,t){return t.length<2?i:Qg(i,BT(t,0,-1))}var GC=dW;function fW(i,t){return FC(i,t)}var rp=fW;function pW(i,t){return t=qi(t,i),i=GC(i,t),i==null||delete i[Ua(UC(t))]}var HC=pW;function mW(i){return NT(i)?void 0:i}var jC=mW;var gW=1,yW=2,vW=4,xW=Kg(function(i,t){var e={};if(i==null)return e;var r=!1;t=zg(t,function(s){return s=qi(s,i),r||(r=s.length>1),s}),Ws(i,ey(i),e),r&&(e=sy(e,gW|yW|vW,jC));for(var n=t.length;n--;)HC(e,t[n]);return e}),ih=xW;function bW(i,t,e,r){if(!Kr(i))return i;t=qi(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++n<s;){var l=Ua(t[n]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(n!=o){var c=a[l];u=r?r(c,l,a):void 0,u===void 0&&(u=Kr(c)?c:Vu(t[n+1])?[]:{})}Uu(a,l,u),a=a[l]}return i}var WC=bW;function wW(i,t,e){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=Qg(i,o);e(a,o)&&WC(s,qi(o,i),a)}return s}var qC=wW;function SW(i,t){return qC(i,t,function(e,r){return zC(i,r)})}var YC=SW;var AW=Kg(function(i,t){return i==null?{}:YC(i,t)}),Ni=AW;var _W="Expected a function";function EW(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(_W);return Kr(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),tc(i,t,{leading:r,maxWait:t,trailing:n})}var ww=EW;function XC(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function ui(i,t){return Object.setPrototypeOf(i,t),i}var MW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),TW=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),CW=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||rc&&"ontouchend"in document,PW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,DW=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,IW=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},OW=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},RW=()=>{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"},LW=MW(),Qse=LW?RW():void 0,rc=TW(),uy=CW(),QC=PW(),on=DW(),Sw=IW(),Aw=Number(OW());function hy(i){return Array.isArray(i)?i:[i]}function KC(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function np(i){return rc?i.metaKey:i.ctrlKey}var qe=[],fy={},ip={},dy={};function ZC(i){qe.includes(i)||qe.push(i)}function sh(i){delete fy[i.pointerId];for(let t=0;t<qe.length;t++)if(qe[t].pointerId===i.pointerId){qe.splice(t,1);break}}function JC(){qe.splice(0,qe.length)}function py(i){if(i.pointerType!=="touch")return;let t=fy[i.pointerId];t===void 0&&(t={x:0,y:0},fy[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function my(i){let t=i.pointerId===qe[0].pointerId?qe[1]:qe[0];return fy[t.pointerId]}function $C(i){ip[i.key]=!0,dy[i.key]=dy[i.key]===void 0?1:dy[i.key]+1}function eP(i){if(rc&&ip.Meta)for(let t in ip)ip[t]=!1;else ip[i.key]=!1;dy={}}function tP(i){i.addEventListener("pointerdown",ZC,!0),i.addEventListener("pointerdown",py,!0),i.addEventListener("pointermove",py,!0),i.addEventListener("pointerup",sh,!0),i.addEventListener("pointercancel",sh,!0),i.addEventListener("pointerleave",sh,!0),window.addEventListener("keydown",$C,!0),window.addEventListener("keyup",eP,!0)}function rP(i){i.removeEventListener("pointerdown",ZC,!0),i.removeEventListener("pointerdown",py,!0),i.removeEventListener("pointermove",py,!0),i.removeEventListener("pointerup",sh,!0),i.removeEventListener("pointercancel",sh,!0),i.removeEventListener("pointerleave",sh,!0),window.removeEventListener("keydown",$C,!0),window.removeEventListener("keyup",eP,!0)}var nP,iP=new Promise(i=>{nP=i});var gy;function sP(){if(gy)return gy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.499/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});nP(l)}return gy=i(),gy}var oP,aP=new Promise(i=>{oP=i});var yy;function lP(){if(yy)return yy;async function i(){let e=await import("./physics.js");await e.init(),oP(e)}return yy=i(),yy}var rt=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,rt.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],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,rt.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,rt.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function sp(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&sp(r)}return Object.freeze(i)}function cP(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var oh=class extends Error{};function vy(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function qs(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*n;r.push(o)}return r}function ah(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function uP(){return typeof process<"u"}function hP(i,t){for(let e of i)t(e.id,e.data)!==!0&&hP(e.children,t)}function dP(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)dP(e,t)}var pr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,pr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)sp(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let n of e.children)this.fillCaches0(n,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&dP(n,r)}}traverse(e){hP(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(c=>c.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 n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,pr.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 n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,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,u=this.childrenArray(l),c={fi:n,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(u=>u.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,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 oh("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:n},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),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 n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s<n.length)return n[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>cP(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return qs(0,n,n);{let o=s[0].fi;return qs(o-n,o,n)}}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 qs(l,l+n,n)}else return qs(o.fi,a.fi,n)}}};var lh;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let u=n[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(lh||(lh={}));var Le=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Le.prototype)}deepFreeze(){let e=0;for(;e<this.length;)sp(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.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,Le.prototype);let r=e;return uP()||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:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return qs(0,r,r);{let s=n[0].fi;return qs(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return qs(a,a+r,r)}else return qs(s.fi,o.fi,r)}}};function ch(i){return i&&typeof i=="object"&&i instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!ch(r))return null;n+=1}r=r?vy(r):new Jt;for(let[l,u]of Object.entries(t.props)){let c=r[l];s[l]=c,u===void 0?delete r[l]:r[l]=u}for(;n>0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=vy(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let u=vy(l);u[t.path[n-1]]=r,r=u}else{let u=new Jt;u[t.path[n-1]]=r,r=u}}n-=1}let o=Object.setPrototypeOf(r,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Ys;(r=>{function i(n,s){return op(n,s)??n}r.apply=i;function t(n,s){return Ew(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o<a.length&&l!==void 0;){if(l=Rr.zoomOnce(l,a[o]),l===void 0)return s;if(!ch(l))return;o+=1}if(l===void 0)return s;if(!!ch(l))if(s.type===0){let u={...s.props};for(let c of Object.keys(l))delete u[c];return{...s,props:u}}else if(s.type===1||s.type===4||s.type===7){let u=_w([s],l);return u?(console.log(u),u):s}else return s}r.filterOp=e})(Ys||(Ys={}));function _w(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=op(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=_w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function NW(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=op(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function op(i,t){if(!ch(t))return t;if(i instanceof pr){let e=_w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Le)return NW(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=op(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Jt)return Ew(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=op(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Ew(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!ch(t))return t;if(!ch(i))return Ys.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new Jt;for(let n of e){let s=Ew(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function fP(i,t){let e={cur:[],result:[],len:0};return i=ap(i,t,e)??i,[i,e.result]}function xy(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function by(i){i&&(i.len-=1)}function BW(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function pP(i,t,e){let r=!1,n=i.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=ap(s.data,t,xy(e,o));by(e),r=r||l!==void 0,l===void 0&&(l=s.data);let u=pP(s.children,t,e);return u!==void 0?r=!0:u=s.children,{...s,id:o,data:l,children:u}});if(r)return n}function FW(i,t,e){let r=!1,n=i.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=ap(s.data,t,xy(e,o));return by(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function ap(i,t,e){if(i instanceof pr){let r=pP(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Le)return FW(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=ap(s,t,xy(e,o));return by(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!ah(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=ap(o,t,xy(e,s));by(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&BW(e),r}else return}}var wy;(t=>{function i(e,r){let n=Rr.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(wy||(wy={}));var Lr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Jt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof pr||l instanceof Le||l instanceof rt?d=l.runOp(u):d=lh.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof pr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Le){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof rt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Jt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Jt.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:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof pr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Le){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,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=r;function n(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=n;function s(l,u){return r(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&n(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(Lr||(Lr={}));var lp;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function n(u,c){return[...u.filter(d=>!c.some(f=>Lr.subsumed(d,f))),...c]}l.compress=n;function s(u,c){return u.every(h=>c.every(d=>Lr.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Rr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Rr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=fP(h,{[p.id]:m});h=v;for(let w=0;w<x.length;w++){let S=x[w],A=S.pop();if(typeof A=="number"){let E=[A];for(let M=w+1;M<x.length;M++){let T=x[M],C=T[T.length-1];if(typeof C=="number"&&Rr.equal(S,T.slice(0,T.length-1)))E.push(C),x.splice(M,1);else break}let b=Rr.zoom(h,S);g=b.map((M,T)=>E.includes(T)?p.id:M),m=b,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,b=Rr.zoom(h,S.slice(0,S.length-2)),M=b.layers.map(T=>T.id===S[S.length-1]?{...T,data:{...T.data,[A]:E}}:T);Object.setPrototypeOf(M,Object.getPrototypeOf(b.layers)),b.layers=M}g=p.id}d.push({type:0,path:S,props:{[A]:m}}),f.push({type:0,path:S,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof oh)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(lp||(lp={}));var mP=Symbol(),kW=Symbol(),Ay=Symbol(),nc=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Sy);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ay];r&&r(),delete this._children[t]}}}},Tw=class extends nc{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,lh.runOp(this._current,t),t.path)}},Cw=class extends nc{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,rt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},gP={get(i,t){if(t===Ay)return()=>{i._parent=null};if(t===mP)return i._current;if(t===kW)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=_y(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},VW={...gP,set(i,t,e){let r={type:0,props:{[t]:xr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},zW={...gP,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},uh=class extends nc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{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,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},hh=class extends nc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),n,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Mw(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Rr.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Sy=class extends nc{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,n){Mw(this.ts,e,t),Mw(this.actual,r,t),Mw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _y(i,t,e){return e instanceof pr?new uh(i,t,e):e instanceof Le?new hh(i,t,e):e instanceof rt?new Proxy(new Cw(i,t,e),zW):e!==null&&typeof e=="object"?ah(e)?e:new Proxy(new Tw(i,t,e),VW):e}function Pw(i){let t=new Sy(i);return[_y(t,"",i),t]}function Ga(i,t){let[e,r]=Pw(i);return t(e),r.result()}function xr(i){return i instanceof uh||i instanceof hh?i._current:i!==null&&typeof i=="object"?i[mP]:i}var Rr;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}n.equal=i;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof pr||s instanceof uh)&&typeof o=="string")return s.data(o);if((s instanceof Le||s instanceof hh)&&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]}n.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}n.zoom=r})(Rr||(Rr={}));function yP(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function qn(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Ey=class{},cp=class extends Ey{constructor(e){super();this.id=e}},up=class extends Ey{constructor(e){super();this.data=e}};var Iw;try{Iw=new TextDecoder}catch{}var Be,ja,$=0;var EP=[],Ow=EP,Rw=0,hi={},Nt,Ha,Yi=0,Xs=0,Bi,Zo,ti=[],Ht,vP={useRecords:!1,mapsAsObjects:!0},hp=class{},Nw=new hp;Nw.name="MessagePack 0xC1";var dh=!1,Qs=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(Be)return DP(()=>(Ty(),this?this.unpack(t,e):Qs.prototype.unpack.call(vP,t,e)));ja=e>-1?e:t.length,$=0,Rw=0,Xs=0,Ha=null,Ow=EP,Bi=null,Be=t;try{Ht=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Be=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 Qs){if(hi=this,this.structures)return Nt=this.structures,My();(!Nt||Nt.length>0)&&(Nt=[])}else hi=vP,(!Nt||Nt.length>0)&&(Nt=[]);return My()}unpackMultiple(t,e){let r,n=0;try{dh=!0;let s=t.length,o=this?this.unpack(t,s):Dy.unpack(t,s);if(e){for(e(o);$<s;)if(n=$,e(My())===!1)return}else{for(r=[o];$<s;)n=$,r.push(My());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{dh=!1,Ty()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function My(){try{if(!hi.trusted&&!dh){let t=Nt.sharedLength||0;t<Nt.length&&(Nt.length=t)}let i=Mr();if($==ja)Nt.restoreStructures&&xP(),Nt=null,Be=null,Zo&&(Zo=null);else if($>ja){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 i}catch(i){throw Nt.restoreStructures&&xP(),Ty(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function xP(){for(let i in Nt.restoreStructures)Nt[i]=Nt.restoreStructures[i];Nt.restoreStructures=null}function Mr(){let i=Be[$++];if(i<160)if(i<128){if(i<64)return i;{let t=Nt[i&63]||hi.getStructures&&MP()[i&63];return t?(t.read||(t.read=Bw(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[CP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}else if(i<192){let t=i-160;if(Xs>=$)return Ha.slice($-Yi,($+=t)-Yi);if(Xs==0&&ja<140){let e=t<16?Fw(t):TP(t);if(e!=null)return e}return Lw(t)}else{let t;switch(i){case 192:return null;case 193:return Bi?(t=Mr(),t>0?Bi[1].slice(Bi.position1,Bi.position1+=t):Bi[0].slice(Bi.position0,Bi.position0-=t)):Nw;case 194:return!1;case 195:return!0;case 196:return Dw(Be[$++]);case 197:return t=Ht.getUint16($),$+=2,Dw(t);case 198:return t=Ht.getUint32($),$+=4,Dw(t);case 199:return ic(Be[$++]);case 200:return t=Ht.getUint16($),$+=2,ic(t);case 201:return t=Ht.getUint32($),$+=4,ic(t);case 202:if(t=Ht.getFloat32($),hi.useFloat32>2){let e=Py[(Be[$]&127)<<1|Be[$+1]>>7];return $+=4,(e*t+(t>0?.5:-.5)>>0)/e}return $+=4,t;case 203:return t=Ht.getFloat64($),$+=8,t;case 204:return Be[$++];case 205:return t=Ht.getUint16($),$+=2,t;case 206:return t=Ht.getUint32($),$+=4,t;case 207:return hi.int64AsNumber?(t=Ht.getUint32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigUint64($),$+=8,t;case 208:return Ht.getInt8($++);case 209:return t=Ht.getInt16($),$+=2,t;case 210:return t=Ht.getInt32($),$+=4,t;case 211:return hi.int64AsNumber?(t=Ht.getInt32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigInt64($),$+=8,t;case 212:if(t=Be[$++],t==114)return _P(Be[$++]&63);{let e=ti[t];if(e)return e.read?($++,e.read(Mr())):e.noBuffer?($++,e()):e(Be.subarray($,++$));throw new Error("Unknown extension "+t)}case 213:return t=Be[$],t==114?($++,_P(Be[$++]&63,Be[$++])):ic(2);case 214:return ic(4);case 215:return ic(8);case 216:return ic(16);case 217:return t=Be[$++],Xs>=$?Ha.slice($-Yi,($+=t)-Yi):GW(t);case 218:return t=Ht.getUint16($),$+=2,Xs>=$?Ha.slice($-Yi,($+=t)-Yi):HW(t);case 219:return t=Ht.getUint32($),$+=4,Xs>=$?Ha.slice($-Yi,($+=t)-Yi):jW(t);case 220:return t=Ht.getUint16($),$+=2,wP(t);case 221:return t=Ht.getUint32($),$+=4,wP(t);case 222:return t=Ht.getUint16($),$+=2,SP(t);case 223:return t=Ht.getUint32($),$+=4,SP(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var UW=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Bw(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>UW.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Mr);return i.highByte===0&&(i.read=bP(t,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let o=i[n];r[o]=Mr()}return r}return e.count=0,i.highByte===0?bP(t,e):e}var bP=(i,t)=>function(){let e=Be[$++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Nt[r]||MP()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=Bw(n,i)),n.read()};function MP(){let i=DP(()=>(Be=null,hi.getStructures()));return Nt=hi._mergeStructures(i,Nt)}var Lw=Cy,GW=Cy,HW=Cy,jW=Cy;function Cy(i){let t;if(i<16&&(t=Fw(i)))return t;if(i>64&&Iw)return Iw.decode(Be.subarray($,$+=i));let e=$+i,r=[];for(t="";$<e;){let n=Be[$++];if((n&128)===0)r.push(n);else if((n&224)===192){let s=Be[$++]&63;r.push((n&31)<<6|s)}else if((n&240)===224){let s=Be[$++]&63,o=Be[$++]&63;r.push((n&31)<<12|s<<6|o)}else if((n&248)===240){let s=Be[$++]&63,o=Be[$++]&63,a=Be[$++]&63,l=(n&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=Sn.apply(String,r),r.length=0)}return r.length>0&&(t+=Sn.apply(String,r)),t}function wP(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mr();return t}function SP(i){if(hi.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[CP()]=Mr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mr(),Mr());return t}}var Sn=String.fromCharCode;function TP(i){let t=$,e=new Array(i);for(let r=0;r<i;r++){let n=Be[$++];if((n&128)>0){$=t;return}e[r]=n}return Sn.apply(String,e)}function Fw(i){if(i<4)if(i<2){if(i===0)return"";{let t=Be[$++];if((t&128)>1){$-=1;return}return Sn(t)}}else{let t=Be[$++],e=Be[$++];if((t&128)>0||(e&128)>0){$-=2;return}if(i<3)return Sn(t,e);let r=Be[$++];if((r&128)>0){$-=3;return}return Sn(t,e,r)}else{let t=Be[$++],e=Be[$++],r=Be[$++],n=Be[$++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){$-=4;return}if(i<6){if(i===4)return Sn(t,e,r,n);{let s=Be[$++];if((s&128)>0){$-=5;return}return Sn(t,e,r,n,s)}}else if(i<8){let s=Be[$++],o=Be[$++];if((s&128)>0||(o&128)>0){$-=6;return}if(i<7)return Sn(t,e,r,n,s,o);let a=Be[$++];if((a&128)>0){$-=7;return}return Sn(t,e,r,n,s,o,a)}else{let s=Be[$++],o=Be[$++],a=Be[$++],l=Be[$++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){$-=8;return}if(i<10){if(i===8)return Sn(t,e,r,n,s,o,a,l);{let u=Be[$++];if((u&128)>0){$-=9;return}return Sn(t,e,r,n,s,o,a,l,u)}}else if(i<12){let u=Be[$++],c=Be[$++];if((u&128)>0||(c&128)>0){$-=10;return}if(i<11)return Sn(t,e,r,n,s,o,a,l,u,c);let h=Be[$++];if((h&128)>0){$-=11;return}return Sn(t,e,r,n,s,o,a,l,u,c,h)}else{let u=Be[$++],c=Be[$++],h=Be[$++],d=Be[$++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){$-=12;return}if(i<14){if(i===12)return Sn(t,e,r,n,s,o,a,l,u,c,h,d);{let f=Be[$++];if((f&128)>0){$-=13;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f)}}else{let f=Be[$++],p=Be[$++];if((f&128)>0||(p&128)>0){$-=14;return}if(i<15)return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p);let m=Be[$++];if((m&128)>0){$-=15;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Dw(i){return hi.copyBuffers?Uint8Array.prototype.slice.call(Be,$,$+=i):Be.subarray($,$+=i)}function ic(i){let t=Be[$++];if(ti[t])return ti[t](Be.subarray($,$+=i));throw new Error("Unknown extension type "+t)}var AP=new Array(4096);function CP(){let i=Be[$++];if(i>=160&&i<192){if(i=i-160,Xs>=$)return Ha.slice($-Yi,($+=i)-Yi);if(!(Xs==0&&ja<180))return Lw(i)}else return $--,Mr();let t=(i<<5^(i>1?Ht.getUint16($):i>0?Be[$]:0))&4095,e=AP[t],r=$,n=$+i-3,s,o=0;if(e&&e.bytes==i){for(;r<n;){if(s=Ht.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=Be[r++],s!=e[o++]){r=1879048192;break}if(r===n)return $=r,e.string;n-=3,r=$}for(e=[],AP[t]=e,e.bytes=i;r<n;)s=Ht.getUint32(r),e.push(s),r+=4;for(n+=3;r<n;)s=Be[r++],e.push(s);let a=i<16?Fw(i):TP(i);return a!=null?e.string=a:e.string=Lw(i)}var _P=(i,t)=>{var e=Mr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Nt[i];return n&&n.isShared&&((Nt.restoreStructures||(Nt.restoreStructures=[]))[i]=n),Nt[i]=e,e.read=Bw(e,r),e.read()},PP=typeof self=="object"?self:global;ti[0]=()=>{};ti[0].noBuffer=!0;ti[101]=()=>{let i=Mr();return(PP[i[0]]||Error)(i[1])};ti[105]=i=>{let t=Ht.getUint32($-4);Zo||(Zo=new Map);let e=Be[$],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};Zo.set(t,n);let s=Mr();return n.used?Object.assign(r,s):(n.target=s,s)};ti[112]=i=>{let t=Ht.getUint32($-4),e=Zo.get(t);return e.used=!0,e.target};ti[115]=()=>new Set(Mr());var kw=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");ti[116]=i=>{let t=i[0],e=kw[t];if(!e)throw new Error("Could not find typed array for code "+t);return new PP[e](Uint8Array.prototype.slice.call(i,1).buffer)};ti[120]=()=>{let i=Mr();return new RegExp(i[0],i[1])};ti[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=$;$+=t-4,Bi=[Mr(),Mr()],Bi.position0=0,Bi.position1=0;let r=$;$=e;try{return Mr()}finally{$=r}};ti[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function DP(i){let t=ja,e=$,r=Rw,n=Yi,s=Xs,o=Ha,a=Ow,l=Zo,u=Bi,c=new Uint8Array(Be.slice(0,ja)),h=Nt,d=Nt.slice(0,Nt.length),f=hi,p=dh,m=i();return ja=t,$=e,Rw=r,Yi=n,Xs=s,Ha=o,Ow=a,Zo=l,Bi=u,Be=c,dh=p,Nt=h,Nt.splice(0,Nt.length,...d),hi=f,Ht=new DataView(Be.buffer,Be.byteOffset,Be.byteLength),m}function Ty(){Be=null,Zo=null,Nt=null}function IP(i){i.unpack?ti[i.type]=i.unpack:ti[i.type]=i}var Py=new Array(147);for(let i=0;i<256;i++)Py[i]=+("1e"+Math.floor(45.15-i*.30103));var Dy=new Qs({useRecords:!1}),WW=Dy.unpack,qW=Dy.unpackMultiple,YW=Dy.unpack,Iy={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},XW=new Float32Array(1),oae=new Uint8Array(XW.buffer,0,4);var Oy;try{Oy=new TextEncoder}catch{}var Ry,zw,Ly=typeof Buffer<"u",Vw=Ly?Buffer.allocUnsafeSlow:Uint8Array,NP=Ly?Buffer:Uint8Array,OP=Ly?4294967296:2144337920,de,Nr,ne=0,Ks,Zs=null,QW=/[\u0080-\uFFFF]/,dp=Symbol("record-id"),sc=class extends Qs{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,u=NP.prototype.utf8Write?function(b,M,T){return de.utf8Write(b,M,T)}:Oy&&Oy.encodeInto?function(b,M){return Oy.encodeInto(b,de.subarray(M)).written}:!1,c=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,w=0;this.pack=this.encode=function(b,M){if(de||(de=new Vw(8192),Nr=new DataView(de.buffer,0,8192),ne=0),Ks=de.length-10,Ks-ne<2048?(de=new Vw(de.length),Nr=new DataView(de.buffer,0,de.length),Ks=de.length-10,ne=0):ne=ne+7&2147483640,r=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Zs=["",""],de[ne++]=214,de[ne++]=98,Zs.position=ne-r,ne+=4):Zs=null,n=c.structures,n){n.uninitialized&&(n=c._mergeStructures(c.getStructures()));let T=n.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;C<T;C++){let P=n[C];if(!P)continue;let D,I=n.transitions;for(let R=0,V=P.length;R<V;R++){let k=P[R];D=I[k],D||(D=I[k]=Object.create(null)),I=D}I[dp]=C+64}l=T}h||(n.nextId=T+64)}s&&(s=!1),o=n||[];try{if(S(b),Zs){Nr.setUint32(Zs.position+r,ne-Zs.position-r);let T=Zs;Zs=null,S(T[0]),S(T[1])}if(c.offset=ne,a&&a.idsToInsert){ne+=a.idsToInsert.length*6,ne>Ks&&E(ne),c.offset=ne;let T=ZW(de.subarray(r,ne),a.idsToInsert);return a=null,T}return M&FP?(de.start=r,de.end=ne,de):de.subarray(r,ne)}finally{if(n){if(w<10&&w++,x>1e4)n.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let T=0,C=v.length;T<C;T++)v[T][dp]=0;v=[]}if(s&&c.saveStructures){let T=n.sharedLength||f;n.length>T&&(n=n.slice(0,T));let C=de.subarray(r,ne);return c.saveStructures(n,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,C)}}M&i6&&(ne=r)}};let S=b=>{ne>Ks&&(de=E(ne));var M=typeof b,T;if(M==="string"){let C=b.length;if(Zs&&C>=8&&C<4096){let I=QW.test(b);Zs[I?0:1]+=b,de[ne++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let D=C*3;if(ne+D>Ks&&(de=E(ne+D)),C<64||!u){let I,R,V,k=ne+P;for(I=0;I<C;I++)R=b.charCodeAt(I),R<128?de[k++]=R:R<2048?(de[k++]=R>>6|192,de[k++]=R&63|128):(R&64512)===55296&&((V=b.charCodeAt(I+1))&64512)===56320?(R=65536+((R&1023)<<10)+(V&1023),I++,de[k++]=R>>18|240,de[k++]=R>>12&63|128,de[k++]=R>>6&63|128,de[k++]=R&63|128):(de[k++]=R>>12|224,de[k++]=R>>6&63|128,de[k++]=R&63|128);T=k-ne-P}else T=u(b,ne+P,D);T<32?de[ne++]=160|T:T<256?(P<2&&de.copyWithin(ne+2,ne+1,ne+1+T),de[ne++]=217,de[ne++]=T):T<65536?(P<3&&de.copyWithin(ne+3,ne+2,ne+2+T),de[ne++]=218,de[ne++]=T>>8,de[ne++]=T&255):(P<5&&de.copyWithin(ne+5,ne+3,ne+3+T),de[ne++]=219,Nr.setUint32(ne,T),ne+=4),ne+=T}else if(M==="number")if(b>>>0===b)b<64?de[ne++]=b:b<256?(de[ne++]=204,de[ne++]=b):b<65536?(de[ne++]=205,de[ne++]=b>>8,de[ne++]=b&255):(de[ne++]=206,Nr.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?de[ne++]=256+b:b>=-128?(de[ne++]=208,de[ne++]=b+256):b>=-32768?(de[ne++]=209,Nr.setInt16(ne,b),ne+=2):(de[ne++]=210,Nr.setInt32(ne,b),ne+=4);else{let C;if((C=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){de[ne++]=202,Nr.setFloat32(ne,b);let P;if(C<4||(P=b*Py[(de[ne]&127)<<1|de[ne+1]>>7])>>0===P){ne+=4;return}else ne--}de[ne++]=203,Nr.setFloat64(ne,b),ne+=8}else if(M==="object")if(!b)de[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let D=a.idsToInsert||(a.idsToInsert=[]);P.id=D.push(P)}de[ne++]=214,de[ne++]=112,Nr.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-r})}let C=b.constructor;if(C===Object)A(b,!0);else if(C===Array){T=b.length,T<16?de[ne++]=144|T:T<65536?(de[ne++]=220,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=221,Nr.setUint32(ne,T),ne+=4);for(let P=0;P<T;P++)S(b[P])}else if(C===Map){T=b.size,T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);for(let[P,D]of b)S(P),S(D)}else{for(let P=0,D=Ry.length;P<D;P++){let I=zw[P];if(b instanceof I){let R=Ry[P];if(R.write){R.type&&(de[ne++]=212,de[ne++]=R.type,de[ne++]=0),S(R.write.call(this,b));return}let V=de,k=Nr,z=ne;de=null;let G;try{G=R.pack.call(this,b,H=>(de=V,V=null,ne+=H,ne>Ks&&E(ne),{target:de,targetView:Nr,position:ne-H}),S)}finally{V&&(de=V,Nr=k,ne=z,Ks=de.length-10)}G&&(G.length+ne>Ks&&E(G.length+ne),ne=KW(G,de,ne,R.type));return}}A(b,!b.hasOwnProperty)}}else if(M==="boolean")de[ne++]=b?195:194;else if(M==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))de[ne++]=211,Nr.setBigInt64(ne,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)de[ne++]=207,Nr.setBigUint64(ne,b);else if(this.largeBigIntToFloat)de[ne++]=203,Nr.setFloat64(ne,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");ne+=8}else if(M==="undefined")this.encodeUndefinedAsNil?de[ne++]=192:(de[ne++]=212,de[ne++]=0,de[ne++]=0);else if(M==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?b=>{let M=Object.keys(b),T=M.length;T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);let C;for(let P=0;P<T;P++)S(C=M[P]),S(b[C])}:(b,M)=>{de[ne++]=222;let T=ne-r;ne+=2;let C=0;for(let P in b)(M||b.hasOwnProperty(P))&&(S(P),S(b[P]),C++);de[T+++r]=C>>8,de[T+r]=C&255}:b=>{let M=Object.keys(b),T,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,R=M.length;I<R;I++){let V=M[I];T=C[V],T||(T=C[V]=Object.create(null),P++),C=T}let D=C[dp];if(D)D>=96&&m?(de[ne++]=((D-=96)&31)+96,de[ne++]=D>>5):de[ne++]=D;else{D=o.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(D=o.nextOwnId,D<y||(D=g),o.nextOwnId=D+1):(D>=y&&(D=g),o.nextId=D+1);let I=M.highByte=D>=96&&m?D-96>>5:-1;C[dp]=D,o[D-64]=M,D<g?(M.isShared=!0,o.sharedLength=D-63,s=!0,I>=0?(de[ne++]=(D&31)+96,de[ne++]=I):de[ne++]=D):(I>=0?(de[ne++]=213,de[ne++]=114,de[ne++]=(D&31)+96,de[ne++]=I):(de[ne++]=212,de[ne++]=114,de[ne++]=D),P&&(x+=w*P),v.length>=p&&(v.shift()[dp]=0),v.push(C),S(M))}for(let I=0,R=M.length;I<R;I++)S(b[M[I]])},E=b=>{let M;if(b>16777216){if(b-r>OP)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(OP,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(b-r<<2,de.length-1)>>12)+1<<12;let T=new Vw(M);return Nr=new DataView(T.buffer,0,M),de.copy?de.copy(T,0,r,b):T.set(de.slice(r,b)),ne-=r,r=0,Ks=T.length-10,de=T}}useBuffer(t){de=t,Nr=new DataView(de.buffer,de.byteOffset,de.byteLength),ne=0}};zw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,hp];Ry=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.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:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?RP(i,16,t):LP(Ly?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==NP&&this.structuredClone?RP(i,kw.indexOf(e.name),t):LP(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function RP(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function LP(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function KW(i,t,e,r){let n=i.length;switch(n){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:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function ZW(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function Wa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");zw.unshift(i.Class),Ry.unshift(i)}IP(i)}var BP=new sc({useRecords:!1}),JW=BP.pack,$W=BP.pack;var{NEVER:e6,ALWAYS:t6,DECIMAL_ROUND:r6,DECIMAL_FIT:n6}=Iy,FP=512,i6=1024;var kP=new sc({structuredClone:!0});Wa({Class:rt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,rt.prototype),i}});Wa({Class:Le.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Le.prototype),i}});Wa({Class:pr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,pr.prototype),i}});Wa({Class:cp.prototype.constructor,type:4,write(i){return i.id},read(i){return new cp(i)}});Wa({Class:up.prototype.constructor,type:5,write(i){return i.data},read(i){return new up(i)}});Wa({Class:Jt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Jt.prototype),i}});function s6(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Uw(i){if(ah(i))return i;if(Array.isArray(i))return i.map(Uw);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Uw(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var Ny;(r=>{function i(n){return kP.pack(n)}r.serialize=i;function t(n){return kP.unpack(n)}r.deserialize=t;function e(n){return s6(i(Uw(n))).toString()}r.checksum=e})(Ny||(Ny={}));var VP;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(VP||(VP={}));var di={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},zP;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Le}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Le}}e.defaultData=t})(zP||(zP={}));var By;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(By||(By={}));var Gw;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:By.propertyDefaultData(n),rOperand:{...By.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(Gw||(Gw={}));var UP;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new Le,outActions:new Le,condition:Gw.distanceDefaultData(r)}}e.defaultData=t})(UP||(UP={}));var GP;(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 Le,drop:new Le}})(GP||(GP={}));var Fy;(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 Le})(Fy||(Fy={}));var ky;(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})(ky||(ky={}));var HP;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Le}}e.defaultData=t})(HP||(HP={}));var jP;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Le}}e.defaultData=t})(jP||(jP={}));var WP;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Le}}e.defaultData=t})(WP||(WP={}));var qP;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Le}}e.defaultData=t})(qP||(qP={}));var YP;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Le,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(YP||(YP={}));var Vy;(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 n(){let a={size:"mobile",operator:"<",actions:new Le},l={size:"tablet",operator:"<",actions:new Le},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Le},c=new Le;return c.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Le}}o.defaultBreakpointData=s})(Vy||(Vy={}));var zy;(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(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Le,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(zy||(zy={}));var Xi="personal camera",Ya="a218fcc3-276b-49b9-b485-49037fd14f5f",KP=2960946,an=5526619;var oc;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}e.lerp=t})(oc||(oc={}));var Js;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=r;function n(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=n;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})(Js||(Js={}));var fp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(fp||(fp={}));var qa;(n=>{n.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}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}n.applyMatrix4=r})(qa||(qa={}));var An;(c=>{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function n(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=n;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(An||(An={}));var ri;(a=>{a.white={...An.white,a:1},a.transparent={...An.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function r(l,u){return{...An.fromHex(l),a:u}}a.fromHexAndA=r;function n(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=n;function s(l,u){return An.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(ri||(ri={}));var Uy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Uy||(Uy={}));var XP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(XP||(XP={}));var QP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(QP||(QP={}));var Jo;(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]))(Jo||(Jo={}));function ZP(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var xs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(xs||(xs={}));var Xa;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(Xa||(Xa={}));var $s;(e=>{function i(r,n=.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]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),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=i;function t(r,n){let s={...r};if(Hw.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;jw.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;Ww.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;qw.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;Yw.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;Xw.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})($s||($s={}));var Gy;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Gy||(Gy={}));var Hw=["count"],jw=["radius","start","end","position","scale","rotation"],Ww=["position","scale","rotation"],qw=["count","size"],Yw=["count","position","scale","rotation"],Xw=["strength","scale","rotation","position","movement","seed","freqScale"];var Hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Hy||(Hy={}));var jy;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:ri.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:ri.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:ri.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jy||(jy={}));var Qa;(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]})(Qa||(Qa={}));var Qw;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(Qw||(Qw={}));var Kw;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(Kw||(Kw={}));var Wy;(t=>t.defaultData={...Kw.defaultData,...Qw.defaultData})(Wy||(Wy={}));var JP;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.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&&n.push(o)}return n}t.getMaterialData=i})(JP||(JP={}));var fh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(fh||(fh={}));var $P;(t=>{function i(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==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})($P||($P={}));function t2(i){return i.type!=="displace"}var e2;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(e2||(e2={}));var qy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],r2=["wrapping","image","video","name"],_n;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.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]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:fh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:An.fromHex(an)};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:{...An.fromHex(6710886),a:1},colorB:{...An.fromHex(6710886),a:1},colorC:{...An.fromHex(16777215),a:1},colorD:{...An.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:ri.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:ri.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:ri.fromHexAndA(0,1),contourColor:ri.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]}};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:{...An.fromHex(0),a:1},colorB:{...An.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}}}})(_n||(_n={}));var Br;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Le}}l.defaultEmptyData=e;function r(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=r;function n(u,c){return{...u,name:c}}l.withName=n;function s(u,c="layer1",h="layer2"){let d=new Le;return d.push({fi:0,data:_n.defaultData("light",u),id:c}),d.push({fi:1,data:_n.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("video");Object.assign(f.texture,{video:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Br||(Br={}));var ph;(t=>{function i(){return{points:new Le,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(ph||(ph={}));var mh;(t=>{function i(){return{points:new Le,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(mh||(mh={}));var Zw={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Yy;(t=>{function i(e,r){let n={...e};return Jw.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Yy||(Yy={}));var Xy={shape:Zw,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},Jw=["depth","offset","angle","twist","startScale","endScale"];var pp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=i;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})(pp||(pp={}));var Qy;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Yy.merge(n.extrusion,r.extrusion))),n}t.merge=i})(Qy||(Qy={}));var Ka;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:mh.defaultData(),extrusion:Xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ph.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=i})(Ka||(Ka={}));var $w=["width","height","depth"];var Ky;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:An.white,near:.1,far:2e3})(Ky||(Ky={}));var gh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(gh||(gh={}));var eS;(t=>t.defaultData={softShadowQuality:"low"})(eS||(eS={}));var tS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(tS||(tS={}));var rS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(rS||(rS={}));var Za;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Za||(Za={}));var nS;(t=>t.defaultData={playCamera:Xi,gameControlObject:null})(nS||(nS={}));var Zy;(t=>t.defaultData={backgroundColor:ri.fromHexAndA(KP,1),postprocessing:gh.defaultData,fog:Ky.defaultData,globalPhysics:Za.defaultData,ambient:tS.defaultData,ao:rS.defaultData,shadow:eS.defaultData,publish:nS.defaultData})(Zy||(Zy={}));var n2;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(n2||(n2={}));var yh;(n=>{n.identity={...Uy.identity,hiddenMatrix:qa.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.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}}n.merge=e;function r(s,o){return XC({position:Js.isEqual(s.position,o.position)?void 0:o.position,rotation:Js.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:Js.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:qa.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(yh||(yh={}));var Fn;(t=>t.defaultData={states:new Le,events:new Le,visible:!0,raycastLock:!1,physics:Qa.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...yh.identity,cloner:null})(Fn||(Fn={}));var Jy;(t=>t.defaultData={type:"Empty",...Fn.defaultData})(Jy||(Jy={}));var i2;(t=>t.defaultData={type:"Component",...Fn.defaultData})(i2||(i2={}));var ac;(t=>t.defaultData={type:"Mesh",...Fn.defaultData,...Wy.defaultData})(ac||(ac={}));var lc;(t=>t.defaultData={...Fn.defaultData,...yh.identity,position:[0,0,Xa.DefaultTargetOffset],...Xa.defaultData})(lc||(lc={}));var $y;(e=>{function i(r){return{...Fn.defaultData,...jy.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var vh;(e=>{function i(r,n,s=0){for(;s<n.length;){let o=r?r[n[s]]:void 0;if(n.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(r,n,s=0){let o=i(r,n,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(vh||(vh={}));var eo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...Fn.defaultData,...a,component:o,overrides:new Jt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=yh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(eo||(eo={}));var $o;(t=>t.defaultData={type:"Page",...Fn.defaultData,physics:{...Qa.defaultData,fusedBody:!1},...Zy.defaultData,camera:lc.defaultData})($o||($o={}));var ev;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:qa.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Qa.defaultData,states:new Le,events:new Le,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Xa.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",...Fn.defaultData,...ac.defaultData,geometry:Ka.defaultData("RectangleGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Fn.defaultData,...ac.defaultData,geometry:Ka.defaultData("BooleanGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Fn.defaultData,...ac.defaultData,geometry:Ka.defaultData("TextGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var ea;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):xs.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Ga(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&_n.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Ga(a.materials,l=>{for(let u=0;u<a.materials.length;u++){let c=o.materials[u];if(typeof c!="string")for(let[h,d]of Object.entries(c.layers)){let f=l[u]?.layers?.data(h);f&&_n.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],u={orthographic:0,perspective:0,geometry:0};function c(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:m,...g}=p;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Gy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[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}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,yh.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})}),xs.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:Qy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:$s.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:$s.merge(a.cloner,o.cloner)});else if(Hy.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=An.clone(l.color))}return a}n.patch=r})(ea||(ea={}));var bh;(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})(bh||(bh={}));var to;(t=>t.defaultData={orbitControls:bh.defaultData,playPage:Ya,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,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})(to||(to={}));var iS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(iS||(iS={}));var sS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(sS||(sS={}));var Ja;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...iS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:sS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ja||(Ja={}));var $a;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=wh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})($a||($a={}));var el;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=ev.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new pr;return h.push({fi:1,id:Ya,data:{...$o.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:to.defaultData,styles:Ja.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new pr,publish:to.defaultData,styles:Ja.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:to.defaultData,styles:Ja.defaultData()}};function s(l){return{...a.defaultData,objects:ui(l,pr.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(el||(el={}));var Sh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Sh||(Sh={}));var Ah;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Ah||(Ah={}));var En;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(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=n})(En||(En={}));var oS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(oS||(oS={}));var s2;(t=>t.all=[...oS.all,"components"])(s2||(s2={}));var o2;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(o2||(o2={}));var tl;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(tl||(tl={}));var fi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ui(o,rt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Ah.emptyImage,name:"AI generated image"}),ui(a,rt.prototype)}s.defaultImages=t;function e(){return{catelogs:new rt,materials:new rt,images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,variables:new Le,lib:tl.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 n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(fi||(fi={}));var _h;(t=>t.list=["idle","move","jump","run"])(_h||(_h={}));var Eh;(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 Le,move:new Le,jump:new Le,run:new Le},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:ri.fromHexAndA(3728051,1)}}))(Eh||(Eh={}));function a2(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[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++)n.push(n[1]),s.push(1);let o={...Ni(xr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,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={...xr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ta(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function ra(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Br.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&t(n.material)})})}function a6(i){Object.assign(i.scene.publish,{orbitControls:{...bh.defaultData,...xr(i.scene.publish.orbitControls)}})}function l6(i){Object.assign(i.scene.publish.settings,{video:{...to.defaultData.settings.video,...xr(i.scene.publish.settings.video)}})}function c6(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((qy.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(r2.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function u6(i){i.scene.publish.withBackground=!0}function h6(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function d6(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function f6(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function p6(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=xr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=xr(e).booleanExclude!==!0)}})}function m6(i){i.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 g6(i){function t(r){Object.setPrototypeOf(r,Jt.prototype),r.texture&&Object.setPrototypeOf(r.texture,Jt.prototype)}function e(r){Object.setPrototypeOf(r,Jt.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=xr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],u=xr(l).layers;e(u),l.layers=u}})})}function l2(i){i.layers===void 0&&Object.assign(i,Br.defaultTwoLayerData("lambert"))}function aS(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...xr(t),colors:e,steps:r};Object.assign(t,n)}})}function y6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function c2(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&aS(r)}):"material"in e&&typeof e.material!="string"&&aS(e.material)}),Object.values(i.shared.materials).forEach(t=>aS(t))}function v6(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function x6(i){i.shared.audios=ui({},rt.prototype)}function b6(i){i.shared.videos=ui({},rt.prototype)}function w6(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={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]:n})}})}function S6(i){Object.entries(xr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(xr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function A6(i){i.scene.publish.settings.web.preload=!1}function u2(i){i.layers&&i.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 h2(i){i.layers&&i.layers.forEach(t=>{t2(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 _6(i){i.shared.fonts=ui({},rt.prototype)}function E6(i){return i.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 M6(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=Br.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=E6(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,...Fn.defaultData,...ac.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ka.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:xr(n.states),events:xr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},u=xr(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function T6(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new Le,move:new Le,jump:new Le}});else{let s=new Le;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Ni(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{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,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Le({fi:0,id:Se.generateUUID(),data:u},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function C6(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new Le,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Ni(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={...Ni(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function d2(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=_n.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function f2(i){ta(i,d2),ra(i,d2)}function P6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function D6(i){i.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 I6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Br.defaultTwoLayerData("phong"))})}function O6(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.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 R6(i){i.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 L6(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function N6(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function B6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function F6(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function k6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Eh.defaultDataThirdPerson.navmesh)})})}function V6(i){i.scene.styles||(i.scene.styles=Ja.defaultData())}function p2(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function z6(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ra(i,p2),ta(i,p2)}function U6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Le})})})}function G6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function m2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function g2(i,t){if(t<1&&(ra(i,a2),ta(i,a2),i.schema=1),t<2&&(a6(i),i.schema=2),t<3&&(c6(i),i.schema=3),t<4&&(u6(i),i.schema=4),t<5&&(h6(i),i.schema=5),t<6&&(d6(i),i.schema=6),t<7&&(f6(i),i.schema=7),t<8&&(i.schema=8),t<9&&(c2(i),i.schema=9),t<10&&(y6(i),i.schema=10),t<11&&(v6(i),i.schema=11),t<12&&(c2(i),i.schema=12),t<13&&(x6(i),i.schema=13),t<14&&(w6(i),i.schema=14),t<15&&(S6(i),i.schema=15),t<16&&(A6(i),i.schema=16),t<17&&(ra(i,u2),ta(i,u2),i.schema=17),t<18&&(ra(i,l2),ta(i,l2),i.schema=18),t<19&&(l6(i),i.schema=19),t<20&&(_6(i),M6(i),i.schema=20),t<21&&(T6(i),C6(i),i.schema=21),t<22&&(f2(i),i.schema=22),t<23&&(P6(i),i.schema=23),t<24&&(D6(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(b6(i),t<25&&(i.schema=25)),t<26&&(p6(i),i.schema=26),t<27&&(m6(i),i.schema=27),t<28&&(f2(i),i.schema=28),t<29&&(g6(i),i.schema=29),t<30&&(I6(i),i.schema=30),t<31&&(O6(i),i.schema=31),t<33&&(R6(i),i.schema=33),t<34&&(L6(i),i.schema=34),t<35&&(N6(i),i.schema=35),t<36&&(B6(i),i.schema=36),t<37&&(F6(i),i.schema=37),t<38&&(ra(i,h2),ta(i,h2),i.schema=38),t<39&&(k6(i),i.schema=39),t<40&&(V6(i),i.schema=40),t<41&&(z6(i),i.schema=41),t<42&&(U6(i),i.schema=42),t<43&&(G6(i),i.schema=43),t<99){ra(i,m2),ta(i,m2),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Xi);let e=xr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Ya,r.insertBefore(null,null,[{id:Ya,data:{...$o.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Ni(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Ni(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Za.defaultData,...Ni(i.scene.environment,"usePhysics","gravity")},camera:xr(i.scene.ownerCamera)??$o.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==el.TRASH_CAN_ID&&r.move(Ya,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.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,Qa.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function y2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function H6(i){i.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"))})}var Mh=180/Math.PI;function v2(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Mh)}function x2(i){v2(i),i.type==="Page"&&v2(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Mh))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Mh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Mh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Mh,t.extrusion.twist*=Mh),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(xr(i.events))&&i.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":"Once")})}function j6(i){i.shared.variables=ui({},rt.prototype)}function W6(i){let t=xr(i.shared.variables);i.shared.variables=ui(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),Le.prototype)}var na=107;function b2(i,t){t(i.data);for(let e of i.children)b2(e,t)}function q6(i){let t=i.schema??104;t!==na&&t<105&&(b2(i.asset,x2),i.schema=105)}function tv(i){let t=i.schema??0;if(t!==na){console.warn("updating from ",t,"to ",na),g2(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=to.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(ra(i,y2),ta(i,y2),i.schema=101),t<102&&(H6(i),i.schema=102),t<104&&(i.shared.catelogs=new rt,i.shared.lib=tl.defaultData(),i.schema=104),t<105&&(j6(i),i.scene.objects.traverse((e,r)=>{x2(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))q6(e);t<106&&(W6(i),i.schema=106),t<107&&(i.shared.lib.variables=tl.defaultData().variables,i.schema=107)}}var wh;(a=>{a.defaultData={schema:na,scene:el.defaultData,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Sh.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors()}},a.emptyDataForImports=function(l){let u=el.emptyDataWithPage(l);return{schema:na,scene:u,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Sh.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors(),images:fi.defaultImages(l)}}},a.emptyData=function(){return{schema:na,scene:el.emptyDataWithPage(),frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Sh.defaultData),shared:fi.emptyData()}},a.collabHelper={...lp,updateSchema(l){return(l.schema??0)<na?Ga(l,tv):(l.schema??0)-na}};function n(l){let u=a.collabHelper.updateSchema(l);return typeof u=="number"?u===0?l:null:u.data}a.updateSchemaDirectly=n;function s(l){return{...l,shared:{...l.shared,lib:tl.defaultData()}}}a.withoutLib=s;function o(l,u){let c=l.scene.objects.get(u);if(c&&c.data.type==="Component")return c;{let h=l.shared.lib.components[u];if(h)return h.asset}}a.getComponentData=o})(wh||(wh={}));function bs(i,t=!1){let e=i[0].index!==null,r=new Set(Object.keys(i[0].attributes)),n=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ae,u=0;for(let c=0;c<i.length;++c){let h=i[c],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(e){let c=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+c);c+=i[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=w2(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][d]);let p=w2(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(p)}}return l}function w2(i){let t,e,r,n=0;for(let a=0;a<i.length;++a){let l=i[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=l.itemSize),e!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;n+=l.array.length}let s=new t(n),o=0;for(let a=0;a<i.length;++a)s.set(i[a].array,o),o+=i[a].array.length;return new Ge(s,e,r)}var S2=Math.pow(2,-24);var cc=class{constructor(){}};function Qi(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function lS(i){let t=-1,e=-1/0;for(let r=0;r<3;r++){let n=i[r+3]-i[r];n>e&&(e=n,t=r)}return t}function cS(i,t){t.set(i)}function uS(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=r<n?r:n,r=i[o],n=t[o],e[o]=r>n?r:n}}function mp(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function Th(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function Q6(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ge(n,1));for(let s=0;s<e;s++)n[s]=s}}function K6(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let n of i.groups)e.add(n.start),e.add(n.start+n.count);let r=Array.from(e.values()).sort((n,s)=>n-s);for(let n=0;n<r.length-1;n++){let s=r[n],o=r[n+1];t.push({offset:s/3,count:(o-s)/3})}return t}function dS(i,t,e,r,n=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,g=-1/0,y=n!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let w=i[v+0],S=i[v+1],A=w-S,E=w+S;A<s&&(s=A),E>l&&(l=E),y&&w<h&&(h=w),y&&w>p&&(p=w);let b=i[v+2],M=i[v+3],T=b-M,C=b+M;T<o&&(o=T),C>u&&(u=C),y&&b<d&&(d=b),y&&b>m&&(m=b);let P=i[v+4],D=i[v+5],I=P-D,R=P+D;I<a&&(a=I),R>c&&(c=R),y&&P<f&&(f=P),y&&P>g&&(g=P)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=c,y&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=m,n[5]=g)}function Z6(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;c<h;c+=6){let d=i[c+0];d<n&&(n=d),d>a&&(a=d);let f=i[c+2];f<s&&(s=f),f>l&&(l=f);let p=i[c+4];p<o&&(o=p),p>u&&(u=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=u}function J6(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=i[s*3+u];i[s*3+u]=i[o*3+u],i[o*3+u]=c;let h=t[s*6+u*2+0];t[s*6+u*2+0]=t[o*6+u*2+0],t[o*6+u*2+0]=h;let d=t[s*6+u*2+1];t[s*6+u*2+1]=t[o*6+u*2+1],t[o*6+u*2+1]=d}s++,o--}else return s}}var ia=32,$6=(i,t)=>i.candidate-t.candidate,rl=new Array(ia).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),rv=new Float32Array(6);function e8(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=lS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=lS(i),o!==-1&&(a=t8(e,r,n,o));else if(s===2){let l=Th(i),u=1.25*n,c=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/ia;if(n<ia/4){let y=[...rl];y.length=n;let v=0;for(let w=c;w<h;w+=6,v++){let S=y[v];S.candidate=e[w+2*d],S.count=0;let{bounds:A,leftCacheBounds:E,rightCacheBounds:b}=S;for(let M=0;M<3;M++)b[M]=1/0,b[M+3]=-1/0,E[M]=1/0,E[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;mp(w,e,A)}y.sort($6);let x=n;for(let w=0;w<x;w++){let S=y[w];for(;w+1<x&&y[w+1].candidate===S.candidate;)y.splice(w+1,1),x--}for(let w=c;w<h;w+=6){let S=e[w+2*d];for(let A=0;A<x;A++){let E=y[A];S>=E.candidate?mp(w,e,E.rightCacheBounds):(mp(w,e,E.leftCacheBounds),E.count++)}}for(let w=0;w<x;w++){let S=y[w],A=S.count,E=n-S.count,b=S.leftCacheBounds,M=S.rightCacheBounds,T=0;A!==0&&(T=Th(b)/l);let C=0;E!==0&&(C=Th(M)/l);let P=1+1.25*(T*A+C*E);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let x=0;x<ia;x++){let w=rl[x];w.count=0,w.candidate=f+g+x*g;let S=w.bounds;for(let A=0;A<3;A++)S[A]=1/0,S[A+3]=-1/0}for(let x=c;x<h;x+=6){let A=~~((e[x+2*d]-f)/g);A>=ia&&(A=ia-1);let E=rl[A];E.count++,mp(x,e,E.bounds)}let y=rl[ia-1];cS(y.bounds,y.rightCacheBounds);for(let x=ia-2;x>=0;x--){let w=rl[x],S=rl[x+1];uS(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;x<ia-1;x++){let w=rl[x],S=w.count,A=w.bounds,b=rl[x+1].rightCacheBounds;S!==0&&(v===0?cS(A,rv):uS(A,rv,rv)),v+=S;let M=0,T=0;v!==0&&(M=Th(rv)/l);let C=n-v;C!==0&&(T=Th(b)/l);let P=1+1.25*(M*v+T*C);P<u&&(o=d,u=P,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function t8(i,t,e,r){let n=0;for(let s=t,o=t+e;s<o;s++)n+=i[s*6+r*2];return n/e}function r8(i,t){let e=i.attributes.position,r=i.index.array,n=r.length/3,s=new Float32Array(n*6),o=e.normalized,a=e.array,l=e.offset||0,u=3;e.isInterleavedBufferAttribute&&(u=e.data.stride);let c=["getX","getY","getZ"];for(let h=0;h<n;h++){let d=h*3,f=h*6,p,m,g;o?(p=r[d+0],m=r[d+1],g=r[d+2]):(p=r[d+0]*u+l,m=r[d+1]*u+l,g=r[d+2]*u+l);for(let y=0;y<3;y++){let v,x,w;o?(v=e[c[y]](p),x=e[c[y]](m),w=e[c[y]](g)):(v=a[p+y],x=a[m+y],w=a[g+y]);let S=v;x<S&&(S=x),w<S&&(S=w);let A=v;x>A&&(A=x),w>A&&(A=w);let E=(A-S)/2,b=y*2;s[f+b+0]=S+E,s[f+b+1]=E+(Math.abs(S)+E)*S2,S<t[y]&&(t[y]=S),A>t[y+3]&&(t[y+3]=A)}}return s}function n8(i,t){function e(y){d&&d(y/f)}function r(y,v,x,w=null,S=0){if(!p&&S>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let A=e8(y.boundingData,w,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let E=J6(a,o,v,x,A);if(E===v||E===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new cc,M=v,T=E-v;y.left=b,b.boundingData=new Float32Array(6),dS(o,M,T,b.boundingData,s),r(b,M,T,s,S+1);let C=new cc,P=E,D=x-T;y.right=C,C.boundingData=new Float32Array(6),dS(o,P,D,C.boundingData,s),r(C,P,D,s,S+1)}return y}Q6(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=r8(i,n),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=K6(i);if(g.length===1){let y=g[0],v=new cc;v.boundingData=n,Z6(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 cc;v.boundingData=new Float32Array(6),dS(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function E2(i,t){let e=n8(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<e.length;c++){let h=e[c],d=l(h),f=new a(32*d);r=new Float32Array(f),n=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,p=!!h.count,m=h.boundingData;for(let g=0;g<6;g++)r[d+g]=m[g];if(p){let g=h.offset,y=h.count;return n[d+6]=g,s[f+14]=y,s[f+15]=65535,c+32}else{let g=h.left,y=h.right,v=h.splitAxis,x;if(x=u(c+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=u(x,y),n[d+7]=v,x}}}var pi=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};pi.prototype.setFromBox=function(){let i=new _;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=n.x*l+s.x*(1-l),i.y=n.y*u+s.y*(1-u),i.z=n.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var ahe=function(){let i=new pi;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,u=r.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var i8=function(){let i=new _,t=new _,e=new _;return function(n,s,o){let a=n.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),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}}(),gp=function(){let i=new N,t=new _,e=new _;return function(n,s,o,a){i8(n,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){n.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=n.start:c=n.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),M2=function(){let i=new _,t=new _,e=new Or,r=new nn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(r.start=u,r.end=c,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).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 s8=1e-15;function Ch(i){return Math.abs(i)<s8}var mi=class extends dr{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new pi),this.points=[this.a,this.b,this.c],this.sphere=new fr,this.plane=new Or,this.needsUpdate=!0}intersectsSphere(t){return M2(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};mi.prototype.closestPointToSegment=function(){let i=new _,t=new _,e=new nn;return function(n,s=null,o=null){let{start:a,end:l}=n,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),gp(e,n,i,t),c=i.distanceToSquared(t),c<h&&(h=c,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),c=a.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),c=l.distanceToSquared(i),c<h&&(h=c,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();mi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new Array(3),r=new pi,n=new pi,s=new _,o=new _,a=new _,l=new _,u=new nn,c=new nn,h=new nn;return function(f,p=null,m=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let g=this.plane,y=f.plane;if(Math.abs(g.normal.dot(y.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let E=v[A],b=x[A];if(r.setFromPoints(b,e),E.isSeparated(r))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let E=w[A],b=S[A];if(r.setFromPoints(b,t),E.isSeparated(r))return!1}for(let A=0;A<4;A++){let E=x[A];for(let b=0;b<4;b++){let M=S[b];if(s.crossVectors(E,M),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))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,w=0;for(let I=0;I<3;I++){let R=v[I],V=v[(I+1)%3];u.start.copy(R),u.end.copy(V),u.delta(o);let k=x?c.start:c.end,z=Ch(y.distanceToPoint(R));if(Ch(y.normal.dot(o))&&z){c.copy(u),w=2;break}if((y.intersectLine(u,k)||z)&&!Ch(k.distanceTo(V))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,A=!1,E=0;for(let I=0;I<3;I++){let R=S[I],V=S[(I+1)%3];u.start.copy(R),u.end.copy(V),u.delta(a);let k=A?h.start:h.end,z=Ch(g.distanceToPoint(R));if(Ch(g.normal.dot(a))&&z){h.copy(u),E=2;break}if((g.intersectLine(u,k)||z)&&!Ch(k.distanceTo(V))){if(E++,A)break;A=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=c.start.dot(o),M=c.end.dot(o),T=h.start.dot(o),C=h.end.dot(o),P=M<T,D=b<C;return b!==C&&T!==M&&P===D?!1:(p&&(l.subVectors(c.start,h.start),l.dot(o)>0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();mi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();mi.prototype.distanceToTriangle=function(){let i=new _,t=new _,e=["a","b","c"],r=new nn,n=new nn;return function(o,a=null,l=null){let u=a||l?r:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<c&&(c=d,a&&a.copy(i),l&&l.copy(p));let m=this[f];o.closestPointToPoint(m,i),d=m.distanceToSquared(i),d<c&&(c=d,a&&a.copy(m),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let m=e[p],g=e[(p+1)%3];n.set(o[m],o[g]),gp(r,n,i,t);let y=i.distanceToSquared(t);y<c&&(c=y,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(c)}}();var gi=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new _,this.max=new _,this.matrix=new ie,this.invMatrix=new ie,this.points=new Array(8).fill().map(()=>new _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new pi),this.alignedSatBounds=new Array(3).fill().map(()=>new pi),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}};gi.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=n[d];f.x=u?r.x:e.x,f.y=c?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=n[d];c.subVectors(a,f),h.setFromPoints(c,n)}let l=this.alignedSatBounds;l[0].setFromPointsField(n,"x"),l[1].setFromPointsField(n,"y"),l[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();gi.prototype.intersectsBox=function(){let i=new pi;return function(e){this.needsUpdate&&this.update();let r=e.min,n=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=r.x,i.max=n.x,a[0].isSeparated(i)||(i.min=r.y,i.max=n.y,a[1].isSeparated(i))||(i.min=r.z,i.max=n.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(i.setFromBox(u,e),c.isSeparated(i))return!1}return!0}}();gi.prototype.intersectsTriangle=function(){let i=new mi,t=new Array(3),e=new pi,r=new pi,n=new _;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],p=c[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let m=c[p];if(n.crossVectors(f,m),e.setFromPoints(n,t),r.setFromPoints(n,h),e.isSeparated(r))return!1}}return!0}}();gi.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();gi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();gi.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new nn),e=new Array(12).fill().map(()=>new nn),r=new _,n=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),u&&u.copy(n)),0;let c=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];n.copy(y).clamp(h,d);let v=y.distanceToSquared(n);if(v<p&&(p=v,l&&l.copy(y),u&&u.copy(n),v<c))return Math.sqrt(v)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){let x=(g+1)%3,w=(g+2)%3,S=y<<x|v<<w,A=1<<g|y<<x|v<<w,E=f[S],b=f[A];t[m].set(E,b);let T=i[g],C=i[x],P=i[w],D=e[m],I=D.start,R=D.end;I[T]=h[T],I[C]=y?h[C]:d[C],I[P]=v?h[P]:d[C],R[T]=d[T],R[C]=y?h[C]:d[C],R[P]=v?h[P]:d[C],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){n.x=g?d.x:h.x,n.y=y?d.y:h.y,n.z=v?d.z:h.z,this.closestPointToPoint(n,r);let x=n.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),u&&u.copy(n),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){let y=t[g];for(let v=0;v<12;v++){let x=e[v];gp(y,x,r,n);let w=r.distanceToSquared(n);if(w<p&&(p=w,l&&l.copy(r),u&&u.copy(n),w<c))return Math.sqrt(w)}}return Math.sqrt(p)}}();var Ph=new _,Dh=new _,Ih=new _,iv=new N,sv=new N,ov=new N,T2=new _,C2=new _,P2=new _,av=new _;function o8(i,t,e,r,n,s){let o;return s===Qr?o=i.intersectTriangle(r,e,t,!0,n):o=i.intersectTriangle(t,e,r,s!==Ln,n),o===null?null:{distance:i.origin.distanceTo(n),point:n.clone()}}function a8(i,t,e,r,n,s,o,a,l){Ph.fromBufferAttribute(t,s),Dh.fromBufferAttribute(t,o),Ih.fromBufferAttribute(t,a);let u=o8(i,Ph,Dh,Ih,av,l);if(u){r&&(iv.fromBufferAttribute(r,s),sv.fromBufferAttribute(r,o),ov.fromBufferAttribute(r,a),u.uv=dr.getInterpolation(av,Ph,Dh,Ih,iv,sv,ov,new N)),n&&(iv.fromBufferAttribute(n,s),sv.fromBufferAttribute(n,o),ov.fromBufferAttribute(n,a),u.uv1=dr.getInterpolation(av,Ph,Dh,Ih,iv,sv,ov,new N)),e&&(T2.fromBufferAttribute(e,s),C2.fromBufferAttribute(e,o),P2.fromBufferAttribute(e,a),u.normal=dr.getInterpolation(av,Ph,Dh,Ih,T2,C2,P2,new _),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new _,materialIndex:0};dr.getNormal(Ph,Dh,Ih,c.normal),u.face=c,u.faceIndex=s}return u}function pS(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=a8(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function D2(i,t,e,r,n,s){for(let o=r,a=r+n;o<a;o++)pS(i,t,e,o,s)}function I2(i,t,e,r,n){let s=1/0,o=null;for(let a=r,l=r+n;a<l;a++){let u=pS(i,t,e,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Ki(i,t,e,r){let n=i.a,s=i.b,o=i.c,a=t,l=t+1,u=t+2;e&&(a=e.getX(t),l=e.getX(t+1),u=e.getX(t+2)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(u),o.y=r.getY(u),o.z=r.getZ(u)}function mS(i,t,e,r,n,s,o){let a=e.index,l=e.attributes.position;for(let u=i,c=t+i;u<c;u++)if(Ki(o,u*3,a,l),o.needsUpdate=!0,r(o,u,n,s))return!0;return!1}var Oh=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function sa(i,t){return t[i+15]===65535}function uc(i,t){return t[i+6]}function Rh(i,t){return t[i+14]}function Lh(i){return i+8}function Nh(i,t){return t[i+6]}function O2(i,t){return t[i+7]}var Bh=new Pt,cv=new _,c8=["x","y","z"];function uv(i,t,e,r,n){let s=i*2,o=Fh,a=nl,l=il;if(sa(s,a)){let c=uc(i,l),h=Rh(s,a);D2(t,e,r,c,h,n)}else{let c=Lh(i);dv(c,o,r,cv)&&uv(c,t,e,r,n);let h=Nh(i,l);dv(h,o,r,cv)&&uv(h,t,e,r,n)}}function hv(i,t,e,r){let n=i*2,s=Fh,o=nl,a=il;if(sa(n,o)){let u=uc(i,a),c=Rh(n,o);return I2(t,e,r,u,c)}else{let u=O2(i,a),c=c8[u],d=r.direction[c]>=0,f,p;d?(f=Lh(i),p=Nh(i,a)):(f=Nh(i,a),p=Lh(i));let g=dv(f,s,r,cv)?hv(f,t,e,r):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=dv(p,s,r,cv)?hv(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var R2=function(){let i,t,e=[],r=new Oh(()=>new Pt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,u=null,c=0,h=0){function d(x){let w=x*2,S=nl,A=il;for(;!sa(w,S);)x=Lh(x),w=x*2;return uc(x,A)}function f(x){let w=x*2,S=nl,A=il;for(;!sa(w,S);)x=Nh(x,A),w=x*2;return uc(x,A)+Rh(w,S)}let p=s*2,m=Fh,g=nl,y=il;if(sa(p,g)){let x=uc(s,y),w=Rh(p,g);return Qi(s,m,i),l(x,w,!1,h,c+s,i)}else{let x=Lh(s),w=Nh(s,y),S=x,A=w,E,b,M,T;if(u&&(M=i,T=t,Qi(S,m,M),Qi(A,m,T),E=u(M),b=u(T),b<E)){S=w,A=x;let k=E;E=b,b=k,M=T}M||(M=i,Qi(S,m,M));let C=sa(S*2,g),P=a(M,C,E,h+1,c+S),D;if(P===2){let k=d(S),G=f(S)-k;D=l(k,G,!0,h+1,c+S,M)}else D=P&&n(S,o,a,l,u,c,h+1);if(D)return!0;T=t,Qi(A,m,T);let I=sa(A*2,g),R=a(T,I,b,h+1,c+A),V;if(R===2){let k=d(A),G=f(A)-k;V=l(k,G,!0,h+1,c+A,T)}else V=R&&n(A,o,a,l,u,c,h+1);return!!V}}}(),L2=function(){let i=new mi,t=new mi,e=new ie,r=new gi,n=new gi;return function s(o,a,l,u,c=null){let h=o*2,d=Fh,f=nl,p=il;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,u),c=r),sa(h,f)){let g=a,y=g.index,v=g.attributes.position,x=l.index,w=l.attributes.position,S=uc(o,p),A=Rh(h,f);if(e.copy(u).invert(),l.boundsTree)return Qi(o,d,n),n.matrix.copy(e),n.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>n.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let M=S*3,T=(A+S)*3;M<T;M+=3)if(Ki(t,M,y,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let E=S*3,b=A+S*3;E<b;E+=3){Ki(i,E,y,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let M=0,T=x.count;M<T;M+=3)if(Ki(t,M,x,w),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let g=o+8,y=p[o+6];return Qi(g,d,Bh),!!(c.intersectsBox(Bh)&&s(g,a,l,u,c)||(Qi(y,d,Bh),c.intersectsBox(Bh)&&s(y,a,l,u,c)))}}}();function dv(i,t,e,r){return Qi(i,t,Bh),e.intersectBox(Bh,r)}var gS=[],lv,Fh,nl,il;function kh(i){lv&&gS.push(lv),lv=i,Fh=new Float32Array(i),nl=new Uint16Array(i),il=new Uint32Array(i)}function yp(){lv=null,Fh=null,nl=null,il=null,gS.length&&kh(gS.pop())}var yS=Symbol("skip tree generation"),vS=new Pt,xS=new Pt,Vh=new ie,hc=new gi,vp=new gi,xp=new _,fv=new _,u8=new _,h8=new _,d8=new _,N2=new Pt,ro=new Oh(()=>new mi),no=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."),no.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,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."),no.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new no(e,{...r,[yS]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),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,[yS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[yS]||(this._roots=E2(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Pt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;d<f;d++)s=c[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,u),u+=s.byteLength;function h(d,f,p=!1){let m=d*2;if(a[m+15]===65535){let y=o[d+6],v=a[m+14],x=1/0,w=1/0,S=1/0,A=-1/0,E=-1/0,b=-1/0;for(let M=3*y,T=3*(y+v);M<T;M++){let C=r[M],P=n.getX(C),D=n.getY(C),I=n.getZ(C);P<x&&(x=P),P>A&&(A=P),D<w&&(w=D),D>E&&(E=D),I<S&&(S=I),I>b&&(b=I)}return l[d+0]!==x||l[d+1]!==w||l[d+2]!==S||l[d+3]!==A||l[d+4]!==E||l[d+5]!==b?(l[d+0]=x,l[d+1]=w,l[d+2]=S,l[d+3]=A,l[d+4]=E,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,w=v+f,S=p,A=!1,E=!1;t?S||(A=t.has(x),E=t.has(w),S=!A&&!E):(A=!0,E=!0);let b=S||A,M=S||E,T=!1;b&&(T=h(y,f,S));let C=!1;M&&(C=h(v,f,S));let P=T||C;if(P)for(let D=0;D<3;D++){let I=y+D,R=v+D,V=l[I],k=l[I+3],z=l[R],G=l[R+3];l[d+D]=V<z?V:z,l[d+D+3]=k>G?k:G}return P}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=n[a+6],d=s[u+14];t(l,c,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,c,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Pi){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,u=o?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=a?e[l[c].materialIndex].side:u,f=s.length;if(kh(r[c]),uv(0,n,d,t,s),yp(),a){let p=l[c].materialIndex;for(let m=f,g=s.length;m<g;m++)s[m].face.materialIndex=p}}return s}raycastFirst(t,e=Pi){let r=this._roots,n=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=n.groups,u=s?e.side:e;for(let c=0,h=r.length;c<h;c++){let d=o?e[l[c].materialIndex].side:u;kh(r[c]);let f=hv(0,n,d,t);yp(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,n=!1;for(let s of this._roots)if(kh(s),n=L2(0,r,t,e),yp(),n)break;return n}shapecast(t,e,r){let n=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,m,g)=>{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ro.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:mS(f,p,n,u,m,g,s)}else l||(u?l=(d,f,p,m)=>mS(d,f,n,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(kh(d),c=R2(0,n,a,l,o,h),yp(),c)break;h+=d.byteLength}return ro.releasePrimitive(s),c}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;Vh.copy(e).invert();let c=ro.getPrimitive(),h=ro.getPrimitive();if(s){let f=function(p,m,g,y,v,x,w,S){for(let A=g,E=g+y;A<E;A++){Ki(h,A*3,l,u),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let b=p,M=p+m;b<M;b++)if(Ki(c,b*3,o,a),c.needsUpdate=!0,s(c,h,b,A,v,x,w,S))return!0}return!1};if(n){let p=n;n=function(m,g,y,v,x,w,S,A){return p(m,g,y,v,x,w,S,A)?!0:f(m,g,y,v,x,w,S,A)}}else n=f}t.getBoundingBox(xS),xS.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>xS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(vS.copy(v),vS.applyMatrix4(Vh),t.shapecast({intersectsBounds:x=>vS.intersectsBox(x),intersectsRange:(x,w,S,A,E)=>n(f,p,x,w,g,y,A,E)}))});return ro.releasePrimitive(c),ro.releasePrimitive(h),d}intersectsBox(t,e){return hc.set(t.min,t.max,e),hc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>hc.intersectsBox(r),intersectsTriangle:r=>hc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),hc.set(t.boundingBox.min,t.boundingBox.max,e),hc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=ro.getPrimitive(),f=ro.getPrimitive(),p=fv,m=u8,g=null,y=null;n&&(g=h8,y=d8);let v=1/0,x=null,w=null;return Vh.copy(e).invert(),vp.matrix.copy(Vh),this.shapecast({boundsTraverseOrder:S=>hc.distanceToBox(S),intersectsBounds:(S,A,E)=>E<v&&E<o?(A&&(vp.min.copy(S.min),vp.max.copy(S.max),vp.needsUpdate=!0),!0):!1,intersectsRange:(S,A)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>vp.distanceToBox(E),intersectsBounds:(E,b,M)=>M<v&&M<o,intersectsRange:(E,b)=>{for(let M=E*3,T=(E+b)*3;M<T;M+=3){Ki(f,M,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=S*3,P=(S+A)*3;C<P;C+=3){Ki(d,C,u,l),d.needsUpdate=!0;let D=d.distanceToTriangle(f,p,g);if(D<v&&(m.copy(p),y&&y.copy(g),v=D,x=C/3,w=M/3),D<s)return!0}}}});{let E=h?h.count:c.count;for(let b=0,M=E;b<M;b+=3){Ki(f,b,h,c),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let T=S*3,C=(S+A)*3;T<C;T+=3){Ki(d,T,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,p,g);if(P<v&&(m.copy(p),y&&y.copy(g),v=P,x=T/3,w=b/3),P<s)return!0}}}}}),ro.releasePrimitive(d),ro.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=v,r.faceIndex=x,n&&(n.point?n.point.copy(y):n.point=y.clone(),n.point.applyMatrix4(Vh),m.applyMatrix4(Vh),n.distance=m.sub(n.point).length(),n.faceIndex=w),r)}closestPointToPoint(t,e={},r=0,n=1/0){let s=r*r,o=n*n,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(xp.copy(t).clamp(c.min,c.max),xp.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(t,xp);let d=t.distanceToSquared(xp);return d<a&&(fv.copy(xp),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return e.point?e.point.copy(fv):e.point=fv.clone(),e.distance=u,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{Qi(0,new Float32Array(r),N2),t.union(N2)}),t}};var Dd=pn(F2());var f8=.5*(Math.sqrt(3)-1),bp=(3-Math.sqrt(3))/6,p8=1/3,io=1/6,ede=(Math.sqrt(5)-1)/4,tde=(5-Math.sqrt(5))/20,wp=i=>Math.floor(i)|0,k2=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]),wS=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 pv(i=Math.random){let t=z2(i),e=new Float64Array(t).map(n=>k2[n%12*2]),r=new Float64Array(t).map(n=>k2[n%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*f8,h=wp(s+c),d=wp(o+c),f=(h+d)*bp,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 w=g-v+bp,S=y-x+bp,A=g-1+2*bp,E=y-1+2*bp,b=h&255,M=d&255,T=.5-g*g-y*y;if(T>=0){let D=b+t[M],I=e[D],R=r[D];T*=T,a=T*T*(I*g+R*y)}let C=.5-w*w-S*S;if(C>=0){let D=b+v+t[M+x],I=e[D],R=r[D];C*=C,l=C*C*(I*w+R*S)}let P=.5-A*A-E*E;if(P>=0){let D=b+1+t[M+1],I=e[D],R=r[D];P*=P,u=P*P*(I*A+R*E)}return 70*(a+l+u)}}function V2(i=Math.random){let t=z2(i),e=new Float64Array(t).map(s=>wS[s%12*3]),r=new Float64Array(t).map(s=>wS[s%12*3+1]),n=new Float64Array(t).map(s=>wS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*p8,p=wp(o+f),m=wp(a+f),g=wp(l+f),y=(p+m+g)*io,v=p-y,x=m-y,w=g-y,S=o-v,A=a-x,E=l-w,b,M,T,C,P,D;S>=A?A>=E?(b=1,M=0,T=0,C=1,P=1,D=0):S>=E?(b=1,M=0,T=0,C=1,P=0,D=1):(b=0,M=0,T=1,C=1,P=0,D=1):A<E?(b=0,M=0,T=1,C=0,P=1,D=1):S<E?(b=0,M=1,T=0,C=0,P=1,D=1):(b=0,M=1,T=0,C=1,P=1,D=0);let I=S-b+io,R=A-M+io,V=E-T+io,k=S-C+2*io,z=A-P+2*io,G=E-D+2*io,H=S-1+3*io,Q=A-1+3*io,F=E-1+3*io,j=p&255,Y=m&255,q=g&255,U=.6-S*S-A*A-E*E;if(U<0)u=0;else{let W=j+t[Y+t[q]];U*=U,u=U*U*(e[W]*S+r[W]*A+n[W]*E)}let J=.6-I*I-R*R-V*V;if(J<0)c=0;else{let W=j+b+t[Y+M+t[q+T]];J*=J,c=J*J*(e[W]*I+r[W]*R+n[W]*V)}let Z=.6-k*k-z*z-G*G;if(Z<0)h=0;else{let W=j+C+t[Y+P+t[q+D]];Z*=Z,h=Z*Z*(e[W]*k+r[W]*z+n[W]*G)}let K=.6-H*H-Q*Q-F*F;if(K<0)d=0;else{let W=j+1+t[Y+1+t[q+1]];K*=K,d=K*K*(e[W]*H+r[W]*Q+n[W]*F)}return 32*(u+c+h+d)}}function z2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),s=e[r];e[r]=e[n],e[n]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var ws=new dr,mv=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let s=1;ws.a.fromBufferAttribute(t,n),ws.b.fromBufferAttribute(t,n+1),ws.c.fromBufferAttribute(t,n+2),s*=ws.getArea(),e[n/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,s=-1;for(;r<=n;){let o=Math.ceil((r+n)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?n=o-1:r=o+1}return s}sampleFace(t,e,r){let n=this.randomFunction(),s=this.randomFunction();return n+s>1&&(n=1-n,s=1-s),ws.a.fromBufferAttribute(this.positionAttribute,t*3),ws.b.fromBufferAttribute(this.positionAttribute,t*3+1),ws.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ws.a,n).addScaledVector(ws.b,s).addScaledVector(ws.c,1-(n+s)),ws.getNormal(r),this}};var G2=pn(SS()),m8=new ie,g8=new ie,y8=new ie,zh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(zh||(zh={}));var Uh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof gt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.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 n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){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)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)zh.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)zh.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[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,G2.SVD)(n),l=m8.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),u=g8.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),c=y8.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ie?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var AS=class extends Uh(gt){},v8=i=>i.type==="Mesh",mr=class extends AS{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 n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new mr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.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 v8(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 dc=new _,fc=new _,Gh=new ie,j2=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],x8=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],b8=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],H2=(i,t,e)=>{i.updateEntityBoxSize(dc,fc),Gh.copy(t).multiply(i.matrixWorld),fc.x===0&&fc.y===0&&fc.z===0?e.push(new _(dc.x,dc.y,dc.z).applyMatrix4(Gh)):j2.forEach(r=>{e.push(r.clone().multiply(fc).add(dc).applyMatrix4(Gh))})},Sp=class extends Pt{constructor(){super(...arguments);this.matrix=new ie;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 n=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new _);return}H2(o,r,s)}}):H2(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(Gh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(fc).multiplyScalar(.5),this.getCenter(dc),Gh.copy(this.matrix).setPosition(dc),this.vertices=j2.map(e=>e.clone().multiply(fc).applyMatrix4(Gh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=x8.map(([e,r])=>new nn(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=b8.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Ss={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var ES=class extends kf{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a<l.length;a++){let u=l[a],c=a===0?n[a]:n[a]-n[a-1],h=Math.ceil(t*c/o),d=u.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var MS=.001;function TS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=MS}function _S(i,t){let e=new _(...i.position),r=new _(...i.controlNext.position),n=new _(...t.controlPrevious.position),s=new _(...t.position);return TS(e,r,s)&&TS(e,n,s)}function yv(i){let t=i.points.map(c=>new _(...c.data.position)),e=[i.points[0]],r=new _(...e[0].data.position);for(let c=0;c<i.points.length-1;c++)TS(r,t[c],t[c+1])||(e.push(i.points[c]),r=t[c]);e.push(i.points[i.points.length-1]);let n=i.isClosed,s=e.length-(n?0:1),o=e.length,a=[];for(let c=0;c<o;c++){let h=e[c].data,d=new _(...h.position),f=new _(...h.controlPrevious.position),p=new _(...h.controlNext.position),m={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(c===0||c===o-1)){a[c]={...m,removedLength:0};continue}let g=n&&c==0?o-1:c-1,y=n&&c==o-1?0:c+1,v=e[g].data,x=e[y].data,w=new _(...v.position),S=new _(...x.position),A=w.clone().sub(d).normalize(),E=S.clone().sub(d).normalize();Object.assign(m,{prevDir:A,nextDir:E});let b=_S(v,h),M=_S(h,x);if(!b||!M)a[c]={...m,removedLength:0};else{let T=A.clone().add(E).normalize(),C=T.clone().cross(A).length()/A.dot(T);a[c]={...m,tan:C,removedLength:h.roundness/C}}}for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let m=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,m/2),p.removedLength=Math.min(p.removedLength,m/2)}}let l=[];for(let c=0;c<s;c++){let h=c,d=n&&c===o-1?0:c+1,f=a[h],p=a[d],m=null;if(!_S(e[h].data,e[d].data))f.position.distanceTo(p.position)>MS&&(m=new Wl(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)>MS&&(m=new Wl(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c<o;c++){let h=a[c];if(h.removedLength===0){l[2*c]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),m=h.tan*h.removedLength,g=h.prevDir.clone().add(h.nextDir).normalize(),y=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(y),w=g.clone().multiplyScalar(-m).add(x),S=d.distanceTo(w)/d.distanceTo(y),A=h.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),E=A.clone().lerp(w,2),b=f.clone().lerp(A,4/3),M=p.clone().lerp(E,4/3);l[2*c]=new Wl(f,b,M,p)}let u=new ES;return l.forEach(c=>{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var so=i=>lt.is(i),w8={type:"completeState",isfromEntity:!0},S8=["x","y","z"],CS=new _,A8=new _().set(0,1,0),Hh=i=>class extends Uh(i){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 Sp;this._recursiveBBox=new Sp;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(lt.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(lt.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 n=r.parent;if(lt.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ea.toOps(this.data,o.data).forEach(l=>{let u=wy.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ea.patch(this.data,o),ea.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),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,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{so(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(lt.is(n[s]))return n[s];if(lt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&<.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)so(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{lt.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)so(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)so(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)so(n)&&n.visible&&n.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,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>so(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ih(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,S8[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(CS.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(CS),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??qa.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(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)lt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{lt.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ih(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,u=qn(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){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=Rr.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 c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Rr.removeOverridden(r.path,r.props,c);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ea.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),qn(r.path,["overrides"])){let c=[],h=[...r.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[d],f.updateState(Ys.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Rr.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=vh.resolve(n.overrides,c),d.updateByOp(r,Lr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let h;for(let d of eo.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(c={...r,props:h})}else for(let h of eo.rootOverrideProps)if(qn(r.path,[h])){c=r;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Ys.filterOp(h.overrideData,c);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Ys.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Lr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!xs.is(r.props.type)&&Ss.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Ss.changeEntityProptotype(this,n,s);for(let o of this.children)lt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),qn(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),qn(r.path,["cloner"])!==null){let o=Lr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.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 n=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(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yv(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h),f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let p=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new ie().lookAt(d,y,A8),x=CS.setFromEuler(new Zt().setFromRotationMatrix(v)).multiplyScalar(Se.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(w8)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Ss.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Ss.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}};var vv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Se.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*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:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new Ap(u,c,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Yl(u,c,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function sl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function W2(i){return new N(i.y,-i.x)}var Ap=class extends Ae{constructor(t,e,r,n,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||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&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,w=new _,S=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new N(t,x),E=new N(e,-x),b=null,M=null,T=null,C=null,P=A.clone().sub(E),D=0,I=0,R=0;d>0&&(D=Math.min(t,e)*(1-d),I=t-D,R=e-D);let V=A.clone();V.x-=D;let k=Math.PI-P.angle(),z=P.angle(),G=Math.tan(z/2),H=Math.tan(k/2),Q=G+H,F=d?Q:H,j=d?Q:G;if(u=Math.min(u,(t-I)/F,P.length()/Q),c=Math.min(c,(e-R)/j,P.length()/Q),u>0){let K=u/G;b=A.clone().sub(new N(K,u)),d&&(T=b.clone(),T.x-=D-Q*u),A.sub(P.clone().setLength(K))}if(c>0){let K=c/H;M=E.clone().sub(new N(K,-c)),E.add(P.clone().setLength(K)),d&&(C=M.clone(),C.x-=D-Q*c,V.sub(P.clone().setLength(K)))}P=A.clone().sub(E);let Y=P.length()<.5,q=[];for(let K=0;K<=n;K++){let W=[],ye=K/n,fe=ye*l+a,se=new N(Math.sin(fe),Math.cos(fe));C&&M?(U(W,ye,se,k,c,C,-1,!0),U(W,ye,se,z,c,M,-1,!1)):M?(J(W,se,M.x,0,-1),U(W,ye,se,z,c,M,-1,!1)):o||J(W,se,e,R,-1);let _e=W2(P).normalize();if(sl(_e,se,w),!Y)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=P.clone().multiplyScalar(Oe).add(E);sl(Ie,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}if(T&&b?(U(W,ye,se,k,u,b,1,!1),U(W,ye,se,z,u,T,1,!0)):b?(U(W,ye,se,k,u,b,1,!1),J(W,se,b.x,0,1)):o||J(W,se,t,I,1),d&&!Y){let xe=W2(P).multiplyScalar(-1).normalize();sl(xe,se,w);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=P.clone().multiplyScalar(-Ie).add(V);sl(Pe,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;K<q.length-1;K++)for(let W=0;W<q[0].length-1;W++){if(o&&d&&W==s)continue;let ye=q[K][W],fe=q[K+1][W],se=q[K+1][W+1],_e=q[K][W+1],xe=m[se*3+0],Oe=m[se*3+2];p.push(ye,fe,_e),(xe!=0||Oe!=0)&&p.push(fe,se,_e)}l<Math.PI*2&&(Z(-1,q[0],a),Z(1,q[q.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new be(m,3)),this.setAttribute("normal",new be(g,3)),this.setAttribute("uv",new be(y,2));function U(K,W,ye,fe,se,_e,xe,Oe){for(let Ie=0;Ie<h+1;Ie++){let Pe=Ie/h,Me=xe<0?Pe:1-Pe;Oe&&(Me-=1),Me*=fe;let ze=new N(Math.sin(Me),Math.cos(Me)*xe),Ue=ze.clone().multiplyScalar(se).add(_e);sl(Ue,ye,S),m.push(S.x,S.y,S.z),sl(ze,ye,w),g.push(w.x,w.y,w.z),y.push(W,.5+S.y/r),K.push(v++)}}function J(K,W,ye,fe,se){let _e=new _,xe=new N,Oe=[ye,fe];se<0&&Oe.reverse();for(let Ie of Oe)xe.set(Ie,x*se),sl(xe,W,_e),m.push(_e.x,_e.y,_e.z),g.push(0,se,0),y.push(.5,.5),K.push(v++)}function Z(K,W,ye){let fe=new N(Math.sin(ye),Math.cos(ye)),se=new N(-Math.cos(ye),Math.sin(ye)),_e=new _,xe=K<0?(Pe,Me,ze)=>p.push(Pe,Me,ze):(Pe,Me,ze)=>p.push(Pe,ze,Me),Oe=new N((t+e+I+R)/4,0);sl(Oe,fe,_e),m.push(_e.x,_e.y,_e.z),g.push(se.x,0,se.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Me=m.slice(Pe*3,Pe*3+3);m.push(...Me),g.push(se.x,0,se.y);let ze=y.slice(Pe*2,Pe*2+2);y.push(...ze),v++}for(let Pe=Ie+1;Pe<v-1;Pe++)xe(Ie,Pe,Pe+1);xe(Ie,v-1,Ie+1)}}};var q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ae,d.setAttribute("position",new be([],3))):u>0||c>0||l<360?d=new Ap(0,t/2,r,n,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new du(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var Y2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new yn(t,e,r,n,s,o):u=new DS(t,e,r,n,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},PS=Math.PI/2,DS=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,r,e,t,o,s,0),g("z","y","x",1,-1,r,e,-t,o,s,1),g("x","z","y",1,1,t,r,e,n,o,2),g("x","z","y",1,-1,t,r,-e,n,o,3),g("x","y","z",1,-1,t,e,r,n,s,4),g("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,o,0),y("z","y","x",1,-1,-1,r,e,t,o,1),y("z","y","x",-1,1,-1,r,e,t,o,1),y("z","y","x",1,1,1,r,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,r,n,0),y("x","y","z",1,-1,1,t,e,r,n,1),y("x","y","z",-1,1,1,t,e,r,n,0),y("x","y","z",1,1,-1,t,e,r,n,1),y("y","x","z",-1,-1,1,e,t,r,s,0),y("y","x","z",1,-1,-1,e,t,r,s,1),y("y","x","z",1,1,1,e,t,r,s,1),y("y","x","z",-1,1,-1,e,t,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,w,S,A,E,b,M,T,C,P,D){let I=(b-2*a)/C,R=(M-2*a)/P,V=b/2-a,k=M/2-a,z=T/2,G=C+1,H=P+1,Q=0,F=0,j=new _;for(let Y=0;Y<H;Y++){let q=Y*R-k;for(let U=0;U<G;U++){let J=U*I-V;j[x]=J*A,j[w]=q*E,j[S]=z,h.push(j.x,j.y,j.z),j[x]=0,j[w]=0,j[S]=T>0?1:-1,d.push(j.x,j.y,j.z),f.push(U/C),f.push(1-Y/P),Q+=1}}for(let Y=0;Y<P;Y++)for(let q=0;q<C;q++){let U=p+q+G*Y,J=p+q+G*(Y+1),Z=p+(q+1)+G*(Y+1),K=p+(q+1)+G*Y;c.push(U,J,K),c.push(J,Z,K),F+=6}u.addGroup(m,F,D),m+=F,p+=Q}function y(x,w,S,A,E,b,M,T,C,P,D){let I=(M-2*a)/P,R=M/2-a,V=T/2-a,k=C/2,z=P+1,G=0,H=0,Q=new _,F=new _;for(let j=0;j<l+1;j++){let Y=j/l*PS,q=Math.sin(Y)*a,U=(1-Math.cos(Y))*a,J=Math.sin(Y),Z=Math.cos(Y);Q[w]=(V+q)*E,Q[S]=(k-U)*b,F[x]=0,F[w]=J*Math.sign(Q[w]),F[S]=Z*Math.sign(Q[S]);for(let K=0;K<z;K++){let W=K*I-R;Q[x]=W*A,h.push(Q.x,Q.y,Q.z),d.push(F.x,F.y,F.z),f.push(K/P),f.push(0),G+=1}}for(let j=0;j<l;j++)for(let Y=0;Y<P;Y++){let q=p+Y+z*j,U=p+Y+z*(j+1),J=p+(Y+1)+z*(j+1),Z=p+(Y+1)+z*j;c.push(q,U,Z),c.push(U,J,Z),H+=6}u.addGroup(m,H,D),m+=H,p+=G}function v(x,w,S){let A=new _,E=new _(t/2,e/2,r/2);E.subScalar(a);let b=[],M=x*w*S>0?(C,P,D)=>c.push(C,P,D):(C,P,D)=>c.push(C,D,P);for(let C=0;C<=l;C++){let P=[],D=PS*(1-C/l),I=Math.cos(D),R=Math.sin(D),V=0;for(let k=0;k<=C;k++){let z=Math.cos(V),G=Math.sin(V);A.x=I*z,A.y=R,A.z=I*G;let H=E.clone().addScaledVector(A,a);h.push(x*H.x,w*H.y,S*H.z),d.push(x*A.x,w*A.y,S*A.z),f.push(0,0),P.push(p++),V+=PS/C}b.push(P)}let T=b.length-1;for(let C=0;C<T;C++){let P=b[C],D=b[C+1],I=P.length-1;M(P[0],D[1],D[0]);for(let R=1;R<=I;R++)M(P[R-1],P[R],D[R]),M(P[R],D[R+1],D[R])}}}};var ol=class extends Ae{constructor(t=[],e=[],r="",n=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(u,3)),this.setAttribute("uv",new be(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new _,m=p.clone(),g=new dr,y=s*n,v=n-y,x=o+1,w=new _,S=(G,H)=>w.subVectors(G,H).normalize(),A=(G,H)=>Array(G).fill(void 0).map(H),E=A(t.length/3,(G,H)=>new _().fromArray(t,H*3).setLength(n)),b=[],M=1e6;for(let G=0;G<E.length;G++){let H=E[G],Q=[],F,j,Y,q=1e10,U=-1;for(;(U=e.indexOf(G,U+1))!=-1;){let W=U-U%3;F=e[W+(U+1)%3],j=e[W+(U+2)%3],Y=H.distanceToSquared(E[F]),q=Math.min(q,Y),Q.push([F,j,Y])}q+=1e-6;let J=[],Z=0,K=Q.length;for(let W=0;W<K;W++){[F,j,Y]=Q[Z];let ye=b[F]?.includes(G)==!0;Y<=q&&J.push(F+ +ye*M),Z=Q.findIndex(fe=>fe[0]==j)}b.push(J)}let T=[];{let G=0,H=0,Q,F,j=f==3;for(let Y=0;Y<=o;Y++){Q=Y*(Y+1)/2,F=(Y+1)*(Y+2)/2;for(let q=0;q<o-Y;q++)[G,H]=[Q+q+Y+2,F+q+Y+3],T.push(Q,F,...j?[H,Q]:[G,F],H,G),[Q,F]=[G,H];T.push(Q,F,Q+o+2)}}let C=p.clone(),P=p.clone(),D=p.clone(),I=p.clone(),R=p.clone(),V=[],k=A(E.length,()=>A(f,()=>p.clone()));for(let G=0;G<E.length;G++){p.copy(E[G]).normalize(),C.copy(p).multiplyScalar(v);let H=b[G];for(let J=0;J<H.length;J++){let Z=H[J],K=H[(J+1)%f];g.setFromPointsAndIndices(E,G,Z%M,K%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,k[G][J])}let Q=[],F=[],j=[],Y=new _;o==0&&[...k[G]].reduce((J,Z)=>J.add(Z),Y).multiplyScalar(1/f);for(let J=0;J<f;J++){let Z=[],K=(J-1+f)%f,W=k[G][K],ye=k[G][J];p.copy(W).sub(C),m.copy(ye).sub(C);let fe=C.angleTo(p),se=p.angleTo(m),_e=Math.cos(fe)*y;o==0?P.copy(Y):P.copy(C).setLength(v+_e),F.push(_e);let xe=[P,W,ye];for(let Oe=0;Oe<2;Oe++){let Ie=xe[Oe],Pe=xe[Oe+1];I.subVectors(Ie,C),R.subVectors(Pe,C),D.crossVectors(I,R).normalize();for(let Me=0;Me<x;Me++){let ze=[fe,se][Oe]*Me/x;p.copy(I).applyAxisAngle(D,ze).add(C),Q.push(p.clone()),Oe&&(S(p,C),Z.push([Me==0?Ie:p.clone(),w.clone()]))}Oe&&(S(Pe,C),Z.push([Pe,w.clone()]))}j.push(Z)}V.push(j);let q=2*x,U=2;for(let J=0;J<f;J++){let Z=q*J,K=q*((J+1)%f),W=[Q[Z]];for(let fe=1;fe<x;fe++){I=Q[Z+fe],R=Q[K+fe],W.push(I);for(let se=1,_e=fe-U+1;se<=_e;se++)p.lerpVectors(I,R,se/(_e+1)),p.sub(C).setLength(F[J]).add(C),W.push(p.clone());W.push(R)}for(let fe=0;fe<x;fe++)W.push(Q[fe+x+Z]);W.push(Q[K+x]);let ye=T.map(fe=>W[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(S(fe,C),[w.x,w.y,w.z])).flat())}}let z=[];for(let G=0;G<b.length;G++)for(let H=0;H<f;H++){let Q=b[G][H];if(Q<M){let F=b[Q].findIndex(q=>q%M==G),j=V[G][H],Y=V[Q][F];for(let q=0;q<x;q++){let U=j[q],J=Y[x-q],Z=j[q+1],K=Y[x-(q+1)];[U,J,Z,Z,J,K].forEach(W=>{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}z.push(j[0][0],Y[x][0],j[x][0],Y[0][0])}}for(;z.length;){let G,H,Q,F;[G,H]=z.splice(0,2);let j=[G];for(;G!=H;)j.push(H),Q=z.indexOf(H),F=Q%2,H=z.splice(Q-F,2)[1-F];w.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let Y=w.dot(j[0])<0;Y&&w.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +Y],j[q+1-+Y],j[0]].forEach(U=>{a.push(U.x,U.y,U.z),u.push(w.x,w.y,w.z)})}}function h(){let d=new _;for(let E=0;E<a.length;E+=3){d.x=a[E+0],d.y=a[E+1],d.z=a[E+2];let b=S(d)/2/Math.PI+.5,M=A(d)/Math.PI+.5;l.push(b,1-M)}let f=new _,p=new _,m=new _,g=new _,y=new N,v=new N,x=new N,w=(E,b,M,T)=>{T<0&&E.x===1&&(l[b]=E.x-1),M.x===0&&M.z===0&&(l[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E<a.length;E+=9,b+=6){f.set(a[E+0],a[E+1],a[E+2]),p.set(a[E+3],a[E+4],a[E+5]),m.set(a[E+6],a[E+7],a[E+8]),y.set(l[b+0],l[b+1]),v.set(l[b+2],l[b+3]),x.set(l[b+4],l[b+5]),g.copy(f).add(p).add(m).divideScalar(3);let M=S(g);w(y,b+0,f,M),w(v,b+2,p,M),w(x,b+4,m,M)}for(let E=0;E<l.length;E+=6){let b=l[E+0],M=l[E+2],T=l[E+4],C=Math.max(b,M,T),P=Math.min(b,M,T);C>.9&&P<.1&&(b<.2&&(l[E+0]+=1),M<.2&&(l[E+2]+=1),T<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function A(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new ol(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var X2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new _p(t*.5,s,o):new pu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},_p=class extends ol{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,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,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,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 _p(t.radius,t.corner,t.cornerSides)}};var Ep=1e-12,jh=class{constructor(t){this.position=new N;this.startPosition=new N;this.uuid=Se.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 jh(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wh=class extends jh{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wh(this.parent).copy(this)}},As=class extends jh{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Wh(this),new Wh(this))}static create(e,r){let n=new As(e,new N(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}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 n=0,s=this.controls.length;n<s;n++){let o=this.controls[n];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new As(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new N,r=new N){let[n,s]=this.computeTangents();return n&&s&&(Q2(n,e),Q2(s,r)),[e,r]}computeTangent(e=new N){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new N){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function Q2(i,t=new N){let e=i.length();return t.set(-i.y/e,i.x/e)}var OS=i=>i,qh=new N,xv=new N,_8=new N,E8=new N,M8=new N,T8=new N,Z2=new _,J2=new _;function $2(i){let t=new N;t.addVectors(i.v0,qh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new N;return e.addVectors(i.v2,xv.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new jn(i.v0,t,e,i.v2)}function Mp(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function C8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function P8(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function RS(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function eD(i,t,e){return K2(i,t)&&K2(t,e)&&IS(i.position,t.position,e.position)}function IS(i,t,e){return qh.copy(t).sub(i).cross(xv.copy(e).sub(i))===0}function tD(i,t,e,r,n){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,u=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return r.set(a+l,o+u),n.set(a-l,o-u),[r,n]}function rD(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function nD(i,t,e,r,n,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,u=e.y-i.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return RS(t,i,e)>Math.PI&&(c*=-1),Mp(u,a)?h=(a+u)*(r/c-.5)*8/3/(o-l):h=(o+l)*(r/c-.5)*8/3/(u-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[n,s]}function LS(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function K2(i,t){return IS(i.position,i.controls[1].position,t.position)&&IS(i.position,t.controls[0].position,t.position)}function iD(i,t,e,r,n=.5){let s=qh.subVectors(t,i).multiplyScalar(n).add(i),o=xv.subVectors(e,t).multiplyScalar(n).add(t),a=_8.subVectors(r,e).multiplyScalar(n).add(e),l=s,u=E8.subVectors(o,s).multiplyScalar(n).add(s),c=M8.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=T8.subVectors(c,u).multiplyScalar(n).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,r.x,r.y]}function sD(i,t,e=12,r=!0){let n=J2.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let u=OS(t[l]),c=qh,h=al(u,e);a.push(h);for(let d=0;d<=h;d++)if(u instanceof jn||u instanceof Ii||u instanceof Wn){if(u.getPoint(d/h,c),n.set(c.x,c.y,0),s!==void 0&&P8(s,n))continue;s===void 0&&(s=Z2),s.copy(n),i.setXYZ(o,n.x,n.y,n.z),o++}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function oD(i,t,e,r=12,n=!0){let s=J2.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=OS(t[l]),h=qh,d=al(c,r);a.push(d);for(let f=0;f<=d;f++)if(c instanceof jn||c instanceof Ii||c instanceof Wn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=Z2:(i.setXYZ(o,u.x,u.y,u.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function NS(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let o=i[n],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=al(o.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=al(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=al(i[0].roundedCurveCorner,t)*.5),r}function al(i,t=12){return i&&i instanceof jl?t*2:i&&(i instanceof Wn||i instanceof Ff)?1:i&&i instanceof uu?t*i.points.length:t}function aD(i,t,e=12,r=!0){let n,s=0;for(let o=0;o<t.length;o++){let a=OS(t[o]),l=al(a,e),u=qh;for(let c=0;c<=l;c++)if(a instanceof jn||a instanceof Ii||a instanceof Wn){if(a.getPoint(c/l,u),n!==void 0&&C8(n,u,Ep))continue;n===void 0&&(n=xv),n.copy(u),i.push(u.x,u.y),s++}}return Mp(i[0],i[i.length-2],Ep)&&Mp(i[1],i[i.length-1],Ep)&&(i.pop(),i.pop()),r&&s>1&&!(Mp(i[s-1],i[1],Ep)&&Mp(i[s-2],i[0],Ep))&&(i.push(i[0],i[1]),s++),i}var BS=new N,D8=new N,I8=new N,O8=new N,R8=new N,L8=new N,Ot=class extends jo{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Or(new _(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=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Ot;return s.isClosed=e.isClosed,s.points=e.points.map(o=>As.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Ot.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),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,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(e);if(c<0)s+=u;else return c+s}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=BS.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(n),a.controls[0].position.multiply(n),a.controls[1].position.multiply(n)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,n=Se.generateUUID()){let s;e instanceof N?s=e:s=new N(e,r);let o=new As(n,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=n?this.roundedCurveDivisions:this.curveDivisions;return sD(e,n?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=NS(this.points,e,!1),this.roundedCurveDivisions=NS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return oD(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),aD(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=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=al(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<n+c)return[l,(a-n+1)/c];n+=c}return[0,1]}getCurveT(e,r,n){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(LS(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(BS.set(n.x,n.y))/h}let u=0;for(let h=0;h<e;h++)u+=a[h];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){LS(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let s=n.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,s=this.points.length;n<s;n++){let o=this.points[n],a=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],u=o.roundness,c=a&&l&&eD(a,o,l);if(!o.controlsMoved()&&u>0&&!c){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(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/m,S=x/g,A=h.getPointAt(w,BS),E=d.getPointAt(S,D8);this._subSplitCurve(h,f,w,A,void 0),this._subSplitCurve(d,p,S,void 0,E);let b;if(this.useCubicForRoundedCorners){let M=RS(A,o.position,E)/2,T=Math.tan(M)*A.distanceTo(o.position),[C,P]=tD(A,E,T,I8,O8),D=rD(C,P,o.position),[I,R]=nD(D,A,E,T,R8,L8);b=new jn(A.clone(),I.clone(),R.clone(),E.clone())}else b=new Ii(A.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(n+r,0,b),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof Wn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,u=a.getUtoTmapping(n,0),c=iD(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Ot(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 n=0;n<r;n++){let s=n*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],u=e.points[s+3],c=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new As(Se.generateUUID(),new N(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let s=new Ot;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof jn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,u;for(l=0,u=o.length;l<u;l++)o[l]instanceof Ii&&(o[l]=$2(o[l]));for(l=0,u=o.length;l<u;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof jn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof Wn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let c=o[o.length-1],h=!1;return c instanceof jn?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),h=!0):c instanceof Wn&&c.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof jo&&(this.shapeHoles=e.holes.map(o=>{let a=new Ot;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.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 kS=Math.PI*2;function FS({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function N8(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function lD(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function B8(i,t,e,r,n,s,o,a,l,u){let c=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*n/s*a,g=p*-s/n*o,y=m+(i+e)/2,v=g+(t+r)/2,x=(o-m)/n,w=(a-g)/s,S=(-o-m)/n,A=(-a-g)/s,E=lD(1,0,x,w),b=lD(x,w,S,A);return!u&&b>0&&(b-=kS),u&&b<0&&(b+=kS),{centerx:y,centery:v,ang1:E,ang2:b}}function cD({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let u=(i-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=B8(i,t,e,r,n,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(kS/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x<v;x++)l.push(N8(f,p)),f+=p;return l.map(x=>{let{x:w,y:S}=FS(x[0],n,s,m,g),{x:A,y:E}=FS(x[1],n,s,m,g),{x:b,y:M}=FS(x[2],n,s,m,g);return{x1:w,y1:S,x2:A,y2:E,x:b,y:M}})}var St;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(St||(St={}));var br;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(br||(br={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Ze=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?n<s?e.t-t.t+(t.t-r.t)*(n/(n+s)):e.t-r.t+(r.t-t.t)*(s/(n+s)):0},i.edgeSign=function(t,e,r){nt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n<s?e.s-t.s+(t.s-r.s)*(n/(n+s)):e.s-r.s+(r.s-t.s)*(s/(n+s)):0},i.transSign=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),Tp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),bv=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Yh=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),uD=function(){function i(){var t=new Yh,e=new Tp,r=new bv(0),n=new bv(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new bv(0),r=new bv(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;nt(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e;var o=e;do o.Org=n,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;nt(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var o=e;do o.Lface=n,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Yh,e=new Yh,r=new Tp,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var s=new Yh;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new Tp;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var n=new Tp;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new Yh;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),s=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(s,e),n.Org=t.Dst,s.Org=e.Org,n.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new Tp;this.makeFace_(o,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,s,o,a;n=e.Lnext;do r=n,n=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&Ze.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&Ze.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,s,o,a,l,u;for(s=t,s=t;(n=s.next)!==t;s=n){nt(n.prev===s),l=n.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(nt(n.prev===s&&n.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){nt(o.prev===a),l=o.anEdge;do nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l),nt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(nt(o.prev===a&&o.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)nt(l.Sym.next===u.Sym),nt(l.Sym!==l),nt(l.Sym.Sym===l),nt(l.Org!==null),nt(l.Dst!==null),nt(l.Lnext.Onext.Sym===l),nt(l.Onext.Sym.Lnext===l);nt(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),hD=function(){function i(){this.handle=null}return i}(),dD=function(){function i(){this.key=null,this.node=0}return i}(),F8=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new hD,this.handles[r]=new dD;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,nt(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new hD;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new dD}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;nt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),VS=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),fD=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),k8=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new fD,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new fD;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),V8=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?Ze.vertLeq(s.Org,o.Org)?Ze.edgeSign(o.Dst,s.Org,o.Org)<=0:Ze.edgeSign(s.Dst,o.Org,s.Org)>=0:Ze.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return Ze.edgeSign(s.Dst,n,s.Org)>=0;var a=Ze.edgeEval(s.Dst,n,s.Org),l=Ze.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new VS;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case St.ODD:return(e&1)!==0;case St.NONZERO:return e!==0;case St.POSITIVE:return e>0;case St.NEGATIVE:return e<0;case St.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,u,c,h=!0;u=r;do nt(Ze.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Ze.vertL1dist(e,t),s=Ze.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+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]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(Ze.vertLeq(n.Org,s.Org)){if(Ze.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Ze.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(Ze.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(nt(!Ze.vertEq(n.Dst,s.Dst)),Ze.vertLeq(n.Dst,s.Dst)){if(Ze.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ze.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,u=s.Dst,c,h,d=new Yh,f,p;if(nt(!Ze.vertEq(u,l)),nt(Ze.edgeSign(l,t.event,o)<=0),nt(Ze.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Ze.vertLeq(o,a)){if(Ze.edgeSign(u,o,a)>0)return!1}else if(Ze.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ze.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Ze.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Ze.vertLeq(o,a)?o:a,Ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ze.vertEq(d,o)||Ze.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,d)>=0||!Ze.vertEq(u,t.event)&&Ze.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(Ze.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Ze.edgeSign(u,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(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ze.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,r.Onext,s,s,!0);return}Ze.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,Ze.vertEq(n.Org,r)){nt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Ze.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),Ze.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,u=new VS;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,Ze.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=Ze.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);nt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new VS,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,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)},i.initEdgeDict=function(t){t.dict=new k8(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++r===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,Ze.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new F8(s,Ze.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Ze.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),z8=function(){function i(){this.mesh=new uD,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=St.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],u=[0,0,0],c=[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],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],s<u[y]&&(u[y]=s,p[y]=e),s>l[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[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_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==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]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,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,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(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,n);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Ze.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Ze.edgeGoesLeft(n.Lnext)||Ze.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===br.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*n;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],n>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===br.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){n=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,n=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new uD),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=St.ODD),e===void 0&&(e=br.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,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),V8.computeInterior(this,o);var a=this.mesh;return e===br.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===br.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function _s(i){var t=i.windingRule,e=t===void 0?St.ODD:t,r=i.elementType,n=r===void 0?br.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new z8;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)y.addContour(l||2,d[v]);return y.tesselate(e,n,o,l,c,p),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:g?y.mesh:void 0}}}var Pfe=St.ODD,Dfe=St.NONZERO,Ife=St.POSITIVE,Ofe=St.NEGATIVE,Rfe=St.ABS_GEQ_TWO,Lfe=br.POLYGONS,Nfe=br.CONNECTED_POLYGONS,Bfe=br.BOUNDARY_CONTOURS;var wv=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*wv.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*wv.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(n,o*s,3*t);o+=3*t;let l=new Float32Array(n,o*s,3*t);o+=3*t;let u=new Float32Array(n,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=l,this.uvs=u,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}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)}},Cp=wv;Cp.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var yD=pn(gD()),Pp={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},WS={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},HS=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),cl=class extends Ae{constructor(e,r,n=0,s=12,o=3,a=St.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 u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let P=C.extractShapePointsToFlatArray([],s),D=[];for(let I=P.length-1;I>=1;I-=2){let R=P[I-1],V=P[I-0];D.push(R,V)}return D}),h=[],d=[];for(let C=0;C<u.length;C+=2)d.push([u[C],u[C+1]]);h.push(d);for(let C=0;C<c.length;C++){let P=c[C],D=[];for(let I=0;I<P.length;I+=2)D.push([P[I],P[I+1]]);h.push(D)}let f;e.isText?f=new Mu().setFromPoints(e.points.map(P=>P.position)).getSize(new N).length()*.1:h[0].length===0?f=n:f=(0,yD.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=_s({windingRule:a,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Pp}let m;try{m=_s({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=jS}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;C<m.elements.length;C++){let P=m.elements[C],D=C%2===0?p.vertexCount:0;p.elements.push(P+D)}for(let C=0;C<m.vertexIndices.length;C++){let P=m.vertexIndices[C],D=p.vertexCount;p.vertexIndices.push(P+D)}for(let C=0;C<m.vertices.length;C++){let P=m.vertices[C];p.vertices.push(P)}}let y=1/0,v=-1/0,x=1/0,w=-1/0;for(let C=0,P=p.vertexCount;C<P;C++){let D=C*2,I=p.vertices[D+0],R=p.vertices[D+1];I<y&&(y=I),I>v&&(v=I),R<x&&(x=R),R>w&&(w=R)}this._minX=y,this._minY=x,this._width=v-y,this._height=w-x,this._buffer=new Cp(this._computeBufferEstimatedSize(p));let S=[],A=[];for(let C=p.elementCount-1;C>=0;C--){let P=C>=g,D=C*2,I=p.elements[D+0],R=p.elements[D+1],V=I+R,k={start:I,count:R,normals:[],continuous:[],concave:[]},z=I,G=V-1,H=I+1,Q=this._shape.roundedCurves.length;do{let U=z-I,J=p.vertices[G*2+0],Z=p.vertices[G*2+1],K=p.vertices[z*2+0],W=p.vertices[z*2+1],ye=p.vertices[H*2+0],fe=p.vertices[H*2+1],se=K-J,_e=W-Z,xe=Math.sqrt(se*se+_e*_e);se/=xe,_e/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,k.normals[U*2+0]=-Ie,k.normals[U*2+1]=Oe,k.concave[U]=se*Ie-_e*Oe>0;let Me=p.vertexIndices[z];if(Array.isArray(Me))k.continuous[U]=!1;else{let[ze,Ue]=this._shape.getCurveIndexFromVertexId(Me-1,!0);if(Ue>0&&Ue<1)k.continuous[U]=!0;else{let L=Ue===1?ze+1:ze-1;L=(L+Q)%Q;let O=Ue===1?0:1,re=this._shape.roundedCurves[ze].getTangent(Ue),ue=this._shape.roundedCurves[L].getTangent(O);k.continuous[U]=re.dot(ue)>.95}}P&&(k.normals[U*2+0]*=-1,k.normals[U*2+1]*=-1),[G,z,H]=[z,H,H+1],H>=V&&(H-=R)}while(H!==I+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,V*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((U,J)=>[J,J]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,V*2)});let j=0;for(let U=1;U<=this._bevelSegments;U++){let J=U/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(J))*this._bevel,K=[],W=[],ye=[],fe=[],se=0;for(let xe=0;xe<R;xe++){let Oe=xe*2,Ie=(xe-1+R)%R*2,Pe=p.vertices[k.start*2+Oe+0],Me=p.vertices[k.start*2+Oe+1],ze=-k.normals[Ie+0]*Z,Ue=-k.normals[Ie+1]*Z,L=-k.normals[Oe+0]*Z,O=-k.normals[Oe+1]*Z;if(k.concave[xe]||!k.concave[xe]&&P){let re=Math.atan2(Ue,ze),ue=Math.atan2(O,L);ue>re&&(ue-=Math.PI*2);let me=ue-re;if(k.continuous[xe]||P){let De=re+me/2,Te=Math.cos(De)*Z,Ee=Math.sin(De)*Z;K[2*se+0]=Pe+Te*(P?-1:1),K[2*se+1]=Me+Ee*(P?-1:1),fe[se]=xe,se++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Te=0;Te<=De;Te++){let Ee=re+me*(Te/De),le=Math.cos(Ee)*Z,Ke=Math.sin(Ee)*Z;K[2*se+0]=Pe+le,K[2*se+1]=Me+Ke,fe[se]=xe,se++}}}else K[2*se+0]=Pe+ze,K[2*se+1]=Me+Ue,fe[se]=xe,W[xe]=se,se++,K[2*se+0]=Pe,K[2*se+1]=Me,fe[se]=xe,se++,K[2*se+0]=Pe+L,K[2*se+1]=Me+O,fe[se]=xe,ye[xe]=se,se++}let _e=_s({windingRule:St.POSITIVE,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Me=fe[(Ie+1)%fe.length];xe.idx=[Pe,Me],xe.Sym.idx=[Me,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!_e)throw console.log("Error"),new Error(`error generating bevel geometry for ${U}'th loop`);if(!_e.vertexCount){let xe=(U-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<_e.vertexIndices.length;xe++){let[Oe,Ie]=_e.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie<Oe&&(Pe+=R);for(let Me=Oe;Me<Pe;Me++){let ze=Me%R,Ue=(Me+1)%R;if(!k.continuous[ze]||!k.continuous[Ue]){_e.vertexIndices[xe]=[Oe,ze],_e.vertexIndices.splice(xe+1,0,[Ue,Ie]),_e.vertices.splice((xe+1)*2,0,_e.vertices[xe*2],_e.vertices[xe*2+1]);break}}}F.push({bevelI:U,angle:J,size:Z,boundary:_e,reverseMap:fe,insetPoints:K})}let Y=(U,J,Z)=>{let K=0,W=U.boundary.vertexIndices.length;for(;K<W&&Z(U.boundary.vertexIndices[J]);)J=(J+1)%W,K++;return K},q=S.length;for(let U=1;U<F.length;U++){let J=F[U-1],Z=F[U],K=J.boundary.vertexIndices.length,W=Z.boundary.vertexIndices.length;if(!K||!W)break;let ye=k.concave.length,fe=0,se=HS(fe,R);for(;!J.boundary.vertexIndices.filter(se).length||!Z.boundary.vertexIndices.filter(se).length;)fe++,se=HS(fe,R);let _e=J.boundary.vertexIndices.findIndex(se),xe=Z.boundary.vertexIndices.findIndex(se);do _e=(_e+1)%K;while(se(J.boundary.vertexIndices[_e]));do xe=(xe+1)%W;while(se(Z.boundary.vertexIndices[xe]));fe=(fe+1)%R;let Oe=fe,Ie=0,Pe=this._buildBevelVert(k,J,(_e-1+K)%K,void 0,Ie),Me=this._buildBevelVert(k,Z,(xe-1+W)%W,void 0,Ie),ze=Pe,Ue=Me,L,O,re=!1;do{Ie=(fe||ye)/ye,se=HS(fe,R);let ue=Y(J,_e,se),me=Y(Z,xe,se),De=re;if(re=!1,ue&&!me){for(let Te=0;Te<ue;Te++)L=this._buildBevelVert(k,J,(_e+Te)%K,Te/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L;re=!0}else if(!ue&&me)for(let Te=0;Te<me;Te++)O=this._buildBevelVert(k,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(Ue.topN,ze.topP,O.topP),l===!1&&S.push(ze.bottomP,Ue.bottomN,O.bottomP),Ue=O;else if(ue&&me)if(L=this._buildBevelVert(k,J,_e,0,Ie),O=this._buildBevelVert(k,Z,xe,0,Ie),De?(S.push(ze.topN,O.topP,Ue.topN),S.push(ze.topN,L.topP,O.topP),l===!1&&(S.push(O.bottomP,ze.bottomN,Ue.bottomN),S.push(O.bottomP,L.bottomP,ze.bottomN))):(S.push(Ue.topN,ze.topN,L.topP),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP))),ze=L,Ue=O,ue===me)for(let Te=1;Te<ue;Te++)L=this._buildBevelVert(k,J,(_e+Te)%K,Te/(ue-1),Ie),O=this._buildBevelVert(k,Z,(xe+Te)%W,Te/(me-1),Ie),S.push(ze.topN,L.topP,Ue.topN),S.push(Ue.topN,L.topP,O.topP),l===!1&&(S.push(L.bottomP,ze.bottomN,Ue.bottomN),S.push(L.bottomP,Ue.bottomN,O.bottomP)),ze=L,Ue=O;else if(ue>me){let Te=ue/me,Ee=0;for(let le=1;le<ue;le++)L=this._buildBevelVert(k,J,(_e+le)%K,le/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L,le>(Ee+1)*Te&&(Ee++,O=this._buildBevelVert(k,Z,(xe+Ee)%W,Ee/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O)}else{let Te=me/ue,Ee=0;for(let le=1;le<me;le++)O=this._buildBevelVert(k,Z,(xe+le)%W,le/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O,le>(Ee+1)*Te&&(Ee++,L=this._buildBevelVert(k,J,(_e+Ee)%K,Ee/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L)}_e=(_e+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(F,k,S),P){let U=[];for(let J=S.length-1;J>=q+2;J-=3){let Z=S[J-2],K=S[J-1],W=S[J-0];U.push(W,K,Z)}S.splice(q,S.length-q,...U)}if(P){let U=[];for(let J=F[F.length-1].boundary.vertices.length-1;J>=1;J-=2){let Z=F[F.length-1].boundary.vertices[J-1],K=F[F.length-1].boundary.vertices[J-0];U.push(Z,K)}A.push(U)}if(!P){let U=F[F.length-1],J;try{J=_s({windingRule:F.length>1?St.POSITIVE:St.ODD,elementType:br.POLYGONS,vertexSize:2,strict:!0,contours:[U.insetPoints,...A]})}catch{J=WS}if(!J)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<J.elementCount*3;Z+=3){let K=this._buildSurfaceVert(J,J.elements[Z+0],j),W=this._buildSurfaceVert(J,J.elements[Z+1],j),ye=this._buildSurfaceVert(J,J.elements[Z+2],j);S.push(K.top,W.top,ye.top),l===!1&&S.push(ye.bottom,W.bottom,K.bottom)}}this.vertexCache={}}this._buffer.shrink();let E=new Ge(Uint32Array.from(S),1),b=new Ge(this._buffer.positions,3),M=new Ge(this._buffer.normals,3),T=new Ge(this._buffer.uvs,2);b.needsUpdate=!0,M.needsUpdate=!0,T.needsUpdate=!0,E.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",M),this.setAttribute("uv",T),this.setIndex(E)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,n){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,u=(a-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),h=c*3,d=c*2,f={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-n,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=u,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=n,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=u),this.vertexCache[s]=f,f}_buildBevelVert(e,r,n,s=1,o){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,u]=r.boundary.vertexIndices[n],c,h,d,f;l!==u?(h=l,c=u,f=!1,d=e.continuous[h]&&e.continuous[c]):(c=l,h=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,d=e.continuous[c]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=n*2,y=c*2,v=h*2,x=r.boundary.vertices[g+0],w=r.boundary.vertices[g+1],S=(1-m)*this._bevel,A=(x-this._minX)/this._width,E=(w-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),E=1);let b=e.normals[y+0],M=e.normals[y+1],T=e.normals[v+0],C=e.normals[v+1];if(f){let V=T-b,k=C-M;b=b+V*(1-s),M=M+k*(1-s);let z=Math.sqrt(b*b+M*M);b/=z,M/=z}let P=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),D=P*3,I=P*2,R={i:n,fi:c,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:o};return this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=b*p,this._buffer.normals[D+1]=M*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=b*p,this._buffer.normals[D+4]=M*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(P+=1,D+=3,I+=2):(P+=2,D+=6,I+=4),R.topP=P+0,R.bottomP=P+1,this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=T*p,this._buffer.normals[D+1]=C*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=T*p,this._buffer.normals[D+4]=C*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=R,R}clone(){let e=new cl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ko(this.userData),e}};var Xh=class extends Ae{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=St.ODD;this.elementType=br.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;p<m;p++){let g=p*2,y=s[g+0],v=s[g+1];if(c!==void 0&&y!==c&&(l=!1),h!==void 0&&v!==h&&(u=!1),c=y,h=v,!l&&!u)break}if(!l&&!u)try{a=_s({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Pp}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let p=1/0,m=-1/0,g=1/0,y=-1/0;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1];E<p&&(p=E),E>m&&(m=E),b<g&&(g=b),b>y&&(y=b)}let v=m-p,x=y-g;for(let w=0,S=d;w<S;w++){let A=w*2,E=a.vertices[A+0],b=a.vertices[A+1],M=(E-p)/v,T=(b-g)/x;this._positionAttribute.setXYZ(w,E,b,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,M,T)}for(let w=0,S=f;w<S;w++){let A=w*3,E=a.elements[A+0],b=a.elements[A+1],M=a.elements[A+2];this._indexAttribute.setX(A+0,E),this._indexAttribute.setX(A+1,b),this._indexAttribute.setX(A+2,M)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Xh(this._shape,this._curveSegments);return e.userData=Ko(this.userData),e}};var Qh=class extends cl{constructor(e,r,n=0,s=12,o=3,a=St.ODD){super(e,r,n,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),u=this._buildBevelVert(r,s,(o+1)%a);n.push(u.topP,l.topN,l.bottomN),n.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Qh(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Ko(this.userData),e}};var yi=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:St.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Ot?(o.width!==r||o.height!==n)&&o.applySize(r,n):o=new Ot(r,n).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Ot(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Xh(i.shape,n,{windingRule:o}):a=new Qh(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var xD=Math.PI*2,Zh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Se.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=W8(u,c,h,n*Math.PI/180,r,s);u.isClosed=!0,u.update();let f;return n===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=yi.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function W8(i,t,e,r,n,s){if(r>=xD)return n>30||n%4===0?(Y8(i,t,e,s),Math.round(n/4)):vD(i,r,n,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},u=cD({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?q8(i,o.x,o.y,u,n,t,e,s):vD(i,r,n,t,e,s)}function q8(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Kh(t,e));for(let u=0,c=r.length;u<c;u++){let h=r[u],d=i.points[u],f=Kh(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?bD(i,s,o,a):i.addPoint(Kh(0,0)),l}function vD(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*r,c=Math.cos(l)*n;i.addPoint(Kh(u,c))}return t<xD?s>0?bD(i,r,n,s):i.addPoint(Kh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&wD(i,r,n,s)),1}function Y8(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Av(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(Av(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(Av(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(Av(n,s-e,n+a,s-e,n-a,s-e)),r>0&&wD(i,t,e,r)}function Kh(i,t){return new As(Se.generateUUID(),new N(i,t))}function Av(i,t,e,r,n,s){let o=Kh(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function bD(i,t,e,r){SD(i,t,e,r).forEach(s=>i.addPoint(s))}function wD(i,t,e,r){let n=SD(i,t,e,r),s=new Ot;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function SD(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new N(n/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Se.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var AD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=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:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Dp(!1,t,e,r,n,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},qS=new js([0,0,0],1),Dp=class extends Ae{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,u=1,c=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 _,m=new _,g=p(),y=p(),v=p(),x,w,S,A,E,b,M,T,C=p(),P=p(),D=p(),I=p(),R=p(),V=p(),k=p(),z=p(),G=r-2*l+.001,H=G/o,Q=Math.ceil(a*o),F=Q+1,j=G/Q,Y=-G/2,q=c+1,U=2*Math.PI/c,J=Math.PI/2/d,Z=.01,K=Math.min((1-h/100)*l,l-Z),W=l-K,ye=0,fe=2,se=d*fe+fe,_e=q*se/fe,xe=_e+q*F,Oe=Math.max(0,q*(F+se)),[Ie,Pe,Me]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),ze=[],Ue=s-l;function L(ke,Ne){let We=Math.PI/2;b=Ne*j,T=2*Math.PI*(b%H)/H+We,b+=Y,M=Math.sin(T)*Ue,E=Math.cos(T)*Ue,t?ke.set(E,M,b):ke.set(E,b,M)}L(m,-1e-10),L(g,0),C.copy(m),L(m,1);let O=m.distanceTo(g),re=f?0:W+K,ue=O*Q+2*re,me=K,De=ue-re;for(let ke=0;ke<=Q;ke++){L(y,ke),z.subVectors(y,C).normalize(),C.copy(y),V.copy(y).setComponent(+t+1,0).normalize(),k.crossVectors(z,V).normalize();let Ne=ke===0,We=ke===Q,$e=Ne?3*Math.PI/2:J,_t=Ne?me:De,ir=Ne?q:xe,Gr=Ne?0:Oe-q,X=z.clone().multiplyScalar(Ne?-W:W).add(y),ce=z.clone().multiplyScalar(Ne?-1:1).normalize();for(let ve=0;ve<q;ve++){let Ve=ve*U;if(P.addVectors(m.copy(V).multiplyScalar(l*Math.cos(Ve)),g.copy(k).multiplyScalar(l*Math.sin(Ve))),D.copy(P).normalize(),Ne||We){f||(ye=Gr+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=X.getComponent(Fe),Pe[ye*3+Fe]=ce.getComponent(Fe)}),Me[ye*2]=+We,Me[ye*2+1]=ve/c),g.copy(D).multiplyScalar(K),v.addVectors(y,g);for(let Fe=0;Fe<d;Fe++){let Et=Fe*J+$e;I.addVectors(m.copy(z).multiplyScalar(W*Math.sin(Et)),g.copy(D).multiplyScalar(W*Math.cos(Et))),R.copy(I).normalize(),g.addVectors(v,I),I.normalize(),ye=ir+Fe*q+ve,[0,1,2].forEach(Pr=>{Ie[ye*3+Pr]=g.getComponent(Pr),Pe[ye*3+Pr]=R.getComponent(Pr)});let Hr=+Ne+Math.sin(Et);Me[ye*2]=(_t+W*Hr)/ue,Me[ye*2+1]=ve/c}}g.addVectors(y,P),ye=_e+ke*q+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=g.getComponent(Fe),Pe[ye*3+Fe]=D.getComponent(Fe)}),Me[ye*2]=(re+ke*O)/ue,Me[ye*2+1]=ve/c}}let Te=F+2*d+fe,Ee=1,[le,Ke]=[+f,Te-1];for(let ke=le;ke<=Ke-1;ke++){let Ne=f&&ke===Ke-1;for(let We=0;We<q-1;We++)x=ke*q+We,w=x+1,S=(Ne?We:x)+q,A=(Ne?We+1:w)+q,ke===0?ze.push(w,A,S):ke===Te-2?ze.push(x,w,S):ze.push(x,w,S,w,A,S)}this.setIndex(ze),this.setAttribute("position",new be(Ie,3)),this.setAttribute("normal",new be(Pe,3)),this.setAttribute("uv",new be(Me,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,n=Array.from(this.getIndex().array),s,o,a,l,u=6*(e-1)*t.radialSegments,c=e,h=c===e;for(let d=0;d<t.radialSegments;d++)s=c*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,n[u++]=s,n[u++]=o,n[u++]=a,n[u++]=o,n[u++]=l,n[u++]=a;return n.length=u,qS.array=n,qS.count=n.length,qS}};var _D=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Ip(t*.5,s,o):new gu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},Ip=class extends ol{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new Ip(t.radius,t.corner,t.cornerSides)}};var ED=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new jo;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new hu(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var oo=new ie,YS=new gt,_v=new _,ul=class extends Yt{constructor(){super(),this.uuid=Se.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 Gt().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return oo.makeRotationX(t),this.applyMatrix4(oo),this}rotateY(t){return oo.makeRotationY(t),this.applyMatrix4(oo),this}rotateZ(t){return oo.makeRotationZ(t),this.applyMatrix4(oo),this}translate(t,e,r){return oo.makeTranslation(t,e,r),this.applyMatrix4(oo),this}scale(t,e,r){return oo.makeScale(t,e,r),this.applyMatrix4(oo),this}lookAt(t){return YS.lookAt(t),YS.updateMatrix(),this.applyMatrix4(YS.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,n=t.attributes;if(n.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=n.position,o=n.normal,a=n.color,l=n.uv,u=n.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new _().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new Re().fromBufferAttribute(a,d));function c(d,f,p,m){let g=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],y=o===void 0?[]:[new _().fromBufferAttribute(o,d),new _().fromBufferAttribute(o,f),new _().fromBufferAttribute(o,p)],v=new Jh(d,f,p,y,g,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new N().fromBufferAttribute(l,d),new N().fromBufferAttribute(l,f),new N().fromBufferAttribute(l,p)]),u!==void 0&&e.faceVertexUvs[1].push([new N().fromBufferAttribute(u,d),new N().fromBufferAttribute(u,f),new N().fromBufferAttribute(u,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,m=f.count;for(let g=p,y=p+m;g<y;g+=3)r!==void 0?c(r.getX(g),r.getX(g+1),r.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)c(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_v).negate(),this.translate(_v.x,_v.y,_v.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,n=new ie;return n.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){let t=new _,e=new _;for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,n=this.vertices.length;r<n;r++)e[r]=new _;if(t){let r=new _,n=new _;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];r.subVectors(c,u),n.subVectors(l,u),r.cross(n),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,n=this.vertices.length;r<n;r++)e[r].normalize();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],n=r.vertexNormals;n.length===3?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(let s=0,o=n.vertexNormals.length;s<o;s++)n.__originalVertexNormals[s]?n.__originalVertexNormals[s].copy(n.vertexNormals[s]):n.__originalVertexNormals[s]=n.vertexNormals[s].clone()}let t=new ul;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new _,c={a:new _,b:new _,c:new _};s.push(u),o.push(c)}}let n=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=n.faceNormals[s],u=n.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new fr),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let n,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,u=t.faces,c=this.colors,h=t.colors;e!==void 0&&(n=new Gt().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let m=a[d].clone();e!==void 0&&m.applyMatrix4(e),o.push(m)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let p=u[d],m,g,y=p.vertexNormals,v=p.vertexColors,x=new Jh(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),n!==void 0&&x.normal.applyMatrix3(n).normalize();for(let w=0,S=y.length;w<S;w++)m=y[w].clone(),n!==void 0&&m.applyMatrix3(n).normalize(),x.vertexNormals.push(m);x.color.copy(p.color);for(let w=0,S=v.length;w<S;w++)g=v[w],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++)v.push(y[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],n=[],s=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),n[l]=r.length-1):n[l]=n[e[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=n[c.a],c.b=n[c.b],c.c=n[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let n=t[e];this.vertices.push(new _(n.x,n.y,n.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,u){return l.materialIndex-u.materialIndex}t.sort(r);let n=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;n&&n.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let u=t[l]._id;o&&o.push(n[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let m in p)p[m]!==void 0&&(t[m]=p[m]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let m=this.vertices[p];e.push(m.x,m.y,m.z)}let r=[],n=[],s={},o=[],a={},l=[],u={};for(let p=0;p<this.faces.length;p++){let m=this.faces[p],g=!0,y=!1,v=this.faceVertexUvs[0][p]!==void 0,x=m.normal.length()>0,w=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,E=0;if(E=c(E,0,0),E=c(E,1,g),E=c(E,2,y),E=c(E,3,v),E=c(E,4,x),E=c(E,5,w),E=c(E,6,S),E=c(E,7,A),r.push(E),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)),w){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(S&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function c(p,m,g){return g?p|1<<m:p&~(1<<m)}function h(p){let m=p.x.toString()+p.y.toString()+p.z.toString();return s[m]!==void 0||(s[m]=n.length/3,n.push(p.x,p.y,p.z)),s[m]}function d(p){let m=p.r.toString()+p.g.toString()+p.b.toString();return a[m]!==void 0||(a[m]=o.length,o.push(p.getHex())),a[m]}function f(p){let m=p.x.toString()+p.y.toString();return u[m]!==void 0||(u[m]=l.length/2,l.push(p.x,p.y)),u[m]}return t.data={},t.data.vertices=e,t.data.normals=n,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new ul().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let n=t.faces;for(let d=0,f=n.length;d<f;d++)this.faces.push(n[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,g=p.length;m<g;m++){let y=p[m],v=[];for(let x=0,w=y.length;x<w;x++){let S=y[x];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let m=0,g=s[d].vertices.length;m<g;m++)p.vertices.push(s[d].vertices[m].clone())}if(s[d].normals!==void 0){p.normals=[];for(let m=0,g=s[d].normals.length;m<g;m++)p.normals.push(s[d].normals[m].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let m=0,g=o[d].vertexNormals.length;m<g;m++){let y=o[d].vertexNormals[m],v={};v.a=y.a.clone(),v.b=y.b.clone(),v.c=y.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let m=0,g=o[d].faceNormals.length;m<g;m++)p.faceNormals.push(o[d].faceNormals[m].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=t.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new XS().fromGeometry(this),e=new Ae,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ev.call(new Ge(r,3),t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ev.call(new Ge(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",MD.call(new Ge(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",TD.call(new Ge(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",TD.call(new Ge(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new be(u.data.length*3,3);c.name=u.name,s.push(Ev.call(c,u.data))}e.morphAttributes[n]=s}if(t.skinIndices.length>0){let n=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",CD.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",CD.call(n,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 Ae,r=t.geometry;if(t.isPoints||t.isLine){let n=new be(r.vertices.length*3,3),s=new be(r.colors.length*3,3);if(e.setAttribute("position",Ev.call(n,r.vertices)),e.setAttribute("color",MD.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new be(r.lineDistances.length,1);e.setAttribute("lineDistance",X8.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}};ul.prototype.isGeometry=!0;var XS=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,n,s,o=t.faces;for(n=0;n<o.length;n++){let a=o[n];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=n*3-r.start,e.push(r)),r={start:n*3,materialIndex:s})}r!==void 0&&(r.count=n*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,n=t.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y<l;y++)u[y]={name:a[y].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,h=c.length,d;if(h>0){d=[];for(let y=0;y<h;y++)d[y]={name:c[y].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,m=f.length===r.length,g=p.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y<e.length;y++){let v=e[y];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=n[0][y];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),this.uvs.push(new N,new N,new N))}if(o===!0){let S=n[1][y];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),this.uvs2.push(new N,new N,new N))}for(let S=0;S<l;S++){let A=a[S].vertices;u[S].data.push(A[v.a],A[v.b],A[v.c])}for(let S=0;S<h;S++){let A=c[S].vertexNormals[y];d[S].data.push(A.a,A.b,A.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Jh=class{constructor(t,e,r,n,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new _,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new Re,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function X8(i){return this.array.set(i),this}function MD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new Re),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function TD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new N),t[e++]=s.x,t[e++]=s.y}return this}function Ev(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new _),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function CD(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Xe),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var Q8=["a","b","c"];function K8(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function QS(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),s=r+"_"+n;return e.get(s)}function KS(i,t,e,r,n,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,u;if(r.has(l))u=r.get(l);else{let c=e[o],h=e[a];u={a:c,b:h,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(n),s[i].edges.push(u),s[t].edges.push(u)}function Z8(i,t,e,r){let n,s,o;for(n=0,s=i.length;n<s;n++)e[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],KS(o.a,o.b,i,r,o,e),KS(o.b,o.c,i,r,o,e),KS(o.c,o.a,i,r,o,e)}function Mv(i,t,e,r,n){i.push(new Jh(t,e,r,void 0,void 0,n))}function $h(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function Tv(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Cv=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ae?t=new ul().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new _,r,n,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;Z8(l,u,d,f);let p=[],m,g,y,v,x,w,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),y=new _,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(m=l[K8(v,Q8[a])],!(m!==g.a&&m!==g.b));a++);m&&e.add(m)}e.multiplyScalar(w),y.add(e),g.newEdge=p.length,p.push(y)}let A,E,b,M,T,C,P,D=[];for(n=0,s=l.length;n<s;n++){for(C=l[n],T=d[n].edges,r=T.length,r==3?A=3/16:r>3&&(A=3/(8*r)),E=1-r*Number(A),b=A,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),P=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<r;o++)M=T[o],m=M.a!==C?M.a:M.b,e.add(m);e.multiplyScalar(Number(b)),P.add(e),D.push(P)}let I=D.concat(p),R=D.length,V,k,z,G=[],H=[],Q,F,j,Y,q=new N,U=new N,J=new N;for(n=0,s=u.length;n<s;n++)v=u[n],V=Number(QS(v.a,v.b,f).newEdge)+R,k=Number(QS(v.b,v.c,f).newEdge)+R,z=Number(QS(v.c,v.a,f).newEdge)+R,Mv(G,V,k,z,v.materialIndex),Mv(G,v.a,V,z,v.materialIndex),Mv(G,v.b,k,V,v.materialIndex),Mv(G,v.c,z,k,v.materialIndex),h&&(Q=c[n],F=Q[0],j=Q[1],Y=Q[2],q.set($h(F.x,j.x),$h(F.y,j.y)),U.set($h(j.x,Y.x),$h(j.y,Y.y)),J.set($h(F.x,Y.x),$h(F.y,Y.y)),Tv(H,q,U,J),Tv(H,F,q,J),Tv(H,j,U,q),Tv(H,Y,J,U));t.vertices=I,t.faces=G,h&&(t.faceVertexUvs[0]=H)}};var ln=new _,PD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ae().copy(new yn(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ln),r={width:ln.x,height:ln.y,depth:ln.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,s=i.geometry??new Ae().copy(new yn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(ln)):ln.set(o.width,o.height,o.depth),(t!==ln.x||e!==ln.y||r!==ln.z)&&s.scale(ln.x===0?1:t/ln.x,ln.y===0?1:e/ln.y,ln.z===0?1:r/ln.z);let a=s.originalGeometry;try{n>0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new Cv(n).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 i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new _u(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(ln);let o=100/ln.x;Object.assign(s.parameters,{width:100,height:ln.y*o,depth:ln.z*o}),t(this.build(s))})}};var Pv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let g=f*m,y=h+Math.sin(g)*u,v=d+Math.cos(g)*c;l.addPoint(l.createPoint(y,v))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=n;l.roundness=n,l.update();let p=yi.create({shape:l,parameters:{roundness:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var DD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=new JS(t*.5,e,n,s,o,a,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...i,type:"PyramidGeometry"}})}};function Op(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function ZS(i,t,e,r,n,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===n){let u=o.add(a).normalize();s.copy(i).addScaledVector(u,r/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(i),s.addScaledVector(o,n/Math.sin(u)),s.addScaledVector(a,r/Math.sin(u))}}function J8(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var JS=class extends Ae{constructor(t=.5,e=1,r=4,n=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=e/2,p=Math.PI/r,m=t*Math.cos(Math.PI/r),g=2*Math.PI/r,y=(r-2)*Math.PI/r,v=Math.PI-y,x=new _(0,-f,0),w=new _(0,f,0),S=new N(t,-f),A=new N(m,-f),E=new N(0,w.y).sub(A),b=new N(0,w.y).sub(S),M=new N(E.y,-E.x).normalize(),T=new N(b.y,-b.x).normalize(),P=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,P);let D;{let H=new _(M.x,M.y,0),Q=new _(Math.cos(g)*H.x,H.y,Math.sin(g)*H.x);D=H.angleTo(Q)}let I=o/Math.tan((Math.PI-E.angle())/2),R=o/Math.tan((Math.PI-D)/2),V=new _;if(!s){u.push(x.x,x.y,x.z),c.push(0,-1,0),h.push(0,0);let H=d++,Q=[],F=S.clone(),j=I/Math.cos(Math.PI/r);F.x-=j;for(let Y=0;Y<r;Y++){let q=Y/r*Math.PI*2+p,U=new N(Math.sin(q),Math.cos(q));Op(F,U,V),u.push(V.x,V.y,V.z),c.push(0,-1,0),h.push(0,0),Q.push(d++)}for(let Y=0;Y<Q.length;Y++)l.push(Q[Y],H,Q[(Y+1)%Q.length])}let k=[];{let H=new _,Q=new _,F=new _,j=new _,Y=new _,q=new _;for(let U=0;U<r;U++){let J=U/r*Math.PI*2+p,Z=(U+.5)/r*Math.PI*2+p,K=(U+1)/r*Math.PI*2+p,W=new N(Math.sin(J),Math.cos(J)),ye=new N(Math.sin(Z),Math.cos(Z)),fe=new N(Math.sin(K),Math.cos(K));Op(S,W,Q),Op(S,fe,F),Op(M,ye,H),ZS(w,Q,F,R,R,j),u.push(j.x,j.y,j.z),ZS(Q,w,F,R,I,Y),u.push(Y.x,Y.y,Y.z),ZS(F,Q,w,I,R,q),u.push(q.x,q.y,q.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),c.push(H.x,H.y,H.z),h.push(0,0),h.push(0,0),h.push(0,0);let se=d++,_e=d++,xe=d++;if(l.push(se,_e,xe),o>0){{let Pe=Q.clone().add(F).multiplyScalar(.5),Me=w.clone().sub(Pe).normalize(),Ue=x.clone().sub(Pe).normalize().add(Me).normalize().multiplyScalar(-1),L=q.clone().sub(Y);z(Pe,L,Ue,E.angle())}let Oe,Ie;{let Pe=new _;Op(T,fe,Pe);let Me=q.clone().add(j).multiplyScalar(.5);Me=J8(Me,F,w);let ze=q.clone().sub(j);[Oe,Ie]=z(Me,ze,Pe,D,j.y)}{let Pe=Oe,Me=Pe.clone().setY(0).normalize(),ze=new _(0,-1,0),Ue=Me.clone().cross(ze);G(Pe,Me,ze,Ue)}k.concat(Ie);{let Pe=E.angle(),Me=Math.PI-Pe,ze=w.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let Ue=new _,L=[];for(let re=0;re<a;re++){let ue=[],me=Math.PI/2-Me*re/a,De=Math.cos(me),Te=Math.sin(me),Ee=Z;for(let le=0;le<=re;le++){let Ke=Math.cos(Ee),ke=Math.sin(Ee);H.x=De*ke,H.y=Te,H.z=De*Ke,Ue.copy(ze).addScaledVector(H,o),u.push(Ue.x,Ue.y,Ue.z),c.push(H.x,H.y,H.z),h.push(0,0),ue.push(d++),Ee+=Math.PI*2/re/r}L.push(ue)}Ie.reverse(),L.push(Ie);let O=L.length-1;for(let re=0;re<O;re++){let ue=L[re],me=L[re+1],De=ue.length-1;l.push(me[1],ue[0],me[0]);for(let Te=1;Te<=De;Te++)l.push(ue[Te],ue[Te-1],me[Te]),l.push(me[Te+1],ue[Te],me[Te])}}}}}this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function z(H,Q,F,j,Y){let q=-j/2,U=(Math.PI-j)/2,J=Q.clone().normalize().cross(F);H.addScaledVector(F,-o/Math.sin(U));let Z=new _,K=new _,W=1,ye=d,fe=[];for(let se=0;se<=a;se++){let _e=q+se/a*j;K.set(0,0,0),K.addScaledVector(J,Math.sin(_e)),K.addScaledVector(F,Math.cos(_e));for(let xe=0;xe<=W;xe++){let Oe=xe/W-.5;if(Z.copy(H),Z.addScaledVector(Q,Oe),Z.addScaledVector(K,o),Y!=null){let Ie=Math.max(0,Z.y-Y);Z.addScaledVector(Q,-Ie/Q.y)}u.push(Z.x,Z.y,Z.z),c.push(K.x,K.y,K.z),h.push(0,0),xe===0&&fe.push(d),d++}}for(let se=0;se<a;se++)for(let _e=0;_e<W;_e++){let xe=ye+_e+(W+1)*se,Oe=xe+(W+1),Ie=Oe+1,Pe=xe+1;l.push(xe,Oe,Pe),l.push(Oe,Ie,Pe)}return[H.clone().addScaledVector(Q,.5),fe]}function G(H,Q,F,j){let Y=Math.PI/2,q=b.angle()-Y,U=[],J=new _,Z=new _;for(let W=0;W<=a;W++){let ye=[],fe=W/a;for(let se=0;se<=W;se++){let xe=((W?se/W:0)-.5)*v,Oe=Math.cos(xe),Ie=Math.sin(xe),Pe=Math.atan(Math.tan(q)*Oe),Me=(Y+Pe)*fe,ze=Math.cos(Me),Ue=Math.sin(Me);J.set(0,0,0),J.addScaledVector(Q,Ue*Oe),J.addScaledVector(F,ze),J.addScaledVector(j,Ue*Ie),Z.copy(H).addScaledVector(J,o),u.push(Z.x,Z.y,Z.z),c.push(J.x,J.y,J.z),h.push(0,0),ye.push(d++)}U.push(ye)}let K=U.length-1;for(let W=0;W<K;W++){let ye=U[W],fe=U[W+1],se=ye.length-1;l.push(ye[0],fe[1],fe[0]);for(let _e=1;_e<=se;_e++)l.push(ye[_e-1],ye[_e],fe[_e]),l.push(ye[_e],fe[_e+1],fe[_e])}}}};var Dv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(w,S,A){return S>e&&A>r?Math.min(w*e/S,w*r/A):S>e?w*e/S:A>r?w*r/A:w}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=c.x,m=h.x,g=h.y,y=c.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 w=0,S=t.points.length;w<S;w++)t.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=yi.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var ID=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Se.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(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Ql(.5*t,n,s,o,a,l,u*Se.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var OD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new Ho(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var RD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new $S(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},$S=class extends Ae{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-c,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(Z=0,K=0,W=0)=>new _(Z,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,w=+y,[S,A,E]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(Z,K=!1)=>Math.sin(Z-Math.PI/(1+ +K)),M=(Z,K=!1)=>Math.cos(Z-Math.PI/(1+ +K));E.y=Math.sin(n)*e-g;let T=Math.cos(n)*e-v,C=S.z-c;n<=d?(E.z=Math.min(T,C),E.z==C&&(E.y-=(T-C)/Math.tan(d-n))):A.z=Math.min(A.z-T-v,S.z-c),p.subVectors(S,A),m.subVectors(E,A);let P=Math.min(p.length(),m.length())*s/100,D=P*Math.tan(n/2),I=P/Math.cos(n/2),R=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(n,!0),M(n,!0)),h.push([E,p.clone()]);let V=(Math.PI-n)/o;for(let Z=0;Z<=o;Z++){let K=d+n+Z*V;p.set(0,Math.sin(K)*D,Math.cos(K)*D),p.add(R),m.set(0,b(K),M(K)),h.push([p.clone(),m.clone()])}h.push([S,f(0,1,0)]);let k=Math.sin(V/2)*D*2,z=h.length-1,G=h[0][0].distanceTo(h[1][0]),H=h[z-1][0].distanceTo(h[z][0]),Q=G+k*o+H;h[0].push(1);for(let Z=0;Z<=o;Z++)h[Z+1].push(1-(G+Z*k)/Q);h[z].push(0);let[F,j,Y]=h[0],q,U,J;for(let Z=1;Z<h.length;Z++)[q,U,J]=h[Z],a.push(x,F.y,F.z,x,q.y,q.z,w,F.y,F.z,w,F.y,F.z,x,q.y,q.z,w,q.y,q.z),l.push(0,j.y,j.z,0,U.y,U.z,0,j.y,j.z,0,j.y,j.z,0,U.y,U.z,0,U.y,U.z),u.push(0,Y,0,J,1,Y,1,Y,0,J,1,J),[F,j,Y]=[q,U,J];this.setAttribute("position",new be(a,3)),this.setAttribute("normal",new be(l,3)),this.setAttribute("uv",new be(u,2))}};var Iv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=i.parameters,c=i.shape,h=t*.5,d=e*.5,f=0,p=0,m=o*Math.PI/360/n,g=Math.PI/2*3*-1,y=h*r/100,v=d*r/100;if(n===3&&r===50){m=2*Math.PI/n;for(let w=0;w<n;w++){let S=m*w,A=f+Math.sin(S)*h,E=p+Math.cos(S)*d;c.addPoint(c.createPoint(A,E))}}else for(let w=0;w<n;w++){let S=f+Math.cos(g)*h,A=p+Math.sin(g)*d;c.addPoint(c.createPoint(S,A)),g+=m,S=f+Math.cos(g)*y,A=p+Math.sin(g)*v,w<=n,c.addPoint(c.createPoint(S,A)),g+=m}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let x=yi.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var LD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new Ho(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var ND=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:s})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,u=$8(t,e,r,t*.5,o,s,0,0,n,a,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...i,type:"TorusGeometry"}})}};function $8(i,t,e,r,n,s,o,a,l,u,c){[t,e]=[e,t],o=t/2;let h=Se.clamp(n/360,0,1);if(h===0){let d=new Ae;return d.setAttribute("position",new be([],3)),d}return h===1&&(u=0),new Dp(!0,i,t,e,r,h,s,o,a,l,u,c)}var BD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new yu(a,e,r,n,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var FD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=yi.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function kD(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var eA=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},tA=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,r){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,r?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}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 ae(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 ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.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(ae.hooks[t]){let r={context:this,node:e};return ae.hooks.run(t,r),r.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.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:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===ae.SEMCOL_CODE||r===ae.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ae.max_binop_len),e=t.length;for(;e>0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,s,o,a,l,u;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ae.binaryPrecedence(e),right_a:ae.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),n=[o,s,a];e=this.gobbleBinaryOp();){if(r=ae.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:ae.right_associative.has(e)},u=e;let c=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&c(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ae.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),r=e.length;r>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ae.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ae.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}ae.isIdentifierStart(t)?(n=this.gobbleIdentifier(),ae.literals.hasOwnProperty(n.name)?n={type:ae.LITERAL,value:ae.literals[n.name],raw:n.name}:n.name===ae.this_str&&(n={type:ae.THIS_EXP})):t===ae.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ae.PERIOD_CODE||e===ae.OBRACK_CODE||e===ae.OPAREN_CODE||e===ae.QUMARK_CODE;){let r;if(e===ae.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ae.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ae.OBRACK_CODE?(t={type:ae.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ae.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ae.OPAREN_CODE?t={type:ae.CALL_EXP,arguments:this.gobbleArguments(ae.CPAREN_CODE),callee:t}:(e===ae.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:ae.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ae.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ae.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ae.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,ae.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===ae.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ae.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ae.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){n=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
|
3153 | `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:ae.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(ae.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ae.isIdentifierPart(t));)this.index++;return{type:ae.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){r=!0,this.index++,t===ae.CPAREN_CODE&&n&&n>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o<n;o++)e.push(null)}}else if(e.length!==n&&n!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ae.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ae.CPAREN_CODE);if(this.code===ae.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ae.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ae.ARRAY_EXP,elements:this.gobbleArguments(ae.CBRACK_CODE)}}},eq=new eA;Object.assign(ae,{hooks:eq,plugins:new tA(ae),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var pc=i=>new ae(i).parse(),tq=Object.getOwnPropertyNames(ae);tq.forEach(i=>{pc[i]===void 0&&i!=="prototype"&&(pc[i]=ae[i])});pc.Jsep=ae;var rq="ConditionalExpression",nq={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:rq,test:r,consequent:n,alternate:s},r.operator&&i.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&i.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 :")}})}};pc.plugins.register(nq);var iq=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],sq=["0","1","2","3","4","5","6","7","8","9","."],oq=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function aq(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}pc.addBinaryOp("^",11,!0);function Ov(i,t,e="number"){let r="";for(let o=0;o<i.length;o++){let a=i[o];if("id"in a){let l=i[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",i);return}let u=t.getVariable(a.id),c=En.getDisplayedValue(u);e==="number"&&En.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&En.isBoolean(u)?c=u?"true":"false":e==="boolean"&&En.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),r+=c;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"&&!aq(a.name)&&!sq.includes(a.name)&&!iq.includes(a.name)&&!oq.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=pc(r)}catch(o){console.error(r,o);return}let s;try{s=Dt(n)}catch(o){console.error(r,n,o)}return s}function Dt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Dt(i.left)===Dt(i.right));case"!=":return Number(Dt(i.left)!==Dt(i.right));case">":return Number(Dt(i.left)>Dt(i.right));case">=":return Number(Dt(i.left)>=Dt(i.right));case"<":return Number(Dt(i.left)<Dt(i.right));case"<=":return Number(Dt(i.left)<=Dt(i.right));case"+":return Dt(i.left)+Dt(i.right);case"-":return Dt(i.left)-Dt(i.right);case"*":return Dt(i.left)*Dt(i.right);case"/":return Dt(i.left)/Dt(i.right);case"%":return Dt(i.left)%Dt(i.right);case"&&":return Dt(i.left)&&Dt(i.right);case"||":return Dt(i.left)||Dt(i.right);case"^":return Math.pow(Dt(i.left),Dt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-Dt(i.argument);case"!":return Number(!Dt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=Dt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=Dt(i.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[i.callee.name].apply(null,i.arguments.map(Dt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var lq=new ie,cq=new ie;function uq(i,t,e){let r=[new _,new _,new _],n=[new _,new _,new _];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((s,o)=>{let a=n[o],l=Se.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ie().makeBasis(r[0],r[1],r[2])}var VD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Zh.create({parameters:Zw}).userData.shape;return{path:i.path??mh.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:s,extrusion:{...Xy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new rA(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ae,{userData:{...i,type:"PathGeometry"}})}},rA=class extends Ae{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)||!kD(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:n,offset:s}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,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((n+s)*o):Math.ceil(Math.min(1,n+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],h=[];for(let G=0;G<u;G++){let H=this.inputs.path.isClosed?(G+a)%e.length:Math.min(G+a,e.length-1);c.push(e[H].clone()),h.push(r[H].clone())}let d=(G,H,Q)=>{c[G]=c[G].clone().lerp(c[H],Q),h[G]=uq(h[G],h[H],Q)},f=0,p=s*o%1;(!this.inputs.path.isClosed||n<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+n)*o%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&s+n<1)&&g&&(m=g,d(c.length-1,c.length-2,1-m)),n===0){let G=c.length-1;c[G].copy(c[0]),h[G].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",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:A,vertices:E}=this._computeShapePoints(w),b=0,M;x==="round"&&(M=new cl(this.inputs.shapeData,2*y,y,w,v,void 0,!0),b=M.getAttribute("position").count);let T=0,C=0;A.sort((G,H)=>G.start-H.start),A.forEach(G=>{G.verticesStart=T,G.verticesCount=G.continuous.reduce((H,Q,F)=>H+(F===0||!Q?2:1),0),C+=G.verticesCount,T=C});let P=C*u,D,I=0;if(this._isOpenEnded()&&x==="flat"){try{D=_s({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{D=WS}I=D.vertexCount}let R=P+2*I+b*2,V=P+2*I,k={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},z=[];if(A.forEach(G=>{this._extrudeRegion(G,E,h,c,k,z,this._isGeometryClosed()&&!this._isOpenEnded())}),D&&(this._closeEnd(D,P,z,k,h[0],c[0],!1),this._closeEnd(D,P+I,z,k,h[h.length-1],c[c.length-1],!0)),M){k.positions.set(M.getAttribute("position").array,V*3),k.normals.set(M.getAttribute("normal").array,V*3),k.uvs.set(M.getAttribute("uv").array,V*2);let G=z.length;z.push(...M.getIndex().array.map(F=>F+V)),V+=b,k.positions.set(M.getAttribute("position").array,V*3),k.normals.set(M.getAttribute("normal").array,V*3),k.uvs.set(M.getAttribute("uv").array,V*2);let H=z.length;z.push(...M.getIndex().array.map(F=>F+V)),this.setAttribute("position",new Ge(k.positions,3)),this.setAttribute("normal",new Ge(k.normals,3)),this.setAttribute("uv",new Ge(k.uvs,2)),this.setIndex(z);let Q=lq;Q.copy(h[h.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(Q,V,R),Q.copy(h[0]).setPosition(c[0]).multiply(cq.makeScale(1,1,-1)),this.applyMatrix4OnRange(Q,V-b,V),this.reverseIndicesOnRange(G,H)}else this.setAttribute("position",new Ge(k.positions,3)),this.setAttribute("normal",new Ge(k.normals,3)),this.setAttribute("uv",new Ge(k.uvs,2)),this.setIndex(z)}_extractPathPoints(){let r=yv(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let n=[r[0]];return r.forEach(o=>{n[n.length-1].distanceToSquared(o)>.001&&n.push(o)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],n=e.length,s=this.inputs.path.isClosed,o=new _,a=new _,l=new _,u=new _,c=new _(0,1,0);for(let g=0;g<n;g++){let y=e[g],v;g===0?v=s?e[e.length-2]:y.clone().multiplyScalar(2).sub(e[1]):v=e[g-1];let x;g===n-1?x=s?e[1]:y.clone().multiplyScalar(2).sub(e[g-1]):x=e[g+1];let w=y.clone().sub(v).normalize(),S=x.clone().sub(y).normalize(),A=w.clone().add(S).normalize();l.copy(A),g===0&&(A.equals(c)||A.clone().negate().equals(c))&&c.set(0,0,1);let E=c.clone().cross(A).normalize(),b=A.clone().cross(E).normalize();c.copy(b),u.copy(E),g===0&&(o.copy(b),a.copy(A));let M=new ie().makeBasis(E,b,A);r.push(M)}let h=s?a:l,d=s?o:new _(0,1,0),f=h.clone().cross(u).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return r;let m=d.clone().cross(f);h.dot(m)>0&&(p*=-1);for(let g=1;g<r.length;g++){let y=new ie().makeRotationZ(p*g/r.length);r[g].multiply(y)}return r}_applyPathModifiers(e,r,n){let s=e.length,{angle:o,twist:a,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new ie,h=new ie;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-r)/(s-(n===0?0:1)-(r+(1-n)));c.makeRotationZ(Se.lerp(o,o+a,p)*Se.DEG2RAD);let m=Se.lerp(l,u,p);h.makeScale(m,m,m),d.multiply(c).multiply(h)}),e}_computeShapePoints(e=12,r=St.ODD){let n=this.inputs.shapeData,s=n.extractShapePointsToFlatArray([],e),o=n.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=_s({windingRule:r,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Pp}let l;try{l=_s({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=jS}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let g=l.elements[m],y=m%2===0?a.vertexCount:0;a.elements.push(g+y)}for(let m=0;m<l.vertexIndices.length;m++){let g=l.vertexIndices[m],y=a.vertexCount;a.vertexIndices.push(g+y)}for(let m=0;m<l.vertices.length;m++){let g=l.vertices[m];a.vertices.push(g)}}let c=1/0,h=-1/0,d=1/0,f=-1/0;for(let m=0,g=a.vertexCount;m<g;m++){let y=m*2,v=a.vertices[y+0],x=a.vertices[y+1];v<c&&(c=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=u,y=m*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(S);let A=v,E=w-1,b=v+1,M=n.roundedCurves.length;do{let T=A-v,C=a.vertices[E*2+0],P=a.vertices[E*2+1],D=a.vertices[A*2+0],I=a.vertices[A*2+1],R=a.vertices[b*2+0],V=a.vertices[b*2+1],k=D-C,z=I-P,G=Math.sqrt(k*k+z*z);k/=G,z/=G;let H=D-R,Q=I-V,F=Math.sqrt(H*H+Q*Q);H/=F,Q/=F,S.normals[T*2+0]=-Q,S.normals[T*2+1]=H;let j=a.vertexIndices[A];if(Array.isArray(j))S.continuous[T]=!1;else{let[Y,q]=n.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)S.continuous[T]=!0;else{let U=q===1?Y+1:Y-1;U=(U+M)%M;let J=q===1?0:1,Z=n.roundedCurves[Y].getTangent(q),K=n.roundedCurves[U].getTangent(J);S.continuous[T]=Z.dot(K)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[E,A,b]=[A,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,n,s,o){let a=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.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,n,s,o,a,l){let u=new _,c=new _,h=new _,d=new _,f=new N;n.forEach((m,g)=>{let y=s[g],v=e.verticesStart*n.length+e.verticesCount*g;for(let x=0;x<e.count;x++){let w=(e.start+x)*2;if(u.set(r[w+0],r[w+1],0),h.copy(u).applyMatrix4(m).add(y),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x===0?(e.start+e.count-1)*2:w-2;c.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(x===0?1:x/e.count,g/(n.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,g/(n.length-1));else{let S=x===e.count-1?e.start*2:w+2;c.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=n.length-1;for(let m=0;m<p;m++){let g=e.verticesStart*n.length+e.verticesCount*m,y=e.verticesStart*n.length+e.verticesCount*(m+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let w=x===e.count-1?0:v+1,S=g+v,A=g+w,E=y+w,b=y+v;e.isHole?a.push(S,E,A,S,b,E):a.push(S,A,E,S,E,b),v++}}}_closeEnd(e,r,n,s,o,a,l){let u=e.vertexCount,c=new _(0,0,l?-1:1).applyMatrix4(o),h=new _,d=new N;for(let p=0;p<u;p++){let m=2*p;h.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+p,h,c,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let m=3*p,g=f[m+0]+r,y=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;n.push(g,y,v)}}applyMatrix4OnRange(e,r,n){let s=e.elements,o=new Gt().getNormalMatrix(e).elements,a,l,u,c,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,m=h.itemSize;for(let g=r*m,y=n*m;g<y;g+=m){if(g===r)debugger;a=f[g+0],l=f[g+1],u=f[g+2],c=1/(s[3]*a+s[7]*l+s[11]*u+s[15]),f[g+0]=(s[0]*a+s[4]*l+s[8]*u+s[12])*c,f[g+1]=(s[1]*a+s[5]*l+s[9]*u+s[13])*c,f[g+2]=(s[2]*a+s[6]*l+s[10]*u+s[14])*c,a=p[g+0],l=p[g+1],u=p[g+2],p[g+0]=o[0]*a+o[3]*l+o[6]*u,p[g+1]=o[1]*a+o[4]*l+o[7]*u,p[g+2]=o[2]*a+o[5]*l+o[8]*u}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let n=this.index;if(n){for(let s=e;s<r;s+=3){let o=n.getX(s),a=n.getX(s+1),l=n.getX(s+2);n.setXYZ(s,l,a,o)}n.needsUpdate=!0}}};function zD(){let i=new Ae;return i.setAttribute("position",new Ge(new Float32Array([]),3)),i.setIndex(new Ge(new Uint16Array([]),1)),i}var hq=zD().attributes,dq=12,fq=1,ed=class extends Ae{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,hq),this.userData={parameters:e,type:"TextGeometry"};let n=r.getFont(e.font);n?.isLoaded?(this.font=n,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.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:n,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,h=En.getDisplayedValue(u),d=c===2?h.toUpperCase():c===3?h.toLowerCase():h,f=pq(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof n=="number"?n:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new Ot().fromShape(A,!0));this.vectorShapes=x;let w=x.map(A=>yi.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?St.NONZERO:St.ODD,subdivisions:this.isLowResolution&&o>0?fq:dq}})),S=w.length?bs(w):zD();S.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([A,E])=>{this.setAttribute(A,E)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=ui(new Ae,ed.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),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 pq(i,t,e){let r=[""],n="";for(let s of e)n+=s,s===" "||s===`
|
3154 | `?(r[r.length-1]+=n,n="",s===`
|
3155 | `&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var GD,td=new Promise(i=>{GD=i}),UD=!1;var Rv;function HD(){if(UD)return;if(Rv)return Rv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.499/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});GD(l),UD=!0}return Rv=i(),Rv}function mc(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(n in c){let h=c[n];ZP(h)&&(c[n]=t.getVariable(h,[r.uuid,"geometry",...u,n]))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Ot.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new _u().parse(s);else if(s.type==="SubdivGeometry"){let u=new Fr(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new ed(s,t);let l;try{l=nA(a)}catch(u){console.error(u)}if(!l){let u=Ot.createFromState(ph.defaultData(),100,100);a.shape=u,l=nA(a)}return l}var mq=new ie;function Rp(i,t,e,r){let n=i.position.array,s=i.normal.array,o=mq.makeScale(t,e,r).invert().elements,a,l,u;for(var c=0,h=n.length;c<h;c+=3)n[c]*=t,n[c+1]*=e,n[c+2]*=r,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Lv=new Pt,rd=new _,tt;td.then(i=>{tt=i});var jD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),WD=new Uint32Array([0,1,2,3]),qD=new Uint8Array([4]),Fr=class extends Ae{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=Js.div(r,n);this.subdividedGeometry&&Rp(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Rp(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(rd.fromArray(s));let a=rd.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,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Fr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new yn(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Lv.setFromBufferAttribute(r),Lv.getCenter(n),e.boundingSphere.radius=n.distanceTo(Lv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lv.getSize(rd);let s={width:rd.x,height:rd.y,depth:rd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,u=e?.phongAngle??35;n===!1&&(u=-1),r&&(tt.free_bvh(r),tt.free_subdivision_surface(r));try{o=Fr.allocate(e,s)}catch(c){console.error(c,e),o=Fr.allocate({positionWASM:jD,indexWASM:WD,verticesPerFaceWASM:qD},s)}if(tt.set_destination_refinement_level(o,0),a=Fr.buildLevel(o,!0,u),e.subdivisions>0)try{tt.set_destination_refinement_level(o,e.subdivisions),l=Fr.buildLevel(o,!1,u)}catch{try{tt.set_destination_refinement_level(o,e.subdivisions-1),l=Fr.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){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:mc(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=gc(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:u}=aA(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=jD,s=WD,o=qD);let u=n.length,c=s.length,h=o.length,d=n.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=tt._malloc(p),v=new Float32Array(tt.HEAPF32.buffer,y,d),x=new Uint32Array(tt.HEAPU32.buffer,y+m,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(A=>A!==1)&&(w=new ie().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let S=w?tt.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,w.elements):tt.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return tt._free(y),S}static buildLevel(e,r,n,s,o){let a=o?tt.get_mesh_data2(e,r?tt.Level.CONTROL:tt.Level.REFINED,n,o.elements):tt.get_mesh_data(e,r?tt.Level.CONTROL:tt.Level.REFINED,n),l=8,u=tt.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=tt.HEAPU32[u[h]>>2],f=tt.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=tt.HEAPU32[u[h]>>2],m=tt.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=tt.HEAPU32[u[h]>>2],y=tt.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=tt.HEAPU32[u[h]>>2],x=tt.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let w=new Ae;if(w.setIndex(new js(x,1)),w.setAttribute("position",new be(f,3)),w.setAttribute("normal",new be(m,3)),r){w.setAttribute("faceMap",new js(y,1));let S=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ge(S,4))}return tt.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,tt.free_mesh_data(a)}static freeSubdivPointer(e){tt.free_bvh(e),tt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=tt.get_wireframe_data_for_base_level(e),o=4,a=tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=tt.HEAPU32[a[u]>>2],h=tt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=tt.HEAPU32[a[u]>>2],f=tt.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(r===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g<y;)m[g++]=n.r,m[g++]=n.g,m[g++]=n.b;return p.setAttribute("color",new Ge(m,3)),p.setIndex(new js(f,1)),tt.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,tt.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,n){let s=r===0;s||tt.set_destination_refinement_level(e,r);let o=n?tt.get_topological_data2(e,s?tt.Level.CONTROL:tt.Level.REFINED,n.elements):tt.get_topological_data(e,s?tt.Level.CONTROL:tt.Level.REFINED),a=6,l=tt.HEAPU32.subarray(o>>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=tt.HEAPU32[l[c]>>2],d=new Float32Array(tt.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=tt.HEAPU32[l[c]>>2],p=new Uint32Array(tt.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=tt.HEAPU32[l[c]>>2],g=new Uint8Array(tt.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return tt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var YD=["getX","getY","getZ"];function gc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(i[YD[d]](c)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[YD[d]](c));e[h]=n,s.push(n),n++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var Nv=new _,iA=new _,sA=new _,oA=new _;function aA(i,t,e,r){let n=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let h=0;if(c<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),n.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Nv.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),iA.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),sA.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),oA.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),iA.sub(Nv).normalize(),sA.sub(Nv).normalize(),oA.sub(Nv).normalize();let l=iA.cross(sA).dot(oA);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:a>=r[c]&&a<r[c+1])?(n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(n.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),c++),i[h+2]===o&&u.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=u[0];u[0]=u[1],u[1]=h}l.reverse(),n.push(...l,...u),s.push(c,c)}return{indices:n,verticesPerFace:s}}var Zi={};P3(Zi,{calcBoolean:()=>vq,calcBooleanTopological:()=>yq,freeMeshSet:()=>Sq,getMeshSet:()=>xq,hasOpenEdges:()=>bq,transformMeshSet:()=>wq});var XD,QD=new Promise(i=>{XD=i});var Bv;function KD(){if(Bv)return Bv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.499/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});XD(l)}return Bv=i(),Bv}var ft,nd;QD.then(i=>ft=i);function gq(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=gc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:u}=aA(s,o,i);a=u.length,r=[];for(let c=0,h=0;c<a;c++){r.push(u[c]);for(let d=0;d<u[c];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let u=0,c=0;c<r.length;)r[c++]=3,a++,r[c++]=o[u++],r[c++]=o[u++],r[c++]=o[u++]}return{positions:s,faceIndices:r,nFaces:a}}function ZD(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,n=Number.isInteger(i[0])?e:r,s=ft._malloc(n);return(Number.isInteger(i[0])?new Uint32Array(ft.HEAPU32.buffer,s,t):new Float32Array(ft.HEAPF32.buffer,s,t)).set(i,0),s}function JD(i){switch(i){case 0:return ft.OP.UNION;case 1:return ft.OP.INTERSECTION;case 2:return ft.OP.A_MINUS_B;case 3:return ft.OP.B_MINUS_A;case 4:return ft.OP.SYMMETRIC_DIFFERENCE;case 5:return ft.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function yq(i,t){nd===void 0&&(nd=ft.init_csg());let e=ZD(i),r=ft.csg_calc_topological(nd,e,i.length,JD(t));ft._free(e);let n=6,s=ft.HEAPU32.subarray(r>>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=ft.HEAPU32[s[a]>>2],u=new Float32Array(ft.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ft.HEAPU32[s[a]>>2],h=new Uint32Array(ft.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=ft.HEAPU32[s[a]>>2],f=new Uint8Array(ft.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ft.free_mesh_data(r),{positions:u,indices:h,verticesPerFace:f}}function vq(i,t,e,r){nd===void 0&&(nd=ft.init_csg());let n=ZD(i),s=ft.csg_calc(nd,n,i.length,r,JD(t));ft._free(n);let o=5,a=ft.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ft.HEAPU32[a[u]>>2],h=ft.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=ft.HEAPU32[a[u]>>2],f=ft.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=ft.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new fr),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ft.free_mesh_data(s),p}function xq(i,t,e){if(ft===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let g=i.userData;s=g.verticesPerFace.length,r=g.positions,n=Array(g.verticesPerFace.reduce((y,v)=>y+v,0)+s);for(let y=0,v=0,x=0;y<g.verticesPerFace.length;y++){n[x++]=g.verticesPerFace[y];for(let w=0;w<g.verticesPerFace[y];w++)n[x++]=g.indices[v++]}}else({positions:r,faceIndices:n,nFaces:s}=gq(i,t,e));let o=r.length,a=n.length,l=r.length,u=n.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=ft._malloc(c),p=new Float32Array(ft.HEAPF32.buffer,f,l),m=new Uint32Array(ft.HEAPU32.buffer,f+h,u);return p.set(r,0),m.set(n,0),ft.get_csg_mesh(f,o,f+h,a,s)}function bq(i){return ft.has_open_edges(i)}function wq(i,t){ft.transform_csg_mesh(i,t.elements)}function Sq(i){ft.free_csg_mesh(i)}var Aq={ConeGeometry:q2,CubeGeometry:Y2,CylinderGeometry:vv,DodecahedronGeometry:X2,EllipseGeometry:Zh,HelixGeometry:AD,IcosahedronGeometry:_D,LatheGeometry:ED,NonParametricGeometry:PD,PolygonGeometry:Pv,PyramidGeometry:DD,RectangleGeometry:Dv,SphereGeometry:ID,PlaneGeometry:OD,BackdropGeometry:RD,StarGeometry:Iv,TextFrameGeometry:LD,TorusGeometry:ND,TorusKnotGeometry:BD,TriangleGeometry:FD,PathGeometry:VD,VectorGeometry:yi},nA=i=>Aq[i.type].create(i);function id(i){return i!==null&&"booleanOp"in i}var sd=class extends Hh(_r){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(e){super.updateVisible(e),this.visible=!id(this.parent)&&this.visible,id(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Zi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),id(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof sd&&(e.freeBooleanPointer(),id(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&id(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),id(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Fv=new Pt;function Lp(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>u&&(u=f),p>c&&(c=p)}Fv.min.set(s,o,a),Fv.max.set(l,u,c),Fv.getCenter(r),Fv.getSize(n).multiplyScalar(.5)}var _q=new Ae,Eq=new Go,$t=class extends sd{constructor(t,e){super(_q,Eq),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?Lp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Np=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 Mn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Se.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,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,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Mn&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n<this.hashProperties.length;n++)e=this.hashProperties[n],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var lA=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}},cn=new lA;var Ye=class extends Mn{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,n,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=Se.generateUUID()),n=e.getUUID(n??this.getUUID(),!o);let a=e.getNodeData(n),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,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let u=this.getTemp(e,n);if(u)return e.format(u,l,r);{u=super.generate(e,r,n,a.output,s);let c=this.generate(e,l,n);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,n)}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 n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var jt=class extends Ye{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,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,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 wr=class extends jt{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof N?e:new N(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,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var kn=class extends jt{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,r,n)}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,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var gr=class extends Re{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),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)}setStyle(e,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[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 vi=class extends jt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof gr?e:new gr(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var Mq=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,$D=/[a-z_0-9]+/gi,ge=class extends Ye{constructor(e,r,n,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,n,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,n,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let c=[];for(;a=$D.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&p&&cn.containsKeyword(f)){let g=this.keywords[f];if(!g){let y=cn.getKeywordData(f);y.cache&&(g=e.keywords[f]),g=g||cn.getKeyword(f,e),y.cache&&(e.keywords[f]=g)}m=g.build(e)}f!==m&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+m+u.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&cn.contains(m)&&e.include(cn.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,n,s){if(this.src=e||"",this.includes=r??[],this.extensions=n??{},this.keywords=s??{},this.isMethod){let o=Mq.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match($D);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var Tq=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,cA=class extends Ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||cA.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,s,o){this.src=e||"";let a,l,u="",c=Tq.exec(e);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}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,n,s,o){return e.format(this.name,this.getType(e),r)}},It=cA;It.PI="PI",It.PI2="PI2",It.RECIPROCAL_PI="RECIPROCAL_PI",It.RECIPROCAL_PI2="RECIPROCAL_PI2",It.LOG2="LOG2",It.EPSILON="EPSILON";var Cq=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
3156 | )*?)}`,"gim"),Pq=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),od=class extends Ye{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,n,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=Cq.exec(e);if(r){let n=r[2],s;for(;s=Pq.exec(n);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ad=class extends Ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(s,this.getType(e),r)}};cn.addKeyword("uv",function(){return new ad});cn.addKeyword("uv2",function(){return new ad(1)});var yc=class extends Ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??yc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Di:return["Linear"];case et:return["sRGB"];default:return[]}}generate(e,r){let n=this.input.build(e,"v4"),s=this.getType(e),o=yc.Nodes[this.method],a=e.include(o);if(a===yc.LINEAR_TO_LINEAR)return e.format(n,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+n+", "+l+" )",s,r)}else return e.format(a+"( "+n+" )",s,r)}fromEncoding(e){let r=yc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=yc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},ni=yc;ni.Nodes={LinearToLinear:new ge(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
3157 | `)),sRGBToLinear:new ge(["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(`
|
3158 | `)),LinearTosRGB:new ge(["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(`
|
3159 | `))},ni.LINEAR_TO_LINEAR="LinearToLinear",ni.SRGB_TO_LINEAR="sRGBToLinear",ni.LINEAR_TO_SRGB="LinearTosRGB";var Rt=class extends ge{constructor(e="",r,n,s,o){super(e,o,s,n,r);this.nodeType="Expression"}};var ii=class extends jt{constructor(e=new or,r,n,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new ad,this.bias=n,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 n=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+"( "+n+", "+s+", "+o+" )":l=a+"( "+n+", "+s+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new ni(new Rt("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var Ce=class extends jt{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,n,s,o,a){return e.format(this.value+(this.value%1?"":".0"),s,r)}};var Bp=class extends Ye{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,n,s,o){s=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",u=[];if(a.inputs){for(let c=0;c<a.inputs.length;c++){let h=a.inputs[c],d=this.inputs[c]||this.inputs[h.name];u.push(d.build(e,e.getTypeByFormat(h.type)))}l+=u.join(", ")+" )"}return e.format(l,s,r)}};var uA=class extends Ye{constructor(e,r,n=uA.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=n}getType(e){let r=this.a.getType(e),n=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(n)>e.getTypeLength(r)?n:r}generate(e,r){let n=this.getType(e);this.type=n;let s=this.a.build(e,n),o=this.b.build(e,n);return e.format("( "+s+" "+this.op+" "+o+" )",n,r)}},Tn=uA;Tn.ADD="+",Tn.SUB="-",Tn.MUL="*",Tn.DIV="/";var Wt=class extends Ye{constructor(e,r=Wt.ABS,n,s){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:s=r,typeof n!="string"?this.c=n:s=n,this.method=s,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Wt.MIX:case Wt.CLAMP:case Wt.REFRACT:case Wt.SMOOTHSTEP:case Wt.FACEFORWARD:return 3;case Wt.MIN:case Wt.MAX:case Wt.MOD:case Wt.STEP:case Wt.REFLECT:case Wt.DISTANCE:case Wt.DOT:case Wt.CROSS:case Wt.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0;return r>n&&r>s?this.a.getType(e):n>s?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Wt.LENGTH:case Wt.DISTANCE:case Wt.DOT:return"f";case Wt.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let n,s,o,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Wt.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case Wt.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case Wt.CROSS:n=this.a.build(e,"v3"),s=this.b.build(e,"v3");break;case Wt.STEP:n=this.a.build(e,a===1?"f":c),s=this.b.build(e,c);break;case Wt.MIN:case Wt.MAX:case Wt.MOD:n=this.a.build(e,c),s=this.b.build(e,l===1?"f":c);break;case Wt.REFRACT:n=this.a.build(e,c),s=this.b.build(e,c),o=this.c.build(e,"f");break;case Wt.MIX:n=this.a.build(e,c),s=this.b.build(e,c),o=this.c.build(e,u===1?"f":c);break;default:n=this.a.build(e,c),this.b&&(s=this.b.build(e,c)),this.c&&(o=this.c.build(e,c));break}let d=[];d.push(n),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)}},ot=Wt;ot.RAD="radians",ot.DEG="degrees",ot.EXP="exp",ot.EXP2="exp2",ot.LOG="log",ot.LOG2="log2",ot.SQRT="sqrt",ot.INV_SQRT="inversesqrt",ot.FLOOR="floor",ot.CEIL="ceil",ot.NORMALIZE="normalize",ot.FRACT="fract",ot.SATURATE="saturate",ot.SIN="sin",ot.COS="cos",ot.TAN="tan",ot.ASIN="asin",ot.ACOS="acos",ot.ARCTAN="atan",ot.ABS="abs",ot.SIGN="sign",ot.LENGTH="length",ot.NEGATE="negate",ot.INVERT="invert",ot.MIN="min",ot.MAX="max",ot.MOD="mod",ot.STEP="step",ot.REFLECT="reflect",ot.DISTANCE="distance",ot.DOT="dot",ot.CROSS="cross",ot.POW="pow",ot.MIX="mix",ot.CLAMP="clamp",ot.REFRACT="refract",ot.SMOOTHSTEP="smoothstep",ot.FACEFORWARD="faceforward";var ld=class extends Ye{constructor(e,r,n){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=n}bilinearCubeUV(e,r,n,s){let o=new Bp(ld.Nodes.bilinearCubeUV,[r,n,s]);this.colorSpaceTL=this.colorSpaceTL??new ni(new Rt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(o.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new ni(new Rt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(o.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new ni(new Rt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(o.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new ni(new Rt("","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 Rt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Rt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Rt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Rt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Rt("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 n=this.uv,s=this.bias||e.context.roughness,o=new Bp(ld.Nodes.roughnessToMip,[s]),a=new ot(o,ld.Nodes.m0,ld.Nodes.cubeUV_maxMipLevel,ot.CLAMP),l=new ot(a,ot.FLOOR),u=new ot(a,ot.FRACT),c=this.bilinearCubeUV(e,this.value,n,l),h=this.bilinearCubeUV(e,this.value,n,new Tn(l,new Ce(1).setReadonly(!0),Tn.ADD)),d=new ot(c,h,u,ot.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)}},cd=ld;cd.Nodes=function(){let e=new od(`struct TextureCubeUVData {
|
3160 | vec4 tl;
|
3161 | vec4 tr;
|
3162 | vec4 br;
|
3163 | vec4 bl;
|
3164 | vec2 f;
|
3165 | }`),r=new It("float cubeUV_maxMipLevel 8.0",!0),n=new It("float cubeUV_minMipLevel 4.0",!0),s=new It("float cubeUV_maxTileSize 256.0",!0),o=new It("float cubeUV_minTileSize 16.0",!0),a=new ge(`float getFace(vec3 direction) {
|
3166 | vec3 absDirection = abs(direction);
|
3167 | float face = -1.0;
|
3168 | if (absDirection.x > absDirection.z) {
|
3169 | if (absDirection.x > absDirection.y)
|
3170 | face = direction.x > 0.0 ? 0.0 : 3.0;
|
3171 | else
|
3172 | face = direction.y > 0.0 ? 1.0 : 4.0;
|
3173 | } else {
|
3174 | if (absDirection.z > absDirection.y)
|
3175 | face = direction.z > 0.0 ? 2.0 : 5.0;
|
3176 | else
|
3177 | face = direction.y > 0.0 ? 1.0 : 4.0;
|
3178 | }
|
3179 | return face;
|
3180 | }`);a.useKeywords=!1;let l=new ge(`vec2 getUV(vec3 direction, float face) {
|
3181 | vec2 uv;
|
3182 | if (face == 0.0) {
|
3183 | uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
|
3184 | } else if (face == 1.0) {
|
3185 | uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
|
3186 | } else if (face == 2.0) {
|
3187 | uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
|
3188 | } else if (face == 3.0) {
|
3189 | uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
|
3190 | } else if (face == 4.0) {
|
3191 | uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
|
3192 | } else {
|
3193 | uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
|
3194 | }
|
3195 | return 0.5 * (uv + 1.0);
|
3196 | }`);l.useKeywords=!1;let u=new ge(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
|
3197 | float face = getFace(direction);
|
3198 | float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
|
3199 | mipInt = max(mipInt, cubeUV_minMipLevel);
|
3200 | float faceSize = exp2(mipInt);
|
3201 | float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
|
3202 | vec2 uv = getUV(direction, face) * (faceSize - 1.0);
|
3203 | vec2 f = fract(uv);
|
3204 | uv += 0.5 - f;
|
3205 | if (face > 2.0) {
|
3206 | uv.y += faceSize;
|
3207 | face -= 3.0;
|
3208 | }
|
3209 | uv.x += face * faceSize;
|
3210 | if(mipInt < cubeUV_maxMipLevel){
|
3211 | uv.y += 2.0 * cubeUV_maxTileSize;
|
3212 | }
|
3213 | uv.y += filterInt * 2.0 * cubeUV_minTileSize;
|
3214 | uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
|
3215 | uv *= texelSize;
|
3216 | vec4 tl = texture2D(envMap, uv);
|
3217 | uv.x += texelSize;
|
3218 | vec4 tr = texture2D(envMap, uv);
|
3219 | uv.y += texelSize;
|
3220 | vec4 br = texture2D(envMap, uv);
|
3221 | uv.x -= texelSize;
|
3222 | vec4 bl = texture2D(envMap, uv);
|
3223 | return TextureCubeUVData( tl, tr, br, bl, f );
|
3224 | }`,[e,a,l,r,n,s,o]);u.useKeywords=!1;let c=new It("float r0 1.0",!0),h=new It("float v0 0.339",!0),d=new It("float m0 -2.0",!0),f=new It("float r1 0.8",!0),p=new It("float v1 0.276",!0),m=new It("float m1 -1.0",!0),g=new It("float r4 0.4",!0),y=new It("float v4 0.046",!0),v=new It("float m4 2.0",!0),x=new It("float r5 0.305",!0),w=new It("float v5 0.016",!0),S=new It("float m5 3.0",!0),A=new It("float r6 0.21",!0),E=new It("float v6 0.0038",!0),b=new It("float m6 4.0",!0),M=[c,h,d,f,p,m,g,y,v,x,w,S,A,E,b],T=new ge(`float roughnessToMip(float roughness) {
|
3225 | float mip = 0.0;
|
3226 | if (roughness >= r1) {
|
3227 | mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
|
3228 | } else if (roughness >= r4) {
|
3229 | mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
|
3230 | } else if (roughness >= r5) {
|
3231 | mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
|
3232 | } else if (roughness >= r6) {
|
3233 | mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
|
3234 | } else {
|
3235 | mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
3236 | }
|
3237 | return mip;
|
3238 | }`,M);return{bilinearCubeUV:u,roughnessToMip:T,m0:d,cubeUV_maxMipLevel:r}}();var vc=class extends Ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??vc.VIEW}getShared(){return this.scope===vc.WORLD}build(e,r,n,s){let o=e.context[this.scope+"Normal"];return o?o.build(e,r,n,s):super.build(e,r,n)}generate(e,r,n,s,o){let a;switch(this.scope){case vc.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case vc.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case vc.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}},Cn=vc;Cn.LOCAL="local",Cn.WORLD="world",Cn.VIEW="view",Cn.NORMAL="normal";cn.addKeyword("viewNormal",function(){return new Cn(Cn.VIEW)});cn.addKeyword("localNormal",function(){return new Cn(Cn.NORMAL)});cn.addKeyword("worldNormal",function(){return new Cn(Cn.WORLD)});var ao=class extends Ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??ao.LOCAL}getType(){switch(this.scope){case ao.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case ao.LOCAL:case ao.WORLD:return!1}return!0}generate(e,r,n,s,o){let a;switch(this.scope){case ao.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case ao.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case ao.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ao.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}},xi=ao;xi.LOCAL="local",xi.WORLD="world",xi.VIEW="view",xi.PROJECTION="projection";cn.addKeyword("position",function(){return new xi});cn.addKeyword("worldPosition",function(){return new xi(xi.WORLD)});cn.addKeyword("viewPosition",function(){return new xi(xi.VIEW)});var Es=class extends Ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Es.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Es.SPHERE:return"v2"}return this.type}generate(e,r){let n=this.getUnique(e);if(e.isShader("fragment")){let s;switch(this.scope){case Es.VECTOR:{let o=new Cn(Cn.VIEW),a=e.context.roughness,l=o.build(e,"v3"),u=new xi(xi.VIEW).build(e,"v3"),c=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${u} ), ${l} )`;c&&(h=`normalize( mix( ${h}, ${l}, ${c} * ${c} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${d};`),s="reflectVec"):s=d;break}case Es.CUBE:{let o=new Es(Es.VECTOR).build(e,"v3"),a="vec3( -"+o+".x, "+o+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),s="reflectCubeVec"):s=a;break}case Es.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new Es(Es.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(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)}},lo=Es;lo.CUBE="cube",lo.SPHERE="sphere",lo.VECTOR="vector";var kv=class extends Ye{constructor(e=new ii,r,n){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new cd(this.value,r??new lo(lo.VECTOR),n),this.irradianceNode=new cd(this.value,new Cn(Cn.WORLD),new Ce(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 Vv=class extends jt{constructor(e=new ou,r,n){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new lo,this.bias=n}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let n=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( "+n+", "+s+", "+o+" )":a="texCube( "+n+", "+s+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new ni(new Rt("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,u),e.removeContext(),e.format(a,u,r)}};var eI=`
|
3239 | uniform int frameIndex;
|
3240 | uniform vec2 resolution;
|
3241 | uniform mat4 previousModelViewMatrix;
|
3242 | uniform mat4 previousProjectionMatrix;
|
3243 |
|
3244 | varying vec4 vCurrentPosition;
|
3245 | varying vec4 vPreviousPosition;
|
3246 | `,tI=`
|
3247 | layout(location = 1) out vec4 gVelocity;
|
3248 |
|
3249 | uniform int frameIndex;
|
3250 | uniform vec2 resolution;
|
3251 |
|
3252 | varying vec4 vCurrentPosition;
|
3253 | varying vec4 vPreviousPosition;
|
3254 |
|
3255 | const vec2 haltonSequence[16] = vec2[16](
|
3256 | vec2( 0.000000,-0.333334),
|
3257 | vec2(-0.500000, 0.333334),
|
3258 | vec2( 0.500000,-0.777778),
|
3259 | vec2(-0.750000,-0.111112),
|
3260 | vec2( 0.250000, 0.555556),
|
3261 | vec2(-0.250000,-0.555556),
|
3262 | vec2( 0.750000, 0.111112),
|
3263 | vec2(-0.875000, 0.777778),
|
3264 | vec2(0.125000, -0.925926),
|
3265 | vec2(-0.375000, -0.259260),
|
3266 | vec2(0.625000, 0.407408),
|
3267 | vec2(-0.625000, -0.703704),
|
3268 | vec2(0.375000, -0.037038),
|
3269 | vec2(-0.125000, 0.629630),
|
3270 | vec2(0.875000, -0.481482),
|
3271 | vec2(-0.937500, 0.185186));
|
3272 |
|
3273 | vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {
|
3274 | const float goldenAngle = 2.399963f; // radians
|
3275 | float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));
|
3276 | float theta = float(sampleIndex) * goldenAngle + angle;
|
3277 | float sine = sin(theta);
|
3278 | float cosine = cos(theta);
|
3279 | return vec2(cosine, sine) * r;
|
3280 | }
|
3281 |
|
3282 | // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
|
3283 | float getNoiseInterleavedGradient(vec2 screenPos) {
|
3284 | vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
|
3285 | return fract(magic.z * fract(dot(screenPos, magic.xy)));
|
3286 | }
|
3287 |
|
3288 | `,rI=`
|
3289 | // TODO: This could be generated CPU side and passed to the shader every frame
|
3290 | const vec2 haltonSequence[16] = vec2[16](
|
3291 | vec2( 0.000000,-0.333334),
|
3292 | vec2(-0.500000, 0.333334),
|
3293 | vec2( 0.500000,-0.777778),
|
3294 | vec2(-0.750000,-0.111112),
|
3295 | vec2( 0.250000, 0.555556),
|
3296 | vec2(-0.250000,-0.555556),
|
3297 | vec2( 0.750000, 0.111112),
|
3298 | vec2(-0.875000, 0.777778),
|
3299 | vec2(0.125000, -0.925926),
|
3300 | vec2(-0.375000, -0.259260),
|
3301 | vec2(0.625000, 0.407408),
|
3302 | vec2(-0.625000, -0.703704),
|
3303 | vec2(0.375000, -0.037038),
|
3304 | vec2(-0.125000, 0.629630),
|
3305 | vec2(0.875000, -0.481482),
|
3306 | vec2(-0.937500, 0.185186));
|
3307 |
|
3308 | // TODO: Pass correct view size
|
3309 | vec2 offset = haltonSequence[frameIndex];
|
3310 | offset.x /= resolution.x;
|
3311 | offset.y /= resolution.y;
|
3312 |
|
3313 | vec4 currentPosition = gl_Position;
|
3314 | vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);
|
3315 |
|
3316 | // We want to calculate the velocity with unjittered positions
|
3317 | // so that things that are not moving get a velocity = 0
|
3318 | vCurrentPosition = currentPosition;
|
3319 | vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);
|
3320 | #ifdef OUTLINE_COMPENSATION
|
3321 | vPreviousPosition.xy += OUTLINE_COMPENSATION;
|
3322 | #endif
|
3323 | gl_Position = currentPositionJittered;
|
3324 |
|
3325 | `,nI=`
|
3326 | vec2 oldPos = vPreviousPosition.xy;
|
3327 | oldPos /= vPreviousPosition.w;
|
3328 | oldPos.xy = (oldPos.xy+1.)/2.0;
|
3329 |
|
3330 | vec2 newPos = vCurrentPosition.xy;
|
3331 | newPos /= vCurrentPosition.w;
|
3332 | newPos.xy = (newPos.xy+1.)/2.0;
|
3333 |
|
3334 | vec2 velocity = (newPos - oldPos);
|
3335 |
|
3336 | // Discard fully transparent pixels
|
3337 | if (gl_FragColor.a <= 0.0) discard;
|
3338 |
|
3339 | gVelocity = vec4(velocity, 0.0, 1.0);
|
3340 | `;var iI=["x","y","z","w"],Dq=["float","vec2","vec3","vec4"],Iq={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},Oq={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[]"},zv=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,n){let s=this.getIncludes(r,n);if(!s)return"";let o="";s=s.sort(t);for(let a=0;a<s.length;a++)s[a].src&&(o+=s[a].src+`
|
3341 | `);return o}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
|
3342 | // NOTE: Include Spline's blending modes. This could be part of BlendNode
|
3343 | #define SPE_BLENDING_NORMAL 0
|
3344 | #define SPE_BLENDING_MULTIPLY 1
|
3345 | #define SPE_BLENDING_SCREEN 2
|
3346 | #define SPE_BLENDING_OVERLAY 3
|
3347 |
|
3348 | vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
|
3349 | return mix( a, b, alpha );
|
3350 | }
|
3351 |
|
3352 | vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
|
3353 | return mix( a, a * b, alpha );
|
3354 | }
|
3355 |
|
3356 | vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
|
3357 | vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
|
3358 | return mix( a, tmp, alpha );
|
3359 | }
|
3360 |
|
3361 | vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
|
3362 | vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
|
3363 | return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
|
3364 | }
|
3365 |
|
3366 | vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
|
3367 | if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
|
3368 | else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
|
3369 | else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
|
3370 | else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
|
3371 | return vec3( 1.0 );
|
3372 | }
|
3373 | `,"#include <packing>","#include <common>"].join(`
|
3374 | `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
|
3375 | `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
|
3376 | accumAlpha += (1.0 - accumAlpha) * alpha;
|
3377 | }`,""].join(`
|
3378 | `)},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(eI),this.addFragmentParsCode(tI),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let n=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+n+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+n+";"),this.addVertexFinalCode("vUv"+n+" = uv"+n+";")}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(rI),this.addFragmentFinalCode(nI)),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+`
|
3379 | `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
|
3380 | `}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+`
|
3381 | `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
|
3382 | `}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,n="varying",s="V",o=""){let a=this.getVars(n),l=a[t];if(!l){let u=a.length;l={name:r||"node"+s+u+(o?"_"+o:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,n){return this.getVar(t,e,r,this.shader,"T",n)}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(`
|
3383 | `)}getVarListCode(t,e){e=e??"";let r="";for(let n=0,s=t.length;n<s;++n){let o=t[n],a=o.type,l=o.name,u=o.size,c=this.getFormatByType(a);if(c===void 0)throw new Error("Node pars "+c+" not found.");c.includes("[]")?r+=e+" "+c.substring(0,c.length-2)+" "+l+`[${u}];
|
3384 | `:r+=e+" "+c+" "+l+`;
|
3385 | `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof Mn?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,n,s,o){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,u=new Np({type:e,size:r.size,name:n||"nodeUA"+l+(o?"_"+o:""),node:r,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}else{let a=this.inputs.uniforms,l=a.list.length,u=new Np({type:e,name:n||"nodeU"+l+(o?"_"+o:""),node:r,needsUpdate:s});return a.list.push(u),a[t].push(u),a[t][u.name]=u,this.uniforms[u.name]=u,u}}createVertexUniform(t,e,r,n,s){return this.createUniform("vertex",t,e,r,n,s)}createFragmentUniform(t,e,r,n,s){return this.createUniform("fragment",t,e,r,n,s)}include(t,e,r){let n;if(t=typeof t=="string"?cn.get(t):t,this.context.include===!1)return t.name;t instanceof ge?n=this.includes.functions:t instanceof It?n=this.includes.consts:t instanceof od&&(n=this.includes.structs);let s=n[this.shader]=n[this.shader]||[];if(t){let o=s[t.name];if(o||(o=s[t.name]={node:t,deps:[]},s.push(o),o.src=t.build(this,"source")),t instanceof ge&&e&&s[e.name]&&s[e.name].deps.indexOf(t)===-1&&(s[e.name].deps.push(t),t.includes?.length)){let a=0;do this.include(t.includes[a++],e);while(a<t.includes.length)}return r&&(o.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return Dq[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case Ea:case Ma:return new Vv(r);case Tu:return new kv(new ii(r));default:return new ii(r)}else{if(r.isVector2)return new wr(r);if(r.isVector3)return new kn(r);if(r.isVector4)return new vi(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return Iq[t]||t}getFormatByType(t){return Oq[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return iI[t]}getIndexByElement(t){return iI.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=Di,e===Di&&this.context.gamma&&(e=et),e}};var zt=class extends jt{constructor(e=0,r,n,s){super("c");this.nodeType="Color";this.value=e instanceof gr?e:new gr(e||0,r,n,s)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return u?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}generateReadonly(e,r,n,s,o,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",s,r)}};var yt=class extends jt{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,n,s,o,a){return e.format(this.value.toString(),s,r)}};var Tr=class extends jt{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,n,s){return e.format(this.value?"true":"false",s,r)}};var Ms=class extends jt{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var hl=class extends jt{};var Uv=class extends hl{constructor(e){super("v3");this.image=e;this._value=new _}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var xc=class extends hl{constructor(e,r){super("t");this.image=e;this.wrap=r}get value(){return this.image.getTexture(this.wrap)}};var ud=class extends jt{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Gt}generateReadonly(e,r,n,s,o,a){return e.format("mat3("+this.value.elements.join(", ")+")",s,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Vn=class extends jt{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new ie}generateReadonly(e,r,n,s,o,a){return e.format("mat4("+this.value.elements.join(", ")+")",s,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function sI(i,t,e){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0)}var Gv=class extends ud{constructor(e,r){super(new Gt);this.repeat=e;this.offset=r;sI(this.value,e,r)}updateMatrix(){sI(this.value,this.repeat,this.offset)}};var Ts=class extends jt{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Xe?new Array(e).fill(r):new Array(e).fill(new Xe(0))}};var hd=class extends Ye{constructor(e,r,n,s){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=n,this.mode=s}generate(e,r){if(e.isShader("fragment")){let n=[];return n.push(this.a.build(e,"c")),n.push(this.b.build(e,"c")),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),e.format("spe_blend("+n.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var hA=class extends Ye{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let n=e.include(hA.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.color.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},bc=hA;bc.Nodes=function(){return{customColor:new ge(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
3386 | float lalpha = alpha * mask;
|
3387 | calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
3388 | accumAlpha += (1.0 - accumAlpha) * lalpha;
|
3389 |
|
3390 | return color;
|
3391 | }`)}}();var dA=class extends Ye{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let n=e.include(dA.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let s=[];return s.push(this.cnormal.build(e,"v3")),s.push("normal"),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},dd=dA;dd.Nodes=function(){return{customNormal:new ge(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
|
3392 | vec3 normal = packNormalToRGB( norm ).rgb;
|
3393 | normal *= step( vec3(0.5), cnormal );
|
3394 |
|
3395 | float lalpha = alpha * mask;
|
3396 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
3397 | accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
3398 |
|
3399 | return normal;
|
3400 | }`)}}();var fd=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=r,this.crop=n,this.projection=s,this.axis=o,this.side=a,this.size=l,this.blending=u,this.mat=c,this.isMask=f,this.alpha=h,this.mode=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let n=`g${this.uuid.toString().replace(/-/g,"")}`,s;switch(this.projection.value){case 3:s=e.include(fd.Nodes.cylindrical);break;case 2:s=e.include(fd.Nodes.spherical);break;case 1:let a=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=["zy","xz","xy"][this.axis.value],u=new ge(`
|
3401 | vec3 ${n}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
|
3402 | vec2 projected = (1. + (position.${l})) / 2.;
|
3403 | vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
3404 | writeUv = uvs;
|
3405 |
|
3406 | vec4 tmp = texture2D( tex, uvs );
|
3407 |
|
3408 | vec3 col = tmp.rgb;
|
3409 | float lalpha = alpha * tmp.a;
|
3410 | ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, ${a}));`}
|
3411 |
|
3412 | if ( crop > 0.5 ) {
|
3413 | if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
3414 | lalpha = 0.0;
|
3415 | }
|
3416 | }
|
3417 |
|
3418 | lalpha *= mask;
|
3419 |
|
3420 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
3421 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3422 |
|
3423 | return col;
|
3424 | }`);s=e.include(u);break;case 4:s=e.include(fd.Nodes.triplanar);break;default:s=e.include(fd.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=`${n}_writeUvs`,l=a+"0",u=a+"1",c=a+"2",h=`${n}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(h,"vec3"),o.push(l),o.push(u),o.push(c),o.push(h)}else{let a=`${n}_writeUvs`;e.addFragmentVariable(a,"vec2"),o.push(a)}return e.format(s+"("+o.join(",")+")",this.getType(e),r)}},dl=fd;dl.Nodes=function(){let e=new ge(`
|
3425 | 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) {
|
3426 | vec3 posN = normalize(position);
|
3427 | float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
3428 | float scaledHeight = position.y / (size.y * 0.5);
|
3429 | float v = (scaledHeight / 2.) + .5;
|
3430 |
|
3431 | vec2 calculatedUv = vec2(u,v);
|
3432 | vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
3433 | writeUv = uvs;
|
3434 |
|
3435 | vec2 df = fwidth(uvs);
|
3436 | if(df.x > 0.5) df.x = 0.;
|
3437 |
|
3438 | #ifdef GL_EXT_shader_texture_lod
|
3439 | vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
|
3440 | #else
|
3441 | vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
|
3442 | #endif
|
3443 |
|
3444 | vec3 col = tmp.rgb;
|
3445 | float lalpha = alpha * tmp.a;
|
3446 | if ( crop > 0.5 ) {
|
3447 | if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
3448 | lalpha = 0.0;
|
3449 | }
|
3450 | }
|
3451 |
|
3452 | lalpha *= mask;
|
3453 |
|
3454 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
3455 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3456 |
|
3457 | return col;
|
3458 | }
|
3459 | `),r=new ge(`
|
3460 | 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) {
|
3461 | vec3 posN = normalize(vPosition);
|
3462 | float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
|
3463 | float v = 0.5 + asin(posN.y) / 3.1415;
|
3464 |
|
3465 | vec2 calculatedUv = vec2(u,v);
|
3466 | vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
3467 | writeUv = uvs;
|
3468 |
|
3469 | vec2 df = fwidth(uvs);
|
3470 | if(df.x > 0.5) df.x = 0.;
|
3471 | #ifdef GL_EXT_shader_texture_lod
|
3472 | vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
|
3473 | #else
|
3474 | vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
|
3475 | #endif
|
3476 |
|
3477 | vec3 col = tmp.rgb;
|
3478 | float lalpha = alpha * tmp.a;
|
3479 | if ( crop > 0.5 ) {
|
3480 | if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
3481 | lalpha = 0.0;
|
3482 | }
|
3483 | }
|
3484 |
|
3485 | lalpha *= mask;
|
3486 |
|
3487 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
3488 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3489 |
|
3490 | return col;
|
3491 | }
|
3492 | `),n=new ge(`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) {
|
3493 | vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
|
3494 | writeUv = uvs;
|
3495 |
|
3496 | vec4 tmp = texture2D( tex, uvs );
|
3497 |
|
3498 | vec3 col = tmp.rgb;
|
3499 |
|
3500 | float lalpha = alpha * tmp.a;
|
3501 | if ( crop > 0.5 ) {
|
3502 | if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
3503 | lalpha = 0.0;
|
3504 | }
|
3505 | }
|
3506 |
|
3507 | lalpha *= mask;
|
3508 |
|
3509 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
3510 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3511 |
|
3512 | return col;
|
3513 | }`),s=new ge(`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) {
|
3514 | vec3 p = position;
|
3515 | vec2 uv0 = (1.0 + p.xy) / 2.0;
|
3516 | vec2 uv1 = (1.0 + p.zy) / 2.0;
|
3517 | vec2 uv2 = (1.0 + p.xz) / 2.0;
|
3518 |
|
3519 | uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
|
3520 | uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
|
3521 | uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
|
3522 |
|
3523 | // Range from 3 to 128 seems to be good
|
3524 | float exponent = (1.0 - blending) * 125.0 + 3.0;
|
3525 |
|
3526 | vec3 n = vObjectNormal;
|
3527 | vec3 weights = abs(normalize(n));
|
3528 | weights = pow(weights, vec3(exponent));
|
3529 | weights /= dot(weights, vec3(1.0));
|
3530 |
|
3531 | // Write out all sets of UVs that we generated
|
3532 | writeUvs0 = uv0;
|
3533 | writeUvs1 = uv1;
|
3534 | writeUvs2 = uv2;
|
3535 | writeWeights = weights;
|
3536 |
|
3537 | // Derivatives for LOD
|
3538 | vec2 df0 = fwidth(uv0);
|
3539 | vec2 df1 = fwidth(uv1);
|
3540 | vec2 df2 = fwidth(uv2);
|
3541 | if (df0.x > 0.5) df0.x = 0.0;
|
3542 | if (df1.x > 0.5) df1.x = 0.0;
|
3543 | if (df2.x > 0.5) df2.x = 0.0;
|
3544 |
|
3545 | #ifdef GL_EXT_shader_texture_lod
|
3546 | vec4 tmp =
|
3547 | texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
|
3548 | texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
|
3549 | texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
|
3550 | #else
|
3551 | vec4 tmp =
|
3552 | textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
|
3553 | textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
|
3554 | textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
|
3555 | #endif
|
3556 |
|
3557 | vec3 col = tmp.rgb;
|
3558 | float lalpha = alpha * tmp.a;
|
3559 |
|
3560 | // Apply cropping across all 3 planes
|
3561 | if ( crop > 0.5 ) {
|
3562 | if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {
|
3563 | lalpha = 0.0;
|
3564 | }
|
3565 | if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {
|
3566 | lalpha = 0.0;
|
3567 | }
|
3568 | if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {
|
3569 | lalpha = 0.0;
|
3570 | }
|
3571 | }
|
3572 |
|
3573 | lalpha *= mask;
|
3574 | calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
3575 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3576 |
|
3577 | return col;//n * 0.5 + 0.5;
|
3578 | }
|
3579 | `);return{cylindrical:e,spherical:r,uv:n,triplanar:s}}();var pd=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=n,this.far=s,this.isVector=o,this.isWorldSpace=a,this.origin=l,this.direction=u,this.colors=c,this.steps=h,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let n=`g${this.uuid.toString().replace(/-/g,"")}`,s=new ge(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[${n}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
|
3580 | vec4 color = colors[0];
|
3581 | #ifdef ${n}_IS_VECTOR
|
3582 | #ifdef ${n}_LINEAR
|
3583 | #ifdef ${n}_WORLDSPACE
|
3584 | float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
|
3585 | #else
|
3586 | float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
|
3587 | #endif
|
3588 | #else
|
3589 | #ifdef ${n}_WORLDSPACE
|
3590 | float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
|
3591 | #else
|
3592 | float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
|
3593 | #endif
|
3594 | #endif
|
3595 | #else
|
3596 | float dist = length(vWPosition - cameraPosition);
|
3597 | float depth = ( dist - near ) / ( far - near );
|
3598 | #endif
|
3599 |
|
3600 |
|
3601 | float p;
|
3602 | #ifdef ${n}_SMOOTH
|
3603 | for ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {
|
3604 | p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
|
3605 | color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
|
3606 | }
|
3607 | #else
|
3608 | for ( int i = 1; i < ${n}_MAX_COLORS; i++ ) {
|
3609 | p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
|
3610 | color = mix(color, colors[i], p);
|
3611 | }
|
3612 | #endif
|
3613 |
|
3614 | float lalpha = alpha * color.a * mask;
|
3615 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
3616 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3617 |
|
3618 | return color.rgb;
|
3619 | }`,[pd.Nodes.vectorLinearWorldSpaceDepth,pd.Nodes.vectorLinearObjectSpaceDepth,pd.Nodes.vectorSphericalObjectSpaceDepth,pd.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_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)}},md=pd;md.Nodes=function(){let e=new ge(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
3620 | vec3 n = normalize(direction);
|
3621 | float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
|
3622 | return ( dist - near ) / ( far - near );
|
3623 | }`),r=new ge(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
|
3624 | vec3 n = normalize(direction);
|
3625 | float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
|
3626 | return ( dist - near ) / ( far - near );
|
3627 | }`),n=new ge(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
|
3628 | float dist = length(vWPosition - origin);
|
3629 | return ( dist - near ) / ( far - near );
|
3630 | }`),s=new ge(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
|
3631 | float dist = length(position - origin);
|
3632 | return ( dist - near ) / ( far - near );
|
3633 | }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:n,vectorSphericalObjectSpaceDepth:s}}();var Fp=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=n,this.intensity=s,this.factor=o,this.isMask=u,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 n=new ge(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
3634 | float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
|
3635 |
|
3636 | float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
|
3637 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
3638 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3639 |
|
3640 | return color;
|
3641 | }`),s=e.include(n),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 fA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=n,this.steps=s,this.offset=o,this.morph=a,this.angle=l,this.isMask=c,this.alpha=u,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 n=e.include(fA.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(n+"("+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)}},gd=fA;gd.Nodes=function(){return{gradient:new ge(`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) {
|
3642 | vec4 color = colors[0];
|
3643 | vec2 m = morph / vUv.xy;
|
3644 | vec2 rot = vec2( 0.5 + m.x, m.y );
|
3645 | vec2 dt = vec2(
|
3646 | cos( angle ) * rot.x - sin( angle ) * rot.y,
|
3647 | sin( angle ) * rot.x + cos( angle ) * rot.y
|
3648 | );
|
3649 | vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
|
3650 | float t = dot( pt, dt ) / dot( dt, dt );
|
3651 | if ( gradientType == 1 ) {
|
3652 | t = distance (
|
3653 | ( vUv + morph ) * 3.0,
|
3654 | ( vUv + offset ) + 1.0
|
3655 | ) + angle;
|
3656 | } else if ( gradientType == 2 ) {
|
3657 | float polar = atan(
|
3658 | vUv.x + morph.x - 0.5 + offset.x,
|
3659 | vUv.y + morph.y - 0.5 + offset.y
|
3660 | ) * -1.0;
|
3661 | t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
|
3662 | }
|
3663 |
|
3664 | float p;
|
3665 | if (smoothed) {
|
3666 | for ( int i = 1; i < GRAD_MAX; i++ ) {
|
3667 | p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
|
3668 | color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
|
3669 | }
|
3670 |
|
3671 | } else {
|
3672 | for ( int i = 1; i < GRAD_MAX; i++ ) {
|
3673 | p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
|
3674 | color = mix(color, colors[i], p);
|
3675 | }
|
3676 | }
|
3677 |
|
3678 | float lalpha = alpha * color.a * mask;
|
3679 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
3680 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3681 |
|
3682 | return color.xyz;
|
3683 | }`)}}();var pA=class extends Ye{constructor(e,r,n,s){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=s,this.alpha=r,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(pA.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),e.format(n+"("+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)}},yd=pA;yd.Nodes=function(){return{matcap:new ge(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
|
3684 | vec3 viewDir = normalize( vViewPosition );
|
3685 | vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
3686 | vec3 y = cross( viewDir, x );
|
3687 | vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
|
3688 | vec4 matcapColor = texture2D( matcapTex, uv );
|
3689 |
|
3690 | float lalpha = alpha * mask;
|
3691 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
3692 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
3693 |
|
3694 | return matcapColor.rgb;
|
3695 | }`)}}();var kp=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o.VORONOI="voronoi",o))(kp||{}),Pn=function(){let t=new ge(`vec3 random3(vec3 c) {
|
3696 | float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
|
3697 | vec3 r;
|
3698 | r.z = fract(512.0*j);
|
3699 | j *= .125;
|
3700 | r.x = fract(512.0*j);
|
3701 | j *= .125;
|
3702 | r.y = fract(512.0*j);
|
3703 | return r-0.5;
|
3704 | }`),e=new ge(`float simplex3d(vec3 p) {
|
3705 | vec3 s = floor(p + dot(p, vec3(F3)));
|
3706 | vec3 x = p - s + dot(s, vec3(G3));
|
3707 |
|
3708 | vec3 e = step(vec3(0.0), x - x.yzx);
|
3709 | vec3 i1 = e*(1.0 - e.zxy);
|
3710 | vec3 i2 = 1.0 - e.zxy*(1.0 - e);
|
3711 |
|
3712 | vec3 x1 = x - i1 + G3;
|
3713 | vec3 x2 = x - i2 + 2.0*G3;
|
3714 | vec3 x3 = x - 1.0 + 3.0*G3;
|
3715 |
|
3716 | vec4 w, d;
|
3717 |
|
3718 | w.x = dot(x, x);
|
3719 | w.y = dot(x1, x1);
|
3720 | w.z = dot(x2, x2);
|
3721 | w.w = dot(x3, x3);
|
3722 |
|
3723 | w = max(0.6 - w, 0.0);
|
3724 |
|
3725 | d.x = dot(random3(s), x);
|
3726 | d.y = dot(random3(s + i1), x1);
|
3727 | d.z = dot(random3(s + i2), x2);
|
3728 | d.w = dot(random3(s + 1.0), x3);
|
3729 |
|
3730 | w *= w;
|
3731 | w *= w;
|
3732 | d *= w;
|
3733 |
|
3734 | return dot(d, vec4(52.0));
|
3735 | }`,[t]);e.keywords.F3=new It("float F3 0.3333333"),e.keywords.G3=new It("float G3 0.1666667");let r=new ge(`float simplex3dFractal(vec3 m) {
|
3736 | mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
|
3737 | mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
|
3738 | mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
|
3739 | return 0.5333333 * simplex3d(m * rot1)
|
3740 | + 0.2666667 * simplex3d(2.0 * m * rot2)
|
3741 | + 0.1333333 * simplex3d(4.0 * m * rot3)
|
3742 | + 0.0666667 * simplex3d(8.0 * m);
|
3743 | }`,[e]),n=new ge("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new ge("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new ge(`float simplexAshima(vec3 v) {
|
3744 | const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
3745 | const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
3746 | vec3 i = floor(v + dot(v, C.yyy) );
|
3747 | vec3 x0 = v - i + dot(i, C.xxx) ;
|
3748 | vec3 g = step(x0.yzx, x0.xyz);
|
3749 | vec3 l = 1.0 - g;
|
3750 | vec3 i1 = min( g.xyz, l.zxy );
|
3751 | vec3 i2 = max( g.xyz, l.zxy );
|
3752 | vec3 x1 = x0 - i1 + 1.0 * C.xxx;
|
3753 | vec3 x2 = x0 - i2 + 2.0 * C.xxx;
|
3754 | vec3 x3 = x0 - 1. + 3.0 * C.xxx;
|
3755 | i = mod(i, 289.0 );
|
3756 | vec4 p = permute( permute( permute(
|
3757 | i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
|
3758 | + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
|
3759 | + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
|
3760 | float n_ = 1.0/7.0; // N=7
|
3761 | vec3 ns = n_ * D.wyz - D.xzx;
|
3762 | vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
|
3763 | vec4 x_ = floor(j * ns.z);
|
3764 | vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
|
3765 | vec4 x = x_ *ns.x + ns.yyyy;
|
3766 | vec4 y = y_ *ns.x + ns.yyyy;
|
3767 | vec4 h = 1.0 - abs(x) - abs(y);
|
3768 | vec4 b0 = vec4( x.xy, y.xy );
|
3769 | vec4 b1 = vec4( x.zw, y.zw );
|
3770 | vec4 s0 = floor(b0)*2.0 + 1.0;
|
3771 | vec4 s1 = floor(b1)*2.0 + 1.0;
|
3772 | vec4 sh = -step(h, vec4(0.0));
|
3773 | vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
|
3774 | vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
|
3775 | vec3 p0 = vec3(a0.xy,h.x);
|
3776 | vec3 p1 = vec3(a0.zw,h.y);
|
3777 | vec3 p2 = vec3(a1.xy,h.z);
|
3778 | vec3 p3 = vec3(a1.zw,h.w);
|
3779 | vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
|
3780 | p0 *= norm.x;
|
3781 | p1 *= norm.y;
|
3782 | p2 *= norm.z;
|
3783 | p3 *= norm.w;
|
3784 | vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
|
3785 | m = m * m;
|
3786 | return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
3787 | dot(p2,x2), dot(p3,x3) ) );
|
3788 | }`,[n,s]),a=new ge("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new ge("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),u=new ge(`float noise(vec3 p){
|
3789 | vec3 a = floor(p);
|
3790 | vec3 d = p - a;
|
3791 | d = d * d * (3.0 - 2.0 * d);
|
3792 | vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
|
3793 | vec4 k1 = perm(b.xyxy);
|
3794 | vec4 k2 = perm(k1.xyxy + b.zzww);
|
3795 | vec4 c = k2 + a.zzzz;
|
3796 | vec4 k3 = perm(c);
|
3797 | vec4 k4 = perm(c + 1.0);
|
3798 | vec4 o1 = fract(k3 * (1.0 / 41.0));
|
3799 | vec4 o2 = fract(k4 * (1.0 / 41.0));
|
3800 | vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
|
3801 | vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
|
3802 | return o4.y * d.y + o4.x * (1.0 - d.y);
|
3803 | }`,[l]),c=new ge(`float fbm(vec3 x) {
|
3804 | float v = 0.0;
|
3805 | float a = 0.5;
|
3806 | vec3 shift = vec3(100);
|
3807 | for (int i = 0; i < NUM_OCTAVES; ++i) {
|
3808 | v += a * noise(x);
|
3809 | x = x * 2.0 + shift;
|
3810 | a *= 0.5;
|
3811 | }
|
3812 | return v;
|
3813 | }`,[u]);c.keywords.NUM_OCTAVES=new It(`int NUM_OCTAVES ${5}`);let h=new ge("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new ge(`float perlin(vec3 P){
|
3814 | vec3 Pi0 = floor(P);
|
3815 | vec3 Pi1 = Pi0 + vec3(1.0);
|
3816 | Pi0 = mod(Pi0, 289.0);
|
3817 | Pi1 = mod(Pi1, 289.0);
|
3818 | vec3 Pf0 = fract(P);
|
3819 | vec3 Pf1 = Pf0 - vec3(1.0);
|
3820 | vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
3821 | vec4 iy = vec4(Pi0.yy, Pi1.yy);
|
3822 | vec4 iz0 = Pi0.zzzz;
|
3823 | vec4 iz1 = Pi1.zzzz;
|
3824 | vec4 ixy = permute(permute(ix) + iy);
|
3825 | vec4 ixy0 = permute(ixy + iz0);
|
3826 | vec4 ixy1 = permute(ixy + iz1);
|
3827 | vec4 gx0 = ixy0 / 7.0;
|
3828 | vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
|
3829 | gx0 = fract(gx0);
|
3830 | vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
|
3831 | vec4 sz0 = step(gz0, vec4(0.0));
|
3832 | gx0 -= sz0 * (step(0.0, gx0) - 0.5);
|
3833 | gy0 -= sz0 * (step(0.0, gy0) - 0.5);
|
3834 | vec4 gx1 = ixy1 / 7.0;
|
3835 | vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
|
3836 | gx1 = fract(gx1);
|
3837 | vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
|
3838 | vec4 sz1 = step(gz1, vec4(0.0));
|
3839 | gx1 -= sz1 * (step(0.0, gx1) - 0.5);
|
3840 | gy1 -= sz1 * (step(0.0, gy1) - 0.5);
|
3841 | vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
|
3842 | vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
|
3843 | vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
|
3844 | vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
|
3845 | vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
|
3846 | vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
|
3847 | vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
|
3848 | vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
|
3849 | vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
3850 | g000 *= norm0.x;
|
3851 | g010 *= norm0.y;
|
3852 | g100 *= norm0.z;
|
3853 | g110 *= norm0.w;
|
3854 | vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
3855 | g001 *= norm1.x;
|
3856 | g011 *= norm1.y;
|
3857 | g101 *= norm1.z;
|
3858 | g111 *= norm1.w;
|
3859 | float n000 = dot(g000, Pf0);
|
3860 | float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
|
3861 | float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
|
3862 | float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
|
3863 | float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
|
3864 | float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
|
3865 | float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
|
3866 | float n111 = dot(g111, Pf1);
|
3867 | vec3 fade_xyz = fade(Pf0);
|
3868 | vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
|
3869 | vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
|
3870 | float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
3871 | return 2.2 * n_xyz;
|
3872 | }`,[n,s,h]),f=new ge(`float hashwithoutsine13(vec3 p3)
|
3873 | {
|
3874 | p3 = fract(p3 * .1031);
|
3875 | p3 += dot(p3, p3.yzx + 33.33);
|
3876 | return fract((p3.x + p3.y) * p3.z);
|
3877 | }`),p=new ge(`vec3 hashwithoutsine33(vec3 p3)
|
3878 | {
|
3879 | p3 = fract(p3 * vec3(.1031, .1030, .0973));
|
3880 | p3 += dot(p3, p3.yxz+33.33);
|
3881 | return fract((p3.xxy + p3.yxx)*p3.zyx);
|
3882 | }`),m=new ge(`float metric(in vec3 p)
|
3883 | {
|
3884 | // L2
|
3885 | return length(p);
|
3886 |
|
3887 | // Chebyshev
|
3888 | // vec3 a = abs(p);
|
3889 | // return max(a.x, max(a.y, a.z));
|
3890 | }`),g=new ge(`float smin( float a, float b, float k )
|
3891 | {
|
3892 | float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
|
3893 | float correction = k * h * (1.0 - h);
|
3894 | return mix(b, a, h) - correction;
|
3895 | }`),y=new ge(`float smax( float a, float b, float k )
|
3896 | {
|
3897 | float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
|
3898 | float correction = k * h * (1.0 - h);
|
3899 | return mix(a, b, h) + correction;
|
3900 | }`),v=new ge(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
|
3901 | // Compute width of each interval
|
3902 | float input_width = input_max - input_min;
|
3903 | float output_width = output_max - output_min;
|
3904 |
|
3905 | // Convert input range into a 0-1 range
|
3906 | float scaled = (value - input_min) / input_width;
|
3907 |
|
3908 | // Convert the 0-1 range into a value in output range
|
3909 | return output_min + (scaled * output_width);
|
3910 | }`),x=new ge(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
|
3911 | {
|
3912 | // Integer and fractional parts of this point's coordinates
|
3913 | ivec3 p = ivec3(floor(x));
|
3914 | vec3 f = fract(x);
|
3915 |
|
3916 | // Different variables that we will use to construct noise:
|
3917 | //
|
3918 | // f1: distance to the closest feature point
|
3919 | // f2: distance to the second closest feature point
|
3920 | // e: distance to the closest edge (cell boundary)
|
3921 | //
|
3922 | // We also compute "smooth" versions of all of the above quantites, essentially
|
3923 | // replacing "hard" minimums with "smooth" minimums (described by IQ)
|
3924 | float f1_smooth = 8.0;
|
3925 | float f1 = 8.0;
|
3926 | float f2_smooth = 8.0;
|
3927 | float f2 = 8.0;
|
3928 | float e_smooth = 8.0;
|
3929 | float e = 8.0;
|
3930 |
|
3931 | // Variables stored from closest cell
|
3932 | ivec3 mb;
|
3933 | vec3 mr;
|
3934 |
|
3935 | int steps = quality;
|
3936 |
|
3937 | for (int x = -steps; x <= steps; x++)
|
3938 | for (int y = -steps; y <= steps; y++)
|
3939 | for (int z = -steps; z <= steps; z++)
|
3940 | {
|
3941 | ivec3 b = ivec3(x, y, z);
|
3942 | vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
|
3943 | float d = length(r);
|
3944 |
|
3945 | f1_smooth = smin(d, f1_smooth, smoothness);
|
3946 |
|
3947 | // Store un-smoothed distances too
|
3948 | if (d < f1)
|
3949 | {
|
3950 | f2 = f1;
|
3951 | f1 = d;
|
3952 |
|
3953 | mb = ivec3(x, y, z);
|
3954 | mr = r;
|
3955 | }
|
3956 | else if (d < f2)
|
3957 | {
|
3958 | f2 = d;
|
3959 | }
|
3960 | }
|
3961 |
|
3962 | float id = hashwithoutsine13(vec3(p + mb) + seed);
|
3963 |
|
3964 | // Second pass for edge distance
|
3965 | for (int x = -steps; x <= steps; x++)
|
3966 | for (int y = -steps; y <= steps; y++)
|
3967 | for (int z = -steps; z <= steps; z++)
|
3968 | {
|
3969 | // Start search at the cell that contains the closest point to "x" (found in 1st pass)
|
3970 | ivec3 b = mb + ivec3(x, y, z);
|
3971 | vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
|
3972 | float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version?
|
3973 | float d2 = dot(0.5 * (mr + r), normalize(r - mr));
|
3974 |
|
3975 | e_smooth = smin(d1, e_smooth, smoothness);
|
3976 |
|
3977 | e = min(e, d2);
|
3978 |
|
3979 | // Also compute a smooth version of F2 in this pass
|
3980 | {
|
3981 | ivec3 b = ivec3(x, y, z);
|
3982 | if (b != mb)
|
3983 | {
|
3984 | vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
|
3985 | float d = length(r);
|
3986 |
|
3987 | f2_smooth = smin(d, f2_smooth, smoothness);
|
3988 | }
|
3989 | }
|
3990 | }
|
3991 |
|
3992 | // Different visualization modes
|
3993 | if (style == 0)
|
3994 | {
|
3995 | return f1_smooth;
|
3996 | }
|
3997 | if (style == 1)
|
3998 | {
|
3999 | return f2_smooth;
|
4000 | }
|
4001 | if (style == 2)
|
4002 | {
|
4003 | return f2_smooth - f1_smooth;
|
4004 |
|
4005 | // "Pebbles" also cool
|
4006 | //return step(0.2, f2_smooth - f1_smooth);
|
4007 | }
|
4008 | if (style == 3)
|
4009 | {
|
4010 | // This one is really good for rock / stone effects
|
4011 | float a = f1;
|
4012 | float b = f2;
|
4013 | float k = 3.0;
|
4014 | float h = max(k - abs(a - b), 0.0) / k;
|
4015 | float final = min(a, b) - h * h * k * (1.0 / 4.0);
|
4016 | return final;
|
4017 | }
|
4018 | if (style == 4)
|
4019 | {
|
4020 | // Some random adjustments to make this style stand out more
|
4021 | return exp(5.0 * e_smooth);
|
4022 | }
|
4023 | if (style == 5)
|
4024 | {
|
4025 | return pow(f1_smooth, 3.0);
|
4026 | }
|
4027 | if (style == 6)
|
4028 | {
|
4029 | const float eps = 0.0125;
|
4030 |
|
4031 | // Thicker lines as the user increases the smoothness slider
|
4032 | float thickness = smoothness * 0.25 + eps;
|
4033 |
|
4034 | // Blurrier lines as the user increases the smoothness slider
|
4035 | float blur = pow(smoothness, 3.0) * 0.25 + eps;
|
4036 |
|
4037 | return smoothstep(
|
4038 | thickness - thickness * blur,
|
4039 | thickness + thickness * blur,
|
4040 | e
|
4041 | );
|
4042 | }
|
4043 | if (style == 7)
|
4044 | {
|
4045 | return hashwithoutsine13(vec3(p + mb) + seed);
|
4046 | }
|
4047 | }
|
4048 | `,[f,p,m,g,y,v]);return{simplex:e,simplexFractal:r,simplexAshima:o,fbm:c,perlin:d,voronoi:x}}();var vd=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=n,this.fA=s,this.fB=o,this.distortion=a,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=h,this.noiseType=f,this.voronoiStyle=m,this.highCut=g,this.lowCut=y,this.smoothness=v,this.seed=x,this.quality=w,this.isMask=p,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,n,s,o){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(kp)[this.noiseType.value],l=a=="voronoi"?`
|
4049 | float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);
|
4050 |
|
4051 | // Apply clipping to colors
|
4052 | v = remap(v, lowCut, highCut, 0.0, 1.0);
|
4053 | v = smax(v, 0.0, smoothness * 0.25);
|
4054 | v = smin(v, 1.0, smoothness * 0.25);
|
4055 |
|
4056 | // Note that the voronoi mode only uses colors "A" and "C" from the UI
|
4057 | vec4 color = mix(colorA, colorC, v);
|
4058 | `:`
|
4059 | vec3 q = vec3(${a}(st),
|
4060 | ${a}(st + vec3(1.0)),
|
4061 | ${a}(st + vec3(1.0)));
|
4062 | vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
|
4063 | ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
|
4064 | ${a}(st * q));
|
4065 | float f = ${a}(st + r);
|
4066 | vec4 color;
|
4067 | color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
|
4068 | color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
|
4069 | color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
|
4070 | `,u=new ge(`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)
|
4071 | {
|
4072 | // Prevent scale of zero
|
4073 | scale = max(abs(scale), 0.001);
|
4074 |
|
4075 | vec3 st = position / size;
|
4076 | st /= scale;
|
4077 |
|
4078 | ${l}
|
4079 |
|
4080 | float lalpha = alpha * color.a * mask;
|
4081 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
4082 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
4083 |
|
4084 | return clamp(color, 0.0, 1.0).rgb;
|
4085 | }`,[Pn.simplex,Pn.simplexFractal,Pn.simplexAshima,Pn.fbm,Pn.perlin,Pn.voronoi]),c=e.include(u),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(c+"("+h.join(",")+")",this.getType(e),r)}};vd.numOctaves=5;var mA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=n,this.contourWidth=s,this.contourThreshold=o,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,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 n=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${n}_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(`
|
4086 | vID = randomColor.r;
|
4087 | vec2 ${n}_offset = vec2(0.0);
|
4088 | if (${a}) {
|
4089 | vec4 ${n}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
|
4090 | // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
|
4091 | // normals face the camera directly. So we hackily fix this by offsetting the normal
|
4092 | // by a tiny amount.
|
4093 | vec3 ${n}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
|
4094 | ${n}_offset = normalize(${n}_clipNormal.xy) / ${o} * (${s} / 2.0) * ${n}_clipPosition.w * 2.0 * ${l};
|
4095 | ${n}_clipPosition.xy += ${n}_offset;
|
4096 | // TODO(MAX): To handle multiple outline layers, we only want to extrude
|
4097 | // if this offset is the biggest of all the potential offsets
|
4098 | gl_Position = ${n}_clipPosition;
|
4099 | }
|
4100 | `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=e.include(mA.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."),""}},xd=mA;xd.Nodes=function(){let e=new ge(`
|
4101 | float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
|
4102 | {
|
4103 | vec2 halton = haltonSequence[frameIndex];
|
4104 | float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
4105 | float temporalAngle = temporalOffset * PI2;
|
4106 |
|
4107 | vec2 texelSize = (vec2(1.0) / resolution);
|
4108 | vec2 offsetSize = texelSize * outlineWidth * pixelRatio;
|
4109 |
|
4110 | vec2 uvSamples[9];
|
4111 | vec4 normalSamples[9];
|
4112 |
|
4113 | uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);
|
4114 | uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);
|
4115 | uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);
|
4116 | uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);
|
4117 | uvSamples[4] = uv;
|
4118 | uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);
|
4119 | uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);
|
4120 | uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);
|
4121 | uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);
|
4122 |
|
4123 |
|
4124 | normalSamples[0] = texture2D(t, uvSamples[0]);
|
4125 | normalSamples[1] = texture2D(t, uvSamples[1]);
|
4126 | normalSamples[2] = texture2D(t, uvSamples[2]);
|
4127 | normalSamples[3] = texture2D(t, uvSamples[3]);
|
4128 | normalSamples[4] = texture2D(t, uvSamples[4]);
|
4129 | normalSamples[5] = texture2D(t, uvSamples[5]);
|
4130 | normalSamples[6] = texture2D(t, uvSamples[6]);
|
4131 | normalSamples[7] = texture2D(t, uvSamples[7]);
|
4132 | normalSamples[8] = texture2D(t, uvSamples[8]);
|
4133 |
|
4134 | float depthBias = 0.0001;
|
4135 | // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?!
|
4136 | if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {
|
4137 | float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;
|
4138 | if (gl_FragCoord.z > depthAtSample) {
|
4139 | return 0.0;
|
4140 | }
|
4141 | }
|
4142 |
|
4143 | if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {
|
4144 | float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;
|
4145 | if (gl_FragCoord.z > depthAtSample) {
|
4146 | return 0.0;
|
4147 | }
|
4148 | }
|
4149 |
|
4150 | if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {
|
4151 | float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;
|
4152 | if (gl_FragCoord.z > depthAtSample) {
|
4153 | return 0.0;
|
4154 | }
|
4155 | }
|
4156 |
|
4157 | if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {
|
4158 | float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;
|
4159 | if (gl_FragCoord.z > depthAtSample) {
|
4160 | return 0.0;
|
4161 | }
|
4162 | }
|
4163 |
|
4164 |
|
4165 | if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {
|
4166 | float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;
|
4167 | if (gl_FragCoord.z > depthAtSample) {
|
4168 | return 0.0;
|
4169 | }
|
4170 | }
|
4171 |
|
4172 | if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {
|
4173 | float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;
|
4174 | if (gl_FragCoord.z > depthAtSample) {
|
4175 | return 0.0;
|
4176 | }
|
4177 | }
|
4178 |
|
4179 | if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {
|
4180 | float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;
|
4181 | if (gl_FragCoord.z > depthAtSample) {
|
4182 | return 0.0;
|
4183 | }
|
4184 | }
|
4185 |
|
4186 | if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {
|
4187 | float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;
|
4188 | if (gl_FragCoord.z > depthAtSample) {
|
4189 | return 0.0;
|
4190 | }
|
4191 | }
|
4192 |
|
4193 | if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {
|
4194 | float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;
|
4195 | if (gl_FragCoord.z > depthAtSample) {
|
4196 | return 0.0;
|
4197 | }
|
4198 | }
|
4199 |
|
4200 | 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);
|
4201 | 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);
|
4202 |
|
4203 | float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
|
4204 | return edgeNormal;
|
4205 | }
|
4206 | `);return{outline:new ge(`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) {
|
4207 | vec3 result = outlineColor;
|
4208 | float resultAlpha = 0.0;
|
4209 |
|
4210 | vec3 N = normalize(vWNormal);
|
4211 | vec2 nuv = (gl_FragCoord.xy / resolution);
|
4212 | float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
|
4213 | resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);
|
4214 |
|
4215 | //resultAlpha = 1.0;
|
4216 | //result = vec3(sobelSample);
|
4217 |
|
4218 | float t = 1.0 - contourThreshold;
|
4219 | if(positionalLines) {
|
4220 | vec3 NDir = position * contourDirection;
|
4221 | float NT = NDir.x + NDir.y + NDir.z;
|
4222 | float f = fract(NT * contourFrequency * 0.01);
|
4223 | float df = fwidth(NT * contourFrequency);
|
4224 |
|
4225 | float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);
|
4226 | if (g < 1.0 && resultAlpha == 0.0) {
|
4227 | result = contourColor;
|
4228 | resultAlpha = 1.0;
|
4229 | }
|
4230 | }
|
4231 | else {
|
4232 | vec3 NDir = N * contourDirection;
|
4233 | float NT = NDir.x + NDir.y + NDir.z;
|
4234 | float df = fwidth(NT * contourThreshold);
|
4235 | float f = sin(NT * 1.0 * contourFrequency);
|
4236 | float g = smoothstep(0.0, df * contourWidth, 1.0 - f);
|
4237 |
|
4238 | if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {
|
4239 | result = contourColor;
|
4240 | resultAlpha = 1.0 - g;
|
4241 | }
|
4242 | }
|
4243 |
|
4244 | float lalpha = alpha * resultAlpha * mask;
|
4245 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
4246 | accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
|
4247 |
|
4248 | return result;
|
4249 | }`,[e])}}();var co=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y,v,x){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=n,this.blending=s,this.offset=o,this.colorA=a,this.colorB=l,this.frequency=u,this.size=c,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 n;switch(this.style.value){case 0:n="circle";break;case 1:n="ring";break;case 2:n="polygon";break;case 3:n="xcross";break;case 4:n="diamond";break;case 5:n="checkerboard";break;case 6:n="line";break;case 7:n="wave";break;default:n="circle";break}let s=`g${this.uuid.toString().replace(/-/g,"")}`,o=new ge(`float hashwithoutsine12(vec2 p)
|
4250 | {
|
4251 | vec3 p3 = fract(vec3(p.xyx) * .1031);
|
4252 | p3 += dot(p3, p3.yzx + 33.33);
|
4253 | return fract((p3.x + p3.y) * p3.z);
|
4254 | }`),a=new ge(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
|
4255 | {
|
4256 | const float mid = 0.5;
|
4257 | float radians = a * (PI / 180.0);
|
4258 | vec2 rotated = vec2(
|
4259 | cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,
|
4260 | cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid
|
4261 | );
|
4262 | return repeat ? fract(rotated): rotated;
|
4263 | }`),l="";if(this.projection.value===4){let d=this.style.value===2?`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f=this.style.value===2?`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,p=this.style.value===2?`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;l=`
|
4264 | vec3 p = position;
|
4265 | float factor = 0.0125;
|
4266 | vec2 uv0 = fract(p.xy * factor);
|
4267 | vec2 uv1 = fract(p.zy * factor);
|
4268 | vec2 uv2 = fract(p.xz * factor);
|
4269 |
|
4270 | uv0 = rotate_uv(uv0 + offset, rotation, true);
|
4271 | uv1 = rotate_uv(uv1 + offset, rotation, true);
|
4272 | uv2 = rotate_uv(uv2 + offset, rotation, true);
|
4273 |
|
4274 | float d0 = ${d};
|
4275 | float d1 = ${f};
|
4276 | float d2 = ${p};
|
4277 |
|
4278 | // Range from 3 to 128 seems to be good
|
4279 | float exponent = (1.0 - blending) * 125.0 + 3.0;
|
4280 |
|
4281 | vec3 n = vObjectNormal;
|
4282 | vec3 weights = abs(normalize(n));
|
4283 | weights = pow(weights, vec3(exponent));
|
4284 | weights /= dot(weights, vec3(1.0));
|
4285 | d0 *= weights.z;
|
4286 | d1 *= weights.x;
|
4287 | d2 *= weights.y;
|
4288 | float draw = d0 + d1 + d2;
|
4289 |
|
4290 | vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;
|
4291 | `}else{let d=this.style.value===2?`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f="";this.axis.value===0?f=`float radius = length(p);
|
4292 | float theta = atan(p.y, p.z);
|
4293 | float phi = acos(p.x / radius);`:this.axis.value===1?f=`float radius = length(p);
|
4294 | float theta = atan(p.x, p.z);
|
4295 | float phi = acos(p.y / radius);`:(this.axis.value,f=`float radius = length(p);
|
4296 | float theta = atan(p.y, p.x);
|
4297 | 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=`
|
4298 | vec3 p = position;
|
4299 | ${f}
|
4300 | custom_uv = vec2(theta, phi);
|
4301 | custom_uv /= PI;
|
4302 | `;break;case 3:break;default:break}l=`
|
4303 | vec2 custom_uv;
|
4304 | ${p}
|
4305 |
|
4306 | custom_uv += offset;
|
4307 | custom_uv = fract(custom_uv);
|
4308 | custom_uv = rotate_uv(custom_uv, rotation, true);
|
4309 |
|
4310 | float draw = ${d};
|
4311 | `}let u=new ge(`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) {
|
4312 | const float TWO_PI = PI * 2.0;
|
4313 | float smoothness_remapped = pow(smoothness, 5.0);
|
4314 |
|
4315 | ${l}
|
4316 |
|
4317 | // Construct final output color
|
4318 | vec4 color = mix(colorA, colorB, draw);
|
4319 | color.a = clamp(color.a, 0.0, 1.0);
|
4320 |
|
4321 | // Apply cuts
|
4322 | color.a *=
|
4323 | step(vertical.x, custom_uv.y) *
|
4324 | step(custom_uv.y, vertical.y);
|
4325 | color.a *=
|
4326 | step(horizontal.x, abs(custom_uv.x)) *
|
4327 | step(abs(custom_uv.x), horizontal.y);
|
4328 |
|
4329 | // Accumulate alpha
|
4330 | float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;
|
4331 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
4332 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
4333 |
|
4334 | return clamp(color, 0.0, 1.0).rgb;
|
4335 | }`,[a,o,co.DrawFunctions.circle,co.DrawFunctions.ring,co.DrawFunctions.polygon,co.DrawFunctions.cross,co.DrawFunctions.diamond,co.DrawFunctions.checkerboard,co.DrawFunctions.line,co.DrawFunctions.wave]),c=e.include(u),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(c+"("+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)}},bd=co;bd.DrawFunctions=function(){let e=new ge(`float hashwithoutsine12(vec2 p) {
|
4336 | vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
4337 | p3 += dot(p3, p3.yzx + 33.33);
|
4338 | return fract((p3.x + p3.y) * p3.z);
|
4339 | }`),r=new ge(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
|
4340 | // Create tiles in UV-space
|
4341 | uv *= frequency;
|
4342 |
|
4343 | // Integer coords
|
4344 | vec2 i = floor(uv);
|
4345 |
|
4346 | // Offset every other row based on zigzag param, then compute fractional coords
|
4347 | float row_offset = mod(i.y, 2.0);
|
4348 | uv.x += row_offset * zigzag;
|
4349 | vec2 f = fract(uv);
|
4350 |
|
4351 | // Rotate the tile itself:
|
4352 | // const float mid = 0.5;
|
4353 | // f = vec2(
|
4354 | // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid,
|
4355 | // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid
|
4356 | // );
|
4357 | // f = fract(f);
|
4358 |
|
4359 | f = f * 2.0 - 1.0;
|
4360 |
|
4361 | // Recompute integer coords after shifting - then, random value per tile
|
4362 | i = floor(uv);
|
4363 | float rand = (hashwithoutsine12(i) * 5.0 + 1.0);
|
4364 | float jitter = mix(1.0, rand, variation);
|
4365 | f *= jitter;
|
4366 |
|
4367 | return f;
|
4368 | }`,[e]),n=new ge(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4369 | vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
4370 | return smoothstep(
|
4371 | -smoothness,
|
4372 | smoothness,
|
4373 | length(f) - size
|
4374 | );
|
4375 | }`,[r]),s=new ge(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4376 | vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
4377 |
|
4378 | float d = length(f);
|
4379 | const float inner_width = 0.5;
|
4380 |
|
4381 | float outer = smoothstep(-smoothness, smoothness, d - size);
|
4382 | float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
|
4383 | return outer + (1.0 - inner);
|
4384 | }`,[r]),o=new ge(`float sdf_ngon(in vec2 p, in float r, in int n) {
|
4385 | float an = (PI * 2.0) / float(n);
|
4386 | float he = r * tan(0.5 * an);
|
4387 |
|
4388 | // Rotate to first sector
|
4389 | p = -p.yx;
|
4390 | float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);
|
4391 | vec2 cs = vec2(cos(bn), sin(bn));
|
4392 | p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;
|
4393 |
|
4394 | // Side of polygon
|
4395 | return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);
|
4396 | }
|
4397 |
|
4398 | 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) {
|
4399 | vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
4400 | return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
|
4401 | }`,[r]),a=new ge(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
|
4402 | p = abs(p);
|
4403 | p = (p.y > p.x) ? p.yx : p.xy;
|
4404 | vec2 q = p - b;
|
4405 | float k = max(q.y, q.x);
|
4406 | vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);
|
4407 | return sign(k) * length(max(w, 0.0)) + r;
|
4408 | }
|
4409 |
|
4410 | // Avoid namespace conflicts
|
4411 | float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4412 | vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
4413 | return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
|
4414 | }`,[r]),l=new ge(`float ndot(vec2 a, vec2 b) {
|
4415 | return a.x*b.x - a.y*b.y;
|
4416 | }
|
4417 |
|
4418 | float sdf_diamond(in vec2 p, in vec2 b) {
|
4419 | p = abs(p);
|
4420 | float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);
|
4421 | float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));
|
4422 | return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);
|
4423 | }
|
4424 |
|
4425 | float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4426 | vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
|
4427 | return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
|
4428 | }`,[r]),u=new ge(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4429 | uv *= frequency;
|
4430 | vec2 i = floor(uv);
|
4431 |
|
4432 | float offset = mod(i.y, 2.0);
|
4433 |
|
4434 | uv.x += offset + zigzag * offset;
|
4435 | float x = floor(uv.x);
|
4436 |
|
4437 | return mod(x, 2.0);
|
4438 | }`),c=new ge(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4439 | vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
|
4440 |
|
4441 | // Different approach for variation param here
|
4442 | float row = floor(uv * frequency).y;
|
4443 | float rand = hashwithoutsine12(vec2(row));
|
4444 | float s = mix(size, size * rand, variation);
|
4445 |
|
4446 | return smoothstep(
|
4447 | s - smoothness,
|
4448 | s + smoothness,
|
4449 | abs(f.y)
|
4450 | );
|
4451 | }`,[r]),h=new ge(`// Uses bisection
|
4452 | float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
|
4453 | // Convert all data to a primitive cosine wave
|
4454 | p = c * (p - vec2(d, a));
|
4455 |
|
4456 | const float TWO_PI = PI * 2.0;
|
4457 |
|
4458 | // Reduce to principal half cycle
|
4459 | p.x = mod(p.x, TWO_PI);
|
4460 | if (p.x > PI) {
|
4461 | p.x = TWO_PI - p.x;
|
4462 | }
|
4463 |
|
4464 | // Find zero of derivative (minimize distance)
|
4465 | float xa = 0.0;
|
4466 | float xb = TWO_PI;
|
4467 |
|
4468 | // 24 bit precision
|
4469 | for (int i = 0; i < 24; i++) {
|
4470 | float x = 0.5 * (xa + xb);
|
4471 | float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));
|
4472 | if (y < 0.0) xa = x;
|
4473 | else xb = x;
|
4474 | }
|
4475 | float x = 0.5 * (xa + xb);
|
4476 |
|
4477 | // Compute distance
|
4478 | vec2 q = vec2(x, b * c * cos(x));
|
4479 | return length(p - q) / c;
|
4480 | }
|
4481 |
|
4482 | float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
|
4483 | float repeat = frequency.x;
|
4484 | uv *= repeat;
|
4485 | vec2 i = floor(uv);
|
4486 | float row_offset = mod(i.y, 2.0);
|
4487 | uv.x += row_offset * zigzag;
|
4488 | vec2 f = vec2(uv.x, fract(uv.y));
|
4489 |
|
4490 | // Generalized cosine: y(x) = a + b * cos(cx + d)
|
4491 | const float amplitude = 0.125;
|
4492 | float wave_frequency = frequency.y * 0.1;
|
4493 | float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);
|
4494 |
|
4495 | // Different approach for variation param here
|
4496 | float rand = hashwithoutsine12(vec2(i.y));
|
4497 | float s = mix(size, size * rand, variation);
|
4498 |
|
4499 | return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
|
4500 | }`);return{tileAndCenter:r,circle:n,ring:s,polygon:o,cross:a,diamond:l,checkerboard:u,line:c,wave:h}}();var gA=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=n,this.noiseStrength=s,this.noiseScale=o,this.offset=a,this.isMask=u,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 n=e.include(gA.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(n+"("+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)}},wd=gA;wd.Nodes=function(){let e=new ge(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
|
4501 | vec3 st = position / noiseScale;
|
4502 | vec3 q = vec3(simplex3d(st),
|
4503 | simplex3d(st + vec3(1.0)),
|
4504 | simplex3d(st + vec3(1.0)));
|
4505 |
|
4506 | vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
|
4507 | simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
|
4508 | simplex3d(st * q));
|
4509 |
|
4510 | float noise = simplex3d(st + r);
|
4511 |
|
4512 | 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);
|
4513 | }`,[Pn.simplex]);return{rainbow:new ge(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
|
4514 | vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
|
4515 |
|
4516 | float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
|
4517 |
|
4518 | float lalpha = alpha * rainbowContribution * mask;
|
4519 | calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
|
4520 | accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
|
4521 |
|
4522 | return res;
|
4523 | }`,[e])}}();var yA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=n,this.source=s,this.isWorldSpace=o,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=u,this.offset=c,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 n=e.include(yA.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(n+"("+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)}},Sd=yA;Sd.Nodes=function(){let e=new ge(`float rand(float n) {
|
4524 | return fract(sin(n) * 43758.5453123);
|
4525 | }`),r=new ge(`float hash1(float p) {
|
4526 | p = fract(p * 0.011);
|
4527 | p *= p + 7.5;
|
4528 | p *= p + p;
|
4529 | return fract(p);
|
4530 | }`),n=new ge(`float valueNoise(vec3 x) {
|
4531 | const vec3 step = vec3(110, 241, 171);
|
4532 |
|
4533 | vec3 i = floor(x);
|
4534 | vec3 f = fract(x);
|
4535 |
|
4536 | // For performance, compute the base input to a 1D hash from the integer part of the argument and the
|
4537 | // incremental change to the 1D based on the 3D -> 1D wrapping
|
4538 | float n = dot(i, step);
|
4539 |
|
4540 | vec3 u = f * f * (3.0 - 2.0 * f);
|
4541 | return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
|
4542 | mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
|
4543 | mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
|
4544 | mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
|
4545 | }`,[r]),s=new ge(`vec3 hash3(vec3 x) {
|
4546 | x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
|
4547 | dot(x,vec3(269.5, 183.3, 246.1)),
|
4548 | dot(x,vec3(113.5, 271.9, 124.6)));
|
4549 |
|
4550 | return fract(sin(x)*43758.5453123);
|
4551 | }`),o=new ge(`vec3 voronoiNoise(in vec3 x)
|
4552 | {
|
4553 | vec3 p = floor(x);
|
4554 | vec3 f = fract(x);
|
4555 |
|
4556 | float id = 0.0;
|
4557 | vec2 res = vec2(100.0);
|
4558 |
|
4559 | for(int k=-1; k<=1; k++)
|
4560 | for(int j=-1; j<=1; j++)
|
4561 | for(int i=-1; i<=1; i++)
|
4562 | {
|
4563 | vec3 b = vec3(float(i), float(j), float(k));
|
4564 |
|
4565 | // Comment out the "+ hash(p + b);" part below to get "square" cells
|
4566 | vec3 r = vec3(b) - f + hash3(p + b);
|
4567 | float d = dot(r, r);
|
4568 |
|
4569 | if (d < res.x)
|
4570 | {
|
4571 | id = dot(p + b, vec3(1.0, 57.0, 113.0));
|
4572 | res = vec2(d, res.x);
|
4573 | }
|
4574 | else if (d < res.y)
|
4575 | {
|
4576 | res.y = d;
|
4577 | }
|
4578 | }
|
4579 |
|
4580 | return vec3(sqrt(res), abs(id));
|
4581 | }
|
4582 | `,[s]);return{toon:new ge(`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) {
|
4583 | float t = 0.0;
|
4584 | float shadow = 1.0;
|
4585 |
|
4586 | if (positioning == 0) {
|
4587 |
|
4588 | // Can't do this mode if lighting is "none"
|
4589 | #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
|
4590 |
|
4591 | // Algorithm from Chapter 10 of Graphics Shaders
|
4592 | const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
|
4593 | vec3 lpos;
|
4594 | vec3 l;
|
4595 | float dproduct;
|
4596 |
|
4597 | #if (NUM_POINT_LIGHTS > 0)
|
4598 |
|
4599 | #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
|
4600 | PointLightShadow pointLightShadow;
|
4601 | #endif
|
4602 |
|
4603 | #pragma unroll_loop_start
|
4604 | for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
|
4605 | // Light positions are in view-space for some reason?
|
4606 | lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
|
4607 | l = normalize(lpos - worldPosition);
|
4608 |
|
4609 | dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
4610 |
|
4611 | // TODO: we want to use "intensity" but it isn't available in the shader code
|
4612 | //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
|
4613 |
|
4614 | t = max(t, dproduct);
|
4615 |
|
4616 | // Accumulate shadow contribution
|
4617 | #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
|
4618 | pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
|
4619 | shadow *= getPointShadow(
|
4620 | pointShadowMap[UNROLLED_LOOP_INDEX],
|
4621 | pointLightShadow.shadowMapSize,
|
4622 | pointLightShadow.shadowBias,
|
4623 | pointLightShadow.shadowRadius,
|
4624 | vPointShadowCoord[UNROLLED_LOOP_INDEX],
|
4625 | pointLightShadow.shadowCameraNear,
|
4626 | pointLightShadow.shadowCameraFar);
|
4627 | #endif
|
4628 | }
|
4629 | #pragma unroll_loop_end
|
4630 |
|
4631 | #endif
|
4632 |
|
4633 | #if NUM_DIR_LIGHTS > 0
|
4634 |
|
4635 | #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
|
4636 | DirectionalLightShadow directionalLightShadow;
|
4637 | #endif
|
4638 |
|
4639 | #pragma unroll_loop_start
|
4640 | for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
|
4641 | // Use the direction vector for directional lights instead
|
4642 | l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
|
4643 |
|
4644 | dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
4645 | t = max(t, dproduct);
|
4646 |
|
4647 | // Accumulate shadow contribution
|
4648 | #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
|
4649 | directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
|
4650 | shadow *= getShadow(
|
4651 | UNROLLED_LOOP_INDEX,
|
4652 | directionalShadowMap[UNROLLED_LOOP_INDEX],
|
4653 | directionalLightShadow.shadowMapSize,
|
4654 | directionalLightShadow.shadowBias,
|
4655 | directionalLightShadow.shadowRadius,
|
4656 | vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
|
4657 | #endif
|
4658 | }
|
4659 | #pragma unroll_loop_end
|
4660 |
|
4661 | #endif
|
4662 |
|
4663 | #if NUM_SPOT_LIGHTS > 0
|
4664 |
|
4665 | #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
|
4666 | SpotLightShadow spotLightShadow;
|
4667 | #endif
|
4668 |
|
4669 | #pragma unroll_loop_start
|
4670 | for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
|
4671 | lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
|
4672 | l = normalize(lpos - worldPosition);
|
4673 |
|
4674 | dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
4675 | t = max(t, dproduct);
|
4676 |
|
4677 | // Accumulate shadow contribution
|
4678 | #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
|
4679 | spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
|
4680 | shadow *= getShadow(
|
4681 | UNROLLED_LOOP_INDEX,
|
4682 | spotShadowMap[UNROLLED_LOOP_INDEX],
|
4683 | spotLightShadow.shadowMapSize,
|
4684 | spotLightShadow.shadowBias,
|
4685 | spotLightShadow.shadowRadius,
|
4686 | vSpotLightCoord[UNROLLED_LOOP_INDEX]);
|
4687 | #endif
|
4688 | }
|
4689 | #pragma unroll_loop_end
|
4690 |
|
4691 | #endif
|
4692 |
|
4693 | t = clamp(t, 0.0, 1.0);
|
4694 |
|
4695 | #endif
|
4696 |
|
4697 | } else if (positioning == 1) {
|
4698 |
|
4699 | vec3 origin = mix(position, worldPosition, float(isWorldSpace));
|
4700 | vec3 direction = normalize(source - origin);
|
4701 | t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
|
4702 |
|
4703 | } else {
|
4704 |
|
4705 | vec3 origin = worldPosition;
|
4706 | vec3 source = cameraPosition - offset;
|
4707 | vec3 direction = normalize(source - origin);
|
4708 | t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
|
4709 |
|
4710 | }
|
4711 |
|
4712 | if (noiseStrength > 0.0) {
|
4713 | // Distort with noise
|
4714 | vec3 st = position / noiseScale;
|
4715 |
|
4716 | // Voronoi "smooth" noise
|
4717 | float noise = 1.0 - voronoiNoise(st).x;
|
4718 |
|
4719 | // Voronoi cellular noise
|
4720 | //float noise = 1.0 - rand(voronoiNoise(st).z);
|
4721 |
|
4722 | // Position warp noise
|
4723 | // vec3 offset = vec3(
|
4724 | // simplex3d(st),
|
4725 | // simplex3d(st + vec3(111.1, 143.89, 217.19)),
|
4726 | // simplex3d(st + vec3(171.1, 247.89, 117.23))
|
4727 | // );
|
4728 | // st += offset;
|
4729 | // float noise = valueNoise(st);
|
4730 |
|
4731 | t += noise * noiseStrength;
|
4732 | }
|
4733 |
|
4734 | t = clamp(t, 0.0, 1.0);
|
4735 |
|
4736 | // Compute ramp color
|
4737 | float p;
|
4738 | vec4 color = colors[0];
|
4739 | for (int i = 1; i < COLORS_MAX; i++) {
|
4740 | p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
|
4741 | color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
|
4742 | }
|
4743 |
|
4744 | // Incorporate custom shadow color
|
4745 | if (positioning == 0) {
|
4746 |
|
4747 | vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
|
4748 | color.rgb = mix(blendedShadow, color.rgb, shadow);
|
4749 |
|
4750 | }
|
4751 |
|
4752 | // Accumulate alpha as usual
|
4753 | float lalpha = alpha * color.a * mask;
|
4754 | calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
4755 | accumAlpha += (1.0 - accumAlpha) * lalpha;
|
4756 |
|
4757 | return color.xyz;
|
4758 |
|
4759 | }`,[Pn.simplex,e,n,o])}}();var oI=function(){return{textureBicubic:new ge(`float w0( float a ) {
|
4760 | return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
4761 | }
|
4762 |
|
4763 | float w1( float a ) {
|
4764 | return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
4765 | }
|
4766 |
|
4767 | float w2( float a ){
|
4768 | return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
4769 | }
|
4770 |
|
4771 | float w3( float a ) {
|
4772 | return ( 1.0 / 6.0 ) * ( a * a * a );
|
4773 | }
|
4774 |
|
4775 | // g0 and g1 are the two amplitude functions
|
4776 | float g0( float a ) {
|
4777 | return w0( a ) + w1( a );
|
4778 | }
|
4779 |
|
4780 | float g1( float a ) {
|
4781 | return w2( a ) + w3( a );
|
4782 | }
|
4783 |
|
4784 | // h0 and h1 are the two offset functions
|
4785 | float h0( float a ) {
|
4786 | return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
4787 | }
|
4788 |
|
4789 | float h1( float a ) {
|
4790 | return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
4791 | }
|
4792 |
|
4793 | vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
4794 | uv = uv * texelSize.zw + 0.5;
|
4795 |
|
4796 | vec2 iuv = floor( uv );
|
4797 | vec2 fuv = fract( uv );
|
4798 |
|
4799 | float g0x = g0( fuv.x );
|
4800 | float g1x = g1( fuv.x );
|
4801 | float h0x = h0( fuv.x );
|
4802 | float h1x = h1( fuv.x );
|
4803 | float h0y = h0( fuv.y );
|
4804 | float h1y = h1( fuv.y );
|
4805 |
|
4806 | vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
4807 | vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
4808 | vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
4809 | vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
4810 |
|
4811 | return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
4812 | g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
4813 | }
|
4814 |
|
4815 | vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
4816 | vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
4817 | vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
4818 | vec2 fLodSizeInv = 1.0 / fLodSize;
|
4819 | vec2 cLodSizeInv = 1.0 / cLodSize;
|
4820 | vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
4821 | vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
4822 | return mix( fSample, cSample, fract( lod ) );
|
4823 | }`)}}();function aI(i,t){return i>=t?new N(t/i,1):new N(1,i/t)}var vA=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=n,this.transmissionSamplerSize=s,this.transmissionSamplerMap=o,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=u,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,je.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let n=e.include(vA.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(n+"("+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)}},Ad=vA;Ad.Nodes=function(){let e=new ge(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
|
4824 | // Slightly modified version of this:
|
4825 | // https://www.shadertoy.com/view/ltScRG
|
4826 |
|
4827 | // Special case for blur == 0.0
|
4828 | if (lod == 0.0) {
|
4829 | #ifdef TEXTURE_LOD_EXT
|
4830 | return texture2DLodEXT( sp, U, 0.0).rgb;
|
4831 | #else
|
4832 | return textureLod( sp, U, 0.0).rgb;
|
4833 | #endif
|
4834 | }
|
4835 |
|
4836 | vec2 texelSize = vec2(1.0) / resolution;
|
4837 | vec2 halton = haltonSequence[frameIndex];
|
4838 | float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
4839 | float temporalAngle = temporalOffset * PI2;
|
4840 | vec3 res = vec3(0.0);
|
4841 | vec2 uv = vec2(0.0);
|
4842 | vec2 offset = vec2(0.0);
|
4843 | vec2 vogelSample = vec2(0.0);
|
4844 | for (int i = 0; i < NUM_SAMPLES; i++) {
|
4845 | vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;
|
4846 | offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20
|
4847 | uv = U + offset;
|
4848 | float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));
|
4849 | if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
|
4850 | uv = unrefractedU;
|
4851 | lod = lod > 4.0 ? lod : lod / 2.0;
|
4852 | }
|
4853 | res += textureLod(sp, uv, lod).rgb;
|
4854 | }
|
4855 | return res / float(NUM_SAMPLES);
|
4856 | }`),r=new ge(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
|
4857 | // Direction of refracted light.
|
4858 | vec3 refractionVector = refract( -v, n, 1.0 / ior );
|
4859 |
|
4860 | // Compute rotation-independant scaling of the model matrix.
|
4861 | vec3 modelScale;
|
4862 | modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
4863 | modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
4864 | modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
4865 |
|
4866 | // The thickness is specified in local space
|
4867 | return normalize( refractionVector ) * thickness * modelScale;
|
4868 | }`),n=new ge(`float applyIorToRoughness( float roughness, float ior ) {
|
4869 | // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
|
4870 | // an IOR of 1.5 results in the default amount of microfacet refraction.
|
4871 | return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
4872 | }`),s=new ge(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
|
4873 | // Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
|
4874 | // also the code in convertTransmission.ts, which runs during export
|
4875 | #ifdef IS_THREEJS_EXPORT
|
4876 | float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);
|
4877 | return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;
|
4878 | #else
|
4879 | float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
4880 | float lod = applyIorToRoughness(roughness, ior);
|
4881 | return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
|
4882 | #endif
|
4883 | }`,[oI.textureBicubic,n,e]),o=new ge(`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 ) {
|
4884 | vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
4885 | vec3 refractedRayExit = position + transmissionRay;
|
4886 |
|
4887 | // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
|
4888 | vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
4889 | vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
4890 | refractionCoords += 1.0;
|
4891 | refractionCoords /= 2.0;
|
4892 |
|
4893 | vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
|
4894 | vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
|
4895 | unrefractedCoords += 1.0;
|
4896 | unrefractedCoords /= 2.0;
|
4897 |
|
4898 | // Sample framebuffer to get pixel the refracted ray hits.
|
4899 | return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
|
4900 | }`,[s,r]);return{transmission:new ge(`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) {
|
4901 | vec3 v = vec3(0.);
|
4902 | if (isOrthographic) {
|
4903 | v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
4904 | } else {
|
4905 | v = normalize(vWPosition - cameraPosition);
|
4906 | }
|
4907 | vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
|
4908 |
|
4909 | float lalpha = alpha * mask;
|
4910 | calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
|
4911 | accumAlpha += ( 1.0 - accumAlpha ) * alpha;
|
4912 |
|
4913 | return transmission;
|
4914 | }`,[o])}}();var xA=(e=>(e.NOISE="noise",e.MAP="map",e))(xA||{}),bA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d){super("v3");this.displacementTypeIndex=new yt(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(xA)[this.displacementTypeIndex.value]==="map"&&(this.mat=new ud(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=h,this.noiseFunctionIndex=d,this.voronoiStyle=s,this.smoothness=o,this.seed=a,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,s=[];switch(s.push("displaced_position"),s.push("displaced_normal"),Object.values(xA)[this.displacementTypeIndex.value]){case"map":{n=e.include(bA.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(kp)[this.noiseFunctionIndex.value],l=new ge(`vec3 orthogonal(vec3 v) {
|
4915 | return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
4916 | }`),u=a=="voronoi"?`
|
4917 | float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
|
4918 | v = remap(v, lowCut, highCut, 0.0, 1.0);
|
4919 | v = smax(v, 0.0, smoothness * 0.25);
|
4920 | v = smin(v, 1.0, smoothness * 0.25);
|
4921 |
|
4922 | return p + n * v * intensity;
|
4923 | `:`
|
4924 | return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
|
4925 | `,c=new ge(`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) {
|
4926 | ${u}
|
4927 | }`,[Pn.simplex,Pn.simplexFractal,Pn.simplexAshima,Pn.fbm,Pn.perlin,Pn.voronoi]),h=new ge(`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) {
|
4928 | vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
4929 | vec3 tangent1 = orthogonal(normal);
|
4930 | vec3 tangent2 = normalize(cross(normal, tangent1));
|
4931 |
|
4932 | // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
|
4933 | // This caused some small oval/circular visual artifacts in the lighting.
|
4934 | // For now, simply using neighbors further away betters the problem,
|
4935 | // but we should figure out the underlying cause when we have some time.
|
4936 | // Maybe its related to how we calculate the tangent and bitangent?
|
4937 | vec3 nearby1 = position + tangent1;
|
4938 | vec3 nearby2 = position + tangent2;
|
4939 | vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
4940 | vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
|
4941 | displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
4942 | return displaced_position;
|
4943 | }`,[c,l]);n=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(n+"("+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)}},_d=bA;_d.Nodes=function(){let e=new ge(`vec3 orthogonal(vec3 v) {
|
4944 | return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
|
4945 | }`),r=new ge(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
|
4946 | vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
|
4947 | vec4 tmp = texture2D(tex, uvs);
|
4948 | vec3 col = tmp.rgb;
|
4949 | if (crop > 0.5) {
|
4950 | if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
|
4951 | return 0.0;
|
4952 | }
|
4953 | }
|
4954 | return col.r;
|
4955 | }`);return{map:new ge(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
|
4956 | vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
|
4957 | vec3 tangent1 = normalize(orthogonal(normal));
|
4958 | vec3 tangent2 = normalize(cross(normal, tangent1));
|
4959 | vec3 nearby1 = position + tangent1 * 0.1;
|
4960 | vec3 nearby2 = position + tangent2 * 0.1;
|
4961 | vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
4962 | vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
4963 | displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
4964 | return displaced_position;
|
4965 | }`,[e,r])}}();var je={normalRenderTarget:new ii,normalRenderTargetDepth:new ii,transmissionRenderTarget:new ii,aspectRatio:new wr,transmissionSize:new wr(2048,2048),transmissionRenderTargetDepth:new ii,aoRenderTarget:new ii,aoEnabled:new Tr,pixelRatioNode:new Ce(1),resolution:new wr,penumbraSize:new Ms(5,.5),frameIndex:new yt(0),transmissionLod:new yt(2)};for(let i of Object.values(je))i.isRenderGlobal=!0;var Sc=class extends Mn{constructor(){super("basic");this.nodeType="Basic";this.color=new zt(an),this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ys.merge([we.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
4966 | `));let s=["#include <beginnormal_vertex>",`
|
4967 | #if !defined( USE_LAYER_DISPLACE )
|
4968 | #include <defaultnormal_vertex>
|
4969 | #endif
|
4970 |
|
4971 | vec3 displaced_position = position;
|
4972 | vec3 displaced_normal = normal;
|
4973 |
|
4974 | #if defined( USE_LAYER_DISPLACE )
|
4975 | vec3 transformed;
|
4976 | vec3 transformedNormal;
|
4977 | #endif
|
4978 | `,"#include <normal_vertex>",`
|
4979 | #if !defined( USE_LAYER_DISPLACE )
|
4980 | #include <begin_vertex>
|
4981 | #endif /* !USE_LAYER_DISPLACE */
|
4982 | `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
|
4983 | `)}else{this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),s=this.alpha?this.alpha.flow(e,"f"):void 0,o=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=s!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
|
4984 | `));let l=["#include <normal_fragment_begin>",n.code];s&&l.push(s.code,"#ifdef ALPHATEST"," if ( "+s.result+" <= ALPHATEST ) discard;","#endif"),a?l.push(a.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${n.result};`);let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),s?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${s.result} * ${u} );`):l.push("gl_FragColor = vec4("+n.result+", 1.0 );"),o&&l.push(`gl_FragColor.a *= ${o.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),r=l.join(`
|
4985 | `)}return r}};var Vp=class extends Mn{constructor(){super("lambert");this.nodeType="Lambert";this.color=new zt(an),this.emissive=new zt(0),this.emissiveIntensity=new Ce(1),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!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 n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ys.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
4986 | `));let s=["#include <beginnormal_vertex>",`
|
4987 | #ifndef USE_LAYER_DISPLACE
|
4988 | #include <defaultnormal_vertex>
|
4989 | #endif
|
4990 |
|
4991 | vec3 displaced_position = position;
|
4992 | vec3 displaced_normal = normal;
|
4993 |
|
4994 | #ifdef USE_LAYER_DISPLACE
|
4995 | vec3 transformed;
|
4996 | vec3 transformedNormal;
|
4997 | #endif
|
4998 | `,"#include <normal_vertex>",`
|
4999 | #ifndef USE_LAYER_DISPLACE
|
5000 | #include <begin_vertex>
|
5001 | #endif
|
5002 | `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
|
5003 | vec3 diffuse = vec3( 1.0 );
|
5004 | GeometricContext geometry;
|
5005 | geometry.position = mvPosition.xyz;
|
5006 | geometry.normal = normalize( transformedNormal );
|
5007 | geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
5008 | `),s.push(`
|
5009 | GeometricContext backGeometry;
|
5010 | backGeometry.position = geometry.position;
|
5011 | backGeometry.normal = -geometry.normal;
|
5012 | backGeometry.viewDir = geometry.viewDir;
|
5013 | vLightFront = vec3( 0.0 );
|
5014 | vIndirectFront = vec3( 0.0 );
|
5015 | #ifdef DOUBLE_SIDED
|
5016 | vLightBack = vec3( 0.0 );
|
5017 | vIndirectBack = vec3( 0.0 );
|
5018 | #endif
|
5019 | IncidentLight directLight;
|
5020 | float dotNL;
|
5021 | vec3 directLightColor_Diffuse;
|
5022 | vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
|
5023 | vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
|
5024 | #ifdef DOUBLE_SIDED
|
5025 | vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
|
5026 | vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
|
5027 | #endif
|
5028 | #if NUM_POINT_LIGHTS > 0
|
5029 | #pragma unroll_loop_start
|
5030 | for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
5031 | getPointLightInfo( pointLights[ i ], geometry, directLight );
|
5032 | dotNL = dot( geometry.normal, directLight.direction );
|
5033 | directLightColor_Diffuse = directLight.color;
|
5034 | vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
5035 | #ifdef DOUBLE_SIDED
|
5036 | vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
5037 | #endif
|
5038 | }
|
5039 | #pragma unroll_loop_end
|
5040 | #endif
|
5041 | #if NUM_SPOT_LIGHTS > 0
|
5042 | #pragma unroll_loop_start
|
5043 | for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
5044 | getSpotLightInfo( spotLights[ i ], geometry, directLight );
|
5045 | dotNL = dot( geometry.normal, directLight.direction );
|
5046 | directLightColor_Diffuse = directLight.color;
|
5047 | vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
5048 | #ifdef DOUBLE_SIDED
|
5049 | vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
5050 | #endif
|
5051 | }
|
5052 | #pragma unroll_loop_end
|
5053 | #endif
|
5054 | #if NUM_DIR_LIGHTS > 0
|
5055 | #pragma unroll_loop_start
|
5056 | for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
5057 | getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
|
5058 | dotNL = dot( geometry.normal, directLight.direction );
|
5059 | directLightColor_Diffuse = directLight.color;
|
5060 | vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
5061 | #ifdef DOUBLE_SIDED
|
5062 | vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
|
5063 | #endif
|
5064 | }
|
5065 | #pragma unroll_loop_end
|
5066 | #endif
|
5067 | #if NUM_HEMI_LIGHTS > 0
|
5068 | #pragma unroll_loop_start
|
5069 | for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
5070 | vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
5071 | #ifdef DOUBLE_SIDED
|
5072 | vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
|
5073 | #endif
|
5074 | }
|
5075 | #pragma unroll_loop_end
|
5076 | #endif
|
5077 | `," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
|
5078 | `)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),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 n=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"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
|
5079 | `));let f=["#include <normal_fragment_begin>",`
|
5080 | // NOTE: gl_FrontFacing alternative using face normal estimation.
|
5081 | vec3 viewdx = dFdx(vViewPosition);
|
5082 | vec3 viewdy = dFdy(vViewPosition);
|
5083 | vec3 faceNormal = normalize(cross(viewdx, viewdy));
|
5084 | bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
|
5085 | `,"#include <clipping_planes_fragment>"];f.push(n.code,"vec3 diffuseColor = "+n.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),s&&f.push(s.code,"reflectedLight.directDiffuse += "+s.result+" * "+o.result+";"),f.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
|
5086 | if (outgoingLight != diffuseColor) {
|
5087 | float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
5088 | accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
|
5089 | outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${u.result} );
|
5090 |
|
5091 | outgoingLight *= ao;
|
5092 | }
|
5093 | `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
|
5094 | `)}return r}};var oa=function(){let i=new ge(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
|
5095 |
|
5096 | // Gradient of UVs w.r.t. X coordinate (in screen-space)
|
5097 | vec2 dSTdx = dFdx(bumpMapUv);
|
5098 |
|
5099 | // Gradient of UVs w.r.t. Y coordinate (in screen-space)
|
5100 | vec2 dSTdy = dFdy(bumpMapUv);
|
5101 |
|
5102 | // Forward differencing
|
5103 | float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);
|
5104 | float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;
|
5105 | float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;
|
5106 |
|
5107 | return vec2( dBx, dBy );
|
5108 | }`),t=new ge(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
5109 | vec3 vSigmaX = dFdx( surf_pos.xyz );
|
5110 | vec3 vSigmaY = dFdy( surf_pos.xyz );
|
5111 | vec3 vN = surf_norm; // normalized
|
5112 |
|
5113 | vN = normalize(vN);
|
5114 |
|
5115 | vec3 R1 = cross( vSigmaY, vN );
|
5116 | vec3 R2 = cross( vN, vSigmaX );
|
5117 |
|
5118 | R1 = normalize(R1);
|
5119 | R2 = normalize(R2);
|
5120 |
|
5121 | float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
5122 |
|
5123 | vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
5124 | return normalize( abs( fDet ) * vN - vGrad );
|
5125 | }`);return{dHdxy:i,perturbNormalArb:t}}();var zp=class extends Mn{constructor(){super("phong");this.nodeType="Phong";this.color=new zt(an),this.specular=new zt(1118481),this.shininess=new Ce(30),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!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 n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ys.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
5126 | `));let s=["#include <beginnormal_vertex>",`
|
5127 | #include <skinbase_vertex>
|
5128 | #include <skinnormal_vertex>
|
5129 | #ifndef USE_LAYER_DISPLACE
|
5130 | #include <defaultnormal_vertex>
|
5131 | #endif
|
5132 |
|
5133 |
|
5134 | vec3 displaced_position = position;
|
5135 | vec3 displaced_normal = objectNormal;
|
5136 |
|
5137 | #ifdef USE_LAYER_DISPLACE
|
5138 | vec3 transformed;
|
5139 | vec3 transformedNormal;
|
5140 | #endif
|
5141 | `,"#include <normal_vertex>",`
|
5142 | #ifndef USE_LAYER_DISPLACE
|
5143 | #include <begin_vertex>
|
5144 | #endif
|
5145 | `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
|
5146 | `)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let n=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"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
|
5147 | `));let f=["#include <normal_fragment_begin>",`
|
5148 | // NOTE: gl_FrontFacing alternative using face normal estimation.
|
5149 | vec3 viewdx = dFdx(vViewPosition);
|
5150 | vec3 viewdy = dFdy(vViewPosition);
|
5151 | vec3 faceNormal = normalize(cross(viewdx,viewdy));
|
5152 | if (dot(normal, faceNormal) < 0.0) {
|
5153 | normal *= -1.0;
|
5154 | }
|
5155 | `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(oa.dHdxy),e.include(oa.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=`
|
5156 | vec3 bumpNormal = vec3(0.0);
|
5157 | {
|
5158 | vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
5159 | vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
5160 | vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
5161 | vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
5162 |
|
5163 | vec2 grad0 = dHdxy(${m.result}, uv0, ${y});
|
5164 | vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
5165 |
|
5166 | vec2 grad1 = dHdxy(${m.result}, uv1, ${y});
|
5167 | vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
5168 |
|
5169 | vec2 grad2 = dHdxy(${m.result}, uv2, ${y});
|
5170 | vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
5171 |
|
5172 | bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
5173 | bumpNormal = normalize(bumpNormal);
|
5174 | }
|
5175 |
|
5176 | normal = bumpNormal;
|
5177 | `:v=`
|
5178 | vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
5179 | vec2 grad = dHdxy(${m.result}, bumpMapCachedUv, ${y});
|
5180 | normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
5181 | `,f.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
5182 | ${g.result};
|
5183 | ${v}
|
5184 | `)}f.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.push("material.diffuseColor = diffuseColor;"),f.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),f.push("vec3 ao = aoEnabled && "+n.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(`
|
5185 | if (outgoingLight != diffuseColor) {
|
5186 | float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
5187 | accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
|
5188 | outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${u.result} );
|
5189 |
|
5190 | outgoingLight *= ao;
|
5191 | }
|
5192 | `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
|
5193 | `)}return r}};var Up=class extends Mn{constructor(){super("standard");this.nodeType="Standard";this.color=new zt(an),this.roughness=new Ce(.3),this.metalness=new Ce(0),this.reflectivity=new Ce(.5),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!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 n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ys.merge([we.fog,we.lights])),we.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
5194 | `));let s=["#include <beginnormal_vertex>",`
|
5195 | #if !defined( USE_LAYER_DISPLACE )
|
5196 | #include <defaultnormal_vertex>
|
5197 | #endif
|
5198 |
|
5199 | vec3 displaced_position = position;
|
5200 | vec3 displaced_normal = normal;
|
5201 |
|
5202 | #if defined( USE_LAYER_DISPLACE )
|
5203 | vec3 transformed;
|
5204 | vec3 transformedNormal;
|
5205 | #endif
|
5206 | `,"#include <normal_vertex>",`
|
5207 | #if !defined( USE_LAYER_DISPLACE )
|
5208 | #include <begin_vertex>
|
5209 | #endif /* !USE_LAYER_DISPLACE */
|
5210 | `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
|
5211 | `)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled});let n={gamma:!0};this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color",context:n}),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:n}),a=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
|
5212 | `));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
|
5213 | // NOTE: gl_FrontFacing alternative using face normal estimation.
|
5214 | vec3 viewdx = dFdx(vViewPosition);
|
5215 | vec3 viewdy = dFdy(vViewPosition);
|
5216 | vec3 faceNormal = normalize(cross(viewdx,viewdy));
|
5217 | if (dot(normal, faceNormal) < 0.0) {
|
5218 | normal *= -1.0;
|
5219 | }
|
5220 | `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(oa.dHdxy),e.include(oa.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",w="";this.bumpMap.projection.value===4?w=`
|
5221 | vec3 bumpNormal = vec3(0.0);
|
5222 | {
|
5223 | vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
5224 | vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
5225 | vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
5226 | vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
5227 |
|
5228 | vec2 grad0 = dHdxy(${y.result}, uv0, ${x});
|
5229 | vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
5230 |
|
5231 | vec2 grad1 = dHdxy(${y.result}, uv1, ${x});
|
5232 | vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
5233 |
|
5234 | vec2 grad2 = dHdxy(${y.result}, uv2, ${x});
|
5235 | vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
5236 |
|
5237 | bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
5238 | bumpNormal = normalize(bumpNormal);
|
5239 | }
|
5240 |
|
5241 | normal = bumpNormal;
|
5242 | `:w=`
|
5243 | vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
5244 | vec2 grad = dHdxy(${y.result}, bumpMapCachedUv, ${x});
|
5245 | normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
5246 | `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
5247 | ${v.result};
|
5248 | ${w}
|
5249 | `)}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=`
|
5250 | float roughnessChange = 1.0;
|
5251 | {
|
5252 | vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
5253 | vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
5254 | vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
5255 | vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
5256 |
|
5257 | float r0 = luminance(texture(${y.result}, uv0).rgb) * roughnessScale;
|
5258 | float r1 = luminance(texture(${y.result}, uv1).rgb) * roughnessScale;
|
5259 | float r2 = luminance(texture(${y.result}, uv2).rgb) * roughnessScale;
|
5260 |
|
5261 | roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
|
5262 | }
|
5263 | float roughnessFactor = roughnessChange * ${a.result};
|
5264 | `:x=`
|
5265 | vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
5266 |
|
5267 | vec4 vals = texture(${y.result}, roughnessMapCachedUv);
|
5268 | float roughnessFactor = luminance(vals.rgb) * ${a.result};
|
5269 | `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
5270 | ${v.result};
|
5271 |
|
5272 | const float roughnessScale = 1.0;
|
5273 |
|
5274 | ${x}
|
5275 | `)}else m.push(a.code," float roughnessFactor = "+a.result+";");d&&m.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),p?m.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let g="1.0";this.mask&&(this.mask.analyze(e),g=`luminance(${this.mask.flow(e,"v3").result})`),m.push(`
|
5276 | if (outgoingLight != diffuseColor) {
|
5277 | float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
5278 | accumAlpha += ( 1.0 - accumAlpha ) * ${u.result} * ${g} * lightAccu;
|
5279 | outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${g}, ${c.result} );
|
5280 |
|
5281 | outgoingLight *= ao;
|
5282 | }
|
5283 | `),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
|
5284 | `)}return r}};var Gp=class extends Mn{constructor(){super("toon");this.nodeType="Toon";this.color=new zt(an),this.specular=new zt(1118481),this.shininess=new Ce(30),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(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 n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ys.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
5285 | `));let s=["#include <beginnormal_vertex>",`
|
5286 | #ifndef USE_LAYER_DISPLACE
|
5287 | #include <defaultnormal_vertex>
|
5288 | #endif
|
5289 |
|
5290 | vec3 displaced_position = position;
|
5291 | vec3 displaced_normal = normal;
|
5292 |
|
5293 | #ifdef USE_LAYER_DISPLACE
|
5294 | vec3 transformed;
|
5295 | vec3 transformedNormal;
|
5296 | #endif
|
5297 | `,"#include <normal_vertex>",`
|
5298 | #ifndef USE_LAYER_DISPLACE
|
5299 | #include <begin_vertex>
|
5300 | #endif
|
5301 | `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(`
|
5302 | `)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),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 n=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"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
|
5303 | varying vec3 vViewPosition;
|
5304 | struct ToonMaterial {
|
5305 | vec3 diffuseColor;
|
5306 | vec3 specularColor;
|
5307 | float specularShininess;
|
5308 | float specularStrength;
|
5309 | };
|
5310 | void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
5311 | vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
5312 |
|
5313 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
5314 | reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
5315 | }
|
5316 | void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
5317 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
5318 | }
|
5319 | #define RE_Direct RE_Direct_Toon
|
5320 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
5321 | #define Material_LightProbeLOD( material ) (0)
|
5322 | `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
|
5323 | `));let d=["#include <normal_fragment_begin>",`
|
5324 | // NOTE: gl_FrontFacing alternative using face normal estimation.
|
5325 | vec3 viewdx = dFdx(vViewPosition);
|
5326 | vec3 viewdy = dFdy(vViewPosition);
|
5327 | vec3 faceNormal = normalize(cross(viewdx,viewdy));
|
5328 | if (dot(normal, faceNormal) < 0.0) {
|
5329 | normal *= -1.0;
|
5330 | }
|
5331 | `," ToonMaterial material;"];if(this.bumpMap){e.include(oa.dHdxy),e.include(oa.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=`
|
5332 | vec3 bumpNormal = vec3(0.0);
|
5333 | {
|
5334 | vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
|
5335 | vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
|
5336 | vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
|
5337 | vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
|
5338 |
|
5339 | vec2 grad0 = dHdxy(${p.result}, uv0, ${g});
|
5340 | vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
|
5341 |
|
5342 | vec2 grad1 = dHdxy(${p.result}, uv1, ${g});
|
5343 | vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
|
5344 |
|
5345 | vec2 grad2 = dHdxy(${p.result}, uv2, ${g});
|
5346 | vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
|
5347 |
|
5348 | bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
|
5349 | bumpNormal = normalize(bumpNormal);
|
5350 | }
|
5351 |
|
5352 | normal = bumpNormal;
|
5353 | `:y=`
|
5354 | vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
|
5355 | vec2 grad = dHdxy(${p.result}, bumpMapCachedUv, ${g});
|
5356 | normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
|
5357 | `,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
|
5358 | ${m.result};
|
5359 | ${y}
|
5360 | `)}d.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," vec3 specular = "+s.result+";",o.code," float shininess = max( 0.0001, "+o.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
|
5361 | if (outgoingLight != diffuseColor) {
|
5362 | float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
|
5363 | accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${f} * lightAccu;
|
5364 | outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${f}, ${l.result} );
|
5365 | }
|
5366 | `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&d.push(`gl_FragColor.a *= ${h.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
|
5367 | `)}return r}};var Hv=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var SA=class extends Hv{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},wA;function lI(i){return typeof i=="string"?i:(wA||(wA=new SA),wA.load(i))}var jv=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Wv=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Ed=class extends jv{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;let s=[1e3,1001,1002];for(let o of s){let a=this[o];a&&(a.image=this.img,a.needsUpdate=!0)}this.shared.requestRender()};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 n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"}));let s;await new Promise(o=>{n.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=lI(e),this.img.onload=r}getTexture(e){let r=this[e];if(r)return r;{let n;return this.isVideo?n=new wg(this.img,void 0,e,e):n=new or(this.img,void 0,e,e),this.loaded&&(n.needsUpdate=!0),this[e]=n,n}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var Ji=class extends Ed{};function _A(i,t){var e=Bq(t);return e.formatToParts?Lq(e,i):Nq(e,i)}var Rq={year:0,month:1,day:2,hour:3,minute:4,second:5};function Lq(i,t){try{for(var e=i.formatToParts(t),r=[],n=0;n<e.length;n++){var s=Rq[e[n].type];s>=0&&(r[s]=parseInt(e[n].value,10))}return r}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function Nq(i,t){var e=i.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 AA={};function Bq(i){if(!AA[i]){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";AA[i]=e?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return AA[i]}function qv(i,t,e,r,n,s,o){var a=new Date(0);return a.setUTCFullYear(i,t,e),a.setUTCHours(r,n,s,o),a}var cI=36e5,Fq=6e4,EA={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function Hp(i,t,e){var r,n;if(!i||(r=EA.timezoneZ.exec(i),r))return 0;var s;if(r=EA.timezoneHH.exec(i),r)return s=parseInt(r[1],10),uI(s)?-(s*cI):NaN;if(r=EA.timezoneHHMM.exec(i),r){s=parseInt(r[1],10);var o=parseInt(r[2],10);return uI(s,o)?(n=Math.abs(s)*cI+o*Fq,s>0?-n:n):NaN}if(zq(i)){t=new Date(t||Date.now());var a=e?t:kq(t),l=MA(a,i),u=e?l:Vq(t,l,i);return-u}return NaN}function kq(i){return qv(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())}function MA(i,t){var e=_A(i,t),r=qv(e[0],e[1]-1,e[2],e[3]%24,e[4],e[5],0).getTime(),n=i.getTime(),s=n%1e3;return n-=s>=0?s:1e3+s,r-n}function Vq(i,t,e){var r=i.getTime(),n=r-t,s=MA(new Date(n),e);if(t===s)return t;n-=s-t;var o=MA(new Date(n),e);return s===o?s:Math.max(s,o)}function uI(i,t){return-23<=i&&i<=23&&(t==null||0<=t&&t<=59)}var hI={};function zq(i){if(hI[i])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:i}),hI[i]=!0,!0}catch{return!1}}var wI=pn(fI(),1),PA=pn(mI(),1);var Hq=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,gI=Hq;var TA=36e5,yI=6e4,jq=2,si={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:gI};function DA(i,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(i===null)return new Date(NaN);var e=t||{},r=e.additionalDigits==null?jq:(0,wI.default)(e.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]")return new Date(i.getTime());if(typeof i=="number"||Object.prototype.toString.call(i)==="[object Number]")return new Date(i);if(!(typeof i=="string"||Object.prototype.toString.call(i)==="[object String]"))return new Date(NaN);var n=Wq(i),s=qq(n.date,r),o=s.year,a=s.restDateString,l=Yq(a,o);if(isNaN(l))return new Date(NaN);if(l){var u=l.getTime(),c=0,h;if(n.time&&(c=Xq(n.time),isNaN(c)))return new Date(NaN);if(n.timeZone||e.timeZone){if(h=Hp(n.timeZone||e.timeZone,new Date(u+c)),isNaN(h))return new Date(NaN)}else h=(0,PA.default)(new Date(u+c)),h=(0,PA.default)(new Date(u+c+h));return new Date(u+c+h)}else return new Date(NaN)}function Wq(i){var t={},e=si.dateTimePattern.exec(i),r;if(e?(t.date=e[1],r=e[3]):(e=si.datePattern.exec(i),e?(t.date=e[1],r=e[2]):(t.date=null,r=i)),r){var n=si.timeZone.exec(r);n?(t.time=r.replace(n[1],""),t.timeZone=n[1].trim()):t.time=r}return t}function qq(i,t){var e=si.YYY[t],r=si.YYYYY[t],n;if(n=si.YYYY.exec(i)||r.exec(i),n){var s=n[1];return{year:parseInt(s,10),restDateString:i.slice(s.length)}}if(n=si.YY.exec(i)||e.exec(i),n){var o=n[1];return{year:parseInt(o,10)*100,restDateString:i.slice(o.length)}}return{year:null}}function Yq(i,t){if(t===null)return null;var e,r,n,s;if(i.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(e=si.MM.exec(i),e)return r=new Date(0),n=parseInt(e[1],10)-1,xI(t,n)?(r.setUTCFullYear(t,n),r):new Date(NaN);if(e=si.DDD.exec(i),e){r=new Date(0);var o=parseInt(e[1],10);return Zq(t,o)?(r.setUTCFullYear(t,0,o),r):new Date(NaN)}if(e=si.MMDD.exec(i),e){r=new Date(0),n=parseInt(e[1],10)-1;var a=parseInt(e[2],10);return xI(t,n,a)?(r.setUTCFullYear(t,n,a),r):new Date(NaN)}if(e=si.Www.exec(i),e)return s=parseInt(e[1],10)-1,bI(t,s)?vI(t,s):new Date(NaN);if(e=si.WwwD.exec(i),e){s=parseInt(e[1],10)-1;var l=parseInt(e[2],10)-1;return bI(t,s,l)?vI(t,s,l):new Date(NaN)}return null}function Xq(i){var t,e,r;if(t=si.HH.exec(i),t)return e=parseFloat(t[1].replace(",",".")),CA(e)?e%24*TA:NaN;if(t=si.HHMM.exec(i),t)return e=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),CA(e,r)?e%24*TA+r*yI:NaN;if(t=si.HHMMSS.exec(i),t){e=parseInt(t[1],10),r=parseInt(t[2],10);var n=parseFloat(t[3].replace(",","."));return CA(e,r,n)?e%24*TA+r*yI+n*1e3:NaN}return null}function vI(i,t,e){t=t||0,e=e||0;var r=new Date(0);r.setUTCFullYear(i,0,4);var n=r.getUTCDay()||7,s=t*7+e+1-n;return r.setUTCDate(r.getUTCDate()+s),r}var Qq=[31,28,31,30,31,30,31,31,30,31,30,31],Kq=[31,29,31,30,31,30,31,31,30,31,30,31];function SI(i){return i%400===0||i%4===0&&i%100!==0}function xI(i,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var r=SI(i);if(r&&e>Kq[t]||!r&&e>Qq[t])return!1}return!0}function Zq(i,t){if(t<1)return!1;var e=SI(i);return!(e&&t>366||!e&&t>365)}function bI(i,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function CA(i,t,e){return!(i!=null&&(i<0||i>=25)||t!=null&&(t<0||t>=60)||e!=null&&(e<0||e>=60))}function Qv(i,t,e){var r=DA(i,e),n=Hp(t,r,!0),s=new Date(r.getTime()-n),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 zn(i,t){return t.color(i)}function IA(i=new Date,t){let e=t.format,r=i.getSeconds(),n=i;t&&t.timeZone!==null&&(n=Qv(new Date,t.timeZone));let s=n.getHours(),o=n.getMinutes(),a;t.format12h24h==="12ampm"&&(a=s>=12?"PM":"AM");let l=s;t.format12h24h!=="24"&&(l=s%12,l===0&&(l=12));let u,c;switch(e){case"HH:mm:ss":u=[l,o,r];break;case"HH:mm":u=[l,o];break;case"HH":u=[l],a=void 0;break;case"mm":u=[o],a=void 0;break;case"ss":u=[r],a=void 0;break;case"year":c=n.getFullYear();break;case"month":c=n.getMonth()+1;break;case"dayOfYear":c=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=n.getDate();break;case"secondOfDay":c=s*60*60+o*60+r;break;default:console.error("Unknown time format",e),c=0;break}return u!==void 0?{textValue:u,suffix:a}:c}function AI(i,t){switch(i.type){case"fresnel":return e9(i,t);case"gradient":return t9(i,t);case"depth":return r9(i,t);case"normal":return n9(i,t);case"noise":return i9(i,t);case"rainbow":return s9(i,t);case"toon":return o9(i,t);case"outline":return a9(i,t);case"transmission":return l9(i,t);case"color":return $q(i,t);case"pattern":return c9(i,t)}}function Jq(i){return{type:i.type}}function Cs(i,t){let{alpha:e,mode:r,isMask:n}=i,s=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...Jq(i),alpha:s,mode:r,isMask:n}}function $q(i,t){return{...Cs(i,t),color:zn(i.color,t)}}function e9(i,t){let{bias:e,scale:r,intensity:n,factor:s,color:o}=i;return{...Cs(i,t),color:zn(o,t),bias:e,scale:r,intensity:n,factor:s}}function t9(i,t){let{gradientType:e,smooth:r,colors:n,steps:s,angle:o,offset:a,morph:l}=i;return{...Cs(i,t),gradientType:e,smooth:r,colors:n.map(u=>new Xe(u[0],u[1],u[2],u[3])),num:n.length,steps:s,offset:new N(...a),morph:new N(...l),angle:o}}function r9(i,t){let{gradientType:e,near:r,far:n,isVector:s,isWorldSpace:o,origin:a,direction:l,colors:u,steps:c,smooth:h}=i;return{...Cs(i,t),gradientType:e,near:r,far:n,isVector:s,isWorldSpace:o,origin:new _(...a),direction:l?new _(...l):new _(1,0,0),colors:u.map(d=>d!==void 0?new Xe(d[0],d[1],d[2],d[3]):new Xe(0,0,0,0)),steps:c.slice(0,u.length),smooth:h}}function n9(i,t){let{cnormal:e}=i;return{...Cs(i,t),cnormal:new _(e[0],e[1],e[2])}}function i9(i,t){return{...Cs(i,t),scale:i.scale,move:i.move,fA:new N(...i.fA),fB:new N(...i.fB),size:new _(...i.size),distortion:new N(...i.distortion),colorA:zn(i.colorA,t),colorB:zn(i.colorB,t),colorC:zn(i.colorC,t),colorD:zn(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function s9(i,t){return{...Cs(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new _(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new _(...i.offset)}}function o9(i,t){return{...Cs(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Xe(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new _(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:zn(i.shadowColor,t),offset:new _(...i.offset)}}function a9(i,t){return{...Cs(i,t),outlineColor:zn(i.outlineColor,t),contourColor:zn(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new _(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function l9(i,t){return{...Cs(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function c9(i,t){return{...Cs(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new N(...i.offset),colorA:zn(i.colorA,t),colorB:zn(i.colorB,t),frequency:new N(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new N(...i.vertical),horizontal:new N(...i.horizontal),sides:i.sides}}var fl=class extends gr{};var OA={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},RA={depth:["colors"]};function u9(i,t,e){if(t==="isMask")return!0;let r=OA[i.type],n=RA[i.type];if(n!==void 0){let s=i.color;if(n.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 LA(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let n=!1,s=i;if("image"in s){let o=s.image,a=t.image(o),l=r;l.image instanceof Ji||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=r;l.image instanceof Ji||l.image.deref(),l.image=a}if("wrapping"in s){let o=r;o.wrap=s.wrapping}if("repeat"in s||"offset"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),a.updateMatrix()}return n}function _I(i,t,e,r){let n=!1;for(let[s,o]of Object.entries(i)){if(s==="bumpMap"||s==="roughnessMap"){n=!0;continue}if(!s||o===void 0)continue;if(NA(s,e,r,t)){s==="visible"&&e.type==="light"&&(n=!0);continue}e.visible=r.visible;let a=e.uniforms[`f${e.id}_${s}`];if(!!a&&!(a instanceof hl))switch(n=n||u9(e,s,o),a.constructor){case zt:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof fl?a.value=new gr(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case vi:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof fl?a.value=new gr(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case wr:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]);break}case kn:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case ii:{LA(o,t,e);break}case Ts:{a.value=o.map(l=>new Xe(...l));break}default:{a.value=o;break}}}return n}var pl=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,uo=class{constructor(t,e,r,n,s){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let o in n)this.uniforms[`f${this.id}_${o}`]=n[o];for(let o in r)NA(o,this,r,s)}get type(){return this.data.type}static create(t,e,r,n){if(r.type==="light")return Fi.createLigherLayer(t,e,r,n);if(r.type==="texture"||r.type==="video"){let s=r.type==="texture"?n.image(r.texture.image):n.video(r.texture.video),o=new xc(s,r.texture.wrapping),a=new Uv(s),l=new Gv(r.texture.repeat,r.texture.offset),u=new Ce(r.crop?1:0),c=new yt(r.projection??0),h=new yt(["x","y","z"].indexOf(r.axis)??0),d=new yt(r.side??0),f=new wr(r.size?new N(r.size[0],r.size[1]):new N(100,100)),p=new Ce(r.blending??0),m=new Ce(pl(r.alpha,n)),g=new yt(r.mode??0),y=new Tr(r.isMask??!1),v=new dl(o,a,u,c,h,d,f,p,l,m,g,y),x=new Rt(v.calpha,"f");return new ur(t,e,r,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,blending:p,mat:l,alpha:m,mode:g,isMask:y},v,g,x,y,n)}else if(r.type==="matcap"){let s=n.image(r.texture.image),o=new xc(s,r.texture.wrapping),a=new Ce(pl(r.alpha,n)),l=new yt(r.mode??0),u=new Tr(r.isMask??!1),c=new yd(o,a,l,u),h=new Rt(c.calpha,"f");return new ur(t,e,r,{texture:o,alpha:a,mode:l,isMask:u},c,l,h,u,n)}else if(r.type==="displace")if(r.displacementType==="noise"){let s=new kn(new _(...r.offset)),o=new Ce(r.scale??10),a=new Ce(r.intensity??8),l=new Ce(r.movement??1),u=new yt(r.noiseType??0),c=new yt(r.voronoiStyle??0),h=new Ce(r.smoothness??.5),d=new Ce(r.seed??0),f=new Ce(r.highCut??1),p=new Ce(r.lowCut??0),m=new yt(r.quality??1),g=new _d(a,l,s,c,h,d,f,p,m,o,u);return new jp(t,e,r,{offset:s,scale:o,intensity:a,movement:l,noiseType:u,voronoiStyle:c,smoothness:h,seed:d,highCut:f,lowCut:p,quality:m},g,n)}else throw new Error;else return f9(t,e,r,n)}updateByOp(t,e,r){let n=t;if(n.path[0]===void 0){if(n.type===0)return"type"in n.props||"category"in n.props||"visible"in n.props?(r.scene.markNeedsUpdateRendererDirty(),!0):_I(n.props,r.shared,this,e)}else if(n.path[0]==="texture")return"texture"in e||"video"in e?LA(n.props,r.shared,this):!0;return!1}dispose(){if(h9(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Ji||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}},ur=class extends uo{constructor(e,r,n,s,o,a,l,u,c){super(e,r,n,s,c);this.params=s;this.color=o;this.mode=a;this.alpha=l;this.isMask=u}},jp=class extends uo{constructor(e,r,n,s,o,a){super(e,r,n,s,a);this.position=o}},Fi=class extends uo{constructor(e,r,n,s,o,a){super(e,r,n,o,a);this.node=s}static createLigherLayer(e,r,n,s){let o,a=new Ce(pl(n.alpha,s)),l=new yt(n.mode),u=new Ce(n.bumpMapIntensity),c=new Ce(pl(n.alphaOverride,s)),h;if(!n.visible)o=new Sc,h={};else if(n.category==="lambert"){o=new Vp;let d=new zt(s.color(n.emissive)??0),f=new Tr(n.occlusion??!0);h={emissive:d,occlusion:f},o.emissive=d,o.occlusion=f}else if(n.category==="toon"){o=new Gp;let d=new Ce(n.shininess??30),f=new zt(s.color(n.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(n.category==="physical"){o=new Up;let d=new Ce(n.roughness??.3),f=new Ce(n.metalness??0),p=new Ce(n.reflectivity??.5),m=new Tr(n.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 zp;let d=new Ce(n.shininess??30),f=new zt(n.specular!==void 0?s.color(n.specular)??1118481:1118481),p=new Tr(n.occlusion??!0);h={shininess:d,specular:f,occlusion:p},o.shininess=d,o.specular=f,o.occlusion=p}return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,o.bumpMapIntensity=u,o.alphaOverride=c,h.alpha=o.shadingAlpha,h.mode=o.shadingBlend,h.bumpMapIntensity=o.bumpMapIntensity,h.alphaOverride=o.alphaOverride,new Fi(e,r,n,o,h,s)}get category(){return this.node.category}};function h9(i){let t=i instanceof uo?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function $i(i){return{alpha:new Ce(i.alpha??1),mode:new yt(i.mode??0),isMask:new Tr(i.isMask??!1)}}function d9(i,t,e,r,n){switch(i.type){case"color":{let s=new zt(r.color??an),o=$i(r),a=new bc(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,n)}case"fresnel":{let s=new zt(r.color??16777215),o=new Ce(r.bias??.1),a=new Ce(r.scale??1),l=new Ce(r.intensity??2),u=new Ce(r.factor??1),c=$i(r),h=new Fp(s,o,a,l,u,c.alpha,c.mode,c.isMask),d=new Rt(h.calpha,"f");return new ur(t,e,i,{color:s,bias:o,scale:a,intensity:l,factor:u,...c},h,c.mode,d,c.isMask,n)}case"rainbow":{let s=new Ce(r.filmThickness??30),o=new Ce(r.movement??0),a=new kn(r.wavelengths??new _(0,0,0)),l=new Ce(r.noiseStrength??0),u=new Ce(r.noiseScale??1),c=new kn(r.offset??new _(0,0,0)),h=$i(r),d=new wd(s,o,a,l,u,c,h.alpha,h.isMask),f=new Rt(d.calpha,"f");return new ur(t,e,i,{filmThickness:s,movement:o,wavelengths:a,noiseStrength:l,noiseScale:u,offset:c,...h},d,h.mode,f,h.isMask,n)}case"transmission":{let s=new Ce(r.thickness??10),o=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),l=je.transmissionSize,u=je.transmissionRenderTarget,c=je.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new wr(d/h,1):new wr(1,h/d),p=$i(r),m=new Ad(s,o,a,l,u,c,f,p.alpha),g=new Rt(m.calpha,"f");return new ur(t,e,i,{thickness:s,ior:o,roughness:a,aspectRatio:f,...p},m,p.mode,g,p.isMask,n)}case"toon":{let s=new yt(r.positioning??0),o;r.colors?o=new Ts(r.colors.length,r.colors):(o=new Ts(10,new Xe(0,0,0,1)),o.value[1]=new Xe(1,1,1,1));let a;r.steps?a=new Ms(r.steps.length,r.steps):(a=new Ms(10,1),a.value[0]=0);let l=new kn(r.source??new _(0,0,0)),u=new Tr(r.isWorldSpace??!0),c=new Ce(r.noiseStrength??0),h=new Ce(r.noiseScale??1),d=new vi(r.shadowColor),f=new kn(r.offset??new _(0,0,0)),p=$i(r),m=new Sd(s,o,a,l,u,c,h,d,f,p.alpha),g=new Rt(m.calpha,"f");return new ur(t,e,i,{positioning:s,colors:o,steps:a,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:h,shadowColor:d,offset:f,...p},m,p.mode,g,p.isMask,n)}case"outline":{let s=new zt(r.outlineColor??16777215),o=new zt(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),l=new Ce(r.contourWidth??.1),u=new Ce(r.outlineThreshold??.1),c=new Ce(r.contourThreshold??.1),h=new Ce(r.outlineSmoothing??.1),d=new Ce(r.contourFrequency??.1),f=new kn(r.contourDirection??new _(0,1,0)),p=new Tr(r.positionalLines??!1),m=new Tr(r.compensation??!0),g=je.normalRenderTarget,y=je.normalRenderTargetDepth,v=je.pixelRatioNode,x=je.resolution,w=$i(r),S=new xd(s,o,a,l,u,c,h,d,f,p,m,x,g,y,v,w.alpha),A=new Rt(S.calpha,"f");return new ur(t,e,i,{outlineColor:s,contourColor:o,outlineWidth:a,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:p,compensation:m,...w},S,w.mode,A,w.isMask,n)}case"depth":{let s=new yt(r.gradientType??0),o=new Tr(r.smooth??!1),a=new Ce(r.near??50),l=new Ce(r.far??200),u=new Ce(r.isVector??1),c=new Ce(r.isWorldSpace??0),h=new kn(r.origin??new _),d=new kn(r.direction??new _),f;r.colors?f=new Ts(r.colors.length,r.colors):(f=new Ts(2,new Xe(0,0,0,1)),f.value[1]=new Xe(1,1,1,1));let p;r.steps?p=new Ms(r.steps.length,r.steps):(p=new Ms(2,1),p.value[0]=0);let m=$i(r),g=new md(s,o,a,l,u,c,h,d,f,p,m.alpha,m.isMask),y=new Rt(g.calpha,"f");return new ur(t,e,i,{gradientType:s,smooth:o,near:a,far:l,isVector:u,isWorldSpace:c,origin:h,direction:d,colors:f,steps:p,...m},g,m.mode,y,m.isMask,n)}case"noise":{let s=new Ce(r.scale??1),o=new kn(r.size??new _(100,100,100)),a=new Ce(r.move??1),l=new wr(r.fA??new N(1.7,9.2)),u=new wr(r.fB??new N(8.3,2.8)),c=new wr(r.distortion??new N(1,1)),h=new vi(r.colorA),d=new vi(r.colorB),f=new vi(r.colorC),p=new vi(r.colorD),m=new yt(r.noiseType??0),g=new yt(r.voronoiStyle??0),y=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),x=new Ce(r.smoothness??.5),w=new Ce(r.seed??.5),S=new yt(r.quality??1),A=$i(r),E=new vd(s,o,a,l,u,c,h,d,f,p,A.alpha,m,A.isMask,g,y,v,x,w,S),b=new Rt(E.calpha,"f");return new ur(t,e,i,{scale:s,size:o,move:a,fA:l,fB:u,distortion:c,colorA:h,colorB:d,colorC:f,colorD:p,noiseType:m,...A,voronoiStyle:g,highCut:y,lowCut:v,smoothness:x,seed:w,quality:S},E,A.mode,b,A.isMask,n)}case"normal":{let s=new kn(r.cnormal??new _(1,1,1)),o=$i(r),a=new dd(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{cnormal:s,...o},a,o.mode,l,o.isMask,n)}case"gradient":{let s=new yt(r.gradientType??0),o=new Tr(r.smooth??!1),a;r.colors?a=new Ts(r.colors.length,r.colors):(a=new Ts(10,new Xe(0,0,0,1)),a.value[1]=new Xe(1,1,1,1));let l;r.steps?l=new Ms(r.steps.length,r.steps):(l=new Ms(10,1),l.value[0]=0);let u=new wr(r.offset??new N(0,0)),c=new wr(r.morph??new N(0,0)),h=new Ce(r.angle??0),d=$i(r),f=new gd(s,o,a,l,u,c,h,d.alpha,d.isMask),p=new Rt(f.calpha,"f");return new ur(t,e,i,{gradientType:s,smooth:o,colors:a,steps:l,offset:u,morph:c,angle:h,...d},f,d.mode,p,d.isMask,n)}case"pattern":{let s=new yt(r.style??0),o=new yt(r.projection??0),a=new yt(["x","y","z"].indexOf(r.axis)??0),l=new Ce(r.blending??0),u=new wr(r.offset??new N(0,0)),c=new vi(r.colorA),h=new vi(r.colorB),d=new wr(r.frequency??new N(10,10)),f=new Ce(r.size??.5),p=new Ce(r.variation??0),m=new Ce(r.smoothness??.5),g=new Ce(r.zigzag??0),y=new Ce(r.rotation??0),v=new wr(r.vertical??new N(0,1)),x=new wr(r.horizontal??new N(0,1)),w=new yt(r.sides??6),S=$i(r),A=new bd(s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,w,S.alpha,S.isMask),E=new Rt(A.calpha,"f");return new ur(t,e,i,{style:s,projection:o,axis:a,blending:l,offset:u,colorA:c,colorB:h,frequency:d,size:f,variation:p,smoothness:m,zigzag:g,rotation:y,vertical:v,horizontal:x,sides:w,...S},A,S.mode,E,S.isMask,n)}default:{let s=new zt(1,0,0,1),o=$i(r),a=new bc(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,n)}}}function f9(i,t,e,r){let n=AI(e,r);return d9(e,i,t,n,r)}function NA(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=e.intensity*(e.visible?1:0),n):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=pl(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=e.compensation&&e.visible)}return n}}function Ac(i,t){let e=0,r=i.layers.find(n=>n.data.type==="light");if(r){let n=r.data,s=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?s/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let s=n.data.visible?n.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let o of n.data.colors)if(o[3]<1){s=o[3];break}}else if(s===1&&n.data.type==="noise"){let o=t.color(n.data.colorA).a,a=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,u=t.color(n.data.colorD).a,c=Math.min(o,Math.min(a,Math.min(l,u)));c<1&&(s=c)}e+=(1-e)*s}}return e<1}var bi=class extends at{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Kv=class extends bi{constructor(e,r,n,s){super();this.flatShading=e;this.side=r;this.wireframe=n;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,n){return this.root.getFlavor(e,r,n)}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,n){this.root.updateByOp(e,r,n)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},aa=class extends bi{constructor(e,r,n=!0){super();this.data=e;this.allowVariableSaves=n;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,n){let s=n?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 Kv(e,r,n,this),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){this.data!==e&&this.reset0(e,r)}reset0(e,r){this.data=e;let n=e.layers??Br.defaultTwoLayerData("phong").layers;try{this.layers=n.map(s=>uo.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=Ac(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,n){if(e[0]==="alphaOverride")this.transparent=Ac(this.data,n.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=Ac(this.data,n.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(n=>n.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(n=>{"alpha"in n.data&&typeof n.data.alpha=="string"&&e.shared.getVariable(n.data.alpha,["material",this.uuid,"layer",n.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.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof Fi),this.lightLayer===void 0&&(this.lightLayer=new Fi(0,"",{..._n.defaultData("light","phong"),visible:!1},new Sc,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(o=>o instanceof Fi);if(!e)return;let r=e.data,n=r.bumpMap,s=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let o=0;o<this.layers.length;++o){let a=this.layers[o];a instanceof ur&&a.color instanceof dl&&(a.uuid===n&&(e.node.bumpMap=a.color),a.uuid===s&&(e.node.roughnessMap=a.color))}}updateByOp(e,r,n){if(r!==void 0?this.data=r:r=this.data,this.transparent=Ac(r,n.shared),e.path[0]==="layers"){this.data=r;let s=n.shared,o=e.path[1];if(o===void 0){if(this.layers.reverse(),e.type===4){let a=uo.create(this.layerIdGen++,e.id,e.data,n.shared);this.layers.splice(e.localIndex,0,a),n.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),n.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let a=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,l),n.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(n.shared)}else{e.type===0&&e.props.occlusion!==void 0&&n.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(l=>l.uuid===o);if(a){let l=r.layers.data(o),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:pl(e.props.alpha,s,["material",this.uuid,"layer",o,"alpha"])}:u={...e.props,alphaOverride:pl(e.props.alphaOverride,s,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,n)){let h=uo.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(d=>d.uuid===o),1,h),this.onUpdate(n.shared)}}}}else this.reset(r,n)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof ur?r.color.mask=void 0:r instanceof Fi&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof ur&&r.isMask.value&&r.data.visible&&e>0){let n=e-1,s=this.layers[n];s instanceof Fi?s.node.mask=new Tn(r.color,r.alpha,Tn.MUL):s instanceof ur&&(s.isMask.value||(s.color.mask=new Tn(r.color,r.alpha,Tn.MUL)))}}}blendColors(){let e=this.layers.findIndex(n=>n instanceof ur),r=this.layers.findIndex(n=>n instanceof Fi);if(e!==-1&&e<r){let n=this.layers[e].color;for(let s=e+1;s<r;++s){let o=this.layers[s];if(o instanceof ur){if(o.isMask.value)continue;n=new hd(n,o.color,o.alpha,o.mode)}}this.fragment.color=n}else this.fragment.color=void 0}blendAfterColors(){let e=new Rt("outgoingLight","f"),r=this.layers.findIndex(n=>n instanceof Fi);if(this.layers.length>r+1){for(let n=r+1;n<this.layers.length;++n){let s=this.layers[n];if(s instanceof ur){if(s.isMask.value)continue;e=new hd(e,s.color,s.alpha,s.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof jp);if(e.length>0){let r=e[0].position;for(let n=1;n<e.length;++n)e[n]&&(r=new Tn(r,e[n].position,Tn.ADD),r=new Tn(r,new Ce(.5).setReadonly(!0),Tn.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let n=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=n(s.uniforms[`f${s.id}_intensity`].value,e,r);s.uniforms[`f${s.id}_intensity`].value=o}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let n=(OA[r.type]??[]).map(u=>r[u]),s=(RA[r.type]??[]).map(u=>r[u]?.length??0),o=[...n,...s],a="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${a}"`;o.length?e+=`[${l}, "${o.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new zv;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ur){let r=e.params.texture;if(r instanceof xc&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(bi.prototype,{properties:{get:function(){return this.fragment.properties}}});var _c=class extends aa{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var CI=pn(EI());var MI=new Map;function TI(i){if(typeof i=="string")return i;let t=MI.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},MI.set(i,t)),t.url}var la=class{constructor({src:t,volume:e,delay:r,loop:n}){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:TI(t),format:"wav"},this.sound=new CI.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),n!==void 0&&(this.loop=n)}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 Jv=class{constructor(){this.type="ShapePath";this.color=new Re;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new ql,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,n){return this.currentPath?.quadraticCurveTo(t,e,r,n),this}bezierCurveTo(t,e,r,n,s,o){return this.currentPath?.bezierCurveTo(t,e,r,n,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 n(m,g,y,v){let x=m.x,w=g.x,S=y.x,A=v.x,E=m.y,b=g.y,M=y.y,T=v.y,C=(A-S)*(E-M)-(T-M)*(x-S),P=(w-x)*(E-M)-(b-E)*(x-S),D=(T-M)*(w-x)-(A-S)*(b-E),I=C/D,R=P/D;if(D===0&&C!==0||I<=0||I>=1||R<0||R>1)return null;if(C===0&&D===0){for(let V=0;V<2;V++)if(s(V===0?y:v,m,g),r.loc===e.ORIGIN){let k=V===0?y:v;return{x:k.x,y:k.y,t:r.t}}else if(r.loc===e.BETWEEN){let k=+(x+r.t*(w-x)).toPrecision(10),z=+(E+r.t*(b-E)).toPrecision(10);return{x:k,y:z,t:r.t}}return null}else{for(let z=0;z<2;z++)if(s(z===0?y:v,m,g),r.loc===e.ORIGIN){let G=z===0?y:v;return{x:G.x,y:G.y,t:r.t}}let V=+(x+I*(w-x)).toPrecision(10),k=+(E+I*(b-E)).toPrecision(10);return{x:V,y:k,t:I}}}function s(m,g,y){let v=y.x-g.x,x=y.y-g.y,w=m.x-g.x,S=m.y-g.y,A=v*S-w*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*w<0||x*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+x*x)<Math.sqrt(w*w+S*S)){r.loc=e.BEYOND;return}let E;v!==0?E=w/v:E=S/x,r.loc=e.BETWEEN,r.t=E}function o(m,g){let y=[],v=[];for(let x=1;x<m.length;x++){let w=m[x-1],S=m[x];for(let A=1;A<g.length;A++){let E=g[A-1],b=g[A],M=n(w,S,E,b);M!==null&&y.find(T=>T.t<=M.t+Number.EPSILON&&T.t>=M.t-Number.EPSILON)===void 0&&(y.push(M),v.push(new N(M.x,M.y)))}}return v}function a(m,g,y){let v=new N;g.getCenter(v);let x=[];return y.forEach(w=>{w.boundingBox.containsPoint(v)&&o(m,w.points).forEach(A=>{x.push({identifier:w.identifier,isCW:w.isCW,point:A})})}),x.sort((w,S)=>w.point.x-S.point.x),x}function l(m,g,y,v,x){(x==null||x==="")&&(x="nonzero");let w=new N;m.boundingBox.getCenter(w);let S=[new N(y,w.y),new N(v,w.y)],A=a(S,m.boundingBox,g);A.sort((P,D)=>P.point.x-D.point.x);let E=[],b=[];A.forEach(P=>{P.identifier===m.identifier?E.push(P):b.push(P)});let M=E[0].point.x,T=[],C=0;for(;C<b.length&&b[C].point.x<M;)T.length>0&&T[T.length-1]===b[C].identifier?T.pop():T.push(b[C].identifier),C++;if(T.push(m.identifier),x==="evenodd"){let P=T.length%2===0,D=T[T.length-2];return{identifier:m.identifier,isHole:P,for:D}}else if(x==="nonzero"){let P=!0,D=null,I=null;for(let R=0;R<T.length;R++){let V=T[R];g[V]&&(P?(I=g[V].isCW,P=!1,D=V):I!==g[V].isCW&&(I=g[V].isCW,P=!0))}return{identifier:m.identifier,isHole:P,for:D}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let u=0,c=999999999,h=-999999999,d=[];this.subPaths.forEach(m=>{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,w=999999999;for(let S=0;S<g.length;S++){let A=g[S];A.y>y&&(y=A.y),A.y<v&&(v=A.y),A.x>x&&(x=A.x),A.x<w&&(w=A.x)}h<=x&&(h=x+1),c>=w&&(c=w-1),g.length&&d.push({curves:m.curves,points:g,isCW:mu.isClockWise(g),identifier:u++,boundingBox:new Mu(new N(w,v),new N(x,y))})});let f=d.map(m=>l(m,d,c,h,this.userData?.style.fillRule)),p=[];return d.forEach(m=>{let g=f[m.identifier];if(g&&!g.isHole){let y=new jo;y.curves=m.curves,f.filter(x=>x?.isHole&&x.for===m.identifier).forEach(x=>{if(x){let w=d[x.identifier],S=new ql;S.curves=w.curves,y.holes.push(S)}}),p.push(y)}}),p}};var DI,BA=new Promise(i=>{DI=i}),PI=!1;var $v;function II(){if(PI)return;if($v)return $v;async function i(){let e=await import("./opentype.js");DI(e),PI=!0}return $v=i(),$v}var Wp=class{async load(t,e,r=()=>{}){let{load:n}=await BA;n(t,(s,o)=>{s||!o?r(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:r}=await BA;try{let n=e(t),s=new r,o=a=>n.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(n,n.defaultRenderOptions.features),{font:n,bidi:s}}catch(n){console.error(n)}}};async function p9(i){return await(await fetch(i)).arrayBuffer()}var m9=new Wp;async function FA(i){let t,e,r=!1;if(i.url?(t=await p9(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t){let n=await m9.parse(t);if(n)return{font:n.font,url:e,intercepted:r,arr:t,bidi:n.bidi}}}function g9(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var e0=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=FA(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=FA(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 n=this._bidi;n.getTextGlyphs(e);let s=n.tokenizer.tokens,o=[],a=0,l=r.length===s.length;for(let u=0;u<r.length;u++){let c=r[u].index,h=String.fromCharCode(r[u].unicode),d=s[a];if(g9(c,d)||l)o.push({char:h,index:c,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),a++;else{let f=d.char,p="",m=[d.state.glyphIndex],g=[],y=!1;for(;!y;)a++,p=e.charAt(a),f+=p,m.push(t.charToGlyphIndex(p)),g=t.stringToGlyphs(f),g.length===1&&g[0].index===c&&(y=!0),a>e.length&&(y=!0);o.push({char:h,index:c,replacements:m,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,n=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(`
|
5368 | `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),h=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),d=this.getLineInitialOffsetY(s,t.length,e.height,n,e.verticalAlign),f=[],p=t.map(v=>[]),m=t.map(v=>[]),g;for(let v=0;v<t.length;v++){let x=t[v],w={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(x,w)}catch(E){console.warn(E)}h=this.getLineInitialOffsetX(o[v],a,e.horizontalAlign,x,l);let A=[];try{A=this.reverseLigaturesTable(r,x,S)}catch(E){console.warn(E)}c=this.computeSpaceWidthForLine(t,v,e);for(let E=0;E<S.length;E++){let b=S[E],M=b.index===0?`
|
5369 | `:b.unicode?String.fromCharCode(b.unicode):void 0,T=A[E],C=0,P=0;E===0&&e.horizontalAlign===2&&b.leftSideBearing!==void 0&&(P=-b.leftSideBearing*n),g&&(C=r.getKerningValue(b,g)*n),h+=P+C;let D=0;if(M===`
|
5370 | `)D=u;else if(M===" ")D=c;else{let I=this.createPath(b,n,h,d,e);I&&(D=I.offsetX-(C+P),f.push(I.path))}if(T.replacements.length===1)m[v].push([h,d]),p[v].push(D);else{let I=T.replacements.map(z=>(r.glyphs.get(z).advanceWidth??0)*n),R=I.reduce((z,G)=>z+=G,0),V=I.map(z=>z/R),k=h;for(let z=0;z<V.length;z++){let G=D*V[z];m[v].push([k,d]),p[v].push(G),k+=G}}h+=D,g=b}d-=s}let y=[];for(let v=0,x=f.length;v<x;v++)y.push(...f[v].toShapes());return{shapes:y,charWidths:p,lineWidths:o,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,n,s){return(r===3||r===2)&&n.indexOf(`
|
5371 | `)>=0&&(t-=s),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,s){let o=e*t,a=Math.abs(this.ascender-this.descender)*n,l=t-a,u=-this.ascender*n-l/2;return s===3?-(r-o-u):s===2?-(r*.5-o*.5-u):u}createPath(t,e,r,n,s){let o=t.getPath(r,-n,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 Jv,l=(t.advanceWidth??1)*e;if(t)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=y9(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.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 n=this.getCharWidth(" ",r),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&o){let a=r.width,l=this.getTextWidth(s,r);return(a-(l-o*n))/o}}return n}countSpaces(t){return(t.match(/ /g)||[]).length}};function y9(i){if(i.length){let t=i[0];if(t instanceof Wn)return t.v1;if(t instanceof jn||t instanceof Ii)return t.v0}}var kA=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},qp=class extends kA{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let s=mc(e,r,this.flatShading,n);return s.computeBoundingSphere(),s}};var OI={markNeedsUpdateRendererDirty:()=>{}};var VA=class extends Wv{constructor(e){super();this.shared=e}create(e){return new Ed(e,this.shared)}},Ec=class{constructor(t,e={}){this.data=t;this.geometryCache=new qp(!0);this.geometryCache2=new qp(!1);this.imageHolderCache=new VA(this);this.thisContext={scene:OI,shared:this};this.deletedMaterial=new _c(Br.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Ji(Ah.emptyImage,this);this.deletedVideo=new Ji(fh.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,n]of Object.entries(e.images))this.addImage(r,n);if(e.videos)for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n);if(e.audios)for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);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:n}of t.variables)this.addVariableHolder(r,n),e&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(t.images))this.addImage(r,n);for(let[r,n]of Object.entries(t.videos))this.addVideo(r,n);for(let[r,n]of Object.entries(t.colors))this.addColor(r,n);for(let[r,n]of Object.entries(t.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(t.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(t.fonts))this.addFont(r,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new _c(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 aa(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 Ji(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)}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Ji(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 fl(e.r,e.g,e.b,e.a):this.colors[t]=new fl(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 gr(0,0,0,0))}else return"a"in t?new gr(t.r,t.g,t.b,t.a):new gr(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 la)return e;{let r=new la({src:e.data});return this.audios[t]=r,r}}deleteAudio(t){let e=this.audios[t];e&&(e instanceof la&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new e0(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 la&&e.dispose()}),this.audios={},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 n=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,u={scene:n,shared:this},c=o.slice(2);n.traverseMaterial(d=>{let f=d.root??d;f.uuid===a&&f.onVariableUpdate(c,l,u)});let h=this.materials[a];h&&h.onVariableUpdate(c,l,u)}else{let a=n.find(o[0]);if(a===void 0){this.variables[t].locations.splice(s,1);continue}if(o[1]!=="geometry"){for(let l=1;l<o.length-1;l++)a=a[o[l]];o[1]==="rotation"&&(r=Se.DEG2RAD*r),a[o[o.length-1]]=r}if(a=n.find(o[0]),lt.is(a)){if(o[1]==="position"||o[1]==="rotation"||o[1]==="scale")a.onVariableUpdate();else if(o[1]==="geometry"){let l=a;a.component&&(l=a.component);let u=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(u.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.instances.forEach(c=>{let h=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(h.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!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 n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=Se.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],s=n.locations?.findIndex(o=>Rr.equal(o,e));s!==void 0&&s!==-1&&n.locations.splice(s,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),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.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]==="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]==="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(Lr.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(Lr.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};n.update(s),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},w_e=new Ec(fi.emptyData());var es=class extends $t{updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),yP(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[s,o]of Object.entries(e.props)){let a=n.shared.material(o);this.material[Number(s)]=a}else if(qn(e.path,["material"])&&this.material instanceof bi)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Lr.drop(e,1),r.material,n);else if(qn(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&s<this.material.length){let o=r.materials[s];typeof o!="string"&&this.material[s].updateByOp(Lr.drop(e,2),o,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;if(e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe),r.scene.markNeedsUpdateRendererDirty()),e.geometry?.type==="NonParametricGeometry"&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(s=>r.shared.material(s).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s<this.material.length;s++)this.material[s]=this.material[s].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe)}disposeMaterial(){this.material&&hy(this.material).forEach(e=>{e instanceof bi&&(e instanceof _c||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var RI=new _,LI=new Xe,NI=new Xe,x9=new _,BI=new ie,Qt=class extends es{constructor(e,r,n){super(e,r);this.data=r;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.isSkinnedMesh=!0,this.bindMode=r.bindMode,this.bindMatrix=new ie().fromArray(r.bindMatrix),this.bindMatrixInverse=new ie)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ae&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Ec){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 pp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return pp.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),qn(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Lr.drop(e,1),r.geometry,n)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...s};this.localGeometry=mc(c,r,this.data.flatShading,this)}let o,a,l;s.scaleBaked?[o,a,l]=s.scaleBaked:{width:o,height:a,depth:l}=s;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Rp(this.localGeometry.attributes,o/u.sxPrev,a/u.syPrev,l/u.szPrev),u.sxPrev=o,u.syPrev=a,u.szPrev=l}else{let s={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=mc(s,r,this.data.flatShading,this)}}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,n){let s=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fr&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(s=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),s||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),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 n=this.geometry.userData.parameters;this.is2DType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(n.width,n.height,n.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,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 Xe,n=this.geometry.attributes.skinWeight;for(let s=0,o=n.count;s<o;s++){r.fromBufferAttribute(n,s);let a=1/r.manhattanLength();a!==1/0?r.multiplyScalar(a):r.set(1,0,0,0),n.setXYZW(s,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let s=this.geometry;LI.fromBufferAttribute(s.attributes.skinIndex,e),NI.fromBufferAttribute(s.attributes.skinWeight,e),RI.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let o=0;o<4;o++){let a=NI.getComponent(o);if(a!==0){let l=LI.getComponent(o);BI.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(x9.copy(RI).applyMatrix4(BI),a)}}return r.applyMatrix4(this.bindMatrixInverse)}};function b9(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,s=new Float32Array(r.length);for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=new _(n[o],n[o+1],n[o+2]);t.has(a)?t.get(a)?.normals.push(l):t.set(a,{normals:[l],result:new _})}t.forEach((o,a)=>{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o<r.length;o+=3){let a=`${r[o]}_${r[o+1]}_${r[o+2]}`,l=t.get(a)?.result;l&&(s[o]=l.x,s[o+1]=l.y,s[o+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new be(s,3))}function w9(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new _;for(let s=0;s<e.length;s+=3)n.set(e[s],e[s+1],e[s+2]).normalize(),r[s]=n.x,r[s+1]=n.y,r[s+2]=n.z;i.geometry.setAttribute("extrudeNormal",new be(r,3))}function Md(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof bi)||i.material.getLayersOfType("outline").length===0)return;i instanceof Qt&&i.is2DAndNoDepth?w9(i):b9(i)}function Td(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=parseInt(i.uuid.replace(/\D/g,"")),s=[Se.seededRandom(n),Se.seededRandom(n+1e4),Se.seededRandom(n+2e4)];for(let o=0;o<e.length;o++)r[o]=s[o%3];i.geometry.setAttribute("randomColor",new Ge(r,3))}var S9;td.then(i=>{S9=i});var ho=new Pt,Yp=new _;function FI(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ps=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new ie;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 n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:s,subdivPointer:o}=Fr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=o,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Md(this),Td(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,$t.prototype.raycast.call(this,e,r),this.localGeometry=n}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 fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;ho.setFromBufferAttribute(r),ho.getCenter(n),e.boundingSphere.radius=n.distanceTo(ho.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ho.getSize(Yp),this.hasNonUniformScale&&Yp.divide(this.scale);let s={width:Yp.x,height:Yp.y,depth:Yp.z};return this.geometry.userData.parameters=s,s}updateBoundingSphere(e){let r=this.originalGeometry;ho.min.set(e[0],e[2],e[4]),ho.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(ho.min.applyMatrix4(this.shearScaleInv),ho.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new fr);let n=r.boundingSphere.center;ho.getCenter(n),r.boundingSphere.radius=n.distanceTo(ho.max)}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&this.createGeometryByControls(r)}};var kI=-1,A9=1,VI={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},zI={polygon_center:0,edge:1,vertex:2},Xp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ct=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-kI)*(e-r)/(A9-kI)+r};function UI(i){let t=[],e={};for(var r=0,n=i.length;r<n;r++){var s=JSON.stringify(i[r].pos.map(o=>Math.round(o*1e4)/1e4));e[s]||(t.push(i[r]),e[s]=!0)}return t}var _9=new _,t0=new _,E9=new _,M9=new _;function Cd(i,t){let e=E9.fromArray(i),r=M9.fromArray(t);t0.copy(r).sub(e);let n=t0.length();return t0.normalize().multiplyScalar(n*.5),_9.copy(e).add(t0).toArray()}var ts=new dr,r0=new _,n0=new _,Mc=new _;function GI(i){let t=[];for(let e=0;e<=i.index.count;e++)if(r0.fromArray(i.index.array,e*3),ts.setFromAttributeAndIndices(i.attributes.position,r0.x,r0.y,r0.z),ts.getNormal(n0),ts.getMidpoint(Mc),!(isNaN(Mc.x)||isNaN(Mc.y)||isNaN(Mc.z))){let{a:r,b:n,c:s}=ts,o=r.toArray(),a=n.toArray(),l=s.toArray(),u=r.distanceTo(n),c=n.distanceTo(s),h=s.distanceTo(r),d=Cd(o,a),f=Cd(a,l),p=Cd(l,o),m=[u,c,h],g=Math.max(...m),y=m.filter(w=>Math.round(w)===Math.round(g)).length>1,v=[],x=ts.getMidpoint(Mc).toArray();g===u&&!y&&(v=[f,p,p],x=d),g===c&&!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:ts.getNormal(n0).toArray()})}return t}function HI(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){ts.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),ts.getNormal(n0),ts.getMidpoint(Mc);let n=ts.a.toArray(),s=ts.b.toArray(),o=ts.c.toArray();t.push({vertices:[n,s,o],faceCenters:[Cd(n,s),Cd(s,o),Cd(o,n)],midpoint:Mc.toArray(),norm:n0.toArray()})}return t}var T9=4,C9=.5,zA=i=>.5*(1-Math.cos(i*Math.PI)),UA=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 n=Math.floor(t),s=Math.floor(e),o=Math.floor(r),a=t-n,l=e-s,u=r-o,c,h,d=0,f=.5,p,m,g;for(let y=0;y<T9;y++){let v=n+(s<<4)+(o<<8);c=zA(a),h=zA(l),p=this.perlin[v&4095],p+=c*(this.perlin[v+1&4095]-p),m=this.perlin[v+16&4095],m+=c*(this.perlin[v+16+1&4095]-m),p+=h*(m-p),v+=256,m=this.perlin[v&4095],m+=c*(this.perlin[v+1&4095]-m),g=this.perlin[v+16&4095],g+=c*(this.perlin[v+16+1&4095]-g),m+=h*(g-m),p+=zA(u)*(m-p),d+=p*f,f*=C9,n<<=1,a*=2,s<<=1,l*=2,o<<=1,u*=2,a>=1&&(n++,a--),l>=1&&(s++,l--),u>=1&&(o++,u--)}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()}},jI=UA;var WI=new _,qI=new ie,YI=new ms;function GA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Pd=class extends Qt{constructor(e,r,n){super(e,r,n);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:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(qI.copy(n).invert(),YI.copy(e.ray).applyMatrix4(qI),YI.intersectBox(this.singleBBox,WI))){let s=WI.applyMatrix4(n),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var oi=1e-4,fo,KI,ZI,JI,XI=new _,QI=new _;td.then(i=>{fo=i,KI=[fo.get_face_center,fo.get_edge_midpoint,fo.get_vertex_position],ZI=[fo.get_face_normal,fo.get_edge_normal,fo.get_vertex_normal],JI=[fo.face_count,fo.edge_count,fo.vertex_count]});var P9=new ie,D9=new ie,ml=new _,Tc=new _,Qp=new _,HA=new _,I9=new _,O9=new _;var ca=new jI,Dn=class extends Uh(gt){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 mr&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof mr&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let s=0,o=this.children.length;s<o;++s)this.remove(this.children[0]);let n=this.children;if(n.length===r)return;if(n.length<r)for(let s=0,o=r-n.length;s<o;++s){let a=new mr(this.object);a.expand(),this.add(a)}else for(let s=0,o=n.length-r;s<o;++s)this.remove(n[s])}else{if(this.children.length===r)return;if(this.children.length<r)for(let n=0,s=r-this.children.length;n<s;++n){let o=new mr(this.object);o.expand(),this.add(o)}else for(let n=0,s=this.children.length-r;n<s;++n)this.remove(this.children[0])}}_updateRadial(e){let r=e.radial,n=r.start*Se.DEG2RAD,s=r.end*Se.DEG2RAD,o=n-s,a=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),l;switch(r.axis){case"z":l=new _(0,0,1);break;case"y":l=new _(0,1,0);break;default:case"x":l=new _(1,0,0);break}let u=e.randomnessObject??$s.defaultData([1,1,1]).randomnessObject,c=u.noiseType==="perlin";ca.noiseSeed(u.seed);let h=pv((0,Dd.default)(u.seed)),d=Xp(u.strength,this.parameters.randomness);for(let[f,p]of this.children.entries()){let m=f*(u.freqScale/10)+u.movement,g=c?ca.noise(m):h(m,m),y=f+1;p.scale.x=r.scale[0]+d(y,ct(g,u.scale[0]))||oi,p.scale.y=r.scale[1]+d(y,ct(g,u.scale[1]))||oi,p.scale.z=r.scale[2]+d(y,ct(g,u.scale[2]))||oi,p.position.setScalar(0);let v=o/e.count*f-n;switch(r.axis){case"x":p.rotation.set(0,v,0);break;case"y":p.rotation.set(0,0,v);break;case"z":p.rotation.set(v,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0]+d(y,ct(g,u.position[0])),p.position.y+=r.position[1]+d(y,ct(g,u.position[1])),p.position.z+=r.position[2]+d(y,ct(g,u.position[2]));let x=d(y,ct(g,u.rotation[0])),w=d(y,ct(g,u.rotation[1])),S=d(y,ct(g,u.rotation[2]));r.alignment===!0?(p.rotation.x+=a.x+x,p.rotation.y+=a.y+w,p.rotation.z+=a.z+S):p.rotation.set(a.x+x,a.y+w,a.z+S)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??$s.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ca.noiseSeed(s.seed);let a=pv((0,Dd.default)(s.seed)),l=Xp(s.strength,this.parameters.randomness);for(let[u,c]of this.children.entries()){let h=u*(s.freqScale/10)+s.movement,d=o?ca.noise(h):a(h,h),f=u+1,p=l(f,ct(d,s.rotation[0])),m=l(f,ct(d,s.rotation[1])),g=l(f,ct(d,s.rotation[2]));c.scale.x=1+(r.scale[0]-1)*u+l(f,ct(d,s.scale[0]))||oi,c.scale.y=1+(r.scale[1]-1)*u+l(f,ct(d,s.scale[1]))||oi,c.scale.z=1+(r.scale[2]-1)*u+l(f,ct(d,s.scale[2]))||oi,c.rotation.x=n.x*u+p,c.rotation.y=n.y*u+m,c.rotation.z=n.z*u+g,c.position.x=r.position[0]*u+l(f,ct(d,s.position[0])),c.position.y=r.position[1]*u+l(f,ct(d,s.position[1])),c.position.z=r.position[2]*u+l(f,ct(d,s.position[2]))}}_updateGrid(e){let r=0,n=e.grid,s=e.randomnessObject??$s.defaultData([1,1,1]).randomnessObject,o=Xp(s.strength,this.parameters.randomness),a=s.noiseType==="perlin";ca.noiseSeed(s.seed);let l=V2((0,Dd.default)(s.seed));if(n.useCenter===!0){let u={x:n.count[0]%2===0?2:1,y:n.count[1]%2===0?2:1,z:n.count[2]%2===0?2:1},c=new _(n.size[0]*(n.count[0]-u.x)*.5,n.size[1]*(n.count[1]-u.y)*.5,n.size[2]*(n.count[2]-u.z)*.5);for(let h=0;h<n.count[0];h++)for(let d=0;d<n.count[1];d++)for(let f=0;f<n.count[2];f++){let p=[(h+1)*(s.freqScale/10)+s.movement,(d+1)*(s.freqScale/10)+s.movement,(f+1)*(s.freqScale/10)+s.movement],m=a?ca.noise(...p):l(...p),g=this.children[r++];g.scale.x=1+o(r,ct(m,s.scale[0]))||oi,g.scale.y=1+o(r,ct(m,s.scale[1]))||oi,g.scale.z=1+o(r,ct(m,s.scale[2]))||oi;let y=o(r,ct(m,s.rotation[0])),v=o(r,ct(m,s.rotation[1])),x=o(r,ct(m,s.rotation[2]));g.rotation.set(y,v,x),g.position.x=n.size[0]*h-c.x+o(r,ct(m,s.position[0])),g.position.y=n.size[1]*d-c.y+o(r,ct(m,s.position[1])),g.position.z=n.size[2]*f-c.z+o(r,ct(m,s.position[2]))}}else for(let u=0;u<n.count[0];u++)for(let c=0;c<n.count[1];c++)for(let h=0;h<n.count[2];h++){let d=[(u+1)*(s.freqScale/10)+s.movement,(c+1)*(s.freqScale/10)+s.movement,(h+1)*(s.freqScale/10)+s.movement],f=a?ca.noise(...d):l(...d),p=this.children[r++];p.scale.x=1+o(r,ct(f,s.scale[0]))||oi,p.scale.y=1+o(r,ct(f,s.scale[1]))||oi,p.scale.z=1+o(r,ct(f,s.scale[2]))||oi;let m=o(r,ct(f,s.rotation[0])),g=o(r,ct(f,s.rotation[1])),y=o(r,ct(f,s.rotation[2]));p.rotation.set(m,g,y),p.position.x=n.size[0]*u+o(r,ct(f,s.position[0])),p.position.y=-n.size[1]*c+o(r,ct(f,s.position[1])),p.position.z=-n.size[2]*h+o(r,ct(f,s.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:r}=e,n=new Zt(r.rotation[0],r.rotation[1],r.rotation[2]),s=e.randomnessObject??$s.defaultData([1,1,1]).randomnessObject,o=s.noiseType==="perlin";ca.noiseSeed(s.seed);let a=pv((0,Dd.default)(s.seed)),l=Xp(s.strength,this.parameters.randomness);if(!r.object){for(let[,y]of this.children.entries())y.position.set(0,0,0),y.scale.setScalar(1),y.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Pd)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let u=this.getSubdivData(),c=[],h=y=>{let v=y.length,x=y.map(A=>A[0]).reduce((A,E)=>A+E,0),w=y.map(A=>A[1]).reduce((A,E)=>A+E,0),S=y.map(A=>A[2]).reduce((A,E)=>A+E,0);return[x/v,w/v,S/v]},d=y=>Math.round(y*1e6)/1e6;u.forEach(y=>{let v=u.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?c.push({pos:y.pos,norm:h(v.map(x=>x.norm))}):c.push(y)});let f=UI(c);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 mv(this.objectForSample).build(),m=VI[r.axis],g=this.children;p.setRandomGenerator((0,Dd.default)(this.object.uuid+r.seed));for(let[y,v]of g.entries()){let x=y*(s.freqScale/10)+s.movement,w=o?ca.noise(x):a(x,x),S=y+1,A=l(S,ct(w,s.rotation[0])),E=l(S,ct(w,s.rotation[1])),b=l(S,ct(w,s.rotation[2]));r.spreadType==="random"?p.sample(Qp,HA):(f.length&&(Qp.fromArray(f[y].pos),HA.fromArray(f[y].norm)),this.objectForSample instanceof Ps&&Qp.applyMatrix4(P9.copy(this.objectForSample.matrixWorld).invert())),Qp.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Qp),ml.fromArray(m);let M=r.align==="normal"?HA:this.object.getWorldDirection(O9),T=Tc.fromArray(r.position);Tc.x+=Tc.x+l(S,ct(w,s.position[0])),Tc.y+=Tc.y+l(S,ct(w,s.position[1])),Tc.z+=Tc.z+l(S,ct(w,s.position[2]));let C=Math.acos(M.dot(ml)),P=I9.crossVectors(ml,M).normalize(),D=D9.makeRotationAxis(P,C),I=M.clone().cross(this.object.up).normalize(),R=I.clone().cross(M).normalize(),V=new ie().makeBasis(I,M,R),k=new _(ml.y,ml.z,ml.x).normalize(),z=k.clone().cross(ml).normalize(),G=new ie().makeBasis(k,ml,z).invert(),H=new ie().multiplyMatrices(V,G);v.rotation.setFromRotationMatrix(H),T.applyMatrix4(D),v.position.add(T),v.rotation.x=v.rotation.x+n.x+A,v.rotation.y=v.rotation.y+n.y+E,v.rotation.z=v.rotation.z+n.z+b,v.scale.setScalar(1),v.scale.x=v.scale.x+r.scale[0]+l(S,ct(w,s.scale[0]))||oi,v.scale.y=v.scale.y+r.scale[1]+l(S,ct(w,s.scale[1]))||oi,v.scale.z=v.scale.z+r.scale[2]+l(S,ct(w,s.scale[2]))||oi,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 Ps){let r=this.objectForSample,n=zI[e],s=JI[n],o=KI[n],a=ZI[n],l=[],u=s(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let h=o(r.subdivPointerNew,c),d=a(r.subdivPointerNew,c);XI.fromArray(h).applyMatrix4(r.matrixWorld),QI.fromArray(d),l.push({pos:XI.toArray(),norm:QI.toArray()})}return l}else return(this.objectForSample.geometry.index?GI(this.objectForSample.geometry):HI(this.objectForSample.geometry)).map((n,s)=>e==="polygon_center"?{pos:n.midpoint,norm:n.norm}:e==="vertex"?[{pos:n.vertices[0],norm:n.norm},{pos:n.vertices[1],norm:n.norm},{pos:n.vertices[2],norm:n.norm}]:e==="edge"?[{pos:n.faceCenters[0],norm:n.norm},{pos:n.faceCenters[1],norm:n.norm},{pos:n.faceCenters[2],norm:n.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Ko(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 n=r.find(this.parameters.toObject.object);n instanceof $t?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new ie,this.hiddenMatrix=new ie,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var po=i=>{var t;return t=class extends i{},t.geometryHelper=new yn(30,30,30),t};var i0=new ms,jA=new fr,$I=new ie,mo=(i,t,e,r,n=!1)=>{let s=t,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),jA.copy(s.boundingSphere),jA.applyMatrix4(o),e.ray.intersectsSphere(jA)===!1||($I.copy(o).invert(),i0.copy(e.ray).applyMatrix4($I),s.boundingBox!==null&&i0.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,p,m;if(n===!1){let y=Math.max(0,f.start),v=Math.min(h.count,f.start+f.count);for(p=y,m=v;p<m;p+=3)if(l=h.getX(p),u=h.getX(p+1),c=h.getX(p+2),a=g(i,e,i0,d,l,u,c),a){a.faceIndex=Math.floor(p/3),r.push(a);return}}else{let v=s.attributes.position,x=new _,w=new _,S=new _,A=new _,E=2,M=1/((i.scale.x+i.scale.y+i.scale.z)/3),T=M*M,C=Math.max(0,f.start),P=Math.min(v.count,f.start+f.count);for(let D=C,I=P-1;D<I;D+=E){if(x.fromBufferAttribute(v,D),w.fromBufferAttribute(v,D+1),i0.distanceSqToSegment(x,w,A,S)>T)continue;A.applyMatrix4(i.matrixWorld);let V=e.ray.origin.distanceTo(A);V<e.near||V>e.far||r.push({distance:V,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function g(y,v,x,w,S,A,E){let b=new _,M=new _,T=new _,C=new _,P=new _;if(b.fromBufferAttribute(w,S),M.fromBufferAttribute(w,A),T.fromBufferAttribute(w,E),x.intersectTriangle(b,M,T,!1,C)===null)return null;P.copy(C),P.applyMatrix4(y.matrixWorld);let I=v.ray.origin.distanceTo(P);return I<v.near||I>v.far?null:{faceIndex:1,distance:I,point:P.clone(),object:y}}};var s0=new _,rs=new gs,WA=class extends Pa{constructor(e){let r=new Ae,n=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Re(15711266),u=new Re(15711266),c=new Re(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",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);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 be(s,3)),r.setAttribute("color",new be(o,3));super(r,n);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,n=!0;rs.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=n?.8:1e-4;Ds("n1",r,e,rs,-s,-o,a),Ds("n2",r,e,rs,s,-o,a),Ds("n3",r,e,rs,-s,o,a),Ds("n4",r,e,rs,s,o,a);let l=a;Ds("f1",r,e,rs,-s,-o,l),Ds("f2",r,e,rs,s,-o,l),Ds("f3",r,e,rs,-s,o,l),Ds("f4",r,e,rs,s,o,l);let u=l,c=.5;Ds("u1",r,e,rs,s*.7*c,o*1.1,u),Ds("u2",r,e,rs,-s*.7*c,o*1.1,u),Ds("u3",r,e,rs,0,o*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ds(i,t,e,r,n,s,o){s0.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],s0.x,s0.y,s0.z)}}var o0=class extends po(WA){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){mo(this.object,this.geometry,e,r,!0)}};var a0;(t=>t.is=e=>"objectHelper"in e)(a0||(a0={}));var go=(i,t)=>class extends Hh(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,s){this.objectHelper.raycast(n,s)}showGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof La&&(s.visible=!0)}}updateEntityBoxSize(n,s){this.objectHelper.visible&&this.geometryHelper instanceof yn?(n.setScalar(0),s.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,s)}hideGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof La&&(s.visible=!1)}}};var l0=790,Id=new _,qA=new _,YA=new He,XA=new _,Kp=new _,QA=new _,er=class extends go(gs,o0){constructor(e="",r={...lc.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Xa.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ie,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,s=this.height;this.orthoCamera=new au(n*-.5,n*.5,s*.5,s*-.5,-5e4,1e4),this.perspCamera=new Ir(45,n/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,n){typeof e=="number"&&(e=new _(e,r,n)),super.lookAt(e),this.getWorldPosition(Id),this.targetOffset=Id.distanceTo(e)}getTarget(e=new _){return this.getWorldDirection(qA),this.getWorldPosition(Id),qA.multiplyScalar(this.targetOffset),e.copy(Id).add(qA),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Id),Id.distanceTo(e)}updateUp(){this.getWorldQuaternion(YA),XA.set(0,0,1).applyQuaternion(YA),Kp.copy(gt.DEFAULT_UP),this.isUpVectorFlipped&&Kp.negate(),Kp.applyQuaternion(YA),QA.copy(gt.DEFAULT_UP).projectOnPlane(XA),this.angleOffsetFromUp=QA.angleTo(Kp),this.angleOffsetFromUp*=QA.cross(Kp).dot(XA)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new _),s=e.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new _,n=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let s=e>r?this.aspect:1,o=e>r?1:this.aspect;this.left=-l0*.5*s,this.right=l0*.5*s,this.top=l0*.5*(1/o),this.bottom=-l0*.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,n,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,s,o,a):this.orthoCamera.setViewOffset(e,r,n,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 ih(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="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,n){super.updateByPatchedOp(e,r,n),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 Od=new ie,L9=new ie,c0=new ie,eO=new _,tO=new _;function KA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var ns=class extends es{constructor(e,r,n){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Ae;this.onAfterRender=(e,r,n,s,o,a)=>{super.onAfterRender(e,r,n,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,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];o instanceof ns&&o.dataPatched.visible===!0&&o.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(o instanceof $t&&o.dataPatched.visible===!0&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0){if(Od.multiplyMatrices(o.hiddenMatrix,o.matrix),o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=Zi.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;Zi.transformMeshSet(o.booleanMeshSetAddress,Od),o.booleanMatrixInvOld.copy(Od).invert(),o.booleanWasTransformed=!1}else o instanceof ns&&o.needsTransformForDownstream===!0?(Zi.transformMeshSet(o.booleanMeshSetAddress,Od),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(Zi.transformMeshSet(o.booleanMeshSetAddress,L9.multiplyMatrices(Od,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(Od).invert(),o.booleanWasTransformed=!1);Zi.hasOpenEdges(o.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(o.booleanMeshSetAddress),o.geometry.userData.wasFilteredFromBoolean=!1):o.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new be([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Zi.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Ae,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Zi.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Md(this),Td(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),c0.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(c0),eO.copy(e.max).applyMatrix4(c0),tO.copy(e.min).applyMatrix4(c0),this.geometry.boundingSphere.radius=eO.distanceTo(tO)/2),e}};var u0;(t=>{function i(e){return lt.is(e)&&e instanceof Oa}t.is=i})(u0||(u0={}));var Rd=(i,t)=>class extends go(i,t){updateState_Light(r,n){this.updateState_Entity(r,n),r.color!==void 0&&(this.color=n.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 Yn=i=>i instanceof $t,Xn=i=>i!==null&&i instanceof ns,rO=i=>i instanceof er,nO=i=>u0.is(i),Zp=i=>a0.is(i);var yo=class extends po(Rg){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){mo(this.object,yo.geometryHelper,e,r)}update(){}};var is=class extends go(Hs,yo){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 uO={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Jp="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var N9=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
5372 | uniform mediump sampler2D inputBuffer;
|
5373 | #else
|
5374 | uniform lowp sampler2D inputBuffer;
|
5375 | #endif
|
5376 | uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;
|
5377 | #if PASS == 1
|
5378 | uniform vec4 kernel64[32];
|
5379 | #else
|
5380 | uniform vec4 kernel16[8];
|
5381 | #endif
|
5382 | varying vec2 vUv;void main(){
|
5383 | #ifdef FOREGROUND
|
5384 | vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale;
|
5385 | #else
|
5386 | float CoC=texture2D(cocBuffer,vUv).g*scale;
|
5387 | #endif
|
5388 | if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{
|
5389 | #ifdef FOREGROUND
|
5390 | vec2 step=texelSize*max(CoC,CoCNearFar.g*scale);
|
5391 | #else
|
5392 | vec2 step=texelSize*CoC;
|
5393 | #endif
|
5394 | #if PASS == 1
|
5395 | 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;
|
5396 | #else
|
5397 | vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue;
|
5398 | #endif
|
5399 | }}`,h0=class extends at{constructor(i=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:i?"2":"1"},uniforms:{kernel64:new oe(null),kernel16:new oe(null),inputBuffer:new oe(null),cocBuffer:new oe(null),texelSize:new oe(new N),scale:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:N9,vertexShader:Jp}),this.toneMapped=!1,t&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}set cocBuffer(i){this.uniforms.cocBuffer.value=i}setCoCBuffer(i){this.uniforms.cocBuffer.value=i}get scale(){return this.uniforms.scale.value}set scale(i){this.uniforms.scale.value=i}getScale(i){return this.uniforms.scale.value=i}setScale(i){this.uniforms.scale.value=i}generateKernel(){let i=2.39996323,t=new Float32Array(128),e=new Float32Array(32),r=0,n=0;for(let a=0;a<80;++a){let l=a*i,u=Math.sqrt(a)/Math.sqrt(80),c=u*Math.cos(l),h=u*Math.sin(l);a%5===0?(e[n++]=c,e[n++]=h):(t[r++]=c,t[r++]=h)}let s=[],o=[];for(let a=0;a<128;)s.push(new Xe(t[a++],t[a++],t[a++],t[a++]));for(let a=0;a<32;)o.push(new Xe(e[a++],e[a++],e[a++],e[a++]));this.uniforms.kernel64.value=s,this.uniforms.kernel16.value=o}setTexelSize(i,t){this.uniforms.texelSize.value.set(i,t)}setSize(i,t){this.uniforms.texelSize.value.set(1/i,1/t)}};function iO(i,t,e){return i*(t-e)-t}function t1(i,t,e){return Math.min(Math.max((i+t)/(t-e),0),1)}var B9=`#include <common>
|
5400 | #include <packing>
|
5401 | #ifdef GL_FRAGMENT_PRECISION_HIGH
|
5402 | uniform highp sampler2D depthBuffer;
|
5403 | #else
|
5404 | uniform mediump sampler2D depthBuffer;
|
5405 | #endif
|
5406 | uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){
|
5407 | #if DEPTH_PACKING == 3201
|
5408 | return unpackRGBAToDepth(texture2D(depthBuffer,uv));
|
5409 | #else
|
5410 | return texture2D(depthBuffer,uv).r;
|
5411 | #endif
|
5412 | }void main(){float depth=readDepth(vUv);
|
5413 | #ifdef PERSPECTIVE_CAMERA
|
5414 | float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
|
5415 | #else
|
5416 | float linearDepth=depth;
|
5417 | #endif
|
5418 | 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));}`,F9=class extends at{constructor(i){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new oe(null),focusDistance:new oe(0),focusRange:new oe(0),cameraNear:new oe(.3),cameraFar:new oe(1e3)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:B9,vertexShader:Jp}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(i)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(i){this.uniforms.depthBuffer.value=i}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(i){this.uniforms.focusDistance.value=i}get worldFocusDistance(){return-iO(this.focusDistance,this.near,this.far)}set worldFocusDistance(i){this.focusDistance=t1(-i,this.near,this.far)}getFocusDistance(i){this.uniforms.focusDistance.value=i}setFocusDistance(i){this.uniforms.focusDistance.value=i}get focalLength(){return this.focusRange}set focalLength(i){this.focusRange=i}get focusRange(){return this.uniforms.focusRange.value}set focusRange(i){this.uniforms.focusRange.value=i}get worldFocusRange(){return-iO(this.focusRange,this.near,this.far)}set worldFocusRange(i){this.focusRange=t1(-i,this.near,this.far)}getFocalLength(i){return this.focusRange}setFocalLength(i){this.focusRange=i}adoptCameraSettings(i){i&&(this.uniforms.cameraNear.value=i.near,this.uniforms.cameraFar.value=i.far,i instanceof Ir?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},k9=`#include <common>
|
5419 | #include <dithering_pars_fragment>
|
5420 | #ifdef FRAMEBUFFER_PRECISION_HIGH
|
5421 | uniform mediump sampler2D inputBuffer;
|
5422 | #else
|
5423 | uniform lowp sampler2D inputBuffer;
|
5424 | #endif
|
5425 | 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;
|
5426 | #include <encodings_fragment>
|
5427 | #include <dithering_fragment>
|
5428 | }`,V9="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);}",sO=class extends at{constructor(i=new N){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new oe(null),texelSize:new oe(new N),halfTexelSize:new oe(new N),kernel:new oe(0),scale:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:k9,vertexShader:V9}),this.toneMapped=!1,this.setTexelSize(i.x,i.y)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.inputBuffer=i}get scale(){return this.uniforms.scale.value}set scale(i){this.uniforms.scale.value=i}getScale(){return this.uniforms.scale.value}setScale(i){this.uniforms.scale.value=i}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(i){this.uniforms.kernel.value=i}setKernel(i){this.kernel=i}setTexelSize(i,t){this.uniforms.texelSize.value.set(i,t),this.uniforms.halfTexelSize.value.set(i,t).multiplyScalar(.5)}setSize(i,t){let e=this.uniforms;e.texelSize.value.set(1/i,1/t),e.halfTexelSize.value.copy(e.texelSize.value).multiplyScalar(.5)}},z9=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
5429 | uniform mediump sampler2D inputBuffer;
|
5430 | #else
|
5431 | uniform lowp sampler2D inputBuffer;
|
5432 | #endif
|
5433 | uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;
|
5434 | #include <encodings_fragment>
|
5435 | }`,U9=class extends at{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new oe(null),opacity:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:z9,vertexShader:Jp}),this.toneMapped=!1}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}getOpacity(i){return this.uniforms.opacity.value}setOpacity(i){this.uniforms.opacity.value=i}};var G9=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
|
5436 | #if THREE_REVISION < 143
|
5437 | #define luminance(v) linearToRelativeLuminance(v)
|
5438 | #endif
|
5439 | #if EDGE_DETECTION_MODE != 0
|
5440 | varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
|
5441 | #endif
|
5442 | #if EDGE_DETECTION_MODE == 1
|
5443 | #include <common>
|
5444 | #endif
|
5445 | #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1
|
5446 | #ifdef GL_FRAGMENT_PRECISION_HIGH
|
5447 | uniform highp sampler2D depthBuffer;
|
5448 | #else
|
5449 | uniform mediump sampler2D depthBuffer;
|
5450 | #endif
|
5451 | float readDepth(const in vec2 uv){
|
5452 | #if DEPTH_PACKING == 3201
|
5453 | return unpackRGBAToDepth(texture2D(depthBuffer,uv));
|
5454 | #else
|
5455 | return texture2D(depthBuffer,uv).r;
|
5456 | #endif
|
5457 | }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}
|
5458 | #elif PREDICATION_MODE == 2
|
5459 | 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);}
|
5460 | #endif
|
5461 | #if PREDICATION_MODE != 0
|
5462 | 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);}
|
5463 | #endif
|
5464 | #if EDGE_DETECTION_MODE != 0
|
5465 | uniform sampler2D inputBuffer;
|
5466 | #endif
|
5467 | void main(){
|
5468 | #if EDGE_DETECTION_MODE == 0
|
5469 | const vec2 threshold=vec2(DEPTH_THRESHOLD);
|
5470 | #elif PREDICATION_MODE != 0
|
5471 | vec2 threshold=calculatePredicatedThreshold();
|
5472 | #else
|
5473 | const vec2 threshold=vec2(EDGE_THRESHOLD);
|
5474 | #endif
|
5475 | #if EDGE_DETECTION_MODE == 0
|
5476 | 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);
|
5477 | #elif EDGE_DETECTION_MODE == 1
|
5478 | 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);
|
5479 | #elif EDGE_DETECTION_MODE == 2
|
5480 | 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);
|
5481 | #endif
|
5482 | }`,H9=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
|
5483 | #if EDGE_DETECTION_MODE != 0
|
5484 | varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
|
5485 | #endif
|
5486 | 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);
|
5487 | #if EDGE_DETECTION_MODE != 0
|
5488 | 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);
|
5489 | #endif
|
5490 | gl_Position=vec4(position.xy,1.0,1.0);}`,Ld={DEPTH:0,LUMA:1,COLOR:2},j9={DISABLED:0,DEPTH:1,CUSTOM:2},W9=class extends at{constructor(i=new N,t=Ld.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:Wo.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 oe(null),depthBuffer:new oe(null),predicationBuffer:new oe(null),texelSize:new oe(i)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:G9,vertexShader:H9}),this.toneMapped=!1,this.edgeDetectionMode=t}set depthBuffer(i){this.uniforms.depthBuffer.value=i}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(i){this.defines.EDGE_DETECTION_MODE=i.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(i){this.edgeDetectionMode=i}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(i){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=i.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(i){this.localContrastAdaptationFactor=i}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(i){this.defines.EDGE_THRESHOLD=i.toFixed("6"),this.defines.DEPTH_THRESHOLD=(i*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(i){this.edgeDetectionThreshold=i}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(i){this.defines.PREDICATION_MODE=i.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(i){this.predicationMode=i}set predicationBuffer(i){this.uniforms.predicationBuffer.value=i}setPredicationBuffer(i){this.uniforms.predicationBuffer.value=i}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(i){this.defines.PREDICATION_THRESHOLD=i.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(i){this.predicationThreshold=i}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(i){this.defines.PREDICATION_SCALE=i.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(i){this.predicationScale=i}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(i){this.defines.PREDICATION_STRENGTH=i.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(i){this.predicationStrength=i}setSize(i,t){this.uniforms.texelSize.value.set(1/i,1/t)}},q9=`#include <common>
|
5491 | #include <packing>
|
5492 | #include <dithering_pars_fragment>
|
5493 | #define packFloatToRGBA(v) packDepthToRGBA(v)
|
5494 | #define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
|
5495 | #ifdef FRAMEBUFFER_PRECISION_HIGH
|
5496 | uniform mediump sampler2D inputBuffer;
|
5497 | #else
|
5498 | uniform lowp sampler2D inputBuffer;
|
5499 | #endif
|
5500 | #ifdef GL_FRAGMENT_PRECISION_HIGH
|
5501 | uniform highp sampler2D depthBuffer;
|
5502 | #else
|
5503 | uniform mediump sampler2D depthBuffer;
|
5504 | #endif
|
5505 | uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;
|
5506 | #if THREE_REVISION < 143
|
5507 | #define luminance(v) linearToRelativeLuminance(v)
|
5508 | #endif
|
5509 | #if THREE_REVISION >= 137
|
5510 | 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);}
|
5511 | #endif
|
5512 | float readDepth(const in vec2 uv){
|
5513 | #if DEPTH_PACKING == 3201
|
5514 | return unpackRGBAToDepth(texture2D(depthBuffer,uv));
|
5515 | #else
|
5516 | return texture2D(depthBuffer,uv).r;
|
5517 | #endif
|
5518 | }float getViewZ(const in float depth){
|
5519 | #ifdef PERSPECTIVE_CAMERA
|
5520 | return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
|
5521 | #else
|
5522 | return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
|
5523 | #endif
|
5524 | }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0;
|
5525 | #ifdef ENCODE_OUTPUT
|
5526 | #include <encodings_fragment>
|
5527 | #endif
|
5528 | #include <dithering_fragment>
|
5529 | }`,Y9="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);}",Is={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"},r1=class extends at{constructor(i,t,e,r,n=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Wo.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new oe(null),depthBuffer:new oe(null),resolution:new oe(new N),texelSize:new oe(new N),cameraNear:new oe(.3),cameraFar:new oe(1e3),aspect:new oe(1),time:new oe(0)},blending:Vt,depthWrite:!1,depthTest:!1,dithering:n}),this.toneMapped=!1,i&&this.setShaderParts(i),t&&this.setDefines(t),e&&this.setUniforms(e),this.adoptCameraSettings(r)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(i){this.uniforms.depthBuffer.value=i}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}setShaderParts(i){return this.fragmentShader=q9.replace(Is.FRAGMENT_HEAD,i.get(Is.FRAGMENT_HEAD)).replace(Is.FRAGMENT_MAIN_UV,i.get(Is.FRAGMENT_MAIN_UV)).replace(Is.FRAGMENT_MAIN_IMAGE,i.get(Is.FRAGMENT_MAIN_IMAGE)),this.vertexShader=Y9.replace(Is.VERTEX_HEAD,i.get(Is.VERTEX_HEAD)).replace(Is.VERTEX_MAIN_SUPPORT,i.get(Is.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(i){for(let t of i.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(i){for(let t of i.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(i){this.extensions={};for(let t of i)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(i){this.encodeOutput!==i&&(i?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(i){return this.encodeOutput}setOutputEncodingEnabled(i){this.encodeOutput=i}get time(){return this.uniforms.time.value}set time(i){this.uniforms.time.value=i}setDeltaTime(i){this.uniforms.time.value+=i}adoptCameraSettings(i){i&&(this.uniforms.cameraNear.value=i.near,this.uniforms.cameraFar.value=i.far,i instanceof Ir?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(i,t){let e=this.uniforms;e.resolution.value.set(i,t),e.texelSize.value.set(1/i,1/t),e.aspect.value=i/t}static get Section(){return Is}};var X9=`#include <common>
|
5530 | #if THREE_REVISION < 143
|
5531 | #define luminance(v) linearToRelativeLuminance(v)
|
5532 | #endif
|
5533 | #ifdef FRAMEBUFFER_PRECISION_HIGH
|
5534 | uniform mediump sampler2D inputBuffer;
|
5535 | #else
|
5536 | uniform lowp sampler2D inputBuffer;
|
5537 | #endif
|
5538 | #ifdef RANGE
|
5539 | uniform vec2 range;
|
5540 | #elif defined(THRESHOLD)
|
5541 | uniform float threshold;uniform float smoothing;
|
5542 | #endif
|
5543 | varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);
|
5544 | #ifdef RANGE
|
5545 | float low=step(range.x,l);float high=step(l,range.y);l*=low*high;
|
5546 | #elif defined(THRESHOLD)
|
5547 | l=smoothstep(threshold,threshold+smoothing,l);
|
5548 | #endif
|
5549 | #ifdef COLOR
|
5550 | gl_FragColor=vec4(texel.rgb*l,l);
|
5551 | #else
|
5552 | gl_FragColor=vec4(l);
|
5553 | #endif
|
5554 | }`,Q9=class extends at{constructor(i=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Wo.replace(/\D+/g,"")},uniforms:{inputBuffer:new oe(null),threshold:new oe(0),smoothing:new oe(1),range:new oe(null)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:X9,vertexShader:Jp}),this.toneMapped=!1,this.colorOutput=i,this.luminanceRange=t}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get threshold(){return this.uniforms.threshold.value}set threshold(i){this.smoothing>0||i>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=i}getThreshold(){return this.threshold}setThreshold(i){this.threshold=i}get smoothing(){return this.uniforms.smoothing.value}set smoothing(i){this.threshold>0||i>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=i}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(i){this.smoothing=i}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(i){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(i){i?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(i){return this.colorOutput}setColorOutputEnabled(i){this.colorOutput=i}get useRange(){return this.luminanceRange!==null}set useRange(i){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(i){i!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=i,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(i){this.luminanceRange=i}},K9=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
5555 | uniform mediump sampler2D inputBuffer;
|
5556 | #else
|
5557 | uniform lowp sampler2D inputBuffer;
|
5558 | #endif
|
5559 | #ifdef MASK_PRECISION_HIGH
|
5560 | uniform mediump sampler2D maskTexture;
|
5561 | #else
|
5562 | uniform lowp sampler2D maskTexture;
|
5563 | #endif
|
5564 | #if MASK_FUNCTION != 0
|
5565 | uniform float strength;
|
5566 | #endif
|
5567 | varying vec2 vUv;void main(){
|
5568 | #if COLOR_CHANNEL == 0
|
5569 | float mask=texture2D(maskTexture,vUv).r;
|
5570 | #elif COLOR_CHANNEL == 1
|
5571 | float mask=texture2D(maskTexture,vUv).g;
|
5572 | #elif COLOR_CHANNEL == 2
|
5573 | float mask=texture2D(maskTexture,vUv).b;
|
5574 | #else
|
5575 | float mask=texture2D(maskTexture,vUv).a;
|
5576 | #endif
|
5577 | #if MASK_FUNCTION == 0
|
5578 | #ifdef INVERTED
|
5579 | mask=step(mask,0.0);
|
5580 | #else
|
5581 | mask=1.0-step(mask,0.0);
|
5582 | #endif
|
5583 | #else
|
5584 | mask=clamp(mask*strength,0.0,1.0);
|
5585 | #ifdef INVERTED
|
5586 | mask=1.0-mask;
|
5587 | #endif
|
5588 | #endif
|
5589 | #if MASK_FUNCTION == 2
|
5590 | gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
|
5591 | #else
|
5592 | gl_FragColor=mask*texture2D(inputBuffer,vUv);
|
5593 | #endif
|
5594 | }`,hO={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},Z9=class extends at{constructor(i=null){super({name:"MaskMaterial",uniforms:{maskTexture:new oe(i),inputBuffer:new oe(null),strength:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:K9,vertexShader:Jp}),this.toneMapped=!1,this.setColorChannel(uO.RED),this.setMaskFunction(hO.DISCARD)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}set maskTexture(i){this.uniforms.maskTexture.value=i,delete this.defines.MASK_PRECISION_HIGH,i.type!==lr&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(i){this.maskTexture=i}set colorChannel(i){this.defines.COLOR_CHANNEL=i.toFixed(0),this.needsUpdate=!0}setColorChannel(i){this.colorChannel=i}set maskFunction(i){this.defines.MASK_FUNCTION=i.toFixed(0),this.needsUpdate=!0}setMaskFunction(i){this.maskFunction=i}get inverted(){return this.defines.INVERTED!==void 0}set inverted(i){this.inverted&&!i?delete this.defines.INVERTED:i&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(i){this.inverted=i}get strength(){return this.uniforms.strength.value}set strength(i){this.uniforms.strength.value=i}getStrength(){return this.strength}setStrength(i){this.strength=i}};var J9=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
|
5595 | #if __VERSION__ < 300
|
5596 | #define round(v) floor(v + 0.5)
|
5597 | #endif
|
5598 | #ifdef FRAMEBUFFER_PRECISION_HIGH
|
5599 | uniform mediump sampler2D inputBuffer;
|
5600 | #else
|
5601 | uniform lowp sampler2D inputBuffer;
|
5602 | #endif
|
5603 | uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x>end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x<end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.y>end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;i++){if(!(texCoord.y<end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
|
5604 | #if !defined(DISABLE_CORNER_DETECTION)
|
5605 | 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);
|
5606 | #endif
|
5607 | }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
|
5608 | #if !defined(DISABLE_CORNER_DETECTION)
|
5609 | 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);
|
5610 | #endif
|
5611 | }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){
|
5612 | #if !defined(DISABLE_DIAG_DETECTION)
|
5613 | weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){
|
5614 | #endif
|
5615 | 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);
|
5616 | #if !defined(DISABLE_DIAG_DETECTION)
|
5617 | }else{e.r=0.0;}
|
5618 | #endif
|
5619 | }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;}`,$9="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);}",eY=class extends at{constructor(i=new N,t=new N){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 oe(null),searchTexture:new oe(null),areaTexture:new oe(null),resolution:new oe(t),texelSize:new oe(i)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:J9,vertexShader:$9}),this.toneMapped=!1}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(i){this.uniforms.searchTexture.value=i}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(i){this.uniforms.areaTexture.value=i}setLookupTextures(i,t){this.searchTexture=i,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(i){let t=Math.min(Math.max(i,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(i){this.orthogonalSearchSteps=i}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(i){let t=Math.min(Math.max(i,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(i){this.diagonalSearchSteps=i}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(i){i?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(i){this.diagonalDetection=i}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(i){let t=Math.min(Math.max(i,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(i){this.cornerRounding=i}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(i){i?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(i){this.cornerDetection=i}setSize(i,t){let e=this.uniforms;e.texelSize.value.set(1/i,1/t),e.resolution.value.set(i,t)}};var tY=new gs,gl=null;function rY(){if(gl===null){let i=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);gl=new Ae,gl.setAttribute!==void 0?(gl.setAttribute("position",new Ge(i,3)),gl.setAttribute("uv",new Ge(t,2))):(gl.addAttribute("position",new Ge(i,3)),gl.addAttribute("uv",new Ge(t,2)))}return gl}var Zr=class{constructor(i="Pass",t=new Nn,e=tY){this.name=i,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(i){if(this.rtt===i){let t=this.getFullscreenMaterial();t!==null&&(t.needsUpdate=!0),this.rtt=!i}}setRenderer(i){this.renderer=i}isEnabled(){return this.enabled}setEnabled(i){this.enabled=i}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(i){let t=this.screen;t!==null?t.material=i:(t=new _r(rY(),i),t.frustumCulled=!1,this.scene===null&&(this.scene=new Nn),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(i){this.fullscreenMaterial=i}getDepthTexture(){return null}setDepthTexture(i,t=vn){}render(i,t,e,r,n){throw new Error("Render method not implemented!")}setSize(i,t){}initialize(i,t,e){}dispose(){for(let i of Object.keys(this)){let t=this[i];if(t!==null&&typeof t.dispose=="function"){if(t instanceof Nn||t===this.renderer)continue;this[i].dispose()}}}},$p=class extends Zr{constructor(i,t=!0){super("CopyPass"),this.fullscreenMaterial=new U9,this.needsSwap=!1,this.renderTarget=i,i===void 0&&(this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=t}get resize(){return this.autoResize}set resize(i){this.autoResize=i}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(i){this.autoResize=i}render(i,t,e,r,n){this.fullscreenMaterial.inputBuffer=t.texture,i.setRenderTarget(this.renderToScreen?null:this.renderTarget),i.render(this.scene,this.camera)}setSize(i,t){this.autoResize&&this.renderTarget.setSize(i,t)}initialize(i,t,e){e!==void 0&&(this.renderTarget.texture.type=e,e!==lr?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":i.outputEncoding===et&&(this.renderTarget.texture.encoding=et))}};var dO=class extends Zr{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(i,t,e,r,n){let s=i.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},ZA=new Re,n1=class extends Zr{constructor(i=!0,t=!0,e=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=i,this.depth=t,this.stencil=e,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(i,t,e){this.color=i,this.depth=t,this.stencil=e}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(i){this.overrideClearColor=i}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(i){this.overrideClearAlpha=i}render(i,t,e,r,n){let s=this.overrideClearColor,o=this.overrideClearAlpha,a=i.getClearAlpha(),l=s!==null,u=o>=0;l?(ZA.copy(i.getClearColor(ZA)),i.setClearColor(s,u?o:a)):u&&i.setClearAlpha(o),i.setRenderTarget(this.renderToScreen?null:t),i.clear(this.color,this.depth,this.stencil),l?i.setClearColor(ZA,a):u&&i.setClearAlpha(a)}},yl=-1,wi=class extends Yt{constructor(i,t=yl,e=yl,r=1){super(),this.resizable=i,this.base=new N(1,1),this.preferred=new N(t,e),this.target=this.preferred,this.s=r}get width(){let{base:i,preferred:t,scale:e}=this,r;return t.width!==yl?r=t.width:t.height!==yl?r=Math.round(t.height*(i.width/Math.max(i.height,1))):r=Math.round(i.width*e),r}set width(i){this.preferredWidth=i}get height(){let{base:i,preferred:t,scale:e}=this,r;return t.height!==yl?r=t.height:t.width!==yl?r=Math.round(t.width/Math.max(i.width/Math.max(i.height,1),1)):r=Math.round(i.height*e),r}set height(i){this.preferredHeight=i}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(i){this.s!==i&&(this.s=i,this.preferred.setScalar(yl),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(i){this.scale=i}get baseWidth(){return this.base.width}set baseWidth(i){this.base.width!==i&&(this.base.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(i){this.base.width!==i&&(this.base.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(i){this.base.height!==i&&(this.base.height=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(i){this.baseHeight=i}setBaseSize(i,t){(this.base.width!==i||this.base.height!==t)&&(this.base.set(i,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(i){this.preferred.width!==i&&(this.preferred.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(i){this.preferredWidth=i}get preferredHeight(){return this.preferred.height}set preferredHeight(i){this.preferred.height!==i&&(this.preferred.height=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(i){this.preferredHeight=i}setPreferredSize(i,t){(this.preferred.width!==i||this.preferred.height!==t)&&(this.preferred.set(i,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(i){this.base.set(i.getBaseWidth(),i.getBaseHeight()),this.preferred.set(i.getPreferredWidth(),i.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return yl}},JA=!1,oO=class{constructor(i=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(i),this.meshCount=0,this.replaceMaterial=t=>{if(t.isMesh){let e;if(t.material.flatShading)switch(t.material.side){case Ln:e=this.materialsFlatShadedDoubleSide;break;case Qr:e=this.materialsFlatShadedBackSide;break;default:e=this.materialsFlatShaded;break}else switch(t.material.side){case Ln:e=this.materialsDoubleSide;break;case Qr: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(i){if(this.disposeMaterials(),this.material=i,i!==null){let t=this.materials=[i.clone(),i.clone(),i.clone()];for(let e of t)e.uniforms=Object.assign({},i.uniforms),e.side=Pi;t[2].skinning=!0,this.materialsBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.side=Qr,r}),this.materialsDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.side=Ln,r}),this.materialsFlatShaded=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r}),this.materialsFlatShadedBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r.side=Qr,r}),this.materialsFlatShadedDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r.side=Ln,r})}}render(i,t,e){let r=i.shadowMap.enabled;if(i.shadowMap.enabled=!1,JA){let n=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),i.render(t,e);for(let s of n)s[0].material=s[1];this.meshCount!==n.size&&n.clear()}else{let n=t.overrideMaterial;t.overrideMaterial=this.material,i.render(t,e),t.overrideMaterial=n}i.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let i=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of i)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return JA}static set workaroundEnabled(i){JA=i}},nY=class extends Zr{constructor(i,t,e=null){super("RenderPass",i,t),this.needsSwap=!1,this.clearPass=new n1,this.overrideMaterialManager=e===null?null:new oO(e),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(i){super.renderToScreen=i,this.clearPass.renderToScreen=i}get overrideMaterial(){let i=this.overrideMaterialManager;return i!==null?i.material:null}set overrideMaterial(i){let t=this.overrideMaterialManager;i!==null?t!==null?t.setMaterial(i):this.overrideMaterialManager=new oO(i):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(i){this.overrideMaterial=i}get clear(){return this.clearPass.enabled}set clear(i){this.clearPass.enabled=i}getSelection(){return this.selection}setSelection(i){this.selection=i}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(i){this.ignoreBackground=i}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(i){this.skipShadowMapUpdate=i}getClearPass(){return this.clearPass}render(i,t,e,r,n){let s=this.scene,o=this.camera,a=this.selection,l=o.layers.mask,u=s.background,c=i.shadowMap.autoUpdate,h=this.renderToScreen?null:t;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(i.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(i,t),i.setRenderTarget(h),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(i,s,o):i.render(s,o),o.layers.mask=l,s.background=u,i.shadowMap.autoUpdate=c}},i1=class extends Zr{constructor(i,t,{resolutionScale:e=1,width:r=wi.AUTO_SIZE,height:n=wi.AUTO_SIZE,renderTarget:s}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new nY(i,t,new Nf({depthPacking:Jb}));let o=this.renderPass;o.skipShadowMapUpdate=!0,o.ignoreBackground=!0;let a=o.getClearPass();a.overrideClearColor=new Re(16777215),a.overrideClearAlpha=1,this.renderTarget=s,this.renderTarget===void 0&&(this.renderTarget=new ht(1,1,{minFilter:kt,magFilter:kt,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new wi(this,r,n,e);l.addEventListener("change",u=>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(i){this.resolution.scale=i}render(i,t,e,r,n){let s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(i,s)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height)}};var ETe=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var pt={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},iY="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);}",sY="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));}",oY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",aY="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);}",lY="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);}",cY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",uY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",hY="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);}",dY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",fY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",pY="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);}",mY="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);}",gY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",yY="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);}",vY="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);}",xY="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);}",bY="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);}",wY="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);}",SY=new Map([[pt.SKIP,null],[pt.ADD,iY],[pt.ALPHA,sY],[pt.AVERAGE,oY],[pt.COLOR_BURN,aY],[pt.COLOR_DODGE,lY],[pt.DARKEN,cY],[pt.DIFFERENCE,uY],[pt.EXCLUSION,hY],[pt.LIGHTEN,dY],[pt.MULTIPLY,fY],[pt.DIVIDE,pY],[pt.NEGATION,mY],[pt.NORMAL,gY],[pt.OVERLAY,yY],[pt.REFLECT,vY],[pt.SCREEN,xY],[pt.SOFT_LIGHT,bY],[pt.SUBTRACT,wY]]),AY=class extends Yt{constructor(i,t=1){super(),this.f=i,this.opacity=new oe(t)}getOpacity(){return this.opacity.value}setOpacity(i){this.opacity.value=i}get blendFunction(){return this.f}set blendFunction(i){this.f=i,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(i){this.blendFunction=i}getShaderCode(){return SY.get(this.blendFunction)}},vo={NONE:0,DEPTH:1,CONVOLUTION:2};var xo=class extends Yt{constructor(i,t,{attributes:e=vo.NONE,blendFunction:r=pt.SCREEN,defines:n=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=i,this.renderer=null,this.attributes=e,this.fragmentShader=t,this.vertexShader=a,this.defines=n,this.uniforms=s,this.extensions=o,this.blendMode=new AY(r),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(i){this.renderer=i}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(i){this.attributes=i,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(i){this.fragmentShader=i,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(i){this.vertexShader=i,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(i,t=vn){}update(i,t,e){}setSize(i,t){}initialize(i,t,e){}dispose(){for(let i of Object.keys(this)){let t=this[i];if(t!==null&&typeof t.dispose=="function"){if(t instanceof Nn||t===this.renderer)continue;this[i].dispose()}}}};function aO(i,t,e){for(let r of t){let n="$1"+i+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,n))}}function _Y(i,t,e,r,n,s,o){let a=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=a.get("fragment")!==void 0&&/mainImage/.test(a.get("fragment")),u=a.get("fragment")!==void 0&&/mainUv/.test(a.get("fragment")),c=[],h=[],d=!1,f=!1;if(a.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(u&&(o&vo.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(!l&&!u)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=r1.Section;if(u){let y=` ${i}MainUv(UV);
|
5620 | `;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=` ${i}MainSupport(`;y+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a.get("vertex"))?`vUv);
|
5621 | `:`);
|
5622 | `,e.set(m.VERTEX_MAIN_SUPPORT,e.get(m.VERTEX_MAIN_SUPPORT)+y),c=c.concat([...a.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(v=>v[1])),h=h.concat(c).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(i+v.charAt(0).toUpperCase()+v.slice(1),y)),t.defines.forEach((y,v)=>n.set(i+v.charAt(0).toUpperCase()+v.slice(1),y)),aO(i,h,n),aO(i,h,a);let g=t.blendMode;if(r.set(g.blendFunction,g),l){let y=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,v=`${i}MainImage(color0, UV, `;(o&vo.DEPTH)!==0&&y.test(a.get("fragment"))&&(v+="depth, ",f=!0),v+=`color1);
|
5623 | `;let x=i+"BlendOpacity";s.set(x,g.opacity),v+=`color0 = blend${g.blendFunction}(color0, color1, ${x});
|
5624 |
|
5625 | `,e.set(m.FRAGMENT_MAIN_IMAGE,e.get(m.FRAGMENT_MAIN_IMAGE)+v),v=`uniform float ${x};
|
5626 |
|
5627 | `,e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+v)}e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+a.get("fragment")+`
|
5628 | `),a.get("vertex")!==null&&e.set(m.VERTEX_HEAD,e.get(m.VERTEX_HEAD)+a.get("vertex")+`
|
5629 | `)}return{varyings:c,transformedUv:d,readDepth:f}}var Cc=class extends Zr{constructor(i,...t){super("EffectPass"),this.fullscreenMaterial=new r1(null,null,null,i),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(i){this.fullscreenMaterial.encodeOutput=i}get dithering(){return this.fullscreenMaterial.dithering}set dithering(i){let t=this.fullscreenMaterial;t.dithering=i,t.needsUpdate=!0}verifyResources(){let i=this.renderer.capabilities,t=Math.min(i.maxFragmentUniforms,i.maxVertexUniforms);this.uniformCount>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniformCount+" were defined"),t=i.maxVaryings,this.varyingCount>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let i=r1.Section,t=new Map([[i.FRAGMENT_HEAD,""],[i.FRAGMENT_MAIN_UV,""],[i.FRAGMENT_MAIN_IMAGE,""],[i.VERTEX_HEAD,""],[i.VERTEX_MAIN_SUPPORT,""]]),e=new Map,r=new Map,n=new Map,s=new Set,o=0,a=0,l=0,u=!1,c=!1;for(let d of this.effects)if(d.blendMode.blendFunction===pt.SKIP)l|=d.getAttributes()&vo.DEPTH;else if((l&d.getAttributes()&vo.CONVOLUTION)!==0)console.error("Convolution effects cannot be merged",d);else{l|=d.getAttributes();let f="e"+o++,p=_Y(f,d,t,e,r,n,l);if(a+=p.varyings.length,u=u||p.transformedUv,c=c||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(i.FRAGMENT_HEAD,t.get(i.FRAGMENT_HEAD)+f+`
|
5630 | `)}if((l&vo.DEPTH)!==0){if(c){let d=`float depth = readDepth(UV);
|
5631 |
|
5632 | `;t.set(i.FRAGMENT_MAIN_IMAGE,d+t.get(i.FRAGMENT_MAIN_IMAGE))}this.needsDepthTexture=this.getDepthTexture()===null}else this.needsDepthTexture=!1;if(u){let d=`vec2 transformedUv = vUv;
|
5633 | `;t.set(i.FRAGMENT_MAIN_UV,d+t.get(i.FRAGMENT_MAIN_UV)),r.set("UV","transformedUv")}else r.set("UV","vUv");t.forEach((d,f,p)=>p.set(f,d.trim().replace(/^#/,`
|
5634 | #`))),this.uniformCount=n.size,this.varyingCount=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(t).setExtensions(s).setUniforms(n).setDefines(r)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(i,t=vn){this.fullscreenMaterial.depthBuffer=i,this.fullscreenMaterial.depthPacking=t;for(let e of this.effects)e.setDepthTexture(i,t)}render(i,t,e,r,n){for(let s of this.effects)s.update(i,t,r);if(!this.skipRendering||this.renderToScreen){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,s.time+=r,i.setRenderTarget(this.renderToScreen?null:e),i.render(this.scene,this.camera)}}setSize(i,t){this.fullscreenMaterial.setSize(i,t);for(let e of this.effects)e.setSize(i,t)}initialize(i,t,e){this.renderer=i;for(let r of this.effects)r.initialize(i,t,e),r.addEventListener("change",n=>this.handleEvent(n));this.updateMaterial(),this.verifyResources(),e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let i of this.effects)i.dispose()}handleEvent(i){switch(i.type){case"change":this.recompile();break}}},EY=[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])],fO=class extends Zr{constructor({resolutionScale:i=.5,width:t=wi.AUTO_SIZE,height:e=wi.AUTO_SIZE,kernelSize:r=s1.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let n=this.resolution=new wi(this,t,e,i);n.addEventListener("change",s=>this.setSize(n.baseWidth,n.baseHeight)),this.blurMaterial=new sO,this.ditheredBlurMaterial=new sO,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(i){this.resolution.preferredWidth=i}get height(){return this.resolution.height}set height(i){this.resolution.preferredHeight=i}get scale(){return this.blurMaterial.scale}set scale(i){this.blurMaterial.scale=i}getScale(){return this.blurMaterial.scale}setScale(i){this.blurMaterial.scale=i}getKernelSize(){return this.kernelSize}setKernelSize(i){this.kernelSize=i}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}render(i,t,e,r,n){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,u=EY[this.kernelSize],c=this.blurMaterial,h=t,d,f;for(this.fullscreenMaterial=c,d=0,f=u.length-1;d<f;++d){let p=(d&1)===0?a:l;c.kernel=u[d],c.inputBuffer=h.texture,i.setRenderTarget(p),i.render(s,o),h=p}this.dithering&&(c=this.ditheredBlurMaterial,this.fullscreenMaterial=c),c.kernel=u[d],c.inputBuffer=h.texture,i.setRenderTarget(this.renderToScreen?null:e),i.render(s,o)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t);let r=e.width,n=e.height;this.renderTargetA.setSize(r,n),this.renderTargetB.setSize(r,n),this.blurMaterial.setSize(r,n),this.ditheredBlurMaterial.setSize(r,n)}initialize(i,t,e){e!==void 0&&(this.renderTargetA.texture.type=e,this.renderTargetB.texture.type=e,e!==lr?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):i.outputEncoding===et&&(this.renderTargetA.texture.encoding=et,this.renderTargetB.texture.encoding=et))}static get AUTO_SIZE(){return wi.AUTO_SIZE}};var MY=class extends Zr{constructor({width:i=wi.AUTO_SIZE,height:t=wi.AUTO_SIZE,renderTarget:e,luminanceRange:r,colorOutput:n}={}){super("LuminancePass"),this.fullscreenMaterial=new Q9(n,r),this.needsSwap=!1,this.renderTarget=e,this.renderTarget===void 0&&(this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1);let s=this.resolution=new wi(this,i,t);s.addEventListener("change",o=>this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(i,t,e,r,n){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,i.setRenderTarget(this.renderToScreen?null:this.renderTarget),i.render(this.scene,this.camera)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height)}initialize(i,t,e){e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},pO=class extends Zr{constructor(i,t){super("MaskPass",i,t),this.needsSwap=!1,this.clearPass=new n1(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(i){this.inverse=i}get clear(){return this.clearPass.enabled}set clear(i){this.clearPass.enabled=i}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(i){this.inverted=i}render(i,t,e,r,n){let s=i.getContext(),o=i.state.buffers,a=this.scene,l=this.camera,u=this.clearPass,c=this.inverted?0:1,h=1-c;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,c,4294967295),o.stencil.setClear(h),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?u.render(i,null):(u.render(i,t),u.render(i,e))),this.renderToScreen?(i.setRenderTarget(null),i.render(a,l)):(i.setRenderTarget(t),i.render(a,l),i.setRenderTarget(e),i.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 ss=class extends Zr{constructor(i,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=i,this.inputBufferUniform=null,this.setInput(t)}setInput(i){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let t=this.fullscreenMaterial.uniforms;t!==void 0&&t[i]!==void 0&&(this.inputBufferUniform=t[i])}}render(i,t,e,r,n){this.inputBufferUniform!==null&&t!==null&&(this.inputBufferUniform.value=t.texture),i.setRenderTarget(this.renderToScreen?null:e),i.render(this.scene,this.camera)}initialize(i,t,e){e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},$A=1/1e3,TY=1e3,mO=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(i){return this.fixedDeltaEnabled=i,this}isAutoResetEnabled(i){return this.autoReset}setAutoResetEnabled(i){return typeof document<"u"&&document.hidden!==void 0&&(i?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=i),this}getDelta(){return this.delta*$A}getFixedDelta(){return this.fixedDelta*$A}setFixedDelta(i){return this.fixedDelta=i*TY,this}getElapsed(){return this.elapsed*$A}getTimescale(){return this.timescale}setTimescale(i){return this.timescale=i,this}update(i){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=i!==void 0?i: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(i){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}};var s1={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var CY=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
5635 | uniform mediump sampler2D map;
|
5636 | #else
|
5637 | uniform lowp sampler2D map;
|
5638 | #endif
|
5639 | 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);}`,gO=class extends xo{constructor({blendFunction:i=pt.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:e=.025,resolutionScale:r=.5,intensity:n=1,width:s=wi.AUTO_SIZE,height:o=wi.AUTO_SIZE,kernelSize:a=s1.LARGE}={}){super("BloomEffect",CY,{blendFunction:i,uniforms:new Map([["map",new oe(null)],["intensity",new oe(n)]])}),this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,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 MY({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=e,this.blurPass=new fO({resolutionScale:r,width:s,height:o,kernelSize:a});let l=this.blurPass.getResolution();l.addEventListener("change",u=>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(i){this.resolution.preferredWidth=i}get height(){return this.resolution.height}set height(i){this.resolution.preferredHeight=i}get dithering(){return this.blurPass.dithering}set dithering(i){this.blurPass.dithering=i}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(i){this.blurPass.kernelSize=i}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(i){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(i){this.uniforms.get("intensity").value=i}getIntensity(){return this.intensity}setIntensity(i){this.intensity=i}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}update(i,t,e){let r=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(i,t,r),this.blurPass.render(i,r,r)):this.blurPass.render(i,t,r)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height),this.luminancePass.resolution.copy(e)}initialize(i,t,e){this.blurPass.initialize(i,t,e),e!==void 0&&(this.renderTarget.texture.type=e,i.outputEncoding===et&&(this.renderTarget.texture.encoding=et))}};var PY="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);}",yO=class extends xo{constructor({blendFunction:i=pt.NORMAL,brightness:t=0,contrast:e=0}={}){super("BrightnessContrastEffect",PY,{blendFunction:i,uniforms:new Map([["brightness",new oe(t)],["contrast",new oe(e)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(i){this.uniforms.get("brightness").value=i}getBrightness(i){return this.brightness}setBrightness(i){this.brightness=i}get contrast(){return this.uniforms.get("contrast").value}set contrast(i){this.uniforms.get("contrast").value=i}getContrast(i){return this.contrast}setContrast(i){this.contrast=i}},DY="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",vO=class extends xo{constructor(i=pt.NORMAL){super("ColorAverageEffect",DY,{blendFunction:i})}};var IY="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));}",OY="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;}",xO=class extends xo{constructor({blendFunction:i=pt.NORMAL,offset:t=new N(.001,5e-4)}={}){super("ChromaticAberrationEffect",IY,{vertexShader:OY,blendFunction:i,attributes:vo.CONVOLUTION,uniforms:new Map([["offset",new oe(t)]])})}get offset(){return this.uniforms.get("offset").value}set offset(i){this.uniforms.get("offset").value=i}getOffset(){return this.offset}setOffset(i){this.offset=i}};var RY=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
5640 | uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
|
5641 | #else
|
5642 | uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
|
5643 | #endif
|
5644 | 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;}`,bO=class extends xo{constructor(i,{blendFunction:t=pt.NORMAL,worldFocusDistance:e,worldFocusRange:r,focusDistance:n=0,focalLength:s=.1,focusRange:o=s,bokehScale:a=1,width:l=wi.AUTO_SIZE,height:u=wi.AUTO_SIZE}={}){super("DepthOfFieldEffect",RY,{blendFunction:t,attributes:vo.DEPTH,uniforms:new Map([["nearColorBuffer",new oe(null)],["farColorBuffer",new oe(null)],["nearCoCBuffer",new oe(null)],["scale",new oe(1)]])}),this.camera=i,this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,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 ss(new F9(i));let c=this.cocMaterial;c.focusDistance=n,c.focusRange=o,e!==void 0&&(c.worldFocusDistance=e),r!==void 0&&(c.worldFocusRange=r),this.blurPass=new fO({kernelSize:s1.MEDIUM,width:l,height:u});let h=this.blurPass.getResolution();h.addEventListener("change",f=>this.setSize(h.getBaseWidth(),h.getBaseHeight())),this.maskPass=new ss(new Z9(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=hO.MULTIPLY,d.colorChannel=uO.GREEN,this.bokehNearBasePass=new ss(new h0(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new ss(new h0(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new ss(new h0(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new ss(new h0(!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(i){let t=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let e of t)e.fullscreenMaterial.setScale(i);this.maskPass.fullscreenMaterial.setStrength(i),this.uniforms.get("scale").value=i}getBokehScale(){return this.bokehScale}setBokehScale(i){this.bokehScale=i}getTarget(){return this.target}setTarget(i){this.target=i}calculateFocusDistance(i){let t=this.camera,e=t.position.distanceTo(i);return t1(-e,t.near,t.far)}setDepthTexture(i,t=vn){this.circleOfConfusionMaterial.depthBuffer=i,this.circleOfConfusionMaterial.depthPacking=t}update(i,t,e){let r=this.renderTarget,n=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(i,null,n),this.blurPass.render(i,n,s),this.maskPass.render(i,t,o),this.bokehFarBasePass.render(i,o,r),this.bokehFarFillPass.render(i,r,this.renderTargetFar),this.bokehNearBasePass.render(i,t,r),this.bokehNearFillPass.render(i,r,this.renderTargetNear)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t);let r=e.width,n=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(i,t)),s=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],s.forEach(a=>a.setSize(r,n)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.fullscreenMaterial.setSize(r,n))}initialize(i,t,e){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(n=>n.initialize(i,t,e)),this.blurPass.initialize(i,t,lr),e!==void 0&&(this.renderTarget.texture.type=e,this.renderTargetNear.texture.type=e,this.renderTargetFar.texture.type=e,this.renderTargetMasked.texture.type=e,i.outputEncoding===et&&(this.renderTarget.texture.encoding=et,this.renderTargetNear.texture.encoding=et,this.renderTargetFar.texture.encoding=et,this.renderTargetMasked.texture.encoding=et))}};var FTe=new _,kTe=new ie;var LY="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);}",wO=class extends xo{constructor({blendFunction:i=pt.NORMAL,hue:t=0,saturation:e=0}={}){super("HueSaturationEffect",LY,{blendFunction:i,uniforms:new Map([["hue",new oe(new _)],["saturation",new oe(e)]])}),this.hue=t}get saturation(){return this.uniforms.get("saturation").value}set saturation(i){this.uniforms.get("saturation").value=i}getSaturation(){return this.saturation}setSaturation(i){this.saturation=i}get hue(){let i=this.uniforms.get("hue").value;return Math.acos((i.x*3-1)/2)}set hue(i){let t=Math.sin(i),e=Math.cos(i);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(i){this.hue=i}};var UTe=new Re;var NY=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));
|
5645 | #ifdef PREMULTIPLY
|
5646 | outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
|
5647 | #else
|
5648 | outputColor=vec4(noise,inputColor.a);
|
5649 | #endif
|
5650 | }`,SO=class extends xo{constructor({blendFunction:i=pt.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",NY,{blendFunction:i}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(i){this.premultiply!==i&&(i?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(i){this.premultiply=i}};var BY="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));}}",AO=class extends xo{constructor(i=30){super("PixelationEffect",BY,{uniforms:new Map([["active",new oe(!1)],["d",new oe(new N)]])}),this.resolution=new N,this.d=0,this.granularity=i}get granularity(){return this.d}set granularity(i){let t=Math.floor(i);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(i){this.granularity=i}setSize(i,t){this.resolution.set(i,t),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};var jTe=Math.PI*.5,WTe=new _,qTe=new _;var lO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",cO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8AcC2AhRIoDXbsYb48dl5WkVFTE3LGDcC9m4CZCWBuFFgeAZaGAYJQQCRqDHT+McJrVb8zwATUXH02MHYfMHEIGFsAxgjApQqACYQORjtd/B7Axt/z79sC0+cMPgjjlwPwVwHcA+DfAHzTxcVgWBroqMN8+cYBeM71wH0TwKExYHYUWCIAHYRLTlkCYgcIBcAgU/n3qy8GRu4HRgnAOWBkERhddPAJhGJDBxkvw7cqimr+zFM/ZLnZF64cgL8BYD+AWwB8x/dlWuWagHiYL984AJ/0RWBy1AE4AizyM1yxYAcTigW55xMbAkxEiwEdkJ/ZCQxPAiOHgBECcKEC4TBZcKkSv+mTieNcNPNC26mLNsj45QD8LQDTAO4GcJt/7iw2bfoG4WG+vAGwm9ExiEg69zpg/wgwPQLMjgALzn4E4aIzoJjQ9g4024uygkj+pyuAoX0VAIfngOH5NgCHMhAm8Sv2y3XDZeBhNIp8OzJE8OsBzAKYBHAXgDt8/4O+MVT0j4f58o0D8Pxrgf3DwMwIMEPQEYRkNwfgsuuDZLskip0No0gWMD/9HGDoADAkAC4Aw/wsAgZAgs2Z0ABI0GU6IVmKv+f28KDnHxkA/G0A8y6G73N9kOCjXnh/Ebb6OvgwX75xAF5wLTA1VIHPADgMLDj4yIA5AAm6aCUnv4oz46eeDwxNAUMzwJAz4BABSNDFTwSfg7DDKHE23MG5PqIY8A1u/dINs9dBdy8AgnGPM2NfUBrsnw7z5RsH4IXXAAcJviFgluAbygBINnSLWOAjGxJ4pgOKDV0v/OSLKp8iGXBovhLBBOCQM2ACoTOhnYrAdItYbCij5JFzRyIAqRccAnDAQUjg6UNQ7hsMXP0cRQAexss3DsCLCECCLwCQzMcPwUi2MwAScAKbfnY/YRLFQ8DHX+IAJAMSfDkAF13kLvleIjhjQQHxUVS3jjgGpKeeNzYVQEjgUS8k+PghONdhIwAP4+XXBYCHKIJbwJyDTgaIAdCBJx3Q2M8tYAHP9m4df/ylQOsQ0JqtRLCx30K1wtLBggScQOgsKBGcWHAJeOwRC0BSM1mQIKRbhh+Bj98JQP6t4U0APEyXXxcAEnxkQAFwoVUxID9kvQg+c1C7vidRbIDkc24B//hTQGumDcCWA5DgMxASdNIFBUI5pCML8v8API5zfEQx4BudgqiczviSnJhQwCP4BMCGl+wO8+U7AJi/W4O4YS6+pmK/2ciADsAOBhTIIiAJnPB7AvNjP+0AnANaYkAHX2JBAc+tYaJXOqBZv24Vc386XW5dtkHGW+4HFAJonpOe+YYQZAShgKjv3PNvPQaxVoI8zJdfFwASfPzMUwS3Kt1v0UFIlos6oDFdAGFcliMAP/ryAEAGNwQRnDOgLbdlIEwrIs6AZ/QgkMMHQF6ZAKQcJAsSYPwIeAIk9wJgoPK1gi7+PwF4GC/fOAAvIQPSs0URTPBJ/Pp3GSEGRHfBCIQ0xowBtUbcAj7ys5X4Jfu1HIAGQrIgQRXEsAFQIORDFhiDY/rMHmrU4QUgR08AkgUjCAW6CD6CkwBsAIQC4GG6fPMA3OXiNzCg2I9gNCMksmAAoemDzoimFwL48M85AKkiuQVMAAp8CYRRDAt8GQiJ67N6GJODAXAHlsGguscA2AJg1IPGYmxOpBxFWkRN9LsATgIwXnNs/v/5z/9XCf8BO3YAtxbc/46/KDt+5+ea1Yku2VUxHz/z0v24FwMGK1gWsK2OUUxHHdCBeRUB6OxHABr4ZICIBd0QWSF+XRdMTAjgCdTrG9cBNwE4F8CpDkICyYLGsuhFt6zs+gISwUen8zEAjgMw4cfx2H6O/90yAFo84Cbg4ID3/9TfLTt+5+ebnRABkODjx0SwPi5ec/FrYpmqSAxM8Dn60CsqAFI6GfhqAMiDE/gokmvEr0C4PgDkBQm40wE8zMFEUDKEVoxIMLl/KS73mE7H9d+vcKHQQcjwW0Yu9nP8m8sAmOIBuWY6wP2/4s0ezjjg8TuvaR6ABJ70vxUApGrm7EbGE+i472BAB+WHfqHS/eoAaEwY2E9+wLSXTqhI7CXgnB6LCoOJ4BiST+hTnG0HcCwAglCx3ARoZEVFXnBPp/O/A/hXACc7CPs9/i1lAOyIB+RDX+P9/+pbQjjjAMfv/PL6AFDs1wFAgs/9fgKfgdE/ZEpuiQlbwAde6QAMBgiRmsSwA9BY0JfjovGRDBMH4TlcXGhcBOc6HkF0gjPhZgchxTLZMAci/04W/B6Ab3t09EPXcPyflgFwRTwgJ2MN9/8bf5qFM67x+B/aW4XQz42FeL0YrRyikztUFw0704mf9kXgxhOAqc3AAsPyRxxQCs/PdXOFY0W1KHy3QIUGtx+6vdnx1vsB+dsTncm2AogglFgVEAlUWrOMB2RyEmMCGQ/Y7/HvKns6tfGAnJQ+r/9b76oJZ1zD8WdyQjYBh8aBhVEHjELouQ8ukQ7VRSCJAALwkr+sALhnGzDD3JAJYJHg9uhoi4bx8ytkWUtvHT/7+Zc4dw1uZ3612fH2dkQf7yxIEEockwkJQn4IQoq8unhAhmPRKKFx0uv4K8ueTs94wD7u//VX9ghn7OP4c+4G7h8HpseB+dF2AKlFLwuAIZ8jD6NPrOhAffmfA9/ZBuzZCkyRWSeqBCWyoYGQ5yQrBpDbum/ME1HoPo0XEkSD2zlfbna8q6+EUJcTCxKEtHL5EQjP6BEPyIgYAZBvYt3xHyx7OqvGA65y/7/9wVXCGVc5/sl7qxD66dEqiYgRzAqhN1A4CBNAAlDyAFI+iZ9/N3DLJuC+jcDUBmCWyUnOrmTYCMIOkNclLg0B8/RsNLg9+UvNjnd1APLmmQpFHyEBROuWACQT8nN+H/GAvY7/VNnT6SsesMf13/CpahGnZzhjj+PPmwX2MYdDIfQexWyBAwEUOQDrRDN/98p3A7dvAO6fAA5sqHJDBEAyoUVGkwEd6HR12XU4kwzfl6fCXTZzjy57vvnR513X7Hj7AyDvggAUi9EyFgiZqNxPQF6345nOWbD1HQ/Y5fpvuLa/2+82/vNHgAPDFQDnhoF5j2C2qBWCI8bw1eRw5CL5l94L3DEOTI4DB8Y9OWmsEu/zBJ3rgsaybqBob/7A4C7jtWcooRrczr+u2fH2D0AOQgAUCxKEP7aGgLy64+m6KdjWFA9Yc/03/Osa4glrjr+AupqHz1sEs0cxG0BC9HIePLoit9eNkVf9L+DuUWByDJgaq4ybGYLPAWgiXmLedUE7dwC7saL7CqfPKXi4NYdaykCD410bAHlDEsNiwZ9wAPYbkJcfz6T2gm3N8YDZ9d/wHxUA+739fPwXPrSKYGb+BuP3jAFDElFH9HIWwbzCIGkBr/or4J4RYO8oMOW6ZVcAuvi1Cgoha04BCwT5gfMKHm7NoRde2+x41w5A3hQZkADk5+cGiAeMx3+/7AENFA8Yrv/G71cAXFM4Yzj+otOAaQLQA0gZxaIIZtMDFTigKJV8H9Iq6aZ59ZXAvSPAvpEKgBTtBODcSCWCZeRYtpzrmLyeGNCAyFl1v+Hei8qeb370Rdc2O97BAMi7EgB/2QG41nhAHU9LuWAbOB7Qr//GPRUA13r7Gv9FZwIMoVcEswEwfDoimEP0shKKtIphaZQAXv1+YM+wA3DEdcvRKkGJADQQEsQuhi1Tjt95vBsh5nx2IO59SsHDrTmUOStNjndwAAqEry0IyCMICkOyiuIBNwBvPFQQT7gBuPjc9oRYAIHyOEL4vIFEYVNaOou5vCGE/tV/A0wOVcnpzI47NOri3QFIBpSeaSDUdYLOSWvYImSGgftpJDa4MWJbAGxivGUA5MAOc0Be6eVLj7/4Mk+hzCOYPYpZDBiNkLh+G/M3yFyv/ltgL3W3YQfgcFUhgRY2PwY+Z7/EhAR1SFyXCOb57r28QfQBsJQBMn5D4y0HYLPje9Cd7RIC0PM3EiMofF4gVCBp1P840ix/gyz56r+vAMjk9Gl375iB4+CzveuZdLkkEPJ8ZEfX/6R73vOjzT5Si9hucLxHAVg4PwJgRwh9CKOXK8YA4ZEqKZXSQWh5P+5AftXfA/uGKvYjCKn72cctbFrZNECka5L5CPwIPtMH3TVz17MLB5gdLgA2Nd6jACycHwLQxFEUSR5ASvARDB0h9AQb9bXIgCGk6lUfAPYTgEPAITKgg1BObk58srTJgG58WMkWMaAbQQT1nc8rHGANAJsc71EAFs4PAagQestgC1lsBJ4BMCSOK6dDUcwqqaFiQr/0QeAAAdjy+jBiQQeeMSBZT3nCPUDIa9z+/MIB1gCwyfEeBWDh/BCAeQSzgkjFfGLBBD5nxQ4DxN0wv3hVxX5TBGDwL5obxvVA5YqYL5BeMLd66YYxJpRB0gK+96LCAdYAsMnxHgVg4fwIgMrhUPKQ2C+Bz0PmBTqBMQehAbDlIjj4F80KJguSVZ0FuXpjoCOgXawLjALhbT9eOMAuAGxqvEcBWDg/l1IE05Ed0ygZnyHdz0VwCqEPIfNyx0QQvvLDFQCp+8nfZk5und8tXwIgWcHSNX0N2CJmnAl3v6RwgNnhl17T7HiPArBwfghAS7mV/hey2JS9FvM3BLpUUi1YwDRMXvkRYJoAlAh2l0dcZ04s6JUTDIjyBcrl4yDc/dLCAdYAsMnxHgVg4fxwKVwJgGEJNmWtxpQMpX9on2eRhVA+O56AjMfnP+e3Xvf3NwG4xIPTleiY55bpGh6UbafNU0l0z0p+5Jh5HqYJ6b51nP6XP8cx12XNHQVgIQB/bFPVg2OC7Q+WgVFWng/FvtWLI06uWh5oguKEcXVS/9sEAF//VGD7t4ETDgJbF4CNi8CGZWBs2fPL/H6Vwp2KEtVk4fJ+v/EIYPN9wKa5qu+IncfPwXHVZe/aOL3EbwS7xv8A1rQvnO0j8PArTgTGZ4BxFv9mIxhOCGsv+0OPYDRghcLfkWkEuq0+G00x4OtfDGz+d2DbHmDLjL8si8AYP/7CGIAiEEMTG92zXqSbH+d9R2aA0XnvO+JjthiIrOVDHHPOkBrzUQAWAPsZp3oPDpa/Xag6EVkLBK+5rAnJC3/nYk/APD704WiEAV8OTHwX2LQH2DgFbJgFNrBhjd8r79deGoEwsllgNBOzy8CdjweG9wBj08AIAci2D6HafmyAk4/Z7SJ72hGYRwFYAMDLTwOGp4FRFgD3HhzqRGQiyeurqOdG6r0Rm8IEZjzRlkiqCWoEgK8Axm4BJu4HJhyAbFhDxmbDGnZO4j0SgLGDkpibgEq66TJw/1nA0F5gdLpq+zDqFfd5LMeWqu5HNST0uJOIllg+qgMWgI+HPv0xwLA3gWHpW2sC441gCECbmKziaGrnUdMO4aHeh6MxAP4SMHI7ML4HGD8AjHvHJGNAgpDgY/ck3stipRemvVhc+uASMPUEYGh/9dIRgGx8Y+MNbR/00uVtH0wEx94j/v0oAxaA8Ed+GBieAYZZg5kADC0QWGOFzGJlcGPzl1BxNLXD8sk4xftwNAbA/wwM3wGMUmxOOQBnHXzetIYvibonmSiuYTNjriVg7glAiwBk0fNZH6+PmX9P6kfNmCXGpftJ7TgKwBIAnln14BAAYxMYm5C6RjCyCoOyr0qkD/c+HI0B8DXA8N3AyCQwesD1VQKH7EcASm1Q+y4CkN9pUKiVF5nLvy+fBbTUd8QBaH1HvNBROiZvfsNnrF4kcvPwpdsBLBeU18Nf7AB23Dp4ecHC8oBgUlJJecLS+7+WOpE3gbE+HKw+yoevCYkMGKqPJrdEKARutaFYRs1fiEZ0wP8CDN8LDO8FRqYq3W10pgKgfYLaYCzootgA6KXaTA90y374TKB1sBozy77xHFZ536utRgAmEaw6g5kUSFZwSXnA330qsOlfgHMPDlZesLA8IOjoLypPWHj/11EnCiVwkz7kAExtsGraYUWdSDX5TmsagL8KDBGA7Bd30JsW0oWivnEOQNP7yGTSBR101AlZSUtGyfgZDkCWY1HnJdcBVe6325hTvelg2CQjZNDygG/2An0j1wKnL6y9vGBheUC8prQ8YeH9X39OVQSc7Mc6fCaKvAeHdCIVf4yMYCynTpX+nb97NJmlSQb8r8DQHm9YOFUZTKOzoXGhs6AxF0HIexcLBvWBuiHN8s2ne98R3qc6L4Vyb2oBVjfm9MIFHbjDCh6kPOBbQoG+oW8CO5bWVl6wsDwgfr20PGHh/X/1iaEIuDcCTIW/1Q4rFv8OnYiW3c+W2iKwUjKbyjQNwL1uuR6sAEgDgq1brXOmV81PxhNB6DUDBSYzQJwFtz623XcktX1Q1VWKaTF/zZhVazBVYA1tX5MazsGvobwe/jQr0Ne6BTh5uf/ygoXlAfG60vKEhff/rSe1i4DnTWDUACY1guFTDqLYdCBvf6DJYSMYATBfOx1kLfj1v1axH10nQ3Sd0GUkBnTfpemtBJgseIKQAHLQcVxa2TnuMW0Aqui5es8xBIegVdVVE8VhzHnLh65WMB9An+X18K6aAn2tO4ETl6vqbKuVFywsDwhevqg8YeH93/Rk70JE90nowxZbIJjvS3WYNSGUwGHJTpPxwwcbBuBrgRYBeKACn7VtpdUu/c0NJxO9BIxcKu4TTODzbkonPLoaL0vyUQRb2y8HsL1ckfWzMeuFi40Qezqi+yiPhyt7FOjr6/gCFwgP7Xb5vssTFt7/nQRg6MGRWmDRoeyTlpgw68GRTwgZgo1gGmXAX6/8dtaylSKY/koyID9BhzML3q1gAos2AcOrZYSoq/pJp1VtODRm9Z3LS/7WjVkvXOzEtOpKyGrlAT+4SoG+VY8vBGCvy/dVnrDw/vee65NBJiAjBIVcAJQjOm+DkCZEeiGAMw6sAwDZsJrAdhFM9rPGhd4904Co5oVuCZPV6kD40Ec6+9W8dBTBsfdc3nkpvnB82fp2RPcs79dHgb51LA9ofsDV6vut5/3PnxcAmLVBiDqgevDaJLkYrpuQxzcNwN8AWgIgRbB8loEBzXDwl4cGiDGft58SCOWGedgjvOJ+bPvgRkiuA+ZjzhnQQOiFNVbloa7l/fos0LdO5QENgEXlCfs8Qbf7HyMA3QVjYihYhLENgjX9y/qwxQmRU/asfd0ZcLU2CHVGyusJQLKfVi98CS12T5f7iECkHpsMkAhCF8+nshWH2I/jXsOYO144GV/9ApAIrS3vt4YCfetQHtAA2G+/4PW4/2PPbzMgmUMi2NoeSCRxIt2/FvuxWURIWCXg357gfTjEDNIHnTRXRCpH5ugKwGl3HpMBXQc0v6WLYVm/5limj04rG762K2uYY9jBkr9+rI03NL5ZbczS/dJ+LQyoga4o77fGAn0NlwdMAOy3vl/T938KAcj121z8Bn+Y9eWQJRz8Y6kNagDh2ey5EvxjxQD8TWdAuneCCO4An1vw5vdzQMmdktwq7pLZQR+dM34+ZumAxvY1Y04uqOAJ6FsExzeto7zfAAX6GiwPaLWR1lrfr8n7f/Rl3QGzmsis+/uO71V9OFgP2gpPhgr7TGRqRUT6dyvr4aIs/pm/2zVUNbBSv6G8e5pEv0Cvec7Po7+bTtjlBRlkvAMBkDeQyvsNWKCvofKACYBrre/X1P0/oWEAnnFD1YdjhtXxR73mX10FfCHHE9pVWcGAI/S0gKsfA2y+twrFZw6Hxf/F0Pk8Ri/kpGSnMuDx5T0iACgQHioo0NdAecBUHW6QdsV2/cL7v/Cyqr5gnc42CCOcfX1VIZ/V8We9IDmTzVXwPDJiXuKXPxtDBma8+lzP4WAgKkPxCUAPE4v5GzEuMX0PYJPLhB6FJsc7MAMmkVxaYC/K9gG+F1++8AQ7Gwbgk78I7GFpXgIwFiRXOwaJZPUbiR0yCUDRk+cHf+YpwMj9HgfI8ClGPyvsSiH0WSKRuYlitLb/zHM/JOSs5C/YIC9cMQDZr/dwxgOW9gtGYUBi0wA8l304vDQvAchilFbpIBQhZ7Ejq6ZQ0/Yhil8y4j89Axie9DAsD6FX9HOK3QtROTFkviN83kG4felIY8DCeLrSeMDSfsEovAECUFsTjHD+tcB+tkFgcXKvBRir7qtFl9owmO4Xy/1G3bAFfPrZHorFNWBFwHjQAFctIghj2kBarw06If/+MM9ZqTN6DgsDojCerjQesLRfMApvoGkAWh8Ob/tgAPSKWCp8ngNQtadjmTdltvNvn3peFYhgQQgh+iUmEaUAUoXM1yRLmWuFLaE9Z+XIAWBhPF1pPGBpv2AU3kDTALzwmqo6qtVh9kJErAudABia38TC5wJgS2xIhAwBn3yhByL4EhzXfRXxYsDTJ4IvrNN2JFMxZcBzVo4cABbG05XGA5b2C0bhDTQNQLZBYH1AVsQSAAU+imI1obHyblnjG/kJk3U8BHz8xVUQAhnQIl5CyNgKAGp5LKSSCoAySh5Jj79vTagcxUaIBeRNe79g9gq+DXig4wGzy+PONfT7RWFA4noAkGXZVAhcBckJQgNgrLiaNb3paIDo1vHHX+oA9LQBi4DxJcOUPJUnTgU2NJUyROs8irGARxQAC+PpCtsFd40H/AEf0gMQkLgeACT41PiGoLOKqyrJq3K/Ya9mNyr5FusN/uPLPIeDa8Bc+w3rtyl4VFHaMZc3i9RWBM9jjzgAFsbTFbYLRmm/YBTeQNMAtD4cBKDXBTQGdAB2MGBo8SCLmEuS1AFVAJ3A/NhPt0PoCcA8bSDG76XI7aySg6JYuGfKwJHFgH0E5B3ueMCe/Y4L+xVHAOZ+9EHcEgQgwbeiEYx6jwTdz4qfu7EhEJqxGqruf/RnHIAEnxgwBM0aC8aUAYWNBRCmoIll4HTqO122QcZbrgMWxtMVtgvuOx6wa7/jwhtoGoDWh4MBJ16WN4lfr8AqI0TVV1O1fa9BbQzovkAy4Ed+NgCQUSxZCFWvCOaOFREXyUwZOPIA2GdA3uGOB6wPaOz+QPv5S+MA3OXiN9aclghW+d3IgupBF2pPqxcxGenDPxfSRh2ASiKKiVP2PaZScvAKoA0VDc6cOlIB2GdA3uGOB1zR77iwX/F6AFB9ONSOQW0frA50sILVcckWJyIDSgwPAVcJgFbYuZ3FJvAlEHbJ3IsgJLGedeBIA+AAAXmHOx6wo99xYb/i9QKg2iAIfDJEJHqj4SExbEty0gkdhB/6P9oZbBZIGiKYVb9GKaN50lRHBLOvhDxh/5EKwDUG5B3ueMB2QGM/grb7/6wHAPNGMAY+GSGUjC52VX2f2CD4+HO0gqkZfegXKgBaHkcWtS0AWii9xG1ImrLlN5XR8L8fmQD05BVrmEENmpYSP9QX+KHiqj2/82+HqqDWwnbBRfGATdzAegGwru2DpRq7Mzq2fpAf0Nq0Rl2wBXzglZ4yUAPAmDSVWDBPHQjLcgTqOZ6zUvdKHh4ruDCerox/Dnu7YqwXAC1NI/QcEQuK6WK/kdgCTGC0PYAP/KIDMBgglq+hIkrOfsaCviLSofcJgJ5AdM7kkSaCj/HqQKVIGvD4swF8bcBjmzjsaQ2H5D/6acBd9wALB4DFWWB5AVherMp4GKIYEOp7+26UF0aSfT/xYuDG7wDjrIpAERytXf2vajj7ueryQXSFl10K/ON3gIWDwCLvjfGB8Z54O+Ee4ve6513uB2R1yzsqC+twbC8HcNVhfAeaBuDP/TvwtS3A/ePAIfYFVlPq2HHTuyulZCTlhbjhETF5yxTQGgPGhoHhIWC4VSXGD3n0tLkMHXHxu+YyB+MlPwDuZs5K6FlsbCzdVO9DuKfkHM8AEkP7B8fOkwDcD+B7np42+JkGOvKdAL4E4K8P0zvQdET0b14D3DgB3D0B7B8HZka9WzrD88N6sFm+YcUjrn7E1ZDvMtF9DBgeAYaHgSGB0PNHCD4BLwLRsByAyX/ij0/dDUxuqlIG5hix7eFhvLcOVUAtyPSydAFmOQNe6EYGV/9ZESiKgIEgtbaD/gHALQC4ovY5r5KwtjOU/XfTAHzzLuCmIeDuMWDvKHBwpMoN0WQzNtAaYSs0K4ZlOSAjGG9kPjCBRwZ0ABKEBJexYAZEAU3A7Oi1BeDym4EDnjQ1TwCGWMW8MXcKks0YOyZNlQOQjcgYIUHllEzYQ0ktm+r6oz8G4F4AXwXwRd8/kO9A0wB8y65KmPxgGJgcqYJTKYpTv2CCzyddQJRDOjKivn+Deh8BF8BnwBtaCUA+YYEyAU8h+c6Az9gNHHRmrgOgmDA3jHQ+iWupCeUAvNSrA9HNwqx+muk9nJVNg/CTfrmbAPwbgK8D+PcHkIibjob5o13A3XypWsAkG1cPA9PDFQDZM1id0i1KxsWfOrKnAFXlifCFFMMRcASigOcs2MGAIfE9iWXplS6On7UbmPaUUTXQrgsVMzcRj5Folg2V5ayUA5BWYKwOxKUafnosWjcJwk+7W5F2EKvlE3xcXaNYfiCYsGkA/smuqug6hcleAnAImPbO6YwRpMgjCAVAm/yQmKTv5hNsAf/i7SyNBSl2a8Qv/4/M1yF+BZSYlNQCnnVrpbC+mToAACAASURBVJcaI7sOSEY2NpaDXLqpR+vE/OVksDgImgGgghHoYJbTWc7oJtFWc65/cg2AYvh2ALsB3AzgVv95nS/f4QdsIkT9T3cBrGtITWZfC5hqtQHInsEGQn3UDDvEDEY/ICf7SxMOrAg8T+c00JGkvHGd2DABUYZIAONzCUDppCFhSukCBsLQrFtZe/IixYQpSyEoJoqnuPWrVRAubQh83HNlZB23z7j1ywmj6CIIqUPxw2Xeu9bx2jx10wz4Z7sqTYZaDD8EIDuoE3hMVEphWg66JIp90k0sBxBcy+iPIIaT1RtEsHS/yIAqw+VSNPWQfe5tlVEk8auXgVa5BUsEJuT5uoliAbE5AGotmIAjCPnR9xDG3TQernYAUupTdBGEFMf83OkApHG+XlvTAPwfuyrgSZOhas3u6cwTsUBVn2gTwyFMi8wjHZAA1M9fYGHDULJD1m8Cpa8fRxDad+l+Ykf/3XNvd11U+qiL39SxXevSsshdDFvgbI1O2AwAtRZMZzTBRuDFjxe1Xg8QEIB8yyj5yYIUxfQIkfkIRnmHCM712JoG4FsdgHHp3ACoMH2G6jM4lWzoQarSvwQ6MSB/vporVaFkh+mCLlpVR8Z+dqDZLoDOpHSiQeAFDkBjPrlgCHgCUaFifg67H/9uYjn4Ai1vpTERTAASBaoQJBAKeNqHlL6mwPDZYAOROag/EYRkPX34MwHIvzW9rQcA+TLpI22G7EcQKlJGsYIJhC6ClUMiXfBTbFUQAej6nPS/OuAl9pOOqIc2BLzg++3VmWgIEUz82cRuCAtLIHQQm0gO52uOAb22sC3JEWgRfPpZf2sQBQIgLydPEIFGwPEj8MlF2bSbsulghLftqsCXq9HGgHysznrGgi5qzTUTFH8FLhAUn3hIJwCN0HLncw37qaF2zoYvuKNivmQIuUNc7GvWt6sHNs26twA6vhyq8NEMAHlyntFrDCcQehyaPTl+FwAbXDcmAKMRThakEk8Q8kPg8SPL0qzLBl+A9QCgR6uZGs3vfHz8TtBZvkgGQrEPBVAUg2Sij50QAOjiVKI3saADJRm7dSLYWfSFDkCem/dhZeMy9pPY5QvSDYQyUJoDIK8qMezh3wY6fSL49PcGgCAA8pScJLIgAUYQEmz8RPA17StvGoBv39W24eREiBoNQSgWNI1HBkdgxJSw1AI+dFIbgOYmkjimQ1r6XXC3rAbCHycAgytohf8vsB/r2KRaRq7zpZ+D37HMX0s3DDcCUGLYaw53MJ4YUODzusqlGCQAOQCejuxA8UULUkxIwAmMAp8Wa3qkN/R9W+sBwOhIEPjk5SLr8HeKFbTQfb77csPIMHGl/4MPbReslPhNe4+MiTpi9AFGV4nI7MfvagNQLh/pfrYnDAS8aJQ42A2w4em2cAyWQUuJVQTGWLs1uL7DG9J1RjhA+jvYk4t3KXeMqijpzrud4At9z3XtP16yGfjKZmCGooYh1tZzvv8xXPFl4PoJYC97k9FlwZWD+Azi/deMZWeP13eQCGEyoERudChIjbb3mJYwH7V0QIKuCwj/gfMj0asn2I0FXRSHXfL/iRkNgLyeVj8ccMY//J1fyxzTAXT2+xoQViKYD/1hDqLxPiYxTgSvQrphphG97tz4Slqafnj7uk1kIQDZrvWTw8B3jwEW+RLxPgSiCERdPwPR7+wCPg/gulFgfruDkOMQkFc5x84e708JAMmCuRNBXi4TIg5CGRzGiBGE/D4E/C2r2vcAYJoify62i0aJSMhB+2IHoNwu0fkcjQ85pu3ack5nIBREqneYFyWLkAXIJHESe00Cyx5QyeL6F/tyEcDcrOW2n7fX8df0mME+/vQ/PQjhoy3gzo3AISYf80MQaQx1peH9wb7v2mrtmCBkIMMejp3jIJD1MsaxaMZ8v5N/67INAsB3BAYU4JL4DSo1J15AFPAEwuQHZJzkKfUAtOHLJSOQRWndBYQvCQA01cfnNopfsaCJaD2baBn79QjSTiOEP1EcawIpkq2kegBTNgHWEpOKF8Uwq2NRFPM4AqCf46/rA2U9/uVDvurB01zvAJpiiwOl3fEeciCGF+Ij11f+QkbSfMPfIzqw57mEFZ9Dl3Ps5HXWAYByHJAJKV7N+s0cCQQhwSlfm4lGZ0KB8C/rABgZUS6ZHITBSEhCowUYAAksF7cStWREyxRwtuPpOlgw+5s9sq6OaIJIIlUgEhA1edoTgHxa9HVw5jibZNF+j/9yGQA/7pbujZ4bwv2+cWB6tFo0NzYnkxFA+cvEAo43VBoEo2e+48EMXEOmD9F6xhCE8RwZEJ80VblKvDlmzwicfqy93/o+8K8TwB2jVSgW138FrJQTXBNlnJgmrjZwanow9CBP/rL9wF0jwAGWDtFyoN9PHutnIHT05mPXz93dMGQAPniJsjiBXiTbxDZFMF9NLUPQxKR5qezz1Y6/YZDH0D6GkdAkYJIvRalAdHAMmPZoYhb6NhDWvEyf/ma737CXN7R1ZC7hUbPgcFgqt/ZZjADnM1xqEVhYBpb4CUk5UsL7jQvj///5buDrLeCOEeD+YQchYwG9VIfyg1NaZszFiCH6DkRGLze5/dgk8IMWcMCjdCiCzR8od1B8OTwvJM8JEShFut1fzMhi+eRJr6LI7hYP2M/xVLwKNoZjUTwRMAQQmYyhWGQxsSADOflZ4kukj7PhZ75bETjBpkAGahMkcrGgwhsXeCyBHBj1wmOBQwvAwqKzoFeRV8ZaerjKYAuirmPY/o9X7q5Cyr7fAvYMAftCPGAEoYlBiVtFwLjtp2U4irj7yOANbi+crHyrfCbTquJV44O0F1FrwQGIMZFqdQDyP/gGSZ8TC0ZRRsOlVzzgasd/u+zpMByLehAfCgMQCDyGZJHFCCgLZ2f8mgI5qauEcVx9e5vACTgCTwEMWr5TdIpWKJb5MvrnoocDswvAPAG4VLGg6UKeqmi4iuDz4er30oX0FP7u5moMvIf7W8B+jwlUNAzFnlZCIhvGFRCeWzrgXSSIBreXTFZSgVLHAp4UHOFuociEEsn2PJwl/XEk0dzfSojeerFg1IOo5BKAveIBex1P67lgUzgWQaJwLAKRH04i14ItgDKEtGsRnWx49b2Vkk9wUefTGrKCF7R0JxZMqxN8cmPAxWcAcxGABKEAKPA5u9lEaAbCmKMI+sDN1X3z+ro24wEZFc0VEE64ABgT180PF9ZdBcDb6JpqcPtPk+1ACbmKjJnllwyuILunEAWjZHkBsrsRUnfD0qEiC5IJfyisgMhzWhcP2O14Ro4WbASgAMQJ48SJwchmBCDFa8qpyBbSP7OvU4PQ0p2W7+LSnSJUFOrI4V7w5IoBTQQTfJ6oTSYk2mQcpGRyH2syGjIF6EM3V/fM++C1CfwUExhCsmzCaQT43lZC3e1hBpEHh36XEqrB7Scmq5dV0XZxmV8WuDFzAF9iwhow9seAGoBcGtKjqAc+1l9rLb/1igesO55ysmCrC8ei6IxRMAKTWNBi6Xw98xNTFUi0jEcmpYgRAPhddpVi9OIEPP5cYD4CcLkCooHPwaW9kV+iwWrQHT8uA1fd3F7DFvgUHUP2k8jTiogAqLoxFpDgbMj9jXSuN7i9dLIdaxzBp5XVBMIMgFEnFAPKT9qPd6A9BIGI7MfPmf4U+40HzI8nWgq2PBxL4FEkjKJixGRRFyQQPzzd1iAUzCAQas1YOmAEoFjwkecDC/PAwhKw6CxIkCXwOdVJLxTobMjBdyIgfvimNvNJ7Evf4jWtdnRYD1YNGVuG93VWuWs4Jf+mlZCCZxwP/cnJ6mXVKk2+tK8lQQVHRTGc64SDAZB3Ey3JcxyACkToJx4wHl+YwqloGDICmYmTFgMQFBET8yyYzyAG/AfWX8mCGQg0BTRoHwt9KVaPE/HQ890AIfgWK+CRAaMRYnVdxHbhdY8Wslw1V93UDsmPIj9GxgiAioRRMIJNvoti+SW/Ikd0gwAU8+XxJcbGITJPDvI6XdCFREFSknTB83xka40H1PGF9dnycCxFwygkK0bASJQSVAbAYeD98xUAe5U3jKIwBosSgNsuABYogl3/IwgFPrOIg1Xc4ZrpAsSrvruykl2ucykapkMMh4CExD5DwJfWAYAxwk4MKPAJgOIjGSEGwuCakRhemw6Yv0UUwRf7L00L9pnsNx6Qx4feY4O8pDEcixOjsoTKKpMYjSFYYjOC8Eq3Wnnr0YYS+0Tmi2HysrPGLqwASNYzBnT2Mz2QD91laxLB0gs12GAh81cf/o/OcHyJ+qj0S/zxnhUZbSyYWaL8+Rq2S29wowiWkJPan4MvgrDDGAlRe7KIywDIgR3meEDWg9HbJgApNTkXo8o0i7oVgxnEgFr8F7jEdnU5GvqfJQKQKyEOPlsNIQvyvupAGHS/Okv4qv9oh+PHxMLk8ggBCRxvAmEN+AiEzz2iQfQBeNmkh4K52hJBKOaNe/FSLobLRXCz43rQnu2yi9oMSMDxs2jo8303ERz1wsCGZECF4kd3DwEYYwJjhoNlQrgIjlYodbBPrwMAZfEmyzcIv27gs6XDzC/IR1DOgA9a6DRz4wZAsZ+LYXvQYsHoD4ziOFklna6YD3+nnU6dZ7bGDAcBUImIAmEUw/zbJ1i/scGNDJiLXmle3RhQ+l/aq57gUQCWzwwBKPeLsZ/LFrGg/ShRXAe64Ajkv30kALAjF8R11Dy3K7KRwJcsUTaqWScARou3w/INVnCH+A36n8RvM3nB5XP4oD6DATBYwGb5ajlOLOh6X8JaBKRG77+7ygGYp1bn+V25/01AzBnwQ1ypanD7KWfA1QDYC3zJIj7KgOUzc9nFbetX/r+O5biwNhyX5uSEDr5o0xsJwLp8/m4A7GaJUv/j3/5+HQFYJ3oFPPkho/hNeqBcMkcB2BAA6XrxmMBkfFAci/m0JpwzXw0TXvXtzrz+PKc/Ml/ugzM9MDqCAbz/keVjjGcQA/YLvjoguo1mRslRI6RwfsiA5nqhL5D6nscF8gfTdfxpS+/hLzvWfzMQCoB1Fq/8b3VWaPIDZqsRV64DALsZHVHs1gEvsqFAeBSApQC8pHK90Oql4UEAyvCwNeGcBXNLOPMLftgZsI75ouUr9ousp2TEyIJ/sU4AzC1e+WIFshyAHPZREVwItrrD3wGAhibTYBhxVpe/xePyrNBuWaoNp3DgFwC81O+RAepK/a5Lfe51jxr7JwA83nPXYgq1asl0yX5N48+f4VEGLATlK1vAo5YB1gBSRmsM+NFE57lcfPD5pPFWCJImtyvGgGfOAacBYO59zFglgHgPefZsXV6/gPXBYeC0RVgyJNOGYuJjPka9eHWgjL9bWzhWk0/n/wPn+k8bgFNmgYcsVflZnBRmIShtJM/m7JGibGBoOIIez9wKPP4AcNpylfbNlGfdI+9NjBjz8JVzppckZuJ+dBw4aQ44drk6j1LIY9JkPD7P4s2lwVEGLHwJnncscNIh4Nh5YMsSsHm5ndOu1BGFThJ8/K6JrZtoslST2+XHA6ftB05ZAE5crgAups5TfaL6EF+UyIif3gAcOwtsXep82eIYY9JkXpMgMp/AeZQBC2b8OduBYw8C2+aALQvARgJwGZhY7swEzbNa88IRvAVO1qkF91J36DNOBE7eD2yfB45fqphLnevzdGeBKBfL8UX5/CZgyyyweRHYsFwxYHzRNK6oetSBMDLjUQAWTPqPngpsnQK2zgKbCMAlYMMSME4ALrcnR6JYQIwsoUnjpDRstOLy7cBJB4CHUGwuAtuW2nUDVH1EFUhycSwWjGD64mZg0xywcaECoI0z5P3X5P6nWlHdgHgUgAUAfOYOYMtBYNMssHEe2LgITBCADkIzSJZXpCOnIg25uPrhgnupO/TyhwLHHwSOmwW2LVSik2pCrDsQskzNIBGIpBdGI+VfNgMb5oENCxX4yPRjPj4xaJ0+WGeEHRXBDUz2Mx4FbDoIbJypADixUAFwzAFI8KUJChMV2SUaAGc1cE/xFJef3FYRti64nkqWDrqqEhbrsm5zvZCdPCd8nHzJOLZuABRz9hTHZwPL7LnLnoNMIY2VyaKcjtZLHOAbNgNPngKe4BacfGF1pnydD+hphQ/8XV5UiEueLGnDN1tWXj/3/4cTwAUzwGPcRcFJiDpPt3FLmf5vjwE2HAQ2zPrEzDv7OQg5OSM+ScYQy5Xbo8465u/ZfLTJ7fKHAdumKxVh8wKwealSE6inEoSy2MWCdbUHIghv3AqMzwHji9VLZuDzD8cXxxWZs5c7apmW0fMBnIHKn5X7d6I5npvRz94O7LgXuGIReJSb+Xl1tzqflybwRwqf9i97BQRWomWJQ7oZVFtJoqDX/b/oGODsvcBTATB9gsfGqmzdjtVz+G+PAyamgYmZCoDjFE2anCVg1CeJwOMnTRB/DmUINVkkgia3y08BtkwDW+YqAFJFMD1VAAw6XG61R31O9/fdrcDYPDDmY0zjc1UjivBuAMx1QdMB+WAYXU8dhEU16dOSkppbcHFSrng8MHwnsGMPcN5ypURHp2xMIa7zDz2z8Gn/kVe0YomO0wEwBYKujL7v/zHA6C3AxfOVh58g5AsZxx4fZM7sf3h6BcDxWWeGBZ+cMEFiwGEHHRnDzun7ONHs/djkRgBunql0VDOSHIDU3cxSD4aEajhFXS4H4S1bgVGN0V8we7E0Fh9jVDG6Obr1LJMRwn+kOCaTEYT0dsfqZHXl/p7PrLi9wIY7gO0H2yAgCAWCWCowKrYE8nMLn/a7PQn9X7zIJPPkCcK+758y7x7guNsB6l98gZjLLYet3Ay5n0sv4R+fCYxPA2MOwLEAQLIDPyP8uBg2cRYmzFweAYilKkn+OC8/Fdh0CNhEA4nGA40kd6FES13WLO8v1qHKAfh9B+DoYjU2Ak/js/8NAIwg7OUb7LCC+WAfB4CpBJoIiTRNRmS1l13kqWh3Adv2A8cdqqp1MB+aIOSxWv6pq5D2kkIAvt8rF7BLJksN/jMqfa7v+7/Ak4B3A6ceqpasKMq5akAmlLWY37t8ZW97PDB2qALg2BxgAFwANEGcnI5JcrDZRPlkaXL4u1KJUAfAjbTQ59x6dSvdLPXAgGYshZWR6JIRaXB/NwFI8C1WwLMXzMeSwLfcXuKrA2G+wrLCDcN/IIg4ERRn0qvyySAQX6mG1XuA4fuAbTOVwktRRr2MLCoQyvEZ/UY/WwjAj3jtFJZkU79g1ghkgEBf98+0Umb/3A2M3lkBl/fOcdMok2EjkZyv8773LAfgHDDKjwNwxEUw9yailpwdxBAEYhBbAuGzG3aKkQEJwAkCkOCjlb7Y6SYyf2UwlAS+vKYnAXjfNmDEX7DEfA5CjUcsnzvbu1nDtUMmCDkRZEEyGdlAk6G6lQTSa6m0MP6HuY73AxNTlcJLZ6WOJYC5/CNxLpHMgdKIKNl69Qvu6/75AjHOiTU87gKOOViJb748BKCWrnK/maTA+58AjM0Ao7PA6Lx/xBAupoYDC9okBRAmPdBZ47lNA/DhwMRsxX7mPgl+SrmK5EaRNRslXFQ9CKB9DkADn79cZtkHFkysJ103eBbqlh97DpmTQTYgk9VNxu+xYbXKU3lhFoJPOgdFGY+lPkgQxokkgF9Xgj4AvfoFs84eX4Ke9x9fIC+tRfDxvvniif358sSir2LCj5wNjBKAc8CIi2AxxLCzIAGY9L7AhGIKgpATw4l8wToB0JjPrfTkp+SLQbHrOqm5jNyajS6VCMIpApDAWwQ4LrGgXqzIfnq5cv0vN0ZXHTInME5GBNLb1DGdOYQsI7AfGKFjlgqve8wJwG4T+fuFAFytXzCLb+VgWnH/fIGYfc46Hs7iHC8ZkPcdXx4VfVXJw8+cA4wIgM6AHSLKWZCTESfLfg7WsIyRF3ckiRQ+HACXkwHptyP4KHrpJvKVGnOhRF9eBF9wE0mUEogz2wC+WGI/vVxiQQIxAs9+rmHA6E1YFYB8DJwQMZl0OrLZ++i7sfT8zroYHLS9df4RACWKxSZvLXzG/fQLZqk2gqn2/vUCUQ9UZaM9wDaPeSPrC4A5C1KV+NITKwCS/SiCR/jRBDlLmP7nHynsxno1IPwJSyRpbiMADXzuPDYfZfBTEoAmcuVQdiaW0zwXwQsCYDYmMaDA1wG8TBSvaoR0G77EcGSET6hjOvVApfRPAUN0zjr45JzVcSqiTxD+VeGzXku/4Nr7JwDJOkxFIwt6j6+RqUrlkO4bXzp1gCAAv04AzgLDDsBhKugLFUvQUhTwCEKbnKCw14HwJ9cDgGQ9WegRgDI8XEcVEDvAl7lVlglAgi+I4CR+Zf1mLGgMmDFhBGFfDCicRJFERviSABjLS7FC0MFKMU+07wOPE0kGvaoQgGvtF9z1/iODkwn3VWoEXxres5ib9xx1wZufBAwLgAQexbAD0JiQwJOuJBA68/H3Zhk6+3CifqqwWNMKN8wjKgbk6gWJgC+FMaBb5vJVmsUbV2vCqo3cRWZcCIACoax53+ulkqNd7iqOcU1WcC9cxEm5kQBUdZ+sTnSL/jEtTWngi21jhJNJBivZBukXvOL+yYBkcOqxKjJ4AGgxzMrBVwdAMmHrZOAYF2l6y/mwV6xD17zmWo6MbRyeWtOHwxJ91IIhr6rqZS70DPPLXDVUrfBwzHKr1EUp6/h0T/6L/GcCqslt4IhoTcwdAqDSs7I60WQH6R329pHuFyuXDJmEjuOSbdB+wSvuP5bGUjmsA5XoUvcvBXKKAQnApUdXwah0b8jXR2YzJTsC0ZHB33FL+2yiX3h/1YeD1fFZGT81g/H6yqkVa9YEpqMhTADle8erHA6t7Mh6j4ZBXdBGjFyO4CSIm9wGBiBvgqxwIAJQlXIyEJLyI/i0SkAG/FbhaEr6BXfcv+5dLKhCg4z1C1HEBJ8+BODQGZXfk/quAZC6ketAZEQCTWAU8PIJt0fgwHzZvVWNaKqi7JLOmtDWFy42g1FxH/XfqGkII0C+a0tnDkfsGxQjn3VPsk7tXmuy+Xp0JhtoJosAaFcUAJUYKiYJxcqHqKAH9rPlG2cMrmCUbMX9guMLpGTcCMKDlZGhMK8IPnPIn1X5PA2AwegwEEYmDGBMjOI5whGQP3NPBT7VJlRNaKvF4t2IWHbDErtDlSk1p4lJ7/zd246tglGZryIfrFhQ7pU8WCAX0ZENG+57U14Z4YrCeLrSxXdev6TfLwrbxT7znMrfKQXfHLQCnyvmRIv0Q3430ezMmL98P393G3wqz6am1NYzzoGn+svqRmTAU2citctqAX/2EI8F9ACEmLHXLZGoFxtSl2xyK2bAYwrj6Xr12+1noL/jUTCD9vvFrn6u0v1/nvGkaoVBAQi0eummMAuXQHMWJAA7gCixG8U0gFfcXdlBKk4Z6zELgAJfZEKrxpC1xOIl/+Sk7jkcdYlSco90y9+gK6vJrRiADD0piad7RuFo3udNCgft94vCdrGXn+tujgV3QAcHLcFnroelivHkchEL8ue0uQ74S3eubAITS3IQhKkMRjBMokgWG3L//2z3VSnP4VDgQWxUEEUxAZFHL0eR3HDfm3IRbDHkBfF0zy4EIKNhSvr9goGEBdvTz/MIYQLQdVsTwRTFDj5jQmdArRDYJQNDSs961R3tPhx5NXoVgoxleHnarjohgLec3D2HI492yQNvIwvqO9fJm9zKGbAwnu6FhaP5pFuMg/b7tTbpBdvTz68cz/zI8azVj8iAHTqgmFHXDUB89R2dtaC7tUGw4kDOgFb0R2wYRDGZ8g9O8aU4XwPOczhiwGlMjqqLWiFYGu570wADFsbTvaxg8nkow7E8nM/atfKzln6/1mS4YHv6BQ4+Z0BbqHcd0NwwYbVD3+1yWhXJxPBrbq8AqE/XApSqAxiBV2MZ/54DMOZwKE00rnDUWcR5KiV/brjtSAMALIyn+/mCyeehjIYp6fdrvVELth8RAClyHXxmhPi6r1m8FM0ucgk8+y4RHC1kAK/5XgW+2hZYofafWcPq1B5AqDqEYsQ3nepR2gqhV2yiol1COkD0C+aOaoGx4aL7DQCwMJ7uVwomn4fm7VrX2u/XAlELth+5sHPtN+l/Ap6sX2dCsZ/phZkIJgv9l++1wbcq+2WFv2NXIjNKAPzuw7MUAV8DTuynFIEsQy83RgTAhiv+NgBABaQOGE/3mwWTLwAqHnaQfr9GnwUbARgDNBUlkpzQboyYCyYDYdILdf0l4NduW9kGoa4geNdazLElKoA3Prx7DofiETtC6XvE7hGEzJlpcis3Qgrj6d5UOJoYDcMglrX2+y0NPtl5UZUjkfx/Hqbecoe0OZzdF1gHQrln9Bhee4s3f3Zxm4MvAk9VSFdUIw0i+Q2PaBtISiBSSFgCYMjMW00MP7pwvvLDmwFgQTzdHxcOSGvBg/b7ZRZByWYAlOERluKM3Ra9CKWc0q73dTBhMFT4ZwIw9l5Lrpes+HjeBiGCUOKXeuBvPcKTiEIOR0f+RhDBMYi0Lhea4GTaa5NbOQAVDzhgPB1La5RssV3rIP1+7yy5OAADoAchEHBkFbKfGRpiweAPtMs5IFNokyOGk/7rAYC9OhBFwNXVY1at5tftCBHaWVS2AJdEcEinrDNC+Lumiyc1B8AB4+muLARAXTDCWvr93lR4/Z0Xt6ODFQkj8WtumEwHTKDLQejAfN3uds/dfjoQdatGLxb8jQBAYz6/boxiFgAVudzNIc2/s3xLk1szAORoB4yn+2DhaATAGJCtbpkCYq9+v4V+aBgAQ4i66XtaC85YkDog/zdZvzUgfN1N7a633Xqv6fe9msDIHfNaB6Ay2JRE1AHAEDIfI5nzZCLeN4Nbm9yaA+CA8XSsul6yqV0rJ2WQfr+splCyCYBR/HJyKX4phs0PKBZ0lqOYTpvniAiUAmAd+HKjo1cvDjHgr+3wPJQsVCymUZrPMuRsRBDG4AQCsunyJtFGHwAAIABJREFUcc0BUJlxQoH62q8ST8cggpKNAFRGwCD9fkuvbwAkyGgJE3C+Nz1P1q9/T3F1EZBxvZh50s6AEYC5yyUHXt5/Q8zI5/KrAmAIkkipkyGPYwXz1aRT8v5ZO6jJrRyAvKOvNXlLazsXs9bo/ztc29Pohgotp5J49Rcj/pzfIwGS//3OM4CNd1dpntQpFUmjEH4LYIgnyn/OLjL8FeDGhwJbNgFjI8DIEDA8BAy1PFK7FSKf43cNKrvHx+8C/vmxwMgmYHgEaA35J0StpvvzL/nP8RbLAfhyT207TChgDRiu/ZL9DsfWNABvYzbhCDBKoBAk/pEobGWTqp819hzQ1/0k0PoaMDEJbJjxVZFgDad0SaUO5LksWVj+XScDmw5UEUDJ6U4d0nVbC91S3ovfVHp5al64cgC+k7mZAP768KCA0WD3A/ieLz090CDceVmlAuhBljLgrfcAw6PAyDAwPFwBkCAbItM4a/FiNtERjBl76W9ffD2AbwJDdwFj+6syImRXrd5Y2FjIYcnzWPLEqnsfC0zsr6qBMQmfIDR/pyJ6xMhKyMrSDiKD2xja6TADTt0/AGAs1KcAUCFrOLF6tbtiRVFavT/wuMCa7MfVTlH098YBeBcwNAIMEYAUlS4uBULOmK3LCnwOPANlEIOSoF9+C4DvVoWXhvdWZVOYqWgi3vOXDUQhgieB0EElViMYJ08HxqeqnG8D4IIDkAzo51DKQQJvBKUmKACzbM4+5hUivwrgiwC4LzvjmgCh6nBcgiMTcv9Abo0D8E6g5eCjfpUA6AxoQIzgi8ALmWwC4z//DxcPPwBak8DQFDB8yJPpPZHeGCyC0KN5DFCByfh9/+OAsekKgEzCTwD047X0SCPM1IYQjCv2E/MJoGVwUUQoPboq0MdqkWVn7RtDDMahB4g+P6qhXFpjVtkDtRGA2nKjos7IyOyHFUbIrXe0FXsTuzIYfNb4O2M3ATGIYQOmPn6hG6gi3eUkQQAeAIYOAUOzALMVh2pAlESqGFBAXAYOMQVjxll03iO/yYKRAT0FQXkwZkjp1pz51LO2XAT3KtD3AIAwj4Wg05kfiuUHYlsXAJLVnP0INLM0OYFx78AzcRySeTsw2AJueI+Dj2Fne4EWKz5MA0MzDkCCkAByUWqsJzarEanzj2zXwjEGFHuGY+pYsMojzZL1G9EBexXou339IRBrC3lJGmNDuSHX+w7WC4Cm6wWxm8DngLTImgC8pBcGBuTXf/1fXnyTugnFwxTQOgi0CECyIFlsvvJfEnh0mhsYI/s5uxFYi1xZof7oOqSAawwYjRGBzYGXbtWXaCIrlvHUagX6SP/ruMVYCEbEqECXAMjfree2HgA0ESur1/0vtnNwGSsG0RsZME20/+/XWH6Mugk/yngPAGy5GDYALjiIHIgRUIrsZjM7Ax+BSx1S4pfffQVIep8dL7dMDsTGjJB+CvQxTHmdtrw4l0CovFruC2NOe975egDQsCXRK/eK634JhBK90q2C7I1i+Gt0jxF40k1cPJAB7UP2m3MGJAAFQrGei9iUTH9yBUDTHfU3B5+BOIKQ43BWtNtPcWIOzEZE8FoK9K0DCGNxLi3FqaKA9gTgeoFwPQAoI0OulWT11oEwiFz7cwbErzNxWtEYBB+VY76Vh4DWrH8IOoGQ7Ocg1CqMRLPltmxvs1/SHaP4dcAJePYyyUCRIzrTB8tE8FoL9DUMwl61kQQ87Rmy2PS2rgB0a1ci18RudEJH57OsY02y/+83/sZdBKr4FXQTApBvprGgQCg9UEAM+h9F6ugJDkC3gJPBEvRGrYoYCBX9IxEcS5K4i6cZAHIw8oXQ4mLBb35YH5d7OekadtTV1UZSjaEIPH4nQzYNwgjAHNwDuWGYpZc7lzPfX1cQur5oBorfzDf+zi0yVTuSkuxBI2Q+PhQDIUEnMLo1TBCZLufGw/ixbQa0KB8CTODjPohdY78IQmfDjmW7Yo/doAX6GqIiAtDHaYswSmeMubV81kp11L6hy2PdAcgblfslOKC1IiKRmyRxZgV/8++DS8BFrxXi5Hd/U6MeSKdqEsEKhpBRsgRMbAtuG4KU/+9ry5brzP/lPVMv1EPOQegharrVcgZUhVHFxNPcp9VFtlOWkL437C0WABWypFRGsV0sb5Hn2zYBwvUGoKl10v1knDgo0y7XA8Pfv0UACnjaK33Co9gJQAOe64FkNvtZAHQdjz9v2Nz2GSa3jYej2W3KGuZ9ixGdIVSoKT13B2s5AHkGheST6qn0erHv5AIgAAU+LVfw/wq3CEAV7clBKDDGZG9/5oVXx/oyYARczcqH5GyH8eFplTawFvAtrtXLGpNrQDGbejupB3omlIHQGc/ErzOcGSRs8zrhAbbuL1Tco/JfbLlNwHOmi2kIcs3owbdwNpYtynDQhsFcgvuG9/YapGFvYX22zZcAU0/GwA2LJ/4AmGF9mwEbBu98Y3cMF+uAGQCj2HVp3BbPuo3IlqxAy5wHAq4OfARmEBXGfNIBa0BIsG0ecwC67merHgRpZLwocrWaovuTxew/V0txJQ2DWeae3WAGbdhb2DB4+wRw7w5g8Qpv88liyGtoWHzMi4C9fAEHbBi8kwUKu2xNAdBxaGBLbJdZux1LwAGECYAEm6wyfpelJrEgFnRDxESwgyUxIUsVMwjVy5AYO0bG89Auu1/5BF38KqjBHlUAYXsteNCGwTeWNuwtk4JMkrlzGNizA1hm69g1Nix+zDOBW0aBeRZZGqBh8M4emfWNADDT+zqMjQyESdQFHfDbZECCLRgdHeCTe8CBaKJY1rDnBRCIAuGW4TYAZeFG8ZuMkGiQ1IEwGCJtHZBmy1obBsvVMnDD3jIAerti3LEBOMjGcOpa3WfD4ic9t6oveDtLfw7QMHjnH6wPAybW6yaG4+8D4HIQfvtDIVtLejpBFsVvUI7NIBHw3DUjRzL3rDVtsYPOkAScuX3coNDynT2VYJCkn+PjqvUD8hVbS8NgjphGxcANe8sAGNoVY/824BCBtIaGxRe8pLKZdpMkTvXiJ2toGHzSNHDPScAyq3er4qPyGaNc7JCRXWLT2TjwGmCOeQashq6+qSpZmp8vojQpheF58ncdZVjLnjWPHr4VWKTKxrHGUqq97qXu3jp0wPy+eEC/DYNZsZAO6IEb9pY9lNCuGPcNV830ZmkM9dmw+OKfbdcXvJMPdY0Ng0/7GnDXKcDMccBS7MwdKz8KCAKQIgY0MWGCtr4TOHAasMwOkTqf6unyuLykfd254nkb7qsw/iVg7jhgmSX31Vpd9yRHeLx+zRhjEGRbB6wDYT8NdymyubzDzCCGfpMJWfSRYfr9HP/aMgBm7YoxNQHMbQHm+ID6aFh8yS93tAvGQb7da2gYfPoXgbtPAqaPA+a3AEubgGU1RM6B060fgkRoCzj+TcD+04CFE4BldZdRc4/YxlxgjJMewSiwN1zWfsOngdljq3EmY08vm5i/7j5yIMqpvupKyGoNg9lngYosl9wY/0dZdrMzYl8Ne8sAWNOu2MA3zw/F2CoNiy99XbvftrcLriz6PhsGn3U9cM9xMODObQYWCMANwPJ49UliuW6SaqqBn/gGYP8pwPyJwNIxwDK76ahDeN6uXYCuYyABkEza4LbpY5WEWdSLxjF26/dQB0SJ6r4ByAN6NQxmkWcqrnQ00x1DEDJFjR8CcNWGvWVPp6ZdMQ6OVOCb3wAscPJ6NCy+7PerkP5Q3tBY1PrT9tEw+JwbgPu2AlNbgVkCcCOwtAFYcgAuiwWlM/XqDjMEbP9t4MB2YO54YJFMo/5gHIcALV1TRZ17FXOhPtvgtvkqf9H4kvHDlyKK4l6VzvVSBF22uwjOb7pbw+CfcwBSkyeFEHAUx/yw9JTyEbo27C17Ol3aFWNuAlgIn9QxO2tYfNlbK6MvaxeMRYquvL9rTcPgJ30TuH8LcHAzMOugX3QALo21WXBZLEHwRF1OgHS2eOgbgIPHA7PHAezNu7QFWFZ7JnXJ5rnqxHEulvlzwyVNN3+wern5Yovl7SXLGwvn4riLWO4fgMRJXcPd/+pmOymELEhRzBxJAo9gVL4kwVnbsLccgHEpWi3epocCAMeBRU5eTcPiy/6qtl0wpvhA+2gYfO7NwOQm4OBGYGaDs+5ExYDGgqP+ccAkINaVpB8GTv4d4OBxwNw2YGFrxYCmV0YxLNYheCXau7EhV3ga3Lb8g4+R45uoGLADgHWqhsBXA8K1AZADyRvuvtkBSArh+i9DsQhCOtf0UUgW/7aiYW/Z0+nRrhizoxXwFhyAi5y4rGHxU66qAFhT3rDSIVdpGHzencDejcDBDcDsBDBP1uX1CMJRwFiQIBzxieL3KIY1YW5MPOxNwLRb8gs0aghAss1GZ1O+SFHsdRPt0i/PLHu++dFb/x4mXfhcbWxhfCtYMFr/uWvKxfDaAcg7ipPCvFOVpuo3HrCjYW/ZA+rRrti6TS6MVQ+L4NPH2nx698GnXF0BsKa8Iab4dFZpGHz+JLBvApieqAA4J8CPOQuOBBAOV0CUYbIskRkAecrvAdNbXc/aDCxSpyT4CEIyTgRgneiLIp3nP6fs+a4A4N8B8/48CUC+ZGJA29fpuLmxJW+5h5kNFg2jiWHSi0r0Uv4pCoZsxw8DUfnhd4Vk0XGdGvaWPaBV2hVjdjgA0BlpkQ/K9bmn/HOVqtClvKEBqlfD4AtmgP3jDsBxB6DA7tdbcvYzJvQJkii2n4NOeMpbgJktbYPGACiF3wFoEx1ZMNe/4jnPLXu+KwD4t/5SO/iMBcXuesHylyACMBPDgzGg7opM8mEHIGdwrfGA1rC37AH10a64Yr4APvvOSdwEPOVbKxu+K2pdKRTmdI3dqkPPVgbSTBGAY8AsATjWniBdx0QxJylOFCcr6HBiw1P/CDgU3EgEIMW52M8YkLolQRddIN1AyKWiBretf9MJQN6HsaCPxe4rvgDdHOcOxDIAcmDFDXvLnk4f7Yqt63gEIB/Yoj+4p9xaAbBHeUPM8qF2aRh84QQwNQYcGgdmx4C50WqCFngNsgSvQ+Dxu4MuiawhwIAXVk1O+e/A7CZgThY1dcno1nHL2oDIyZULpBsAFTBZ9pjT0QQgn2V6ufRicS8QRgbs5ZYpEsENDejBfpoLrwAOjgIzZMBRZ0AHoUC+SOA56xJwNlEyTFw5FxBPeWvlzpnbANCdQ1eSGTRybMuydgMggVBsKmtYoC6Mt8znZxsZMLzAxoAOvsh+ydDqtXx4FIDl8L/omQ7A0QqA82S/ERdTI22mNfaTuBIIxR4BhKe+y61punQC+MytI/Zz/c9EuvyBeetLAfGZ5WOMZ9j2/gqABB1fMLsHAVBqhfTcyH5d9MByEdzs+B50Z7voGZX+NzNSsd8cwUcG5ASRKYbdHRNYwhhDIHRgGmO0gFP+HJh15jOXjnyKblVT5Cbfoq+yJOszF8P8+VnNPlICkMAzds/YLxlYznrJwIpO6egTPMqA5ZNDAB6iCCYAyYBcBqTRQ0e4630SxZyQJQIvMJ8mSeLrYe+p/GzGfnTpEIBy6US/out+K1wg+brs88rHmDOgAVCMnrEfxxMte1Mt6j7u9zzKgIXzczEBOJIB0BnCJoqgIfDEhM58SWzJEPGJe9hfVH42un/Mfxl9bgSiBySIBWnAJBDGEDAB8QWFA8wO3/a+wH4+rg4RLPYLul8tCI8CsJmJMQAOuwFC9qMI9g9Z0CxhZz65K0wfFBPqu7PEyVdWAOTHVlTcpxhXHZLz1w0ZA6EDLhkCskRf0sw4dRYC0PQ/vVSRAYPo7QCdj7GqVOSMeBSAzUzMxZcDMwLgcKX/zbv45SQlHXDIgagJc+bjZBqAWhUoH/Y+B2D0J7rFa6LYDRmzomsAaOeKqxEvbWacHQB08JkRIteSXiSBLYJOLB+X4xrzAzY7vgfd2S4RAKkDDgPzNEAIxMASSWF38WsgkuXLyXTRSRCe/DduSZMBMwe6ObTd8JBj24Aot07uDObPP9XsIzUGFPs5+JJ/M6oT4buxHv9X7BeY8KgOWDg/Z58GTC9Xq5FxTXOw9c3Cm6k5fPcjgbHbgAlvVG2tH1T3Oavoq6BlniZ+12n5u/2sDbOvasqoFg8x2Lnbcd1GdhSAhXN+7qMrAC4sA8sORJ6yHwD28z+Ft4fdv8UyqUDrDmCEBcpZ39kLS6aq9l4D2rLb/KYsFTPWdfbvh86vQu2s1K/K+zIjTsXIVQ9a59Egs4Y6sZfIA/EcSp/jEXv8BWcAhxaA+SVgSQAkGAMICcwVlNLlqTc9Gbv/HAA7MrL4+f1VlXwrUq7SvCoyGcrrWpGhuur2fNGYwM8YT67hT3s1LaZvqn5MLM0bzmHMmIFSgdFNj/mIBct63NhFZwEzDsBFgpDPeanNgATfCtGsX9TIKwNrg9tuVkhlng7TI/YArX1VkXKrEe1l2SynN1RCsFJsqnQv3UIMxhwIRjU5AGN9QUteVz3BUAvahuNgjC3HxLAND7nBp/cgONXF5wCz8xUDGgCjKPbvevlzcKUHH2ag6cnYzepYBB9Zi2FxDJdjoXJv1WDFiLJ6MKqKZUzoQFTfj2HmwTKcTpVWvcxHKm6kKgoORAEvVclPD6NdzLXpMT8IYNPcLV7yJGB2AVhYrAC4SNA5AxKM9ryDPE5fs6eeVKWGZ2M3S3MQfEyJUKV8L1ZpJXpVJ9pLilmlAxWkVJHKwIhjjD9TtVXVm1HdOy/pJiaMFRWM+bo0rWl4yM1N7oPhTJecC8wRgAttBjQWdBBGESwgSiV0Pb9DRgu0TY19N+M1mRKh8niqFx3rRDsLqjgl9yaGXT80vcL1wnE252PAZCzAHQCoiqoW3yYWFIt664fUpKaREr1NPakH6XkuOQ+YDwy4FMSwgU8GSRSz0UJx3Vx/5vFNbrs/EiLRY+v4ACITww6iJEodQKwBIyBRv9vwhKzUW6z66TUGEwhDS3ezqusAyNxnJn8xa1KRPSFts9YfFB/QDZcAm78CnDBT5U8rCqjfc3yh8Gn/hGd/MsKf1+QzYJ4891Jye13iy1cAE9cDJ+6FpYrEkidxDN3OtXR+FwBGMezoMmxJLOumAuD4J4rxJrfdH/XCoLGFVKiUbw+LAPQqWWaMMLrd6/+JycSIm85w9lOpt1j1MwAwFTiqAWEUxeYH5ENn/jInUVHeMXQ/f/jRePvCa4DhTwLHfBc4frGqqaNJzLPw6iZxV+HTplFGvZrXZT45N39+HW3TujlZv8D6fp8HRq8Dts9XIOR5YtakgBgdrrrt5Qsq8Ssd0BhQ4HMwmVitAWHAY/LbLDQNQDaTVJ8Q6W4qVB51OOqDZDPVB3TLOBepW5jmqaLbec3jGgBGMSxvvemDYkQ9GoKF1ShUCSKCqBeQrvmfVZPC1keBjXcCmw911tTJ8q5XgOLaQgA+x/OdWA2EGZ98gbjleTHdQHQN+2iwls3nK3/Zhj3VeQhovYzdxmArSwQgDRA3QiSCJUrTnjfl4KozRCSCCeYmt90EoJJbVCk/1+FiCwFZxLk4dRfLFia6x8LbYkD9v9cXtLG6+O4AYQRfrgPygVIcqyhTXcWFOJH8fh3rz7EKwnUArq8mcGwK2MCC1i7WY7Zenh56feHT/jE3yliE4TZncd636gPFCKWavGhcRx2J+cvs9MlSw0Ty3cCm+c7n0G0MExdW4BMIbTXE9UCynvyCCX+Ovm4gbByA/xisVgJPpXrzLj4EoRJjJIZrWHArS9iprK+KcefgiyB0XVKGjOmCmW9xhRVMUSyRFnNeFGEdI2q+/HFXclkp9WsAbgTG9wGj08CI64WxRk/OTDcUAvBHXSLQxcVCDMQSWbzv+1e7WVbz+k5w2tJtsbcCYV6WJY7hmAsDA7r1Sz3OgOgoM+KTOJbcjSI5yGIaNE1uuwlAAU/MF+tF5/0sIghVLdVdM2S0bSzHx2Mi+FTxXf8X925NC4BycK8QwfmgVX1LlcFiykEMcL2BndJJ7aQfijKfxLGDwAhByM7aC5U4qwPzNwufNnNuOH4VZaCPlPo2AahqFqoPVFc14ga2m+WEEL0cAz9kdPrOmMu8r1o/rTsXz7f9oswFs+jO6LAqkvC3Ggg5Fg6mwW03CUI6X12h8lyfcz3QHqr3DIl64DbqaQKc9mI87QXACD6vpJqY0EVxz2CEyCI5eMSGX2e7VtI5J4yTRyZhscrvt1nQuivOAaNLlYESwcySgiVbr37Bfd0/u31yEgg2FVaiPCeVOguqAfGov0iR0R9JABJ0bnwk9nMxw+fOh55EbgRhzozrBUA1polN9CLwok5HEEUQBjFMQB7D+j656PW+IrJ8O/bBCo4sGFdGejqiyYCx3mKe9/JtTiBvmI5OFiTisg9LtJFF7gZGDrUbHKs79+hyu5hSaUvh1foFr3r/6vZJCiXgCDwVVFJ7MVmRLsrGltuFCc68yFdACMDAflwR4QM3HPoKgIExt4gz42SuaQb8hBOE2oZmlu+KFlKR3QSssMJxDPWbbjpfLoJrxG8CYT8MKGZSVTCxYFTIb84nkCxCIPLDiby30gXFghaF4c2ReR466Uu2fvoFr3r/fKAEFxvpqMcd9yonIrkuK5LLV7MVCM+/uDJCyIC2J8a0z1iwqyESgMl15Sa33QKgmtPEBnp11mwuXgO70Ud4DHWzfgDYC3zBEOk7HlA6XKyHQzb8HgGoCSQLqsxorIy1Bxie7Wx0rFaf+wr9Xv32C+56/7HbJ5VHtRYT+GJrsehHcya57PyKAQk6+vBkBZPpjPEExlwU59awg3C24W6KBsC6tqHR+MidyVG3i3rdAnAsH2T093XT+zLr197MTA80h3SfsZP2UqpCrPQ46oF317VrpeiKXTJ9MhMLkgGdCacKG/mupV9w1/vnwyGgCDCKWzJe3lqsyzLWZWe6/kc/oKzgKH4jC7oolhdC4jiuzM0WPo+cPQ2AsX1obFCTO5Jzn566PwbReiwnfTWjI4KvDoh1juh+aT+WKSYD3i8Aql2rJk+VsVQly5kkddv2FvHT61icqO7Fr71/IkLNXOi0FQjV0046oBy6wZ922Q95ICqDEaL4XWw3COcf9Mw73DFB9AqE6wZAAS8XuzGQIDKf+oVkqxt00ttAc+YT0PJ9qRFSB8xoye5Xu1ZVeCSgCLbYLVNswoncHxoeLwCzBGjBNki/4BX3z9lXgUCyIIGmhova83cRgO5Te9yLgP3MfmsBS8xs8/U67ePQOqy9umBUruDchqo8sHSd3PMfT5ifo+ack8eFHI6QEcnT5GvdOnVdXof+ptJ+BVPWceiaRHA8Us/nkACo8mzqlqmWrbFDppT5A5UIZm7CPA2Vgm3QfsEd909kKIqB1qJAKCBG8ZstZz3xHOAAiwmpDIdng1maZQAkZzsHZ537YfQrwNyxoQ+HakrnS0h1mUA1C96TdJTmORyhC3oeqdwROi+GDhkFI6bYNrcNDEDeAkXwQizPRpmnIs3OdqZPSaRFUcbchHlgie6agq2kX7Dd/+d8lUJVXuUzk8ERmS+2vfd4uvN2VOV5rSwb0y3JhgIh9wJeN3YMQCIgR78Q+nDEVYBYZUrUpbXFnM7COSdf7N4IPvtDnT2BY/h8Chh10MXQeYGS+7GGjaQiABpuNIFiECnzdWJMIUHcazLptC7YivsF8/7FgLFMqpiQL5TuNbKfA/DC46rqqAbAwIKWK+timRUBEiNGsOQsyQm+Gpjd4n046hbT84KPuYjOmHHyp92gcgDS2OoIuVIeh/xyUkaVwyEWdLrewHE3uBUDcKIwnq40HpDXL+n3CzbaKdguel5VnFJl2awaghLQBTzteZ0cjLq2A2n0M6EPh2pC57Wg41poLzZsAZNso0Hw6eVR/J8bF9YjWGmVCpGKwQLBRCcrbiSxNLgVAxCF8XSl8YDHHFPW7xeFBRwv/rGqOKUBkODzqgdWPYAM53vTASMQu4Bx9J+69OHIF+N71F1O1gUB+AsBfFqKC+4Wi4BWX+CYgOTAU36wdMVNVKka3MoBWBhPxyiuko3xkSX9fvGMkqsDlzzHC1N6SQ4DoINOe7KelWWTheziObeKCdARApD1AdVnRH048gKUAmAEYi6Oh4DJV4VoGDWqjq4XLbO5o1jBoimEPhPJmwu9FvnTLgdgYTwd2wyXbMyRKen3i2eXXB245FlVYUpVxUpGiLtmGBlrTEhVUwV8dEkVKAq3MHJ1uzRbRx+OOgDWFX6MsXJU/36lJoEoA2AKvw8+uwTEDIBbStdOs8ddDsDCeDom7ZdszBIs6fcL9ror2C75US9IxJJsEsHdGFBil4yYuUwknofJgF4XcEUfjrz+X7fKo4EJJ//PkMORO6FrVjQMeL5kJhZMMXzLwNZCt1nzDFgYT8cQwpLt4hDON0i/X7ys5OrAJVe0S/ISgFY7j9ZvnQ7I3+lyqpYaL98CWp/N+nDkZdhi6bW8An1kP3fRTLKVWlwF6RZCH2L4zDDR0k1IqeTNb2OQSYNbOQMWxtMxeqtkY6I+ny9VEz6btfb7xc+XXB249AoXv85+tIBVgJJ6n4lf6oV+mfjdDJNMH0wAVFX90GMk1f5TxlS3Fggh92DyN0IORy5665KIfCktsl+K3VsGtpVOWOMiuDCerlSnjQ2rB+n3C+pIBdulz8wqonrNPLKgwKaC5B3s53qhXVq6oDNg6sOhqvqhEr3V2VNLBjmnSSNdrOLJ1zkAu6VPRjFcFz4fXDJ8i45hG94Gt3IGjOFYA8TTlQZ/qGH1oP1+8ZtlT1MAtHK8mQg25zOZUSCLIliWcbw8wfW5Ln04ssqnHX04euiCk6/3de66MPpuAQVZAEFkw2MKFw6a1wEL4+lSBvmAOMhD8vkOkFX77feLNw14YT/ssmc4A6oOdHBEkwXlgjH2k4Nal6wB4fIuX9LzZjAmorNeHMo5Tc0OewHwDTUh9HXxfGJsYkAbAAAgAElEQVS/uvCpoAcew6zBBrdyBlQwwoDxdLZWXLDFkHyF8xGE/fb7xR8XXByAAVC1oB18HQYIT+8uGfP75SCUs1o64he8v4j6cIQ+IqkPhxrBCHjdjBH6AblQkAeY1ondukSiELmsUPpjbyp7XuvDgAXxdNZVvWCLIfmKg6Bbhrjup98v3lVwcQLw8gqA5v9zC9jErutltg8gMxDWWMBaMVkmANWFyEV6R0uH2I1IzW7ypbkQOTP5f2ch9KsFkwp0kQlDAOmxzHpscGuGAQvi6VD4RgmAg/b7xZVlT5MATNXwqQc6KGwf2U2uGV2uzg3D4ua7fDnPwZcKgIdq9GaIBPZb0YdD7hgyIFWMXiH0eQ5vXS5HcMkc++9lz2t9GLAgns7KxxZsCkgdtN8vWD+vYDMAUpcja7lOR9eLVcIP4tcuob/3AOHCdW02VTX62ApB4Mv1v24gnPy9HiH03fJ366KYHYTHsgBBg1s5AxbG0+HLZaOp65i+ln6/YM5EwdYBwGj1cmUkE7+8THLNdAHhwrUOXtcrO/pwhF4cct2oN68BMDCfmsJM/n6PEPoYPp8bH3kCkbtjji2tJJA962YAWBBPZ0WBCrbYsFoOf9pDAiENk179fkuvf9nTXewKcBSjsn7ldonWbgQpx+26otaLIwAlfi2QQSJY3Yjy5i9dmsFM/oEDMM/Z7Uf0RiYUA7J+ToNbOQC3e0WBBm9qLad6HICG1ZK1XB5PoxnuOOIcxSXe/Of8xHV/P+FpwN47gKUpYHmuSve0pKZgCKSq5wqniWE1WZz/xouBm74KTMwBI17lVBXwtWSs+8/vL45Ff3vhpcAnvwos8d48DZX3M2hx9XIAnu0IIO0chu35AOgLL0yuG/jOmwbg028G/mNz1YWdETbm4I5BrFlov+EtD2wIo7l+Atg8D2xY7iw3V5diEqO54mnj6XdMAYcU+6gon7A3NSO2qFjlyZYDkAX6uD5Iam44YaUfVNDNxaJcLIPXcGGpfi6PnZdVD1wPspQBX/wl4OaNwN6Jqg+xwrxslcVFuYJblehkcYYZGPS3L20BxueBcS8nwg5H5kZkx6TQSbXFZcCQKadx5Cz5mPurAFxrRaa17pAR2PFC+ElSHKQ/0QjQcgCyGyM9v3SnsDBRJgL6msWCf6IfWeUJac8UFlpY8500DcCfvgb43hiwZwyYVhd2D/VSrKGAmIDnBkiafEcN9cprHgKMzgNjS1V7rRjRlceyrqif6KAkMgXIM+6tAnDl+zSL36O9+U8p9jGHQo285/2XA/AnXeNnKAorDXH/AILwbSvLEz6Ql2+cAf/3XcCdw8DkKHBwpOpFbE2wadzIdyh3jjNQirYWEwYq+/zJwMh8pf+xKNSwM6DZMmzNRRbM2K+2Ii6TlFrAWfd5V3i/F7IgT2LBF5LbIdkqxLPWvtzlAGQ3RpU3Y7AiixMxLOUB2t7pKQ8M0qCTnp8HkojJgNqaMEJesQv4AR3Iw8DB4QqAs+6SWRiqgJgY0HVDAdBA4Ba4xN7ndlSFAAjAYX4IPO5dBDMAdS2i+Jx7XTf1eEdTDfgAQnR34p/wQkRmjNAoByDT/ugFphXAmjAEn8qaPQAgZCs0lSckCNmVigEbFMsPBBE3DcBX7gLuawH7hoAD7EM8DMw48AhATrjtQwiXoqkTEwWd7LOneXNCbz6Tiq/TInb2M8ZzIFrTQbGiy92oGz7pXl/7jvdAJnb2470IbB3T77Sai+hyAP5voTqW6sKwFAc/TAdc5+3dvcsTrvPVYSK4SQb8xV3+6IaAqSHg0FDVh3iOIFTIFxtit9orL5Z/LD1Q4s+B8OnHVuXwhhdd5DoLGsgCCJ04q66X/Ju/vSaeAxDPvbdtmdtKDV90gVEPIl/xySkviOhmAEjrlzSkwj40SlQZYZ39I+8JBMx8mZryhOsKwqYB+KpdVSDFvhYwPVR9BD7uyX4SwRS59nNI+bRck/DzJ05v12M0nY8fAk8iWL5BB5qASPGRCi8EVjzv3mqpkC9ACrrwhKukB67GhpqRRowQMqCiYbj8oOoHeUWpdYIBAUj8c8WjrjyhNIJ1unzjDPjqXdUjJAAP8TMEzLYq9uOHICQALe/EwWe+QgddAqCzzD8+vgIgg0qp+5nYjaDzCgjmnCYone0klqP4JSgvvK+6LoFPoFMlkPGh+0rPWta4RHTNJJQz4M8EAGoNTPVU8opS64CC9zoAWTFChcq7lCdch6s3L4J/2QFIEBKA1P9mHIBmhPh3Ai354RyAAmWsR/PRs6vOR8Z8FMPS97yxtIlYgVB/I7jC0rIKSfLXF1EEB+BFFjQ3jCLA49OWsRTTEPzvzQEwry7VrZ5KwzAQAPssT9jw1dcHgCrORQCS/bgn+1HsCYQSveaHkzvGv1scgU/6R55Y1YIxhvOm1EZekQWl8wVDxJgwc88QiJc6AKX/meHDawX9z16M/Em7bO8Q08GBP/jEkAEVjMBoAFWXUjRA3KtNwOBXW3EkAZhrALktpC6lKtTV4OU7RHB+3kHWgv/zrnYZl2kCkF4uF8MGQGc+MqEYUCA0n1tkwxbw4ScHAHr71Q7W4++c8czwcBAmHVB/c7Bcek9b3FuwbdD/kjGWgzJjQ3thGmVA3jhfOyU+RxB6FamOFp8NrhsTgLy8Cpzm5QlVptAU+6CiNgXCaIQ0BcDYV8b0P4pi30vfIxD5+w72C9aliegW8MHzqrmh/meuFhYi0pKbs6D9fsh/n1XFMrYMbPgUByCZz6J+uEknDA9AornWFRb01WZEsACoHhOqyC7wdetT0QAK2KqOb5MCUvPyhLE0oQxzqaYNXL5xBvyVXe12vByLADjXAvgxBvSPGFGMIjCmJbEW8HfntxtQmxT0cmxp9UPAdKAZ1upA6EB7qgDo6oCUxXRtPVSpAwJpnUhuxAqWCCYK1MBExZljY5S8SYr+pxAFAuBayhNG26jw8usCQLX0SAAkwwcAEngyQizaXoziIli+Oe7/9kJvNk1LmBMe9ECO3XRB7aPeF0EYHNVPdT8gj016YBcWtBfBVYJuz7mF7VgGY/pO8f5WdQ1/7U67nIKNS7j0wIbDPFZsyNHHY7od/xdlEHj8CcC3TgCWHgGAPSxiSdt4312u/8SPAl8/Dlh4pDeZW2PD4J1c9+uyDaIDkgEJQKnTfG/N8nUAmu5HUnMW5ARbPfEuIHy/ACjRK7FL5pOR4RaxgTHofKl8r/S1ZWBnAGDKefbn3AFIPRPXB7sFiVQimKVgGdl5ooNwLQ1/1U+DQGSXQ9r5Evy1q9rZbP1lGQDZsPpzI8APHgXgod7qUx11YtBbFzC+/C+BL7SAWwhgdoLkONSLqy5oLogYft3ZI1F7EAC+phsAnekokhP4HIzml/PvthQWmPB9LJ7jxkcSr14jWj4/0wFlgJD5eoDw6fe4DzAYPHokWhHJZ3TFSkn4h7YOSOBwEtiMTv1aY0uktFYTmI2/43EMQmCuAJmUE0gmVD8EFdPpdnxhVhqzDr8F4NMtYM9Jfg98EVTeNu9Q2OFZBX7vr9vtgm/lcezczZ61ZNN8DCvilYCdPXqNDQpAlfGTKm0M6AA0PTAyoMSx64cRfPQHXsniOTI+fEWDFGp+Qb9BeySRBV2kpl0QxxGAlHDmkI56X6z+EP7UDYSdRgh/IouwIZ36lHabBE0GJ0r10Rgb/xA/tt/j/6aMAf+7R4CxzuBXWRGULwBfIrY6UNfpvLae7n0I+LO/reoLMqiVMbW38oUhkNkQIzZO7tIweGePcmWlAFTjAYHPVGwXxWoLYblEDkLuTT8MDPhXLJ4jALpaJB+ggU6xfgJknT7IKXIQXh4Y0FZCog+wxiUTwSkXUbSMV1rB/A31OXWuFpPUda/mRHKi1e6U+hA7Zq7l+A+UAfDtHg/LrptkQpZ727cRWOL9542Pa3rOvuOqagUltgtmJM08j4/PILbIDKz6w5PAHsbraTnMGdZWIwIzxIfeK0rn578J3LAVuH8CODRahV/FFQ/1IumIvXP1QudNfyNT8oVqcHviPcBd48A0g2RDuoDqHdb2SalZAdG9dnfDkAE0gXnH5ijWCDbKCq5/MRiV0QD8HgHQ63jG0hdsLGxA3x9Bw1Asli7hO3BwApgng/Gjvq01IHrXJ7q3Cz7E++YziF2rs1ZLZ+8H9jJsSoECWXj6igmR87aLgfbGq4GvbgLu2gjsHwdmCEIPSI1h+SkCRjpfUC3iNWcpoRrcnrYbuGsUOMBo7QBCxSTG/igxVcBIVGPWM1h1JYQPnyKNExGZMDIJ9b66eEBGxPDY1Y5nv+GCjfGAxD+DDpiawphABWZPjwNzNLAEIH4XCH0M7/5c93bBfI8Yk2cgVAdvdT10ifDkBWC/r9lGH51NhIsnsWHOfPmEUKT94WeAG8eAO8aAfWPAwVEHISNQlKQUglJjJExqC+H6Nq93kOpUg9szbwLuHa66QzFWkaFieXxi6hgVHOMCYGRuJ+5V4jYJIDKI9KlsAvFDq8QDrnb8NWVPh9EwdFkQ79TlSMIsN0Mi5s9MoOGno4U6f3YAvefL7Y7rvdoFLxOANSA8f7xSgWmd0kCQbmZ6mTLEnJ0UqWLhUkxlrBn6n3wWuGkYuGukCsufGq2iojnRFpafsU7MDxErJuZhYCsJosHtWTcBe1oeq+hxigJgXBrMmTBPnJKLrr+VED54ibHYvZos8sO+DNcrHrDX8YVVyglAKud0LtMjFPtNMz6QLDY7VomLJd671AEH4Xu+3g7nWq28ISvX58/hguOBg8vtFQvV/hEzxfqOevuTfpjri8vAWz8L3NYCfjBc6ZYHmBcitnFd06pxyb8W4gPlgonBqffTtdTg9pybqiVNBssyUsdUD7eGO9amnf3sXtxQipl7Wg/sD4A8AwHIyZMYky50Tp/xgN2OL8y051qw2hXzwRCEdT2nmck1RxHG+w5jeO9NFQBpR6ldMIMXlFWgVndqF2dVFsJzuOgRwMElB6DcI6rznemD0RnbwQiSRS3g7Z+tVIl7PC9kahiYZm6IizuLigliT/VoUog+p8P9l3wJ7qGEanB77k3VczroUToWLCsABud4ypaLCUoxf9i/9w9ADiICULrQRWuIB6w7nuZrwaZwLBGwClSqSyz3AhHbaRGEFGOmC44D72UVgjW2C2Z4lIF4ArjodODQcqUGqAxfcpG4mJVuVqcL5tbs2z/veV0tYK/nhTAqesYNHdO5PCJZos+WuzxHJIViuXFyJxupNLg976ZK2lizUKodilGUgzyGhokF8yw5Mf+qRkjdjfuDtwkkm7DTkNaBaQ2ox1q3eMD8+B6O3H6em8Kx1Ccx9ptWl9iYIUAAWrI3I3nHgPdOtsO5eOuxXXBdj0V1vOL/so3Cxef60tlSpYwveKf0pAu6ohfdJ8k4CUqgvr5jV6VGTBKALeCAh+VbZLTnh5gu6D44A6H8cVlkNK95O1WkBrfn31R5HSy+JCwPplAxRegE/2T+AloGncNmbQyogUQx/KwB4gHj8YWNTwRAOW0FIIIndoqNkTAxz/bd09XDGLBdMM6/pLKi5whAX60gCK2ujxzEAqGL2pQ1Jis5AJEAFHvTujYAKjRf+SEugm1d2COQLU/DAwQ44caEw8AtZzSIPgAvuKkdrWMM6M7xCMBoiBn4YpCE2NCfxWAA5MEuwvCCEICwlnhAHV+YORfDsWJGgPpMKwg1b9QpFnzHbD2BK2JGul9s8KkYW17vLALQRTCBpzXZpS4gtCXXMAkduuAy8E7PijPWprXJ5CR38ygw1fJDohh2BlRAgq2OeN7uTWc1D0AFNtmL54ESBsCaJcLkDajxj5ZXRiCIGA0waDwgjy8sk5+HY+X9ppUbJSCp6TnFCMXwny1WAFQ8rUAc2wUrRL6mXTAefWnFfnz3FpbagQKLAqAzoZjAKkkpXkNO5GCEvOMLFXOnnC4xIKOjnQGNdWSM+GqHQGd7JSsxUf+JzQLwhTdV4je1nQvr1MkPGtlf9yP2Dy+gAqZ6rQytfvdHSDxgLwBF8AmAYjHWluEDiKGMiqOVvtejXTBOuRSYJwDJAARgZAGWL9Nk+IM3SzgTydE4eec1nZHbtDaNAf1Dpd/SMx2END6kD0oXtFhBXmcY+OY6AFChnKnzl7NfdMR3qCAae2B+VVMYXASvDs3/X/zHJZcB84vuiqABEo0QPnhnwqQLyRURmZBPytnwHde0M1vN2lR6picoKULaxHDIEdHkW2iWg4/7b5zb7DSQAVd0/griV2JYojfpwRGEYsGBrOBmx/OgP5sAKANkcbFzNWTRnX/GSGImMYH/LYlk+gGvdT+bW+SWH+Ig1GqL5QeTtR2EYj5LVHfjw/ZDwL8yJ6TB7UU3VVoTjTYxYDK+Ivv7dzNAZIxpZSiU8jjKgIWTcykZkBawDBBnQdMr5QeTKI5iWCB09AmEb7+ucnOQ/aTPWn6wuzyS4u+R0Ob6CUGqJpIDA97AdqINbgRgBJ69CG4Jp6q/ckjXqB/RKla4WpkO2ODgHoynigA0JiLwaNiEt95YQKJ4FRC+7brKzRH9jZbN6iJYuSHm9I5iOAOhHNJfZkh+gxsBKPbLu3+JgaWDdojhMO5kkDWSlNTg4B6MpyIAjf3IggJgMD4MCARjFMU9QCgAykhSKnUCYHB9JB0wy5aTRUxmup4h+Q1uAmDs+hpXgFLnB6ULONOn5xACNJqxghsc3IPxVBGAiQG9aLeilWUJW1FvVXEN0TKp1C6At19TMSCBpz1dHtT/JH7N9yaxp6QkF73KBxYIr10nAMproB44qQGTj6sjUrtOFPtLeFQHLES9AdDFrq1E6M13MaxVCTNAXNFThIylLcor40zxtgDAPKuVwDMrOKw+SBTbtR2MND7sZwC7Qvm4wqHa4T/uIrhb+7n0EgbQdTijoyg+agWXT8llDsAFWr/B8qP1K7bT0pvtVwHhW6+t2C/m8svvZlawi2CKe37nhFtapkDnILRqBQA+v04AjMyn79EIkXO/DnzyCBwVweX4wxs9B4rRZgyPVFqykgDd+5JSpBU5r0vHyHz+jsc3ub0KABsZMCyQgeExKyFPVIz3lmcM6OfPAGCADYPE67Jfs6h7G0o+xvi7oyK4cLZfOgpsXwC2Lq9MwuuVERonKn4nSJrcXnQKcM7dwMMXgYcsVxkSebJgzOWPqdB1ad2f3gpsnwK2LXWeR9m3danUIV1lBSCPArBwtp+7DThuBti6UDWDmWA/DvXk8LRptfPtNUlihYZTOPCi04GH3wFsnwGOW6iAs5n3GeJJ+KLoE+9VDClQ8R6vOQHYegDYwuY3S6H/iJ8jb11ck0q9Qhoc9QMWgPBZJwFbpoFN88DGRWBiqQIgWyJY3lPozaGJ1KTEPh36zpTkJrcXPRE44S7g+Cng2DlgyyKwaclfFoIwvCwx9Zn3Q1DmIPx/2/sSaMuusszvjfXq1ZRUElJkKsBEGQyYhJCBSkUqAW1tsBdpuxEVaBzowXZqe1g90G2LotjQdmMjKqtBxQERdAWUAkUlZNBGkQRNyIAEMAkxpFKpqjfUG3t9//m/c/+737njPq9uVeqcte66b7jnnn32/s6///3v//++Tz0dmD0KzC4DM6vAFpd/0L3Gh6yTDgnvLwKzAWDGiH/ThcC2OWDrErB1pRgQisIQhAa+AED+HEEY6uNLyrRnZLSl6tSbrgLOeBQ44yiw8ziwfaV4UGbdegmA5QMTLFlqsfn7XecDW+eAmePAltXiXnkuZSBkRcm4UGXtU2uo3xsAZgz6y54JzMwDWzkgBOAqMMVBCSAUObh8QuN/CiTgcWAuyWhL1amvvBbY+VgxbW477paa7gIBqCnUrbUBiQuhAKDUot13IbBlDtiyBEyvtO5VDxvvVfxW/JkWNFrCeK8NAGsY7BsvKQC4hQCkJNaKy2LRIsg6SJ3IQSe1onKKC2CsOYMeN+0Dtj0ObDsGbFsEZmWp5S74g2Ir2uA22BScAJGA+dJFwPQ8ML0ETAUAkgDTPq9zdK/+sMWpPF19NxYwA4g3PtsHxAE4SQC6FdSgmGWRRIJLZJll8EGKjHiX1jwaN10HzD4BbD0GzC4WrsKMW2pNobZoCu6CLCDfCTqzgg6sr+wFphaAKQfgZHKvpRSYg7HN5XCL2AbAZwPrZGaj6ippXhgn0kqmU1woxnHedg5AATuWHig2FE1uVRwoxoX+Wcbg89S3AqCKPONcCi8oPtVP+9++G3j+oSK2xRBFDElUxbTS+3nvc4FpDsjxllXQoJg8FgdCQoGJJTTicLcQ6vPL6wbg9cDM4cJv27oAzFA5ky9/UOSvmg8oP86n0dICBn25JwjARWDSAUgBHN6vfdbv10AbARh8X91vDM2ss+NvAECKPVLCsHoyUgRqrlbnRwB933OBc+4DXrIC0IEmiLnE75di8HsyAcjzWUVGUi6uICMpVwwJVMXdeOk3XAxc+Hng+vV2esAYw+sWoP31r3eLcLwQBeQUrEHh4Jo2h4vDmJPuAyMLGAeEn7uqbgB+I7DlSWBGCwe31Gb9aL20kGDb/EGRxY6WTz8f2wtM8l4pgL1SgM8esHCvsuylME4nn9cfQLtldg6TZ0kUKorAfij23vAPCmqp3fcCl60XFINid1PlZrf41/dnApB6wSQjutUfIDJR8CGIQOwWEH7DywpKrWc8CFzqRLHkVYrB2jS2FQH5vkuBycXCAlIUUAAkCM2iRBA6+ARCe7DjYmQduLYTleiQ/XTTS4DpI+6nLhZW2nzVCEBaMLd+soIGqjD1ampdugiYWCpeBKA9bBJC9ActAk8LES26SqsftInLZ44dQif4Igdhym5WLrPDyuYH/7HTCNwDnPko8LXrBccjQaioe6BiKad3+QY/MGTH6rS3OBvCnQDuAIyqhiDkQ9RX+29yE3on8IwjxQPI8zkTiApGU3oVkD/4fGDieAuAdMw5MFQjEgg1DYsUku+a3uI0TGBfV7PotwHwaOEmbHEATvuDIutni6UAQoFRIFRYhfe/dhEw7tbe9Of0Si1g8HkrwRcevDajz07gIJ7n05rYyWIpb4ya/7vv8PRdFpj/LXDmkQLAnA4jCCOlTBRN/rFMAJKgkkVHpGUjySSBSFeg7/azqk8EgbSEq8UDRACLKDXSyaQ7Br//DcA4LSCtwnKhTEkQcmAIQhtM+Uaajl0uS9NatITXWzpzfcdNB4DpY+6nBgDaCtanYLN6fCj4u1ay0QIqtML/EYC61wSA9tAJeP6eWsAoDysFpg1eB0HIQRCIIkVeCqQf/05P3WCB+UPA+CPAzvmCaFWDKEuYcl1yMN+Y2dckqGTeHPEvvWDSNhOAfbefX0A6rS8CUw8X9066bFIfdqMHJID++DJgLACQumyc3gyAEYRRKFCLD1eu5ODLF6QvXedx0w3A1BwwxdAJLTXjd8seQnGrZ9bPFxLyA7WIKON63tYtCQBN/sv9QPm6BkLp0vl9t/m6ietR6fbyBA4gnXtORwRRpNnTtPpW6gWLH83lKqcOFTEnDiKtoHwy8RNFhrefyeztbnrBfbWfgttsP+kIyO32ELD1cHHvInrlvWs6TsnB7qAUlg/suFtAWkE55zYQ0QpqcALoNCXTEt7A3KoaDwGQfqoAOEUBa7fUbKctltwCajVbxvSiyvoasM0BaBKwwdKb9fN7NfcqBWGiSWykWXER0umeacUEonQgCKRfIgDFjya5yq8Wfsfs8dYgiuMxgpAg/vnMzu6mF0z6Zj5APdvPQec0TEosnvQosGOhaLuIYvnwEYSithE52F1XFAA0p5yigD4otCqygFKnpHUpLYP0OcKURYv6Mj4MNR433QhM0gL6QongawOg+6rl9CswKoSkEIxPyTsuAPigCYBmAXVfYcVf+n0SRYw6dP1YwNgHsgSajiJP429RrpWOM6cxDiJB6NINM4w7LbUGMQUwB/M9mZ3dSy+YVG0EoBiDBST5ddZ+PkCsAiIlQZDa3LVatJ0WXG2PbL98AB+4omB3oP/HgTUhmGgBfRqWf2TTrUSjExDSP/qWzQDgfAFAWyzR8rkFtDAKX75jo6nUguZxZ8NByHbvvqBQ36T1swcsBaBAGGRg40Ir+rt9WUDhQ5ZAU7Es2e9LLzglqHRxNkbeuW+oQRRls5jaMjnK0a9ecNf2R4LAwO829kQB3LTtEYQPUwzQAWgW0AGo8AQH0ljp/V17pm0KRcEifGuNOnocO1rACQbKPXhs8TtNwVr5uh+n6Zf3wDgu29g2FdMtOc8B6PdpFj08ZFrplw+ZA5FTvAQQ0/BT36FPDkRqBT9Jag7xYlQItY0f88j78sZzCcKPZlrAQfSCK9uvB4h577SCotUiEJ8opq8IQFl/PUBPEoBLxbRE62LSqG4dFB8r5bHcOtiOQSqT5T7RKzYDgJx+BUCCTxZQCwhaQc9oKcEnEBKknj5FsJ1LAPo9xoWWPWDy+6IIoqbeaO0VA+zHB0zxIQDKkn1GgtXiRxMIAx0Vn0Db+lkuFjLRCt5WEwD71Qvu2H5OfekD5FaciQay/GIbFgBXriwAyGmJADR1ck3DwTE3TQ4B0LetzBJErTYAr2BBSI3HTS8tLKBZPo/fWQDZp197Z3scjGb5BDp/L3+njMweB6B83Gj9wj3atOsPWin9WgXCFlVO/3ctf4iD8XkBkH5USlAZlNPZAQqARr5vxu1yjmH0givbX0UQKI63o0Wun/xHuR8E4VnPK5JQLd4VNttTBvK2uoiKOUf/f+GjwMNBh0NMV6J0c0NpcRv7mrYv3kh8/uHxYp+bVpwLp3R7sts2YzouSq3KGa+q7+x7Co4nazAerRKsVlV1QitF59dyyFZaYY0HMu9mWL3gtvZXMbymBIFMZ1ov2h0B+LTLisxgW+Eq5uU92iZ72ud9vvR+4JFp4NjkRh2ONi0OB1/UBCkvEYRhfuNs4OmhhiPKnFQlx6aAjMnSXJUAACAASURBVPjmz1w41nnwO4cCIBvBwZgTAOUHRq3gyDExD4zRGVYEnpm5LqmQc0M5esFt7acFl0SlHiBxuTkYxxdaihUC4QVXFu5FCUD5QtJl85sjGA0ziQxqeu/fem+hw0F2fLLQGxFlYMRvo7v1WmIVtpt1DFkXvOR7LwJ2HSkyoZmEypoVVe8p7b6qEMnidGG/Vl/L2aPOIwuA1pAIQE3DAmFa4j9f7CPaFpCHKujr5xzZesGdHqAqKz5X+FLRAl58le+jui+kTBALMcgZ73CDBkpN2/7+bfcWOhwUyCEAjQTcAVhKdjkPc2RajewKyu/n1//qJcA2uhBMRGXQOcn9U6JIOjXHQqSYOsVoQp1HNgAvz8yny80H5PVz9H6RqVd849WtXQ/zA0Ow2ayGLJ474L0G79vvbulwkJi8BGCg4S01SKqofoNvSIC+5zkhFUupV8rUTpJN06KpaBkFQm5M1HlkA3AyM5/u9Zl38zrk6f0iU6/4hmscgK5ISUtCTowyDqb7UxwsqFJW3fo/vbuIBJEZ1YRgyHwQKNi0KEl1OKTCZJdxtPDn//v8ooaDaVgqFyiTD2IKfcjZS4Fo+7g+HXOPv84jG4DIzKfLzQf8KVfI/FNKrQ6h94tfz+vOA9cGAAbrpylY2SDlVTTt+uCnV3/V3a7DQQAysJAwobZJgUXi78Qayhd812WeiOAZzEyUiAkHMeu5BF5FwZQAWLPwknkLQy9CrPMy8+lIHZFzvN3T+YbV+8X7c64OHHix74V6zIxB+RJ0wQ+UU992tYoFy3fcXcTDxQkoPsCUhFIczKVCegSg5B8A/PILN9ZwxBSxtiKiUAOi7JW0dLTustF8AGbm0/1o3vjjnSGdj+lYlGwdRO8XN+c1wABIoHk6k61yuSCJITq3jDY9Vx0BqK++uwAfX6JkI/hME0SC1EGguiQ+isqcQRLrF6/0jO2w+6FMnZhyZYsQ1W50qOHgPX1NXndtODsfgMwHzMin+0+ZN0S9YOllMzWfLwKQSS396P3iY3kNOLDPM1y065H4gOW3p4uTDkB8zWdb7FgbdDhEgJkCUDRvogTmd/vPv3BVAUBuvylNzAAYi4hisVQnEHoIqWblrxqm4Mx8ujfljT+YjsWBYgIOc0oJPsq1slCpH71fKybJOEoAuuVTRSCnYlmU6P/Z4iSJEcbLv+Yu9/1EAh7JKEXDKxq4ChUiKymRbwjgHdcUWTARgLYXHSr2LOU+BV7MVwzxwOfkOWybYAGZD5iRT0edjpxD6VhcOQ6j94tP51wdOHBdMeXa9OqWRcmWXA1XLUIUH6zyCwlAs3z+YBkfs1u+VIejJEF3ckrjI9T0y/aMA2+/tgAg08VURKT8vbKMUgAMIGzzAcOi5HknHQAz8+l+MW/829KxhtH7tTz+jIMAJPCYMULAWd6fvi+EY9ouoZBM/Kx/4LUBgFLgNC5o16FrE8JJVJgkiFhaQQBv3+dVbMrWVsC8UxFRkjjaVsW2DtRdOJ/vAyohVYK7A+bTvTdj8HlqTMcaRu/XxHkzjgNkIOWuDr8jnYYDKDutgpUhra0uAlAyCCUAK8BXcjBXgLCk/h0D/hcByDxFAdAzoFUqUBYRJTUcMWdPP7ONL6i5bLQeALJRQ+bT/W7G4AuAOXq/lsGdcRgAY+glLkYclJVTsa6ptCX3uQjAKINQstFrAZKIwWxQIhIJuovB/Nx+r2LzFCwlj8Y0evl/MYk0kieVtcvrwGUnHQCVjjVkPl3mItQsIPuElx9G79dOzDgMgGkAWlNyBJn8xKprBRC+zgEo4LWRgcdVcOCjjlNvmx84DrzNAahaFZWLygKWxUNibIhTcPD9BMLLa65bzreAMSGVoXvJ/Cgh1WUfO+XTZS5CDYDs9GH1fnOrIDcAkABTTDCCLYK0Cwi/586WcKJUiEpC8CCBYDsiiSplqUIUmOjf+o2tIiKVUJbgU5uSWl4DWwX4+PcXnrQATBNS+8yny1yEopdcay+930y5YhgAg+9n2OoUeI5TdQer+32fdhmGoOBZanBo+g1yEKU4dYgFSvqB//vZBIBt9RshkTbW8ZZZ2hUgvDL3iU3uux4LSBM0ZD7dPRnTH08VAIfV+2XAOucQAMuVcKfFSD/+IAABsEoGwYAoHZIKEEYxRIHwLS8pUuhjFVs6/ZZhIVWyxVKBBIRXnbQATBNS+8ynI4tBzkEACv+chlUVIKE/5cRGsWmlKfIzudc3APLQSlg3E2OCyVRc1kpU3DgBmKoQsWtlBcswjPu+nfTYtBL+GQdgOf16GCZW6pXlBCqWSgqJypoOAFfXXDifbwFJLvi5HAjlnUsiIe6AjOp4iQNQHRlT2PlgJCUbbc2s+v/hFwFb/q7gm6HlYpBbmTV2sscQyy/qFBj2v0/cAdz/HGD7NDA1AUyOOU+1CwWOewNjKj6/O03F1/WuugW4/XJgfBoYmwDGdH7IxB5kLPIB+I8AfNwZgga5ck2fJbEm8V9zNWPfrasbgMuPAcuseJ8Exsb9FdBhA+7gaQNKB6TfcgCYug+YJT+g89aoBDMmIMScP12uTKj13uDv8zsKig/uJ1uQOsnojm3qB5P5ACRBH3OhPuzzRN9DV88HqQLEWPJnvTy5nm/t/1s4BcuSpRZtGAu4fi+wtBVYEyccrYwn6hF8/FkJp9bKxAKVFsn/d8urgbHPA9NPOEOWl4+2cfoFHhfVrJTZPKHSj5daOtup6JyCpPx8rHWRVQ7WOlrYCMx8AHIzlxkALPD9c0VB+x/A3E/+E2fUYHXdF7KTGwdvTd0AHP9r4PgWYG0KWBdfsBdsMPfPrKKsoL9XAVLAvO2fFylCE4cKliyrDVZNcGS1CqEYhWFiAZV+XntaURdTLmpCEbpchTYLqi6NrkMCzLzt5Xc4HwyJmmkJ+Z73jQOh4NWeDUZiK1K08f0EXt7CMHVawIk7gaVpYJUA9LI1Ao8bzKX1cytoFtFfpdCIWz7rgzHgth8u0oPGDwETc8CEMySUzFaikgtlpW1Ta8JqNba7lVljSRgW+Q6ZP/57WQvj6fydBjXfAjKbgEvMLwWCvhNoipgNpnQshlS4IGFWzIk6ylWwAz93ETLxGWB5ClidLABoIOS7pmGfG+33YAG5mND0G8F4678vkiPJczNOAC4UyQm2N8w94kirFlfIAl7i402d6dbPWWAtrsjOFiuCvAJZOQE0pHTFsckHYDeCvhNgipQNxoAz8/8IPr5nbvH2jd+6AThJAE4AqwTdZKEBLDoDgU4+YVkPHIBoPwareOt/BkDexsMFAFnbzNJYm0IDnVwbt4uyur1kwL7Tp+iZM/08WT9Rc7DHUmuYTr/x+6o4ovvu9fjBbgR9JyA+omwwxvZI5ULg6ZW7y9FPf9QNwKm/CgCcKABovh8ByVy/UCtJq2f+X1yYJPGU27lIZLbuEWDsWBHesZeDz4iURLUWa1TE47LqK12fZmd3OXidFctqm92KatVs1jAEsNv6sdymaa2g8+xUL4I+Pn2beCgbLGWHI/h8G3oTr45iK86POlbBU9yKI/AcfLR+ouQwH9BfmmbLlTHboOnZ/T9+5vaf8FUaAThXsFOQ45mUcgZCWTAxe0UQ+urYMO1/37GtxQmoLCBtRSp30LrDp2SFdzYMgk/R+VNwvwR9mwQDsaspGSfJgYDYNTbp8psCQFJxEIBkQjDrxt8dXCUIY+COH5MVFPi8SOn2n/QYLZ9Gp0cxANIP5IvAkzVzxivRydnKNzBa8fddM84b6AFyAriMF2pajk9kYIeoClXmA3AQgr5NQEHMBqMVFMNaIOayNRL/vhlH3RZwmhbQQUcAasrVVGz4EtjCu/3dfb/ID3PbT7uKAZ/MhcIC0vqRTo4W0IBIEAmEtFwCYqjW03bcmdwBYeoWgetUbrR8snrloiR2drpACf+rD4D9EvTVjIJu7HBV+781X752Czj9lwUZkTEgcPoNPp5Nv4oBRhCG6dd+1DkMz1JIhR1BAHJ7zwqO3fIRRM5tmDK5CoQKsSgOeBYBKFZULTqcB9r6Ni5KYmd3WKDUA0BlhNLM8EbT1QBXBU72aI5ZjUcVOxz7WLkQ8d37vsart/uA6RcPsxNSAtAXHDYNC1AEpf9s01kKwuBwGU7HgVt/1jtD1e60fgQigSe/j5bQp+KYpGB+H62jT7P8/ZypBIC8Dhcx8eY9wF015abhmnoAyJ5WSrKeNgKO9SHxnT/LSasJBim5lRjWBEIVeROInKL1qunybRawLgASdEy74qjaNNzJCgqEEYzBGvK0297mAFSHEIB6ebKDgc8J1ksmV8t29f1en6L5v6cxIK5iK6Xne/5jCTiFcTqVn/r/tWDPWwXnEPTVgIKUHU7ljASawKefIwDpMdRxRB+wFgD+RREDJABpwSzz2c0LfxczVjkVKwaYgtBBezu3SvX08d39P5uO3QKahXMQciourZRAGKZWar/YZ1xXRPe8wQr2AUK7TvbOVTZBXx4MBECRnConUBSFEXT6mf/TK+/qmzAF/0UBOPqBZYF52HrTFCw2LH5G8UCzJEko5nZqmRnPh/uCXmpnVpDTsIPPwKApOaSA2QLDLSHf97iPx0tpISLfz7bl4iFfsUsnj+HZWEeOYDCDnDmCvZkEgedcCjxGseIhBYt3vx049HwMLRh8gA9gh2MoH9ABqKJzxf0McO7XlSAU4HzhYYFq+5D7hwBu/98OQLlIBCKnW39SlXNY+nqeiq2dkQg+gnGPb9/ZpT0lq6MV5D96gLCwgDmCwbdnCvZmCgY/dxy47xxg5SWuUjigYPHFbwA+fyGwfr2rXrMvPB+vp3L3GHCgi9JOHQCkRVPppeUBigXLFymyejYTB4YsgfA20ofRAlYB0FfAlvQqP0/TsX5PLOB5DNu471cmIwiBaRww/F01J+mz2pqChxUMZvpJlmBv3iTocsW4dzewfhkGFix+2febXDAeJO/YEILBB7pU1g8LQFo98QASVGYNQ6DZfEG3fnEqrgLhbf/HV15anbkFNCvohWSl9XPQ2XTM/2s3I4DwPIZwBEDfgitH0Ek6N6x+u/iD7T4g/YdBBYPpWHEaHlqwNw+AQa4Yj54JrJO+aQDB4pt+oCAyYvOPEIQDCgYfeF/9U3AbAMX7ItAlVtAspKZdz5SOlvA2pstxjES3wJ+92NgAGK2gwi78QoVfEhBeQACqNNP1RdoA18kKdgDhxkUI/zKIYDCnqyzB3jwAJnLFOEIW7QEEi1/1Y21ywVglCAcQDD5/Efj7M4CVrZ5AKlkhxeQUaxBI4nvFzxf8IfCVC4HV7cC6ZEX5nen3VX1vAGLZq8ysrvHY+QBwbGfI2E6JpLvdX+ksthpUvQrmX/sVDGZVUJZgb17vJHLFeGQcmCdVb5+Cxd/5xjZ6QzzMLOQBBIOfTV2Ps4HFHQ7CLQUQmUrV0rgKJMsCjsxGAqTn/hzw0EXA4tnAyg5gbTYBorKkUyLnkB9YVhTxu+kT13iccwtwdBewPAus+b2ar9xJAafqfgMQO4dh+J9+BHe5gqZZZzYok1JJUcpaR6bp93P+W/N6p0KuGIemgEWKgPQhWPxdP7NBLhiHKYHUp2DwpZ8rLOD8tmJQVplOLxAqmbRKC6EDYC7/CeCRPcCx3cDSrsISrs04CPm9ArZk55UvKAspYLqPaPdR4/H0g8DRHcDyVr/X6VabLHk2PhjpPVZY7d5xwF6CwS9y/4LbbVyQsEKIufGiKe0p2JvXOx3kinF0GjhOQY+oNRtljji9TQPf/fOV9IZY4Gq4D8Hgy/4W+Oo2YG5bUUy04vUcLCqSJVRWszJbNgxSmMau+q/Ao2cBR88EjtOqbgNWWaTkIFz3YiWrF4nAjtN0nBZrJnU+/8PA3CxwfMYB6LUra3oglL0tps6wlVha5rLiqd9AdDfB4Je6U0s/0BXTDYh80Sr2FOzNA2AXuWIszABL1JaKWq1R+nwGeM17OsoFY5XTVw/B4Cv+Djg0C8xvLYqJCECzgsxmZlq9T8e0XGUyaUizavPtxoFr/zvw2BnA0Z3A8e2FVV3x6c4sqwObckeyhiXAowUSADhD1XhceDMwx37lvU4XxVN2n3rJIocygkr/Vbs7fe+EdBLcfaXXQ3IPWIrpBB6XlnwpR76jYG9e7/SQKzarxM7qJFj8mg8UarMV9IZ4gvNDD8HgKx8HDs8A8zMFAFnPYQPDl0Co2g4fpDZLqKCxT0/7fhJ4fCdwbFvhRiwRgJruCOwUgCpeCvUjZmEFxhfk9W969kW/B8xvKQqnVgg+B6CB0MsI7P70AHgmd2n1NQ0rv7FvALIlVYK73MnQCDLThSGZoDpuP7uCeuX5n8zroB5yxThGnQ0CgyBMxY63Aq/5aBHG6EBviDlOLV0Eg1+0AByZLgbl+HRxnZXJoqqttA4ODovlJZVuSjTQFtq+NwNPbHMAzramdVpVs6wEoPtdNg37wJfvsYiJP9NFqvHY+7vAwjSwxAeNxVO8T6aNVRRRlT6hHrJ0Ovaw0WDJCKng7g86APvNB9wg2JvXO33IFWOBgn8EIf2nRLD4tbe1+AU7yAWbZeskGHwVdd2mgAUCcNKnJgLQrZ/V9/Jnn5JUYmnAE3hCmv3+t8AWQfSzyPK/POOgJgDdsgqA5nfJAvLdLV+bz0kK4RqPZ3wQWJxyAPqDVhZQyQr7gyaXI9axWCFVAGLvRUhV46PgLnUWBs0HbBPszeudPuWKsTRZAJDTo8l8ui/42juL5veQC7ZpsEow+OrZQlqVVuH4FLA8WVyDAOTAmHUQCAWQkOlsQAwDt/9/AE8SgPQpNa07+AhAA6HLXbb5Xr4IaAMfv/eGvP5NzyYA7UGjBWTWjh40v9fSyscHLtaxhJWxFVsNNAXH1khw983+DYPmA5aCvXkdNIBccemfceooAfhAAcA+6A2xLuAGucxrzgKOMexDfV9OwbS2BB/BEoqLSrBoYGgJ3E8qLcIEsP/ngCPuUy7S13L3wb6PU56/m/Xj4Ps0TKCXQA6AXuNeZY3HMz5QANAeND1kwcKXlj6wOZQ+b7R+Pi0PD0DeFAfk590CKg8qncfoFzIRVWVqfFfBhgn25vXOAHLFWCDbvPstBsJZ4LUPt+jdesgFg+qVptWq11bg2gtgfuLiRAAgQeg+oEmsOujsXb5SsAoCIN/3vx04OlNM6Yv0tdx1MKvK7/TFjVmeCD4HQQQhf159eV7/pmc/kwCcKABoeYvR0oept7SEoZQ0Tr1lPuPQFlAtO0nyAcWhpzw/FSjFzGjLx+RGvxzoSeC1hwsA9klvaFN5FAy+9mJgnhaQ0qqagglADo4c9AhCDpJPl5ZommQ8738HcGw6AJBW1VecZv0cePwOY0/wl1lAD/WUCx0mMlDLr8bjmb+Dwp3x4nkDYbD0thIO5aNtfmDi/xGEeRawxhs7Vb/q2huABQJwAlhyy2cC0xoggjAAUCWWAkksOiIY978TmOOqeqqwqAx3WGhHK06n7TDwOcAV/iipPAKjwgrZm2o8nkUA0gKmAHTrp+o9MTrEYvq44o9pZIOtgmu8mafCV72YAKT/RwAy5OPOuVlAAk9Oule6xQRTWUKlWtkU/IvAHAHti5oIwDK841ZPFtCmdr0U8PaC9hVultd4CIC8P2Ztt/m5/qC11TJXlJDGGpfGAmYODgFoCxACkLpuWh3KCgqE8gNVZK4KtxgjJAB/2X1Krao1rfN7CWZf3LSBT4uAEIyWBVpipL7GgwA0AW25GbGENBTRx3rm1M2w39mmrFVwjTd1Kn+VAZALEE5LtIDyMWUBvbLNLGHgd5H/V07BDp7r3uU+Jadgn3ptxekA5MBri0/Wp4wzBjDbCnkMWMqVpE8GJwLQqvfc0pqbkVj5aNk7gbCxgJno30cAjntowtXNaZ1suvSKNhsYTcVKmw9F5xGE+94dfEoP+JYhD/8OC8eIPUsUHokVVKB78XszbzAF4Pvd//PCKVGIpOAr78mn4DZOm8YC1jco+w6EFTDDPJqeCEBZBa5GffVbhmQ8DtZW5TYOvPhXip0GTuu22lTMLSw+aAVl9QhEWjurI/aQiLJkTMLsX9R3r/ymZ73fp1+37OU9hunXSkdl7T3QrhKCtlCM59k2i5CMMSIAGdqxEIwrmptzTsCEut5yilKoJLAcxCq3fe8tLCDBFwO+tKjyuxSCMdYEXoeDrHcHvu0tTwLzmwHA4N/Gh6zNCqqeOSxC2lb8tQSiMwbuqXIqAcjFh2JjBKGJyShQG6ygVbfJegULWBYcMR3rvb6oCRaQwFPgl1M5rR7/JtBZOIZWx/0+s4QeY5z/1/X2tFnAxPpFELaVkdLN8MWGVr4pCBsfMHN8bmTKfCjZ0Ncp456/x58zLzfw6Qf3ABd8pUgEYmqk5bGyek06IQl1bkXScnlN/u8L24Gdx1qVq91KQvrpgwaAAw9p+wnXPw1YjyWMGtDo2ASOFGMU7SIEUzdYD34vMPmXwLbHgdkFYAtlGiim6DpxJtvq9LtlVr/aWKEB8pUXAOOPAFPzwBTZ9r04vdQ9Ts4pAZ3cd+yHxgfMAOH+vcA69/9Uxijmz/AerYpdar1lNSMYzV+vWY/34I8DY58Gph8Bpo8A04vAFEFIknIHohGVR62QhFRSYjQE6qFri2z3iaPAhHNNlxKwArI0Q1IAxwfReacbC5gBPp66/5ICgLKCtqnsrKKlrFZUFPKOr7osMTtdsxzqQRZ93Q1MPARMPllohUxRqkEK6gShOP0S+dY2hlRv99y+ovRi7IiTnTvLqmg6xDPYpqAUgRgsoR7MxgJmgHD/c4E1FXu7FRRbvEgd7evXWlbPpp9EgUjiJpwe6zwOMlvpAWCMVusJYPIYMOlSDZRpoGiNxKzbdIQlXONMWJbGtw4svdgz3El47nzTRvPrrKptAJT6ZrzfintvAJgx4vsvdQvIXK5VYF3sUZxmJUvgA1FOvwF8spKyBtM1y6EepI4LqVMedbEaTp0EIKdPKh5FqYYqSxgo2jgFr13j6XXHnOiSZOeBVSvyC8qC2r05FVvVw9cAMAOA178AWPMp2LJaaekiCPXExwHw660n1oB/niGQazwOkkSepbJ/72I1x4CJ+cJ6lYI1riccrVicUuVSmIW82pkwnHHVOKbFsOozQGkFkwewnBES37ABYMaAX39ZAUCCb82nIlo+40p2gNnvsoKunxH1xGwA/LOzdQOQJPIuHzV2GBg7Cow7AI0l33XfjOsv6oVodes6ISbBsAZMX+kJxU56KY7pkmFVhOciuvTzSt05v0+ryuT/9gDrZNe4wPMsI7VJP3GcP7gUOOdvgL1rRYJ0ZI5IV3hV4/wrGYPPU3/AiRhYusy2K7mU999P+z90ObD7LuBZK0Xdkeq9NSX2+o4HLwfWlopFCC0fgciBMtAFC8CGrYXVoVjnU2G7rTXrzh4kfRzLY1kyGwBoeiGcPiXb5eAzdXWnazPCSScb4j3xfmav8Cx2p50lAMW0VXINitCogl2r9H2dcctWwQxQsn6ZTBbMNtcgdKIbiZj51VcBk38CXPxoQcfCUg8pjcYgZScw/momACnXyr4leBhs5QaBTHpf7X8dMPYJYO8XgAv9e8QJlAZZq8D4xSuANYKPJQn0AR2AHKy1MACKe9nfFI6IEqduEWoHIJ9wlsVKLekoMCa9EAegSTYQeM4TXco2SEMkAHEbBZoj4bbYtdyCVrFqGXgTSxgXYTZeHLi9AMjEQRCVUXP/n4KUaaT8vVTi+Rtg7GPAuYcAWlMCgUVkQfJ2Q12yBvPXMwHImhDWwf81imsTiLSEvHZkr+jY/p9CQRD4p8DOBwteItai05qn31FFdfLlFxYWgCDUIkRkj/TxbCEi/89jfPZ3X2VqYSJQbmUNQY3HQT7hbv2sLoerVwKQHNEEoCsm8R4MhPRjXUGzVEIKIoY7yaEYuY4dgGb5RXruoSgtSCLLarkICQ9f6QNykGjFdjsIBaI4kGlt8W+Rg5g0HJ8qAp47nihAzFpuWtPIMBZJlASILvR6fQ0DCVbJCkJOJCqnk4pGpb99tZ8MopyiKDX7WWDiwYKXiEQOehCrgKh+eJQ+EQHo1Lby/zRlyf8TIbf9XS5ftIb8I92YugH4ay2pLusorl7dAoonWtMwQSTdOFuQSLTGHyIC8kxSIQuA4hwU2WUAoO4/grBcDbsfWElSzg+JCoYDoEGM1ixSkHzgF/wG7y8sIa3J7JPAGWuFJSQIaU01iJHUiYP4e33BrPOHmG/JMaOfTZVYRhwGav87vWKPJ9/rSH4IOGO5sITqg/ggxXs4TOaBAECbeoOsgfl+DrQShFqcEIhyyt0MbMusEkx76iAZXKM8BvXiZAGlF+KaIbaadYpem4aDgpJZQz6YJABV5VcHAJZ0v4FxX6KG5UpYs0KnqjhRuagEVgPglYAl9ciHf8mdUrJh0Qx9vkDBzBywfbkYQIGwahA/kglATsHsDzKA0BATiPyZ4NEDwIeoa/uFYKKXL2f24nQoIgd9R3yQCMTFqwIAfdBWI7+yB5ZLECYLETd85YJl+2YAUNosLIel/xYlu4Jsl6bhNhD6it4WJCvA2Zc4Gxo73RcgJeOqFmGR6rcChLYACyGojmEYdj59KnZ+tIQRhH9IvWA2hiREjDeRI9Cly7fMF3EtWRFawhQIf5IJwE56wdTIYdt7tp9ys1K8JnoJvod9Wn682PNkP4hUy1ndWgstAtBDMLYN5/6PAc5DGNoF4SrZfN+4+IhT8jqwg2Cp8ThIJ5vfSWBXAVCrWN9SMxDK+skaOvhoAc8me654pmUB3f0wyt+E8FyRAGmPlOEoiSD2qgvmAKoOm52fAuiTDHSyIRxx+lI0QxxADubfF5vffMmSajrWlP7nmZ3dSy+4r/ZzAUEHnQ8R70HsXlK+PgJsW68G4XYGZj0EY2EYATCAT6tAhmE0DXcC4faapcwMgAIfLb0kuzT9Qmw5uwAAIABJREFUSi+EfeALkSrpBovbrQDnkm8wAo8/E3i+CCsZ98NCpAp8cUekZyBavI4ET/TnaAk/RQCyAXy6uNSPA0i+wMeB6ePA5HFgZq2wpNGK3FUDAHmv3fSCe7afX8CB4UNEEOolVi/3obastNwJ9cO5BOBKEQMsAcifHWzRAigWWAlCn5K2bQYAOe1KMjTIR2kRUhKVS7IrLia0v+3xwHMZMCbYNP0KfG79zAqK5DxOvyEuWu6VD5KSHy2YAEQAfpaRdl5UkuUctIpBnCIIl4psD03FtIIP1ADAlBuJM47EqqUX3LX9kSBQcuuyftK78xUkHyQ+RLqHZ3Fv1KcgLj5kAQ1s0Qo6IA1nHhNLQzA8ZxvBXuNx8DcS5UYpNnoYxsCnUIqvZo0F3wPTMa7Hv53HOJVbS/l+5bumX7d+5WLE44hxIRJB2NMCqj9ixwuE90svWCaIA6bAp959EKeWChAyA0PTOV2unGMQveCO7bfqHbcS4rJR7Ewqnw5AWhLuImg2uFQAXAVs8RGmntW4+g2hB3P79L/EJ9zGvqrxOPibiVihAOgrWQOf/EBfBcsPNBBqW9Hv6zzGqFzmoXz3B9AePgXiq6bgiv4YOB9QHS8AfpkAFMMjrWAcQA0iO9XJiQyAnos2vV7ESHOOQfWCO7Zf7F40mZFQScRKAYBaSU6vAVcTgN7xXHiUFpDTMK2dFh56912BTiDcvpkATIXzCL4g3WXTZ4jpGfjoF/oihL+fx+0yWUABLwIwtYKKIabgCzHQvi2ggBKn0McEQDaKT5cGkIOo6SuyYzEfjQB0EM5nZgAPoxe8of3sgSqCQM3jkdFLvpRvR13+7UVRuhUFSavNO6otwp88ZZ3+t4M6HLtch6OT9AG/q9cmtf//gV1JDYcnQ2zY6/YakfSrU+Pg1M45NqPt3IEtoM7WFHokyrWKkooglCMWLYjiUXMtK3g8Uzd1WL3gDe3vRRCoUEYCwGtYFxxqgA2E/jI20F5hhmQod98BHNnlxOTig1aGiDanO21yV4DygWuB8YeB6fnC9WEtiKVVKeE0ZGiXWczeJoWMIig5a9V5DA1ANoKDeDylZ9NSXxyAsiKawrQqmCv2HVf5e8aRoxfc1n7xs+khItAUvojvyWryxVcWJZksVSyZoQRA3dcAoHzax4Gj2wtu6FVKM7gMgti02jbV476oUJJs1j/AbA1mQ3Pm8eTRsoZDtR+xZKCiEKmMXTIeXHPGdhYArX8FwG4DGMEnAHIK4yvT58nWC2b73cexaZgWWaEKgU1gjNbPP7PvOYGsUSBkv3hBtmRWNzxjTk9RWktvxp6POj0vARjY9sWkFel8RWxegjIF4RjwAOnZWMPBTGjqvHmszxJOBUD3xyznL2bqROvoP3N3q84jG4C7M/PpcvMBef0cvV9k6hXv+2Yno5QfGArRbaCC0mWv2YtF3ecerNDhkNZIIsXQRv5dlTtGADJSz2gEE1EJQM//026HdIEZLC8B6A0tk0g1Ja8DuzJdphS82QBEZj5dbj7gxZN5er/IZI+67pscgE7QaDOUMyC0Wb8+gXjuR4F5J6YsaXnFhBoAGEVvUhb60jISgCQnoh/OLBgvIrL8v7DdFkEYM5dtNg97tvz5zJqzdfIBmJlPl5sP+DJP5xtW7xffnzeh7H+Z+3+RpkyWT1YxuURJYVtx6T0fCTocouQV85VkHRIGegEuEv/YKpkA/JceVmL8kv6t5/9pu62tfiPWcFQVEa0DZ9WcLJEPwMx8uvfnjT9IgZyj94t/ldeA/S9tMaGa9SNdmsIxbvVscVJ1GScoMt4UPwhAsmMZ0aXzQBsvdGRBjQz0FUpEJRAJQOq4KAnBdz+sfiPJ3bOYn8fsykyVWMfiN3BOzckS+QDMzKe7OW/88aqQzsfE5kH1fvGjeQ0wADodmVGwOeiMsUqHrGOnS4UFy9P/wAEojkEnI+IqOIJQNLgpCXhcmLAtD/D+kgQE235L93tj+YBqgTX9BiCeW/NedT4AmQ+YkU/3sbzxBymQuZhm8g1T+QbV+wWFdjKO/Te2mEFNlCb6gPF708VJ1TXHgKd91GnZpDfi1k/gM2vqU3DUnCuBmNQe3P9vw6pe229KOvB0K1k+ZS+rnrfM2AlA3JMZtah/EZKZT3drxuDz1O/yxAwu9JgJxr3lQfR+8aa8Buy/wdWQZAVl+ZzCrG3q9c/YrkmHy3IRYryAAqAkEBIlopJxNNUbER+fA/H+/+AAdP9PmS9dazicJybm7mlB8nR2dI1HvgVkOlZGPt2nM29GCamcGZjAwlQ+vvrV+8X/zGsAAUiLVPp/wd+zaTMFWw+/kAA0GQQnpCw5mDsAMIrcRB5mC/+MAffTwgfwKY2KfmCZ6ZIkUShrxXxBX4yYaV8Hzmcn13jUA8CMfDqWYeQcSkhVOl8U6uxH7xekrsg49h8oiCENgC5TUG5vKxxT8f2aRtOtcAKQ1s8soPuOVUIwpchNlEEIOyNSIrrvv3hwnckWIZPZsnbcDyzTpvg3lU8mpZQqozyfK74aj3wAKh1LgrsD5tMxiz/nkGD1sHq/YNFOxkEAcuW7oqmXlisuQOT7VV2jwi/kTgj1RkoZhBje8Z83SCAEEJZW0C3gff8tADCt4VASaWIBK0HI9q8BF5yUAMzIp8tNx5Jg9bB6v/jdDPSRns0BWIZeUitIo9IhHmhXTvzCPQddccnZ76U1V/IvC4SBCFyg26DFNg7c++Mhhb6qiCikT7WVUmr6lYn2nRKyrdZ51GMBlZIc07GUBdMjny6XCiUmpA6j94vMZbgBMFo552pu27PXAqXTyAUQcitOQjAm9xX0N9pIwIPmSCmH5QuPqER0L4kDYgp9zOUL6fYxkbZcFceyAreAF3GlV+NRDwAz8uksnT3jiILVSmpWNlhMze+k94vMZfgGAPJeHDjpCrgM01Tdry9OzvmYAzAqLVWIwEShwzbRwwSEn+MqP6bQK5tZlWyhjCCCsC19Xv7gOnBRbgp7cu/5AOyVjqVMmA75dJZ9nHF0yohWNlhMxKnS+0XmMtwAmFq4imnYbrEqNJPc+9kfd62RKh0On8qV9hXZ9askEPgAfI56ziocUgVbzGT28lEtRMoKtg7lBHtznfZNA+CQ+XQWM8k4uglWK/NLYKzS+8U9GReXD0g/Tyvh4Ne17Yb4Zbr6g6y7/aNWcoPpjKRTsJIags5IJwkEAv6en05S6GUBfRWsUExZyVZVQCQwrgN7Wfdd41GPBczIp8ODeXfTSbBa6YYxlY8/p3q/udc3C+jTbtvqt2oadnB2m4oNgMn0W0p+hYWHWbwg9yU/0Kb9EIy+5y2hiCit4UgKyTeAkN8Valk4Le/ldlONRz4AWWBRM6fdIPfHstw/G+SE5rMnVQ/kA5AkLHS0ak7V7reXfhgACaBqDtD3e/nmc5k9kA/A80JReq+U38zGVp3ObJo/BvAOD3dtwiWar9zEHsgHIGlFubqSx7+Jja36anLLcDvvgwA+NDpDfILv+qlzuXwAXuSjrkKemlO2e3U1uWUYnL8dwB/5e2apca9LNv+vsQfyAUheX4VguB+mzIsaG9ntqxhF4Xbe3QD+n7/uHLAW9wQ1tblMRQ/UA0CaHC7plXEh+q4T0OWcfhleYTSHBK0EH/mi+fcRuKQn4I6fWpeoB4AevCz3HOOm9yb3F5mBlZBNclYCj1aRfyfrbgPCTR6AzK+vD4CyglX7jpmN7HY66d1E0ctdIrEEE4wEIMlam+Pk7YF6AMj7EwAVbU82vTerCwhAXopJN9zVI+AYrOeULLZgErY2x8nZA/kAJGWr0naUWdFpy2cT+oCWjpdjLFxE5UzYIBBpEUX5nLnlvAktb76SPVAfAOUHpiAMm96bsVtCAMaKALICMyxDq6cXfycA+b/mOLl6oF4AiqBRIEzBp7/X2Af0+fi1XIioMIlAI+AIPIGPmeROWV3j1Zuvyu2B+gHoFfZiDS2lC0LiY52WUADkQoTTMH1BFSYRdHoRfKSu5v9qrizMHYPT+vx6ARhSuDcAzzmDo5ZGHT1PAKYMwQxME2jiSo/gEwBrrq+u41ZOy++oD4BaCcsXTPiSI3ey8s4KGoG8QwCMFM+0ggQhLR0BF19SXuD/ayakz7uR0/TsMcxg3SjfqWNA0hsrga/ojaq/8WPcC+YIk4Ke4CMSuB2XVht1Oj8zIfXlU8BtU8DhmYRXWdfrdF1fgr3+S8At48CD04DVjXQSDO70PTUnaJ5uOCwsIIFHSSFy1pKPWCDsZxCpw8UVgKSPxLXM937OzxxAljzcPAbcswU4Qh4V3UN8mKoeKm/bu78IfKJQa8VD48CylHQiL3O3/qg5Rf30BKACMtJXjXKQcfBSK8Dfqc3KVCwuN2VFGRnm/yKZtq4Re5ifyQQgM2A+BeB3GHaZBo5MAIue0l7Kt3cC4xhw+5eL7TuCkJk1jBtyerbUfYG5ExjZ/pqrxE5fAOrOq5SmowVIrRp1IyT2R6+fg0bgVYG4CsyZe2UsaiOGKXr4Sfp9k8CxCYAFSKyvXeY1o1BxQux91yMtfsHPutgnnyUuUvhc0ZsgUXib+nVkq6+ZKaABIHsgVZnuwD9sVo66rrR4ImdhLGSQ8zPL/JgBQxeU1ouWkO9PTgDzbgmXxrzMkatl3keivfG5x4r4IRcz5BfkO5vEZ0kgpIfBZ8yKjlL17syy0tMNcOn9dl4Fy6dLFabj1Mpvow9Ify+I4Nlo9Xt+ZqU9VdJpqZh4QDDyxUyYOYJwHDg+DhgI/WUVZl7aSEt93+GO9Ia2iuZKOfA7lhp9JpvAVy61w2mOwO5hmCgMHC1H9O24gu6UD9jP+ZmbtLRaSsei9SL4XDPbAEh/kGQ/pSUcc0lbApFWb67lQUhpVnLBsoKqqZclFMmUtrxPcwxl3X7vOCAtYLSCcugFQmqhdssH7HU+RznjiOlYXA8wqkOfkItTAom+oKygca4ES8jY+N3z7fSG4hfUtp3ihUHruVSsFy1iRvNP+1N7A5BdJACmVpAgZPhGOyCigEjlPLudn7kvFtOxuB4g6OjD8UWLRkCZFRwrLCEXJQQhp2K+37lQeBCRX1A7KPQto1prFEmSYn2mB9EAsO+kYfk8KQhZF8yjVz5gp/MztyOUjiW9bCUhEBhKRCCgSis45uQ/PhX/xfFWMgOnWu2gxB0TF/o0kEZ/kCDM1Ts+3RHYnwVUL6XhDFrAswfIB6w6P1MrTulY0sum1VICglKwCEACqvQFCUK3gHcsFQCM/ILayqP1k9JshVqrncMalOYYvgcGAyCvIwuod8YBJQmZpmGJeyRwkGw4n8jJOJQNw3idLFhMRNB0SgASTJyKoy/4ieXCeFfJBUeV2SoAclFyR0bbm1OHTUiN0/DTAwD7zQeM52dqj8VsGEkVE2jKetG7AEhQ0frJAv6RC0trC1skl+IWlNinGLbSaZg7Mc0xfA8MbgF1LQV1z08A2G8+oM7PVF9Ms2GUE0gQyp+Lwu2yagLgR9ZaYpkSypQ6a6Q2DCqzpkvietXIFdoZfuieGmcOD0DeP0HEbBhNwYPmA/L8zJQsATAKnguEqS+XTqkE4YfWWwCUFZTksYAYwZfIBeN9Tw0cjOwu8gDIZqsoSSvhEeQDiiGYFoyWiSDRypWgi69UP5sc5fIcquSCNeXqe2X9ZAHfM7Khe2pcOB+AT41+aO5iRD3QAHBEHd9ctuiBBoANEkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cvAFgg4GR9kADwJF2f3PxBoANBkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cfOxqYJ2au9RdPtdp/khoEOlglDYT39V1PzQFXLsMXAlgt9PCxJKPbufyf8/KHIPfBPAZABf79Xc5XQ0ZQ1Q7360NbxoHrlsDvs5ZRsgo0une06by6X1mZvtP99PNAp4F4LsBXA5gjw8EGTeqaGF4QhzQF80CX7cAvGIdeDYAfhdZ2sTKUcVrpE7nd31N5gj8e2dIo2osk7NZpMdK0Z19tv+bJ4F9K8D1ACj8yfNSikHeg+5Z969m57Y/8/ZP+dPLKZhP/rcA+AYAF7g1oRUhEMUzFMt6eSJfX78b2DkPfM0i8GIAX+uWlAMppreUUErn8p2gzTl+2flg/sDbTkvIOik+CP20//mzwAXzwDcCuNTPJeFXpEpM6QEjIHm/zTF8D7T5gATYNQCe69aAloRTGulfBESBSYNyxR5g/Bhw7hKwZwl4vk9LnM5JmsBzUyDGAX3B8G23Mz/g9BuUa/0IiutfMkj7zwKmngAuXSvOpUvAWYBtF4BTnspIj/O8zPaf7qdvWITw6eZA0JLQEhKEGgxZhUj/dz3NzSKwbR44exnYvVKcy+mM5Km0JhxInUtrGkmzCPicg3W5LMGkQiZZTm9xS9Z3+4m2o8C5c4X15pTKW2Lb+fCx7WLtjYxzqiql29Icw/dA5SqYf6RTTilg+lYCIXmICKQ4IK9wxfSJY8AZK8CuFWDnanEua9ZTAMsaCog3Dt92O/MvnRGBtGwkqKRmMEkqCaa+2k+0LQDTh4rP88UHj74kF1WaATo9QHQ7mmP4HugYhtEKj4PB6ZQ+FS0hQahpldPya1kXTOqNY8DscgG+HavAttUCvBxInitrkgL4lcO33c7spBdM3kAuSnq2nx9gQfAh4JyVwvrxwel2z3p4aMlzH6DM2z/lT+8aB+Q/OT4EEqckWQSBkGD6EQKQnDCLwBSnYgcf32fXioGUFawC4esyu7CXXnDP9tOCsyD4KLB1rmgvX7zfbu2WG/Jtme0/3U/vKxBNAMoi0KcjkATCN3HOEr3UAjDrwOP71rXixYEkeKMFlSX8ocwR6KUXTJ7AaNE2tF8WfA4Ye7Kw1mwvX/yZn+eKnvcrfzC6IK/ObP/pfnpfAGQnySoISBqUXyAASS1AK0JfagWYcRDOrAF66TxZQU7jBOEbM0egH71gcgXSFZAV54NQtj9YcNIpbONCyh8Ygi8CVospApDuB63g92W2/3Q/vW8AsqM4gLIKBBIH8bcJwMCNMX68BTqBb8s6sGWtsIA6jwDk662ZI9CvXjA5A6NVa2t/IAicnC/aGV+8T74IQPm/AmGuBc+8/VP+9IEAyLslAKMV/LgAyIUInfnjwPQqMOOgI/DstQ5Mr7UAqMF8V2YXDqoXXNl+EQQ6N9v29aKdesUpWJZbAPyPme0/3U8fGIDssDid/pUASCvCaXgJmFguAEfgEXT27gDkuwaUg/nbmSMwjF7whvbLhSDL5TwwvdRqo9oqHzACkCB8U2b7T/fThwIgO01T1IMCoAZxGRhbKoAXQUcQTjkI+a4B5e5FzjGsXvCG9gdqrLGFYrpVG/UuHzBOw2/LaXxzbh43DKeoJwlAHqLndSs4udoCoIBHQE45EPk3DuitmYOQoxdctp8+rFwIWsGFYiFFoLGNchcEQC6e+OJC5J2Z7T/dTx/aApYdJ37AyJK/DIwvFxYvWr0IwEn/H1Opco5sveDUhSAAF4HJpQJkWixp6k2n4IYfMGf0amDHev2I8+l4/UbvNw8Eozw72wJePOJ8und7EkKj9ztKGA1/7WwATo44n45pWI3e7/AAGPWZ2QBkYHCU+XTMfGGQmYIxjd7vqOE0+PXzATjifDrKtTZ6v4MP/MlyRj4AR5xPF+VaqZLJF1UzKdPV6P2eLDDr3I58AI44n07ZMARbo/d78gMubWE+AEecT8e9YOn2Uheu0fs9tUCYD8AR59MpG6bR+z21gKfW1gNAz4geRT5dTEZo9H5PPRDmAzBmRM8BJzqfLiYjSKKr0fs9dYBYDwBHmE9XtRfMsIz04aQZ1+j9npygrA+Akqs8wfl0BCCTWRq935MTYL1aVQ8Ao1zlAnAi8+kEQGZTNXq/vYb75Pt/fQAcUT5dBGCj93vyAaxXi+oDoFLyT3A+3Rcavd9eY3xS/z8fgCQX/LPR3SOzkon55jg1eyAfgD8M4NcAPD6aDmBtB1e4NMDNcer1QD4AbwbwxwDe4UvRE9wHZG1gNSXDLlwLNcep1QP5APxzzwj9IIAPnXhT5ORc5EYCA9HNcWr1QD4AmRH6FQBMTSZZH98ZmD5Bh5g1FopiNns1x6nTA/kAvAfAEwDudnI+EvQxPfkEzYfaCXRSBluQMB7YHKdGD+QDsBNBH/9+AkAobqTADGK7Inw1x8nfA/kA7EXQt8kgrGAGMfBxZ5Cv5ji5eyAfgL0I+r68uR0QmUFoBQU8vfNvzXHy9kA9AORoMw7CdGQCjoUZDwL4kv/+8OZ1gJhBIjGDgMh3vTavBc035/RAPgD7JegjODfhiMwgoqeJwNPPTaB6Ezq/hq+sB4AcXeXEP+ZhGVo9vRimIQD5v5oPAZCupgDI9wg8/qz/1Xz55usyeyAfgMMQ9GU2Op4eAchpOIJQQEz/VuPlm6/K7IH6AMjgGzdl6QtyX5jWjpQFevF3lq3xf6yhrOlIAUgQCojR8gmE+l9Nl2++JrMH6gEgR5UA5KYsc+AZmCbQCDi+IvgEQMob1XBEAHIajgBMLV+0kCdws6aGu3zqfkV9AGTwjftg3JRVVRAtHQEXX/wbAcoXP5d5CID8GoJKvqDAloKOoIz/y7x8c3pmD4zhaqwjRzCYyQg5gr2ZgsFTLweWr8XQgsXjbwLWrnNtMlKgNoLBmZAa7PTCAuYIBlMvlWQswwr2UlUw45jdDSx8HbD+Ctd+HVCwePKbgJV9aASDM8Yg59TWFDysYPBtmYK91IbNOHaPA/M7gUXKXA4hWDz79cA8+W0aweCMURj+1HYfcBjBYO54MMY3tGDv8I3nmWSHOzYOLJ0LLPGXAQWLz3oB8MQUsEa16kYwOG8whjh74yJkUMFgbsNlCfYO0epwissVY34bsHw2sEIRkAEEi/dcU0SP5qhF1ggG5w3GEGdXr4L5134Fg4kAjuDQgr1DtDqcUmZETwArZwAru4BVqsv0KVh8/o3F4v0QXZBGMDhvMIY4u3MYhv95Zh+Cu1xBcxuOU/HfeDIq5cv7FuwdotXhlCBXjOXZAnyrO4BV6in0IVh8wStLuWCsUAyvEQzOG5ABz+4eB+R/ewnu/kOP/3G/l4kJTERlljQtIot2e53/IwO2OPl4FLtcnCqAp9cahT56CBZf+LpSLhhz1N5qBIPzBmTAs/sLRHcTDKbiNHdBGGymOC/3hglEvgjAnoK9A7Y4+XgiV4zVWYDAs/etxaubYPFFP1QkLtCIP8neaASD8wZkwLP7AyC/tJNg8L/xLNBu+YBdBXsHbHEFAINcMVamgdWZAoRrfPdXm8KitLdmgYveWAq+2y7iMqfuRjA4b1AGOLt/APJLqwSD3+y5T1yI0AoSbAxMMzGV1o8/My2ro2DvAK2t+GgiV4zj4+3AIwDXtwBrVJeuECze+9aW4Dut4PxkIhYsdetGMDhvoDqcPRgA+SWp4O4veQ5Uv/mAGwR78+6rQq4Yq9PAOi2fA4/vBkKudKVU7VZw77uKvWFuZbtcMNb5v0YwOG9g+jx7cADyi6Pg7gccgIxlcA5TKhaD01yYKBmVFpBZMfx/m2Bvny3t8LGqoqTliZbVI+gMgHwnMAnCIFi897cLAAZ6QyzFzzSCwXkD1OPs4QDIL5XgLmk5JHk/SD5gKdibd38VcsVYGmuBTaAzEHLHgyCcaokB7/1IkUET5IKxwF5pBIPzBqbPs4cHIC/AaeqvPL9pmHxAE+zts6VdLCD/lcgVY3UyWD0Bj1ZwqgCggXA7sPfWAoAJvaEtZBrB4Lyx6efsPADyCtmCvf00s/NnOsgVY3m8BTRZPZuGBUACdArY+5lWDqGmYbIrLHEx0ggG5w1OH2fnA7CPizQfaXqgUw80AGywMdIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0BxoAjrT7m4s3AGwwMNIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0B8ZYNMbkX+ZekpuIiOQrPar+xs889HJg6jZg5jAwvVZ8B+ll9PlO5/Fc/o+ECjnHfi8zYfkvM5ulmp4qJXVqx5deD4zfAkw/CGxdAZgoHfuh131QkaI5hu8Bs4Ds8B0AWLnIRGCBsFfn87JffDMwdjOw5R5g8giwZa34jnQQUwDo99wBfJ4TM7COiNdlaj2rA/jeV/vfDeATAP4UGH8I2Lrc6gc+SHqY4oMZ74VSKM0xfA+UUzB/oBUUCKMl6zSQ/PsXqZD5KQC/A0w/DEwcAcYXgYnVwppwADuBkefnCim90FmBWXwnK87Uen53BI8sbuwqaz9p5UgnQhBS+ZN1zE8Ak0utviCwq8DI8/nx5hi+Bzb4gJzKZE1SEFZZgS9/2pWR/gTAJ4HJQ8DEMWB8ARhfBsaWCwDquwQKvvNgHXvOcYVbPFJPkw+dDxC/W1Y4tWDpw/Rlgo4lo1T4/KxTihDNpJwj3/UiMLXemprjffC7eWpzDN8DlYsQDiKtVxzEqoHkyX9HRizW+nIgaQnvAiaeBCbmC0s4tgSMu2rMePAR9X252jXklaTFU108K0MHav/nvJ6ZxVVk9OI7GR2IZoGQNc/HgbHgIwqILIVujuF7oOMqWFawCoRxkfEIB5CWgkREBCNf9wMTc8A4QciBWyoGz16rwNgaML5eWKpctYZL3N+TWLX0gvtuP0HHk2n16JDyxXmVhfU0qywbJbr5GSuXKxA/sV5Y9UYWdnjwyS3qKKgarWA69Wg6fjQOIK0HadnIjPVFB+AiME4AuiUkCFnESyCSkmAuU7Cjm15wX+2X2ifBRn9A8mKcW2UFjULVQcgVDl80u40SYh763FfvquhLCxitoBYUsoJfjXKttByMq9CKcHn4sPuCbgXNJwyWkECcz5Q376UX3LNncZyQAAADEklEQVT9fFgIJs6lBBwtn3Tt6FpIz4RWnuQxPh2XIGzm4CwQ9hWIFgBTK0gQHiIAJddKq0ELQh+KL1qUR4MvSEsoENIKrgALHNiMox+94K7tl9qnnMio8MSf6SNwGpYVjCDk/Ju7isq496fCqX0BkDeqlWwKwic1gAQSpzGREnFgREz01eALLvvq2Kfi45m6cf3qBXdsfxRbJMho8dimqOhEK8cXQRr9QVpvPoDNMXQP9A3ACELFxPh+jACkP0fLIKFCCRRqKuPUdqjlC9o07JZwKVNHeBC94DQcZO0XAAkmgotAk9QYrR9f/BvByYfMSATDVMzwTXMM3QMDAVAgVHCZ7/MaQK4QZUHiNCbBQlqUw74YCb7gcmYkelC9YFlwvVv7RRAorTuBkECU9asCID9/x9B935zYzyKkqpfiNHxcA0gLQgvBAaPVkCqm3h2AtC5m/RyEqzw/4xhGL3hD++MmslgqCbgUfLKAcRrmTlBzDN0DA1tAXUlWcDm1IOIIJAjlT/Fd05lbFQFwjdtgGcewesFt7Rc/Gx8iWjUCjGCT1YvWT1MwgUqrf3NG45tTbcu0aximWx9xENcEQHGbcYAEwtSXSqY0gnCdgeuMI0cvuGx/FUGgFhwEYrR80QckWN+X0fjm1DwAWv8RgJFilJZBznz0pQg+AZAAlVWh1GvGka0XzB0cCQi30aSGVa9AF62fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC",FY="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;}",kY="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);}",ua={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},f0=class extends xo{constructor({preset:i=ua.MEDIUM,edgeDetectionMode:t=Ld.COLOR,predicationMode:e=j9.DISABLED}={}){super("SMAAEffect",FY,{vertexShader:kY,blendFunction:pt.NORMAL,attributes:vo.CONVOLUTION|vo.DEPTH,uniforms:new Map([["weightMap",new oe(null)]])});let r,n;arguments.length>1&&(r=arguments[0],n=arguments[1],arguments.length>2&&(i=arguments[2]),arguments.length>3&&(t=arguments[3])),this.renderTargetEdges=new ht(1,1,{minFilter:Je,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 n1(!0,!1,!1),this.clearPass.overrideClearColor=new Re(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new ss(new W9),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=e,this.weightsPass=new ss(new eY);let s=new Gf;s.onLoad=()=>{let o=new or(r);o.name="SMAA.Search",o.magFilter=kt,o.minFilter=kt,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!0,this.weightsMaterial.searchTexture=o;let a=new or(n);a.name="SMAA.Area",a.magFilter=Je,a.minFilter=Je,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&&n!==void 0?(s.itemEnd("search"),s.itemEnd("area")):typeof Image<"u"&&(r=new Image,n=new Image,r.addEventListener("load",()=>s.itemEnd("search")),n.addEventListener("load",()=>s.itemEnd("area")),r.src=lO,n.src=cO),this.applyPreset(i)}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(i){this.edgeDetectionMaterial.edgeDetectionThreshold=i}setOrthogonalSearchSteps(i){this.weightsMaterial.orthogonalSearchSteps=i}applyPreset(i){let t=this.edgeDetectionMaterial,e=this.weightsMaterial;switch(i){case ua.LOW:t.edgeDetectionThreshold=.15,e.orthogonalSearchSteps=4,e.diagonalDetection=!1,e.cornerDetection=!1;break;case ua.MEDIUM:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=8,e.diagonalDetection=!1,e.cornerDetection=!1;break;case ua.HIGH:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=16,e.diagonalSearchSteps=8,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break;case ua.ULTRA:t.edgeDetectionThreshold=.05,e.orthogonalSearchSteps=32,e.diagonalSearchSteps=16,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break}}setDepthTexture(i,t=vn){this.edgeDetectionMaterial.depthBuffer=i,this.edgeDetectionMaterial.depthPacking=t}update(i,t,e){this.clearPass.render(i,this.renderTargetEdges),this.edgeDetectionPass.render(i,t,this.renderTargetEdges),this.weightsPass.render(i,this.renderTargetEdges,this.renderTargetWeights)}setSize(i,t){this.edgeDetectionMaterial.setSize(i,t),this.weightsMaterial.setSize(i,t),this.renderTargetEdges.setSize(i,t),this.renderTargetWeights.setSize(i,t)}dispose(){let{searchTexture:i,areaTexture:t}=this.weightsMaterial;i!==null&&t!==null&&(i.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return lO}static get areaImageDataURL(){return cO}};var VY=`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;
|
5651 | #if VIGNETTE_TECHNIQUE == 0
|
5652 | float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
|
5653 | #else
|
5654 | vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
|
5655 | #endif
|
5656 | outputColor=vec4(color,inputColor.a);}`,d0={DEFAULT:0,ESKIL:1},_O=class extends xo{constructor({blendFunction:i=pt.NORMAL,technique:t=d0.DEFAULT,eskil:e=!1,offset:r=.5,darkness:n=.5}={}){super("VignetteEffect",VY,{blendFunction:i,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new oe(r)],["darkness",new oe(n)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(i){this.technique!==i&&(this.defines.set("VIGNETTE_TECHNIQUE",i.toFixed(0)),this.setChanged())}get eskil(){return this.technique===d0.ESKIL}set eskil(i){this.technique=i?d0.ESKIL:d0.DEFAULT}getTechnique(){return this.technique}setTechnique(i){this.technique=i}get offset(){return this.uniforms.get("offset").value}set offset(i){this.uniforms.get("offset").value=i}getOffset(){return this.offset}setOffset(i){this.offset=i}get darkness(){return this.uniforms.get("darkness").value}set darkness(i){this.uniforms.get("darkness").value=i}getDarkness(){return this.darkness}setDarkness(i){this.darkness=i}},QTe=[new Float32Array(3),new Float32Array(3)],KTe=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],ZTe=[[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 JTe=[new Float32Array(2),new Float32Array(2)];var $Te=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),eCe=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],tCe=[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])],rCe=[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 nCe=new Map([[Qn(0,0,0,0),new Float32Array([0,0,0,0])],[Qn(0,0,0,1),new Float32Array([0,0,0,1])],[Qn(0,0,1,0),new Float32Array([0,0,1,0])],[Qn(0,0,1,1),new Float32Array([0,0,1,1])],[Qn(0,1,0,0),new Float32Array([0,1,0,0])],[Qn(0,1,0,1),new Float32Array([0,1,0,1])],[Qn(0,1,1,0),new Float32Array([0,1,1,0])],[Qn(0,1,1,1),new Float32Array([0,1,1,1])],[Qn(1,0,0,0),new Float32Array([1,0,0,0])],[Qn(1,0,0,1),new Float32Array([1,0,0,1])],[Qn(1,0,1,0),new Float32Array([1,0,1,0])],[Qn(1,0,1,1),new Float32Array([1,0,1,1])],[Qn(1,1,0,0),new Float32Array([1,1,0,0])],[Qn(1,1,0,1),new Float32Array([1,1,0,1])],[Qn(1,1,1,0),new Float32Array([1,1,1,0])],[Qn(1,1,1,1),new Float32Array([1,1,1,1])]]);function e1(i,t,e){return i+(t-i)*e}function Qn(i,t,e,r){let n=e1(i,t,.75),s=e1(e,r,1-.25);return e1(n,s,1-.125)}var kr=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=pt.NORMAL}};var Nd=class extends kr{constructor(){super(gO),this.blendFunction=pt.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 Bd=class extends kr{constructor(){super(yO)}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 Fd=class extends kr{constructor(){super(xO),this.effect.offset=new N(.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 kd=class extends kr{constructor(){super(vO)}};var Vd=class extends kr{constructor(){super(wO);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 zd=class extends kr{constructor(){super(SO),this.blendFunction=pt.OVERLAY}};var Ud=class extends kr{constructor(){super(_O)}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 Gd=class extends kr{constructor(t){super(bO,t)}set focalLength(t){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=t}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(t){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=t}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(t){this.effect.bokehScale=t}};var Hd=class extends kr{constructor(){super(AO)}get granularity(){return this.effect.getGranularity()}set granularity(t){this.effect.setGranularity(t)}};var EO=`#define GLSLIFY 1
|
5657 | 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 MO=`#define GLSLIFY 1
|
5658 | #include <common>
|
5659 | varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;
|
5660 | #define USE_YCOCG
|
5661 | #define USE_CATMULL_ROM
|
5662 | 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){
|
5663 | #ifdef USE_YCOCG
|
5664 | vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);
|
5665 | #else
|
5666 | return texture(tex,uv);
|
5667 | #endif
|
5668 | }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(){
|
5669 | #ifdef CHOOSE_LONGEST_MOTION_VECTOR
|
5670 | 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;
|
5671 | #else
|
5672 | float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;
|
5673 | #endif
|
5674 | }vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);
|
5675 | #ifdef USE_CATMULL_ROM
|
5676 | vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);
|
5677 | #else
|
5678 | vec4 previousColor=sample_color(historyBuffer,previousPixelPos);
|
5679 | #endif
|
5680 | #ifdef USE_YCOCG
|
5681 | previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);
|
5682 | #endif
|
5683 | 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);
|
5684 | #ifdef USE_YCOCG
|
5685 | 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;
|
5686 | #endif
|
5687 | vec4 previousColorClipped=clamp(previousColor,cmin,cmax);
|
5688 | #ifdef LUMINANCE_DIFFERENCES
|
5689 | #ifdef USE_YCOCG
|
5690 | float lum0=currentColor.r;float lum1=previousColorClipped.r;
|
5691 | #else
|
5692 | float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);
|
5693 | #endif
|
5694 | 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));
|
5695 | #else
|
5696 | const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);
|
5697 | #endif
|
5698 | #ifdef USE_YCOCG
|
5699 | gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);
|
5700 | #else
|
5701 | gl_FragColor=result;
|
5702 | #endif
|
5703 | }`;var TO=`#define GLSLIFY 1
|
5704 | varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`;var CO=`#define GLSLIFY 1
|
5705 | layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`;var jd=class extends at{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new oe(null)},blending:Vt,depthWrite:!1,depthTest:!1,vertexShader:TO,fragmentShader:CO})}set inputBuffer(t){this.uniforms.inputBuffer.value=t}},p0=class extends Zr{constructor(){super("TAAResolvePass");this.MRTCompatible=!0;this.needsSwap=!1,this.passThroughMaterial=new jd,this.resolutionVector=new N,this.resolveMaterial=new at({name:"TAAResolveMaterial",uniforms:{inputBuffer:new oe(null),historyBuffer:new oe(null),velocityBuffer:new oe(null),depthBuffer:new oe(null),resolution:new oe(new N)},blending:Vt,depthWrite:!1,depthTest:!1,vertexShader:EO,fragmentShader:MO}),this.historyRenderTarget=new ht(1024,1024,{minFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new ht(1024,1024,{minFilter:Je,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 n=this.renderToScreen?null:r;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(n),e.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}};var m0=class extends Zr{constructor(e,r,n){super("TransmissionPass",void 0,r);this.MRTCompatible=!0;this.depthPass=new i1(e,r,{renderTarget:n.transmissionDepthTarget}),this.passThroughMaterial=new jd,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new jd,this.depthPass=new i1(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,r,n){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,n),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 PO=new Nn,WY=new at({transparent:!0,vertexShader:`
|
5706 | void main() {
|
5707 | gl_Position = vec4(0.0);
|
5708 | }
|
5709 | `,fragmentShader:`
|
5710 | layout(location = 1) out vec4 gVelocity;
|
5711 |
|
5712 | void main() {
|
5713 | gl_FragColor = vec4(0.0);
|
5714 | gVelocity = vec4(0.0);
|
5715 | }
|
5716 | `}),Pc=class extends Zr{constructor(e,r,n){super("OpaquePass",r??PO,n);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}set splatViewer(e){this._splatViewer=e}get splatViewer(){return this._splatViewer}setCamera(e){this.camera=e}setScene(e){this.scene=e??PO}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 $t&&(this.originalMaterials.set(s.id,s.material),s.material=WY)}),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let n=this.renderToScreen?null:r;if(e.setRenderTarget(n),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),this._splatViewer?.splatRenderingInitialized===!0){let s=e.autoClear;e.autoClear=!1,e.render(this.scene,this.camera),this._splatViewer.update(),e.render(this._splatViewer.splatMesh,this.camera),e.autoClear=s}else 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 g0=class{constructor(t,{depthBuffer:e=!0,stencilBuffer:r=!1,multisampling:n=0,frameBufferType:s=0}={}){this.renderer=t;this.helperStartIndex=0;this.copyPass=new $p;this.depthTexture=null;this.timer=new mO;this._width=1;this._height=1;this.passes=[];this.helperPasses=[];this.autoRenderToScreen=!0;this.inputBuffer=this.createBuffer(e,r,s,n,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(e,r,s,n,!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,n,!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 N),r=t.getContext().getContextAttributes()?.alpha??!1,n=this.inputBuffer.texture[0].type;n===lr&&t.outputEncoding===et&&(this.inputBuffer.texture[0].encoding=et,this.outputBuffer.texture[0].encoding=et,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,n)}}replaceRenderer(t,e=!0){let r=this.renderer,n=r.domElement.parentNode;return this.setRenderer(t),e&&n!==null&&(n.removeChild(r.domElement),n.appendChild(t.domElement)),r}createDepthTexture(){let t=this.depthTexture=new Gi(this._width,this._height);return this.inputBuffer.depthTexture=t,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(t.format=Ta,t.type=_a):t.type=fs,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,n,s,o){let a=this.renderer,l=a===null?new N:a.getDrawingBufferSize(new N),u={minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,stencilBuffer:e,depthBuffer:t},c;return n>0?(c=new ht(l.width,l.height,u),c.samples=n):(s?(c=new yg(l.width,l.height,2,u),c.texture[1].type=Uo):c=new ht(l.width,l.height,u),c.depthTexture=new Gi(2048,2048),c.depthTexture.type=Xr),r===lr&&a!==null&&a.outputEncoding===et&&(Array.isArray(c.texture)?c.texture.forEach(h=>h.encoding=et):c.texture.encoding=et),Array.isArray(c.texture)?c.texture.forEach((h,d)=>{h.name=`EffectComposer.Buffer ${s} ${d}`,h.generateMipmaps=!1}):(c.texture.name=`EffectComposer.Buffer ${s}`,c.texture.generateMipmaps=!1),c.name=o,c}addPass(t,e){let r=this.passes,n=this.renderer,s=n.getDrawingBufferSize(new N),o=n.getContext().getContextAttributes()?.alpha??!1,a;if(t.MRTCompatible&&(a=this.inputBuffer.texture[0].type),t.MRTCompatible||(a=this.inputBuffer.texture.type),t.setRenderer(n),t.setSize(s.width,s.height),t.initialize(n,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,u)=>l||u.needsDepthTexture;e.reduce(o,!1)||(t.getDepthTexture()===this.depthTexture&&t.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&r===e.length&&(t.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let t=this.passes;this.deleteDepthTexture(),t.length>0&&(this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!1),this.passes=[])}render(t){let e=this.renderer,r=this.copyPass,n=this.inputBuffer,s=this.outputBuffer,o=this.inputBufferSingle,a=this.outputBufferSingle,l=!1,u,c,h,d;t===void 0&&(t=this.timer.update().getDelta());for(let f of this.passes)f.enabled&&(f.MRTCompatible?f.render(e,n,s,t,l):f.render(e,o,a,t,l),f.needsSwap&&(l&&(r.renderToScreen=f.renderToScreen,u=e.getContext(),c=e.state.buffers.stencil,c.setFunc(u.NOTEQUAL,1,4294967295),r.render(e,n,s,t,l),c.setFunc(u.EQUAL,1,4294967295)),h=n,d=o,n=s,o=a,s=h,a=d),f instanceof pO?l=!0:f instanceof dO&&(l=!1))}setSize(t,e,r){let n=this.renderer;if(this._width=t,this._height=e,t===void 0||e===void 0){let o=n.getSize(new N);t=o.width,e=o.height}n.setSize(t,e,r);let s=n.getDrawingBufferSize(new N);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 qY=new at({name:"CombineMaterial",uniforms:{inputBufferA:new oe(null),inputBufferB:new oe(null)},blending:Vt,depthWrite:!1,depthTest:!1,vertexShader:`
|
5717 | varying vec2 vUv;
|
5718 | void main() {
|
5719 | gl_Position = vec4(position.xy, 1.0, 1.0);
|
5720 | vUv = position.xy * 0.5 + 0.5;
|
5721 | }
|
5722 | `,fragmentShader:`
|
5723 | varying vec2 vUv;
|
5724 | uniform sampler2D inputBufferA;
|
5725 | uniform sampler2D inputBufferB;
|
5726 |
|
5727 |
|
5728 | layout(location = 1) out vec4 gVelocity;
|
5729 |
|
5730 | void main() {
|
5731 | vec4 resA = texture2D(inputBufferA, vUv);
|
5732 | vec4 resB = texture2D(inputBufferB, vUv);
|
5733 | float a = resA.a + resB.a * ( 1.0 - resA.a );
|
5734 |
|
5735 | vec4 res;
|
5736 | res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));
|
5737 | res.a = resA.a + resB.a * (1.0 - resA.a);
|
5738 | gl_FragColor = res;
|
5739 | gVelocity = vec4(0.0);
|
5740 | }
|
5741 | `}),y0=class extends Zr{constructor(e){super("HelperPass",void 0,e);this.MRTCompatible=!1;this.fullscreenMaterial=qY,this.helperPass=new Pc(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new Pc(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let r=new f0({preset:ua.LOW,edgeDetectionMode:Ld.COLOR});this.effectPass=new Cc(this.camera,r),this.rt=new ht(10,10,{minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,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,n){super.initialize(e,r,n),this.effectPass.initialize(e,r,n)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(e,r,n){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,n),this.fullscreenMaterial.uniforms.inputBufferA.value=n.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=r.texture,e.setClearAlpha(s),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}};var DO=`#define GLSLIFY 1
|
5742 | #include <skinning_pars_vertex>
|
5743 | out vec3 n;void main(){
|
5744 | #include <beginnormal_vertex>
|
5745 | #include <skinbase_vertex>
|
5746 | #include <skinnormal_vertex>
|
5747 | #include <defaultnormal_vertex>
|
5748 | #include <begin_vertex>
|
5749 | #include <skinning_vertex>
|
5750 | vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`;var IO=`#define GLSLIFY 1
|
5751 | in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`;var OO=`#define GLSLIFY 1
|
5752 | out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`;var RO=`#define GLSLIFY 1
|
5753 | in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/norm;return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(int(mod(gl_FragCoord.x,128.0)),int(mod(gl_FragCoord.y,128.0)));float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=texelFetch(texture_blue_noise_in_disk,ivec2(index,0),0).rg;vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}
|
5754 | #define USE_GBUFFER_NORMALS
|
5755 | void main(){vec3 view_space_p=get_view_position(v_uv);
|
5756 | #ifdef USE_GBUFFER_NORMALS
|
5757 | vec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;
|
5758 | #else
|
5759 | vec3 view_space_n=-rebuild_normal(v_uv,view_space_p);
|
5760 | #endif
|
5761 | float radius_ss=radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`;var LO=`#define GLSLIFY 1
|
5762 | out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`;var NO=`#define GLSLIFY 1
|
5763 | 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(){
|
5764 | #ifdef DEBUG
|
5765 | 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);
|
5766 | #else
|
5767 | 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;
|
5768 | #endif
|
5769 | }`;var Wd=[[.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 $Y=new at({vertexShader:DO,fragmentShader:IO}),v0=new at({vertexShader:LO,fragmentShader:NO,uniforms:{texture_ao_lrez:new oe(null),texture_depth_lrez:new oe(null),texture_depth_hrez:new oe(null),near:new oe(null),far:new oe(null)}}),x0=class extends Zr{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 n=1024,s=1024;this.gBuffer=new ht(n,s,{type:Xr,depthTexture:new Gi(n,s),minFilter:Je,magFilter:Je}),this.depthBufferHighRes=new ht(n,s,{depthTexture:new Gi(n,s)}),this.aoBuffer=new ht(n,s,{minFilter:Je,magFilter:Je}),this.splineScene=e,this.splineCamera=r;let o=new Float32Array(Wd.length*2);for(let l=0;l<Wd.length;l++){let u=l*2;o[u+0]=Wd[l][0],o[u+1]=Wd[l][1]}this.blueNoiseInDiskTexture=new li(o,Wd.length,1,Cu,Xr),this.blueNoiseInDiskTexture.wrapS=ps,this.blueNoiseInDiskTexture.wrapT=ps,this.blueNoiseInDiskTexture.needsUpdate=!0,this.hbaoMaterial=new at({vertexShader:OO,fragmentShader:RO,uniforms:{near:new oe(null),far:new oe(null),fov:new oe(null),proj_info:new oe(new Xe),is_ortho:new oe(!1),resolution:new oe(new N),radius_of_influence:new oe(8),radius_in_screen_space:new oe(1),exponent:new oe(1),ao_color:new oe(new _),bias:new oe(.5),texture_depth:new oe(null),texture_normals:new oe(null),texture_blue_noise:new oe(null),texture_blue_noise_in_disk:new oe(this.blueNoiseInDiskTexture),frame_index:new oe(0),fog_enabled:new oe(!1),fog_near:new oe(1),fog_far:new oe(1e3)}}),this.radius=128,this.aoColor={r:0,g:0,b:0},this.bias=.5,this.hbaoMaterial.uniforms.texture_depth.value=this.gBuffer.depthTexture,this.hbaoMaterial.uniforms.texture_normals.value=this.gBuffer.texture,this.needsSwap=!0,this.aaBuffer=new ht(n,s,{minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,depthBuffer:!1,type:Xr});let a=new f0({preset:ua.ULTRA,edgeDetectionMode:Ld.COLOR});this.effectPass=new Cc(this.camera,a)}initialize(e,r,n){super.initialize(e,r,n),this.effectPass.initialize(e,r,n)}setBlueNoiseTexture(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}setSize(e,r){this._width=e,this._height=r,this.depthBufferHighRes.setSize(e,r);let n=this._runHalfRes?.5:1,s=e*n,o=r*n;this.gBuffer.setSize(s,o),this.aoBuffer.setSize(s,o),this.hbaoMaterial.uniforms.resolution.value.set(s,o),this.aaBuffer.setSize(s,o),this.effectPass.setSize(s,o)}get runHalfRes(){return this._runHalfRes}set runHalfRes(e){this._runHalfRes=e,this.setSize(this._width,this._height)}setCamera(e){this.splineCamera=e}setScene(e){this.splineScene=e}render(e,r,n){this.splineScene.overrideMaterial=$Y;let s=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),e.setRenderTarget(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=s,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;let o=this.splineCamera.perspCamera.projectionMatrix.elements,a=2/o[0],l=2/o[5],u=-(1-o[8])/o[0],c=-(1+o[9])/o[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,l,u,c);let d=this.splineCamera.perspCamera.fov*(Math.PI/180),p=this.hbaoMaterial.uniforms.resolution.value.y/(Math.tan(d*.5)*2),m=this.hbaoMaterial.uniforms.radius_of_influence.value*.5*p;this.hbaoMaterial.uniforms.radius_in_screen_space.value=m,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;let o=this.splineCamera.orthoCamera.projectionMatrix.elements,a=2/o[0],l=2/o[5],u=-(1+o[12])/o[0],c=-(1-o[13])/o[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,l,u,c);let d=.5*(this.hbaoMaterial.uniforms.resolution.value.y/l),f=this.hbaoMaterial.uniforms.radius_of_influence.value*d;this.hbaoMaterial.uniforms.radius_in_screen_space.value=f,this.hbaoMaterial.uniforms.is_ortho.value=!0}this.runHalfRes?(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=v0,v0.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,v0.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,v0.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(e.aoRenderTarget),e.clear(),e.render(this.scene,this.camera)):(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),e.clear(),e.render(this.scene,this.camera),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.aaBuffer,e.aoRenderTarget))}dispose(){this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose()}};var e7=`
|
5770 | varying vec2 vUv;
|
5771 | void main() {
|
5772 | vUv = uv;
|
5773 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
5774 | }`,t7=`
|
5775 | uniform sampler2D tInput;
|
5776 | uniform sampler2D tMap;
|
5777 | uniform vec2 resolution;
|
5778 | varying vec2 vUv;
|
5779 |
|
5780 | uniform vec2 uResolution;
|
5781 | uniform vec2 uCoords;
|
5782 |
|
5783 |
|
5784 | float rectangle(vec2 st, vec2 size) {
|
5785 | size = vec2(0.5) - size * 0.5;
|
5786 | vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));
|
5787 | uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));
|
5788 |
|
5789 | return uv.x * uv.y;
|
5790 | }
|
5791 |
|
5792 | uniform vec2 uSize;
|
5793 | uniform float uScale;
|
5794 | uniform float uDPR;
|
5795 | uniform float uCurrent;
|
5796 | uniform vec3 uSceneColor;
|
5797 |
|
5798 | void main() {
|
5799 | vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
|
5800 | screenUv *= 1.0 / uDPR;
|
5801 |
|
5802 | vec2 center = vec2(0.5, -0.5);
|
5803 | vec2 outsideUv = screenUv;
|
5804 | outsideUv += center;
|
5805 | outsideUv -= uCoords.xy / uResolution.xy;
|
5806 | outsideUv = (outsideUv - 0.5) + 0.5;
|
5807 | outsideUv -= center;
|
5808 | vec2 s = (uSize / uResolution) * uScale;
|
5809 | float isOutside = 1.0 - rectangle(outsideUv, s);
|
5810 |
|
5811 | vec2 mid = vec2(0.5);
|
5812 | vec2 insideUv = (screenUv - mid + s * mid) / s;
|
5813 | vec4 background = texture2D(tInput, screenUv);
|
5814 | vec4 image = texture2D(tMap, insideUv);
|
5815 | gl_FragColor = mix(image, background, isOutside);
|
5816 | }
|
5817 | `,b0=class extends ss{constructor(){super(new at({vertexShader:e7,fragmentShader:t7,uniforms:{tInput:new oe(null),tMap:new oe(null),uResolution:new oe(new N),uSize:new oe(new N),uCoords:new oe(new N),uScale:new oe(1),uSceneColor:new oe(new Re(16711680)),uDPR:new oe(1),uCurrent:new oe(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 r7=`
|
5818 | void main() {
|
5819 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
5820 | }`,n7=`
|
5821 | uniform sampler2D toScene;
|
5822 | uniform sampler2D fromScene;
|
5823 | uniform vec2 resolution;
|
5824 |
|
5825 | uniform vec2 uResolution;
|
5826 | uniform float uDPR;
|
5827 |
|
5828 | uniform float mixRatio;
|
5829 | uniform sampler2D tMixTexture;
|
5830 | uniform int useTexture;
|
5831 | uniform float threshold;
|
5832 |
|
5833 | void main() {
|
5834 | vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
|
5835 | screenUv *= 1.0 / uDPR;
|
5836 |
|
5837 | vec4 texel1 = texture2D( fromScene, screenUv );
|
5838 | vec4 texel2 = texture2D( toScene, screenUv );
|
5839 |
|
5840 | if (useTexture==1) {
|
5841 |
|
5842 | vec4 transitionTexel = texture2D( tMixTexture, screenUv );
|
5843 | float r = mixRatio * (1.0 + threshold * 2.0) - threshold;
|
5844 | float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);
|
5845 |
|
5846 | gl_FragColor = mix( texel1, texel2, mixf );
|
5847 | } else {
|
5848 |
|
5849 | gl_FragColor = mix( texel1, texel2, mixRatio );
|
5850 |
|
5851 | }
|
5852 | }
|
5853 | `,i7=[],w0=class extends ss{constructor(){super(new at({vertexShader:r7,fragmentShader:n7,uniforms:{toScene:new oe(null),fromScene:new oe(null),uResolution:new oe(new N),uDPR:new oe(1),mixRatio:new oe(0),threshold:new oe(.1),useTexture:new oe(0),tMixTexture:{value:i7[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}};function FO(i,t){return t&&t.enabled&&i.push(t.effect),i}var s7=i=>Object.values(pt).includes(i)?i:pt.NORMAL,em=class extends Yt{constructor(e){super();this.postprocessingState=gh.defaultData;this._scene=new Nn;this._camera=new er;this.effects=new Map;this.blueNoiseTexture=new li;this._renderToScreen=!0;this.clock=new Cg,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Nd),this.effects.set("chromaticAberration",new Fd),this.effects.set("vignette",new Ud),this.effects.set("noise",new zd),this.effects.set("colorAverage",new kd),this.effects.set("hueSaturation",new Vd),this.effects.set("brightnessContrast",new Bd),this.effects.set("depthOfField",new Gd),this.effects.set("pixelation",new Hd),this.effectComposer=new g0(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Pc(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new m0(this.scene,this.camera,this.renderer),this.aoPass=new x0(this.scene,this.camera),this.taaPass=new p0,this.taaPass.renderToScreen=!1,this.helperPass=new y0(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new b0,this.overlayPass.enabled=!1,this.sceneTransitionPass=new w0,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.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){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let r=this.effectComposer.passes.length-1;r>=0;r--){let n=this.effectComposer.passes[r];if(n.enabled===!0&&!e&&this._renderToScreen){n.renderToScreen=!0,e=!0;continue}n.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new li(e,128,128),this.blueNoiseTexture.wrapS=ps,this.blueNoiseTexture.wrapT=ps,this.blueNoiseTexture.minFilter=kt,this.blueNoiseTexture.magFilter=kt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,r,n,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=r,this.aoPass.bias=n,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}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(FO,[]);e.length>0&&(this.uvEffectPass=new Cc(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("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(FO,[]);r.length>0&&(this.effectPass=new Cc(this.camera,...r),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new N;this.renderer.getDrawingBufferSize(e),this._rt=new ht(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ps,wrapT:ps}),this._rt.samples=0,this._savePass=new $p(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new $p(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,...n}=e,s=!1;r!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(n)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=s7(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,r,n,s){e instanceof Xe?(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,n,s),this.effectComposer.outputBuffer.scissor.set(e,r,n,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,r,n,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,r,n,s){e instanceof Xe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,r,n,s),this.effectComposer.outputBuffer.viewport.set(e,r,n,s))}resize(e,r,n){if(this.effectComposer.setSize(e,r,n),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 o7=i=>`
|
5854 |
|
5855 |
|
5856 |
|
5857 |
|
5858 |
|
5859 |
|
5860 | const float gPenumbraFilterSize = 80.0;
|
5861 | const int gPenumbraSamples = ${i};
|
5862 | const int gShadowSamples = ${i};
|
5863 | const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);
|
5864 |
|
5865 | #ifdef USE_SHADOWMAP
|
5866 | #if NUM_DIR_LIGHT_SHADOWS > 0
|
5867 |
|
5868 | uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
5869 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
5870 |
|
5871 | struct DirectionalLightShadow {
|
5872 | float shadowBias;
|
5873 | float shadowNormalBias;
|
5874 | float shadowRadius;
|
5875 | vec2 shadowMapSize;
|
5876 | };
|
5877 |
|
5878 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
5879 |
|
5880 | #endif
|
5881 |
|
5882 | #if NUM_SPOT_LIGHT_SHADOWS > 0
|
5883 |
|
5884 | uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
5885 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
5886 |
|
5887 | struct SpotLightShadow {
|
5888 | float shadowBias;
|
5889 | float shadowNormalBias;
|
5890 | float shadowRadius;
|
5891 | vec2 shadowMapSize;
|
5892 | };
|
5893 |
|
5894 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
5895 |
|
5896 | #endif
|
5897 |
|
5898 | #if NUM_POINT_LIGHT_SHADOWS > 0
|
5899 |
|
5900 | uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
5901 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
5902 |
|
5903 | struct PointLightShadow {
|
5904 | float shadowBias;
|
5905 | float shadowNormalBias;
|
5906 | float shadowRadius;
|
5907 | vec2 shadowMapSize;
|
5908 | float shadowCameraNear;
|
5909 | float shadowCameraFar;
|
5910 | };
|
5911 |
|
5912 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
5913 |
|
5914 | #endif
|
5915 |
|
5916 | |
5917 |
|
5918 |
|
5919 |
|
5920 |
|
5921 |
|
5922 |
|
5923 |
|
5924 | float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)
|
5925 | {
|
5926 | float penumbra = 1.0;
|
5927 | float blockerDepthAvg = 0.0;
|
5928 | float blockerCount = 0.0;
|
5929 |
|
5930 | #pragma unroll_loop_start
|
5931 | for(int i = 0; i < gPenumbraSamples; i ++)
|
5932 | {
|
5933 | vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;
|
5934 | float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );
|
5935 |
|
5936 | if(depth < compare + 0.0001)
|
5937 | {
|
5938 | blockerDepthAvg += depth;
|
5939 | blockerCount++;
|
5940 | }
|
5941 | }
|
5942 | #pragma unroll_loop_end
|
5943 |
|
5944 | if (blockerCount > 0.0)
|
5945 | {
|
5946 | blockerDepthAvg /= blockerCount;
|
5947 |
|
5948 |
|
5949 | penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);
|
5950 | penumbra *= penumbra;
|
5951 | penumbra *= 200.0 * penumbraSize[min(index, ${5} - 1)];
|
5952 |
|
5953 | return clamp(penumbra, 0.00, 1.0);
|
5954 | }
|
5955 | return 0.0;
|
5956 | }
|
5957 |
|
5958 | float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)
|
5959 | {
|
5960 | float shadow = 0.0f;
|
5961 |
|
5962 |
|
5963 | vec2 halton = haltonSequence[frameIndex];
|
5964 | float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
5965 | float temporalAngle = temporalOffset * PI2;
|
5966 |
|
5967 | float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);
|
5968 | float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);
|
5969 | if (penumbra == -1.0) {
|
5970 | return 1.0;
|
5971 | }
|
5972 |
|
5973 | #pragma unroll_loop_start
|
5974 | for (int i = 0; i < gShadowSamples; i++)
|
5975 | {
|
5976 | vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
5977 |
|
5978 | vec2 offset = vogelSample * (shadowRadius * 2.);
|
5979 |
|
5980 |
|
5981 | offset += vogelSample * (penumbra * texelScalar);
|
5982 |
|
5983 | shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );
|
5984 | }
|
5985 | #pragma unroll_loop_end
|
5986 |
|
5987 | return shadow * gShadowSamplesRpc;
|
5988 | }
|
5989 |
|
5990 |
|
5991 | float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
5992 |
|
5993 | return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
5994 |
|
5995 | }
|
5996 |
|
5997 | vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
5998 |
|
5999 | return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
6000 |
|
6001 | }
|
6002 |
|
6003 | float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
6004 |
|
6005 | float occlusion = 1.0;
|
6006 |
|
6007 | vec2 distribution = texture2DDistribution( shadow, uv );
|
6008 |
|
6009 | float hard_shadow = step( compare , distribution.x );
|
6010 |
|
6011 | if (hard_shadow != 1.0 ) {
|
6012 |
|
6013 | float distance = compare - distribution.x ;
|
6014 | float variance = max( 0.00000, distribution.y * distribution.y );
|
6015 | float softness_probability = variance / (variance + distance * distance );
|
6016 | softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );
|
6017 | occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
6018 |
|
6019 | }
|
6020 | return occlusion;
|
6021 |
|
6022 | }
|
6023 |
|
6024 | float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
6025 |
|
6026 | float shadow = 1.0;
|
6027 |
|
6028 | shadowCoord.xyz /= shadowCoord.w;
|
6029 | shadowCoord.z += shadowBias;
|
6030 |
|
6031 |
|
6032 |
|
6033 |
|
6034 | bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
6035 | bool inFrustum = all( inFrustumVec );
|
6036 |
|
6037 | bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
6038 |
|
6039 | bool frustumTest = all( frustumTestVec );
|
6040 |
|
6041 | if ( frustumTest ) {
|
6042 |
|
6043 | #if defined( SHADOWMAP_TYPE_PCF )
|
6044 |
|
6045 | vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
6046 | return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );
|
6047 |
|
6048 | #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
6049 |
|
6050 | vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
6051 | float dx = texelSize.x;
|
6052 | float dy = texelSize.y;
|
6053 |
|
6054 | vec2 uv = shadowCoord.xy;
|
6055 | vec2 f = fract( uv * shadowMapSize + 0.5 );
|
6056 | uv -= f * texelSize;
|
6057 |
|
6058 | shadow = (
|
6059 | texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
6060 | texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
6061 | texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
6062 | texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
6063 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
6064 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
6065 | f.x ) +
|
6066 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
6067 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
6068 | f.x ) +
|
6069 | mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
6070 | texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
6071 | f.y ) +
|
6072 | mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
6073 | texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
6074 | f.y ) +
|
6075 | mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
6076 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
6077 | f.x ),
|
6078 | mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
6079 | texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
6080 | f.x ),
|
6081 | f.y )
|
6082 | ) * ( 1.0 / 9.0 );
|
6083 |
|
6084 | #elif defined( SHADOWMAP_TYPE_VSM )
|
6085 |
|
6086 | shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
6087 |
|
6088 | #else // no percentage-closer filtering:
|
6089 |
|
6090 | shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
6091 |
|
6092 | #endif
|
6093 |
|
6094 | }
|
6095 |
|
6096 | return shadow;
|
6097 |
|
6098 | }
|
6099 |
|
6100 |
|
6101 |
|
6102 |
|
6103 |
|
6104 |
|
6105 |
|
6106 |
|
6107 |
|
6108 |
|
6109 |
|
6110 |
|
6111 |
|
6112 |
|
6113 |
|
6114 |
|
6115 |
|
6116 |
|
6117 | vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
6118 |
|
6119 |
|
6120 |
|
6121 | vec3 absV = abs( v );
|
6122 |
|
6123 |
|
6124 |
|
6125 | float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
6126 | absV *= scaleToCube;
|
6127 |
|
6128 |
|
6129 |
|
6130 |
|
6131 | v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
6132 |
|
6133 |
|
6134 |
|
6135 |
|
6136 |
|
6137 |
|
6138 |
|
6139 |
|
6140 | vec2 planar = v.xy;
|
6141 |
|
6142 | float almostATexel = 1.5 * texelSizeY;
|
6143 | float almostOne = 1.0 - almostATexel;
|
6144 |
|
6145 | if ( absV.z >= almostOne ) {
|
6146 |
|
6147 | if ( v.z > 0.0 )
|
6148 | planar.x = 4.0 - v.x;
|
6149 |
|
6150 | } else if ( absV.x >= almostOne ) {
|
6151 |
|
6152 | float signX = sign( v.x );
|
6153 | planar.x = v.z * signX + 2.0 * signX;
|
6154 |
|
6155 | } else if ( absV.y >= almostOne ) {
|
6156 |
|
6157 | float signY = sign( v.y );
|
6158 | planar.x = v.x + 2.0 * signY + 2.0;
|
6159 | planar.y = v.z * signY - 2.0;
|
6160 |
|
6161 | }
|
6162 |
|
6163 |
|
6164 |
|
6165 |
|
6166 |
|
6167 | return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
6168 |
|
6169 | }
|
6170 |
|
6171 | float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
6172 |
|
6173 | float shadow = 1.0;
|
6174 | vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
6175 |
|
6176 |
|
6177 |
|
6178 | vec3 lightToPosition = shadowCoord.xyz;
|
6179 |
|
6180 |
|
6181 | float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );
|
6182 | compare += shadowBias;
|
6183 |
|
6184 |
|
6185 | vec3 bd3D = normalize( lightToPosition );
|
6186 |
|
6187 | vec2 halton = haltonSequence[frameIndex];
|
6188 | float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
|
6189 | float temporalAngle = temporalOffset * PI2;
|
6190 |
|
6191 | #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )
|
6192 | for (int i = 0; i < gShadowSamples; i++) {
|
6193 | vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
6194 |
|
6195 |
|
6196 | vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
|
6197 |
|
6198 |
|
6199 |
|
6200 |
|
6201 |
|
6202 | shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
|
6203 |
|
6204 | }
|
6205 | return shadow * gShadowSamplesRpc;
|
6206 |
|
6207 | #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
6208 | for (int i = 0; i < 16; i++) {
|
6209 | vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
|
6210 |
|
6211 |
|
6212 | vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
|
6213 |
|
6214 | shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
|
6215 |
|
6216 | }
|
6217 | return shadow * (1.0 / 16.0);
|
6218 | #else // no percentage-closer filtering
|
6219 |
|
6220 | return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );
|
6221 |
|
6222 | #endif
|
6223 |
|
6224 | }
|
6225 |
|
6226 | #endif
|
6227 | `,a7=ut.lights_fragment_begin,l7=ut.shadowmask_pars_fragment,kO=null,c7=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},VO=(i="medium")=>{if(kO===i)return!1;kO=i;let t=c7(i);ut.shadowmap_pars_fragment=o7(t);let e=a7.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 ]"),ut.lights_fragment_begin=e;let r=l7.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ut.shadowmask_pars_fragment=r,!0};var u7=`
|
6228 | attribute vec3 randomColor;
|
6229 | varying vec3 vNormal;
|
6230 | flat out vec3 vColor;
|
6231 |
|
6232 | void main()
|
6233 | {
|
6234 | vNormal = normal;
|
6235 | vColor = randomColor;
|
6236 | gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
|
6237 | }
|
6238 | `,h7=`
|
6239 | uniform float depthContrast;
|
6240 | varying vec3 vNormal;
|
6241 | flat in vec3 vColor;
|
6242 | void main()
|
6243 | {
|
6244 | vec3 normal = (normalize(vNormal)).rgb;
|
6245 |
|
6246 | float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
|
6247 |
|
6248 | vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
|
6249 | gl_FragColor = vec4(resultColor, vColor.r);
|
6250 | }
|
6251 | `,S0=new at({vertexShader:u7,fragmentShader:h7,uniforms:{depthContrast:{value:1}}});var zO=new or,A0=class extends tw{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new N;this.pipeline=new em(this);this.dummyCamera=new er;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,r=!0,n=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),r&&(o|=s.DEPTH_BUFFER_BIT),n&&(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),n=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Lg,this.dummyCamera.matrixAutoUpdate=!1;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,n(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 ht(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,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 je.transmissionLod.value===1}set hdTransmission(e){je.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ht(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:zl,magFilter:Je,wrapS:sr,wrapT:sr,depthBuffer:!1}),this.transmissionDepthTarget=new ht(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:kt,magFilter:kt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ht(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:kt,magFilter:kt,type:Xr,depthTexture:new Gi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,r,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof er?S0.uniforms.depthContrast.value=(n.far-n.near)/1e4:S0.uniforms.depthContrast.value=1,r.overrideMaterial=S0,this.render(r,n),this.setClearColor(r.bgColor,r.bgColor.a),this.setRenderTarget(null),r.overrideMaterial=e.wireframeState?_0:null,n.layers.enable(0),n.layers.enable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,r,n=1){this.dummyCamera.updateCameraState(r.dataPatched),this.dummyCamera.matrix.copy(r.matrixWorld);let s=r.height,o=r.width,a=this.viewportWidth/this.viewportHeight;o<s?o=s*a:s=o/a,this.dummyCamera.setViewplaneSize(o,s);for(let l=0;l<n;l++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,r,{sceneHelpers:n=void 0,sceneHelpersOnTop:s=void 0,overrideTransmission:o=void 0,overrideNormal:a=void 0}={}){let l=e instanceof vl?e.activePage:e,u=l.visible;l.visible=!0;let c=l.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(r)),this.setClearColor(l.bgColor,l.bgColor.a),l.penumbraSizeArray.forEach((p,m)=>{je.penumbraSize.value[m]=p}),je.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?je.resolution.value.set(this.resolution.x,this.resolution.y):je.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(je.normalRenderTarget.value=a,je.normalRenderTargetDepth.value=zO):c.needsNormal()&&(this.createNormalRenderTarget(),je.normalRenderTarget.value=this.normalRenderTarget.texture,je.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,r));let h=l.data.ao,d=h.occlusion;d&&(this.createAORenderTarget(),je.aoRenderTarget.value=this.aoRenderTarget.texture),je.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),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)je.transmissionRenderTarget.value=o,je.transmissionRenderTargetDepth.value=zO,this.pipeline.setTransmissionPassEnabled(!1);else{let p=c.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),je.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,je.aspectRatio.value=aI(this.viewportWidth,this.viewportHeight),je.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}r.layers.enable(3),r.layers.enable(8),this.pipeline.sceneHelpers=n,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),!n&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?_0:null,this.pipeline.render(),je.frameIndex.value=(je.frameIndex.value+1)%16,r instanceof er&&r.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,r,n){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,r),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=n,this.sceneTransitionTimeRemaining=n,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 qd=class extends po(Og){constructor(e,r=15,n=10066329){super(e,r,n);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){mo(this.object,qd.geometryHelper,e,r)}};var Yd=class extends po(Ig){constructor(e,r=15,n=6710886){super(e,r,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){mo(this.object,Yd.geometryHelper,e,r)}};var E0=class extends po(Dg){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){mo(this.object,E0.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=E0._vector,r=this.object.distance?this.object.distance:1e3,n=r*Math.tan(this.object.angle);this.cone.scale.set(n,n,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},tm=E0;tm._vector=new _;function d7(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var Xd=class extends Rd(Tg,qd){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.top=1250,s.bottom=-1250,s.right=1250,s.left=-1250,s.near=-1e4,s.far=2500;let o=new Ra(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Ra&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&d7(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var UO=new _,GO=new _,HO=new He,Qd=class extends Rd(Eg,tm){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=Se.RAD2DEG*2*this.angle,s.aspect=1,s.near=100,s.far=2500;let o=new Ra(this.shadow.camera);o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof Ra&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),GO.setFromMatrixPosition(this.matrixWorld),HO.setFromRotationMatrix(this.matrixWorld),UO.copy(this.up).applyQuaternion(HO).negate().multiplyScalar(this.distance),this.target.position.copy(GO).add(UO),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var Si=class extends Hh(Nn){constructor(e,r){super();this.data=r;this.bgColor=new gr(1,1,1,1);this.fog=null;this.backupFog=new lu(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Re;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new er(Xi,{...lc.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new _g(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=zn(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.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof es)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&&VO(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let n=this.scene;n.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=zn(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=zn(e.aoColor,r))}updateByOp(e,r,n,s){super.updateByOp(e,r,n,s);let o=r;qn(e.path,["fog"])?this.updateFog(o.fog,n.shared):qn(e.path,["ao"])?this.updateAo(o.ao,n.shared):qn(e.path,["ambient"])?this.updateAmbientLight(o.ambient,n.shared):qn(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(zn(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)}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(n=>{if(!n.visible)return!0;n instanceof Xd&&n.visible&&e<3&&(this.penumbraSizeArrayCache[e]=n.data.penumbraSize,e+=1),n instanceof Qd&&n.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=n.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Yn(o)||Zp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),rm(o,e,r,!0)),n(o))}};return n(this),r}};var M0=class extends Rd(Mg,Yd){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 _(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new _(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new Pt(o,a),u=new La(l,new Re(16755200));u.visible=!1,this.gizmos.shadowmap=u,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 La){let r=this.shadow.camera,n=new _(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new _(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(n,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 T0=class extends Qt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Lp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var xl=class extends Qt{constructor(e,r,n){super(e,r,n);this._shapeId=null;this._context=n}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=Dv;break;case"Ellipse":s=Zh;break;case"Polygon":s=Pv;break;case"Star":s=Iv;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=s.create({parameters:e}).userData.shape}let n=this.geometry;r&&n.inputs&&(n.inputs.shapeData=r,n.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 n=this.geometry.getAttribute("position");n!==void 0?Lp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var Os=class extends go(Hs,yo){constructor(e,r,n){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),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 n=wh.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let s,o;for(let a of eo.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=n.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=Ys.apply(n.data[a],e[a]));return this.overrideData=o,s}else return{...Fn.defaultData,...e,...Ni(Fn.defaultData,eo.rootOverrideProps)}}updateByOp(e,r,n,s){let o;if(this.isInstanceRoot&&!s){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let a of eo.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&&eo.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,n,s)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,s=!1;if(n!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(lt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),C0(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(n){let o={};WO(e,[this.uuid],r.overrides,this,n,n,0,s,o);for(let a of this.children)if(lt.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof Qt&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let h=c.bones.map(p=>e.scene.find(o[p])),d=c.boneInverses.map(p=>new ie().fromArray(p)),f=new Ca(h,d);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function C0(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)lt.is(e)&&C0(e)}}function jO(i,t,e,r){return i.component===t&&rp(i.identity,r)?i.overrideData===e?2:1:0}function WO(i,t,e,r,n,s,o,a,l){if(o>50)return!1;if(r.component!==n){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}n.instances.push(r),r.component=n}n instanceof Os&&n.isInstanceRoot&&n.expandInstanceChildren(i);let u=0;for(let c of n.children)if(lt.is(c)){let h=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],d=vh.resolve(e,h,1);if(d!=null&&!(d instanceof Jt)){if(!1)debugger;Object.setPrototypeOf(d,Jt.prototype),console.error("wrong prototype")}let f=null,p;if(!a){let m=r.children[u];if(f=lt.is(m)?m:null,f!==null){let g=jO(f,c,d,h);p=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(h)??null,f!==null)){let g=jO(f,c,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(u,0,f),f.parent===r?(y<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?Ys.apply(c.data,d):c.data;xs.is(m.type)&&(m={...m,type:"Empty"}),f=Ss.createEntity(h,m,i),f.overrideData=d,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,i),p&&f.changeSelectedState(p,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,WO(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let h=r.children[u];if(lt.is(h))i.pendingDeletes.add(h);else break;u+=1}r.children.splice(c,u-c)}return!0}var P0=class extends go(Bf,yo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function f7(i,t,e){let r;return t.geometry.type==="TextGeometry"?new Pd(i,t,e):(t.geometry.type==="SubdivGeometry"?r=new Ps(i,t,e):t.geometry.type==="PathGeometry"?r=new xl(i,t,e):t.geometry.type==="VectorGeometry"?r=new T0(i,t,e):t.geometry.type==="BooleanGeometry"?r=new ns(i,t,e):r=new Qt(i,t,e),r)}function D0(i,t,e){return t.type==="Mesh"?f7(i,t,e):t.type==="Empty"?new is(i,t):t.type==="Splat"?new is(i,t):t.type==="Bone"?new P0(i,t):t.type==="Page"?new Si(i,t):t.type==="PointLight"?new M0(i,t,e):t.type==="SpotLight"?new Qd(i,t,e):t.type==="DirectionalLight"?new Xd(i,t,e):t.type==="Component"||t.type==="Instance"?new Os(i,t,e):xs.is(t.type)?new er(i,t):(console.error(t),new is(i,t))}Ss.createEntity=D0;function p7(i,t,e){let r=D0(i.identity,t,e),n=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,h=i.stateSelection;i.dispose();for(let d of Object.keys(i))delete i[d];Object.setPrototypeOf(i,Object.getPrototypeOf(r));for(let d of Object.keys(r))i[d]=r[d];i.children=[...i.children,...n],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),h&&i.changeSelectedState(h,e),i.resetBBoxNeedsUpdate()}Ss.changeEntityProptotype=p7;Ss.Cloner=Dn;function qO(i,t,e,r){i.updateByOp(t,e,r,!1)}function YO(i,t){let e=!1,r=t.getLayersOfType("transmission"),n=t.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),r.length>0&&i.layers.enable(3),e=!0,Td(i),Md(i)),r.length===0&&n.length===0&&i.layers.set(0),i instanceof es&&i.needsAO&&i.layers.enable(5),e}function XO(i,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(s=>s.data.visible),n=t.getLayersOfType("outline").filter(s=>s.data.visible);return r.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),e=!0),r.length===0&&n.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function QO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof es)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)YO(e,e.material[r])&&(t=!0);else YO(e,e.material)&&(t=!0)}),t}function KO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof es)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)XO(e,e.material[r])&&(t=!0);else XO(e,e.material)&&(t=!0)}),t}var m7=new Eu,g7=new ie,y7=new ms;function rm(i,t,e,r=!1){let n=i.cloner;if(n)for(let s of n.children){let o=g7.copy(s.matrixWorld).invert(),a=y7.copy(t.ray).applyMatrix4(o),l=i.matrixWorld;a.applyMatrix4(l);let u=m7;u.set(a.origin,a.direction),u.near=t.near,u.far=t.far;let c=u.intersectObject(i,!1);c.length>0&&e.push({...c[0],object:r?s:i})}}var I0=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,n)=>{let s=[n,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 Rs=pn(Kd()),bo=pn(Zd());var Cr=pn(Kd()),Qe=pn(Zd()),bl=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=Qe.sup(t),r=Qe.inf(t),n=(0,Cr.default)(new Float32Array(t.size),t.shape),s=e-r;return s<1e-4?Qe.assigns(n,0):(Qe.subs(n,t,r),Qe.divs(n,n,s)),new bl(n,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,Cr.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return Qe.muls(t,this._dataNormalized,this._maxD-this._minD),Qe.adds(t,t,this._minD),t}},tr=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,n;if(e==="norm8x"){let s=tr.maxIntBits(8),o=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.muls(o,r,s),Qe.roundeq(o),n=(0,Cr.default)(new Uint8Array(o.data),r.shape)}else if(e==="norm565"){let s=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.assign(s,r),Qe.mulseq(s.pick(null,0),tr.maxIntBits(5)),Qe.mulseq(s.pick(null,1),tr.maxIntBits(6)),Qe.mulseq(s.pick(null,2),tr.maxIntBits(5)),Qe.roundeq(s);let o=(0,Cr.default)(new Uint16Array(s.data),r.shape),a=(0,Cr.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,Cr.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);Qe.lshifts(a,o.pick(null,0),11),Qe.lshifts(l,o.pick(null,1),5),Qe.boreq(a,l),Qe.boreq(a,o.pick(null,2)),n=a}else{let s=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.assign(s,r),Qe.mulseq(s.pick(null,0),tr.maxIntBits(11)),Qe.mulseq(s.pick(null,1),tr.maxIntBits(10)),Qe.mulseq(s.pick(null,2),tr.maxIntBits(11)),Qe.roundeq(s);let o=(0,Cr.default)(new Uint32Array(s.data),r.shape),a=(0,Cr.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,Cr.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);Qe.lshifts(a,o.pick(null,0),21),Qe.lshifts(l,o.pick(null,1),11),Qe.boreq(a,l),Qe.boreq(a,o.pick(null,2)),n=a}return new tr(n,e)}dequantize(t,e){let r=this._method,n,s=this._quantized;if(r==="norm8x"){let o=tr.maxIntBits(8);n=(0,Cr.default)(new Float32Array(s.size),s.shape),Qe.muls(n,s,1/o)}else if(r==="norm565"){let o=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]),a=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]),l=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]);Qe.rrshifts(o,s,11),Qe.rrshifts(a,s,5),Qe.bandseq(a,tr.maxIntBits(6)),Qe.bands(l,s,tr.maxIntBits(5)),n=(0,Cr.default)(new Float32Array(s.shape[0]*3),[s.shape[0],3]),Qe.muls(n.pick(null,0),o,1/tr.maxIntBits(5)),Qe.muls(n.pick(null,1),a,1/tr.maxIntBits(6)),Qe.muls(n.pick(null,2),l,1/tr.maxIntBits(5))}else{let o=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]),a=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]),l=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]);Qe.rrshifts(o,s,21),Qe.rrshifts(a,s,11),Qe.bandseq(a,tr.maxIntBits(10)),Qe.bands(l,s,tr.maxIntBits(11)),n=(0,Cr.default)(new Float32Array(s.shape[0]*3),[s.shape[0],3]),Qe.muls(n.pick(null,0),o,1/tr.maxIntBits(11)),Qe.muls(n.pick(null,1),a,1/tr.maxIntBits(10)),Qe.muls(n.pick(null,2),l,1/tr.maxIntBits(11))}return new bl(n,t,e)}};var rr=class{constructor(t,e,r,n,s,o=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=n,this._variableChunkSize=s,this._isDynamicChunks=o}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,n=(0,Rs.default)(new Float32Array(r*2),[r,2]),s=0,o=r,a=0,l=this.minmaxMatrix.shape[0];for(let u=0;u<t.length;u++)l=t[u],o=l-a+s,o>s&&bo.assign(n.hi(o,2).lo(s,0),this.minmaxMatrix.hi(l,2).lo(a,0)),s=o,a=l+1;return s<r&&bo.assign(n.lo(s,0),this.minmaxMatrix.lo(a,0)),n}_createPrunedQuantized(t){let e=t.length,r=this.quantized.shape[0]-e,n=this._quantizationMethod,s,o;if(n==="norm8x"){o=this._quantized.shape[1];let h=o?r*o:r;s=(0,Rs.default)(new Uint8Array(h),o?[r,o]:[r,1])}else n==="norm565"?s=(0,Rs.default)(new Uint16Array(r),[r]):s=(0,Rs.default)(new Uint32Array(r),[r]);let a=0,l=r,u=0,c=s.shape[0];for(let h=0;h<t.length;h++)c=t[h],l=c-u+a,l>a&&(o?bo.assign(s.hi(l,o).lo(a,0),this._quantized.hi(c,o).lo(u,0)):bo.assign(s.hi(l).lo(a),this._quantized.hi(c).lo(u))),a=l,u=c+1;return a<r&&(o?bo.assign(s.lo(a,0),this._quantized.lo(u,0)):bo.assign(s.lo(a),this._quantized.lo(u))),s}pruneFeature(t,e,r){let n=this._createPrunedQuantized(t),s=this._createPrunedMinMax(e);return new rr(n,s,this._chunkSize,this._quantizationMethod,r,!0)}static getRequiredNChunks(t,e){return Math.floor(t/e)}static fromArray(t,e,r){let n=t.shape[0],s=Math.floor(n/r),o=(0,Rs.default)(new Float32Array(s*2),[s,2],[2,1]),a;e==="norm8x"?a=(0,Rs.default)(new Uint8Array(t.size),t.shape):e==="norm565"?a=(0,Rs.default)(new Uint16Array(t.shape[0]),[t.shape[0]]):a=(0,Rs.default)(new Uint32Array(t.shape[0]),[t.shape[0]]);for(let l=0;l<s;l++){let u=l*r,c=l+1<s?(l+1)*r:n,h;t.shape.length>1?h=bl.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):h=bl.createFromUnnormalized(t.hi(c).lo(u)),o.set(l,0,h.minD),o.set(l,1,h.maxD),a.shape.length>1?bo.assign(a.hi(c,a.shape[1]).lo(u,0),tr.fromNormalized(h,e).quantized):bo.assign(a.hi(c).lo(u),tr.fromNormalized(h,e).quantized)}return new rr(a,o,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],n=this._quantizationMethod,s=this._chunkSize,o;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");o=this._variableChunkSize}let a;n==="norm8x"?a=(0,Rs.default)(new Float32Array(e.size),e.shape):a=(0,Rs.default)(new Float32Array(r*3),[r,3]);let l=0,u=s;for(let c=0;c<t;c++){let[h,d]=[this._minMaxMatrix.get(c,0),this._minMaxMatrix.get(c,1)];this._isDynamicChunks&&(u=o[c]);let f=c+1<t?l+u:r,p;e.shape.length>1?p=new tr(e.hi(f,e.shape[1]).lo(l,0),n):p=new tr(e.hi(f).lo(l),n),bo.assign(a.hi(f,a.shape[1]).lo(l,0),p.dequantize(h,d).denormalize()),l=f}return a}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var ha=pn(Kd()),wt=pn(Zd());var vR="http://127.0.0.1:8000";var Ic=pn(Kd()),Xt=pn(Zd());var xR=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function bR(i){return i<1e5?i<100?i<10?0:1:i<1e4?i<1e3?2:3:4:i<1e7?i<1e6?5:6:i<1e9?i<1e8?7:8:9}function wR(i,t){if(i===t)return 0;if(~~i===i&&~~t===t){if(i===0||t===0)return i<t?-1:1;if(i<0||t<0){if(t>=0)return-1;if(i>=0)return 1;i=-i,t=-t}let n=bR(i),s=bR(t),o=0;return n<s?(i*=xR[s-n-1],t/=10,o=-1):n>s&&(t*=xR[n-s-1],i/=10,o=1),i===t?o:i<t?-1:1}let e=String(i),r=String(t);return e===r?0:e<r?-1:1}function G7(i){let t=0;for(;i>=32;)t|=i&1,i>>=1;return i+t}function SR(i,t,e,r){let n=t+1;if(n===e)return 1;if(r(i[n++],i[t])<0){for(;n<e&&r(i[n],i[n-1])<0;)n++;H7(i,t,n)}else for(;n<e&&r(i[n],i[n-1])>=0;)n++;return n-t}function H7(i,t,e){for(e--;t<e;){let r=i[t];i[t++]=i[e],i[e--]=r}}function AR(i,t,e,r,n){for(r===t&&r++;r<e;r++){let s=i[r],o=t,a=r;for(;o<a;){let u=o+a>>>1;n(s,i[u])<0?a=u:o=u+1}let l=r-o;switch(l){case 3:i[o+3]=i[o+2];case 2:i[o+2]=i[o+1];case 1:i[o+1]=i[o];break;default:for(;l>0;)i[o+l]=i[o+l-1],l--}i[o]=s}}function c1(i,t,e,r,n,s){let o=0,a=0,l=1;if(s(i,t[e+n])>0){for(a=r-n;l<a&&s(i,t[e+n+l])>0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a),o+=n,l+=n}else{for(a=n+1;l<a&&s(i,t[e+n-l])<=0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a);let u=o;o=n-l,l=n-u}for(o++;o<l;){let u=o+(l-o>>>1);s(i,t[e+u])>0?o=u+1:l=u}return l}function u1(i,t,e,r,n,s){let o=0,a=0,l=1;if(s(i,t[e+n])<0){for(a=n+1;l<a&&s(i,t[e+n-l])<0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a);let u=o;o=n-l,l=n-u}else{for(a=r-n;l<a&&s(i,t[e+n+l])>=0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a),o+=n,l+=n}for(o++;o<l;){let u=o+(l-o>>>1);s(i,t[e+u])<0?l=u:o=u+1}return l}var h1=class{constructor(t,e){mn(this,"array",null);mn(this,"compare",null);mn(this,"minGallop",7);mn(this,"length",0);mn(this,"tmpStorageLength",256);mn(this,"stackLength",0);mn(this,"runStart",null);mn(this,"runLength",null);mn(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]<this.runLength[t+1]&&t--;else if(this.runLength[t]>this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]<this.runLength[t+1]&&t--,this.mergeAt(t)}}mergeAt(t){let e=this.compare,r=this.array,n=this.runStart[t],s=this.runLength[t],o=this.runStart[t+1],a=this.runLength[t+1];this.runLength[t]=s+a,t===this.stackSize-3&&(this.runStart[t+1]=this.runStart[t+2],this.runLength[t+1]=this.runLength[t+2]),this.stackSize--;let l=u1(r[o],r,n,s,0,e);n+=l,s-=l,s!==0&&(a=c1(r[n+s-1],r,o,a,a-1,e),a!==0&&(s<=a?this.mergeLow(n,s,o,a):this.mergeHigh(n,s,o,a)))}mergeLow(t,e,r,n){let s=this.compare,o=this.array,a=this.tmp,l=0;for(l=0;l<e;l++)a[l]=o[t+l];let u=0,c=r,h=t;if(o[h++]=o[c++],--n===0){for(l=0;l<e;l++)o[h+l]=a[u+l];return}if(e===1){for(l=0;l<n;l++)o[h+l]=o[c+l];o[h+n]=a[u];return}let d=this.minGallop;for(;;){let f=0,p=0,m=!1;do if(s(o[c],a[u])<0){if(o[h++]=o[c++],p++,f=0,--n===0){m=!0;break}}else if(o[h++]=a[u++],f++,p=0,--e===1){m=!0;break}while((f|p)<d);if(m)break;do{if(f=u1(o[c],a,u,e,0,s),f!==0){for(l=0;l<f;l++)o[h+l]=a[u+l];if(h+=f,u+=f,e-=f,e<=1){m=!0;break}}if(o[h++]=o[c++],--n===0){m=!0;break}if(p=c1(a[u],o,c,n,0,s),p!==0){for(l=0;l<p;l++)o[h+l]=o[c+l];if(h+=p,c+=p,n-=p,n===0){m=!0;break}}if(o[h++]=a[u++],--e===1){m=!0;break}d--}while(f>=7||p>=7);if(m)break;d<0&&(d=0),d+=2}if(this.minGallop=d,d<1&&(this.minGallop=1),e===1){for(l=0;l<n;l++)o[h+l]=o[c+l];o[h+n]=a[u]}else{if(e===0)throw new Error("mergeLow preconditions were not respected");for(l=0;l<e;l++)o[h+l]=a[u+l]}}mergeHigh(t,e,r,n){let s=this.compare,o=this.array,a=this.tmp,l=0;for(l=0;l<n;l++)a[l]=o[r+l];let u=t+e-1,c=n-1,h=r+n-1,d=0,f=0;if(o[h--]=o[u--],--e===0){for(d=h-(n-1),l=0;l<n;l++)o[d+l]=a[l];return}if(n===1){for(h-=e,u-=e,f=h+1,d=u+1,l=e-1;l>=0;l--)o[f+l]=o[d+l];o[h]=a[c];return}let p=this.minGallop;for(;;){let m=0,g=0,y=!1;do if(s(a[c],o[u])<0){if(o[h--]=o[u--],m++,g=0,--e===0){y=!0;break}}else if(o[h--]=a[c--],g++,m=0,--n===1){y=!0;break}while((m|g)<p);if(y)break;do{if(m=e-u1(a[c],o,t,e,e-1,s),m!==0){for(h-=m,u-=m,e-=m,f=h+1,d=u+1,l=m-1;l>=0;l--)o[f+l]=o[d+l];if(e===0){y=!0;break}}if(o[h--]=a[c--],--n===1){y=!0;break}if(g=n-c1(o[u],a,0,n,n-1,s),g!==0){for(h-=g,c-=g,n-=g,f=h+1,d=c+1,l=0;l<g;l++)o[f+l]=a[d+l];if(n<=1){y=!0;break}}if(o[h--]=o[u--],--e===0){y=!0;break}p--}while(m>=7||g>=7);if(y)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),n===1){for(h-=e,u-=e,f=h+1,d=u+1,l=e-1;l>=0;l--)o[f+l]=o[d+l];o[h]=a[c]}else{if(n===0)throw new Error("mergeHigh preconditions were not respected");for(d=h-(n-1),l=0;l<n;l++)o[d+l]=a[l]}}};function _R(i,t,e,r){if(!Array.isArray(i))throw new TypeError("Can only sort arrays");t?typeof t!="function"&&(r=e,e=t,t=wR):t=wR,e||(e=0),r||(r=i.length);let n=r-e;if(n<2)return;let s=0;if(n<32){s=SR(i,e,r,t),AR(i,e,r,e+s,t);return}let o=new h1(i,t),a=G7(n);do{if(s=SR(i,e,r,t),s<a){let l=n;l>a&&(l=a),AR(i,e,e+l,e+s,t),s=l}o.pushRun(e,s),o.mergeRuns(),n-=s,e+=s}while(n!==0);o.forceMergeRuns()}function d1(i){let t=(0,Ic.default)(new Int32Array(i.shape[0]),[i.shape[0]]),e=(0,Ic.default)(new Int32Array(i.shape[0]),[i.shape[0]]);return Xt.bands(t,i,1023),Xt.lshifts(e,t,16),Xt.bxoreq(t,e),Xt.bandseq(t,4278190335),Xt.lshifts(e,t,8),Xt.bxoreq(t,e),Xt.bandseq(t,50393103),Xt.lshifts(e,t,4),Xt.bxoreq(t,e),Xt.bandseq(t,51130563),Xt.lshifts(e,t,2),Xt.bxoreq(t,e),Xt.bandseq(t,153391689),t}function j7(i){let t=d1(i.pick(null,0)),e=d1(i.pick(null,1));Xt.lshiftseq(e,1);let r=d1(i.pick(null,2));return Xt.lshiftseq(r,2),Xt.boreq(t,e),Xt.boreq(t,r),t}function wl(i,t){if(i.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,Ic.default)(new Float32Array(i.size),i.shape,i.stride,i.offset);for(let r=0;r<t.shape[0];r++){let n=t.get(r);if(i.shape.length>1)for(let s=0;s<i.shape[1];s++)e.set(r,s,i.get(n,s));else e.set(r,i.get(n))}return e}function f1(i){let t=Xt.sup(i),e=Xt.inf(i),r=1e3/Math.min(1e3,t-e),n=(0,Ic.default)(new Float32Array(i.data),i.shape);Xt.mulseq(n,r);let s=(0,Ic.default)(new Int32Array(n.data),i.shape),o=j7(s),l=Array.from(o.data).map((h,d)=>[h,d]);_R(l,(h,d)=>h[0]-d[0]);let u=l.map(([h,d])=>d);return(0,Ic.default)(Uint32Array.from(u))}var os=class{constructor(t,e,r,n,s,o,a,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=n,this.colors=s,this.harmonics=o,this.opacity=a,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=os._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,n=(0,ha.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(wt.assign(n.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let a=0;a<this.harmonics.length;a++){let l=a*3;wt.assign(n.pick(null,this.propertyDescs[`f_rest_${l}`].index),this.harmonics[a].pick(null,0)),wt.assign(n.pick(null,this.propertyDescs[`f_rest_${l+1}`].index),this.harmonics[a].pick(null,1)),wt.assign(n.pick(null,this.propertyDescs[`f_rest_${l+2}`].index),this.harmonics[a].pick(null,2))}let s=new Uint8Array(n.data.buffer),o=new Uint8Array(s.length+e.length);return o.set(e),o.set(s,e.length),o.buffer}save(t,e){let r=this.getPlyBinary(),n=new Blob([r],{type:"application/octet-stream"}),s=new File([n],t),o=new FormData;o.append("file",s),o.append("filename",t),o.append("basedir",e),fetch(`${vR}/push_file`,{method:"POST",body:o})}static async loadFile(t){return await(await fetch(t)).arrayBuffer()}mortonPositionSplatsSort(){let t=f1(this.xyz),e=wl(this.xyz,t),r=wl(this.colors,t),n=wl(this.opacity,t),s=wl(this.scaling,t),o=wl(this.rotation,t),a=[];for(let l=0;l<this.harmonics.length;l++)a.push(wl(this.harmonics[l],t));return new os(this.propertyDescs,this.format,this.nsplats,e,r,a,n,s,o,this.maxSHDegree)}static _generateHeaderString(t,e,r){let n=`ply
|
6252 | format ${e.format} ${e.version}
|
6253 | element vertex ${r}`,s=Object.keys(t).length,o=Array(s);for(let a in t){let l=t[a];o[l.index]={name:a,dtype:l.dtype}}for(let a=0;a<o.length;a++)n=`${n}
|
6254 | property ${o[a].dtype} ${o[a].name}`;return`${n}
|
6255 | end_header
|
6256 | `}static fromArrayBuffer(t,e=3){let{splatCount:r,vertexData:n,propertiesDesc:s,format:o}=os.decodeHeader(t),a=n.buffer.slice(n.byteOffset),l=Object.keys(s).length,u=(0,ha.default)(new Float32Array(a),[r,l]),c=0,h={},d={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1};for(let S in s)if(s.hasOwnProperty(S)){let A=s[S].dtype;h[S]=c,c+=d[A]}let f=(0,ha.default)(new Float32Array(r*3),[r,3]);wt.assign(f.pick(null,0),u.pick(null,h.x/4)),wt.assign(f.pick(null,1),u.pick(null,h.y/4)),wt.assign(f.pick(null,2),u.pick(null,h.z/4));let p=(0,ha.default)(new Float32Array(r*3),[r,3]);wt.assign(p.pick(null,0),u.pick(null,h.scale_0/4)),wt.assign(p.pick(null,1),u.pick(null,h.scale_1/4)),wt.assign(p.pick(null,2),u.pick(null,h.scale_2/4));let m=(0,ha.default)(new Float32Array(r*3),[r,3]);wt.assign(m.pick(null,0),u.pick(null,h.f_dc_0/4)),wt.assign(m.pick(null,1),u.pick(null,h.f_dc_1/4)),wt.assign(m.pick(null,2),u.pick(null,h.f_dc_2/4));let g=(0,ha.default)(new Float32Array(r*4),[r,4]);wt.assign(g.pick(null,0),u.pick(null,h.rot_1/4)),wt.assign(g.pick(null,1),u.pick(null,h.rot_2/4)),wt.assign(g.pick(null,2),u.pick(null,h.rot_3/4)),wt.assign(g.pick(null,3),u.pick(null,h.rot_0/4));for(let S=0;S<r;S++){let A=g.pick(S,null),E=Math.sqrt(A.get(0)**2+A.get(1)**2+A.get(2)**2+A.get(3)**2);wt.divseq(A,E)}let y=(0,ha.default)(new Float32Array(r*1),[r,1]);wt.assign(y.pick(null,0),u.pick(null,h.opacity/4));let x=(Math.min(Math.max(e,0),3)+1)**2-1,w=[];for(let S=0;S<x;S++){let A=(0,ha.default)(new Float32Array(r*3),[r,3]),E=S*3;wt.assign(A.pick(null,0),u.pick(null,h[`f_rest_${E}`]/4)),wt.assign(A.pick(null,1),u.pick(null,h[`f_rest_${E+1}`]/4)),wt.assign(A.pick(null,2),u.pick(null,h[`f_rest_${E+2}`]/4)),w.push(A)}return new os(s,o,r,f,m,w,y,p,g,e)}static async fromPLYFile(t,e=3){let r=await os.loadFile(t);return os.fromArrayBuffer(r,e)}static decodeHeader(t){let e=new TextDecoder,r=0,n="",s=100;for(;;){if(r+s>=t.byteLength)throw new Error("End of file reached while searching for end of header");let p=new Uint8Array(t,r,s);n+=e.decode(p),r+=s;let m=r-s*2,g=new Uint8Array(t,Math.max(0,m),m>0?s*2:s);if(e.decode(g).includes("end_header"))break}let o=n.split(`
|
6257 | `),a=0,l={},u={},c=0,h;for(let p=0;p<o.length;p++){let m=o[p].trim();if(m.startsWith("element vertex")){let g=m.match(/\d+/);g&&(a=parseInt(g[0]))}else if(m.startsWith("property")){let g=m.match(/(\w+)\s+(\w+)\s+(\w+)/);if(g){let y=g[2],v=g[3];l[v]=c,u[v]={dtype:y,index:c},c++}}else if(m.startsWith("format")){let g=m.match(/(\w+)\s+(\w+)\s+(\d+\.?\d*)/);g&&(h={format:g[2],version:g[3]})}else if(m==="end_header")break}let d=n.indexOf("end_header")+10+1,f=new DataView(t,d);return{splatCount:a,vertexData:f,headerOffset:r,propertiesDesc:u,format:h}}};var Oc=class{constructor(t,e,r,n,s,o,a,l){this.config=t,this.xyz=e,this.scaling=r,this.color=n,this.opacity=s,this.harmonics=a,this.quaternion=o,this.variableChunkSize=l}get isDynamicChunks(){return this.variableChunkSize&&this.variableChunkSize.length>0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=rr.fromArray(t.xyz,e.xyz,e.chunkSize),n=rr.fromArray(t.scaling,e.scaling,e.chunkSize),s=rr.fromArray(t.colors,e.color,e.chunkSize),o=rr.fromArray(t.opacity,e.opacity,e.chunkSize),a=rr.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c<l.length;c++){let h=rr.fromArray(l[c],e.harmonics,e.chunkSize);u.push(h)}return new Oc(e,r,n,s,o,a,u)}_countIndexesInChunks(t){let e=[],r=this.nchunks,n=this.chunkSize,s=this.nsplats,o=rr.getRequiredNChunks(s,n);if(r===o)for(let a=0;a<t.length;a++){let l=t[a],u=Math.floor(l/this.chunkSize);u in e?e[u].push(l):e[u]=[l]}else{let a=this.variableChunkSize,l={},u=0;for(let c=0;c<r;c++)l[c]=u,u+=a[c];for(let c=0;c<t.length;c++){let h=t[c],d=Math.min(Math.floor(h/n),r-1);for(;h>=l[d]+a[d];)d++;d in e?e[d].push(h):e[d]=[h]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,n=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((s,o)=>{r[o]-=s.length,r[o]<=0&&n.push(o)}),r=r.filter(s=>s>0)),new Oc(this.config,this.xyz.pruneFeature(t,n,r),this.scaling.pruneFeature(t,n,r),this.color.pruneFeature(t,n,r),this.opacity.pruneFeature(t,n,r),this.quaternion.pruneFeature(t,n,r),this.harmonics?this.harmonics.map(s=>s.pruneFeature(t,n,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let o=0;o<this.harmonics.length;o++)e[`f_rest_${o}`]={dtype:"float",index:r},r++,e[`f_rest_${o+1}`]={dtype:"float",index:r},r++,e[`f_rest_${o+2}`]={dtype:"float",index:r},r++;e.opacity={dtype:"float",index:r},r++,e.scale_0={dtype:"float",index:r},r++,e.scale_1={dtype:"float",index:r},r++,e.scale_2={dtype:"float",index:r},r++,e.rot_0={dtype:"float",index:r},r++,e.rot_1={dtype:"float",index:r},r++,e.rot_2={dtype:"float",index:r},r++,e.rot_3={dtype:"float",index:r},r++;let n=this.harmonics?.map(o=>o.denormDequant());return new os(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),n||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Rc=pn(Kd()),Jr=pn(Zd());var ER={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},Sl=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),n=(0,Rc.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return Jr.mulseq(e,t),Jr.addseq(e,.5),Jr.mulseq(e,255),Jr.maxseq(e,0),Jr.minseq(e,255),Jr.negeq(r),Jr.expeq(r),Jr.addseq(r,1),Jr.recipeq(r),Jr.mulseq(r,255),Jr.assign(n.hi(e.shape[0],3).lo(0,0),e),Jr.assign(n.hi(e.shape[0],4).lo(0,3),r),(0,Rc.default)(new Uint8Array(n.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:n,vertexData:s,propertiesDesc:o}=this.decodeHeader(),a={xyz:o.xyz.compressionMethod,color:o.color.compressionMethod,opacity:o.opacity.compressionMethod,scaling:o.scaling.compressionMethod,quaternion:o.quaternion.compressionMethod,chunkSize:r};o.harmonics_0&&(a.harmonics=o.harmonics_0.compressionMethod);let l=s.byteOffset,u=Array(Object.keys(o).length);for(let y in o)u[o[y].index]={name:y,method:o[y].compressionMethod};let c=e*2*4,h=l,d=n==="dynamic"?e*2:0,f,p=!1;if(d>0){let y=new Uint16Array(s.buffer.slice(h,h+d));h+=d,f=Array.from(y),p=!0}let m={};for(let y of u){let v=0,x=!0;if(y.method==="norm8x")v=t*1*ER[y.name];else if(y.method==="norm11")v=t*4;else if(y.method==="norm565")v=t*2;else throw x=!1,new Error(`Not Implemented format: ${y.method}`);let w;if(x){let E=s.buffer.slice(h,h+c);w=(0,Rc.default)(new Float32Array(E),[e,2]),h+=c}else throw new Error("loading chunk byt hasnot minmax!");let S=s.buffer.slice(h,h+v);h+=v;let A;if(y.method==="norm8x")A=(0,Rc.default)(new Uint8Array(S),[t,ER[y.name]]);else if(y.method==="norm11")A=(0,Rc.default)(new Uint32Array(S));else if(y.method==="norm565")A=(0,Rc.default)(new Uint16Array(S));else throw new Error(`Not Implemented format: ${y.method}`);m[y.name]=new rr(A,w,r,y.method,f,p)}let g=[];for(let y=0;y<15;y++){let v=m[`harmonics_${y}`];v&&(g.push(v),delete m[`harmonics_${y}`])}return g.length>0&&(m.harmonics=g),new Oc(a,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,n=r.nsplats,s=new ArrayBuffer(24*n),o=new Float32Array(s),a=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new He,c=new Gt,h=new Gt,d=new Gt,f=new ie;for(let p=0;p<n;p++){f.makeScale(Math.exp(a.get(p,0)),Math.exp(a.get(p,1)),Math.exp(a.get(p,2))),h.setFromMatrix4(f),u.set(l.get(p,0),l.get(p,1),l.get(p,2),l.get(p,3)),f.makeRotationFromQuaternion(u),c.setFromMatrix4(f),d.copy(c).multiply(h);let m=d.elements;o[6*p]=m[0]*m[0]+m[3]*m[3]+m[6]*m[6],o[6*p+1]=m[0]*m[1]+m[3]*m[4]+m[6]*m[7],o[6*p+2]=m[0]*m[2]+m[3]*m[5]+m[6]*m[8],o[6*p+3]=m[1]*m[1]+m[4]*m[4]+m[7]*m[7],o[6*p+4]=m[1]*m[2]+m[4]*m[5]+m[7]*m[8],o[6*p+5]=m[2]*m[2]+m[5]*m[5]+m[8]*m[8]}this._precomputedCovarianceBufferData=s}decodeHeader(){let t=this._buffer,e=new TextDecoder,r=0,n="",s=100;for(;;){if(r+s>=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,s);n+=e.decode(m),r+=s;let g=r-s*2,y=new Uint8Array(t,Math.max(0,g),g>=0?s*2:s);if(e.decode(y).includes("end_header"))break}let o=n.split(`
|
6258 | `),a=0,l=0,u=0,c=0,h="",d={};for(let m=0;m<o.length;m++){let g=o[m].trim();if(g.startsWith("element vertex")){let y=g.match(/\d+/);y&&(a=parseInt(y[0]))}else if(g.startsWith("property")){let y=g.match(/(\w+)\s+(\w+)\s+(\w+)/);if(y){let v=y[2],x=y[3];d[v]={compressionMethod:x,index:c},c++}}else if(g.startsWith("element chunks")){let y=g.match(/\d+/);y&&(l=parseInt(y[0]))}else if(g.startsWith("element chunkSize")){let y=g.match(/\d+/);y&&(u=parseInt(y[0]))}else if(g.startsWith("element typeChunks")){let y=g.match(/(\w+)\s+(\w+)\s+(\w+)/);y&&(h=y[3])}else if(g==="end_header")break}let f=n.indexOf("end_header")+10+1,p=new DataView(t,f);return{splatCount:a,chunkCount:l,chunkSize:u,typeChunks:h,vertexData:p,propertiesDesc:d}}pruneSplats(t){let r=this.decodeBuffer().pruneSplats(t);return Sl.fromCompressedGaussianSplats(r)}static fromCompressedGaussianSplats(t){let e=t.xyz.length,r=t.xyz.nchunks,n=`gspline
|
6259 | element vertex ${e}
|
6260 | element chunks ${r}
|
6261 | element chunkSize ${t.chunkSize}
|
6262 | element typeChunks ${t.isDynamicChunks?"dynamic":"static"}
|
6263 | property xyz ${t.xyz.method}
|
6264 | property color ${t.color.method}
|
6265 | property opacity ${t.opacity.method}
|
6266 | property scaling ${t.scaling.method}
|
6267 | property quaternion ${t.quaternion.method}`;if(t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++)n=`${n}
|
6268 | property harmonics_${M} ${t.harmonics[M].method}`;n=`${n}
|
6269 | end_header
|
6270 | `;let o=new TextEncoder().encode(n),a=r*2*4,l=t.xyz.quantized.data.buffer.byteLength,u=t.xyz instanceof rr?a:0,c=t.color.quantized.data.buffer.byteLength,h=t.color instanceof rr?a:0,d=t.opacity.quantized.data.buffer.byteLength,f=t.opacity instanceof rr?a:0,p=t.scaling.quantized.data.buffer.byteLength,m=t.scaling instanceof rr?a:0,g=t.quaternion.quantized.data.buffer.byteLength,y=t.quaternion instanceof rr?a:0,v=t.variableChunkSize?Uint16Array.from(t.variableChunkSize):void 0,x=v?v.byteLength:0,w=o.byteLength+x+l+u+c+h+d+f+p+m+g+y,S=0,A=0;if(t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++)S+=t.harmonics[M].quantized.data.buffer.byteLength,A+=t.harmonics[M]instanceof rr?a:0;S=0,A=0,w+=S+A;let E=new Uint8Array(w),b=0;if(E.set(o,b),b+=o.byteLength,x>0&&(E.set(new Uint8Array(v.buffer),b),b+=x),t.xyz instanceof rr&&(E.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.xyz.quantized.data.buffer),b),b+=l,t.color instanceof rr&&(E.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.color.quantized.data.buffer),b),b+=c,t.opacity instanceof rr&&(E.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.opacity.quantized.data.buffer),b),b+=d,t.scaling instanceof rr&&(E.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.scaling.quantized.data.buffer),b),b+=p,t.quaternion instanceof rr&&(E.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.quaternion.quantized.data.buffer),b),b+=g,S>0&&t.harmonics&&t.harmonics.length>0)for(let M=0;M<t.harmonics.length;M++){let T=t.harmonics[M];T instanceof rr&&(E.set(new Uint8Array(T.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(T.quantized.data.buffer),b),b+=T.quantized.data.byteLength}return new Sl(E.buffer)}};var MR="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEXA2AAAGAMf39/f399fX1/f39/AGAAAX8CEgEDZW52Bm1lbW9yeQIDAICABAMEAwABAgc5AxFfX3dhc21fY2FsbF9jdG9ycwAAC3NvcnRJbmRleGVzAAETZW1zY3JpcHRlbl90bHNfaW5pdAACCrsEAwMAAQuvBAIDfwF9AkAgCUUEQCACIAtBAnRqIQEgCLNDAACAr5QhBUH4////ByENDAELIAMqAighBSADKgIYIQYgAyoCCCEHQfj///8HIQ1BiICAgHghDgNAIAIgDEECdGoCfyAHIAEgDEEMbGoiAyoCAJQgBiADKgIElJIgBSADKgIIlJJDAADIQpQiD4tDAAAAT10EQCAPqAwBC0GAgICAeAsiAzYCACADIA0gAyANSBshDSADIA4gAyAOShshDiAMQQFqIgwgCUcNAAsgAiALQQJ0aiEBIAizIA6yIA2yk5UhBSAJRQ0AQQAhAwNAIAECfyAFIAIgA0ECdGooAgAgDWuylCIGi0MAAABPXQRAIAaoDAELQYCAgIB4C0ECdGoiDCAMKAIAQQFqNgIAIANBAWoiAyAJRw0ACwsgCEECTwRAIAIgC0ECdGohDiABKAIAIQxBASEDA0AgDiADQQJ0aiIBIAEoAgAgDGoiDDYCACADQQFqIgMgCEcNAAsLIAkgCkEBayIDTARAA0AgBCADQQJ0IgFqIAAgAWooAgA2AgAgA0EBayIDIAlODQALCyAJQQBKBEAgAiALQQJ0aiEDIAlBAWsiCCEMA0AgBCAIIAMCfyAFIAIgDCIBQQJ0IglqKAIAIA1rspQiBotDAAAAT10EQCAGqAwBC0GAgICAeAtBAnRqIgooAgBBAWsiC2tBAnRqIAAgCWooAgA2AgAgCiALNgIAIAFBAWshDCABDQALCwsEAEEACw==";var wo=class{};mn(wo,"DepthMapRange",1<<16),mn(wo,"MemoryPageSize",65536),mn(wo,"BytesPerFloat",4),mn(wo,"BytesPerInt",4);function W7(i){let t,e,r,n,s,o,a,l,u,c,h,d,f,p,m,g;function y(C,P){let D=performance.now();h||(h=new Uint32Array(d.DepthMapRange));let I=new Float32Array(u,o,16);for(let G=0;G<16;G++)I[G]=C[G];new Uint32Array(u,l+e*4,d.DepthMapRange).set(h),t.exports.sortIndexes(n,s,l,o,a,P[0],P[1],P[2],d.DepthMapRange,r,r,e);let V=performance.now(),k=new Uint32Array(r),z=k.buffer;k.set(new Uint32Array(u,a,r)),i.postMessage({sortDone:!0,splatSortCount:r,splatRenderCount:r,sortTime:V-D,indexesBuffer:z},[z])}function v(C,P,D){let I=new Float32Array(u,s,e*3);r=0;let R=new Uint32Array(u,n,e);for(let V=0;V<D.length-1;V++){let k=P[V],z=C[V].elements,G;k?.length>0&&(G=k.map(H=>H.type==="Box"?A(H):M(H)));for(let H=D[V];H<D[V+1];H++){let Q=f[H*3],F=f[H*3+1],j=f[H*3+2];if(!G||w(Q,F,j,G)){let Y=1/(z[3]*Q+z[7]*F+z[11]*j+z[15]);I[r*3]=(z[0]*Q+z[4]*F+z[8]*j+z[12])*Y,I[r*3+1]=(z[1]*Q+z[5]*F+z[9]*j+z[13])*Y,I[r*3+2]=(z[2]*Q+z[6]*F+z[10]*j+z[14])*Y,R[r]=H,r++}}}}function x(C,P){let D=[],I;P?.length>0&&(I=P.map(V=>V.type==="Box"?A(V):M(V)));let R=C.length;for(let V=0;V<R;V+=3){let k=C[V],z=C[V+1],G=C[V+2];w(k,z,G,I)===!1&&D.push(V/3)}return D}function w(C,P,D,I,R){return I[R==="Intersect"?"every":"some"](V=>{let k=S(C,P,D,V.invRotationMatrix,V.cropCenter);return Array.isArray(V)?b(k.x,k.y,k.z,V):T(k.x,k.y,k.z,V)})}function S(C,P,D,I,R){let V=C-R[0],k=P-R[1],z=D-R[2],G=1/(I[3]*V+I[7]*k+I[11]*z+I[15]);return{x:(I[0]*V+I[4]*k+I[8]*z+I[12])*G+R[0],y:(I[1]*V+I[5]*k+I[9]*z+I[13])*G+R[1],z:(I[2]*V+I[6]*k+I[10]*z+I[14])*G+R[2]}}function A(C){let P=C.cropSize[0]/2,D=C.cropSize[1]/2,I=C.cropSize[2]/2,R=[C.cropCenter[0]-P,C.cropCenter[1]-D,C.cropCenter[2]-I,C.cropCenter[0]+P,C.cropCenter[1]+D,C.cropCenter[2]+I],V=E(C.cropRotation);return Object.assign(R,{invRotationMatrix:V,cropCenter:C.cropCenter})}function E(C){let P=[],D=C[0]*Math.PI/180,I=C[1]*Math.PI/180,R=C[2]*Math.PI/180,V=Math.cos(D),k=Math.sin(D),z=Math.cos(I),G=Math.sin(I),H=Math.cos(R),Q=Math.sin(R),F=V*H,j=V*Q,Y=k*H,q=k*Q;return P[0]=z*H,P[1]=-z*Q,P[2]=G,P[4]=j+Y*G,P[5]=F-q*G,P[6]=-k*z,P[8]=q-F*G,P[9]=Y+j*G,P[10]=V*z,P[12]=0,P[13]=0,P[14]=0,P[3]=0,P[7]=0,P[11]=0,P[15]=1,P}function b(C,P,D,I){return C>=I[0]&&C<=I[3]&&P>=I[1]&&P<=I[4]&&D>=I[2]&&D<=I[5]}function M(C){let P=2/C.cropSize[0],D=2/C.cropSize[1],I=2/C.cropSize[2],R=E(C.cropRotation);return{invRadiusX:P,invRadiusY:D,invRadiusZ:I,cropCenter:C.cropCenter,invRotationMatrix:R}}function T(C,P,D,I){let R=(C-I.cropCenter[0])*I.invRadiusX,V=(P-I.cropCenter[1])*I.invRadiusY,k=(D-I.cropCenter[2])*I.invRadiusZ;return R*R+V*V+k*k<=1}i.onmessage=C=>{if(C.data.getCroppedIndexes){let P=new Uint32Array(x(new Float32Array(C.data.positions),C.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:P},[P])}else if(C.data.positions)c=C.data.positions,f=new Float32Array(c),m=C.data.meshMatrixWorlds,g=C.data.cropsArray,p=C.data.meshIndexIntervals,v(m,g,p),i.postMessage({sortSetupComplete:!0});else if(C.data.sort||C.data.newMatrixWorlds||C.data.newCropsArray)(C.data.newMatrixWorlds||C.data.newCropsArray)&&(g=C.data.newCropsArray||g,m=C.data.newMatrixWorlds||m,v(m,g,p)),y(C.data.sort.view,C.data.sort.cameraPosition);else if(C.data.init){d=C.data.init.Constants,e=C.data.init.splatCount;let P=d.BytesPerInt,D=d.BytesPerFloat*3,I=new Uint8Array(C.data.init.sorterWasmBytes),R=P+D,V=e*R,k=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,z=d.MemoryPageSize*32,G=V+k+z,H=Math.floor(G/d.MemoryPageSize)+1,Q={module:{},env:{memory:new WebAssembly.Memory({initial:H*2,maximum:H*3,shared:!0})}};WebAssembly.compile(I).then(F=>WebAssembly.instantiate(F,Q)).then(F=>{t=F,n=0,s=e*P,o=s+e*D,l=o+16*d.BytesPerFloat,a=l+e*d.BytesPerInt+d.DepthMapRange*d.BytesPerInt*2,u=Q.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function TR(i){let t=new Worker(URL.createObjectURL(new Blob(["(",W7.toString(),")(self)"],{type:"application/javascript"}))),e=atob(MR),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:i,Constants:{BytesPerFloat:wo.BytesPerFloat,BytesPerInt:wo.BytesPerInt,DepthMapRange:wo.DepthMapRange,MemoryPageSize:wo.MemoryPageSize}}}),t}var L0=function(){let i=new Float32Array(1),t=new Int32Array(i.buffer);return function(e){return i[0]=e,t[0]}}(),CR=function(i,t,e,r){return i+(t<<8)+(e<<16)+(r<<24)};var N0=new N,Al=class extends _r{constructor(e,r,n,s,o=!1,a=1,l,u){super(n,s);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=u,this.splatBuffers=e,this.geometry=n,this.material=s,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=o,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,n=!1,s=1,o,a){let l=Al.buildGeomtery(r),u=Al.buildMaterial(o);return new Al(e,r,l,u,n,s,o,a)}static buildMaterial(e){let r=`
|
6271 | precision highp float;
|
6272 | #include <common>
|
6273 |
|
6274 | attribute uint splatIndex;
|
6275 |
|
6276 | uniform highp sampler2D covariancesTexture;
|
6277 | uniform highp usampler2D centersColorsTexture;
|
6278 | uniform vec2 focal;
|
6279 | uniform vec2 viewport;
|
6280 | uniform vec2 basisViewport;
|
6281 | uniform vec2 covariancesTextureSize;
|
6282 | uniform vec2 centersColorsTextureSize;
|
6283 | uniform highp sampler2D meshMatrixWorldsTexture;
|
6284 | uniform uint meshIndexIntervals[257];
|
6285 | uniform float orthoZoom;
|
6286 |
|
6287 | varying vec4 vColor;
|
6288 | varying vec2 vUv;
|
6289 |
|
6290 | varying vec2 vPosition;
|
6291 |
|
6292 | const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
|
6293 | const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000));
|
6294 | const uvec4 shift4 = uvec4(0, 8, 16, 24);
|
6295 | vec4 uintToRGBAVec (uint u) {
|
6296 | uvec4 urgba = mask4 & u;
|
6297 | urgba = urgba >> shift4;
|
6298 | vec4 rgba = vec4(urgba) * encodeNorm4;
|
6299 | return rgba;
|
6300 | }
|
6301 |
|
6302 | vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) {
|
6303 | vec2 samplerUV = vec2(0.0, 0.0);
|
6304 | float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x;
|
6305 | samplerUV.y = float(floor(d)) / dimensions.y;
|
6306 | samplerUV.x = fract(d);
|
6307 | return samplerUV;
|
6308 | }
|
6309 |
|
6310 | void main () {
|
6311 | uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize));
|
6312 | vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba));
|
6313 | vColor = uintToRGBAVec(sampledCenterColor.r);
|
6314 |
|
6315 | vPosition = position.xy * 2.0;
|
6316 |
|
6317 | uint meshIndex;
|
6318 | for (int i = 1; i < 257; i++) {
|
6319 | if (splatIndex < meshIndexIntervals[i]) {
|
6320 | meshIndex = uint(i - 1);
|
6321 | break;
|
6322 | }
|
6323 | }
|
6324 |
|
6325 | float strideMulmeshIndex = float(4u*meshIndex);
|
6326 | float meshMatrixWorldsTextureLength = float(256*4);
|
6327 |
|
6328 | mat4 modelMat = mat4(
|
6329 | texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)),
|
6330 | texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)),
|
6331 | texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)),
|
6332 | texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0))
|
6333 | );
|
6334 | mat4 modelViewMat = viewMatrix * modelMat;
|
6335 | vec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0);
|
6336 | vec4 clipCenter = projectionMatrix * viewCenter;
|
6337 |
|
6338 | vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg;
|
6339 | vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg;
|
6340 | vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg;
|
6341 |
|
6342 | vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r);
|
6343 | vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg);
|
6344 |
|
6345 |
|
6346 | mat3 Vrk = mat3(
|
6347 | cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z,
|
6348 | cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y,
|
6349 | cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z
|
6350 | );
|
6351 | float s = 1.0 / (viewCenter.z * viewCenter.z);
|
6352 |
|
6353 | mat3 W = transpose(mat3(modelViewMat));
|
6354 | mat3 T = orthoZoom > 0.0 ? W : W * mat3(
|
6355 | focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s,
|
6356 | 0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s,
|
6357 | 0., 0., 0.
|
6358 | );
|
6359 | mat3 cov2Dm = transpose(T) * Vrk * T;
|
6360 | cov2Dm[0][0] += 0.3;
|
6361 | cov2Dm[1][1] += 0.3;
|
6362 |
|
6363 |
|
6364 |
|
6365 |
|
6366 |
|
6367 | vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]);
|
6368 |
|
6369 | vec3 ndcCenter = clipCenter.xyz / clipCenter.w;
|
6370 |
|
6371 |
|
6372 |
|
6373 |
|
6374 |
|
6375 |
|
6376 |
|
6377 |
|
6378 |
|
6379 | float a = cov2Dv.x;
|
6380 | float d = cov2Dv.z;
|
6381 | float b = cov2Dv.y;
|
6382 | float D = a * d - b * b;
|
6383 | float trace = a + d;
|
6384 | float traceOver2 = 0.5 * trace;
|
6385 | float term2 = sqrt(trace * trace / 4.0 - D);
|
6386 | float eigenValue1 = traceOver2 + term2;
|
6387 | float eigenValue2 = max(traceOver2 - term2, 0.00);
|
6388 |
|
6389 | const float maxSplatSize = 1024.0;
|
6390 | vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a));
|
6391 |
|
6392 | vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);
|
6393 | vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize);
|
6394 | vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize);
|
6395 |
|
6396 | vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport;
|
6397 |
|
6398 | if (orthoZoom > 0.0) {
|
6399 | ndcOffset *= orthoZoom;
|
6400 | }
|
6401 |
|
6402 | gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0);
|
6403 | }`,n=`
|
6404 | precision highp float;
|
6405 | #include <common>
|
6406 |
|
6407 | uniform vec3 debugColor;
|
6408 |
|
6409 | varying vec4 vColor;
|
6410 | varying vec2 vUv;
|
6411 |
|
6412 | varying vec2 vPosition;
|
6413 | layout(location = 1) out vec4 gVelocity;
|
6414 |
|
6415 | void main () {
|
6416 |
|
6417 |
|
6418 | float A = -dot(vPosition, vPosition);
|
6419 | if (A < -4.0) discard;
|
6420 | vec3 color = vColor.rgb;
|
6421 | A = exp(A) * vColor.a;
|
6422 | gl_FragColor = vec4(color.rgb, A);
|
6423 | gVelocity = vec4(0.0);
|
6424 | }`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new N},viewport:{type:"v2",value:new N},basisViewport:{type:"v2",value:new N},debugColor:{type:"v3",value:new Re},covariancesTextureSize:{type:"v2",value:new N(1024,1024)},centersColorsTextureSize:{type:"v2",value:new N(1024,1024)},orthoZoom:{type:"f",value:-1}};return new at({uniforms:s,vertexShader:r,fragmentShader:n,transparent:!0,alphaTest:1,blending:Aa,depthTest:!0,depthWrite:!1,side:Ln})}static buildGeomtery(e){let r=new Ae;r.setIndex([0,1,2,0,2,3]);let n=new Float32Array(4*3),s=new Ge(n,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 jf().copy(r),a=new Uint32Array(e),l=new cu(a,1,!1);return l.setUsage(rM),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,n=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(n,n+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),n+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let n=this.splatCount,s=new N(4096,1024);for(;s.x*s.y*2<n*6;)s.y*=2;let o=new N(4096,1024);for(;o.x*o.y*4<n*4;)o.y*=2;let a,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(s.x*s.y*2);for(let p=0;p<this.covariances.length;p++)l[p]=yM.toHalfFloat(this.covariances[p]);a=new li(l,s.x,s.y,Cu,Uo)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new li(l,s.x,s.y,Cu,Xr);a.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=a,this.material.uniforms.covariancesTextureSize.value.copy(s);let u=new Uint32Array(o.x*o.y*4);for(let p=0;p<n;p++){let m=p*4,g=p*3,y=p*4;u[y]=CR(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[y+1]=L0(this.centers[g]),u[y+2]=L0(this.centers[g+1]),u[y+3]=L0(this.centers[g+2])}let c=new li(u,o.x,o.y,Xb,fs);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,this.material.uniforms.centersColorsTextureSize.value.copy(o);let h=256*4,d=new Float32Array(256*16);for(let p=0;p<this.meshMatrixWorlds.length;p++)d.set(this.meshMatrixWorlds[p].elements,p*16);let f=new li(d,h,1,$n,Xr);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:a,size:s},centerColors:{data:u,texture:c,size:o},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e,r){let n=this.geometry;n.attributes.splatIndex.set(e),n.attributes.splatIndex.needsUpdate=!0,n.instanceCount=r}updateUniforms(e,r,n,s){this.splatCount>0&&(N0.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(N0),this.material.uniforms.basisViewport.value.set(2/N0.x,2/N0.y),this.material.uniforms.focal.value.set(r,n),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}};var nm=class{constructor(t={}){mn(this,"updateSplatMeshUniforms",function(){let t=new N;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());mn(this,"updateView",function(){let t=new ie,e=[],r=new _(0,0,-1),n=new _(0,0,-1),s=new _,o=new _;return function(a=!1,l=!1){let u=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!a){n.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,f=!1;if(n.dot(r)<=.95&&(d=!0),o.copy(this.camera.position).sub(s).length()>=1&&(f=!0),!d&&!f&&!u&&!c)return}s.copy(this.camera.position),r.copy(n),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let h={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...u?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{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.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _().fromArray(t.position)),t.orientation&&(t.orientation=new He().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(o=>{if(o.data.type==="Splat"){let a=o.visible;o.traverseAncestors(l=>{a&&(a=l.visible)}),a&&e.push(o)}}),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 Sl(new Uint8Array(o.data.buffer).buffer)),n=0,s=[0];for(let o of r)n+=o.getSplatCount(),s.push(n);return this.setupSplatMesh(r,n,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(n),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((n,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=n.data):Object.entries(n.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,u)=>l!==this.cropsArray[r][s][o][u])?(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 _,n=new He,s=!1,o=1,a,l){this.splatMesh=Al.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(n),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=TR(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer),e.data.splatRenderCount),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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var _0=new Go;_0.wireframe=!0;var PR=new _,vl=class extends Nn{constructor(e,r){super();this.data=e;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 I0;this.errorPage=new Si("fdasfa",{...$o.defaultData,name:""});this.invisibleObjects=new is("jflkdsafjasdifjaslk",{...Jy.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=KO(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=QO(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),n=this.entityIdentityToEntity[r];n&&(e.uuid=n.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Si&&(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 n=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);n.splice(0,0,a)}return{entity:r,sortKey:n}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push(s)}return r.sort((n,s)=>KC(n.sortKey,s.sortKey)),r.map(n=>n.entity)}nonExistOrDescendantOf(e,r){let n=this.find(e);if(n===void 0)return!0;for(;n;){if(n.uuid===r)return!0;n=n.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===Xi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}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 n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,n,e.localIndex,r);s.updateVisible(),s.resetBBoxNeedsUpdate(),Yn(s)&&Xn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markToExpandCloner(n),n.resetBBoxNeedsUpdate(),this.unregisterObject(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(n),this.markPenumbraSizeDirty(),n.parent.remove(n),Xn(n.parent)&&(n.parent.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Yn(n)&&(n.freeBooleanPointer(),s instanceof ns&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n instanceof xl&&n.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),this.pathConstraints.removeDependencies(n.uuid),n.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),n.cloner?.resetOnMove(),this.markToExpandCloner(n);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(n),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(n),n.invalidateClonerTransform(n),n.updateVisible(),n.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Yn(n)&&(n.invalidateUpstreamBooleanData(),Xn(n.parent)?n.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof ns&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n.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 Si&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,n,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{qO(o,r,n,{scene:this,shared:s}),o instanceof Qt&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}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 n=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(n,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{Xn(s)&&s.recomputeBoolean(),s instanceof er&&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){lt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{lt.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,n,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Ga(c.data,h=>{let d=h.events.data(l.id),f=c.goUp(a);if(f){let p=[...hy(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Rr.zoom(d,r);y[n]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,n,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Os&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,n)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=Ga(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of _h.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,n,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,n,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,n,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,n,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,n,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,n,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,n,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,n,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,n,s)})}),!0})}expandInstances(e,r,n){let s=new Set;this.traverseEntity(o=>{if(o instanceof Os&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),n&&o.traverseEntity(a=>{n.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),C0(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Os&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let n=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[n]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[n]),r.dispose()})}clearScene(){for(let e of this.children)lt.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 n=[],s=o=>{for(let a of o.children){let l=a.cloner;if(lt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let h=a.matrixWorld.clone().invert();c.point.applyMatrix4(h),n.push(c)}}else(Yn(a)||Zp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,n),rm(a,e,n)),s(a)}};return s(this),n}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Yn(o)||Zp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),rm(o,e,r,!0)),n(o))}};return n(this),r}forEachEntity(e){for(let r of this.children)lt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)lt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)lt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(n=>{if(n instanceof Qt&&n.data.type==="Mesh"&&n.data.geometry.type==="TextGeometry"&&n.data.geometry.font===e){let s=n.geometry,o=n.data.geometry;s.updateFont(e,r).then(()=>{s.update(o);let a=n.invalidateDownstreamBooleanData();Xn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)zh.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)lt.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,n){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,n),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,n,s,o,a){let l={scene:this,shared:a},u=D0(e,r,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),n.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(n,u,a)),u.updateState(r,l),u instanceof Qt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{if(c instanceof Qt&&c.isSkinnedMesh){let h=c.dataPatched;if(h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new ie().fromArray(m)),p=new Ca(d,f);c.bind(p,c.bindMatrix)}}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let n=new Pt;return n.setFromPoints(r),n.getCenter(PR),PR}copyMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e);n?r.copy(n.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e)?.parent;n?r.copy(n.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof $t)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)r.material[n]instanceof bi&&e(r.material[n]);else r.material instanceof bi&&e(r.material)})}updateViewPlaneSize(e,r,n=!1){this.traverseConcreteEntity(s=>{s instanceof er&&s.setViewplaneSize(e,r,n)})}initializeSplatViewer(e){this.splatViewer=new nm({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var im=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},DR=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return q7(Math.atan2(r,e))},IR=(i,t,e)=>{let r={x:0,y:0};return e=B0(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},B0=i=>i*(Math.PI/180),q7=i=>i*(180/Math.PI),OR=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,p1=new Map,m1=i=>{p1.has(i)&&clearTimeout(p1.get(i)),p1.set(i,setTimeout(i,100))},Jd=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},g1=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var F0=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),y1=()=>{if(typeof window>"u")return;let i=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:i,y:t}},k0=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},V0=(i,t,e)=>{let r=LR(i);for(let n in r)if(r.hasOwnProperty(n))if(typeof t=="string")r[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";r[n]=s.slice(0,-2)}return r},RR=(i,t)=>{let e=LR(i);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},LR=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},z0=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},NR=(i,t)=>{let e={};for(let r in i)i.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:i.hasOwnProperty(r)&&(e[r]=i[r]);return e},sm=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},BR=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(FR="ontouchstart"in window,kR=!!window.PointerEvent,VR=!!window.MSPointerEvent);var FR,kR,VR,om={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"}},$d,am={};kR?$d=om.pointer:VR?$d=om.MSPointer:FR?($d=om.touch,am=om.mouse):$d=om.mouse;function Lc(){}Lc.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};Lc.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Lc.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(o){o.call(e,{type:n,target:e},t)})};Lc.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=NR(t.options,i))};Lc.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Jd(i,$d[t],e._domHandlers_[t]),am[t]&&Jd(i,am[t],e._domHandlers_[t]),e};Lc.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},g1(i,$d[t],e._domHandlers_[t]),am[t]&&g1(i,am[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var ef=Lc;function un(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=un.id,un.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}un.prototype=new ef;un.constructor=un;un.id=0;un.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};un.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=RR("borderRadius","50%"),e=V0("transition","opacity",i),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},z0(r.el,e),this.options.shape==="circle"&&z0(r.back,t),z0(r.front,t),this.applyStyles(r),this};un.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};un.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};un.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};un.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};un.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};un.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};un.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=V0("transition",["top","left"],r);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};un.prototype.restCallback=function(){var i=this,t={};t.front=V0("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};un.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};un.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,s,o;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:n},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var zR=un;function Vr(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Vr.id,Vr.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}Vr.prototype=new ef;Vr.constructor=Vr;Vr.id=0;Vr.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Vr.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Vr.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Vr.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},s=e.options,o={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),n=i,i={x:l.left+r.x,y:l.top+r.y}}var u=new zR(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(k0(u.ui.el,n),k0(u.ui.front,u.frontPosition)),e.nipples.push(u),e.trigger("added "+u.identifier+":added",u),e.manager.trigger("added "+u.identifier+":added",u),e.bindNipple(u),u};Vr.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Vr.prototype.bindNipple=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Vr.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)};Vr.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=F0(i),t.updateBox();var n=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(r.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return sm(i,n),t.manager.bindDocument(),!1};Vr.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(n,o);a.identifier!==n&&t.manager.removeIdentifier(a.identifier),a.identifier=n;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),s>0&&t.pressureFn(i,c,c.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(a))>=0&&t.idles.splice(r,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var u=im(o,a.position);if(u<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};Vr.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Vr.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.scroll;if(!OR(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var o=n.el.getBoundingClientRect();n.position={x:s.x+o.left,y:s.y+o.top}}n.identifier=r;var a=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var u=im(l,n.position),c=DR(l,n.position),h=B0(c),d=u/a,f={distance:u,position:l},p,m;if(n.options.shape==="circle"?(p=Math.min(u,a),m=IR(n.position,p,c)):(m=BR(l,n.position,a),p=im(m,n.position)),e.follow){if(u>a){let x=l.x-m.x,w=l.y-m.y;n.position.x+=x,n.position.y+=w,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",u=im(l,n.position)}}else l=m,u=p;var g=l.x-n.position.x,y=l.y-n.position.y;n.frontPosition={x:g,y},e.dataOnly||k0(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:d,pressure:i.force||i.pressure||i.webkitForce||0,distance:u,angle:{radian:h,degree:c},vector:{x:g/a,y:-y/a},raw:f,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:B0(180-c),degree:180-c},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Vr.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};Vr.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Vr.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var UR=Vr;function In(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=y1(),t.config(i),t.prepareCollections();var e=function(){var n;t.collections.forEach(function(s){s.forEach(function(o){n=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+n.left,y:t.scroll.y+n.top}})})};if(typeof window>"u")return t.collections;Jd(window,"resize",function(){m1(e)});var r=function(){t.scroll=y1()};return Jd(window,"scroll",function(){m1(r)}),t.collections}In.prototype=new ef;In.constructor=In;In.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};In.prototype.create=function(i){return this.createCollection(i)};In.prototype.createCollection=function(i){var t=this,e=new UR(t,i);return t.bindCollection(e),t.collections.push(e),e};In.prototype.bindCollection=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};In.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};In.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};In.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};In.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};In.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};In.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};In.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};In.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=F0(t);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[n](a),a._found_=!0)},o=function(a){r=e.getIdentifier(a),sm(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return sm(t,o),!1};In.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};In.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var GR=In;var HR=new GR,jR={create:function(i){return HR.create(i)},factory:HR};var WR=new Map,lm=new Map,So=class{constructor(t,e,r,n){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let u=typeof s=="string"?n.getAudio(s).src:s.data;this.audioPlayer=new la({src:u,volume:o,delay:a,loop:l}),lm.has(r.uuid)?lm.get(r.uuid).push(this):lm.set(r.uuid,[this]),WR.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},tf=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=WR.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=lm.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...lm.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},cm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new So(t,e,r,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new tf(e);else throw new Error("Missing property")}dispatchBasic(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof So?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof So?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof So&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Y7="text/plain",X7="us-ascii",qR=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),Q7=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:r,data:n,hash:s}=e.groups,o=r.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(h=>{let[d,f=""]=h.split("=").map(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===X7)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==Y7)&&c.unshift(l),`data:${c.join(";")},${a?n.trim():n}${s?`#${s}`:""}`};function v1(i,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},i=i.trim(),/^data:/i.test(i))return Q7(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let n=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),t.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),t.stripAuthentication&&(n.username="",n.password=""),t.stripHash?n.hash="":t.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(n.pathname);if(!c)break;let h=c[0],d=c.index,f=n.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let u=n.pathname.slice(a,n.pathname.length);l+=u.replace(/\/{2,}/g,"/"),n.pathname=l}if(n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=n.pathname.split("/"),a=o[o.length-1];qR(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),n.pathname=o.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...n.searchParams.keys()])qR(o,t.removeQueryParameters)&&n.searchParams.delete(o);if(t.removeQueryParameters===!0&&(n.search=""),t.sortQueryParameters){n.searchParams.sort();try{n.search=decodeURIComponent(n.search)}catch{}}t.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let s=i;return i=n.toString(),!t.removeSingleSlash&&n.pathname==="/"&&!s.endsWith("/")&&n.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var G0=class{constructor({url:t,context:e},r,n,s){this.controlsManager=r;this.shared=n;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:v1(t,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=e??"tab"}dispatch(){if(Bt(this.shared,this.condition)===!1)return!1;uy?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(qe[0]),JC())}};var um=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,n=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)n?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(n||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(Bt(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Bt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var hm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.shared=r;this.eventManager=n;this.condition=s;this.shared=r}dispatch(){if(Bt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),rf(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};var JR={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},S1={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},K7=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],j0={CSS:{},springs:{}};function Ls(i,t,e){return Math.min(Math.max(i,t),e)}function dm(i,t){return i.indexOf(t)>-1}function x1(i,t){return i.apply(null,t)}var it={arr:function(i){return Array.isArray(i)},obj:function(i){return dm(Object.prototype.toString.call(i),"Object")},pth:function(i){return it.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||it.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return it.hex(i)||it.rgb(i)||it.hsl(i)},key:function(i){return!JR.hasOwnProperty(i)&&!S1.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function $R(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function eL(i,t){var e=$R(i),r=Ls(it.und(e[0])?1:e[0],.1,100),n=Ls(it.und(e[1])?100:e[1],.1,100),s=Ls(it.und(e[2])?10:e[2],.1,100),o=Ls(it.und(e[3])?0:e[3],.1,100),a=Math.sqrt(n/r),l=s/(2*Math.sqrt(n*r)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,h=l<1?(l*a+-o)/u:-o+a;function d(p){var m=t?t*p/1e3:p;return l<1?m=Math.exp(-m*l*a)*(c*Math.cos(u*m)+h*Math.sin(u*m)):m=(c+h*m)*Math.exp(-m*a),p===0||p===1?p:1-m}function f(){var p=j0.springs[i];if(p)return p;for(var m=1/6,g=0,y=0;;)if(g+=m,d(g)===1){if(y++,y>=16)break}else y=0;var v=g*m*1e3;return j0.springs[i]=v,v}return t?d:f}function Z7(i){return i===void 0&&(i=10),function(t){return Math.ceil(Ls(t,1e-6,1)*i)*(1/i)}}var J7=function(){var i=11,t=1/(i-1);function e(c,h){return 1-3*h+3*c}function r(c,h){return 3*h-6*c}function n(c){return 3*c}function s(c,h,d){return((e(h,d)*c+r(h,d))*c+n(h))*c}function o(c,h,d){return 3*e(h,d)*c*c+2*r(h,d)*c+n(h)}function a(c,h,d,f,p){var m,g,y=0;do g=h+(d-h)/2,m=s(g,f,p)-c,m>0?d=g:h=g;while(Math.abs(m)>1e-7&&++y<10);return g}function l(c,h,d,f){for(var p=0;p<4;++p){var m=o(h,d,f);if(m===0)return h;var g=s(h,d,f)-c;h-=g/m}return h}function u(c,h,d,f){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var p=new Float32Array(i);if(c!==h||d!==f)for(var m=0;m<i;++m)p[m]=s(m*t,c,d);function g(y){for(var v=0,x=1,w=i-1;x!==w&&p[x]<=y;++x)v+=t;--x;var S=(y-p[x])/(p[x+1]-p[x]),A=v+S*t,E=o(A,c,d);return E>=.001?l(y,A,c,d):E===0?A:a(y,v,v+t,c,d)}return function(y){return c===h&&d===f||y===0||y===1?y:s(g(y),h,f)}}return u}(),tL=function(){var i={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var n,s=4;r<((n=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((n*3-2)/22-r,2)}},Elastic:function(r,n){r===void 0&&(r=1),n===void 0&&(n=.5);var s=Ls(r,1,10),o=Ls(n,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,n){t[r]=function(){return function(s){return Math.pow(s,n+2)}}}),Object.keys(t).forEach(function(r){var n=t[r];i["easeIn"+r]=n,i["easeOut"+r]=function(s,o){return function(a){return 1-n(s,o)(1-a)}},i["easeInOut"+r]=function(s,o){return function(a){return a<.5?n(s,o)(a*2)/2:1-n(s,o)(a*-2+2)/2}}}),i}();function A1(i,t){if(it.fnc(i))return i;var e=i.split("(")[0],r=tL[e],n=$R(i);switch(e){case"spring":return eL(i,t);case"cubicBezier":return x1(J7,n);case"steps":return x1(Z7,n);default:return x1(r,n)}}function rL(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function W0(i,t){for(var e=i.length,r=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(r,o,s,i)&&n.push(o)}return n}function q0(i){return i.reduce(function(t,e){return t.concat(it.arr(e)?q0(e):e)},[])}function YR(i){return it.arr(i)?i:(it.str(i)&&(i=rL(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function _1(i,t){return i.some(function(e){return e===t})}function E1(i){var t={};for(var e in i)t[e]=i[e];return t}function b1(i,t){var e=E1(i);for(var r in i)e[r]=t.hasOwnProperty(r)?t[r]:i[r];return e}function Y0(i,t){var e=E1(i);for(var r in t)e[r]=it.und(i[r])?t[r]:i[r];return e}function $7(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function eX(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,u,c){return l+l+u+u+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),n=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+n+","+s+","+o+",1)"}function tX(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,n=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,u;if(r==0)a=l=u=n;else{var c=n<.5?n*(1+r):n+r-n*r,h=2*n-c;a=o(h,c,e+1/3),l=o(h,c,e),u=o(h,c,e-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function rX(i){if(it.rgb(i))return $7(i);if(it.hex(i))return eX(i);if(it.hsl(i))return tX(i)}function da(i){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(i);if(t)return t[1]}function nX(i){if(dm(i,"translate")||i==="perspective")return"px";if(dm(i,"rotate")||dm(i,"skew"))return"deg"}function w1(i,t){return it.fnc(i)?i(t.target,t.id,t.total):i}function Ao(i,t){return i.getAttribute(t)}function M1(i,t,e){var r=da(t);if(_1([e,"deg","rad","turn"],r))return t;var n=j0.CSS[t+e];if(!it.und(n))return n;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(t);return j0.CSS[t+e]=u,u}function nL(i,t,e){if(t in i.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=i.style[t]||getComputedStyle(i).getPropertyValue(r)||"0";return e?M1(i,n,e):n}}function T1(i,t){if(it.dom(i)&&!it.inp(i)&&(Ao(i,t)||it.svg(i)&&i[t]))return"attribute";if(it.dom(i)&&_1(K7,t))return"transform";if(it.dom(i)&&t!=="transform"&&nL(i,t))return"css";if(i[t]!=null)return"object"}function iL(i){if(!!it.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,n;n=e.exec(t);)r.set(n[1],n[2]);return r}}function iX(i,t,e,r){var n=dm(t,"scale")?1:0+nX(t),s=iL(i).get(t)||n;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?M1(i,s,r):s}function C1(i,t,e,r){switch(T1(i,t)){case"transform":return iX(i,t,r,e);case"css":return nL(i,t,e);case"attribute":return Ao(i,t);default:return i[t]||0}}function P1(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var r=da(i)||0,n=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return n+s+r;case"-":return n-s+r;case"*":return n*s+r}}function sL(i,t){if(it.col(i))return rX(i);if(/\s/g.test(i))return i;var e=da(i),r=e?i.substr(0,i.length-e.length):i;return t?r+t:r}function D1(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function sX(i){return Math.PI*2*Ao(i,"r")}function oX(i){return Ao(i,"width")*2+Ao(i,"height")*2}function aX(i){return D1({x:Ao(i,"x1"),y:Ao(i,"y1")},{x:Ao(i,"x2"),y:Ao(i,"y2")})}function oL(i){for(var t=i.points,e=0,r,n=0;n<t.numberOfItems;n++){var s=t.getItem(n);n>0&&(e+=D1(r,s)),r=s}return e}function lX(i){var t=i.points;return oL(i)+D1(t.getItem(t.numberOfItems-1),t.getItem(0))}function aL(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return sX(i);case"rect":return oX(i);case"line":return aX(i);case"polyline":return oL(i);case"polygon":return lX(i)}}function cX(i){var t=aL(i);return i.setAttribute("stroke-dasharray",t),t}function uX(i){for(var t=i.parentNode;it.svg(t)&&it.svg(t.parentNode);)t=t.parentNode;return t}function lL(i,t){var e=t||{},r=e.el||uX(i),n=r.getBoundingClientRect(),s=Ao(r,"viewBox"),o=n.width,a=n.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function hX(i,t){var e=it.str(i)?rL(i)[0]:i,r=t||100;return function(n){return{property:n,el:e,svg:lL(e),totalLength:aL(e)*(r/100)}}}function dX(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var r=lL(i.el,i.svg),n=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(n.x-r.x)*r.w;case"y":return(n.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function XR(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=sL(it.pth(i)?i.totalLength:i,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:it.str(i)||t?r.split(e):[]}}function cL(i){var t=i?q0(it.arr(i)?i.map(YR):YR(i)):[];return W0(t,function(e,r,n){return n.indexOf(e)===r})}function uL(i){var t=cL(i);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:iL(e)}}})}function fX(i,t){var e=E1(t);if(/^spring/.test(e.easing)&&(e.duration=eL(e.easing)),it.arr(i)){var r=i.length,n=r===2&&!it.obj(i[0]);n?i={value:i}:it.fnc(t.duration)||(e.duration=t.duration/r)}var s=it.arr(i)?i:[i];return s.map(function(o,a){var l=it.obj(o)&&!it.pth(o)?o:{value:o};return it.und(l.delay)&&(l.delay=a?0:t.delay),it.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return Y0(o,e)})}function pX(i){for(var t=W0(q0(i.map(function(s){return Object.keys(s)})),function(s){return it.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var u in a)it.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},n=0;n<t.length;n++)r(n);return e}function mX(i,t){var e=[],r=t.keyframes;r&&(t=Y0(pX(r),t));for(var n in t)it.key(n)&&e.push({name:n,tweens:fX(t[n],i)});return e}function gX(i,t){var e={};for(var r in i){var n=w1(i[r],t);it.arr(n)&&(n=n.map(function(s){return w1(s,t)}),n.length===1&&(n=n[0])),e[r]=n}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function yX(i,t){var e;return i.tweens.map(function(r){var n=gX(r,t),s=n.value,o=it.arr(s)?s[1]:s,a=da(o),l=C1(t.target,i.name,a,t),u=e?e.to.original:l,c=it.arr(s)?s[0]:u,h=da(c)||da(l),d=a||h;return it.und(o)&&(o=u),n.from=XR(c,d),n.to=XR(P1(o,c),d),n.start=e?e.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=A1(n.easing,n.duration),n.isPath=it.pth(s),n.isColor=it.col(n.from.original),n.isColor&&(n.round=1),e=n,n})}var hL={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,r,n){if(r.list.set(t,e),t===r.last||n){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function dL(i,t){var e=uL(i);e.forEach(function(r){for(var n in t){var s=w1(t[n],r),o=r.target,a=da(s),l=C1(o,n,a,r),u=a||da(l),c=P1(sL(s,u),l),h=T1(o,n);hL[h](o,n,c,r.transforms,!0)}})}function vX(i,t){var e=T1(i.target,t.name);if(e){var r=yX(t,i),n=r[r.length-1];return{type:e,property:t.name,animatable:i,tweens:r,duration:n.end,delay:r[0].delay,endDelay:n.endDelay}}}function xX(i,t){return W0(q0(i.map(function(e){return t.map(function(r){return vX(e,r)})})),function(e){return!it.und(e)})}function fL(i,t){var e=i.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},n={};return n.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,n.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,n.endDelay=e?n.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,n}var QR=0;function bX(i){var t=b1(JR,i),e=b1(S1,i),r=mX(e,i),n=uL(i.targets),s=xX(n,r),o=fL(s,e),a=QR;return QR++,Y0(t,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var as=[],KR=[],H0,wX=function(){function i(){H0=requestAnimationFrame(t)}function t(e){var r=as.length;if(r){for(var n=0;n<r;){var s=as[n];s.paused?(as.splice(n,1),r-=1):(s.tick(e),n++)}i()}else H0=cancelAnimationFrame(H0)}return i}();function SX(i){document.hidden?(as.forEach(function(t){return t.pause(i.timeStamp)}),KR=as.slice(0),zr.running=as=[]):KR.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",SX);function zr(i){i===void 0&&(i={});var t=0,e=0,r=0,n,s,o=0,a=null;function l(E){var b=window.Promise&&new Promise(function(M){return a=M});return E.finished=b,b}var u=bX(i),c=l(u);function h(){var E=u.direction;E!=="alternate"&&(u.direction=E!=="normal"?"normal":"reverse"),u.reversed=!u.reversed,s.forEach(function(b){(b.loop===1||b.loop%2===0)&&(b.reversed=u.reversed)})}function d(){u.direction="normal",u.reversed=!1,s.forEach(function(E){return E.reversed=!1})}function f(E){return u.reversed?u.duration-E:E}function p(){t=0,e=f(u.currentTime)*(1/zr.speed)}function m(E,b,M=!1){b&&(u.reversed?b.seek(b.duration*b.loop-(E-b.timelineOffset-b.pingPongDelayCorrection),M):b.seek(E-b.timelineOffset-b.startOnceDelay-b.pingPongDelayCorrection,M))}function g(E,b=!1){if(u.reversed)for(var T=o;T--;)m(E,s[T],b);else for(var M=0;M<o;M++)m(E,s[M],b)}function y(E){var b=0,M=u.animations,T=M.length;for(u.direction!=="alternate"&&u.parent?.direction==="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1&&(u.parent?.reversed&&u.direction==="alternate"?E=u.duration-u.delay+u.endDelay-E:E=u.duration+u.delay-u.endDelay-E):S(!1,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)&&(u.parent?.reversed&&u.direction==="alternate"?E=u.duration-u.delay+u.endDelay-E:E=u.duration+u.delay-u.endDelay-E);b<T;){var C=M[b],P=C.animatable,D=C.tweens,I=D.length-1,R=D[I];I&&(R=W0(D,function(W){return E<W.end})[0]||R);let K;u.parent?.reversed&&u.direction==="alternate"?K=Ls(E-R.start-R.endDelay,0,R.duration)/R.duration:K=Ls(E-R.start-R.delay,0,R.duration)/R.duration;for(var V=isNaN(K)?1:R.easing(K),k=R.to.strings,z=R.round,G=[],H=R.to.numbers.length,Q=void 0,F=0;F<H;F++){var j=void 0;let W,ye;u.direction!=="alternate"?u.parent?.rewind===!1&&u.reversePlayback===!0&&u.rewind===!1?(W=R.to.numbers[F],ye=R.from.numbers[F]||0):(ye=R.to.numbers[F],W=R.from.numbers[F]||0):S(!0,u.parent?.rewind,u.rewind,u.parent?.reversePlayback,u.reversePlayback)?(W=R.to.numbers[F],ye=R.from.numbers[F]||0):(ye=R.to.numbers[F],W=R.from.numbers[F]||0),R.isPath?j=dX(R.value,V*ye):j=W+V*(ye-W),z&&(R.isColor&&F>2||(j=Math.round(j*z)/z)),G.push(j)}var Y=k.length;if(!Y)Q=G[0];else{Q=k[0];for(var q=0;q<Y;q++){var U=k[q],J=k[q+1],Z=G[q];isNaN(Z)||(J?Q+=Z+J:Q+=Z+" ")}}hL[C.type](P.target,C.property,Q,P.transforms),C.currentValue=Q,b++}}function v(E){u[E]&&!u.passThrough&&u[E](u)}function x(){u.remaining&&u.remaining!==!0&&u.remaining--}let w={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function S(E,b,M,T,C){return w[E<<4|b<<3|M<<2|T<<1|C]}function A(E,b=!1){var M=u.duration;let T=u.delay,C=M-u.endDelay;u.parent?.reversed&&u.direction==="alternate"&&(T=u.endDelay,C=M-u.delay);var P=f(E);if(u.progress=Ls(P/M*100,0,100),b||(u.reversePlayback=P<u.currentTime),o&&g(P,b),!u.began&&u.currentTime>=0&&(u.began=!0,v("begin")),!u.loopBegan&&u.currentTime>0&&(u.loopBegan=!0,v("loopBegin")),(u.reversed||P>=0)&&P<=T&&u.currentTime!==0&&(y(0),v("change")),(P>=C&&u.currentTime!==M+u.pingPongDelayCorrection||!M)&&(y(M),v("change")),P>T&&P<C?(u.changeBegan||(u.changeBegan=!0,u.changeCompleted=!1,v("changeBegin")),y(P),v("change")):u.changeBegan?(u.changeCompleted=!0,u.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):u.began&&P>C&&v("changeComplete"),u.currentTime=Ls(P,0,M+u.pingPongDelayCorrection),u.began&&v("update"),E>=M)if(x(),!u.remaining)u.paused=!0,u.completed||(u.completed=!0,v("loopComplete"),v("complete"),!u.passThrough&&"Promise"in window&&(a(),c=l(u)));else{o?t+=u.duration/zr.speed:t+=u.duration;for(let D of s)D.setStartTime(0),D.remaining=D.loop;v("loopComplete"),u.loopBegan=!1,u.direction==="alternate"?h():o&&d()}}return u.reset=function(){var E=u.direction;u.passThrough=!1,u.currentTime=0,u.progress=0,u.paused=!0,u.began=!1,u.loopBegan=!1,u.changeBegan=!1,u.completed=!1,u.changeCompleted=!1,u.reversePlayback=!1,u.reversed=E==="reverse",u.remaining=u.loop,s=u.children,o=s.length;for(var b=o;b--;)u.children[b].reset();y(u.reversed?u.duration:0)},u.setStartTime=function(E){t=E},u.set=function(E,b){return dL(E,b),u},u.tick=function(E){r=E,t||(t=r),A((r+(e-t))*zr.speed)},u.seek=function(E,b=!1){A(E-t,b)},u.pause=function(E){u.paused=!0,o&&(n=E??performance.now())},u.play=function(E){!u.paused||(u.completed&&u.reset(),u.paused=!1,as.push(u),o&&n!==void 0&&(t+=(E??performance.now())-n),H0||wX())},u.reverse=function(){h(),u.completed=!u.reversed,p()},u.restart=function(){u.reset(),u.play()},u.reset(),u.autoplay&&u.play(),u}function ZR(i,t){for(var e=t.length;e--;)_1(i,t[e].animatable.target)&&t.splice(e,1)}function AX(i){for(var t=cL(i),e=as.length;e--;){var r=as[e],n=r.animations,s=r.children;ZR(t,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;ZR(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!n.length&&!s.length&&r.pause()}}function _X(i,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?A1(t.easing):null,n=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",u=o==="last",c=it.arr(i),h=parseFloat(c?i[0]:i),d=c?parseFloat(i[1]):0,f=da(c?i[1]:i)||0,p=t.start||0+(c?h:0),m=[],g=0;return function(y,v,x){if(a&&(o=0),l&&(o=(x-1)/2),u&&(o=x-1),!m.length){for(var w=0;w<x;w++){if(!n)m.push(Math.abs(o-w));else{var S=l?(n[0]-1)/2:o%n[0],A=l?(n[1]-1)/2:Math.floor(o/n[0]),E=w%n[0],b=Math.floor(w/n[0]),M=S-E,T=A-b,C=Math.sqrt(M*M+T*T);s==="x"&&(C=-M),s==="y"&&(C=-T),m.push(C)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(D){return r(D/g)*g})),e==="reverse"&&(m=m.map(function(D){return s?D<0?D*-1:-D:Math.abs(g-D)}))}var P=c?(d-h)/g:h;return p+P*(Math.round(m[v]*100)/100)+f}}function EX(i){i===void 0&&(i={});var t=zr(i);return t.duration=0,t.add=function(e,r){var n=as.indexOf(t),s=t.children;n>-1&&as.splice(n,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Y0(e,b1(S1,i));l.targets=l.targets||i.targets;var u=t.duration;l.autoplay=!1,l.timelineOffset=it.und(r)?u:P1(r,u),o(t);var c=zr(l);o(c),s.push(c),c.parent=t;var h=fL(s,i);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}zr.version="3.2.0";zr.speed=1;zr.running=as;zr.remove=AX;zr.get=C1;zr.set=dL;zr.convertPx=M1;zr.path=hX;zr.setDashoffset=cX;zr.stagger=_X;zr.timeline=EX;zr.easing=A1;zr.penner=tL;zr.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var X0=zr;var pL=new _,mL=new _,gL=new He;function yL(i,t,e,r){if(r===0)return e.copy(i);if(r===1)return e.copy(t);let n=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(n>=1)return e.copy(i);let s=1-n*n;if(s<=Number.EPSILON){let c=1-r;return e.w=c*i.w+r*t.w,e.x=c*i.x+r*t.x,e.y=c*i.y+r*t.y,e.z=c*i.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,n),l=Math.sin((1-r)*a)/o,u=Math.sin(r*a)/o;return e.w=i.w*l+t.w*u,e.x=i.x*l+t.x*u,e.y=i.y*l+t.y*u,e.z=i.z*l+t.z*u,e}function Ns(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(a==null)return;let l=o!=null?typeof o=="string"?Number(n.getVariable(o)??0):o:t[i],u=typeof a=="string"?Number(n.getVariable(a)??0):a;if(l!==u)return{update:c=>{let h=Se.lerp(l,u,c);s?t[i]=Math.trunc(h):t[i]=h},start:()=>{t[i]=l},end:()=>{t[i]=u}}}function I1(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let l=t[i],u=[...o??l].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h),c=[...a].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h);if(!(u.length!==c.length||rp(u,c)))return{update:h=>{u.forEach((d,f)=>{let p=Se.lerp(d,c[f],h);t[i][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[i],u)},end:()=>{Object.assign(t[i],c)}}}function fm(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function O1(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?fm(new _,s,n):a.clone(),u=fm(new _,o,n);if(!l.equals(u))return{update:c=>{a.lerpVectors(l,u,c)},start:()=>{a.copy(l)},end:()=>{a.copy(u)}}}function vL(i,t,e,r){let n=e[i]?e[i]:void 0,s=r[i];if(!s)return;let o=t[i],a=n?new ie().fromArray(n):o.clone(),l=new _,u=new He,c=new _;a.decompose(l,u,c);let h=new ie().fromArray(s),d=new _,f=new He,p=new _;if(h.decompose(d,f,p),!a.equals(h))return{update:m=>{gL.slerpQuaternions(u,f,m),pL.lerpVectors(l,d,m),mL.lerpVectors(c,p,m),o.compose(pL,gL,mL)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(d,f,p)}}}function xL(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return t[i]=c,{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function _o(i,t,e,r,n){if(typeof t[i]=="number")return Ns(i,t,e??{},r,n);if(Array.isArray(t[i]))return I1(i,t,e??{},r,n)}function bL(i,t,e,r){let n=[],s=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,o=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(o!==void 0){let a=s??i.zoom,l=o;a!==l&&n.push({update:u=>{i.zoom=Se.lerp(a,l,u),i.updateProjectionMatrix()},start:()=>{i.zoom=a,i.updateProjectionMatrix()},end:()=>{i.zoom=l,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let a=Ns("targetOffset",i,t,e,r);a&&n.push(a)}return n}function MX(i,t,e,r){if(e.scaleBaked===void 0)return;let n=(t.scaleBaked??i.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a);if(Js.isEqual(n,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[Se.lerp(n[0],s[0],a),Se.lerp(n[1],s[1],a),Se.lerp(n[2],s[2],a)]},r),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:n},r),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},r),i.invalidateDownstreamBooleanData()}}),o}function TX(i,t,e,r){if(!e.extrusion)return;let n=i.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return Jw.forEach(l=>{let u=_o(l,n,s,o,r);u&&a.push(u)}),a}function wL(i,t,e,r){let n=[];if(!("geometry"in e))return n;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof Ps){let l=MX(i,o,a,r);l&&n.push(...l)}else{let l={};if(Object.assign(l,Ni(s,$w)),$w.forEach(u=>{let c=_o(u,l,o,a,r);c&&n.push(c)}),i instanceof xl){Object.assign(l,{extrusion:{...s.extrusion}});let u=TX(l,o,a,r);u&&n.push(...u)}n.length&&n.push({update:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},start:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},end:u=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()}})}return n}function SL(i,t,e,r){let n=[];if(e.intensity!==void 0){let s=Ns("intensity",i,t,e,r);s&&n.push(s)}if(e.color!==void 0){let s=xL("color",i,t,e,r);s&&n.push(s)}return n}function _L(i,t,e,r){let n=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return n;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let u=s[l]??{},c=o[l];typeof u=="string"||typeof c=="string"||n.push(...AL(a,u,c,r))})}else{if(!("material"in e&&e.material))return n;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return n;n.push(...AL(i.material,s,o,r))}return n}function AL(i,t,e,r){let n=[],s=Ac(e,r)||!!t.layers&&Ac(t,r);n.push(BX(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||o.type!=="light"&&(!(o.visible??!0)||!(l.visible??!0)))continue;let u=o.getNames().filter(c=>!qy.some(h=>c.includes(h)));for(let c of u)try{let h=o.getValue(c),d;if(c==="colors")d=LX(o,a,l,c);else if(Array.isArray(h))c==="steps"&&(d=RX(o,a,l,c));else if(typeof h=="number")d=CX(o,a,l,c,r);else{if(typeof h=="boolean")continue;h instanceof N?d=PX(o,a,l,c):h instanceof _?d=DX(o,a,l,c,r):h instanceof gr?d=OX(o,a,l,c,r):h instanceof Re?d=IX(o,a,l,c,r):"isTexture"in h&&(d=NX(o,a,l,c))}d&&(Array.isArray(d)?n.push(...d):n.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${c}`,h)}}return n}function CX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:i.getValue(r),o=e[r],a=typeof s=="string"?Number(n.getVariable(s)??0):s,l=typeof o=="string"?Number(n.getVariable(o)??0):o;if(a!==l)return{update:u=>{i.setValue(r,Se.lerp(a,l,u))},start:()=>{i.setValue(r,a)},end:()=>{i.setValue(r,l)}}}function PX(i,t,e,r){if(!i.hasValue(r)||!(r in e))return;let n=i.getValue(r),s=t?new N().fromArray(t[r]):n.clone(),o=new N().fromArray(e[r]);if(!s.equals(o))return{update:a=>{n.lerpVectors(s,o,a)},start:()=>{n.copy(s)},end:()=>{n.copy(o)}}}function DX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=i.getValue(r),o=t?t[r]:void 0,a=e[r],l=o?fm(new _,o,n):s.clone(),u=fm(new _,a,n);if(!l.equals(u))return{update:c=>{s.lerpVectors(l,u,c)},start:()=>{s.copy(l)},end:()=>{s.copy(u)}}}function IX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new Re().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(r)!==c&&i.setValue(r,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function OX(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new Re().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?n.getColor(o).clone():new gr(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return{update:h=>{i.getValue(r)!==c&&i.setValue(r,c),c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function RX(i,t,e,r="steps"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s,a=e[r];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&n.push({update:h=>{s[l]=Se.lerp(u,c,h)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return n.length?n:void 0}function LX(i,t,e,r="colors"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s.map(l=>l.toArray()),a=e[r];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];fp.isEqual(u,c)||n.push({update:h=>{s[l].fromArray(fp.lerp(u,c,h))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return n.length?n:void 0}function NX(i,t,e,r="texture"){if(!i.hasValue(r)||!(r in e))return;let n=i.getNode("mat");if(!n)return;let s=t?t[r]:n,o=e[r],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!oc.isEqual(a,u)||!oc.isEqual(l,c))return{update:h=>{n.repeat=oc.lerp(a,u,h),n.offset=oc.lerp(l,c,h),n.updateMatrix()},start:()=>{n.repeat=[...a],n.offset=[...l],n.updateMatrix()},end:()=>{n.repeat=[...u],n.offset=[...c],n.updateMatrix()}}}function BX(i,t){return{update:()=>{i.transparent=t}}}var R1=new _,EL=new Zt;function ML(i,t,e,r,n){let s=[],o,a,l,u,c,h,d={slide:t.pathSnapping?.slide??i.updatedPathSnapping?.slide??i.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??i.updatedPathSnapping?.offset??i.dataPatched.pathSnapping?.offset??0};if(c=Ns("slide",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),c&&s.push(c),h=Ns("offset",d,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),h&&s.push(h),!c&&!h&&(o=O1("position",i,t,e,n),o&&s.push(o),a=O1("scale",i,t,e,n),a&&s.push(a),l=FX(i,t,e,r,n),l&&s.push(l),u=vL("hiddenMatrix",i,t,e),u&&s.push(u)),o||a||l||u||c||h){let f=()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),Yn(i)&&Xn(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,d))};s.push({update:f,start:f,end:f})}return s}function FX(i,t,e,r,n){let s=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(n.getVariable(c)??0):c)*Se.DEG2RAD):void 0,o=e.rotation?.map(c=>(typeof c=="string"?Number(n.getVariable(c)??0):c)*Se.DEG2RAD);if(!o)return;let a=s?new _().fromArray(s):new _().setFromEuler(i.rotation),l=new _().fromArray(o);if(a.equals(l))return;let u=R1.subVectors(l,a);if(r&&u.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new He().setFromEuler(EL.setFromVector3(a)),h=new He().setFromEuler(EL.setFromVector3(l));return{update:d=>{yL(c,h,i.quaternion,d)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}else return{update:c=>{R1.lerpVectors(a,l,c),i.rotation.setFromVector3(R1)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}function TL(i,t,e,r){let n=[];if(!("cloner"in e)||!i.cloner)return n;let s=i.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;Hw.forEach(f=>{let p;f==="count"?p=Ns("count",s.parameters,o,a,r,!0):p=_o(f,s.parameters,o??{},a,r),p&&n.push(p)});let l=kX(s,o,a,r);l?.length&&n.push(...l);let u=VX(s,o,a,r);u?.length&&n.push(...u);let c=zX(s,o,a,r);c?.length&&n.push(...c);let h=UX(s,o,a,r);h?.length&&n.push(...h);let d=GX(s,o,a,r);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{s.update()}}),n}function kX(i,t,e,r){if(i.parameters.type!=="radial")return;let n=t.radial,s=e.radial;if(!s)return;let o=i.parameters.radial,a=[];return jw.forEach(l=>{let u=_o(l,o,n??{},s,r);u&&a.push(u)}),a}function VX(i,t,e,r){if(i.parameters.type!=="linear")return;let n=t.linear,s=e.linear;if(!s)return;let o=[],a=i.parameters.linear;return Ww.forEach(l=>{let u=_o(l,a,n??{},s,r);u&&o.push(u)}),o}function zX(i,t,e,r){if(i.parameters.type!=="grid")return;let n=t.grid,s=e.grid;if(!s)return;let o=[],a=i.parameters.grid;return qw.forEach(l=>{let u;l==="count"?u=I1(l,a,n??{},s,r,!0):u=_o(l,a,n??{},s,r),u&&o.push(u)}),o}function UX(i,t,e,r){if(i.parameters.type!=="toObject")return;let n=t.toObject,s=e.toObject;if(!s)return;let o=[],a=i.parameters.toObject;return Yw.forEach(l=>{let u;l==="count"?u=Ns(l,a,n??{},s,r,!0):u=_o(l,a,n??{},s,r),u&&o.push(u)}),o}function GX(i,t,e,r){if(!i.parameters.randomness)return;let n=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=i.parameters.randomnessObject;return Xw.forEach(l=>{let u=_o(l,a,n??{},s,r);u&&o.push(u)}),o}function L1(i,t,e,r,n){let s=[];return i.data.visible&&s.push(...ML(i,t,e,n,r)),i.data.visible&&s.push(...TL(i,t,e,r)),Yn(i)?(i instanceof Qt&&i.data.visible&&s.push(...wL(i,t,e,r)),i.data.visible&&s.push(..._L(i,t,e,r))):nO(i)?i.data.visible&&s.push(...SL(i,t,e,r)):rO(i)&&s.push(...bL(i,t,e,r)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var CL=new _;function rf(i,t,e=!1){let r=[];i.traverseChildren(n=>{if(e&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(CL,!0),n.rigidBody?.setAngvel(CL,!0)),!lt.is(n))return;let s=n.uuid,o=n.data;if(delete n.states,n.uuid===Xi)return;let a=!1;r.some(l=>i.scene.find(s)?.isDescendantOf(l))?a=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(s),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let l of o.states){let u={...l.data};i.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||a)&&(l.data.position!==void 0&&delete u.position,l.data.rotation!==void 0&&delete u.rotation,l.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),n.states||(n.states={}),n.states[l.id]=ea.patch(o,u)}jX(i.scene,n,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),HX(i)})}function HX(i){i.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let n of Object.values(e.data.gameActions))r.push(...n);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let n of r)if(n.data.type==="Create"&&n.data.hideBase==="Yes"){let s=i.scene.find(n.data.object);s&&(s.visible=!1)}}})}function jX(i,t,e,r,n=!1){if(t instanceof Qt&&t.removeInteractionGeometry(),t.changeSelectedState(e,{scene:i,shared:r},n),t instanceof Qt&&t.updateGeometryGroupsIfNeeded(),t instanceof er&&t.updateCameraState(t.dataPatched,{scene:i,shared:r}),t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}function B1(i){let t;if(i.easing===5){let{control1:e,control2:r}=i;t=`cubicBezier(
|
6425 | ${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
|
6426 | )`}else if(i.easing===6){let{mass:e,stiffness:r,damping:n,velocity:s}=i;t=`spring( ${e}, ${r}, ${n}, ${s} )`}else{let e;switch(i.easing){case 0:e=Jo.linear;break;case 1:e=Jo.ease;break;case 2:e=Jo.easeIn;break;case 3:e=Jo.easeOut;break;case 4:e=Jo.easeInOut;break;default:e=Jo.linear}let[r,n,s,o]=e;t=`cubicBezier( ${r}, ${n}, ${s}, ${o} )`}return{duration:i.duration,easing:t}}function N1(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var WX={type:"beginState"},qX={type:"completeState",isfromEntity:!1},K0=class{constructor(t,e,r,n,s,o){this.object=t;this.data=n;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(WX)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object.traverseEntity(e=>{e!==this.object&&e instanceof er&&e.dispatchEvent(qX)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=L1(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=Q0(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=Q0(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=Q0(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...N1(n),...B1(n),change:this.onChange},this.callback=L1(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},pm=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.timelineNeedsRebuild=!1;this.useToggle=!1;this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=Q0(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:n=!1}={}){try{let s=N1(this.data.tweens[0].data);n&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=X0.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let u=this.data.tweens[l],c=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let u=this.data.tweens[l],c=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof er&&(this.object.wasMovedByUser=!1)):h=u.data.state===void 0?this.currentState:u.data.state;let d=new K0(this.object,h,c.data.state===void 0?this.currentState:c.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Bt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=N1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Bt(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Q0(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var YX={type:"beginState"},PL={type:"completeState",isfromEntity:!1},DL={type:"requestRender"},mm=class extends Yt{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new _;this.posEnd=new _;this.qStart=new He;this.qEnd=new He;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=X0({targets:n,t:1,...B1(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(YX));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,n.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(DL),n.t===1&&s.dispatchEvent(PL)}})}switchCamera(e){let r=this.page.scene.find(e);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(r),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:r})}play(){if(Bt(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(Bt(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(PL),this.page.activeCamera.dispatchEvent(DL))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var gm=class extends Yt{constructor(e,r,n,s,o){super();this.page=r;this.animationControls=n;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let u=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=u?.getClip()?.duration??1;let c=u?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/c*this.duration,this.rightFrameTime=this.data.crop[1]/c*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Bt(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,s])=>{let o=n.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Se.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Bt(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===n&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}};var ym=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Bt(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(r=>r.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),rf(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var vm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Bt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=Ov(this.data.expression,this.shared,En.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var xm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.timeoutId=null}dispatchInner(){if(Bt(this.shared,this.condition)===!1)return!1;let t=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function Bt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=Ov(t.expression,i,"boolean");return t.negate?!e:!!e}function nr(i,t,e,r,n,s){let o={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},a=l=>({id:u,data:c})=>{try{c.type==="Audio"?di[i.type].includes("Audio")&&o.Audio.push(new cm(u,c,s,r,l)):c.type==="Video"?di[i.type].includes("Video")&&o.Video.push(new bm(u,c,s,r,l)):c.type==="Link"?di[i.type].includes("Link")&&o.Link.push(new G0(c,n.controlsManager,r,l)):c.type==="Create"?di[i.type].includes("Create")&&o.Create.push(new wm(c,e,n.controlsManager,r,l)):c.type==="Destroy"?di[i.type].includes("Destroy")&&o.Destroy.push(new um(c,e,n.controlsManager,r,l)):c.type==="Reset"?di[i.type].includes("Reset")&&o.Reset.push(new hm(c,e,r,n,l)):c.type==="Transition"?di[i.type].includes("Transition")&&o.Transition.push(new pm(c,e,r,l)):c.type==="SwitchCamera"?di[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new mm(c,e,r,l)):c.type==="SceneTransition"?di[i.type].includes("SceneTransition")&&o.SceneTransition.push(new ym(c,e,n,r,l)):c.type==="Animation"?di[i.type].includes("Animation")&&o.Animation.push(new gm(c,e,n.animationControls,r,l)):c.type==="SetVariable"?di[i.type].includes("SetVariable")&&o.SetVariable.push(new vm(c,e,r,l)):c.type==="DynamicVariablePlay"?di[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new xm(c,e,r,l)):c.type==="Conditional"&&di[i.type].includes("Conditional")&&(c.ifActions.forEach(a({expression:c.condition,negate:!1})),c.elseActions.forEach(a({expression:c.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function qt(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof cm||e instanceof bm||e instanceof gm||e instanceof pm||e instanceof wm||e instanceof um||e instanceof mm||e instanceof ym||e instanceof hm||e instanceof vm||e instanceof xm)&&e.dispose()})})}function IL(i,t){let e;if("material"in i){let r=i.material;Array.isArray(r)?e=i.material[0].layers.find(n=>n.uuid===t):e=i.material.layers.find(n=>n.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var OL=new Map,Sm=new Map,fa=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:n,loop:s,volume:o,delay:a}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=IL(r,n);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),Sm.has(r.uuid)?Sm.get(r.uuid).push(this):Sm.set(r.uuid,[this]),OL.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},nf=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=OL.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Sm.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...Sm.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},bm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new fa(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new nf(e);else throw new Error("Missing property")}dispatchBasic(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof fa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Bt(this.shared,this.condition)===!1)return!1;this.interaction instanceof fa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var RL=(()=>{let i,t,e,r;function n(a){!i&&!LL()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,u=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,d=0;for(;d<h;){let f=u[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&c[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(c[f.userData.actionId]>f.userData.quantity&&c[f.userData.actionId]--,u.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){LL()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):n()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),n})();function LL(){return!!document&&document.hidden}var NL=new He,XX=new _,QX=new _,wm=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Se.generateUUID();this.dispatch=()=>{if(Bt(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()};this.dispatchFromStart=()=>{if(Bt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=ww(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{this.timeoutIdQueue.shift();let t=new mr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldSVD(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),RL(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Dn)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof mr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Dn)return;t instanceof mr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new _().fromArray(this.data.velocity),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(XX,NL,QX),r.applyQuaternion(NL),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");RL(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var z1=200,F1=.02,k1=.3,KX=65,fFe=new _,BL=new _,FL=new _,ZX=new _,ai=new _,_i=new _,_l=new _,V1=new ie,kL=new ie,JX=new ie,pFe=new ie,Bs=new He,pa=new He,Eo=new Zt(0,0,0,"YXZ"),$X=new _(1,0,0),Fs=new _(0,1,0),eQ=new _(0,0,1),VL=new _(1,1,1),mFe=new fr,tQ=1,rQ=.025,nQ=16e-6,zL=12,iQ=20,On=new nn,ls=new Pt,sQ={type:"requestRender"},oQ={type:"updateMatrix"},UL=Math.PI/6,Z0=class extends Yt{constructor(e,r,n,s,o,a,l,u,c){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=u;this.sharedAssets=c;this.enableDamping=!0;this.hiddenMatrix0=new ie;this.target0=new _;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=z1;this.euler0=new Zt(0,0,0,"YXZ");this.position0Cam=new _;this.quat0Cam=new He;this.scale0Cam=new _;this.hiddenMatrix0Cam=new ie;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new nn(new _(0,-40,0),new _(0,40,0)),matrix:new ie,position:new _,rotation:new He};this.euler=new Zt(0,0,0,"YXZ");this.eulerDelta=new _;this.lastPosition=new _;this.lastCameraQuaternion=new He;this.lastCameraPosition=new _;this.PI_2=Math.PI/2;this.prevMouse=new N;this.velocityTarget=new _;this.velocity=new _;this.directionXZ=new _;this.rotVelocityStick=new _;this.rotVelocityTarget=new _;this.rotVelocity=new _;this.rotDirection=new _;this.nonColliderRotOffset=new ie;this.nonColliderPosOffset=new ie;this.firstPointerId=-1;this.rot=new _;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.vrEulerYOffset=0;this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new ie;this.objectToTarget=new _;this.objectToTarget0=new _;this.objectToCamXZ=new _;this.objectToCamXZ0=new _;this.targetToCamera=new _;this.targetToCamera0=new _;this.cameraPolarAxis0=new _;this.targetPos=new _;this.targetQuat=new He;this.lerpFactorPos=new _().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new He;this.objXZQuatInv=new He;this.objXZRotMat=new ie;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new _;this.pushedVelocity=new _;this.groundYRotation=0;this.objectRealQuat=new He;this.colliderWorldQuat=new He;this.groundNormal=new _;this.groundTilt=new He;this.groundTiltInv=new He;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new _;this.quaternion=new He;this.scale=new _;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!on&&(!Sw||Aw>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Sw&&Aw<15.5&&!on?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Z0.isLocked=!0:Z0.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let s=e.axes[n];r===0?n===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let g=new _(0,0,-1).applyQuaternion(this.camera.quaternion),y=new _().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(y),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(g.y)<1e-6?(y.y=0,g.y=0,x=y.projectOnVector(g)):y.y/g.y>0?x=g.multiplyScalar(y.y/g.y):x=g.multiplyScalar(y.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let w=new Zt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-w.x,w.x=0,w.z=0,w.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(w)}if(this.object instanceof er&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*tQ,this.speedOrbit=(n.speedRotate??100)*rQ,this.mouseOrbitSensitivity=(n.speedRotate??100)*nQ,this.keyAssignments=n.keyAssignments.map(g=>{let y=[g[0],g[1]];return y[1]==="\u25B2"?y[1]="ArrowUp":y[1]==="\u25C0"?y[1]="ArrowLeft":y[1]==="\u25BC"?y[1]="ArrowDown":y[1]==="\u25B6"?y[1]="ArrowRight":y[1]==="\u21E7"?y[1]="Shift":y[1]==="\u21B5"?y[1]="Enter":y[1]==="Space"?y[1]=" ":y[1]==="\u2318"?y[1]="Meta":y[1]==="Ctrl"?y[1]="Control":y[1]==="Esc"&&(y[1]="Escape"),y}),n.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(y=>y[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(y=>y[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Za.defaultData.gravity)*zL,this.usePhysics=this.gloabalPhysics.usePhysics??Za.defaultData.usePhysics,this.jumpPower=n.jumpPower*iQ,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Eh.defaultDataThirdPerson.orientWith,this.slopeThresh=KX*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*F1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*F1/this.pixelsPerMeter,this.stepThresh=n.collider.height*k1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let f=new _().fromArray(n.collider.position),p=new He().setFromEuler(new Zt().fromArray([...n.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,VL),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let g=new Le;g.push({fi:0,data:{..._n.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{..._n.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let y=new aa({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new _r(vv.create({parameters:{width:m,height:m/10,hollow:.7}}),y),this.navMeshPathDest.material.userData.opacity0=n.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new Zt().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof er?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},_h.list.forEach(n=>{this.actions[n]=nr({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),qt(this.actions.idle),qt(this.actions.move),qt(this.actions.run),qt(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return ai.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,n){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let u=_i.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*zL),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(c){this.onObject=!0,this.groundNormal.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),c.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=c.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(ai,pa,_i),this.groundVelocity.subVectors(ai,d.prevT),this.object.getWorldPosition(_i).add(this.collider.position).sub(ai),this.groundYRotation=Eo.setFromQuaternion(pa).y-d.prevR.y,_l.copy(_i).applyAxisAngle(Fs,this.groundYRotation),this.groundVelocity.add(_l.sub(_i)).divideScalar(s);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*o),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let u=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let c=ai.subVectors(this.path[1],this.position),h=_i.subVectors(this.path[1],this.path[0]);c.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),u.opacity=u.userData.opacity0}else u.opacity-=.05*u.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let l=ZX.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let u=_i.copy(l);u.y=0,l.set(0,l.y,u.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let u=ai;this.camera.getWorldDirection(u);let c=_l.copy(Fs).multiplyScalar(u.dot(Fs));u.sub(c);let h=_i.copy(this.directionXZ);h.x*=-1,this.rot.y=u.angleTo(h)*(u.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Eo.setFromVector3(this.rot),this.moveMode==="walk"&&(Eo.x=0),l.applyEuler(Eo),a&&(pa.setFromUnitVectors(Fs,this.groundNormal),l.applyQuaternion(pa)),n){let u=Eo.set(0,this.vrEulerYOffset*UL,0);n.applyEuler(u),l.x+=n.x,l.z+=n.z,this.nonColliderPosOffset.elements[13]+=n.y*s}if(this.usePhysics===!0){let u=_i;this.pushedVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=_l.setFromMatrixPosition(c.matrixWorld).sub(c.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=c.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),ai.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=lt.is(c)?c:c.object;if(d!==null&&this.lastHitObj!==f){let p;c instanceof mr&&(p=c);let m=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(m)for(let g of m)g.data.target==="character"&&(g.dispatch(p),f.dispatchEvent(J0));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),u.copy(d.normal1).applyQuaternion(c.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let c=u.dot(l);c<0&&l.addScaledVector(u,-c),l.add(this.pushedVelocity)}else l.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Fs,this.euler.y-this.euler0.y);let u=_i.copy(this.objectToCamXZ).normalize(),c=_l.copy(l).multiplyScalar(s);c.y=0;let h=c.sub(ai.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Se.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(Eo.copy(r),Eo.y=0):(Eo.copy(this.euler),Eo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Eo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*UL),Bs.setFromAxisAngle($X,this.rot.x),pa.setFromAxisAngle(Fs,this.rot.y),pa.multiply(Bs),Bs.setFromAxisAngle(eQ,this.rot.z),pa.multiply(Bs),this.quaternion.copy(pa),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let u=_i.copy(l).multiplyScalar(s/this.pixelsPerMeter),c=null;this.didHit=!1;let h=new _;for(let d=0;d<5;d++){let f=u.length(),p=_l.copy(u).normalize();if(c=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),c!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(c.collider.handle);if(m!==this.lastHitObj&&d===0){this.lastHitObj=m;let x=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(x){for(let w of x)if(w.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(c.collider.handle))._parent,A;if(m.cloner){for(let E of m.cloner.children)if(E.rigidBody===S){A=E;break}}w.dispatch(A),m.dispatchEvent(J0)}}}let g=BL.set(c.normal2.x,c.normal2.y,c.normal2.z).applyQuaternion(this.colliderWorldQuat),y=FL.copy(p).multiplyScalar(c.toi).dot(g),v=c.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),y>this.offset&&(v=c.toi*(y-this.offset)/y,h.addScaledVector(p,v)),u.copy(p).multiplyScalar(f-v),Math.acos(-g.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),w=_l.copy(c.witness2).applyQuaternion(this.colliderWorldQuat);w.y=0;let S=x.add(w);S.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);A!==null&&A.toi===0&&(g.y=0,g.normalize())}u.addScaledVector(g,-u.dot(g))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(u);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(ai.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Bs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let u=this.onObject?1:5,c=l.multiplyScalar(s/u);for(let h=0;h<u;h++)this.position.add(c),this.collisionAdjustment(s/u)}else this.position.addScaledVector(l,s);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let u=this.objectToTarget.add(this.position),c=this.targetToCamera.add(u);V1.lookAt(c,u,Fs).setPosition(c),V1.decompose(this.targetPos,this.targetQuat,ai),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Se.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Se.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(oQ),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(sQ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Bs.setFromAxisAngle(Fs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Se.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=Se.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Se.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=ai.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let s=pa.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){Fs.angleTo(e)*180/Math.PI<15||Fs.angleTo(e)*180/Math.PI>85?Bs.identity():Bs.setFromUnitVectors(Fs,e),this.groundTilt.slerp(Bs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=FL.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=V1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(ai,Bs,_i).compose(ai,Bs,VL);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;ls.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=kL.copy(a).invert(),u=JX.copy(kL).multiply(n);On.copy(this.collider.segment),On.start.applyMatrix4(u),On.end.applyMatrix4(u);let c=BL.copy(this.position).applyMatrix4(l);ls.expandByPoint(On.start),ls.expandByPoint(On.end),ls.min.addScalar(-this.collider.radius),ls.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(On.end)},intersectsBounds:h=>h.intersectsBox(ls),intersectsTriangle:h=>{let d=ai,f=_i,p=h.closestPointToSegment(On,d,f);if(p<this.collider.radius){let m=this.collider.radius-p,g=f.sub(d).normalize(),y=_l.copy(c);y.addScaledVector(g,m);let v=y.applyMatrix4(a).sub(this.position);r.add(v),On.start.addScaledVector(g,m),On.end.addScaledVector(g,m)}}})}),ls.makeEmpty(),On.copy(this.collider.segment),On.start.applyMatrix4(n),On.end.applyMatrix4(n),ls.expandByPoint(On.start),ls.expandByPoint(On.end),ls.min.addScalar(-this.collider.radius),ls.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(On.end)},intersectsBounds:o=>o.intersectsBox(ls),intersectsTriangle:o=>{let a=ai,l=_i,u=o.closestPointToSegment(On,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,c),On.start.addScaledVector(h,c),On.end.addScaledVector(h,c)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},Am=Z0;Am.isLocked=!1;var GL=pn(SS());function ks(i,t){let e=new Ae;if(!i.getAttribute("position"))return e.setAttribute("position",new be([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=gc(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new be(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var aQ=new ie,lQ=new ie,Mo=[[0,0,0],[0,0,0],[0,0,0]];function U1(i){let t=i.elements;Mo[0][0]=t[0],Mo[0][1]=t[4],Mo[0][2]=t[8],Mo[1][0]=t[1],Mo[1][1]=t[5],Mo[1][2]=t[9],Mo[2][0]=t[2],Mo[2][1]=t[6],Mo[2][2]=t[10];let{u:e,v:r}=(0,GL.SVD)(Mo),n=aQ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=lQ.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return n.multiply(s.transpose())}var $0=class extends Eu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(n=>{n.visible&&this.intersectObject(n,e,r)}),r}createRaycastLineHelper(){let t=new Hi({color:65280,linewidth:10}),e=new _(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new _(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=this.camera.far-this.camera.near,s=new _().addVectors(e,r.multiplyScalar(n)),o=new Ae;return o.setFromPoints([e,s]),new Hl(o,t)}};var HL=i=>i instanceof is||i instanceof Os;function cQ(i,t){return i.distance-t.distance}function jL(i,t,e){if(!(!so(t)||!t.visible)){Yn(t)&&t.raycast(i,e);for(let r of t.children)jL(i,r,e)}}function sf(i,t,e,r=!1){if(!r&&!e.some(s=>of(i,s)!==void 0))return[];let n=[];return t.children.forEach(s=>jL(i,s,n)),n.sort(cQ),n}function _m(i){let t=[];if(i.length){let e=i[0].object;so(e)&&t.push(e);let r=e.parent;for(;r;)HL(r)&&t.push(r),r=r.parent}return t}function of(i,t){if(Yn(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(HL(t))return WL(i,t)}function WL(i,t){if(!(!so(t)||!t.visible)){if(Yn(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let r=WL(i,e);if(r)return r}}}function uQ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}var ex=class{constructor(t,e,r,n,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=n;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new $0;this.raycasterNeedsUpdate=!0;this._useWindowEvents=!1;this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(t){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.updateDomRect(),this.raycaster.setFromCamera(uQ(e,r,this.domRect),this.getCamera())}};var G1=(a=>(a[a.keydown=0]="keydown",a[a.keyup=1]="keyup",a[a.pointerdown=2]="pointerdown",a[a.pointerup=3]="pointerup",a[a.pointermove=4]="pointermove",a[a.wheel=5]="wheel",a[a.scroll=6]="scroll",a))(G1||{}),yr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var H1=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],qL=i=>H1.find(([t,e])=>e===i)?.[0],To=i=>H1.find(([t])=>t===i)?.[1],hQ=(i,t)=>{let e=qL(i);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},tx=class extends yr{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[qL(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:n}=this.eventContext;n.dispatchEvent(r)};let{page:r}=this.eventContext;r.traverseEntity(n=>{if(!!n.data?.events.length){for(let[s,o]of H1)if(n.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(n):this.objectsPerEvents.set(s,[n]);let a={id:n.uuid,name:n.name},l=hQ(o,a),u=this.splineEvents[s];u?u[n.uuid]=l:this.splineEvents[s]={[n.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var j1=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{this.alreadyPlayedNonTogglingActions.has(n)===!1&&n.play()}),this.actions.SwitchCamera.some(n=>n.playing)||this.actions.SwitchCamera.forEach(n=>{n.play()}),this.actions.Animation.forEach(n=>{n.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},rx=class extends yr{constructor(e,r,n){super(e);this.useForRaycastProperty=n;this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]};this.canvasMouseEvents=[];this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}};this.heldKeys={};this.heldKeysPress={};this._prevObjects=[];this.sceneInterects=null;this.onCanvasRaycast=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=sf(r,n,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=To(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(n)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext;s.traverseEntity(a=>{if(!a.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let u of l){let c=this.eventsPerObjects[u];a.data.events.filter(({data:h})=>h.type===u&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let f=new j1(h,d,a,s,o,r);f.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(f):c[a.uuid]?c[a.uuid].push(f):c[a.uuid]=[f]}catch(f){!1&&console.log(f)}}),c[a.uuid]?.length&&this.objectsPerTypes[u].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(r=>{Object.values(r).forEach(n=>{n.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:n,page:s}=this.eventContext,o=this.objectsPerTypes[e];if(!(!o.length&&!this.useForRaycastProperty)){if(r||this.useForRaycastProperty){let a;this.sceneInterects===null?a=sf(n,s,o,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),r&&_m(a).forEach(l=>{this.eventsPerObjects[e][l.uuid]&&this.handleObjectMouseEventDispatch(l,e)})}r||o.forEach(a=>{of(n,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let r="MousePress",n=this.objectsPerTypes[r],s=[];if(!!n.length){if(!e){let{stopRaycast:o,raycaster:a,page:l}=this.eventContext;if(o){let u=sf(a,l,n);s=_m(u)}else n.forEach(u=>{of(a,u)&&s.push(u)})}this._prevObjects.length&&this._prevObjects.forEach(o=>{s.includes(o)||this.handleObjectMouseEventDispatchRelease(o,r)}),s.length&&s.forEach(o=>{this.handleObjectMouseEventDispatch(o,r)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatchRelease()})}handleKeyEvent(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(n?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(n)})})}};var dQ=new _,fQ=new _;var nx=class{constructor(t,e,r,n,s){this.actionsIn=nr(t,t.inActions,r,n,s,e),this.actionsOut=nr(t,t.outActions,r,n,s,e)}disconnect(){qt(this.actionsIn),qt(this.actionsOut)}};var W1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=dQ.setFromMatrixPosition(this.objects[0].matrixWorld),r=fQ.setFromMatrixPosition(this.objects[1].matrixWorld),n=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==n){this.stage=n;let s=n==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch())}};let{distance:l,fromObject:u,toObject:c}=r.condition;this.distance=l;for(let h of[u,c]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},q1=class extends nx{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(n=>n.dispatchConditional()),this.actionsOut.Video.forEach(n=>n.dispatchConditional()),this.actionsOut.Link.forEach(n=>n.dispatch()),this.actionsOut.Create.forEach(n=>n.dispatch()),this.actionsOut.Destroy.forEach(n=>n.dispatch()),this.actionsOut.Reset.forEach(n=>n.dispatch()),this.actionsIn.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(n=>n.play()),this.actionsOut.Animation.forEach(n=>n.play()),this.actionsIn.SwitchCamera.forEach(n=>n.pause()),this.actionsOut.SwitchCamera.forEach(n=>n.play()),this.actionsOut.SceneTransition.forEach(n=>n.dispatch()),this.actionsOut.SetVariable.forEach(n=>n.checkConditions()),this.actionsOut.SetVariable.forEach(n=>n.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(n=>n.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(n=>n.dispatchConditional()),this.actionsIn.Video.forEach(n=>n.dispatchConditional()),this.actionsIn.Link.forEach(n=>n.dispatch()),this.actionsIn.Create.forEach(n=>n.dispatch()),this.actionsIn.Destroy.forEach(n=>n.dispatch()),this.actionsIn.Reset.forEach(n=>n.dispatch()),this.actionsOut.Transition.forEach(n=>n.pause()),this.actionsOut.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(n=>n.play()),this.actionsIn.Animation.forEach(n=>n.play()),this.actionsOut.SwitchCamera.forEach(n=>n.pause()),this.actionsIn.SwitchCamera.forEach(n=>n.play()),this.actionsIn.SceneTransition.forEach(n=>n.dispatch()),this.actionsIn.SetVariable.forEach(n=>n.checkConditions()),this.actionsIn.SetVariable.forEach(n=>n.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(n=>n.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let u=s.find(l.object);if(!u)throw new Error("Missing property");if(this.toObject=u,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},ix=class extends yr{constructor(e,r){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let u;l.condition.type==="Comparison"||(l.condition.type==="Distance"?u=new W1(a,l,o,n,s,r):l.condition.type==="State"&&(u=new q1(a,l,o,n,s,r))),u&&(this.eventsPerConditions[l.condition.type].push(u),(u.actionsIn.Video.length||u.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(u){!1&&console.log(u)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var Em=new _,El=new _,Bc=new _,YL=new Or,pQ=.01,Ut=new _,hn=new _,XL=new _,Fc=new He,Y1=new Zt,mQ=new ie,X1=new Gt,af=new _,Co=new _,lf=.2;function Q1(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var gQ=function(){let i=new ie;return(t,e,r)=>{let n=t.obj;i.copy(n.hiddenMatrix),n.parent!==null&&i.premultiply(n.parent.matrixWorld),i.invert(),n.position.copy(e),t.reference==="global"&&Q1(n.position,t.limits),n.position.applyMatrix4(i),t.reference==="parent"?Q1(n.position,t.limits):t.reference==="local"&&(Fc.copy(t.quat0).invert(),n.position.sub(t.position0),n.position.applyQuaternion(Fc),Q1(n.position,t.limits),Fc.invert(),n.position.applyQuaternion(Fc),n.position.add(t.position0)),i.multiply(r??n.matrixWorld).decompose(Ut,n.quaternion,hn),n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n instanceof $t&&Xn(n.parent)&&n.invalidateDownstreamBooleanData(!0)}}(),K1=class{constructor(t,e,r,n,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=nr(e,e.dragDropActions.drag,r,n,s,this.object),this.actionsDrop=nr(e,e.dragDropActions.drop,r,n,s,this.object);let a=[];this.data.objects.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(a.push(u),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let u=r.find(l);!u||u.data.visible!==!1&&(this.dropDestIds.push(u.uuid),o[u.uuid]&&o[u.uuid].forEach(c=>{let h=r.find(c);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new _().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new _().setFromMatrixPosition(l.matrixWorld),pointStart:new _,pointEnd:new _,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new _().copy(l.position),quat0:new He().copy(l.quaternion),snapped:!1,orientationMatrix:new ie,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){qt(this.actionsDrag),qt(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},sx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:u,pointStart:c}of o.dragItems){if(l===s[0].object||l===s[0].object.object||lt.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(Ut,Fc,hn),Y1.setFromQuaternion(Fc),h.prevR===void 0?(h.prevR=Y1.clone(),h.prevT=Ut.clone()):(h.prevR.copy(Y1),h.prevT.copy(Ut)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(qe.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(qe.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||lt.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof is)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===l.object.uuid||n.scene.find(u).isAncestorOf(l.object.uuid))))[0]),a){let l=XL.copy(a.face.normal).applyMatrix3(X1.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ut.copy(l).applyMatrix3(X1.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;Ut.x>lf?hn.x=-u.recursiveBBox.min.x:Ut.x<-lf&&(hn.x=-u.recursiveBBox.max.x),Ut.y>lf?hn.y=-u.recursiveBBox.min.y:Ut.y<-lf&&(hn.y=-u.recursiveBBox.max.y),Ut.z>lf?hn.z=-u.recursiveBBox.min.z:Ut.z<-lf&&(hn.z=-u.recursiveBBox.max.z),hn.applyMatrix3(X1.invert())}else hn.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(hn)}this.activeEvent.data.autoOrient&&(Ut.set(0,1,0).cross(l),Ut.length()<1e-4&&Ut.set(-1,0,0).cross(l),hn.crossVectors(XL,Ut),o.orientationMatrix.makeBasis(Ut,hn,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(n=>n.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let n={};e.page.traverseEntity(s=>{s.component&&(n[s.component.uuid]?n[s.component.uuid].push(s.uuid):n[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new K1(s,o.data,e.page,e.sharedAssets,r,n))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,n,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(El),El.negate();let l=Fc.identity();switch(s==="parent"?mQ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ut,l,hn):s==="local"&&e.matrixWorld.decompose(Ut,l,hn),n){case"x":Ut.set(1,0,0).applyQuaternion(l),af.copy(El).cross(Ut),Co.copy(Ut).cross(af);break;case"y":Ut.set(0,1,0).applyQuaternion(l),af.copy(El).cross(Ut),Co.copy(Ut).cross(af);break;case"z":Ut.set(0,0,1).applyQuaternion(l),af.copy(El).cross(Ut),Co.copy(Ut).cross(af);break;case"xy":Co.set(0,0,1).applyQuaternion(l);break;case"yz":Co.set(1,0,0).applyQuaternion(l);break;case"xz":Co.set(0,1,0).applyQuaternion(l);break;case"adaptive":El.angleTo(hn.set(0,1,0))>Math.PI/6?(Ut.crossVectors(hn.set(0,1,0),El),Co.crossVectors(Ut,hn)):Co.set(0,1,0);break;default:Co.copy(El);break}Bc.setFromMatrixPosition(e.matrixWorld);let u=e.userData.lockedPlane?e.userData.worldPosition0:Bc;if(YL.setFromNormalAndCoplanarPoint(Co,u),!!a.ray.intersectPlane(YL,r)&&(n==="x"||n==="y"||n==="z")){let c=hn.subVectors(r,u).dot(Ut);r.copy(u).addScaledVector(Ut,c)}}updateDragItem(e,r=!1){Bc.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Em.subVectors(e.fromPosition,Bc).divideScalar(e.currentDampingFactor):e.reset==="original"?(Em.subVectors(e.obj.userData.worldPosition0,Bc).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Em.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Bc).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Em.length()<pQ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&gQ(e,Em.add(Bc),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var cf=new _,Z1=new _,ma=new _,ga=new _,QL=new Or,yQ=.01,vQ={type:"requestRender"},xQ=function(){let i=new _,t=new _;return(e,r,n)=>n>0?(i.subVectors(e,r),i.length()<=n?e:t.copy(r).add(i.normalize().multiplyScalar(n))):r}(),KL=function(){let i=new ie;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof $t&&Xn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),J1=class{constructor(t,e,r,n,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new _;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Fy.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=nr(t,t.actions,r,n,s,e)}},ox=class extends yr{constructor(e,r){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!n.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new J1(o.data,s,n,e.sharedAssets,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let s=n.target,o=this.onTargetChange(n);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let n of this.events)n.paused=!0,n.isReset=!1,qt(n.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(u=>{u.dispatchThrottled()})});let{plane:n,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(ma),e.isReset)ga.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ga);else{let{getCamera:l,raycaster:u}=this.eventContext;if(n==="custom"?(l().getWorldDirection(Z1),Z1.negate(),cf.copy(Z1)):n==="xy"?cf.set(0,0,1):n==="xz"?cf.set(0,1,0):n==="yz"&&cf.set(1,0,0),QL.setFromNormalAndCoplanarPoint(cf,ma),!u.ray.intersectPlane(QL,ga))return}if(!e.isReset){if(ga.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ga.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(ga.x=ma.x),e.data.enabledTranslation[1]===!1&&(ga.y=ma.y),e.data.enabledTranslation[2]===!1&&(ga.z=ma.z);let a=xQ(ma,ga,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=cf.subVectors(a,ma).divideScalar(e.currentDampingFactor);ma.add(l),r&&KL(e.object,ma),e.paused=l.length()<yQ}else KL(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(vQ)}};var Mm=new _,ax=new _,Tm=new ie,uf=new He,Ml=new He,Cm=new _,Pm=new _,kc=new _,ya=new _,$1=new Or,bQ=1e-6,wQ={type:"requestRender"},SQ={type:"changeRotation"},ZL=function(){let i=new ie;return function(e,r){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),r.premultiply(U1(i).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof $t&&Xn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),e_=class{constructor(t,e,r){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new He;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...ky.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},lx=class extends yr{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(qe.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onScroll=e=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:n})=>{if(!r||!n)return;let s=To(r);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(n=>{let s=n.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!r.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new e_(s.data,n,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?r.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),l=n.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(n),o=n.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),on&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let[n,s]of this.pairOfUserEventListeners)n.removeEventListener("userEvent",s);for(let n of this.events)n.paused=!0,n.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:n,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:u}=e.data,{getCamera:c,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(Cm),!e.isReset)if(e.target)e.target.getWorldPosition(Pm);else{if(o==="custom"?(c().getWorldDirection(ax),ax.negate(),$1.setFromNormalAndCoplanarPoint(ax,Cm)):(o==="xy"?Mm.set(0,0,1):o==="xz"?Mm.set(0,1,0):o==="yz"&&Mm.set(1,0,0),$1.setFromNormalAndCoplanarPoint(Mm,Cm)),!h.ray.intersectPlane($1,Pm))return;s>0&&(o==="custom"||o===void 0)&&Pm.addScaledVector(ax,s)}if(e.isReset||(f?r==="target"?kc.copy(f.up).applyMatrix4(Tm.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(n==="x"?(ya.set(0,0,1),l[2]===!1&&ya.set(0,1,0)):n==="y"?(ya.set(1,0,0),l[0]===!1&&ya.set(0,0,1)):(ya.set(0,1,0),l[1]===!1&&ya.set(1,0,0)),kc.copy(ya).applyQuaternion(e.worldQuaternion0).normalize()):kc.set(0,1,0):o==="custom"?kc.set(0,1,0):kc.copy(Mm)),e.isReset)Ml.copy(e.worldQuaternion0);else if(Cm.distanceTo(Pm)>a&&u&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Ml.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;AQ(Tm,Pm,Cm,kc,n,ya),Ml.setFromRotationMatrix(Tm),uf.setFromUnitVectors(ya.applyQuaternion(Ml),kc),l.some(p=>p===!1)&&r!=="target"&&Ml.premultiply(uf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),uf.setFromRotationMatrix(U1(d.matrixWorld)),uf.slerp(Ml,1/e.currentDampingFactor),ZL(d,Tm.makeRotationFromQuaternion(uf)),e.paused=8*(1-uf.dot(Ml))<bQ):(ZL(d,Tm.makeRotationFromQuaternion(Ml)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(wQ),d.dispatchEvent(SQ)}},cs=new _,dn=new _,Ur=new _;function AQ(i,t,e,r,n,s){let o=i.elements;Ur.subVectors(t,e),Ur.lengthSq()===0&&(Ur.z=1),Ur.normalize(),dn.crossVectors(r,Ur),dn.lengthSq()===0&&(Math.abs(r.z)===1?Ur.x+=1e-4:Ur.z+=1e-4,Ur.normalize(),dn.crossVectors(r,Ur)),dn.normalize(),cs.crossVectors(Ur,dn),n==="x"?s.z===1?[dn,cs,Ur]=[Ur,dn,cs]:(dn.negate(),[dn,Ur]=[Ur,dn]):n==="y"?s.x===1?[dn,cs,Ur]=[cs,Ur,dn]:(dn.negate(),[cs,Ur]=[Ur,cs]):s.x===1&&(dn.negate(),[dn,cs]=[cs,dn]),o[0]=dn.x,o[4]=cs.x,o[8]=Ur.x,o[1]=dn.y,o[5]=cs.y,o[9]=Ur.y,o[2]=dn.z,o[6]=cs.z,o[10]=Ur.z}var t_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},cx=class extends yr{constructor(e,r){super(e);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{qe.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{qe.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=To(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!(!o.visible||!o.data?.events.length)){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="MouseHover")try{let u=new t_(a,l,o,n,s,r);this.eventsPerObjects[o.uuid]?this.eventsPerObjects[o.uuid].push(u):this.eventsPerObjects[o.uuid]=[u]}catch(u){!1&&console.log(u)}this.eventsPerObjects[o.uuid]?.length&&this.objects.push(o)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),on&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(n=>{n.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:n,raycaster:s,page:o}=this.eventContext;if(n){let a=sf(s,o,this.objects);r=_m(a)}else this.objects.forEach(a=>{of(s,a)&&r.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(n=>{r.includes(n)||(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(n=>{n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var r_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=nr(e,e.actions,n,s,o,r)}connect(){this.scrollCounter=0}disconnect(){qt(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(r)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},n_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=nr(e,e.actions,n,s,a,r)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||e.scrollTop,s=r.clientTop||e.clientTop||0,o=Math.round(t.top+n-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,u=this.data.enterAnchor,c=u==="top"?a:u==="bottom"?a-l:a-l*.5;this.scrollStart=o-c}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){qt(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,n=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(n)),this.actions.Animation.forEach(s=>s.seek(n)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},ux=class extends yr{constructor(e,r){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,n])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),n.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=To(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{page:n,sharedAssets:s,domElement:o,isExport:a}=this.eventContext;n.traverseEntity(l=>{if(!!l.data?.events.length){for(let{id:u,data:c}of l.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!a){let h=new r_(u,c,l,n,s,r);this.wheelEventsPerObject.has(l)?this.wheelEventsPerObject.get(l)?.push(h):this.wheelEventsPerObject.set(l,[h])}else{let h=new n_(u,c,l,n,s,o,r);this.scrollEventsPerObject.has(l)?this.scrollEventsPerObject.get(l)?.push(h):this.scrollEventsPerObject.set(l,[h])}}}),this.intersectionObserver=new IntersectionObserver(l=>{let u=l[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var i_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}disconnect(){qt(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof So?e.interaction.audioPlayer.play():e.interaction instanceof tf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof fa?e.interaction.play(r==="autoplay"):e.interaction instanceof nf&&e.interaction.dispatch())})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof So?e.interaction.audioPlayer.play():e.interaction instanceof tf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof fa?e.interaction.play():e.interaction instanceof nf&&e.interaction.dispatch()})}},hx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext;(r?document:e).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.actions.Audio.forEach(s=>{s.interaction instanceof So&&s.interaction.audioPlayer.play()}),n.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof fa&&s.interaction.play(o==="autoplay")})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=To(e);s&&s==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext;if(r.traverseEntity(n=>{if(!!n.data?.events.length)for(let{id:s,data:o}of n.data.events){if(o.disabled||o.type!=="Start")continue;let a=new i_(s,o,n,r,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(n)?this.eventsPerObject.get(n)?.push(a):this.eventsPerObject.set(n,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(n)?this.eventsAfterPerObject.get(n)?.push(a):this.eventsAfterPerObject.set(n,[a]))}}),[...this.eventsAfterPerObject.values()].some(n=>n.length)){if(this.eventManager.activateCount===0){let{domElement:n,isExport:s}=this.eventContext,o=s?document:n;o.addEventListener("pointerdown",this.onMouseDown,{once:!0}),o.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),o.addEventListener("pointerdown",this.onAny),o.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,l])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(o=>o.dispatch()),n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onMouseDown),n.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(n=>n.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var dx=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=nr(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){qt(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var fx=class extends yr{constructor(e,r,n,s,o){super(e);this.sharedVariables=r;this.eventManager=n;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let r=new Date,n=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:u,property:c,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(u),f=zy.propertyPaths[c];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h===null?this.propertiesToWatch[l].prevValue=d instanceof _?d.clone():d:(d instanceof _?!d.equals(h):h!==d)&&(s.push({objId:u,property:c}),d instanceof _?this.propertiesToWatch[l].prevValue.copy(d):this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:u,prevValue:c}=this.variablesToWatch[l],h=this.shared.getVariable(u);h!==c&&(n.push(u),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:u,expectedTime:c,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],m=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?m=1:d.dynamicVariableType==="counter"?m=d.updateInterval:d.dynamicVariableType==="random"&&(m=d.isStatic?1/0:d.updateInterval),c===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m;continue}if(!((this.shared.getDynamicVariablePlayState(u)==="Stopped"||this.shared.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+m,d.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==p&&(this.shared.updateVariable(u,p),this.eventManager.requestRender()),(d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(u,fi.getFormattedTimerTime(p,d)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(u)==="Restarted"&&this.shared.setDynamicVariablePlayState(u,"Playing"),this.shared.getDynamicVariablePlayState(u)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[l].deltaToExpectedTime===void 0&&(this.dynamicVars[l].deltaToExpectedTime=Math.max(this.dynamicVars[l].expectedTime-e,0)),this.dynamicVars[l].last=e-(m-this.dynamicVars[l].deltaToExpectedTime),this.dynamicVars[l].expectedTime=e+this.dynamicVars[l].deltaToExpectedTime;continue}else this.dynamicVars[l].deltaToExpectedTime=void 0;if(e>=c)if(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=m,d.dynamicVariableType==="random"){let g=d.min+Math.random()*(d.max-d.min),y=d.decimals;g=Math.round(g*Math.pow(10,y))/Math.pow(10,y),this.shared.updateVariable(u,g),n.push(u),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let g=this.shared.getVariable(u),y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=this.shared.getVariable(u)+d.increment*(y?1:-1);d.hasEnd&&(v=d.increment>0?Se.clamp(v,p,d.endValue):Se.clamp(v,d.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?v===d.endValue&&(v=p):(v===p||v===d.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==g&&(n.push(u),this.shared.updateVariable(u,v),this.eventManager.requestRender())}else if(d.dynamicVariableType==="time")this.shared.updateVariable(u,IA(r,d)),n.push(u),this.eventManager.requestRender();else{let g=En.isTextValue(d.endValue)?JL(d.endValue.textValue):d.endValue,y=this.shared.getDynamicVariableToggleIsForward(u)??!0,v=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1)*(y?1:-1);v=Math.max(v,0),d.hasEnd&&(v=d.dynamicVariableType==="stopwatch"?Se.clamp(v,p,g):Se.clamp(v,g,p),v===p&&this.shared.setDynamicVariableToggleIsForward(u,void 0),d.repeat?Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(d.format==="number3decimal"?1e-4:.1)||Math.abs(v-g)<(d.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),v!==f&&(n.push(u),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(u,fi.getFormattedTimerTime(v,d)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(n.includes(l.data.variableId)||s.find(u=>u.objId===l.data.objectId&&u.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new s_(a.uuid,l.data,a,e.page,e.sharedAssets,n))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:l})=>{if(!("dynamicVariableType"in l)){this.events.find(c=>c.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let u;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let c;if(En.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?c=h[2]+h[1]*60+h[0]*3600:c=h[1]+h[0]*60}else c=l.value;u=c,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:c,startValue:u})}else l.dynamicVariableType==="time"&&this.shared.updateVariable(a,IA(new Date,l)),l.dynamicVariableType==="counter"&&(u=En.isTextValue(l.value)?JL(l.value.textValue):l.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:u})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},s_=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=nr(e,e.actions,n,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch())}dispose(){qt(this.actions)}};function JL(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var e3=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@0.9.499/build/",_Q=!1?e3:"https://unpkg.com/@splinetool/navmesh-wasm@0.9.499/build/",EQ=`
|
6427 | (async function() {
|
6428 | const [wasmImport, wasmBinary] = await Promise.all([
|
6429 | import('${e3}' + 'navmesh.js'),
|
6430 | fetch('${_Q}' + 'navmesh.wasm').then((res) => res.arrayBuffer()),
|
6431 | ]);
|
6432 | const wasmModule = wasmImport.default;
|
6433 | self.module = await wasmModule({ wasmBinary });
|
6434 | postMessage('ready');
|
6435 | })();
|
6436 | `,MQ=`
|
6437 | (async function() {
|
6438 | const [wasmImport, wasmBinary] = await Promise.all([
|
6439 | import(self.location.origin + '/_libraries/navmesh.js'),
|
6440 | fetch(self.location.origin + '/_libraries/navmesh.wasm').then((res) => res.arrayBuffer()),
|
6441 | ]);
|
6442 | const wasmModule = wasmImport.default;
|
6443 | self.module = await wasmModule({ wasmBinary });
|
6444 | postMessage('ready');
|
6445 | })();
|
6446 | `,TQ=`
|
6447 |
|
6448 | onmessage = function(messageEvent) {
|
6449 | const meshData = messageEvent.data;
|
6450 | const positions = meshData[0];
|
6451 | const offset = meshData[1];
|
6452 | const indices = meshData[2];
|
6453 | const indicesLength = meshData[3];
|
6454 | const parameters = meshData[4];
|
6455 |
|
6456 | const module = self.module;
|
6457 | const rc = new module.rcConfig();
|
6458 | rc.cs = parameters.cs;
|
6459 | rc.ch = parameters.ch;
|
6460 | rc.borderSize = parameters.borderSize ? parameters.borderSize : 0;
|
6461 | rc.tileSize = parameters.tileSize ? parameters.tileSize : 0;
|
6462 | rc.walkableSlopeAngle = parameters.walkableSlopeAngle;
|
6463 | rc.walkableHeight = parameters.walkableHeight;
|
6464 | rc.walkableClimb = parameters.walkableClimb;
|
6465 | rc.walkableRadius = parameters.walkableRadius;
|
6466 | rc.maxEdgeLen = parameters.maxEdgeLen;
|
6467 | rc.maxSimplificationError = parameters.maxSimplificationError;
|
6468 | rc.minRegionArea = parameters.minRegionArea;
|
6469 | rc.mergeRegionArea = parameters.mergeRegionArea;
|
6470 | rc.maxVertsPerPoly = parameters.maxVertsPerPoly;
|
6471 | rc.detailSampleDist = parameters.detailSampleDist;
|
6472 | rc.detailSampleMaxError = parameters.detailSampleMaxError;
|
6473 |
|
6474 | if (!self.navMesh) {
|
6475 | self.navMesh = new module.NavMesh();
|
6476 | }
|
6477 | self.navMesh.build(positions, offset, indices, indicesLength, rc);
|
6478 |
|
6479 | const navmeshData = navMesh.getNavmeshData();
|
6480 | const arrView = new Uint8Array(module.HEAPU8.buffer, navmeshData.dataPointer, navmeshData.size);
|
6481 | const ret = new Uint8Array(navmeshData.size);
|
6482 | ret.set(arrView);
|
6483 | navMesh.freeNavmeshData(navmeshData);
|
6484 |
|
6485 | postMessage(ret);
|
6486 | }
|
6487 | `,$L=.001,CQ={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1},t3,vt,Un;iP.then(i=>{t3=i,vt=new i.Vec3,Un=new i.Vec3});var PQ=new _,px=class{constructor(t=!1,e=!1){this.usePhysics=t;this.isExport=e;this.onPointerDown=t=>{if(qe.length!==1)return;let{raycaster:e,page:r}=this.eventContext;this.eventContext.updateRaycaster(t);let n=r.raycastWithClones(e);if(n.length!==0){if(this.gameControl){let s=PQ.copy(this.gameControl.colliderWorldPosition);s.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(s,n[0].point)}this.eventContext.requestRender()}};this.traverseWithPhysics=(t,e)=>r=>{let n;if(r instanceof Dn)if(r.objectForSample){if(r.objectForSample.dataPatched.physics.fusedBody)return;n=r.object}else return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(r instanceof mr)n=r.object;else if(n=r,n.dataPatched.cloner?.disabled===!1&&n.dataPatched.cloner?.hideBase&&n.dataPatched.physics?.fusedBody!==!0)return!0;if(e&&!n.userData.navmesh)return;let s=n.dataPatched;if(!s.visible&&s.physics?.enabled!==!0)return!0;r.updateMatrixWorldSVD();let o=Dm(s),a=n.userData.hasDestroy,l=n.userData.hasDrag,u=!1,c=!1;for(let h of s.events)h.data.disabled!==!0&&(h.data.type==="GameControl"?u=!0:h.data.type==="Follow"&&(c=!0));if(u||o||c||a||l)return!0;if(this.usePhysics&&s.physics?.rigidBody==="dynamic"){if(this.usePhysics&&s.physics?.fusedBody)return!0}else if("geometry"in r&&r.geometry&&t.push(ks(r.geometry,r.matrixWorld)),this.usePhysics&&s.physics?.fusedBody)return r.traverseObject((h,d)=>{if(d===0)return;let f;if(h instanceof Dn)if(h.objectForSample){if(h.objectForSample.dataPatched.physics.fusedBody)return;f=h.object}else return h.object.dataPatched.physics.fusedBody===!0&&h.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(h instanceof mr)f=h.object;else if(f=h,h.dataPatched.cloner?.hideBase)return!0;let p=f.dataPatched;if(!p.visible&&p.physics?.enabled!==!0)return!0;"geometry"in h&&h.geometry&&t.push(ks(h.geometry,h.matrixWorld))}),!0};this.traverseNoPhysics=(t,e)=>r=>{let n;if(r instanceof Dn)return;r instanceof mr?n=r.object:n=r;let s=n.dataPatched;if(s.physics.enabled==="visibility"?!s.visible:!s.physics.enabled)return!0;if(e&&!n.userData.navmesh)return;let o=r.geometry,a=n.userData.hasDestroy===!0,l=n.userData.hasDrag===!0;if(Dm(s)||a||l||n.dataPatched.events.some(u=>u.data.disabled!==!0&&u.data.type==="GameControl"))return!0;o&&t.push(ks(o,r.matrixWorld))};this.navmeshWasm=t3,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(e?EQ:MQ)+TQ])),this._worker=new Worker(this._workerURL)}init(t,e,r){this.gameControl=e,this.eventContext=r,this.resolution=t.ch,this.setDefaultQueryExtent(new _().setScalar(t.ch*t.walkableRadius*1.2)),this._worker.onmessage=()=>{this.createNavMesh(r.page,t,n=>{this.buildFromNavmeshData(n.data)})},this.eventContext.renderer.domElement.addEventListener("pointerdown",this.onPointerDown)}createNavMesh(t,e,r){e.objects.forEach(u=>{let c=t.scene.find(u);c.traverseEntity(h=>{h.userData.navmesh=!0}),c.cloner?.traverseObject(h=>{h.userData.navmesh=!0})});let n=[],s=(this.usePhysics?this.traverseWithPhysics:this.traverseNoPhysics)(n,e.zones==="custom");if(t.traverseChildren(s),e.objects.forEach(u=>{let c=t.scene.find(u);c.traverseEntity(h=>{h.userData.navmesh=void 0}),c.cloner?.traverseObject(h=>{h.userData.navmesh=void 0})}),n.length===0)return!1;let o=bs(n),{positions:a,triIndices:l}=gc(o.getAttribute("position"),o.getIndex());return this._worker.postMessage([a,a.length/3,l,l.length,{...CQ,...e}]),this._worker.onmessage=r,!0}createDebugNavGeometry(){let t,e,r=this.navMesh.getDebugNavMesh(),n=r.getTriangleCount(),s=new Uint32Array(n*3),o=new Float32Array(n*3*3);for(t=0;t<n*3;t++)s[t]=t;for(t=0;t<n;t++)for(e=0;e<3;e++){let l=r.getTriangle(t).getPoint(e);o[t*9+e*3+0]=l.x,o[t*9+e*3+1]=l.y,o[t*9+e*3+2]=l.z}let a=new Ae;return a.setIndex(new Ge(s,1)),a.setAttribute("position",new Ge(o,3)),a}getClosestPoint(t){return vt.x=t.x,vt.y=t.y,vt.z=t.z,this.navMesh.getClosestPoint(vt)}getClosestPointToRef(t,e){vt.x=t.x,vt.y=t.y,vt.z=t.z;let r=this.navMesh.getClosestPoint(vt);e.set(r.x,r.y,r.z)}getRandomPointAround(t,e){return vt.x=t.x,vt.y=t.y,vt.z=t.z,this.navMesh.getRandomPointAround(vt,e)}getRandomPointAroundToRef(t,e,r){vt.x=t.x,vt.y=t.y,vt.z=t.z;let n=this.navMesh.getRandomPointAround(vt,e);r.set(n.x,n.y,n.z)}moveAlong(t,e){return vt.x=t.x,vt.y=t.y,vt.z=t.z,Un.x=e.x,Un.y=e.y,Un.z=e.z,this.navMesh.moveAlong(vt,Un)}moveAlongToRef(t,e,r){return vt.x=t.x,vt.y=t.y,vt.z=t.z,Un.x=e.x,Un.y=e.y,Un.z=e.z,this.navMesh.moveAlong(vt,Un)}computePath(t,e){let r=this.getClosestPoint(e);Un.x=r.x,Un.y=r.y,Un.z=r.z,this.getClosestPoint(t);let n=this.navMesh.computePath(vt,Un),s=n.getPointCount(),o=[];for(let a=0;a<s;a++){let l=n.getPoint(a);o.push(new _(l.x,l.y,l.z))}return o}createCrowd(t,e){return new o_(this,t,e)}setDefaultQueryExtent(t){vt.x=t.x,vt.y=t.y,vt.z=t.z,this.navMesh.setDefaultQueryExtent(vt)}getDefaultQueryExtent(){return this.navMesh.getDefaultQueryExtent()}buildFromNavmeshData(t){let e=t.length*t.BYTES_PER_ELEMENT,r=this.navmeshWasm._malloc(e),n=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,r,e);n.set(t);let s=new this.navmeshWasm.NavmeshData;s.dataPointer=n.byteOffset,s.size=t.length,this.navMesh.buildFromNavmeshData(s),this.navmeshWasm._free(n.byteOffset)}getNavmeshData(){let t=this.navMesh.getNavmeshData(),e=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,t.dataPointer,t.size),r=new Uint8Array(t.size);return r.set(e),this.navMesh.freeNavmeshData(t),r}getDefaultQueryExtentToRef(t){let e=this.navMesh.getDefaultQueryExtent();t.set(e.x,e.y,e.z)}dispose(){this.navMesh.destroy(),this._worker.terminate(),URL.revokeObjectURL(this._workerURL),this.eventContext?.renderer.domElement.removeEventListener("pointerdown",this.onPointerDown)}addCylinderObstacle(t,e,r){return vt.x=t.x,vt.y=t.y,vt.z=t.z,this.navMesh.addCylinderObstacle(vt,e,r)}addBoxObstacle(t,e,r){return vt.x=t.x,vt.y=t.y,vt.z=t.z,Un.x=e.x,Un.y=e.y,Un.z=e.z,this.navMesh.addBoxObstacle(vt,Un,r)}removeObstacle(t){this.navMesh.removeObstacle(t)}isSupported(){return this.navmeshWasm!==void 0}},o_=class{constructor(t,e,r){this.navmeshWasmWrapper=t;this.transforms=[];this.agents=new Array;this.reachRadii=new Array;this._agentDestinationArmed=new Array;this._agentDestination=new Array;this.crowd=new this.navmeshWasmWrapper.navmeshWasm.Crowd(e,r,this.navmeshWasmWrapper.navMesh.getNavMesh())}onReachTarget(t,e){}addAgent(t,e,r){let n=new this.navmeshWasmWrapper.navmeshWasm.dtCrowdAgentParams;n.radius=e.radius,n.height=e.height,n.maxAcceleration=e.maxAcceleration,n.maxSpeed=e.maxSpeed,n.collisionQueryRange=e.collisionQueryRange,n.pathOptimizationRange=e.pathOptimizationRange,n.separationWeight=e.separationWeight,n.updateFlags=7,n.obstacleAvoidanceType=0,n.queryFilterType=0,n.userData=0;let s=this.crowd.addAgent(new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z),n);return this.transforms.push(r),this.agents.push(s),this.reachRadii.push(e.reachRadius?e.reachRadius:e.radius),this._agentDestinationArmed.push(!1),this._agentDestination.push(new _(0,0,0)),s}getAgentPosition(t){return this.crowd.getAgentPosition(t)}getAgentPositionToRef(t,e){let r=this.crowd.getAgentPosition(t);e.set(r.x,r.y,r.z)}getAgentVelocity(t){return this.crowd.getAgentVelocity(t)}getAgentVelocityToRef(t,e){let r=this.crowd.getAgentVelocity(t);e.set(r.x,r.y,r.z)}getAgentNextTargetPath(t){return this.crowd.getAgentNextTargetPath(t)}getAgentNextTargetPathToRef(t,e){let r=this.crowd.getAgentNextTargetPath(t);e.set(r.x,r.y,r.z)}getAgentState(t){return this.crowd.getAgentState(t)}overOffmeshConnection(t){return this.crowd.overOffmeshConnection(t)}agentGoto(t,e){this.crowd.agentGoto(t,new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z));let r=this.agents.indexOf(t);r>-1&&(this._agentDestinationArmed[r]=!0,this._agentDestination[r].set(e.x,e.y,e.z))}agentTeleport(t,e){this.crowd.agentTeleport(t,new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z))}updateAgentParameters(t,e){let r=this.crowd.getAgentParameters(t);e.radius!==void 0&&(r.radius=e.radius),e.height!==void 0&&(r.height=e.height),e.maxAcceleration!==void 0&&(r.maxAcceleration=e.maxAcceleration),e.maxSpeed!==void 0&&(r.maxSpeed=e.maxSpeed),e.collisionQueryRange!==void 0&&(r.collisionQueryRange=e.collisionQueryRange),e.pathOptimizationRange!==void 0&&(r.pathOptimizationRange=e.pathOptimizationRange),e.separationWeight!==void 0&&(r.separationWeight=e.separationWeight),this.crowd.setAgentParameters(t,r)}removeAgent(t){this.crowd.removeAgent(t);let e=this.agents.indexOf(t);e>-1&&(this.agents.splice(e,1),this.transforms.splice(e,1),this.reachRadii.splice(e,1),this._agentDestinationArmed.splice(e,1),this._agentDestination.splice(e,1))}getAgents(){return this.agents}update(t){if(this.navmeshWasmWrapper.navMesh.update(),t<=$L)return;let e=1/60,r=10;if(e<=$L)this.crowd.update(t);else{let n=Math.floor(t/e);r&&n>r&&(n=r),n<1&&(n=1);let s=t/n;for(let o=0;o<n;o++)this.crowd.update(s)}for(let n=0;n<this.agents.length;n++){let s=this.agents[n],o=this.getAgentPosition(s);if(this.transforms[n].copy(o),this._agentDestinationArmed[n]){let a=o.x-this._agentDestination[n].x,l=o.z-this._agentDestination[n].z,u=this.reachRadii[n],c=this._agentDestination[n].y-this.reachRadii[n],h=this._agentDestination[n].y+this.reachRadii[n],d=a*a+l*l;o.y>c&&o.y<h&&d<u*u&&(this.onReachTarget(s,this._agentDestination[n]),this._agentDestinationArmed[n]=!1)}}}setDefaultQueryExtent(t){let e=new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z);this.crowd.setDefaultQueryExtent(e)}getDefaultQueryExtent(){return this.crowd.getDefaultQueryExtent()}getDefaultQueryExtentToRef(t){let e=this.crowd.getDefaultQueryExtent();t.set(e.x,e.y,e.z)}getCorners(t){let e,r=this.crowd.getCorners(t),n=r.getPointCount(),s=[];for(e=0;e<n;e++){let o=r.getPoint(e);s.push(new _(o.x,o.y,o.z))}return s}dispose(){this.crowd.destroy()}};function a_(i){let t=!1;return i.scene.objects.forEach(e=>{e.data.type==="Page"&&!t&&e.data.publish.gameControlObject&&$a.traverseModuleInstances(i,e.id,(n,s,o)=>{for(let a of o)a.data.type==="GameControl"&&a.data.navmesh.enabled&&(t=!0)})}),t}var DQ={type:"change"},r3={type:"changeZoom"},IQ={type:"changePan"},hf={type:"start"},df={type:"end",changed:!0},OQ={type:"end",changed:!1},l_=new He,n3=new N,RQ=2*Math.PI,LQ=1e-8,NQ=.01,c_=new _,mx=new N,u_=new _,gx=new He,i3=new ie;var BQ={type:"requestRender"},ff=class extends Yt{constructor(e,r,n={isPlayMode:!1,isExport:!1}){super();this.object=e;this.domElement=r;this.options=n;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Oi.DOLLY_ROTATE,Oi.PAN];this.offset=new _;this.eye=new _;this.lastPosition=new _;this.lastQuaternion=new He;this.current=new N;this.overShoot=new N;this.overRatio=new N;this.spherical=new Wf;this.sphericalDelta=new Wf;this.panOffset=new _;this.panLeftV=new _;this.panUpV=new _;this.panV=new _;this.rotateStart=new N;this.rotateEnd=new N;this.rotateDelta=new N;this.panStart=new N;this.panEnd=new N;this.panDelta=new N;this.dollyStart=new N;this.dollyEnd=new N;this.dollyDelta=new N;this.rotationRangeFactor=new N;this.panRangeFactor=new N;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.resetHoverEffectOnPointerLeave=!1;this.hasChange=!1;this.useWindowEvents=!1;this.isTouchZoom=!0;this.autoRotateSpeed=2;this.dampingFactor=.125;this.zoomSpeed=2;this.rotateSpeed=1;this.panSpeed=1;this.hoverRotatePanStrength=.1;this.hoverRotateDamping=this.dampingFactor;this.thetaIsFree=!1;this.phiIsFree=!1;this.needsUpdate=!0;this.onCameraChange=e=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=e.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)};this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(u_,gx,c_),this.offset.copy(u_).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(l_.copy(gx).invert()),this.panOffset.applyQuaternion(l_),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(gx),this.panOffset.applyQuaternion(gx)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),u_.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(i3.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(i3));let e=this.spherical.phi%RQ;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(gt.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),e>0&&e>Math.PI||e<0&&e>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0){let r=this.hoverRotatePanMode===1?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-r,this.sphericalDelta.phi*=1-r}else this.sphericalDelta.set(0,0,0);return this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>NQ||8*(1-this.lastQuaternion.dot(this.object.quaternion))>LQ?(this.dispatchEvent(DQ),this.object.dispatchEvent(BQ),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=e=>{this.enabled!==!1&&(e.pointerType==="touch"||e.pointerType==="pen"&&on?this.onPointerDownTouch(e):this.onPointerDownMouse(e),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(hf),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),e.stopPropagation(),e.pointerType==="touch"||e.pointerType==="pen"&&on||this.domElement.setPointerCapture(e.pointerId)))};this.onPointerLeave=e=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,c_.subVectors(this.position0,this.target0),this.spherical.setFromVector3(c_),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=e};this.onPointerEnter=e=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?mx.set(e.clientX-this.domElement.clientWidth/2,e.clientY-this.domElement.clientHeight/2):mx.set(e.clientX-this.pointerLeaveEvent.clientX,e.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(mx).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(n3,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(e.clientX,e.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(mx).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(e.clientX,e.clientY)),this.update()};this.onPointerMove=e=>{this.enabled!==!1&&(this.checkRaycastLock()||(e.pointerType==="touch"||e.pointerType==="pen"&&on?this.onPointerMoveTouch(e):this.onPointerMoveMouse(e),e.stopPropagation()))};this.onPointerUp=e=>{this.isPointerDown=!1,qe.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),qe.length>1&&e.preventDefault(),this.hasChange?this.dispatchEvent(df):this.dispatchEvent(OQ),this.state=-1,e&&(e.stopPropagation(),e.pointerType==="touch"||e.pointerType==="pen"&&on||this.domElement.releasePointerCapture(e.pointerId))};this.onPointerDownMouse=e=>{let r;switch(this.useKeyEvents?r=this.mouseButtons[e.button]:r=this.mouseButtonsPlay[e.button],r){case 0:if(e.altKey===!0&&!e.shiftKey&&!np(e)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2;break;case 3:if(np(e)||e.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}break;case 5:if(np(e)||e.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;default:this.state=-1}};this.onPointerMoveMouse=e=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(e);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(e);break}this.object.wasMovedByUser=!0};this.onPointerDownTouch=e=>{switch(qe.length>1&&e.preventDefault(),this.touches[qe.length-1]){case Oi.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Oi.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Oi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Oi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}};this.onPointerMoveTouch=e=>{switch(qe.length>1&&e.preventDefault(),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(e),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(e),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(e),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(e),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0};this.dispatchEndDebounced=tc(()=>this.dispatchEvent(df),33);this.onMouseWheel=e=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||this.checkRaycastLock()||(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&e.preventDefault(),this.dispatchEvent(hf),this.handleMouseWheel(e),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0)};this.onGesture=e=>{if(e.preventDefault(),this.enabled!==!1&&!this.checkRaycastLock()&&!uy)if(e.type==="gesturechange"){if(this.enableZoom===!1||this.isTouchZoom===!1)return;this.dispatchEvent(hf),e.scale>this.prevScale?this.dollyIn(this.getZoomScale()):e.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=e.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(df)};this.onContextMenu=e=>{e.preventDefault()};this.onTouchEnd=e=>{e.preventDefault()};this.onKeyDown=e=>{this.enabled!==!1&&(this.key=e.key,e.key===" "&&this.dispatchEvent(hf))};this.onKeyUp=e=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&e.key==="Alt"&&this.onPointerUp(qe[0]),e.key===" "&&this.dispatchEvent(df))};this.onPointerHover=e=>{e.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(e,this.hoverRotatePanStrength):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(e,this.hoverRotatePanStrength))};this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1};this.onCompleteState=e=>{e.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.offset.copy(this.object.position).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.addEventListenersToCamera()}dispatchEvent(e){e.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(e)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(e){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=e,this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let r=this.useWindowEvents?window:this.domElement;r.addEventListener("pointerleave",this.onPointerLeave),r.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(e,r){this.setEnableDampingSpeed(e.enableDamping),this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableRotate=e.enableRotate,this.rotationLimitsMode=e.rotationLimitsMode,this.thetaIsFree=e.rotationHorizontalOffset.min===e.rotationHorizontalOffset.max&&e.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=e.rotationVerticalOffset.min===e.rotationVerticalOffset.max&&e.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=e.panLimitsMode,this.panSoftLimit=e.panSoftLimit,this.rotationSoftLimit=e.rotationSoftLimit,this.hoverRotatePanMode=e.hoverRotatePanMode,this.hoverRotateDamping=e.hoverRotateDamping??this.dampingFactor,this.useWindowEvents=r==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let n=e.hoverRotatePanStrength/100;this.hoverRotatePanStrength=n**2,this.zoomLimitsEnabled=e.zoomLimitsEnabled,this.minZoom=e.zoomLimits.min,this.maxZoom=Math.max(e.zoomLimits.min,e.zoomLimits.max),this.minDistance=1e3/e.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/e.zoomLimits.min),this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed,this.autoRotateClockwise=e.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(l_.copy(this.object.quaternion).invert());this.minV=-e.panVerticalOffset.min+s.y,this.maxV=e.panVerticalOffset.max+s.y,this.minH=-e.panHorizontalOffset.min+s.x,this.maxH=e.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Po(this.spherical.phi-e.rotationVerticalOffset.min),this.maxPhi=Po(this.spherical.phi+e.rotationVerticalOffset.max),this.minTheta=Po(Po(this.spherical.theta)-e.rotationHorizontalOffset.min),this.maxTheta=Po(Po(this.spherical.theta)+e.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,e.orbitTouches===1&&(this.touches[0]=Oi.ROTATE),e.panTouches===1&&(this.touches[0]=Oi.PAN),e.orbitTouches===2&&(this.touches[1]=Oi.DOLLY_ROTATE),e.panTouches===2&&(this.touches[1]=Oi.DOLLY_PAN),e.orbitTouches===3&&(this.touches[2]=Oi.ROTATE),e.panTouches===3&&(this.touches[2]=Oi.PAN),this.isTouchZoom=e.isTouchZoom,this.resetHoverEffectOnPointerLeave=e.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(e,r,n,s,o,a,l,u){this.overShoot.set(0,0);let c,h,d;e instanceof _?(c=e.x,h=e.y,this.current.set(this.target.x,this.target.y),d=!0):(c=e.theta,h=e.phi,this.current.set(Po(this.spherical.theta),Po(this.spherical.phi)),d=!1),n===0&&(this.current.x+=c,this.current.y+=h),(r===3||r===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(r===3||r===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y)),d||(this.overShoot.x=Po(this.overShoot.x),this.overShoot.y=Po(this.overShoot.y)),n!==0?(this.overRatio.copy(this.overShoot).divide(u),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),n===1&&(this.overRatio.x=s3(Math.abs(this.overRatio.x)),this.overRatio.y=s3(Math.abs(this.overRatio.y))),this.isPointerDown||n===1?n===2&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(c*this.overShoot.x<0&&!this.thetaIsFree&&(c*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):n===2&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(c=this.overShoot.x*.05),this.phiIsFree||(h=this.overShoot.y*.05),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(c+=this.overShoot.x,h+=this.overShoot.y),e instanceof _?(e.x=c,e.y=h):(this.thetaIsFree||(e.theta=c),this.phiIsFree||(e.phi=h))}setEnableDampingSpeed(e){this.enableDamping=e,this.rotateSpeed=e===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}panLeft(e,r){this.panLeftV.setFromMatrixColumn(r,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)}panUp(e,r){this.panUpV.setFromMatrixColumn(r,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)}pan(e,r){let n=this.domElement;if(n&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*o/n.clientHeight,this.object.matrixWorld),this.panUp(2*r*o/n.clientHeight,this.object.matrixWorld)}else n&&this.object.isOrthographicCamera&&(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrixWorld),this.panUp(r*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrixWorld));this.dispatchEvent(IQ)}dollyOut(e){this.object.isPerspectiveCamera?this.scale/=e:this.object.isOrthographicCamera&&(this.object.zoom*=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(r3)}dollyIn(e){this.object.isPerspectiveCamera?this.scale*=e:this.object.isOrthographicCamera&&(this.object.zoom/=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(r3)}zoomOut(e=this.getZoomScale()){this.dispatchEvent(hf),this.dollyOut(e),this.dispatchEvent(df)}zoomIn(e=this.getZoomScale()){this.dispatchEvent(hf),this.dollyIn(e),this.dispatchEvent(df)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e,r=1){e.movementX!==void 0?this.rotateDelta.set(e.movementX,e.movementY):(this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*r).rotateAround(n3,-this.object.angleOffsetFromUp);let n=this.domElement,s=this.useWindowEvents?window.innerHeight:n.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e,r=1){e.movementX!==void 0?this.panDelta.set(e.movementX,e.movementY):(this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*r),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(e){if(QC===!1&&np(e)===!1&&FQ(e)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-e.deltaX,-e.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),e.altKey?this.pan(0,this.panDelta.y):e.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;e.deltaY===0?e.deltaX<0?this.dollyIn(this.getZoomScale()):e.deltaX>0&&this.dollyOut(this.getZoomScale()):e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(qe.length===2){let e=.5*(qe[0].pageX+qe[1].pageX),r=.5*(qe[0].pageY+qe[1].pageY);this.rotateStart.set(e,r)}else this.rotateStart.set(qe[0].pageX,qe[0].pageY)}handleTouchStartPan(){if(qe.length===2){let e=.5*(qe[0].pageX+qe[1].pageX),r=.5*(qe[0].pageY+qe[1].pageY);this.panStart.set(e,r)}else this.panStart.set(qe[0].pageX,qe[0].pageY)}handleTouchStartDolly(){let e=qe[0].pageX-qe[1].pageX,r=qe[0].pageY-qe[1].pageY,n=Math.sqrt(e*e+r*r);this.dollyStart.set(0,n)}handleTouchStartDollyPan(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(e){if(qe.length===2){let n=my(e),s=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this.rotateEnd.set(s,o)}else{if(e.pointerId!==qe[0].pointerId)return;this.rotateEnd.set(e.pageX,e.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let r=this.domElement;r&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/r.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/r.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(qe.length===2){let r=my(e),n=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this.panEnd.set(n,s)}else{if(e.pointerId!==qe[0].pointerId)return;this.panEnd.set(e.pageX,e.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){let r=my(e),n=e.pageX-r.x,s=e.pageY-r.y,o=Math.sqrt(n*n+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let e=this.options?.showCameraLock;return e&&e(),!0}}else return!1}};function Po(i){let t=Math.PI*2;for(;i<=-Math.PI;)i+=t;for(;i>Math.PI;)i-=t;return i}function s3(i){return 1-Math.pow(1-i,4)}function FQ(i){return i.wheelDeltaY===0||i.deltaY===0?rc&&i.shiftKey&&Math.abs(i.wheelDeltaX)>=120?!1:i.wheelDeltaX?i.wheelDeltaX===-3*i.deltaX||i.wheelDeltaX===-3*window.devicePixelRatio*i.deltaX:i.deltaMode===0:i.wheelDeltaY?i.wheelDeltaY===-3*i.deltaY||i.wheelDeltaY===-3*window.devicePixelRatio*i.deltaY:i.deltaMode===0}var Im=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.page=n;this.currentIntersectedObjects=[];this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=nr(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle",this.triggeringObjects=e.triggeringObjects.map(a=>n.scene.find(a))}isValidTriggeringObject(t){return this.target==="all"?!0:this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){qt(this.actions)}dispatch(){this.disabled||this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()))}};var At;aP.then(i=>At=i);var $r=new _,Vs=new He,Tl=new _,h_=new Zt(0,0,0,"YXZ"),o3=new Zt(0,0,0,"XYZ"),zs=new _,d_=new _,f_=new _(1,1,1),pf=new He,yx=new ie,a3=new ie,kQ={type:"updateMatrix"},l3=new He,p_=new fr,J0={type:"beginEvent",eventName:"Collision"},VQ={type:"beginEvent",eventName:"Trigger"};function c3(i){if($a.physicsEnabled(i.scene.objects))return!0;let t=!1;return i.scene.objects.traverse((e,r)=>{if(r.events){if(Array.isArray(r.events)){for(let n of r.events)if(n.data.disabled!==!0&&n.data.type==="GameControl"&&n.data.collisionEnabled){t=!0;break}}else for(let n of Object.values(r.events))if(n.disabled!==!0&&n.type==="GameControl"&&n.collisionEnabled){t=!0;break}}}),t}var Dm=i=>i.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0),vx=class{constructor(t){this.eventContext=t;this.isEnabled=!1;this.gameControl=null;this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}};this.sensorToTriggerEvent={};this.eventManager=void 0;this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.collisionEvents=[];this.isExport=!1;this.processRigidBody=t=>{if(t.bodyType()!==At.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,r,n]=this.rigidBodyToMesh.get(t.handle);if($r.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),Vs.copy(t.rotation()),e.matrixWorld.compose($r,Vs,r),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(kQ),n){let s=e.cloner;if(s&&s.objectForSample===void 0){s.matrixWorld.copy(e.matrixWorld);for(let o of s.children)o.updateMatrixWorld(!0)}for(let o of e.children)o.updateMatrixWorld(!0)}};this.accumulator=0;this.handleCollisionEvents=(t,e,r)=>{if(r===!1)return;let n,s;if(this.sensorToTriggerEvent[t]?(n=this.sensorToTriggerEvent[t],s=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(n=this.sensorToTriggerEvent[e],s=this.sharedGameControlGlobals.colliderToEntity.get(t)),n&&s&&n.isValidTriggeringObject(s)){n.dispatch();return}for(let o=this.sharedGameControlGlobals.createdObjects.length-1;o>=0;o--){let a=this.sharedGameControlGlobals.createdObjects[o];if(a.userData.hasCollisionDestroy&&(a.rigidBody?.collider(0).handle===t||a.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(o,1),a.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(a.rigidBody));break}}if(this.gameControl?.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a===void 0)return;for(let l of a)l.data.target==="character"&&this.dispatchCollisionEvent(l,o,e)}else if(this.gameControl?.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let o=this.sharedGameControlGlobals.colliderToEntity.get(t),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a===void 0)return;for(let l of a)l.data.target==="character"&&this.dispatchCollisionEvent(l,o,t)}else{let o=this.sharedGameControlGlobals.colliderToEntity.get(t),a=this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid];if(a!==void 0)for(let c of a)c.data.target==="scene"&&this.dispatchCollisionEvent(c,o,t);let l=this.sharedGameControlGlobals.colliderToEntity.get(e),u=this.sharedGameControlGlobals.entityToCollisionEvents[l?.uuid];if(u!==void 0)for(let c of u)c.data.target==="scene"&&this.dispatchCollisionEvent(c,l,e)}};this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=z1,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}attachVRControllers(t){t.forEach(e=>{e.addEventListener("connected",r=>{"gamepad"in r.data&&"axes"in r.data.gamepad&&this.sharedGameControlGlobals.gamePads.push(r.data.gamepad)})})}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let r of e.events){if(r.data.disabled===!0)continue;let n=r.data.actions?.find(s=>s.data.type==="Destroy")?.data;if(n)for(let s of n.objects){let o=this.page.scene.find(s);o&&(o.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let r of e.events)if(!(r.data.disabled===!0||r.data.type!=="DragDrop"))for(let n of r.data.objects){let s=this.page.scene.find(n);s&&(s.userData.hasDrag=!0)}})}initBVH(){let t=[];if(this.page.traverseChildren(e=>{let r;if(e instanceof Dn)return;e instanceof mr?r=e.object:r=e;let n=r.dataPatched;if(n.physics?.enabled==="visibility"?!n.visible:!n.physics?.enabled)return!0;let s=e.geometry,o=r.userData.hasDestroy===!0,a=r.userData.hasDrag===!0;if(Dm(n)||o||a||r.dataPatched.events.some(l=>l.data.disabled!==!0&&l.data.type==="GameControl"))return e.updateMatrixWorldSVD(),this.addBoundsTree(e),!0;s&&t.push(ks(s,e.matrixWorld))}),t.length>0){let e=bs(t,!1);this.sharedGameControlGlobals.staticMeshBVH=new no(e)}}addRigidBody(t,e,r){let n=[],s="geometry"in t?t.geometry:void 0,o=e.dataPatched;if(s?.getAttribute("position")!==void 0&&n.push(ks(s,t.shearScale)),o.physics.fusedBody){let a=this.gatherChildrenGeom(t,n);t.traverseObject(a),t.children.forEach(u=>u.updateMatrixWorld(!0));let l=t.cloner;l&&l.objectForSample===void 0&&o.physics.rigidBody==="dynamic"&&(l.traverseObject(a),l.children.forEach(u=>u.updateMatrixWorld(!0)))}if(n.length>0){let a,l=!r.fromCreate&&o.physics.rigidBody==="dynamic"||r.fromCreate&&r.dynamic;l?(a=At.RigidBodyDesc.dynamic(),a.setLinearDamping(o.physics.damping).setAngularDamping(o.physics.damping).setAdditionalMass(1e-9).setGravityScale(o.physics.gravityScale).enabledRotations(...o.physics.enabledRotation).enabledTranslations(...o.physics.enabledTranslation)):(r.hasTransformAnim||r.hasFollow||r.hasDrag)&&!r.fromCreate?(a=At.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):a=At.RigidBodyDesc.fixed();let u=bs(n);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose($r,Vs,Tl),t.position0=$r.clone().divideScalar(this.pixelsPerMeter),t.rotation0=Vs.clone(),$r.divideScalar(this.pixelsPerMeter),a.setTranslation($r.x,$r.y,$r.z).setRotation(Vs),s?u?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):u?.scale(Tl.x/this.pixelsPerMeter,Tl.y/this.pixelsPerMeter,Tl.z/this.pixelsPerMeter);let c=this.sharedGameControlGlobals.rapierWorld.createRigidBody(a);l&&this.rigidBodyToMesh.set(c.handle,[t,Tl.clone(),o.physics.fusedBody]);let h=!(o.geometry===void 0||o.geometry.type==="SubdivGeometry"||o.geometry.type==="NonParametricGeometry"||o.geometry.type==="BooleanGeometry"||o.geometry.type==="VectorGeometry"||o.geometry.type==="StarGeometry"||o.geometry.type==="RectangleGeometry"||o.geometry.type==="EllipseGeometry"||o.geometry.type==="TriangleGeometry"||o.geometry.type==="TorusGeometry"||o.geometry.type==="HelixGeometry");try{this.addCollider(c,o.physics,u,e,h)}catch{try{this.addCollider(c,o.physics,u,e,!1)}catch(f){console.error(f)}}t.rigidBody=c}}addBoundsTree(t){let e=[];if(t.geometry?.getAttribute("position")!==void 0&&t.geometry?.getAttribute("position").count>0&&e.push(ks(t.geometry,t.shearScale)),t.traverseObject(this.gatherChildrenGeom(t,e)),t.children.forEach(r=>r.updateMatrixWorld(!0)),e.length>0){let r=bs(e,!1);t.bvhGeometry=r,t.bvhGeometry.boundsTree=new no(r),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)}}addCollider(t,e,r,n,s=!0){if(r?.getAttribute("position").count===0||r?.getIndex()?.count===0)return;let o;r&&(e.colliderType==="trimesh"?o=At.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array):o=At.ColliderDesc.convexMesh(r.getAttribute("position").array,s?r.getIndex().array:void 0)),o.setFrictionCombineRule(At.CoefficientCombineRule.Average).setRestitutionCombineRule(At.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let a=this.sharedGameControlGlobals.rapierWorld.createCollider(o,t);this.sharedGameControlGlobals.colliderToEntity.set(a.handle,n),this.sharedGameControlGlobals.entityToCollisionEvents[n.uuid]?.some(l=>l.target==="scene")&&a.setActiveEvents(At.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){return(r,n)=>{if(n===0)return;let s;if(r instanceof Dn)if(r.objectForSample){if(r.objectForSample.dataPatched.physics.fusedBody)return;s=r.object}else return r.object.dataPatched.physics.fusedBody===!0&&r.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(r instanceof mr)s=r.object;else if(s=r,s.dataPatched.cloner?.hideBase)return!0;let o=s.dataPatched;if(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)return!0;n===1?t.hasNonUniformScale?r.matrixWorld.multiplyMatrices(t.shearScale,r.hiddenMatrix):r.matrixWorld.copy(r.hiddenMatrix):r.matrixWorld.multiplyMatrices(r.parent.matrixWorld,r.hiddenMatrix),r.matrixWorld.multiply(r.matrix);let a=r.geometry;a?.getAttribute("position")!==void 0&&e.push(ks(a,r.matrixWorld))}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,r=!1,n=5,s=8,o=9,a="drag",l=this.page.data.publish.gameControlObject,u=l!==null?this.page.find(l):null,c=null;if(u)for(let f of u.data.events){if(f.data.disabled||f.data.type!=="GameControl")break;let p=u;for(;this.usePhysics&&(p=p.parent)?.parent!==null&&!p.data.physics?.fusedBody;);f.data.collisionEnabled&&(this.needsCollisionDetection=!0),c===null&&(c=f.data)}if(this.page.traverseEntity(f=>{for(let p of f.dataPatched.events)if(p.data.disabled===!1&&p.data.type==="Trigger")return this.needsCollisionDetection=!0,!0}),u&&c){r=r||c.camera===e.uuid||u.uuid===e.uuid;let f=new Am(u,this.renderer.domElement,c,this.eventContext.page.data.globalPhysics,this,u.uuid!==e.uuid&&c.camera===e.uuid,e,this.page,this.sharedAssets);this.gameControl=f,n=c.joystickPosLoc,s=c.joystickRotLoc,o=c.jumpTouchButtonLoc,a=c.rotByTouch,on&&c.touchControl&&(this.joystickToGameControls[n]="pos",c.moveMode==="walk"&&(this.joystickToGameControls[o]="jmp"),a==="joystick"&&(this.joystickToGameControls[s]="rot"))}if(this.gameControl&&this.gameControl.data.navmesh.enabled){let f=this.gameControl.data;if(!this.navigationMeshWrapper){this.navigationMeshWrapper=new px(this.usePhysics,this.isExport);let p;f.collider.type==="sphere"?p=f.collider.radius*2:p=f.collider.height,p=Math.floor(p/f.navmesh.ch-1),this.navigationMeshWrapper.init({...f.navmesh,walkableHeight:p},this.gameControl,this.eventContext)}}if(r===!1){let{enableRotate:f,enablePan:p,enableZoom:m,autoRotate:g,hoverRotatePanMode:y}=this.eventManager.publish.orbitControls;(f||p||m||g||y!==0)&&(this.orbitControls=new ff(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let h=this.renderer.domElement.width/this.renderer.getPixelRatio(),d=this.renderer.domElement.height/this.renderer.getPixelRatio();this.joystickToGameControls.forEach((f,p)=>{let m=document.body.appendChild(document.createElement("div")),[g,y,v]=this.eventManager.eventContext.publish.joystickSizeAndXYOffset[p],x=(h-5*g)/4+g,w={},S=f==="jmp",A=S?0:g;p<10?(p<5?w.top=A/2:w.bottom=A/2,w.left=A/2+p%5*x):p===10?(w.left=A/2,w.top=d/2):(w.right=A/2,w.top=d/2),w.top?w.top-=y[1]:w.bottom+=y[1],w.left?w.left+=y[0]:w.right-=y[0];for(let M in w)w[M]+="px";if(S){let M=m.appendChild(document.createElement("div"));Object.assign(M.style,w,{position:"absolute",width:g+"px",height:g+"px",backgroundColor:`rgba(255,255,255,${v==="show"?.4:0})`,zIndex:"9999",borderRadius:g+"px",border:v==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let T=g/16*16*.4;v==="show"&&(M.innerHTML=`
|
6488 | <svg width="${T}" height="${g*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
6489 | <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
6490 | </svg>
|
6491 | `),M.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),M.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,m];return}let E={zone:m,mode:"static",position:w,size:g};v==="hide"&&(E.restOpacity=0);let b=jR.create(E);b.on("move",(M,T)=>{let C=this.gameControl;f==="pos"?T.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-T.angle.radian),C.movementState.movePosX=Math.cos(-T.angle.radian),T.force>1.2?C.movementState.run=1:C.movementState.run=0,T.force<.3?C.moveForce=(T.force-.2)/.1:C.moveForce=1):f==="rot"&&(T.force<.2?C.rotForce=0:(C.movementState.rotPosX=T.vector.y,C.movementState.rotPosY=-T.vector.x,T.force<.3?C.rotForce=(T.force-.2)/.1:C.rotForce=1)),this.requestRender()}),b.on("end",(M,T)=>{let C=this.gameControl;f==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):f==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[b,m]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new At.World(new At.Vector3(0,this.gravity,0)),this.events=new At.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Dn)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof mr)l=a.object;else if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0;let u=l.dataPatched,c;for(let y of u.events)y.data.disabled!==!0&&y.data.type==="GameControl"&&(c=y.data);if(!u.physics||(u.physics.enabled==="visibility"?!u.visible:!u.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=Dm(u),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,m=!1;for(let y of u.events)if(y.data.disabled!==!0){if(y.data.type==="Collision"){d=!0;let v=new dx(y.id,y.data,l,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==y.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(y.data.type==="Follow"){m=!0;let v=y.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}u.physics.rigidBody==="dynamic"&&u.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(c!==void 0){let y=At.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose($r,Vs,Tl),a.position0=$r.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Vs.clone(),$r.divideScalar(this.pixelsPerMeter),y.setTranslation($r.x,$r.y,$r.z).setRotation(Vs);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);a.rigidBody=v;let x;c.collider.type==="sphere"?x=At.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?x=At.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):x=At.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(At.CoefficientCombineRule.Average).setRestitutionCombineRule(At.CoefficientCombineRule.Average).setDensity(u.physics.density).setFriction(u.physics.friction).setRestitution(u.physics.restitution);let w=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(w.handle,l),$r.fromArray(c.collider.position).multiply(Tl.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),w.setTranslationWrtParent($r);let S=new He().setFromEuler(new Zt().setFromVector3(new _().fromArray(c.collider.rotation)));w.setRotationWrtParent(S),w.setActiveEvents(At.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else u.physics.rigidBody==="dynamic"||h||m||f||p||d?(this.addRigidBody(a,l,{hasFollow:m,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,u.physics.fusedBody)):(g&&t.push(ks(g,a.matrixWorld)),u.physics.fusedBody&&a.traverseObject((y,v)=>{if(v===0)return;let x;if(y instanceof Dn)if(y.objectForSample){if(y.objectForSample.dataPatched.physics.fusedBody)return;x=y.object}else return y.object.dataPatched.physics.fusedBody===!0&&y.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(y instanceof mr)x=y.object;else if(x=y,x.dataPatched.cloner?.hideBase)return!0;let w=x.dataPatched;if(w.physics.enabled==="visibility"?!w.visible:!w.physics.enabled)return!0;let S=y.geometry;S?.getAttribute("position")!==void 0&&t.push(ks(S,y.matrixWorld))}),this.generateSensorColliderDescs(l,u.physics.fusedBody,e));if(u.physics?.fusedBody===!0||c)return!0}),t.length===0)return;let r=bs(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=At.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n),o=At.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(At.CoefficientCombineRule.Multiply).setRestitutionCombineRule(At.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let u=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[u.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let r=new Im(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),n=new ie().compose(zs.fromArray(e.data.position),pf.setFromEuler(o3.fromArray(e.data.rotation)),f_);if(e.data.triggerZone==="box"){let s=new Pt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,n,t,r])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,n,t,r])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,r){if(!this.isEnabled)return!0;let n=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(n=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,n=!1):this.initializationCounter===2&&this.gameControl&&(n=!this.gameControl.update(t,e,r)&&n),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)n=this.stepPhysics()&&n;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,u=6;for(;this.accumulator>=s&&l<u&&(n=this.stepPhysics()&&n,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return n}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose($r,Vs,Tl),h_.setFromQuaternion(Vs);let r=e;r.prevR===void 0?(r.prevR=h_.clone(),r.prevT=$r.clone()):(r.prevR.copy(h_),r.prevT.copy($r)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation($r.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Vs))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,r){let n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(r))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===n){s=o;break}}t.dispatch(s),e.dispatchEvent(J0)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let n=a3.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new Im(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),u;if(a.data.triggerZone==="box"?u=At.ColliderDesc.cuboid(...a.data.size.map(c=>c/(2*this.pixelsPerMeter))):u=At.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),u.setDensity(0).setSensor(!0).setActiveEvents(At.ActiveEvents.COLLISION_EVENTS),zs.fromArray(a.data.position),pf.setFromEuler(o3.fromArray(a.data.rotation)),yx.compose(zs,pf,f_).premultiply(s.matrixWorld),r?(yx.decompose(zs,pf,d_),u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_FIXED|At.ActiveCollisionTypes.DYNAMIC_FIXED)):(yx.premultiply(n).decompose(zs,pf,d_),t.rigidBody.bodyType()===At.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===At.RigidBodyType.Fixed?u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_FIXED|At.ActiveCollisionTypes.DYNAMIC_FIXED):u.setActiveCollisionTypes(At.ActiveCollisionTypes.KINEMATIC_KINEMATIC|At.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),zs.divideScalar(this.pixelsPerMeter),u.setTranslation(zs.x,zs.y,zs.z),u.setRotation(pf),r)r.push([u,l]);else{let c=this.sharedGameControlGlobals.rapierWorld.createCollider(u,t.rigidBody);this.sensorToTriggerEvent[c.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[r,n,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(lt.is(l)?l:l.object)===!1)continue;let u=a3.copy(s.matrixWorld).decompose(zs,l3,d_).compose(zs,l3,f_).multiply(n),c=yx.copy(l.matrixWorld).invert().multiply(u);r instanceof Pt?t=l.bvhGeometry.boundsTree.intersectsBox(r,c):(p_.radius=r,p_.center.setFromMatrixPosition(c),t=l.bvhGeometry.boundsTree.intersectsSphere(p_)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(VQ)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function u3(i){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,n=this.time+i,s=this._loopCount,o=r===qf;if(i===0)return s===-1?n:o&&(s&1)===1?t-(n-e):n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(s===-1&&(i>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<e){let a=Math.floor((n-e)/(t-e));n-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(n=i>0?t:e,this.repetitions===1&&(n=t)),this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(l===1){let u=i<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return t-(n-e)}return n}var h3=!1,xx=class{constructor(t,e,r,n){this.scene=t;this.requestRender=e;this.updateDisplayProgress=r;this.animationInspectorState=n;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,r)=>{let n=e[0]+"/";if(Array.isArray(t.identity)?n+=t.identity[0]:n+=t.uuid,this.clipIdToAction[n])return;let s=wu.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);h3===!1&&(Object.getPrototypeOf(o)._updateTime=u3,h3=!0),o.clampWhenFinished=!0,this.clipIdToAction[n]=o})};this.mixer=new Pg(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let r=this.scene.find(e);if(!r)return;let n=r.animations.find(o=>o.uuid===t);if(!n)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(n),delete this.clipIdToAction[t],r.animations=r.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=Kb}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,r=this.clipIdToAction[e];if(!!r)return t&&(t.repeat>=0&&(r.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(r.loop=qf)),r.play(),r.paused=!1,this.requestRender(),r}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let r=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),r&&(this.clipIdToAction[e].paused=!0)}};var m_=new WeakMap,bx=class extends Su{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,n){let s=new Au(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.decodeDracoFile(o,e).catch(n)},r,n)}decodeDracoFile(t,e,r,n){let s={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){let r=JSON.stringify(e);if(m_.has(t)){let l=m_.get(t);if(l.key===r)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(n=l,new Promise((u,c)=>{n._callbacks[s]={resolve:u,reject:c},n.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),m_.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new Ae;t.index&&e.setIndex(new Ge(t.index.array,1));for(let r=0;r<t.attributes.length;r++){let n=t.attributes[r],s=n.name,o=n.array,a=n.itemSize;e.setAttribute(s,new Ge(o,a))}return e}_loadLibrary(t,e){let r=new Au(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((n,s)=>{r.load(t,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{let n=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let s=zQ.toString(),o=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
6492 | `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){let o=s.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function zQ(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(c){i.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,u=a.taskConfig;t.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let p=e(h,d,f,u),m=p.attributes.map(g=>g.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{h.destroy(f),h.destroy(d)}});break}};function e(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let m={index:null,attributes:[]};for(let g in c){let y=self[h[g]],v,x;if(u.useUniqueIDs)x=c[g],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[c[g]]),x===-1)continue;v=a.GetAttribute(d,x)}m.attributes.push(n(o,a,d,g,y,v))}return p===o.TRIANGULAR_MESH&&(m.index=r(o,a,d)),o.destroy(d),m}function r(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function n(o,a,l,u,c,h){let d=h.num_components(),p=l.num_points()*d,m=p*c.BYTES_PER_ELEMENT,g=s(o,c),y=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,h,g,m,y);let v=new c(o.HEAPF32.buffer,y,p).slice();return o._free(y),{name:u,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Cl;function UQ(){return Cl||(Cl=new bx,Cl.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Cl.decoderPending}async function GQ(i){if(Cl){let t={attributeIDs:Cl.defaultAttributeIDs,attributeTypes:Cl.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Cl.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function d3(i,t){let[e,r]=Pw(Ny.deserialize(new Uint8Array(i)));tv(e);let n=[];e.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&n.push(o)}),n.length&&await UQ();for(let s of n){let o=await GQ(xr(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return t&&t(e),r.result().data}var g_=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.dataEvent=r;this.object=n;this.stage=!1;this.actions=nr(r,e.actions,s,o,a,n)}disconnect(){qt(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},wx=class extends yr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(n=>{let s=Vy.deviceToSize(n.data.size),o=n.dataEvent.orientation==="horizontal"?e:r,a;switch(n.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}n.stage!==a&&(n.stage=a,n.stage?n.dispatchIn():n.dispatchOut())}),this.eventContext.updateDomRect()};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:n,height:s}=r.contentRect;this.resize(n,s)}})}connect(){let{page:e,sharedAssets:r,domElement:n}=this.eventContext;this.onResizeObserver.observe(n),e.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length))for(let{data:o}of s.data.events)o.disabled||o.type==="Resize"&&o.breakpoints.forEach(({data:a,id:l})=>{try{let u=new g_(l,a,o,s,e,r,this.eventManager);this.breakpoints.push(u)}catch(u){!1&&console.log(u)}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var f3=Object.keys(G1).filter(i=>isNaN(Number(i))),Sx=class{constructor(t,e,r,n,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=n;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=t=>{(t.touches.length>1||this.preventTouchScroll)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:n}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:n-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=n.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new tx(this.eventContext),DynamicVariable:new fx(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new ix(this.eventContext,this),["Start"]:new hx(this.eventContext,this),Basic:new rx(this.eventContext,this,this.needsRaycast),["MouseHover"]:new cx(this.eventContext,this),["Scroll"]:new ux(this.eventContext,this),["Follow"]:new ox(this.eventContext,this),["DragDrop"]:new sx(this.eventContext,this),["LookAt"]:new lx(this.eventContext),["Resize"]:new wx(this.eventContext,this)};let{page:t,domElement:e,eventElement:r}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),f3.forEach(n=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(n))||n==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(e.addEventListener(n,this.onResetRaycaster),r.addEventListener(n,this.onResetRaycaster))}),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),f3.forEach(r=>{e.removeEventListener(r,this.onResetRaycaster)}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let n of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in n&&Array.isArray(n.id)&&(n.id[0]==="mouse"&&(this.needsMouse=!0),n.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let n of r.data.events)if(!n.data.disabled)if(n.data.type==="VariableChange"&&(n.data.variableId==="mouseProperty"&&(this.needsMouse=!0),n.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),n.data.type==="Conditional")for(let s of["inActions","outActions"])n.data[s].forEach(e);else if(n.data.type==="DragDrop")for(let s of["drag","drop"])n.data.dragDropActions[s].forEach(e);else if(n.data.type==="GameControl")for(let s of["idle","move","jump","run"])n.data.gameActions[s].forEach(e);else if(n.data.type==="Resize")for(let s of n.data.breakpoints)s.data.actions.forEach(e);else n.data.type==="LookAt"||n.data.actions.forEach(e)}})}};var Ax=class{constructor(t,e,r,n,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new N().copy(r),this._editorSize=new N().copy(n),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,n=this._fov;if(t&&e>r){let s=HQ(e,1080,2160,1,15)/100;n*=e/r,n*=1-s}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function HQ(i,t,e,r,n){return(i-t)/(e-t)*(n-r)+r}var _x=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Ec(t.shared,e),this.scene=new vl(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof Si&&t.personalCamera.updateState(t.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(t=>{t instanceof Qt&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Ex=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function jQ(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Om(i){return i instanceof Ps?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function WQ(i,t){let e={};return i.traverseEntity(r=>{if(!r.visible||!(r instanceof $t)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let n=r.parent;for(;n;){if(n instanceof $t&&r.states&&Object.keys(r.states).length)return;n=n.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!Br.isMergable(o))return}else{let u=t.scene.objects.get(r.uuid)?.data;if(u&&"material"in u&&typeof u.material!="string"){if(!Br.isMergable(u.material))return;s=Br.getHash(u.material)}}e[s]||(e[s]={});let l=e[s][Om(r)];if(l){if(l.push(r),r.cloner)for(let u of r.cloner.children)l.push(u)}else if(e[s][Om(r)]=[r],r.cloner)for(let u of r.cloner.children)e[s][Om(r)].push(u)}),e}function qQ(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(r=>{let n=r.length;n>t&&(t=n)})}),t}function p3(i,t){let e=WQ(t,i),r=qQ(e),n=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),u=0,c=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,u=0,p.forEach(g=>{g instanceof $t&&(o[a++]=g.geometry.clone(),l[u++]=g)}),u<2)continue;for(let g=0;g<u;g++)l[g].updateWorldMatrix(!0,!1),o[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&jQ(o[g]);let m=bs(o.slice(0,a),!1);if(m){let g;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new _r(m,l[0].material);break}default:{g=new _r(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let y=v=>{h=0;for(let x of v)x.children&&y(x.children),x instanceof $t&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Om(x)]&&e[x.material.uuid][Om(x)].length>1||(c[h++]=x));for(let x=0;x<h;x++)t.attach(c[x])};for(let v=0;v<u;v++){let x=l[v];y(x.children),n[s++]=x}}}for(let d=0;d<s;d++)n[d].removeFromParent()}var v3=pn(g3(),1);var XQ=new N;function QQ(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var y3=class{constructor(t,{renderOnDemand:e,renderMode:r="auto"}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._variablesCache=new Map;this._isPaused=!1;this._renderRequested=!1;this._skipRender=!1;this.time=performance.now();this.dt=0;this.currentTAAFrame=0;this.disposed=!1;this._requestRenderAutoMode=()=>{this._skipRender=!1};this.requestRender=()=>{this._renderRequested=!0};this.render=t=>{if(this.time=t,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()};this._resize=()=>{if(!!this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=XQ.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}};this._debouncedResize=tc(this._resize,10);this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Ex({x:10,y:10})),tP(t)}async load(t,e,r){QQ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let n=await d3(t);this._data=n,n.version&&(0,v3.default)(n.version,"0.9.499")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([KA(n)&&KD(),FI(n)&&HD(),$a.physicsEnabled(n.scene.objects)&&lP(),GA(n)&&II(),a_(n)&&sP()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new _x(n);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();p3(n,s.scene);let u=performance.now();console.log("Merged geometries in ",u-l," ms")}KA(n)&&this._scene.traverse(l=>{Xn(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Dn&&l.pendingMediaLoad&&l.update()})});let o=Object.keys(n.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);Promise.all(o).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),GA(n)&&c3(n)&&await Promise.all(o),this._scene.rewriteEventsBeforeGoToPlayMode(),rf(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new A0({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let a=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(a.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=a.size[0],this._viewportHeight=a.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Ax(this._renderer,this._camera,new N(this._viewportWidth,this._viewportHeight),new N(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(a.allowResponsive??!1)&&a.preset==="fullscreen"),e){let l=new ex(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,a);this._scene.updateMatrixWorld(!0),this._controls=new vx(l),this._animationControls=new xx(this._scene,this._requestRenderAutoMode),this._eventManager=new Sx(n.scene.publish,this._controls,this._animationControls,l,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}setVariables(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,n]of e)this.setVariable(r,n)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let n=e;typeof r.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(n=e.toString());let s=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&En.isTextValue(t)?En.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==Xi&&!this._scene.isInvisibleObjects(e)&&!(e instanceof Si)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof ff&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:n,a:s}={r:0,g:0,b:0,a:1},o=new gr(e,r,n,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{pw.unsubscribe(t)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),rP(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof Si&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof Si||t instanceof vl?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},n=pw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}};export{y3 as Application};
|
6493 |
|
\ | No newline at end of file |