From 300f7fd3110e6c76ac71ead845d97cea3e2deae8 Mon Sep 17 00:00:00 2001 From: benben-miao Date: Tue, 17 Oct 2023 15:55:42 +0800 Subject: [PATCH] Add dynamic background --- .vscode/settings.json | 8 + README.md | 2 + assets/@splinetool-99227827.js | 6343 ++++++++++++++++++++++++++++++ assets/AboutView-06976582.css | 1 + assets/AboutView-2fe9222f.js | 1 + assets/DesignView-0cf80983.js | 1 + assets/DesignView-9614fae7.css | 1 + assets/DownloadView-9b544416.css | 1 + assets/DownloadView-ecc01907.js | 1 + assets/FriendsView-0d93fd03.js | 1 + assets/FriendsView-cd50d063.css | 1 + assets/PublishView-6b0529cb.js | 1 + assets/PublishView-d228bf6d.css | 1 + assets/index-82b12b31.css | 1 + assets/index-d094e413.js | 1 + index.html | 5 +- 16 files changed, 6368 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 assets/@splinetool-99227827.js create mode 100644 assets/AboutView-06976582.css create mode 100644 assets/AboutView-2fe9222f.js create mode 100644 assets/DesignView-0cf80983.js create mode 100644 assets/DesignView-9614fae7.css create mode 100644 assets/DownloadView-9b544416.css create mode 100644 assets/DownloadView-ecc01907.js create mode 100644 assets/FriendsView-0d93fd03.js create mode 100644 assets/FriendsView-cd50d063.css create mode 100644 assets/PublishView-6b0529cb.js create mode 100644 assets/PublishView-d228bf6d.css create mode 100644 assets/index-82b12b31.css create mode 100644 assets/index-d094e413.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c66500e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "python.analysis.extraPaths": [ + "c:\\Users\\benben.miao\\.vscode\\extensions\\continue.continue-0.0.412-win32-x64" + ], + "python.autoComplete.extraPaths": [ + "c:\\Users\\benben.miao\\.vscode\\extensions\\continue.continue-0.0.412-win32-x64" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index ce34673..9681c5c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ **OmicsSuite Website: _https://omicssuite.github.io_** +**OmicsSuite Website (faster): _https://omicssuite.onrender.com_** + **OmicsSuite Courses: _https://space.bilibili.com/34105515_** **OmicsSuite Download1 (GithubRelease): _https://github.com/OmicsSuite/OmicsSuite.github.io/releases/download/v1.3.9/OmicsSuite-v1.3.9.exe_** diff --git a/assets/@splinetool-99227827.js b/assets/@splinetool-99227827.js new file mode 100644 index 0000000..f50797c --- /dev/null +++ b/assets/@splinetool-99227827.js @@ -0,0 +1,6343 @@ +const Qq="modulepreload",Eq=function(g){return"/"+g},ef={},Zn=function(A,I,e){if(!I||I.length===0)return A();const i=document.getElementsByTagName("link");return Promise.all(I.map(t=>{if(t=Eq(t),t in ef)return;ef[t]=!0;const C=t.endsWith(".css"),o=C?'[rel="stylesheet"]':"";if(!!e)for(let s=i.length-1;s>=0;s--){const r=i[s];if(r.href===t&&(!C||r.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${t}"]${o}`))return;const a=document.createElement("link");if(a.rel=C?"stylesheet":Qq,C||(a.as="script",a.crossOrigin=""),a.href=t,document.head.appendChild(a),C)return new Promise((s,r)=>{a.addEventListener("load",s),a.addEventListener("error",()=>r(new Error(`Unable to preload CSS for ${t}`)))})})).then(()=>A()).catch(t=>{const C=new Event("vite:preloadError",{cancelable:!0});if(C.payload=t,window.dispatchEvent(C),!C.defaultPrevented)throw t})};var nq=Object.create,Kw=Object.defineProperty,hq=Object.getOwnPropertyDescriptor,lq=Object.getOwnPropertyNames,cq=Object.getPrototypeOf,Dq=Object.prototype.hasOwnProperty,Na=(g,A)=>()=>(A||g((A={exports:{}}).exports,A),A.exports),dq=(g,A)=>{for(var I in A)Kw(g,I,{get:A[I],enumerable:!0})},uq=(g,A,I,e)=>{if(A&&typeof A=="object"||typeof A=="function")for(let i of lq(A))!Dq.call(g,i)&&i!==I&&Kw(g,i,{get:()=>A[i],enumerable:!(e=hq(A,i))||e.enumerable});return g},Fa=(g,A,I)=>(I=g!=null?nq(cq(g)):{},uq(A||!g||!g.__esModule?Kw(I,"default",{value:g,enumerable:!0}):I,g)),pq=Na((g,A)=>{(function(I,e){typeof g=="object"?A.exports=e():typeof define=="function"&&define.amd?define(e):I.Alea=e()})(g,function(){return I.importState=function(i){var t=new I;return t.importState(i),t},I;function I(){return function(i){var t=0,C=0,o=0,B=1;i.length==0&&(i=[+new Date]);var a=e();t=a(" "),C=a(" "),o=a(" ");for(var s=0;s>>0,B-=i,B*=i,i=B>>>0,B-=i,i+=B*4294967296}return(i>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})}),pN=Na((g,A)=>{(function(I,e){typeof g=="object"&&typeof A<"u"?e(g):typeof define=="function"&&define.amd?define(["exports"],e):e((I=typeof globalThis<"u"?globalThis:I||self).SVDJS={})})(g,function(I){I.SVD=function(e,i,t,C,o){if(i=i===void 0||i,t=t===void 0||t,o=1e-64/(C=C||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var B,a,s,r,Q,E,n,h,l,c,d,u,y=e[0].length,f=e.length;if(f{(function(I,e){typeof g=="object"&&typeof A<"u"?A.exports=e():typeof define=="function"&&define.amd?define(e):(I=I||self,I.TinyQueue=e())})(g,function(){var I=function(i,t){if(i===void 0&&(i=[]),t===void 0&&(t=e),this.data=i,this.length=this.data.length,this.compare=t,this.length>0)for(var C=(this.length>>1)-1;C>=0;C--)this._down(C)};I.prototype.push=function(i){this.data.push(i),this.length++,this._up(this.length-1)},I.prototype.pop=function(){if(this.length!==0){var i=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),i}},I.prototype.peek=function(){return this.data[0]},I.prototype._up=function(i){for(var t=this,C=t.data,o=t.compare,B=C[i];i>0;){var a=i-1>>1,s=C[a];if(o(B,s)>=0)break;C[i]=s,i=a}C[i]=B},I.prototype._down=function(i){for(var t=this,C=t.data,o=t.compare,B=this.length>>1,a=C[i];i=0)break;C[i]=r,i=s}C[i]=a};function e(i,t){return it?1:0}return I})}),wq=Na((g,A)=>{var I=yq();I.default&&(I=I.default),A.exports=e,A.exports.default=e;function e(a,s,r){s=s||1;for(var Q,E,n,h,l=0;ln)&&(n=c[0]),(!l||c[1]>h)&&(h=c[1])}var d=n-Q,u=h-E,y=Math.min(d,u),f=y/2;if(y===0){var k=[Q,E];return k.distance=0,k}for(var M=new I(void 0,i),G=Q;GN.d&&(N=b);for(var O=M.length;M.length;){var H=M.pop();H.d>N.d&&(N=H,r&&console.log("found best %d after %d probes",Math.round(1e4*H.d)/1e4,O)),!(H.max-N.d<=s)&&(f=H.h/2,M.push(new t(H.x-f,H.y-f,f,a)),M.push(new t(H.x+f,H.y-f,f,a)),M.push(new t(H.x-f,H.y+f,f,a)),M.push(new t(H.x+f,H.y+f,f,a)),O+=4)}r&&(console.log("num probes: "+O),console.log("best distance: "+N.d));var _=[N.x,N.y];return _.distance=N.d,_}function i(a,s){return s.max-a.max}function t(a,s,r,Q){this.x=a,this.y=s,this.h=r,this.d=C(a,s,Q),this.max=this.d+this.h*Math.SQRT2}function C(a,s,r){for(var Q=!1,E=1/0,n=0;ns!=y[1]>s&&a<(y[0]-u[0])*(s-u[1])/(y[1]-u[1])+u[0]&&(Q=!Q),E=Math.min(E,B(a,s,u,y))}return E===0?0:(Q?1:-1)*Math.sqrt(E)}function o(a){for(var s=0,r=0,Q=0,E=a[0],n=0,h=E.length,l=h-1;n1?(E=Q[0],n=Q[1]):c>0&&(E+=h*c,n+=l*c)}return h=a-E,l=s-n,h*h+l*l}}),Sq=Na((g,A)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.default=I;function I(e){if(e===null||e===!0||e===!1)return NaN;var i=Number(e);return isNaN(i)?i:i<0?Math.ceil(i):Math.floor(i)}A.exports=g.default}),fq=Na((g,A)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.default=I;function I(e){var i=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return i.setUTCFullYear(e.getFullYear()),e.getTime()-i.getTime()}A.exports=g.default}),Gq=Na(g=>{(function(){var A=function(){this.init()};A.prototype={init:function(){var r=this||I;return r._counter=1e3,r._html5AudioPool=[],r.html5PoolSize=10,r._codecs={},r._howls=[],r._muted=!1,r._volume=1,r._canPlayEvent="canplaythrough",r._navigator=typeof window<"u"&&window.navigator?window.navigator:null,r.masterGain=null,r.noAudio=!1,r.usingWebAudio=!0,r.autoSuspend=!0,r.ctx=null,r.autoUnlock=!0,r._setup(),r},volume:function(r){var Q=this||I;if(r=parseFloat(r),Q.ctx||s(),typeof r<"u"&&r>=0&&r<=1){if(Q._volume=r,Q._muted)return Q;Q.usingWebAudio&&Q.masterGain.gain.setValueAtTime(r,I.ctx.currentTime);for(var E=0;E=0;Q--)r._howls[Q].unload();return r.usingWebAudio&&r.ctx&&typeof r.ctx.close<"u"&&(r.ctx.close(),r.ctx=null,s()),r},codecs:function(r){return(this||I)._codecs[r.replace(/^x-/,"")]},_setup:function(){var r=this||I;if(r.state=r.ctx&&r.ctx.state||"suspended",r._autoSuspend(),!r.usingWebAudio)if(typeof Audio<"u")try{var Q=new Audio;typeof Q.oncanplaythrough>"u"&&(r._canPlayEvent="canplay")}catch{r.noAudio=!0}else r.noAudio=!0;try{var Q=new Audio;Q.muted&&(r.noAudio=!0)}catch{}return r.noAudio||r._setupCodecs(),r},_setupCodecs:function(){var r=this||I,Q=null;try{Q=typeof Audio<"u"?new Audio:null}catch{return r}if(!Q||typeof Q.canPlayType!="function")return r;var E=Q.canPlayType("audio/mpeg;").replace(/^no$/,""),n=r._navigator?r._navigator.userAgent:"",h=n.match(/OPR\/([0-6].)/g),l=h&&parseInt(h[0].split("/")[1],10)<33,c=n.indexOf("Safari")!==-1&&n.indexOf("Chrome")===-1,d=n.match(/Version\/(.*?) /),u=c&&d&&parseInt(d[1],10)<15;return r._codecs={mp3:!!(!l&&(E||Q.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!E,opus:!!Q.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!Q.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!Q.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(Q.canPlayType('audio/wav; codecs="1"')||Q.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!Q.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!Q.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(Q.canPlayType("audio/x-m4a;")||Q.canPlayType("audio/m4a;")||Q.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(Q.canPlayType("audio/x-m4b;")||Q.canPlayType("audio/m4b;")||Q.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(Q.canPlayType("audio/x-mp4;")||Q.canPlayType("audio/mp4;")||Q.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!u&&Q.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!u&&Q.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!Q.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(Q.canPlayType("audio/x-flac;")||Q.canPlayType("audio/flac;")).replace(/^no$/,"")},r},_unlockAudio:function(){var r=this||I;if(!(r._audioUnlocked||!r.ctx)){r._audioUnlocked=!1,r.autoUnlock=!1,!r._mobileUnloaded&&r.ctx.sampleRate!==44100&&(r._mobileUnloaded=!0,r.unload()),r._scratchBuffer=r.ctx.createBuffer(1,1,22050);var Q=function(E){for(;r._html5AudioPool.length"u"?u.noteOn(0):u.start(0),typeof r.ctx.resume=="function"&&r.ctx.resume(),u.onended=function(){u.disconnect(0),r._audioUnlocked=!0,document.removeEventListener("touchstart",Q,!0),document.removeEventListener("touchend",Q,!0),document.removeEventListener("click",Q,!0),document.removeEventListener("keydown",Q,!0);for(var y=0;y"u"||!I.usingWebAudio)){for(var Q=0;Q"u"||!I.usingWebAudio))return r.state==="running"&&r.ctx.state!=="interrupted"&&r._suspendTimer?(clearTimeout(r._suspendTimer),r._suspendTimer=null):r.state==="suspended"||r.state==="running"&&r.ctx.state==="interrupted"?(r.ctx.resume().then(function(){r.state="running";for(var Q=0;Q"u"&&(r="__default",!E._playLock)){for(var h=0,l=0;l0?c._seek:E._sprite[r][0]/1e3),y=Math.max(0,(E._sprite[r][0]+E._sprite[r][1])/1e3-u),f=y*1e3/Math.abs(c._rate),k=E._sprite[r][0]/1e3,M=(E._sprite[r][0]+E._sprite[r][1])/1e3;c._sprite=r,c._ended=!1;var G=function(){c._paused=!1,c._seek=u,c._start=k,c._stop=M,c._loop=!!(c._loop||E._sprite[r][2])};if(u>=M){E._ended(c);return}var v=c._node;if(E._webAudio){var N=function(){E._playLock=!1,G(),E._refreshBuffer(c);var _=c._muted||E._muted?0:c._volume;v.gain.setValueAtTime(_,I.ctx.currentTime),c._playStart=I.ctx.currentTime,typeof v.bufferSource.start>"u"?c._loop?v.bufferSource.noteGrainOn(0,u,86400):v.bufferSource.noteGrainOn(0,u,y):c._loop?v.bufferSource.start(0,u,86400):v.bufferSource.start(0,u,y),f!==1/0&&(E._endTimers[c._id]=setTimeout(E._ended.bind(E,c),f)),Q||setTimeout(function(){E._emit("play",c._id),E._loadQueue()},0)};I.state==="running"&&I.ctx.state!=="interrupted"?N():(E._playLock=!0,E.once("resume",N),E._clearTimer(c._id))}else{var b=function(){v.currentTime=u,v.muted=c._muted||E._muted||I._muted||v.muted,v.volume=c._volume*I.volume(),v.playbackRate=c._rate;try{var _=v.play();if(_&&typeof Promise<"u"&&(_ instanceof Promise||typeof _.then=="function")?(E._playLock=!0,G(),_.then(function(){E._playLock=!1,v._unlocked=!0,Q?E._loadQueue():E._emit("play",c._id)}).catch(function(){E._playLock=!1,E._emit("playerror",c._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."),c._ended=!0,c._paused=!0})):Q||(E._playLock=!1,G(),E._emit("play",c._id)),v.playbackRate=c._rate,v.paused){E._emit("playerror",c._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}r!=="__default"||c._loop?E._endTimers[c._id]=setTimeout(E._ended.bind(E,c),f):(E._endTimers[c._id]=function(){E._ended(c),v.removeEventListener("ended",E._endTimers[c._id],!1)},v.addEventListener("ended",E._endTimers[c._id],!1))}catch(gA){E._emit("playerror",c._id,gA)}};v.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(v.src=E._src,v.load());var O=window&&window.ejecta||!v.readyState&&I._navigator.isCocoonJS;if(v.readyState>=3||O)b();else{E._playLock=!0,E._state="loading";var H=function(){E._state="loaded",b(),v.removeEventListener(I._canPlayEvent,H,!1)};v.addEventListener(I._canPlayEvent,H,!1),E._clearTimer(c._id)}}return c._id},pause:function(r){var Q=this;if(Q._state!=="loaded"||Q._playLock)return Q._queue.push({event:"pause",action:function(){Q.pause(r)}}),Q;for(var E=Q._getSoundIds(r),n=0;n"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),Q._cleanBuffer(h._node)}else(!isNaN(h._node.duration)||h._node.duration===1/0)&&h._node.pause();arguments[1]||Q._emit("pause",h?h._id:null)}return Q},stop:function(r,Q){var E=this;if(E._state!=="loaded"||E._playLock)return E._queue.push({event:"stop",action:function(){E.stop(r)}}),E;for(var n=E._getSoundIds(r),h=0;h"u"?l._node.bufferSource.noteOff(0):l._node.bufferSource.stop(0),E._cleanBuffer(l._node)):(!isNaN(l._node.duration)||l._node.duration===1/0)&&(l._node.currentTime=l._start||0,l._node.pause(),l._node.duration===1/0&&E._clearSound(l._node))),Q||E._emit("stop",l._id))}return E},mute:function(r,Q){var E=this;if(E._state!=="loaded"||E._playLock)return E._queue.push({event:"mute",action:function(){E.mute(r,Q)}}),E;if(typeof Q>"u")if(typeof r=="boolean")E._muted=r;else return E._muted;for(var n=E._getSoundIds(Q),h=0;h"u"){var h=r._getSoundIds(),l=h.indexOf(Q[0]);l>=0?n=parseInt(Q[0],10):E=parseFloat(Q[0])}else Q.length>=2&&(E=parseFloat(Q[0]),n=parseInt(Q[1],10));var c;if(typeof E<"u"&&E>=0&&E<=1){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,Q)}}),r;typeof n>"u"&&(r._volume=E),n=r._getSoundIds(n);for(var d=0;d"u")}}return h},_startFadeInterval:function(r,Q,E,n,h,l){var c=this,d=Q,u=E-Q,y=Math.abs(u/.01),f=Math.max(4,y>0?n/y:n),k=Date.now();r._fadeTo=E,r._interval=setInterval(function(){var M=(Date.now()-k)/n;k=Date.now(),d+=u*M,d=Math.round(d*100)/100,u<0?d=Math.max(E,d):d=Math.min(E,d),c._webAudio?r._volume=d:c.volume(d,r._id,!0),l&&(c._volume=d),(EQ&&d>=E)&&(clearInterval(r._interval),r._interval=null,r._fadeTo=null,c.volume(E,r._id),c._emit("fade",r._id))},f)},_stopFade:function(r){var Q=this,E=Q._soundById(r);return E&&E._interval&&(Q._webAudio&&E._node.gain.cancelScheduledValues(I.ctx.currentTime),clearInterval(E._interval),E._interval=null,Q.volume(E._fadeTo,r),E._fadeTo=null,Q._emit("fade",r)),Q},loop:function(){var r=this,Q=arguments,E,n,h;if(Q.length===0)return r._loop;if(Q.length===1)if(typeof Q[0]=="boolean")E=Q[0],r._loop=E;else return h=r._soundById(parseInt(Q[0],10)),h?h._loop:!1;else Q.length===2&&(E=Q[0],n=parseInt(Q[1],10));for(var l=r._getSoundIds(n),c=0;c=0?n=parseInt(Q[0],10):E=parseFloat(Q[0])}else Q.length===2&&(E=parseFloat(Q[0]),n=parseInt(Q[1],10));var c;if(typeof E=="number"){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,Q)}}),r;typeof n>"u"&&(r._rate=E),n=r._getSoundIds(n);for(var d=0;d=0?n=parseInt(Q[0],10):r._sounds.length&&(n=r._sounds[0]._id,E=parseFloat(Q[0]))}else Q.length===2&&(E=parseFloat(Q[0]),n=parseInt(Q[1],10));if(typeof n>"u")return 0;if(typeof E=="number"&&(r._state!=="loaded"||r._playLock))return r._queue.push({event:"seek",action:function(){r.seek.apply(r,Q)}}),r;var c=r._soundById(n);if(c)if(typeof E=="number"&&E>=0){var d=r.playing(n);d&&r.pause(n,!0),c._seek=E,c._ended=!1,r._clearTimer(n),!r._webAudio&&c._node&&!isNaN(c._node.duration)&&(c._node.currentTime=E);var u=function(){d&&r.play(n,!0),r._emit("seek",n)};if(d&&!r._webAudio){var y=function(){r._playLock?setTimeout(y,0):u()};setTimeout(y,0)}else u()}else if(r._webAudio){var f=r.playing(n)?I.ctx.currentTime-c._playStart:0,k=c._rateSeek?c._rateSeek-c._seek:0;return c._seek+(k+f*Math.abs(c._rate))}else return c._node.currentTime;return r},playing:function(r){var Q=this;if(typeof r=="number"){var E=Q._soundById(r);return E?!E._paused:!1}for(var n=0;n=0&&I._howls.splice(n,1);var h=!0;for(E=0;E=0){h=!1;break}return t&&h&&delete t[r._src],I.noAudio=!1,r._state="unloaded",r._sounds=[],r=null,null},on:function(r,Q,E,n){var h=this,l=h["_on"+r];return typeof Q=="function"&&l.push(n?{id:E,fn:Q,once:n}:{id:E,fn:Q}),h},off:function(r,Q,E){var n=this,h=n["_on"+r],l=0;if(typeof Q=="number"&&(E=Q,Q=null),Q||E)for(l=0;l=0;l--)(!h[l].id||h[l].id===Q||r==="load")&&(setTimeout((function(c){c.call(this,Q,E)}).bind(n,h[l].fn),0),h[l].once&&n.off(r,h[l].fn,h[l].id));return n._loadQueue(r),n},_loadQueue:function(r){var Q=this;if(Q._queue.length>0){var E=Q._queue[0];E.event===r&&(Q._queue.shift(),Q._loadQueue()),r||E.action()}return Q},_ended:function(r){var Q=this,E=r._sprite;if(!Q._webAudio&&r._node&&!r._node.paused&&!r._node.ended&&r._node.currentTime=0;n--){if(E<=Q)return;r._sounds[n]._ended&&(r._webAudio&&r._sounds[n]._node&&r._sounds[n]._node.disconnect(0),r._sounds.splice(n,1),E--)}}},_getSoundIds:function(r){var Q=this;if(typeof r>"u"){for(var E=[],n=0;n=0;if(I._scratchBuffer&&r.bufferSource&&(r.bufferSource.onended=null,r.bufferSource.disconnect(0),E))try{r.bufferSource.buffer=I._scratchBuffer}catch{}return r.bufferSource=null,Q},_clearSound:function(r){var Q=/MSIE |Trident\//.test(I._navigator&&I._navigator.userAgent);Q||(r.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var i=function(r){this._parent=r,this.init()};i.prototype={init:function(){var r=this,Q=r._parent;return r._muted=Q._muted,r._loop=Q._loop,r._volume=Q._volume,r._rate=Q._rate,r._seek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++I._counter,Q._sounds.push(r),r.create(),r},create:function(){var r=this,Q=r._parent,E=I._muted||r._muted||r._parent._muted?0:r._volume;return Q._webAudio?(r._node=typeof I.ctx.createGain>"u"?I.ctx.createGainNode():I.ctx.createGain(),r._node.gain.setValueAtTime(E,I.ctx.currentTime),r._node.paused=!0,r._node.connect(I.masterGain)):I.noAudio||(r._node=I._obtainHtml5Audio(),r._errorFn=r._errorListener.bind(r),r._node.addEventListener("error",r._errorFn,!1),r._loadFn=r._loadListener.bind(r),r._node.addEventListener(I._canPlayEvent,r._loadFn,!1),r._endFn=r._endListener.bind(r),r._node.addEventListener("ended",r._endFn,!1),r._node.src=Q._src,r._node.preload=Q._preload===!0?"auto":Q._preload,r._node.volume=E*I.volume(),r._node.load()),r},reset:function(){var r=this,Q=r._parent;return r._muted=Q._muted,r._loop=Q._loop,r._volume=Q._volume,r._rate=Q._rate,r._seek=0,r._rateSeek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++I._counter,r},_errorListener:function(){var r=this;r._parent._emit("loaderror",r._id,r._node.error?r._node.error.code:0),r._node.removeEventListener("error",r._errorFn,!1)},_loadListener:function(){var r=this,Q=r._parent;Q._duration=Math.ceil(r._node.duration*10)/10,Object.keys(Q._sprite).length===0&&(Q._sprite={__default:[0,Q._duration*1e3]}),Q._state!=="loaded"&&(Q._state="loaded",Q._emit("load"),Q._loadQueue()),r._node.removeEventListener(I._canPlayEvent,r._loadFn,!1)},_endListener:function(){var r=this,Q=r._parent;Q._duration===1/0&&(Q._duration=Math.ceil(r._node.duration*10)/10,Q._sprite.__default[1]===1/0&&(Q._sprite.__default[1]=Q._duration*1e3),Q._ended(r)),r._node.removeEventListener("ended",r._endFn,!1)}};var t={},C=function(r){var Q=r._src;if(t[Q]){r._duration=t[Q].duration,a(r);return}if(/^data:[^;]+;base64,/.test(Q)){for(var E=atob(Q.split(",")[1]),n=new Uint8Array(E.length),h=0;h0?(t[Q._src]=h,a(Q,h)):E()};typeof Promise<"u"&&I.ctx.decodeAudioData.length===1?I.ctx.decodeAudioData(r).then(n).catch(E):I.ctx.decodeAudioData(r,n,E)},a=function(r,Q){Q&&!r._duration&&(r._duration=Q.duration),Object.keys(r._sprite).length===0&&(r._sprite={__default:[0,r._duration*1e3]}),r._state!=="loaded"&&(r._state="loaded",r._emit("load"),r._loadQueue())},s=function(){if(I.usingWebAudio){try{typeof AudioContext<"u"?I.ctx=new AudioContext:typeof webkitAudioContext<"u"?I.ctx=new webkitAudioContext:I.usingWebAudio=!1}catch{I.usingWebAudio=!1}I.ctx||(I.usingWebAudio=!1);var r=/iP(hone|od|ad)/.test(I._navigator&&I._navigator.platform),Q=I._navigator&&I._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),E=Q?parseInt(Q[1],10):null;if(r&&E&&E<9){var n=/safari/.test(I._navigator&&I._navigator.userAgent.toLowerCase());I._navigator&&!n&&(I.usingWebAudio=!1)}I.usingWebAudio&&(I.masterGain=typeof I.ctx.createGain>"u"?I.ctx.createGainNode():I.ctx.createGain(),I.masterGain.gain.setValueAtTime(I._muted?0:I._volume,I.ctx.currentTime),I.masterGain.connect(I.ctx.destination)),I._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:I,Howl:e}}),typeof g<"u"&&(g.Howler=I,g.Howl=e),typeof global<"u"?(global.HowlerGlobal=A,global.Howler=I,global.Howl=e,global.Sound=i):typeof window<"u"&&(window.HowlerGlobal=A,window.Howler=I,window.Howl=e,window.Sound=i)})(),function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(I){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var i=e._howls.length-1;i>=0;i--)e._howls[i].stereo(I);return e},HowlerGlobal.prototype.pos=function(I,e,i){var t=this;if(!t.ctx||!t.ctx.listener)return t;if(e=typeof e!="number"?t._pos[1]:e,i=typeof i!="number"?t._pos[2]:i,typeof I=="number")t._pos=[I,e,i],typeof t.ctx.listener.positionX<"u"?(t.ctx.listener.positionX.setTargetAtTime(t._pos[0],Howler.ctx.currentTime,.1),t.ctx.listener.positionY.setTargetAtTime(t._pos[1],Howler.ctx.currentTime,.1),t.ctx.listener.positionZ.setTargetAtTime(t._pos[2],Howler.ctx.currentTime,.1)):t.ctx.listener.setPosition(t._pos[0],t._pos[1],t._pos[2]);else return t._pos;return t},HowlerGlobal.prototype.orientation=function(I,e,i,t,C,o){var B=this;if(!B.ctx||!B.ctx.listener)return B;var a=B._orientation;if(e=typeof e!="number"?a[1]:e,i=typeof i!="number"?a[2]:i,t=typeof t!="number"?a[3]:t,C=typeof C!="number"?a[4]:C,o=typeof o!="number"?a[5]:o,typeof I=="number")B._orientation=[I,e,i,t,C,o],typeof B.ctx.listener.forwardX<"u"?(B.ctx.listener.forwardX.setTargetAtTime(I,Howler.ctx.currentTime,.1),B.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),B.ctx.listener.forwardZ.setTargetAtTime(i,Howler.ctx.currentTime,.1),B.ctx.listener.upX.setTargetAtTime(t,Howler.ctx.currentTime,.1),B.ctx.listener.upY.setTargetAtTime(C,Howler.ctx.currentTime,.1),B.ctx.listener.upZ.setTargetAtTime(o,Howler.ctx.currentTime,.1)):B.ctx.listener.setOrientation(I,e,i,t,C,o);else return a;return B},Howl.prototype.init=function(I){return function(e){var i=this;return i._orientation=e.orientation||[1,0,0],i._stereo=e.stereo||null,i._pos=e.pos||null,i._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},i._onstereo=e.onstereo?[{fn:e.onstereo}]:[],i._onpos=e.onpos?[{fn:e.onpos}]:[],i._onorientation=e.onorientation?[{fn:e.onorientation}]:[],I.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(I,e){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"stereo",action:function(){i.stereo(I,e)}}),i;var t=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof I=="number")i._stereo=I,i._pos=[I,0,0];else return i._stereo;for(var C=i._getSoundIds(e),o=0;o"u")if(typeof I=="number")C._pos=[I,e,i];else return C._pos;for(var o=C._getSoundIds(t),B=0;B"u")if(typeof I=="number")C._orientation=[I,e,i];else return C._orientation;for(var o=C._getSoundIds(t),B=0;B"u"&&(i.pannerAttr||(i.pannerAttr={coneInnerAngle:i.coneInnerAngle,coneOuterAngle:i.coneOuterAngle,coneOuterGain:i.coneOuterGain,distanceModel:i.distanceModel,maxDistance:i.maxDistance,refDistance:i.refDistance,rolloffFactor:i.rolloffFactor,panningModel:i.panningModel}),I._pannerAttr={coneInnerAngle:typeof i.pannerAttr.coneInnerAngle<"u"?i.pannerAttr.coneInnerAngle:I._coneInnerAngle,coneOuterAngle:typeof i.pannerAttr.coneOuterAngle<"u"?i.pannerAttr.coneOuterAngle:I._coneOuterAngle,coneOuterGain:typeof i.pannerAttr.coneOuterGain<"u"?i.pannerAttr.coneOuterGain:I._coneOuterGain,distanceModel:typeof i.pannerAttr.distanceModel<"u"?i.pannerAttr.distanceModel:I._distanceModel,maxDistance:typeof i.pannerAttr.maxDistance<"u"?i.pannerAttr.maxDistance:I._maxDistance,refDistance:typeof i.pannerAttr.refDistance<"u"?i.pannerAttr.refDistance:I._refDistance,rolloffFactor:typeof i.pannerAttr.rolloffFactor<"u"?i.pannerAttr.rolloffFactor:I._rolloffFactor,panningModel:typeof i.pannerAttr.panningModel<"u"?i.pannerAttr.panningModel:I._panningModel});else return C=I._soundById(parseInt(e[0],10)),C?C._pannerAttr:I._pannerAttr;else e.length===2&&(i=e[0],t=parseInt(e[1],10));for(var o=I._getSoundIds(t),B=0;B{A.exports=function(I,e){for(var i=I.split("."),t=e.split("."),C=0;C<3;C++){var o=Number(i[C]),B=Number(t[C]);if(o>B)return 1;if(B>o)return-1;if(!isNaN(o)&&isNaN(B))return 1;if(isNaN(o)&&!isNaN(B))return-1}return 0}}),PQ="149",xt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Mq=0,tf=1,mq=2,Jw=1,Uq=2,WE=3,RC=0,ni=1,Ft=2,je=0,oQ=1,Cf=2,of=3,Bf=4,Nq=5,Ps=100,Fq=101,Rq=102,af=103,rf=104,Kq=200,Jq=201,vq=202,qq=203,yN=204,wN=205,Lq=206,bq=207,Yq=208,xq=209,Hq=210,Tq=0,Oq=1,_q=2,qp=3,Pq=4,jq=5,Wq=6,Zq=7,SN=0,Vq=1,zq=2,DB=0,Xq=1,$q=2,AL=3,gL=4,IL=5,fN=300,Ur=301,Nr=302,Lp=303,bp=304,Vn=306,hB=1e3,Ke=1001,Yp=1002,ie=1003,sf=1004,md=1005,cI=1006,eL=1007,SQ=1008,vi=1009,iL=1010,tL=1011,GN=1012,CL=1013,oa=1014,Rt=1015,fQ=1016,oL=1017,BL=1018,wr=1020,aL=1021,$t=1023,rL=1024,sL=1025,Sr=1026,Fr=1027,QL=1028,EL=1029,kN=1030,nL=1031,hL=1033,Ud=33776,Nd=33777,Fd=33778,Rd=33779,Qf=35840,Ef=35841,nf=35842,hf=35843,lL=36196,lf=37492,cf=37496,Df=37808,df=37809,uf=37810,pf=37811,yf=37812,wf=37813,Sf=37814,ff=37815,Gf=37816,kf=37817,Mf=37818,mf=37819,Uf=37820,Nf=37821,Kd=36492,cL=36283,Ff=36284,Rf=36285,Kf=36286,MN=2200,mN=2201,vw=2202,Ec=2300,nc=2301,Jd=2302,Xs=2400,$s=2401,hc=2402,qw=2500,DL=2501,fo=3e3,sI=3001,UB=3200,UN=3201,dL=0,uL=1,ao="srgb",lc="srgb-linear",vd=7680,pL=519,xp=35044,Jf="300 es",Hp=1035,Si=class{addEventListener(A,I){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[A]===void 0&&(e[A]=[]),e[A].indexOf(I)===-1&&e[A].push(I)}hasEventListener(A,I){if(this._listeners===void 0)return!1;let e=this._listeners;return e[A]!==void 0&&e[A].indexOf(I)!==-1}removeEventListener(A,I){if(this._listeners===void 0)return;let e=this._listeners[A];if(e!==void 0){let i=e.indexOf(I);i!==-1&&e.splice(i,1)}}dispatchEvent(A){if(this._listeners===void 0)return;let I=this._listeners[A.type];if(I!==void 0){A.target=this;let e=I.slice(0);for(let i=0,t=e.length;i>8&255]+mi[g>>16&255]+mi[g>>24&255]+"-"+mi[A&255]+mi[A>>8&255]+"-"+mi[A>>16&15|64]+mi[A>>24&255]+"-"+mi[I&63|128]+mi[I>>8&255]+"-"+mi[I>>16&255]+mi[I>>24&255]+mi[e&255]+mi[e>>8&255]+mi[e>>16&255]+mi[e>>24&255]).toLowerCase()}function ii(g,A,I){return Math.max(A,Math.min(I,g))}function Lw(g,A){return(g%A+A)%A}function yL(g,A,I,e,i){return e+(g-A)*(i-e)/(I-A)}function wL(g,A,I){return g!==A?(I-g)/(A-g):0}function tn(g,A,I){return(1-I)*g+I*A}function SL(g,A,I,e){return tn(g,A,1-Math.exp(-I*e))}function fL(g,A=1){return A-Math.abs(Lw(g,A*2)-A)}function GL(g,A,I){return g<=A?0:g>=I?1:(g=(g-A)/(I-A),g*g*(3-2*g))}function kL(g,A,I){return g<=A?0:g>=I?1:(g=(g-A)/(I-A),g*g*g*(g*(g*6-15)+10))}function ML(g,A){return g+Math.floor(Math.random()*(A-g+1))}function mL(g,A){return g+Math.random()*(A-g)}function UL(g){return g*(.5-Math.random())}function NL(g){g!==void 0&&(vf=g);let A=vf+=1831565813;return A=Math.imul(A^A>>>15,A|1),A^=A+Math.imul(A^A>>>7,A|61),((A^A>>>14)>>>0)/4294967296}function FL(g){return g*en}function RL(g){return g*dn}function Tp(g){return(g&g-1)===0&&g!==0}function NN(g){return Math.pow(2,Math.ceil(Math.log(g)/Math.LN2))}function cc(g){return Math.pow(2,Math.floor(Math.log(g)/Math.LN2))}function KL(g,A,I,e,i){let t=Math.cos,C=Math.sin,o=t(I/2),B=C(I/2),a=t((A+e)/2),s=C((A+e)/2),r=t((A-e)/2),Q=C((A-e)/2),E=t((e-A)/2),n=C((e-A)/2);switch(i){case"XYX":g.set(o*s,B*r,B*Q,o*a);break;case"YZY":g.set(B*Q,o*s,B*r,o*a);break;case"ZXZ":g.set(B*r,B*Q,o*s,o*a);break;case"XZX":g.set(o*s,B*n,B*E,o*a);break;case"YXY":g.set(B*E,o*s,B*n,o*a);break;case"ZYZ":g.set(B*n,B*E,o*s,o*a);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function lB(g,A){switch(A.constructor){case Float32Array:return g;case Uint16Array:return g/65535;case Uint8Array:return g/255;case Int16Array:return Math.max(g/32767,-1);case Int8Array:return Math.max(g/127,-1);default:throw new Error("Invalid component type.")}}function ee(g,A){switch(A.constructor){case Float32Array:return g;case Uint16Array:return Math.round(g*65535);case Uint8Array:return Math.round(g*255);case Int16Array:return Math.round(g*32767);case Int8Array:return Math.round(g*127);default:throw new Error("Invalid component type.")}}var vg=Object.freeze({__proto__:null,DEG2RAD:en,RAD2DEG:dn,ceilPowerOfTwo:NN,clamp:ii,damp:SL,degToRad:FL,denormalize:lB,euclideanModulo:Lw,floorPowerOfTwo:cc,generateUUID:IC,inverseLerp:wL,isPowerOfTwo:Tp,lerp:tn,mapLinear:yL,normalize:ee,pingpong:fL,radToDeg:RL,randFloat:mL,randFloatSpread:UL,randInt:ML,seededRandom:NL,setQuaternionFromProperEuler:KL,smootherstep:kL,smoothstep:GL}),sA=class{constructor(A=0,I=0){sA.prototype.isVector2=!0,this.x=A,this.y=I}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}set(A,I){return this.x=A,this.y=I,this}setScalar(A){return this.x=A,this.y=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setComponent(A,I){switch(A){case 0:this.x=I;break;case 1:this.y=I;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y)}copy(A){return this.x=A.x,this.y=A.y,this}add(A){return this.x+=A.x,this.y+=A.y,this}addScalar(A){return this.x+=A,this.y+=A,this}addVectors(A,I){return this.x=A.x+I.x,this.y=A.y+I.y,this}addScaledVector(A,I){return this.x+=A.x*I,this.y+=A.y*I,this}sub(A){return this.x-=A.x,this.y-=A.y,this}subScalar(A){return this.x-=A,this.y-=A,this}subVectors(A,I){return this.x=A.x-I.x,this.y=A.y-I.y,this}multiply(A){return this.x*=A.x,this.y*=A.y,this}multiplyScalar(A){return this.x*=A,this.y*=A,this}divide(A){return this.x/=A.x,this.y/=A.y,this}divideScalar(A){return this.multiplyScalar(1/A)}applyMatrix3(A){let I=this.x,e=this.y,i=A.elements;return this.x=i[0]*I+i[3]*e+i[6],this.y=i[1]*I+i[4]*e+i[7],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this}clamp(A,I){return this.x=Math.max(A.x,Math.min(I.x,this.x)),this.y=Math.max(A.y,Math.min(I.y,this.y)),this}clampScalar(A,I){return this.x=Math.max(A,Math.min(I,this.x)),this.y=Math.max(A,Math.min(I,this.y)),this}clampLength(A,I){let e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(A,Math.min(I,e)))}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(A){return this.x*A.x+this.y*A.y}cross(A){return this.x*A.y-this.y*A.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(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let I=this.x-A.x,e=this.y-A.y;return I*I+e*e}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,I){return this.x+=(A.x-this.x)*I,this.y+=(A.y-this.y)*I,this}lerpVectors(A,I,e){return this.x=A.x+(I.x-A.x)*e,this.y=A.y+(I.y-A.y)*e,this}equals(A){return A.x===this.x&&A.y===this.y}fromArray(A,I=0){return this.x=A[I],this.y=A[I+1],this}toArray(A=[],I=0){return A[I]=this.x,A[I+1]=this.y,A}fromBufferAttribute(A,I){return this.x=A.getX(I),this.y=A.getY(I),this}rotateAround(A,I){let e=Math.cos(I),i=Math.sin(I),t=this.x-A.x,C=this.y-A.y;return this.x=t*e-C*i+A.x,this.y=t*i+C*e+A.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},hi=class{constructor(){hi.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(A,I,e,i,t,C,o,B,a){let s=this.elements;return s[0]=A,s[1]=i,s[2]=o,s[3]=I,s[4]=t,s[5]=B,s[6]=e,s[7]=C,s[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){let I=this.elements,e=A.elements;return I[0]=e[0],I[1]=e[1],I[2]=e[2],I[3]=e[3],I[4]=e[4],I[5]=e[5],I[6]=e[6],I[7]=e[7],I[8]=e[8],this}extractBasis(A,I,e){return A.setFromMatrix3Column(this,0),I.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(A){let I=A.elements;return this.set(I[0],I[4],I[8],I[1],I[5],I[9],I[2],I[6],I[10]),this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,I){let e=A.elements,i=I.elements,t=this.elements,C=e[0],o=e[3],B=e[6],a=e[1],s=e[4],r=e[7],Q=e[2],E=e[5],n=e[8],h=i[0],l=i[3],c=i[6],d=i[1],u=i[4],y=i[7],f=i[2],k=i[5],M=i[8];return t[0]=C*h+o*d+B*f,t[3]=C*l+o*u+B*k,t[6]=C*c+o*y+B*M,t[1]=a*h+s*d+r*f,t[4]=a*l+s*u+r*k,t[7]=a*c+s*y+r*M,t[2]=Q*h+E*d+n*f,t[5]=Q*l+E*u+n*k,t[8]=Q*c+E*y+n*M,this}multiplyScalar(A){let I=this.elements;return I[0]*=A,I[3]*=A,I[6]*=A,I[1]*=A,I[4]*=A,I[7]*=A,I[2]*=A,I[5]*=A,I[8]*=A,this}determinant(){let A=this.elements,I=A[0],e=A[1],i=A[2],t=A[3],C=A[4],o=A[5],B=A[6],a=A[7],s=A[8];return I*C*s-I*o*a-e*t*s+e*o*B+i*t*a-i*C*B}invert(){let A=this.elements,I=A[0],e=A[1],i=A[2],t=A[3],C=A[4],o=A[5],B=A[6],a=A[7],s=A[8],r=s*C-o*a,Q=o*B-s*t,E=a*t-C*B,n=I*r+e*Q+i*E;if(n===0)return this.set(0,0,0,0,0,0,0,0,0);let h=1/n;return A[0]=r*h,A[1]=(i*a-s*e)*h,A[2]=(o*e-i*C)*h,A[3]=Q*h,A[4]=(s*I-i*B)*h,A[5]=(i*t-o*I)*h,A[6]=E*h,A[7]=(e*B-a*I)*h,A[8]=(C*I-e*t)*h,this}transpose(){let A,I=this.elements;return A=I[1],I[1]=I[3],I[3]=A,A=I[2],I[2]=I[6],I[6]=A,A=I[5],I[5]=I[7],I[7]=A,this}getNormalMatrix(A){return this.setFromMatrix4(A).invert().transpose()}transposeIntoArray(A){let I=this.elements;return A[0]=I[0],A[1]=I[3],A[2]=I[6],A[3]=I[1],A[4]=I[4],A[5]=I[7],A[6]=I[2],A[7]=I[5],A[8]=I[8],this}setUvTransform(A,I,e,i,t,C,o){let B=Math.cos(t),a=Math.sin(t);return this.set(e*B,e*a,-e*(B*C+a*o)+C+A,-i*a,i*B,-i*(-a*C+B*o)+o+I,0,0,1),this}scale(A,I){return this.premultiply(qd.makeScale(A,I)),this}rotate(A){return this.premultiply(qd.makeRotation(-A)),this}translate(A,I){return this.premultiply(qd.makeTranslation(A,I)),this}makeTranslation(A,I){return this.set(1,0,A,0,1,I,0,0,1),this}makeRotation(A){let I=Math.cos(A),e=Math.sin(A);return this.set(I,-e,0,e,I,0,0,0,1),this}makeScale(A,I){return this.set(A,0,0,0,I,0,0,0,1),this}equals(A){let I=this.elements,e=A.elements;for(let i=0;i<9;i++)if(I[i]!==e[i])return!1;return!0}fromArray(A,I=0){for(let e=0;e<9;e++)this.elements[e]=A[e+I];return this}toArray(A=[],I=0){let e=this.elements;return A[I]=e[0],A[I+1]=e[1],A[I+2]=e[2],A[I+3]=e[3],A[I+4]=e[4],A[I+5]=e[5],A[I+6]=e[6],A[I+7]=e[7],A[I+8]=e[8],A}clone(){return new this.constructor().fromArray(this.elements)}},qd=new hi;function FN(g){for(let A=g.length-1;A>=0;--A)if(g[A]>=65535)return!0;return!1}var JL={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Gh(g,A){return new JL[g](A)}function Dc(g){return document.createElementNS("http://www.w3.org/1999/xhtml",g)}function fr(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}function Wl(g){return g<.0031308?g*12.92:1.055*Math.pow(g,.41666)-.055}var Ld={[ao]:{[lc]:fr},[lc]:{[ao]:Wl}},Yi={legacyMode:!0,get workingColorSpace(){return lc},set workingColorSpace(g){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(g,A,I){if(this.legacyMode||A===I||!A||!I)return g;if(Ld[A]&&Ld[A][I]!==void 0){let e=Ld[A][I];return g.r=e(g.r),g.g=e(g.g),g.b=e(g.b),g}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(g,A){return this.convert(g,this.workingColorSpace,A)},toWorkingColorSpace:function(g,A){return this.convert(g,A,this.workingColorSpace)}},RN={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},$e={r:0,g:0,b:0},nC={h:0,s:0,l:0},kh={h:0,s:0,l:0};function bd(g,A,I){return I<0&&(I+=1),I>1&&(I-=1),I<1/6?g+(A-g)*6*I:I<1/2?A:I<2/3?g+(A-g)*6*(2/3-I):g}function Mh(g,A){return A.r=g.r,A.g=g.g,A.b=g.b,A}var Og=class{constructor(A,I,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,I===void 0&&e===void 0?this.set(A):this.setRGB(A,I,e)}set(A){return A&&A.isColor?this.copy(A):typeof A=="number"?this.setHex(A):typeof A=="string"&&this.setStyle(A),this}setScalar(A){return this.r=A,this.g=A,this.b=A,this}setHex(A,I=ao){return A=Math.floor(A),this.r=(A>>16&255)/255,this.g=(A>>8&255)/255,this.b=(A&255)/255,Yi.toWorkingColorSpace(this,I),this}setRGB(A,I,e,i=Yi.workingColorSpace){return this.r=A,this.g=I,this.b=e,Yi.toWorkingColorSpace(this,i),this}setHSL(A,I,e,i=Yi.workingColorSpace){if(A=Lw(A,1),I=ii(I,0,1),e=ii(e,0,1),I===0)this.r=this.g=this.b=e;else{let t=e<=.5?e*(1+I):e+I-e*I,C=2*e-t;this.r=bd(C,t,A+1/3),this.g=bd(C,t,A),this.b=bd(C,t,A-1/3)}return Yi.toWorkingColorSpace(this,i),this}setStyle(A,I=ao){function e(t){t!==void 0&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+A+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(A)){let t,C=i[1],o=i[2];switch(C){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,Yi.toWorkingColorSpace(this,I),e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,Yi.toWorkingColorSpace(this,I),e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){let B=parseFloat(t[1])/360,a=parseFloat(t[2])/100,s=parseFloat(t[3])/100;return e(t[4]),this.setHSL(B,a,s,I)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(A)){let t=i[1],C=t.length;if(C===3)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,Yi.toWorkingColorSpace(this,I),this;if(C===6)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,Yi.toWorkingColorSpace(this,I),this}return A&&A.length>0?this.setColorName(A,I):this}setColorName(A,I=ao){let e=RN[A.toLowerCase()];return e!==void 0?this.setHex(e,I):console.warn("THREE.Color: Unknown color "+A),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(A){return this.r=A.r,this.g=A.g,this.b=A.b,this}copySRGBToLinear(A){return this.r=fr(A.r),this.g=fr(A.g),this.b=fr(A.b),this}copyLinearToSRGB(A){return this.r=Wl(A.r),this.g=Wl(A.g),this.b=Wl(A.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(A=ao){return Yi.fromWorkingColorSpace(Mh(this,$e),A),ii($e.r*255,0,255)<<16^ii($e.g*255,0,255)<<8^ii($e.b*255,0,255)<<0}getHexString(A=ao){return("000000"+this.getHex(A).toString(16)).slice(-6)}getHSL(A,I=Yi.workingColorSpace){Yi.fromWorkingColorSpace(Mh(this,$e),I);let e=$e.r,i=$e.g,t=$e.b,C=Math.max(e,i,t),o=Math.min(e,i,t),B,a,s=(o+C)/2;if(o===C)B=0,a=0;else{let r=C-o;switch(a=s<=.5?r/(C+o):r/(2-C-o),C){case e:B=(i-t)/r+(i"u")return g.src;let A;if(g instanceof HTMLCanvasElement)A=g;else{Qs===void 0&&(Qs=Dc("canvas")),Qs.width=g.width,Qs.height=g.height;let I=Qs.getContext("2d");g instanceof ImageData?I.putImageData(g,0,0):I.drawImage(g,0,0,g.width,g.height),A=Qs}return A.width>2048||A.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",g),A.toDataURL("image/jpeg",.6)):A.toDataURL("image/png")}static sRGBToLinear(g){if(typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&g instanceof ImageBitmap){let A=Dc("canvas");A.width=g.width,A.height=g.height;let I=A.getContext("2d");I.drawImage(g,0,0,g.width,g.height);let e=I.getImageData(0,0,g.width,g.height),i=e.data;for(let t=0;t0&&(e.userData=this.userData),I||(A.textures[this.uuid]=e),e}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(A){if(this.mapping!==fN)return A;if(A.applyMatrix3(this.matrix),A.x<0||A.x>1)switch(this.wrapS){case hB:A.x=A.x-Math.floor(A.x);break;case Ke:A.x=A.x<0?0:1;break;case Yp:Math.abs(Math.floor(A.x)%2)===1?A.x=Math.ceil(A.x)-A.x:A.x=A.x-Math.floor(A.x);break}if(A.y<0||A.y>1)switch(this.wrapT){case hB:A.y=A.y-Math.floor(A.y);break;case Ke:A.y=A.y<0?0:1;break;case Yp:Math.abs(Math.floor(A.y)%2)===1?A.y=Math.ceil(A.y)-A.y:A.y=A.y-Math.floor(A.y);break}return this.flipY&&(A.y=1-A.y),A}set needsUpdate(A){A===!0&&(this.version++,this.source.needsUpdate=!0)}};ti.DEFAULT_IMAGE=null;ti.DEFAULT_MAPPING=fN;ti.DEFAULT_ANISOTROPY=1;var EI=class{constructor(A=0,I=0,e=0,i=1){EI.prototype.isVector4=!0,this.x=A,this.y=I,this.z=e,this.w=i}get width(){return this.z}set width(A){this.z=A}get height(){return this.w}set height(A){this.w=A}set(A,I,e,i){return this.x=A,this.y=I,this.z=e,this.w=i,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this.w=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setW(A){return this.w=A,this}setComponent(A,I){switch(A){case 0:this.x=I;break;case 1:this.y=I;break;case 2:this.z=I;break;case 3:this.w=I;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){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: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this.w=A.w!==void 0?A.w:1,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this.w+=A.w,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this.w+=A,this}addVectors(A,I){return this.x=A.x+I.x,this.y=A.y+I.y,this.z=A.z+I.z,this.w=A.w+I.w,this}addScaledVector(A,I){return this.x+=A.x*I,this.y+=A.y*I,this.z+=A.z*I,this.w+=A.w*I,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this.w-=A.w,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this.w-=A,this}subVectors(A,I){return this.x=A.x-I.x,this.y=A.y-I.y,this.z=A.z-I.z,this.w=A.w-I.w,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this.w*=A.w,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this.w*=A,this}applyMatrix4(A){let I=this.x,e=this.y,i=this.z,t=this.w,C=A.elements;return this.x=C[0]*I+C[4]*e+C[8]*i+C[12]*t,this.y=C[1]*I+C[5]*e+C[9]*i+C[13]*t,this.z=C[2]*I+C[6]*e+C[10]*i+C[14]*t,this.w=C[3]*I+C[7]*e+C[11]*i+C[15]*t,this}divideScalar(A){return this.multiplyScalar(1/A)}setAxisAngleFromQuaternion(A){this.w=2*Math.acos(A.w);let I=Math.sqrt(1-A.w*A.w);return I<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=A.x/I,this.y=A.y/I,this.z=A.z/I),this}setAxisAngleFromRotationMatrix(A){let I,e,i,t,C=A.elements,o=C[0],B=C[4],a=C[8],s=C[1],r=C[5],Q=C[9],E=C[2],n=C[6],h=C[10];if(Math.abs(B-s)<.01&&Math.abs(a-E)<.01&&Math.abs(Q-n)<.01){if(Math.abs(B+s)<.1&&Math.abs(a+E)<.1&&Math.abs(Q+n)<.1&&Math.abs(o+r+h-3)<.1)return this.set(1,0,0,0),this;I=Math.PI;let c=(o+1)/2,d=(r+1)/2,u=(h+1)/2,y=(B+s)/4,f=(a+E)/4,k=(Q+n)/4;return c>d&&c>u?c<.01?(e=0,i=.707106781,t=.707106781):(e=Math.sqrt(c),i=y/e,t=f/e):d>u?d<.01?(e=.707106781,i=0,t=.707106781):(i=Math.sqrt(d),e=y/i,t=k/i):u<.01?(e=.707106781,i=.707106781,t=0):(t=Math.sqrt(u),e=f/t,i=k/t),this.set(e,i,t,I),this}let l=Math.sqrt((n-Q)*(n-Q)+(a-E)*(a-E)+(s-B)*(s-B));return Math.abs(l)<.001&&(l=1),this.x=(n-Q)/l,this.y=(a-E)/l,this.z=(s-B)/l,this.w=Math.acos((o+r+h-1)/2),this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this.w=Math.min(this.w,A.w),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this.w=Math.max(this.w,A.w),this}clamp(A,I){return this.x=Math.max(A.x,Math.min(I.x,this.x)),this.y=Math.max(A.y,Math.min(I.y,this.y)),this.z=Math.max(A.z,Math.min(I.z,this.z)),this.w=Math.max(A.w,Math.min(I.w,this.w)),this}clampScalar(A,I){return this.x=Math.max(A,Math.min(I,this.x)),this.y=Math.max(A,Math.min(I,this.y)),this.z=Math.max(A,Math.min(I,this.z)),this.w=Math.max(A,Math.min(I,this.w)),this}clampLength(A,I){let e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(A,Math.min(I,e)))}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(A){return this.x*A.x+this.y*A.y+this.z*A.z+this.w*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,I){return this.x+=(A.x-this.x)*I,this.y+=(A.y-this.y)*I,this.z+=(A.z-this.z)*I,this.w+=(A.w-this.w)*I,this}lerpVectors(A,I,e){return this.x=A.x+(I.x-A.x)*e,this.y=A.y+(I.y-A.y)*e,this.z=A.z+(I.z-A.z)*e,this.w=A.w+(I.w-A.w)*e,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z&&A.w===this.w}fromArray(A,I=0){return this.x=A[I],this.y=A[I+1],this.z=A[I+2],this.w=A[I+3],this}toArray(A=[],I=0){return A[I]=this.x,A[I+1]=this.y,A[I+2]=this.z,A[I+3]=this.w,A}fromBufferAttribute(A,I){return this.x=A.getX(I),this.y=A.getY(I),this.z=A.getZ(I),this.w=A.getW(I),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}},WI=class extends Si{constructor(A=1,I=1,e={}){super(),this.isWebGLRenderTarget=!0,this.width=A,this.height=I,this.depth=1,this.scissor=new EI(0,0,A,I),this.scissorTest=!1,this.viewport=new EI(0,0,A,I);let i={width:A,height:I,depth:1};this.texture=new ti(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.internalFormat=e.internalFormat!==void 0?e.internalFormat:null,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:cI,this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0,this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!1,this.depthTexture=e.depthTexture!==void 0?e.depthTexture:null,this.samples=e.samples!==void 0?e.samples:0}setSize(A,I,e=1){(this.width!==A||this.height!==I||this.depth!==e)&&(this.width=A,this.height=I,this.depth=e,this.texture.image.width=A,this.texture.image.height=I,this.texture.image.depth=e,this.dispose()),this.viewport.set(0,0,A,I),this.scissor.set(0,0,A,I)}clone(){return new this.constructor().copy(this)}copy(A){this.width=A.width,this.height=A.height,this.depth=A.depth,this.viewport.copy(A.viewport),this.texture=A.texture.clone(),this.texture.isRenderTargetTexture=!0;let I=Object.assign({},A.texture.image);return this.texture.source=new JN(I),this.depthBuffer=A.depthBuffer,this.stencilBuffer=A.stencilBuffer,A.depthTexture!==null&&(this.depthTexture=A.depthTexture.clone()),this.samples=A.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},vN=class extends ti{constructor(g=null,A=1,I=1,e=1){super(null),this.isDataArrayTexture=!0,this.image={data:g,width:A,height:I,depth:e},this.magFilter=ie,this.minFilter=ie,this.wrapR=Ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},qL=class extends ti{constructor(g=null,A=1,I=1,e=1){super(null),this.isData3DTexture=!0,this.image={data:g,width:A,height:I,depth:e},this.magFilter=ie,this.minFilter=ie,this.wrapR=Ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},LL=class extends WI{constructor(g=1,A=1,I=1,e={}){super(g,A,e),this.isWebGLMultipleRenderTargets=!0;let i=this.texture;this.texture=[];for(let t=0;t=0?1:-1,u=1-c*c;if(u>Number.EPSILON){let f=Math.sqrt(u),k=Math.atan2(f,c*d);l=Math.sin(l*k)/f,o=Math.sin(o*k)/f}let y=o*d;if(B=B*l+Q*y,a=a*l+E*y,s=s*l+n*y,r=r*l+h*y,l===1-o){let f=1/Math.sqrt(B*B+a*a+s*s+r*r);B*=f,a*=f,s*=f,r*=f}}A[I]=B,A[I+1]=a,A[I+2]=s,A[I+3]=r}static multiplyQuaternionsFlat(A,I,e,i,t,C){let o=e[i],B=e[i+1],a=e[i+2],s=e[i+3],r=t[C],Q=t[C+1],E=t[C+2],n=t[C+3];return A[I]=o*n+s*r+B*E-a*Q,A[I+1]=B*n+s*Q+a*r-o*E,A[I+2]=a*n+s*E+o*Q-B*r,A[I+3]=s*n-o*r-B*Q-a*E,A}get x(){return this._x}set x(A){this._x=A,this._onChangeCallback()}get y(){return this._y}set y(A){this._y=A,this._onChangeCallback()}get z(){return this._z}set z(A){this._z=A,this._onChangeCallback()}get w(){return this._w}set w(A){this._w=A,this._onChangeCallback()}set(A,I,e,i){return this._x=A,this._y=I,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(A){return this._x=A.x,this._y=A.y,this._z=A.z,this._w=A.w,this._onChangeCallback(),this}setFromEuler(A,I){let e=A._x,i=A._y,t=A._z,C=A._order,o=Math.cos,B=Math.sin,a=o(e/2),s=o(i/2),r=o(t/2),Q=B(e/2),E=B(i/2),n=B(t/2);switch(C){case"XYZ":this._x=Q*s*r+a*E*n,this._y=a*E*r-Q*s*n,this._z=a*s*n+Q*E*r,this._w=a*s*r-Q*E*n;break;case"YXZ":this._x=Q*s*r+a*E*n,this._y=a*E*r-Q*s*n,this._z=a*s*n-Q*E*r,this._w=a*s*r+Q*E*n;break;case"ZXY":this._x=Q*s*r-a*E*n,this._y=a*E*r+Q*s*n,this._z=a*s*n+Q*E*r,this._w=a*s*r-Q*E*n;break;case"ZYX":this._x=Q*s*r-a*E*n,this._y=a*E*r+Q*s*n,this._z=a*s*n-Q*E*r,this._w=a*s*r+Q*E*n;break;case"YZX":this._x=Q*s*r+a*E*n,this._y=a*E*r+Q*s*n,this._z=a*s*n-Q*E*r,this._w=a*s*r-Q*E*n;break;case"XZY":this._x=Q*s*r-a*E*n,this._y=a*E*r-Q*s*n,this._z=a*s*n+Q*E*r,this._w=a*s*r+Q*E*n;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+C)}return I!==!1&&this._onChangeCallback(),this}setFromAxisAngle(A,I){let e=I/2,i=Math.sin(e);return this._x=A.x*i,this._y=A.y*i,this._z=A.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(A){let I=A.elements,e=I[0],i=I[4],t=I[8],C=I[1],o=I[5],B=I[9],a=I[2],s=I[6],r=I[10],Q=e+o+r;if(Q>0){let E=.5/Math.sqrt(Q+1);this._w=.25/E,this._x=(s-B)*E,this._y=(t-a)*E,this._z=(C-i)*E}else if(e>o&&e>r){let E=2*Math.sqrt(1+e-o-r);this._w=(s-B)/E,this._x=.25*E,this._y=(i+C)/E,this._z=(t+a)/E}else if(o>r){let E=2*Math.sqrt(1+o-e-r);this._w=(t-a)/E,this._x=(i+C)/E,this._y=.25*E,this._z=(B+s)/E}else{let E=2*Math.sqrt(1+r-e-o);this._w=(C-i)/E,this._x=(t+a)/E,this._y=(B+s)/E,this._z=.25*E}return this._onChangeCallback(),this}setFromUnitVectors(A,I){let e=A.dot(I)+1;return eMath.abs(A.z)?(this._x=-A.y,this._y=A.x,this._z=0,this._w=e):(this._x=0,this._y=-A.z,this._z=A.y,this._w=e)):(this._x=A.y*I.z-A.z*I.y,this._y=A.z*I.x-A.x*I.z,this._z=A.x*I.y-A.y*I.x,this._w=e),this.normalize()}angleTo(A){return 2*Math.acos(Math.abs(ii(this.dot(A),-1,1)))}rotateTowards(A,I){let e=this.angleTo(A);if(e===0)return this;let i=Math.min(1,I/e);return this.slerp(A,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(A){return this._x*A._x+this._y*A._y+this._z*A._z+this._w*A._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 A=this.length();return A===0?(this._x=0,this._y=0,this._z=0,this._w=1):(A=1/A,this._x=this._x*A,this._y=this._y*A,this._z=this._z*A,this._w=this._w*A),this._onChangeCallback(),this}multiply(A){return this.multiplyQuaternions(this,A)}premultiply(A){return this.multiplyQuaternions(A,this)}multiplyQuaternions(A,I){let e=A._x,i=A._y,t=A._z,C=A._w,o=I._x,B=I._y,a=I._z,s=I._w;return this._x=e*s+C*o+i*a-t*B,this._y=i*s+C*B+t*o-e*a,this._z=t*s+C*a+e*B-i*o,this._w=C*s-e*o-i*B-t*a,this._onChangeCallback(),this}slerp(A,I){if(I===0)return this;if(I===1)return this.copy(A);let e=this._x,i=this._y,t=this._z,C=this._w,o=C*A._w+e*A._x+i*A._y+t*A._z;if(o<0?(this._w=-A._w,this._x=-A._x,this._y=-A._y,this._z=-A._z,o=-o):this.copy(A),o>=1)return this._w=C,this._x=e,this._y=i,this._z=t,this;let B=1-o*o;if(B<=Number.EPSILON){let E=1-I;return this._w=E*C+I*this._w,this._x=E*e+I*this._x,this._y=E*i+I*this._y,this._z=E*t+I*this._z,this.normalize(),this._onChangeCallback(),this}let a=Math.sqrt(B),s=Math.atan2(a,o),r=Math.sin((1-I)*s)/a,Q=Math.sin(I*s)/a;return this._w=C*r+this._w*Q,this._x=e*r+this._x*Q,this._y=i*r+this._y*Q,this._z=t*r+this._z*Q,this._onChangeCallback(),this}slerpQuaternions(A,I,e){return this.copy(A).slerp(I,e)}random(){let A=Math.random(),I=Math.sqrt(1-A),e=Math.sqrt(A),i=2*Math.PI*Math.random(),t=2*Math.PI*Math.random();return this.set(I*Math.cos(i),e*Math.sin(t),e*Math.cos(t),I*Math.sin(i))}equals(A){return A._x===this._x&&A._y===this._y&&A._z===this._z&&A._w===this._w}fromArray(A,I=0){return this._x=A[I],this._y=A[I+1],this._z=A[I+2],this._w=A[I+3],this._onChangeCallback(),this}toArray(A=[],I=0){return A[I]=this._x,A[I+1]=this._y,A[I+2]=this._z,A[I+3]=this._w,A}fromBufferAttribute(A,I){return this._x=A.getX(I),this._y=A.getY(I),this._z=A.getZ(I),this._w=A.getW(I),this}_onChange(A){return this._onChangeCallback=A,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},J=class{constructor(A=0,I=0,e=0){J.prototype.isVector3=!0,this.x=A,this.y=I,this.z=e}set(A,I,e){return e===void 0&&(e=this.z),this.x=A,this.y=I,this.z=e,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setComponent(A,I){switch(A){case 0:this.x=I;break;case 1:this.y=I;break;case 2:this.z=I;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this}addVectors(A,I){return this.x=A.x+I.x,this.y=A.y+I.y,this.z=A.z+I.z,this}addScaledVector(A,I){return this.x+=A.x*I,this.y+=A.y*I,this.z+=A.z*I,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this}subVectors(A,I){return this.x=A.x-I.x,this.y=A.y-I.y,this.z=A.z-I.z,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this}multiplyVectors(A,I){return this.x=A.x*I.x,this.y=A.y*I.y,this.z=A.z*I.z,this}applyEuler(A){return this.applyQuaternion(qf.setFromEuler(A))}applyAxisAngle(A,I){return this.applyQuaternion(qf.setFromAxisAngle(A,I))}applyMatrix3(A){let I=this.x,e=this.y,i=this.z,t=A.elements;return this.x=t[0]*I+t[3]*e+t[6]*i,this.y=t[1]*I+t[4]*e+t[7]*i,this.z=t[2]*I+t[5]*e+t[8]*i,this}applyNormalMatrix(A){return this.applyMatrix3(A).normalize()}applyMatrix4(A){let I=this.x,e=this.y,i=this.z,t=A.elements,C=1/(t[3]*I+t[7]*e+t[11]*i+t[15]);return this.x=(t[0]*I+t[4]*e+t[8]*i+t[12])*C,this.y=(t[1]*I+t[5]*e+t[9]*i+t[13])*C,this.z=(t[2]*I+t[6]*e+t[10]*i+t[14])*C,this}applyQuaternion(A){let I=this.x,e=this.y,i=this.z,t=A.x,C=A.y,o=A.z,B=A.w,a=B*I+C*i-o*e,s=B*e+o*I-t*i,r=B*i+t*e-C*I,Q=-t*I-C*e-o*i;return this.x=a*B+Q*-t+s*-o-r*-C,this.y=s*B+Q*-C+r*-t-a*-o,this.z=r*B+Q*-o+a*-C-s*-t,this}project(A){return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix)}unproject(A){return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld)}transformDirection(A){let I=this.x,e=this.y,i=this.z,t=A.elements;return this.x=t[0]*I+t[4]*e+t[8]*i,this.y=t[1]*I+t[5]*e+t[9]*i,this.z=t[2]*I+t[6]*e+t[10]*i,this.normalize()}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this}divideScalar(A){return this.multiplyScalar(1/A)}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this}clamp(A,I){return this.x=Math.max(A.x,Math.min(I.x,this.x)),this.y=Math.max(A.y,Math.min(I.y,this.y)),this.z=Math.max(A.z,Math.min(I.z,this.z)),this}clampScalar(A,I){return this.x=Math.max(A,Math.min(I,this.x)),this.y=Math.max(A,Math.min(I,this.y)),this.z=Math.max(A,Math.min(I,this.z)),this}clampLength(A,I){let e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(A,Math.min(I,e)))}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(A){return this.x*A.x+this.y*A.y+this.z*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,I){return this.x+=(A.x-this.x)*I,this.y+=(A.y-this.y)*I,this.z+=(A.z-this.z)*I,this}lerpVectors(A,I,e){return this.x=A.x+(I.x-A.x)*e,this.y=A.y+(I.y-A.y)*e,this.z=A.z+(I.z-A.z)*e,this}cross(A){return this.crossVectors(this,A)}crossVectors(A,I){let e=A.x,i=A.y,t=A.z,C=I.x,o=I.y,B=I.z;return this.x=i*B-t*o,this.y=t*C-e*B,this.z=e*o-i*C,this}projectOnVector(A){let I=A.lengthSq();if(I===0)return this.set(0,0,0);let e=A.dot(this)/I;return this.copy(A).multiplyScalar(e)}projectOnPlane(A){return xd.copy(this).projectOnVector(A),this.sub(xd)}reflect(A){return this.sub(xd.copy(A).multiplyScalar(2*this.dot(A)))}angleTo(A){let I=Math.sqrt(this.lengthSq()*A.lengthSq());if(I===0)return Math.PI/2;let e=this.dot(A)/I;return Math.acos(ii(e,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let I=this.x-A.x,e=this.y-A.y,i=this.z-A.z;return I*I+e*e+i*i}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)+Math.abs(this.z-A.z)}setFromSpherical(A){return this.setFromSphericalCoords(A.radius,A.phi,A.theta)}setFromSphericalCoords(A,I,e){let i=Math.sin(I)*A;return this.x=i*Math.sin(e),this.y=Math.cos(I)*A,this.z=i*Math.cos(e),this}setFromCylindrical(A){return this.setFromCylindricalCoords(A.radius,A.theta,A.y)}setFromCylindricalCoords(A,I,e){return this.x=A*Math.sin(I),this.y=e,this.z=A*Math.cos(I),this}setFromMatrixPosition(A){let I=A.elements;return this.x=I[12],this.y=I[13],this.z=I[14],this}setFromMatrixScale(A){let I=this.setFromMatrixColumn(A,0).length(),e=this.setFromMatrixColumn(A,1).length(),i=this.setFromMatrixColumn(A,2).length();return this.x=I,this.y=e,this.z=i,this}setFromMatrixColumn(A,I){return this.fromArray(A.elements,I*4)}setFromMatrix3Column(A,I){return this.fromArray(A.elements,I*3)}setFromEuler(A){return this.x=A._x,this.y=A._y,this.z=A._z,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z}fromArray(A,I=0){return this.x=A[I],this.y=A[I+1],this.z=A[I+2],this}toArray(A=[],I=0){return A[I]=this.x,A[I+1]=this.y,A[I+2]=this.z,A}fromBufferAttribute(A,I){return this.x=A.getX(I),this.y=A.getY(I),this.z=A.getZ(I),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let A=(Math.random()-.5)*2,I=Math.random()*Math.PI*2,e=Math.sqrt(1-A**2);return this.x=e*Math.cos(I),this.y=e*Math.sin(I),this.z=A,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},xd=new J,qf=new QI,ve=class{constructor(A=new J(1/0,1/0,1/0),I=new J(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=A,this.max=I}set(A,I){return this.min.copy(A),this.max.copy(I),this}setFromArray(A){let I=1/0,e=1/0,i=1/0,t=-1/0,C=-1/0,o=-1/0;for(let B=0,a=A.length;Bt&&(t=s),r>C&&(C=r),Q>o&&(o=Q)}return this.min.set(I,e,i),this.max.set(t,C,o),this}setFromBufferAttribute(A){let I=1/0,e=1/0,i=1/0,t=-1/0,C=-1/0,o=-1/0;for(let B=0,a=A.count;Bt&&(t=s),r>C&&(C=r),Q>o&&(o=Q)}return this.min.set(I,e,i),this.max.set(t,C,o),this}setFromPoints(A){this.makeEmpty();for(let I=0,e=A.length;Ithis.max.x||A.ythis.max.y||A.zthis.max.z)}containsBox(A){return this.min.x<=A.min.x&&A.max.x<=this.max.x&&this.min.y<=A.min.y&&A.max.y<=this.max.y&&this.min.z<=A.min.z&&A.max.z<=this.max.z}getParameter(A,I){return I.set((A.x-this.min.x)/(this.max.x-this.min.x),(A.y-this.min.y)/(this.max.y-this.min.y),(A.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(A){return!(A.max.xthis.max.x||A.max.ythis.max.y||A.max.zthis.max.z)}intersectsSphere(A){return this.clampPoint(A.center,Va),Va.distanceToSquared(A.center)<=A.radius*A.radius}intersectsPlane(A){let I,e;return A.normal.x>0?(I=A.normal.x*this.min.x,e=A.normal.x*this.max.x):(I=A.normal.x*this.max.x,e=A.normal.x*this.min.x),A.normal.y>0?(I+=A.normal.y*this.min.y,e+=A.normal.y*this.max.y):(I+=A.normal.y*this.max.y,e+=A.normal.y*this.min.y),A.normal.z>0?(I+=A.normal.z*this.min.z,e+=A.normal.z*this.max.z):(I+=A.normal.z*this.max.z,e+=A.normal.z*this.min.z),I<=-A.constant&&e>=-A.constant}intersectsTriangle(A){if(this.isEmpty())return!1;this.getCenter(DE),mh.subVectors(this.max,DE),Es.subVectors(A.a,DE),ns.subVectors(A.b,DE),hs.subVectors(A.c,DE),bB.subVectors(ns,Es),YB.subVectors(hs,ns),za.subVectors(Es,hs);let I=[0,-bB.z,bB.y,0,-YB.z,YB.y,0,-za.z,za.y,bB.z,0,-bB.x,YB.z,0,-YB.x,za.z,0,-za.x,-bB.y,bB.x,0,-YB.y,YB.x,0,-za.y,za.x,0];return!Td(I,Es,ns,hs,mh)||(I=[1,0,0,0,1,0,0,0,1],!Td(I,Es,ns,hs,mh))?!1:(Uh.crossVectors(bB,YB),I=[Uh.x,Uh.y,Uh.z],Td(I,Es,ns,hs,mh))}clampPoint(A,I){return I.copy(A).clamp(this.min,this.max)}distanceToPoint(A){return Va.copy(A).clamp(this.min,this.max).sub(A).length()}getBoundingSphere(A){return this.getCenter(A.center),A.radius=this.getSize(Va).length()*.5,A}intersect(A){return this.min.max(A.min),this.max.min(A.max),this.isEmpty()&&this.makeEmpty(),this}union(A){return this.min.min(A.min),this.max.max(A.max),this}applyMatrix4(A){return this.isEmpty()?this:(Zo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(A),Zo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(A),Zo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(A),Zo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(A),Zo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(A),Zo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(A),Zo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(A),Zo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(A),this.setFromPoints(Zo),this)}translate(A){return this.min.add(A),this.max.add(A),this}equals(A){return A.min.equals(this.min)&&A.max.equals(this.max)}},Zo=[new J,new J,new J,new J,new J,new J,new J,new J],Va=new J,Hd=new ve,Es=new J,ns=new J,hs=new J,bB=new J,YB=new J,za=new J,DE=new J,mh=new J,Uh=new J,Xa=new J;function Td(g,A,I,e,i){for(let t=0,C=g.length-3;t<=C;t+=3){Xa.fromArray(g,t);let o=i.x*Math.abs(Xa.x)+i.y*Math.abs(Xa.y)+i.z*Math.abs(Xa.z),B=A.dot(Xa),a=I.dot(Xa),s=e.dot(Xa);if(Math.max(-Math.max(B,a,s),Math.min(B,a,s))>o)return!1}return!0}var bL=new ve,dE=new J,Od=new J,ct=class{constructor(A=new J,I=-1){this.center=A,this.radius=I}set(A,I){return this.center.copy(A),this.radius=I,this}setFromPoints(A,I){let e=this.center;I!==void 0?e.copy(I):bL.setFromPoints(A).getCenter(e);let i=0;for(let t=0,C=A.length;tthis.radius*this.radius&&(I.sub(this.center).normalize(),I.multiplyScalar(this.radius).add(this.center)),I}getBoundingBox(A){return this.isEmpty()?(A.makeEmpty(),A):(A.set(this.center,this.center),A.expandByScalar(this.radius),A)}applyMatrix4(A){return this.center.applyMatrix4(A),this.radius=this.radius*A.getMaxScaleOnAxis(),this}translate(A){return this.center.add(A),this}expandByPoint(A){if(this.isEmpty())return this.center.copy(A),this.radius=0,this;dE.subVectors(A,this.center);let I=dE.lengthSq();if(I>this.radius*this.radius){let e=Math.sqrt(I),i=(e-this.radius)*.5;this.center.addScaledVector(dE,i/e),this.radius+=i}return this}union(A){return A.isEmpty()?this:this.isEmpty()?(this.copy(A),this):(this.center.equals(A.center)===!0?this.radius=Math.max(this.radius,A.radius):(Od.subVectors(A.center,this.center).setLength(A.radius),this.expandByPoint(dE.copy(A.center).add(Od)),this.expandByPoint(dE.copy(A.center).sub(Od))),this)}equals(A){return A.center.equals(this.center)&&A.radius===this.radius}clone(){return new this.constructor().copy(this)}},Vo=new J,_d=new J,Nh=new J,xB=new J,Pd=new J,Fh=new J,jd=new J,jQ=class{constructor(A=new J,I=new J(0,0,-1)){this.origin=A,this.direction=I}set(A,I){return this.origin.copy(A),this.direction.copy(I),this}copy(A){return this.origin.copy(A.origin),this.direction.copy(A.direction),this}at(A,I){return I.copy(this.direction).multiplyScalar(A).add(this.origin)}lookAt(A){return this.direction.copy(A).sub(this.origin).normalize(),this}recast(A){return this.origin.copy(this.at(A,Vo)),this}closestPointToPoint(A,I){I.subVectors(A,this.origin);let e=I.dot(this.direction);return e<0?I.copy(this.origin):I.copy(this.direction).multiplyScalar(e).add(this.origin)}distanceToPoint(A){return Math.sqrt(this.distanceSqToPoint(A))}distanceSqToPoint(A){let I=Vo.subVectors(A,this.origin).dot(this.direction);return I<0?this.origin.distanceToSquared(A):(Vo.copy(this.direction).multiplyScalar(I).add(this.origin),Vo.distanceToSquared(A))}distanceSqToSegment(A,I,e,i){_d.copy(A).add(I).multiplyScalar(.5),Nh.copy(I).sub(A).normalize(),xB.copy(this.origin).sub(_d);let t=A.distanceTo(I)*.5,C=-this.direction.dot(Nh),o=xB.dot(this.direction),B=-xB.dot(Nh),a=xB.lengthSq(),s=Math.abs(1-C*C),r,Q,E,n;if(s>0)if(r=C*B-o,Q=C*o-B,n=t*s,r>=0)if(Q>=-n)if(Q<=n){let h=1/s;r*=h,Q*=h,E=r*(r+C*Q+2*o)+Q*(C*r+Q+2*B)+a}else Q=t,r=Math.max(0,-(C*Q+o)),E=-r*r+Q*(Q+2*B)+a;else Q=-t,r=Math.max(0,-(C*Q+o)),E=-r*r+Q*(Q+2*B)+a;else Q<=-n?(r=Math.max(0,-(-C*t+o)),Q=r>0?-t:Math.min(Math.max(-t,-B),t),E=-r*r+Q*(Q+2*B)+a):Q<=n?(r=0,Q=Math.min(Math.max(-t,-B),t),E=Q*(Q+2*B)+a):(r=Math.max(0,-(C*t+o)),Q=r>0?t:Math.min(Math.max(-t,-B),t),E=-r*r+Q*(Q+2*B)+a);else Q=C>0?-t:t,r=Math.max(0,-(C*Q+o)),E=-r*r+Q*(Q+2*B)+a;return e&&e.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(Nh).multiplyScalar(Q).add(_d),E}intersectSphere(A,I){Vo.subVectors(A.center,this.origin);let e=Vo.dot(this.direction),i=Vo.dot(Vo)-e*e,t=A.radius*A.radius;if(i>t)return null;let C=Math.sqrt(t-i),o=e-C,B=e+C;return o<0&&B<0?null:o<0?this.at(B,I):this.at(o,I)}intersectsSphere(A){return this.distanceSqToPoint(A.center)<=A.radius*A.radius}distanceToPlane(A){let I=A.normal.dot(this.direction);if(I===0)return A.distanceToPoint(this.origin)===0?0:null;let e=-(this.origin.dot(A.normal)+A.constant)/I;return e>=0?e:null}intersectPlane(A,I){let e=this.distanceToPlane(A);return e===null?null:this.at(e,I)}intersectsPlane(A){let I=A.distanceToPoint(this.origin);return I===0||A.normal.dot(this.direction)*I<0}intersectBox(A,I){let e,i,t,C,o,B,a=1/this.direction.x,s=1/this.direction.y,r=1/this.direction.z,Q=this.origin;return a>=0?(e=(A.min.x-Q.x)*a,i=(A.max.x-Q.x)*a):(e=(A.max.x-Q.x)*a,i=(A.min.x-Q.x)*a),s>=0?(t=(A.min.y-Q.y)*s,C=(A.max.y-Q.y)*s):(t=(A.max.y-Q.y)*s,C=(A.min.y-Q.y)*s),e>C||t>i||((t>e||isNaN(e))&&(e=t),(C=0?(o=(A.min.z-Q.z)*r,B=(A.max.z-Q.z)*r):(o=(A.max.z-Q.z)*r,B=(A.min.z-Q.z)*r),e>B||o>i)||((o>e||e!==e)&&(e=o),(B=0?e:i,I)}intersectsBox(A){return this.intersectBox(A,Vo)!==null}intersectTriangle(A,I,e,i,t){Pd.subVectors(I,A),Fh.subVectors(e,A),jd.crossVectors(Pd,Fh);let C=this.direction.dot(jd),o;if(C>0){if(i)return null;o=1}else if(C<0)o=-1,C=-C;else return null;xB.subVectors(this.origin,A);let B=o*this.direction.dot(Fh.crossVectors(xB,Fh));if(B<0)return null;let a=o*this.direction.dot(Pd.cross(xB));if(a<0||B+a>C)return null;let s=-o*xB.dot(jd);return s<0?null:this.at(s/C,t)}applyMatrix4(A){return this.origin.applyMatrix4(A),this.direction.transformDirection(A),this}equals(A){return A.origin.equals(this.origin)&&A.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},zA=class{constructor(){zA.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(A,I,e,i,t,C,o,B,a,s,r,Q,E,n,h,l){let c=this.elements;return c[0]=A,c[4]=I,c[8]=e,c[12]=i,c[1]=t,c[5]=C,c[9]=o,c[13]=B,c[2]=a,c[6]=s,c[10]=r,c[14]=Q,c[3]=E,c[7]=n,c[11]=h,c[15]=l,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 zA().fromArray(this.elements)}copy(A){let I=this.elements,e=A.elements;return I[0]=e[0],I[1]=e[1],I[2]=e[2],I[3]=e[3],I[4]=e[4],I[5]=e[5],I[6]=e[6],I[7]=e[7],I[8]=e[8],I[9]=e[9],I[10]=e[10],I[11]=e[11],I[12]=e[12],I[13]=e[13],I[14]=e[14],I[15]=e[15],this}copyPosition(A){let I=this.elements,e=A.elements;return I[12]=e[12],I[13]=e[13],I[14]=e[14],this}setFromMatrix3(A){let I=A.elements;return this.set(I[0],I[3],I[6],0,I[1],I[4],I[7],0,I[2],I[5],I[8],0,0,0,0,1),this}extractBasis(A,I,e){return A.setFromMatrixColumn(this,0),I.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(A,I,e){return this.set(A.x,I.x,e.x,0,A.y,I.y,e.y,0,A.z,I.z,e.z,0,0,0,0,1),this}extractRotation(A){let I=this.elements,e=A.elements,i=1/ls.setFromMatrixColumn(A,0).length(),t=1/ls.setFromMatrixColumn(A,1).length(),C=1/ls.setFromMatrixColumn(A,2).length();return I[0]=e[0]*i,I[1]=e[1]*i,I[2]=e[2]*i,I[3]=0,I[4]=e[4]*t,I[5]=e[5]*t,I[6]=e[6]*t,I[7]=0,I[8]=e[8]*C,I[9]=e[9]*C,I[10]=e[10]*C,I[11]=0,I[12]=0,I[13]=0,I[14]=0,I[15]=1,this}makeRotationFromEuler(A){let I=this.elements,e=A.x,i=A.y,t=A.z,C=Math.cos(e),o=Math.sin(e),B=Math.cos(i),a=Math.sin(i),s=Math.cos(t),r=Math.sin(t);if(A.order==="XYZ"){let Q=C*s,E=C*r,n=o*s,h=o*r;I[0]=B*s,I[4]=-B*r,I[8]=a,I[1]=E+n*a,I[5]=Q-h*a,I[9]=-o*B,I[2]=h-Q*a,I[6]=n+E*a,I[10]=C*B}else if(A.order==="YXZ"){let Q=B*s,E=B*r,n=a*s,h=a*r;I[0]=Q+h*o,I[4]=n*o-E,I[8]=C*a,I[1]=C*r,I[5]=C*s,I[9]=-o,I[2]=E*o-n,I[6]=h+Q*o,I[10]=C*B}else if(A.order==="ZXY"){let Q=B*s,E=B*r,n=a*s,h=a*r;I[0]=Q-h*o,I[4]=-C*r,I[8]=n+E*o,I[1]=E+n*o,I[5]=C*s,I[9]=h-Q*o,I[2]=-C*a,I[6]=o,I[10]=C*B}else if(A.order==="ZYX"){let Q=C*s,E=C*r,n=o*s,h=o*r;I[0]=B*s,I[4]=n*a-E,I[8]=Q*a+h,I[1]=B*r,I[5]=h*a+Q,I[9]=E*a-n,I[2]=-a,I[6]=o*B,I[10]=C*B}else if(A.order==="YZX"){let Q=C*B,E=C*a,n=o*B,h=o*a;I[0]=B*s,I[4]=h-Q*r,I[8]=n*r+E,I[1]=r,I[5]=C*s,I[9]=-o*s,I[2]=-a*s,I[6]=E*r+n,I[10]=Q-h*r}else if(A.order==="XZY"){let Q=C*B,E=C*a,n=o*B,h=o*a;I[0]=B*s,I[4]=-r,I[8]=a*s,I[1]=Q*r+h,I[5]=C*s,I[9]=E*r-n,I[2]=n*r-E,I[6]=o*s,I[10]=h*r+Q}return I[3]=0,I[7]=0,I[11]=0,I[12]=0,I[13]=0,I[14]=0,I[15]=1,this}makeRotationFromQuaternion(A){return this.compose(YL,A,xL)}lookAt(A,I,e){let i=this.elements;return Gt.subVectors(A,I),Gt.lengthSq()===0&&(Gt.z=1),Gt.normalize(),HB.crossVectors(e,Gt),HB.lengthSq()===0&&(Math.abs(e.z)===1?Gt.x+=1e-4:Gt.z+=1e-4,Gt.normalize(),HB.crossVectors(e,Gt)),HB.normalize(),Rh.crossVectors(Gt,HB),i[0]=HB.x,i[4]=Rh.x,i[8]=Gt.x,i[1]=HB.y,i[5]=Rh.y,i[9]=Gt.y,i[2]=HB.z,i[6]=Rh.z,i[10]=Gt.z,this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,I){let e=A.elements,i=I.elements,t=this.elements,C=e[0],o=e[4],B=e[8],a=e[12],s=e[1],r=e[5],Q=e[9],E=e[13],n=e[2],h=e[6],l=e[10],c=e[14],d=e[3],u=e[7],y=e[11],f=e[15],k=i[0],M=i[4],G=i[8],v=i[12],N=i[1],b=i[5],O=i[9],H=i[13],_=i[2],gA=i[6],CA=i[10],AA=i[14],BA=i[3],iA=i[7],rA=i[11],$=i[15];return t[0]=C*k+o*N+B*_+a*BA,t[4]=C*M+o*b+B*gA+a*iA,t[8]=C*G+o*O+B*CA+a*rA,t[12]=C*v+o*H+B*AA+a*$,t[1]=s*k+r*N+Q*_+E*BA,t[5]=s*M+r*b+Q*gA+E*iA,t[9]=s*G+r*O+Q*CA+E*rA,t[13]=s*v+r*H+Q*AA+E*$,t[2]=n*k+h*N+l*_+c*BA,t[6]=n*M+h*b+l*gA+c*iA,t[10]=n*G+h*O+l*CA+c*rA,t[14]=n*v+h*H+l*AA+c*$,t[3]=d*k+u*N+y*_+f*BA,t[7]=d*M+u*b+y*gA+f*iA,t[11]=d*G+u*O+y*CA+f*rA,t[15]=d*v+u*H+y*AA+f*$,this}multiplyScalar(A){let I=this.elements;return I[0]*=A,I[4]*=A,I[8]*=A,I[12]*=A,I[1]*=A,I[5]*=A,I[9]*=A,I[13]*=A,I[2]*=A,I[6]*=A,I[10]*=A,I[14]*=A,I[3]*=A,I[7]*=A,I[11]*=A,I[15]*=A,this}determinant(){let A=this.elements,I=A[0],e=A[4],i=A[8],t=A[12],C=A[1],o=A[5],B=A[9],a=A[13],s=A[2],r=A[6],Q=A[10],E=A[14],n=A[3],h=A[7],l=A[11],c=A[15];return n*(+t*B*r-i*a*r-t*o*Q+e*a*Q+i*o*E-e*B*E)+h*(+I*B*E-I*a*Q+t*C*Q-i*C*E+i*a*s-t*B*s)+l*(+I*a*r-I*o*E-t*C*r+e*C*E+t*o*s-e*a*s)+c*(-i*o*s-I*B*r+I*o*Q+i*C*r-e*C*Q+e*B*s)}transpose(){let A=this.elements,I;return I=A[1],A[1]=A[4],A[4]=I,I=A[2],A[2]=A[8],A[8]=I,I=A[6],A[6]=A[9],A[9]=I,I=A[3],A[3]=A[12],A[12]=I,I=A[7],A[7]=A[13],A[13]=I,I=A[11],A[11]=A[14],A[14]=I,this}setPosition(A,I,e){let i=this.elements;return A.isVector3?(i[12]=A.x,i[13]=A.y,i[14]=A.z):(i[12]=A,i[13]=I,i[14]=e),this}invert(){let A=this.elements,I=A[0],e=A[1],i=A[2],t=A[3],C=A[4],o=A[5],B=A[6],a=A[7],s=A[8],r=A[9],Q=A[10],E=A[11],n=A[12],h=A[13],l=A[14],c=A[15],d=r*l*a-h*Q*a+h*B*E-o*l*E-r*B*c+o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A[10];return Math.sqrt(Math.max(I,e,i))}makeTranslation(A,I,e){return this.set(1,0,0,A,0,1,0,I,0,0,1,e,0,0,0,1),this}makeRotationX(A){let I=Math.cos(A),e=Math.sin(A);return this.set(1,0,0,0,0,I,-e,0,0,e,I,0,0,0,0,1),this}makeRotationY(A){let I=Math.cos(A),e=Math.sin(A);return this.set(I,0,e,0,0,1,0,0,-e,0,I,0,0,0,0,1),this}makeRotationZ(A){let I=Math.cos(A),e=Math.sin(A);return this.set(I,-e,0,0,e,I,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(A,I){let e=Math.cos(I),i=Math.sin(I),t=1-e,C=A.x,o=A.y,B=A.z,a=t*C,s=t*o;return this.set(a*C+e,a*o-i*B,a*B+i*o,0,a*o+i*B,s*o+e,s*B-i*C,0,a*B-i*o,s*B+i*C,t*B*B+e,0,0,0,0,1),this}makeScale(A,I,e){return this.set(A,0,0,0,0,I,0,0,0,0,e,0,0,0,0,1),this}makeShear(A,I,e,i,t,C){return this.set(1,e,t,0,A,1,C,0,I,i,1,0,0,0,0,1),this}compose(A,I,e){let i=this.elements,t=I._x,C=I._y,o=I._z,B=I._w,a=t+t,s=C+C,r=o+o,Q=t*a,E=t*s,n=t*r,h=C*s,l=C*r,c=o*r,d=B*a,u=B*s,y=B*r,f=e.x,k=e.y,M=e.z;return i[0]=(1-(h+c))*f,i[1]=(E+y)*f,i[2]=(n-u)*f,i[3]=0,i[4]=(E-y)*k,i[5]=(1-(Q+c))*k,i[6]=(l+d)*k,i[7]=0,i[8]=(n+u)*M,i[9]=(l-d)*M,i[10]=(1-(Q+h))*M,i[11]=0,i[12]=A.x,i[13]=A.y,i[14]=A.z,i[15]=1,this}decompose(A,I,e){let i=this.elements,t=ls.set(i[0],i[1],i[2]).length(),C=ls.set(i[4],i[5],i[6]).length(),o=ls.set(i[8],i[9],i[10]).length();this.determinant()<0&&(t=-t),A.x=i[12],A.y=i[13],A.z=i[14],hC.copy(this);let B=1/t,a=1/C,s=1/o;return hC.elements[0]*=B,hC.elements[1]*=B,hC.elements[2]*=B,hC.elements[4]*=a,hC.elements[5]*=a,hC.elements[6]*=a,hC.elements[8]*=s,hC.elements[9]*=s,hC.elements[10]*=s,I.setFromRotationMatrix(hC),e.x=t,e.y=C,e.z=o,this}makePerspective(A,I,e,i,t,C){let o=this.elements,B=2*t/(I-A),a=2*t/(e-i),s=(I+A)/(I-A),r=(e+i)/(e-i),Q=-(C+t)/(C-t),E=-2*C*t/(C-t);return o[0]=B,o[4]=0,o[8]=s,o[12]=0,o[1]=0,o[5]=a,o[9]=r,o[13]=0,o[2]=0,o[6]=0,o[10]=Q,o[14]=E,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(A,I,e,i,t,C){let o=this.elements,B=1/(I-A),a=1/(e-i),s=1/(C-t),r=(I+A)*B,Q=(e+i)*a,E=(C+t)*s;return o[0]=2*B,o[4]=0,o[8]=0,o[12]=-r,o[1]=0,o[5]=2*a,o[9]=0,o[13]=-Q,o[2]=0,o[6]=0,o[10]=-2*s,o[14]=-E,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(A){let I=this.elements,e=A.elements;for(let i=0;i<16;i++)if(I[i]!==e[i])return!1;return!0}fromArray(A,I=0){for(let e=0;e<16;e++)this.elements[e]=A[e+I];return this}toArray(A=[],I=0){let e=this.elements;return A[I]=e[0],A[I+1]=e[1],A[I+2]=e[2],A[I+3]=e[3],A[I+4]=e[4],A[I+5]=e[5],A[I+6]=e[6],A[I+7]=e[7],A[I+8]=e[8],A[I+9]=e[9],A[I+10]=e[10],A[I+11]=e[11],A[I+12]=e[12],A[I+13]=e[13],A[I+14]=e[14],A[I+15]=e[15],A}},ls=new J,hC=new zA,YL=new J(0,0,0),xL=new J(1,1,1),HB=new J,Rh=new J,Gt=new J,Lf=new zA,bf=new QI,Ei=class{constructor(A=0,I=0,e=0,i=Ei.DEFAULT_ORDER){this.isEuler=!0,this._x=A,this._y=I,this._z=e,this._order=i}get x(){return this._x}set x(A){this._x=A,this._onChangeCallback()}get y(){return this._y}set y(A){this._y=A,this._onChangeCallback()}get z(){return this._z}set z(A){this._z=A,this._onChangeCallback()}get order(){return this._order}set order(A){this._order=A,this._onChangeCallback()}set(A,I,e,i=this._order){return this._x=A,this._y=I,this._z=e,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(A){return this._x=A._x,this._y=A._y,this._z=A._z,this._order=A._order,this._onChangeCallback(),this}setFromRotationMatrix(A,I=this._order,e=!0){let i=A.elements,t=i[0],C=i[4],o=i[8],B=i[1],a=i[5],s=i[9],r=i[2],Q=i[6],E=i[10];switch(I){case"XYZ":this._y=Math.asin(ii(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-s,E),this._z=Math.atan2(-C,t)):(this._x=Math.atan2(Q,a),this._z=0);break;case"YXZ":this._x=Math.asin(-ii(s,-1,1)),Math.abs(s)<.9999999?(this._y=Math.atan2(o,E),this._z=Math.atan2(B,a)):(this._y=Math.atan2(-r,t),this._z=0);break;case"ZXY":this._x=Math.asin(ii(Q,-1,1)),Math.abs(Q)<.9999999?(this._y=Math.atan2(-r,E),this._z=Math.atan2(-C,a)):(this._y=0,this._z=Math.atan2(B,t));break;case"ZYX":this._y=Math.asin(-ii(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(Q,E),this._z=Math.atan2(B,t)):(this._x=0,this._z=Math.atan2(-C,a));break;case"YZX":this._z=Math.asin(ii(B,-1,1)),Math.abs(B)<.9999999?(this._x=Math.atan2(-s,a),this._y=Math.atan2(-r,t)):(this._x=0,this._y=Math.atan2(o,E));break;case"XZY":this._z=Math.asin(-ii(C,-1,1)),Math.abs(C)<.9999999?(this._x=Math.atan2(Q,a),this._y=Math.atan2(o,t)):(this._x=Math.atan2(-s,E),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+I)}return this._order=I,e===!0&&this._onChangeCallback(),this}setFromQuaternion(A,I,e){return Lf.makeRotationFromQuaternion(A),this.setFromRotationMatrix(Lf,I,e)}setFromVector3(A,I=this._order){return this.set(A.x,A.y,A.z,I)}reorder(A){return bf.setFromEuler(this),this.setFromQuaternion(bf,A)}equals(A){return A._x===this._x&&A._y===this._y&&A._z===this._z&&A._order===this._order}fromArray(A){return this._x=A[0],this._y=A[1],this._z=A[2],A[3]!==void 0&&(this._order=A[3]),this._onChangeCallback(),this}toArray(A=[],I=0){return A[I]=this._x,A[I+1]=this._y,A[I+2]=this._z,A[I+3]=this._order,A}_onChange(A){return this._onChangeCallback=A,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ei.DEFAULT_ORDER="XYZ";var bw=class{constructor(){this.mask=1}set(g){this.mask=(1<>>0}enable(g){this.mask|=1<1){for(let I=0;I1){for(let e=0;e0&&(e=e.concat(C))}return e}getWorldPosition(A){return this.updateWorldMatrix(!0,!1),A.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(A){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uE,A,TL),A}getWorldScale(A){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uE,OL,A),A}getWorldDirection(A){this.updateWorldMatrix(!0,!1);let I=this.matrixWorld.elements;return A.set(I[8],I[9],I[10]).normalize()}raycast(){}traverse(A){A(this);let I=this.children;for(let e=0,i=I.length;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function t(o,B){return o[B.uuid]===void 0&&(o[B.uuid]=B.toJSON(A)),B.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(A).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(A).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=t(A.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let B=o.shapes;if(Array.isArray(B))for(let a=0,s=B.length;a0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(e.geometries=o),B.length>0&&(e.materials=B),a.length>0&&(e.textures=a),s.length>0&&(e.images=s),r.length>0&&(e.shapes=r),Q.length>0&&(e.skeletons=Q),E.length>0&&(e.animations=E),n.length>0&&(e.nodes=n)}return e.object=i,e;function C(o){let B=[];for(let a in o){let s=o[a];delete s.metadata,B.push(s)}return B}}clone(A){return new this.constructor().copy(this,A)}copy(A,I=!0){if(this.name=A.name,this.up.copy(A.up),this.position.copy(A.position),this.rotation.order=A.rotation.order,this.quaternion.copy(A.quaternion),this.scale.copy(A.scale),this.matrix.copy(A.matrix),this.matrixWorld.copy(A.matrixWorld),this.matrixAutoUpdate=A.matrixAutoUpdate,this.matrixWorldNeedsUpdate=A.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=A.matrixWorldAutoUpdate,this.layers.mask=A.layers.mask,this.visible=A.visible,this.castShadow=A.castShadow,this.receiveShadow=A.receiveShadow,this.frustumCulled=A.frustumCulled,this.renderOrder=A.renderOrder,this.userData=JSON.parse(JSON.stringify(A.userData)),I===!0)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(t)):i.set(0,0,0)}static getBarycoord(A,I,e,i,t){lC.subVectors(i,I),Xo.subVectors(e,I),Wd.subVectors(A,I);let C=lC.dot(lC),o=lC.dot(Xo),B=lC.dot(Wd),a=Xo.dot(Xo),s=Xo.dot(Wd),r=C*a-o*o;if(r===0)return t.set(-2,-1,-1);let Q=1/r,E=(a*B-o*s)*Q,n=(C*s-o*B)*Q;return t.set(1-E-n,n,E)}static containsPoint(A,I,e,i){return this.getBarycoord(A,I,e,i,$o),$o.x>=0&&$o.y>=0&&$o.x+$o.y<=1}static getUV(A,I,e,i,t,C,o,B){return this.getBarycoord(A,I,e,i,$o),B.set(0,0),B.addScaledVector(t,$o.x),B.addScaledVector(C,$o.y),B.addScaledVector(o,$o.z),B}static isFrontFacing(A,I,e,i){return lC.subVectors(e,I),Xo.subVectors(A,I),lC.cross(Xo).dot(i)<0}set(A,I,e){return this.a.copy(A),this.b.copy(I),this.c.copy(e),this}setFromPointsAndIndices(A,I,e,i){return this.a.copy(A[I]),this.b.copy(A[e]),this.c.copy(A[i]),this}setFromAttributeAndIndices(A,I,e,i){return this.a.fromBufferAttribute(A,I),this.b.fromBufferAttribute(A,e),this.c.fromBufferAttribute(A,i),this}clone(){return new this.constructor().copy(this)}copy(A){return this.a.copy(A.a),this.b.copy(A.b),this.c.copy(A.c),this}getArea(){return lC.subVectors(this.c,this.b),Xo.subVectors(this.a,this.b),lC.cross(Xo).length()*.5}getMidpoint(A){return A.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(A){return Ni.getNormal(this.a,this.b,this.c,A)}getPlane(A){return A.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(A,I){return Ni.getBarycoord(A,this.a,this.b,this.c,I)}getUV(A,I,e,i,t){return Ni.getUV(A,this.a,this.b,this.c,I,e,i,t)}containsPoint(A){return Ni.containsPoint(A,this.a,this.b,this.c)}isFrontFacing(A){return Ni.isFrontFacing(this.a,this.b,this.c,A)}intersectsBox(A){return A.intersectsTriangle(this)}closestPointToPoint(A,I){let e=this.a,i=this.b,t=this.c,C,o;Ds.subVectors(i,e),ds.subVectors(t,e),Zd.subVectors(A,e);let B=Ds.dot(Zd),a=ds.dot(Zd);if(B<=0&&a<=0)return I.copy(e);Vd.subVectors(A,i);let s=Ds.dot(Vd),r=ds.dot(Vd);if(s>=0&&r<=s)return I.copy(i);let Q=B*r-s*a;if(Q<=0&&B>=0&&s<=0)return C=B/(B-s),I.copy(e).addScaledVector(Ds,C);zd.subVectors(A,t);let E=Ds.dot(zd),n=ds.dot(zd);if(n>=0&&E<=n)return I.copy(t);let h=E*a-B*n;if(h<=0&&a>=0&&n<=0)return o=a/(a-n),I.copy(e).addScaledVector(ds,o);let l=s*n-E*r;if(l<=0&&r-s>=0&&E-n>=0)return _f.subVectors(t,i),o=(r-s)/(r-s+(E-n)),I.copy(i).addScaledVector(_f,o);let c=1/(l+h+Q);return C=h*c,o=Q*c,I.copy(e).addScaledVector(Ds,C).addScaledVector(ds,o)}equals(A){return A.a.equals(this.a)&&A.b.equals(this.b)&&A.c.equals(this.c)}},PL=0,zn=class extends Si{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:PL++}),this.uuid=IC(),this.name="",this.type="Material",this.blending=oQ,this.side=RC,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=yN,this.blendDst=wN,this.blendEquation=Ps,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=qp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pL,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vd,this.stencilZFail=vd,this.stencilZPass=vd,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(g){this._alphaTest>0!=g>0&&this.version++,this._alphaTest=g}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(g){if(g!==void 0)for(let A in g){let I=g[A];if(I===void 0){console.warn("THREE.Material: '"+A+"' parameter is undefined.");continue}let e=this[A];if(e===void 0){console.warn("THREE."+this.type+": '"+A+"' is not a property of this material.");continue}e&&e.isColor?e.set(I):e&&e.isVector3&&I&&I.isVector3?e.copy(I):this[A]=I}}toJSON(g){let A=g===void 0||typeof g=="string";A&&(g={textures:{},images:{}});let I={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};I.uuid=this.uuid,I.type=this.type,this.name!==""&&(I.name=this.name),this.color&&this.color.isColor&&(I.color=this.color.getHex()),this.roughness!==void 0&&(I.roughness=this.roughness),this.metalness!==void 0&&(I.metalness=this.metalness),this.sheen!==void 0&&(I.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(I.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(I.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(I.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(I.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(I.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(I.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(I.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(I.shininess=this.shininess),this.clearcoat!==void 0&&(I.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(I.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(I.clearcoatMap=this.clearcoatMap.toJSON(g).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(I.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(g).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(I.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(g).uuid,I.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(I.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(I.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(I.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(I.iridescenceMap=this.iridescenceMap.toJSON(g).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(I.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(g).uuid),this.map&&this.map.isTexture&&(I.map=this.map.toJSON(g).uuid),this.matcap&&this.matcap.isTexture&&(I.matcap=this.matcap.toJSON(g).uuid),this.alphaMap&&this.alphaMap.isTexture&&(I.alphaMap=this.alphaMap.toJSON(g).uuid),this.lightMap&&this.lightMap.isTexture&&(I.lightMap=this.lightMap.toJSON(g).uuid,I.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(I.aoMap=this.aoMap.toJSON(g).uuid,I.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(I.bumpMap=this.bumpMap.toJSON(g).uuid,I.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(I.normalMap=this.normalMap.toJSON(g).uuid,I.normalMapType=this.normalMapType,I.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(I.displacementMap=this.displacementMap.toJSON(g).uuid,I.displacementScale=this.displacementScale,I.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(I.roughnessMap=this.roughnessMap.toJSON(g).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(I.metalnessMap=this.metalnessMap.toJSON(g).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(I.emissiveMap=this.emissiveMap.toJSON(g).uuid),this.specularMap&&this.specularMap.isTexture&&(I.specularMap=this.specularMap.toJSON(g).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(I.specularIntensityMap=this.specularIntensityMap.toJSON(g).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(I.specularColorMap=this.specularColorMap.toJSON(g).uuid),this.envMap&&this.envMap.isTexture&&(I.envMap=this.envMap.toJSON(g).uuid,this.combine!==void 0&&(I.combine=this.combine)),this.envMapIntensity!==void 0&&(I.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(I.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(I.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(I.gradientMap=this.gradientMap.toJSON(g).uuid),this.transmission!==void 0&&(I.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(I.transmissionMap=this.transmissionMap.toJSON(g).uuid),this.thickness!==void 0&&(I.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(I.thicknessMap=this.thicknessMap.toJSON(g).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(I.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(I.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(I.size=this.size),this.shadowSide!==null&&(I.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(I.sizeAttenuation=this.sizeAttenuation),this.blending!==oQ&&(I.blending=this.blending),this.side!==RC&&(I.side=this.side),this.vertexColors&&(I.vertexColors=!0),this.opacity<1&&(I.opacity=this.opacity),this.transparent===!0&&(I.transparent=this.transparent),I.depthFunc=this.depthFunc,I.depthTest=this.depthTest,I.depthWrite=this.depthWrite,I.colorWrite=this.colorWrite,I.stencilWrite=this.stencilWrite,I.stencilWriteMask=this.stencilWriteMask,I.stencilFunc=this.stencilFunc,I.stencilRef=this.stencilRef,I.stencilFuncMask=this.stencilFuncMask,I.stencilFail=this.stencilFail,I.stencilZFail=this.stencilZFail,I.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(I.rotation=this.rotation),this.polygonOffset===!0&&(I.polygonOffset=!0),this.polygonOffsetFactor!==0&&(I.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(I.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(I.linewidth=this.linewidth),this.dashSize!==void 0&&(I.dashSize=this.dashSize),this.gapSize!==void 0&&(I.gapSize=this.gapSize),this.scale!==void 0&&(I.scale=this.scale),this.dithering===!0&&(I.dithering=!0),this.alphaTest>0&&(I.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(I.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(I.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(I.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(I.wireframe=this.wireframe),this.wireframeLinewidth>1&&(I.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(I.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(I.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(I.flatShading=this.flatShading),this.visible===!1&&(I.visible=!1),this.toneMapped===!1&&(I.toneMapped=!1),this.fog===!1&&(I.fog=!1),Object.keys(this.userData).length>0&&(I.userData=this.userData);function e(i){let t=[];for(let C in i){let o=i[C];delete o.metadata,t.push(o)}return t}if(A){let i=e(g.textures),t=e(g.images);i.length>0&&(I.textures=i),t.length>0&&(I.images=t)}return I}clone(){return new this.constructor().copy(this)}copy(g){this.name=g.name,this.blending=g.blending,this.side=g.side,this.vertexColors=g.vertexColors,this.opacity=g.opacity,this.transparent=g.transparent,this.blendSrc=g.blendSrc,this.blendDst=g.blendDst,this.blendEquation=g.blendEquation,this.blendSrcAlpha=g.blendSrcAlpha,this.blendDstAlpha=g.blendDstAlpha,this.blendEquationAlpha=g.blendEquationAlpha,this.depthFunc=g.depthFunc,this.depthTest=g.depthTest,this.depthWrite=g.depthWrite,this.stencilWriteMask=g.stencilWriteMask,this.stencilFunc=g.stencilFunc,this.stencilRef=g.stencilRef,this.stencilFuncMask=g.stencilFuncMask,this.stencilFail=g.stencilFail,this.stencilZFail=g.stencilZFail,this.stencilZPass=g.stencilZPass,this.stencilWrite=g.stencilWrite;let A=g.clippingPlanes,I=null;if(A!==null){let e=A.length;I=new Array(e);for(let i=0;i!==e;++i)I[i]=A[i].clone()}return this.clippingPlanes=I,this.clipIntersection=g.clipIntersection,this.clipShadows=g.clipShadows,this.shadowSide=g.shadowSide,this.colorWrite=g.colorWrite,this.precision=g.precision,this.polygonOffset=g.polygonOffset,this.polygonOffsetFactor=g.polygonOffsetFactor,this.polygonOffsetUnits=g.polygonOffsetUnits,this.dithering=g.dithering,this.alphaTest=g.alphaTest,this.alphaToCoverage=g.alphaToCoverage,this.premultipliedAlpha=g.premultipliedAlpha,this.forceSinglePass=g.forceSinglePass,this.visible=g.visible,this.toneMapped=g.toneMapped,this.userData=JSON.parse(JSON.stringify(g.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(g){g===!0&&this.version++}},Xn=class extends zn{constructor(A){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Og(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=SN,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.specularMap=A.specularMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.combine=A.combine,this.reflectivity=A.reflectivity,this.refractionRatio=A.refractionRatio,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.fog=A.fog,this}},He=new J,Jh=new sA,zg=class{constructor(g,A,I=!1){if(Array.isArray(g))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=g,this.itemSize=A,this.count=g!==void 0?g.length/A:0,this.normalized=I,this.usage=xp,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(g){g===!0&&this.version++}setUsage(g){return this.usage=g,this}copy(g){return this.name=g.name,this.array=new g.array.constructor(g.array),this.itemSize=g.itemSize,this.count=g.count,this.normalized=g.normalized,this.usage=g.usage,this}copyAt(g,A,I){g*=this.itemSize,I*=A.itemSize;for(let e=0,i=this.itemSize;e0&&(A.userData=this.userData),this.parameters!==void 0){let B=this.parameters;for(let a in B)B[a]!==void 0&&(A[a]=B[a]);return A}A.data={attributes:{}};let I=this.index;I!==null&&(A.data.index={type:I.array.constructor.name,array:Array.prototype.slice.call(I.array)});let e=this.attributes;for(let B in e){let a=e[B];A.data.attributes[B]=a.toJSON(A.data)}let i={},t=!1;for(let B in this.morphAttributes){let a=this.morphAttributes[B],s=[];for(let r=0,Q=a.length;r0&&(i[B]=s,t=!0)}t&&(A.data.morphAttributes=i,A.data.morphTargetsRelative=this.morphTargetsRelative);let C=this.groups;C.length>0&&(A.data.groups=JSON.parse(JSON.stringify(C)));let o=this.boundingSphere;return o!==null&&(A.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),A}clone(){return new this.constructor().copy(this)}copy(A){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let I={};this.name=A.name;let e=A.index;e!==null&&this.setIndex(e.clone(I));let i=A.attributes;for(let a in i){let s=i[a];this.setAttribute(a,s.clone(I))}let t=A.morphAttributes;for(let a in t){let s=[],r=t[a];for(let Q=0,E=r.length;Q0){let e=A[I[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,t=e.length;iI.far?null:{distance:a,point:Yh.clone(),object:g}}function xh(g,A,I,e,i,t,C,o,B){g.getVertexPosition(C,yE),g.getVertexPosition(o,wE),g.getVertexPosition(B,SE);let a=WL(g,A,I,e,yE,wE,SE,gu);if(a){i&&(qh.fromBufferAttribute(i,C),Lh.fromBufferAttribute(i,o),bh.fromBufferAttribute(i,B),a.uv=Ni.getUV(gu,yE,wE,SE,qh,Lh,bh,new sA)),t&&(qh.fromBufferAttribute(t,C),Lh.fromBufferAttribute(t,o),bh.fromBufferAttribute(t,B),a.uv2=Ni.getUV(gu,yE,wE,SE,qh,Lh,bh,new sA));let s={a:C,b:o,c:B,normal:new J,materialIndex:0};Ni.getNormal(yE,wE,SE,s.normal),a.face=s}return a}var Go=class extends bg{constructor(A=1,I=1,e=1,i=1,t=1,C=1){super(),this.type="BoxGeometry",this.parameters={width:A,height:I,depth:e,widthSegments:i,heightSegments:t,depthSegments:C};let o=this;i=Math.floor(i),t=Math.floor(t),C=Math.floor(C);let B=[],a=[],s=[],r=[],Q=0,E=0;n("z","y","x",-1,-1,e,I,A,C,t,0),n("z","y","x",1,-1,e,I,-A,C,t,1),n("x","z","y",1,1,A,e,I,i,C,2),n("x","z","y",1,-1,A,e,-I,i,C,3),n("x","y","z",1,-1,A,I,e,i,t,4),n("x","y","z",-1,-1,A,I,-e,i,t,5),this.setIndex(B),this.setAttribute("position",new pg(a,3)),this.setAttribute("normal",new pg(s,3)),this.setAttribute("uv",new pg(r,2));function n(h,l,c,d,u,y,f,k,M,G,v){let N=y/M,b=f/G,O=y/2,H=f/2,_=k/2,gA=M+1,CA=G+1,AA=0,BA=0,iA=new J;for(let rA=0;rA0?1:-1,s.push(iA.x,iA.y,iA.z),r.push(IA/M),r.push(1-rA/G),AA+=1}}for(let rA=0;rA0&&(I.defines=this.defines),I.vertexShader=this.vertexShader,I.fragmentShader=this.fragmentShader;let e={};for(let i in this.extensions)this.extensions[i]===!0&&(e[i]=!0);return Object.keys(e).length>0&&(I.extensions=e),I}},ZQ=class extends ZI{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zA,this.projectionMatrix=new zA,this.projectionMatrixInverse=new zA}copy(A,I){return super.copy(A,I),this.matrixWorldInverse.copy(A.matrixWorldInverse),this.projectionMatrix.copy(A.projectionMatrix),this.projectionMatrixInverse.copy(A.projectionMatrixInverse),this}getWorldDirection(A){this.updateWorldMatrix(!0,!1);let I=this.matrixWorld.elements;return A.set(-I[8],-I[9],-I[10]).normalize()}updateMatrixWorld(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,I){super.updateWorldMatrix(A,I),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Ui=class extends ZQ{constructor(A=50,I=1,e=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=A,this.zoom=1,this.near=e,this.far=i,this.focus=10,this.aspect=I,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(A,I){return super.copy(A,I),this.fov=A.fov,this.zoom=A.zoom,this.near=A.near,this.far=A.far,this.focus=A.focus,this.aspect=A.aspect,this.view=A.view===null?null:Object.assign({},A.view),this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this}setFocalLength(A){let I=.5*this.getFilmHeight()/A;this.fov=dn*2*Math.atan(I),this.updateProjectionMatrix()}getFocalLength(){let A=Math.tan(en*.5*this.fov);return .5*this.getFilmHeight()/A}getEffectiveFOV(){return dn*2*Math.atan(Math.tan(en*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(A,I,e,i,t,C){this.aspect=A/I,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=A,this.view.fullHeight=I,this.view.offsetX=e,this.view.offsetY=i,this.view.width=t,this.view.height=C,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let A=this.near,I=A*Math.tan(en*.5*this.fov)/this.zoom,e=2*I,i=this.aspect*e,t=-.5*i,C=this.view;if(this.view!==null&&this.view.enabled){let B=C.fullWidth,a=C.fullHeight;t+=C.offsetX*i/B,I-=C.offsetY*e/a,i*=C.width/B,e*=C.height/a}let o=this.filmOffset;o!==0&&(t+=A*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(t,t+i,I,I-e,A,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(A){let I=super.toJSON(A);return I.object.fov=this.fov,I.object.zoom=this.zoom,I.object.near=this.near,I.object.far=this.far,I.object.focus=this.focus,I.object.aspect=this.aspect,this.view!==null&&(I.object.view=Object.assign({},this.view)),I.object.filmGauge=this.filmGauge,I.object.filmOffset=this.filmOffset,I}},ys=-90,ws=1,XL=class extends ZI{constructor(g,A,I){super(),this.type="CubeCamera",this.renderTarget=I;let e=new Ui(ys,ws,g,A);e.layers=this.layers,e.up.set(0,1,0),e.lookAt(1,0,0),this.add(e);let i=new Ui(ys,ws,g,A);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(-1,0,0),this.add(i);let t=new Ui(ys,ws,g,A);t.layers=this.layers,t.up.set(0,0,-1),t.lookAt(0,1,0),this.add(t);let C=new Ui(ys,ws,g,A);C.layers=this.layers,C.up.set(0,0,1),C.lookAt(0,-1,0),this.add(C);let o=new Ui(ys,ws,g,A);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(0,0,1),this.add(o);let B=new Ui(ys,ws,g,A);B.layers=this.layers,B.up.set(0,1,0),B.lookAt(0,0,-1),this.add(B)}update(g,A){this.parent===null&&this.updateMatrixWorld();let I=this.renderTarget,[e,i,t,C,o,B]=this.children,a=g.getRenderTarget(),s=g.toneMapping,r=g.xr.enabled;g.toneMapping=DB,g.xr.enabled=!1;let Q=I.texture.generateMipmaps;I.texture.generateMipmaps=!1,g.setRenderTarget(I,0),g.render(A,e),g.setRenderTarget(I,1),g.render(A,i),g.setRenderTarget(I,2),g.render(A,t),g.setRenderTarget(I,3),g.render(A,C),g.setRenderTarget(I,4),g.render(A,o),I.texture.generateMipmaps=Q,g.setRenderTarget(I,5),g.render(A,B),g.setRenderTarget(a),g.toneMapping=s,g.xr.enabled=r,I.texture.needsPMREMUpdate=!0}},Yw=class extends ti{constructor(g,A,I,e,i,t,C,o,B,a){g=g!==void 0?g:[],A=A!==void 0?A:Ur,super(g,A,I,e,i,t,C,o,B,a),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(g){this.image=g}},$L=class extends WI{constructor(g=1,A={}){super(g,g,A),this.isWebGLCubeRenderTarget=!0;let I={width:g,height:g,depth:1},e=[I,I,I,I,I,I];this.texture=new Yw(e,A.mapping,A.wrapS,A.wrapT,A.magFilter,A.minFilter,A.format,A.type,A.anisotropy,A.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=A.generateMipmaps!==void 0?A.generateMipmaps:!1,this.texture.minFilter=A.minFilter!==void 0?A.minFilter:cI}fromEquirectangularTexture(g,A){this.texture.type=A.type,this.texture.encoding=A.encoding,this.texture.generateMipmaps=A.generateMipmaps,this.texture.minFilter=A.minFilter,this.texture.magFilter=A.magFilter;let I={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},e=new Go(5,5,5),i=new te({name:"CubemapFromEquirect",uniforms:GQ(I.uniforms),vertexShader:I.vertexShader,fragmentShader:I.fragmentShader,side:ni,blending:je});i.uniforms.tEquirect.value=A;let t=new Qt(e,i),C=A.minFilter;return A.minFilter===SQ&&(A.minFilter=cI),new XL(1,10,this).update(g,t),A.minFilter=C,t.geometry.dispose(),t.material.dispose(),this}clear(g,A,I,e){let i=g.getRenderTarget();for(let t=0;t<6;t++)g.setRenderTarget(this,t),g.clear(A,I,e);g.setRenderTarget(i)}},Iu=new J,Ab=new J,gb=new hi,Nt=class{constructor(A=new J(1,0,0),I=0){this.isPlane=!0,this.normal=A,this.constant=I}set(A,I){return this.normal.copy(A),this.constant=I,this}setComponents(A,I,e,i){return this.normal.set(A,I,e),this.constant=i,this}setFromNormalAndCoplanarPoint(A,I){return this.normal.copy(A),this.constant=-I.dot(this.normal),this}setFromCoplanarPoints(A,I,e){let i=Iu.subVectors(e,I).cross(Ab.subVectors(A,I)).normalize();return this.setFromNormalAndCoplanarPoint(i,A),this}copy(A){return this.normal.copy(A.normal),this.constant=A.constant,this}normalize(){let A=1/this.normal.length();return this.normal.multiplyScalar(A),this.constant*=A,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(A){return this.normal.dot(A)+this.constant}distanceToSphere(A){return this.distanceToPoint(A.center)-A.radius}projectPoint(A,I){return I.copy(this.normal).multiplyScalar(-this.distanceToPoint(A)).add(A)}intersectLine(A,I){let e=A.delta(Iu),i=this.normal.dot(e);if(i===0)return this.distanceToPoint(A.start)===0?I.copy(A.start):null;let t=-(A.start.dot(this.normal)+this.constant)/i;return t<0||t>1?null:I.copy(e).multiplyScalar(t).add(A.start)}intersectsLine(A){let I=this.distanceToPoint(A.start),e=this.distanceToPoint(A.end);return I<0&&e>0||e<0&&I>0}intersectsBox(A){return A.intersectsPlane(this)}intersectsSphere(A){return A.intersectsPlane(this)}coplanarPoint(A){return A.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(A,I){let e=I||gb.getNormalMatrix(A),i=this.coplanarPoint(Iu).applyMatrix4(A),t=this.normal.applyMatrix3(e).normalize();return this.constant=-i.dot(t),this}translate(A){return this.constant-=A.dot(this.normal),this}equals(A){return A.normal.equals(this.normal)&&A.constant===this.constant}clone(){return new this.constructor().copy(this)}},Ss=new ct,Hh=new J,xw=class{constructor(g=new Nt,A=new Nt,I=new Nt,e=new Nt,i=new Nt,t=new Nt){this.planes=[g,A,I,e,i,t]}set(g,A,I,e,i,t){let C=this.planes;return C[0].copy(g),C[1].copy(A),C[2].copy(I),C[3].copy(e),C[4].copy(i),C[5].copy(t),this}copy(g){let A=this.planes;for(let I=0;I<6;I++)A[I].copy(g.planes[I]);return this}setFromProjectionMatrix(g){let A=this.planes,I=g.elements,e=I[0],i=I[1],t=I[2],C=I[3],o=I[4],B=I[5],a=I[6],s=I[7],r=I[8],Q=I[9],E=I[10],n=I[11],h=I[12],l=I[13],c=I[14],d=I[15];return A[0].setComponents(C-e,s-o,n-r,d-h).normalize(),A[1].setComponents(C+e,s+o,n+r,d+h).normalize(),A[2].setComponents(C+i,s+B,n+Q,d+l).normalize(),A[3].setComponents(C-i,s-B,n-Q,d-l).normalize(),A[4].setComponents(C-t,s-a,n-E,d-c).normalize(),A[5].setComponents(C+t,s+a,n+E,d+c).normalize(),this}intersectsObject(g){let A=g.geometry;return A.boundingSphere===null&&A.computeBoundingSphere(),Ss.copy(A.boundingSphere).applyMatrix4(g.matrixWorld),this.intersectsSphere(Ss)}intersectsSprite(g){return Ss.center.set(0,0,0),Ss.radius=.7071067811865476,Ss.applyMatrix4(g.matrixWorld),this.intersectsSphere(Ss)}intersectsSphere(g){let A=this.planes,I=g.center,e=-g.radius;for(let i=0;i<6;i++)if(A[i].distanceToPoint(I)0?g.max.x:g.min.x,Hh.y=e.normal.y>0?g.max.y:g.min.y,Hh.z=e.normal.z>0?g.max.z:g.min.z,e.distanceToPoint(Hh)<0)return!1}return!0}containsPoint(g){let A=this.planes;for(let I=0;I<6;I++)if(A[I].distanceToPoint(g)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function bN(){let g=null,A=!1,I=null,e=null;function i(t,C){I(t,C),e=g.requestAnimationFrame(i)}return{start:function(){A!==!0&&I!==null&&(e=g.requestAnimationFrame(i),A=!0)},stop:function(){g.cancelAnimationFrame(e),A=!1},setAnimationLoop:function(t){I=t},setContext:function(t){g=t}}}function Ib(g,A){let I=A.isWebGL2,e=new WeakMap;function i(a,s){let r=a.array,Q=a.usage,E=g.createBuffer();g.bindBuffer(s,E),g.bufferData(s,r,Q),a.onUploadCallback();let n;if(r instanceof Float32Array)n=5126;else if(r instanceof Uint16Array)if(a.isFloat16BufferAttribute)if(I)n=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else n=5123;else if(r instanceof Int16Array)n=5122;else if(r instanceof Uint32Array)n=5125;else if(r instanceof Int32Array)n=5124;else if(r instanceof Int8Array)n=5120;else if(r instanceof Uint8Array)n=5121;else if(r instanceof Uint8ClampedArray)n=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);return{buffer:E,type:n,bytesPerElement:r.BYTES_PER_ELEMENT,version:a.version}}function t(a,s,r){let Q=s.array,E=s.updateRange;g.bindBuffer(r,a),E.count===-1?g.bufferSubData(r,0,Q):(I?g.bufferSubData(r,E.offset*Q.BYTES_PER_ELEMENT,Q,E.offset,E.count):g.bufferSubData(r,E.offset*Q.BYTES_PER_ELEMENT,Q.subarray(E.offset,E.offset+E.count)),E.count=-1),s.onUploadCallback()}function C(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function o(a){a.isInterleavedBufferAttribute&&(a=a.data);let s=e.get(a);s&&(g.deleteBuffer(s.buffer),e.delete(a))}function B(a,s){if(a.isGLBufferAttribute){let Q=e.get(a);(!Q||Q.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +float G_BlinnPhong_Implicit( ) { + return 0.25; +} +float D_BlinnPhong( const in float shininess, const in float dotNH ) { + return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); +} +vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( specularColor, 1.0, dotVH ); + float G = G_BlinnPhong_Implicit( ); + float D = D_BlinnPhong( shininess, dotNH ); + return F * ( G * D ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif`,Qb=`#ifdef USE_IRIDESCENCE + const mat3 XYZ_TO_REC709 = mat3( + 3.2404542, -0.9692660, 0.0556434, + -1.5371385, 1.8760108, -0.2040259, + -0.4985314, 0.0415560, 1.0572252 + ); + vec3 Fresnel0ToIor( vec3 fresnel0 ) { + vec3 sqrtF0 = sqrt( fresnel0 ); + return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); + } + vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); + } + float IorToFresnel0( float transmittedIor, float incidentIor ) { + return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); + } + vec3 evalSensitivity( float OPD, vec3 shift ) { + float phase = 2.0 * PI * OPD * 1.0e-9; + vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); + vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); + vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); + vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); + xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); + xyz /= 1.0685e-7; + vec3 rgb = XYZ_TO_REC709 * xyz; + return rgb; + } + vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { + vec3 I; + float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); + float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); + float cosTheta2Sq = 1.0 - sinTheta2Sq; + if ( cosTheta2Sq < 0.0 ) { + return vec3( 1.0 ); + } + float cosTheta2 = sqrt( cosTheta2Sq ); + float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); + float R12 = F_Schlick( R0, 1.0, cosTheta1 ); + float R21 = R12; + float T121 = 1.0 - R12; + float phi12 = 0.0; + if ( iridescenceIOR < outsideIOR ) phi12 = PI; + float phi21 = PI - phi12; + vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); + vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); + vec3 phi23 = vec3( 0.0 ); + if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; + if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; + if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; + float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; + vec3 phi = vec3( phi21 ) + phi23; + vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); + vec3 r123 = sqrt( R123 ); + vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); + vec3 C0 = R12 + Rs; + I = C0; + vec3 Cm = Rs - T121; + for ( int m = 1; m <= 2; ++ m ) { + Cm *= r123; + vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); + I += Cm * Sm; + } + return max( I, vec3( 0.0 ) ); + } +#endif`,Eb=`#ifdef USE_BUMPMAP + uniform sampler2D bumpMap; + uniform float bumpScale; + vec2 dHdxy_fwd() { + vec2 dSTdx = dFdx( vUv ); + vec2 dSTdy = dFdy( vUv ); + float Hll = bumpScale * texture2D( bumpMap, vUv ).x; + float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; + float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; + return vec2( dBx, dBy ); + } + vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { + vec3 vSigmaX = dFdx( surf_pos.xyz ); + vec3 vSigmaY = dFdy( surf_pos.xyz ); + vec3 vN = surf_norm; + vec3 R1 = cross( vSigmaY, vN ); + vec3 R2 = cross( vN, vSigmaX ); + float fDet = dot( vSigmaX, R1 ) * faceDirection; + vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); + return normalize( abs( fDet ) * surf_norm - vGrad ); + } +#endif`,nb=`#if NUM_CLIPPING_PLANES > 0 + vec4 plane; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif +#endif`,hb=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,lb=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,cb=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,Db=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,db=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,ub=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,pb=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif`,yb=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +struct GeometricContext { + vec3 position; + vec3 normal; + vec3 viewDir; +#ifdef USE_CLEARCOAT + vec3 clearcoatNormal; +#endif +}; +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +}`,wb=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_v0 0.339 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_v1 0.276 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_v4 0.046 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_v5 0.016 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_v6 0.0038 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Sb=`vec3 transformedNormal = objectNormal; +#ifdef USE_INSTANCING + mat3 m = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); + transformedNormal = m * transformedNormal; +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,fb=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Gb=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); +#endif`,kb=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Mb=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,mb="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ub=`vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,Nb=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,Fb=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,Rb=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Kb=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Jb=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,vb=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,qb=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Lb=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,bb=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Yb=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,xb=`#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`,Hb=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Tb=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Ob=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,_b=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +uniform vec3 lightProbe[ 9 ]; +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + #if defined ( PHYSICALLY_CORRECT_LIGHTS ) + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; + #else + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + } + return 1.0; + #endif +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometry.position; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometry.position; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,Pb=`#if defined( USE_ENVMAP ) + vec3 getIBLIrradiance( const in vec3 normal ) { + #if defined( ENVMAP_TYPE_CUBE_UV ) + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #if defined( ENVMAP_TYPE_CUBE_UV ) + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } +#endif`,jb=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Wb=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Zb=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Vb=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,zb=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULARINTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; + #endif + #ifdef USE_SPECULARCOLORMAP + specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEENCOLORMAP + material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEENROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; + #endif +#endif`,Xb=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif +}; +vec3 clearcoatSpecular = vec3( 0.0 ); +vec3 sheenSpecular = vec3( 0.0 ); +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometry.normal; + vec3 viewDir = geometry.viewDir; + vec3 position = geometry.position; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); + #endif + #ifdef USE_IRIDESCENCE + reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); + #else + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); + #endif + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,$b=` +GeometricContext geometry; +geometry.position = - vViewPosition; +geometry.normal = normal; +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +#ifdef USE_CLEARCOAT + geometry.clearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometry.viewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometry, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, geometry, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,AY=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometry.normal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,gY=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); +#endif`,IY=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,eY=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,iY=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`,tY=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + #else + if ( isPerspectiveMatrix( projectionMatrix ) ) { + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + gl_Position.z *= gl_Position.w; + } + #endif +#endif`,CY=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,oY=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,BY=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,aY=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,rY=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vUv ); + metalnessFactor *= texelMetalness.b; +#endif`,sY=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,QY=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,EY=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } + #else + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + #endif +#endif`,nY=`#ifdef USE_MORPHTARGETS + uniform float morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } + #else + #ifndef USE_MORPHNORMALS + uniform float morphTargetInfluences[ 8 ]; + #else + uniform float morphTargetInfluences[ 4 ]; + #endif + #endif +#endif`,hY=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + #ifdef MORPHTARGETS_TEXTURE + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } + #else + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + #ifndef USE_MORPHNORMALS + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + #endif + #endif +#endif`,lY=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + #ifdef USE_TANGENT + vec3 tangent = normalize( vTangent ); + vec3 bitangent = normalize( vBitangent ); + #ifdef DOUBLE_SIDED + tangent = tangent * faceDirection; + bitangent = bitangent * faceDirection; + #endif + #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) + mat3 vTBN = mat3( tangent, bitangent, normal ); + #endif + #endif +#endif +vec3 geometryNormal = normal;`,cY=`#ifdef OBJECTSPACE_NORMALMAP + normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( TANGENTSPACE_NORMALMAP ) + vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + #ifdef USE_TANGENT + normal = normalize( vTBN * mapN ); + #else + normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); + #endif +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,DY=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,dY=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,uY=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,pY=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef OBJECTSPACE_NORMALMAP + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) + vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( vUv.st ); + vec2 st1 = dFdy( vUv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + } +#endif`,yY=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = geometryNormal; +#endif`,wY=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + #ifdef USE_TANGENT + clearcoatNormal = normalize( vTBN * clearcoatMapN ); + #else + clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); + #endif +#endif`,SY=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif`,fY=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,GY=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha + 0.1; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,kY=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { + return linearClipZ * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * invClipZ - far ); +}`,MY=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,mY=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,UY=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,NY=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,FY=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vUv ); + roughnessFactor *= texelRoughness.g; +#endif`,RY=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,KY=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return shadow; + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + vec3 lightToPosition = shadowCoord.xyz; + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } +#endif`,JY=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,vY=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,qY=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,LY=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,bY=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + mat4 getBoneMatrix( const in float i ) { + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + y = dy * ( y + 0.5 ); + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + mat4 bone = mat4( v1, v2, v3, v4 ); + return bone; + } +#endif`,YY=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,xY=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,HY=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,TY=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,OY=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,_Y=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return toneMappingExposure * color; +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,PY=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmission = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); +#endif`,jY=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + #ifdef texture2DLodEXT + return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + #else + return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + #endif + } + vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return radiance; + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); + } +#endif`,WY=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif`,ZY=`#ifdef USE_UV + #ifdef UVS_VERTEX_ONLY + vec2 vUv; + #else + varying vec2 vUv; + #endif + uniform mat3 uvTransform; +#endif`,VY=`#ifdef USE_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; +#endif`,zY=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; +#endif`,XY=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; +#endif`,$Y=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; +#endif`,Ax=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,gx=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,Ix=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ex=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,ix=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Cx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,ox=`#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,Bx=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + vec4 diffuseColor = vec4( 1.0 ); + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,ax=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,rx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + #include + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,sx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,Qx=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,Ex=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include +}`,nx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +void main() { + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,hx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,lx=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,cx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Dx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,dx=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,ux=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,px=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + vViewPosition = - mvPosition.xyz; +#endif +}`,yx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,wx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Sx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,fx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Gx=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULARINTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif + #ifdef USE_SPECULARCOLORMAP + uniform sampler2D specularColorMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEENCOLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEENROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,kx=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Mx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,mx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Ux=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Nx=`#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Fx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,Rx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Kx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,nI={alphamap_fragment:eb,alphamap_pars_fragment:ib,alphatest_fragment:tb,alphatest_pars_fragment:Cb,aomap_fragment:ob,aomap_pars_fragment:Bb,begin_vertex:ab,beginnormal_vertex:rb,bsdfs:sb,iridescence_fragment:Qb,bumpmap_pars_fragment:Eb,clipping_planes_fragment:nb,clipping_planes_pars_fragment:hb,clipping_planes_pars_vertex:lb,clipping_planes_vertex:cb,color_fragment:Db,color_pars_fragment:db,color_pars_vertex:ub,color_vertex:pb,common:yb,cube_uv_reflection_fragment:wb,defaultnormal_vertex:Sb,displacementmap_pars_vertex:fb,displacementmap_vertex:Gb,emissivemap_fragment:kb,emissivemap_pars_fragment:Mb,encodings_fragment:mb,encodings_pars_fragment:Ub,envmap_fragment:Nb,envmap_common_pars_fragment:Fb,envmap_pars_fragment:Rb,envmap_pars_vertex:Kb,envmap_physical_pars_fragment:Pb,envmap_vertex:Jb,fog_vertex:vb,fog_pars_vertex:qb,fog_fragment:Lb,fog_pars_fragment:bb,gradientmap_pars_fragment:Yb,lightmap_fragment:xb,lightmap_pars_fragment:Hb,lights_lambert_fragment:Tb,lights_lambert_pars_fragment:Ob,lights_pars_begin:_b,lights_toon_fragment:jb,lights_toon_pars_fragment:Wb,lights_phong_fragment:Zb,lights_phong_pars_fragment:Vb,lights_physical_fragment:zb,lights_physical_pars_fragment:Xb,lights_fragment_begin:$b,lights_fragment_maps:AY,lights_fragment_end:gY,logdepthbuf_fragment:IY,logdepthbuf_pars_fragment:eY,logdepthbuf_pars_vertex:iY,logdepthbuf_vertex:tY,map_fragment:CY,map_pars_fragment:oY,map_particle_fragment:BY,map_particle_pars_fragment:aY,metalnessmap_fragment:rY,metalnessmap_pars_fragment:sY,morphcolor_vertex:QY,morphnormal_vertex:EY,morphtarget_pars_vertex:nY,morphtarget_vertex:hY,normal_fragment_begin:lY,normal_fragment_maps:cY,normal_pars_fragment:DY,normal_pars_vertex:dY,normal_vertex:uY,normalmap_pars_fragment:pY,clearcoat_normal_fragment_begin:yY,clearcoat_normal_fragment_maps:wY,clearcoat_pars_fragment:SY,iridescence_pars_fragment:fY,output_fragment:GY,packing:kY,premultiplied_alpha_fragment:MY,project_vertex:mY,dithering_fragment:UY,dithering_pars_fragment:NY,roughnessmap_fragment:FY,roughnessmap_pars_fragment:RY,shadowmap_pars_fragment:KY,shadowmap_pars_vertex:JY,shadowmap_vertex:vY,shadowmask_pars_fragment:qY,skinbase_vertex:LY,skinning_pars_vertex:bY,skinning_vertex:YY,skinnormal_vertex:xY,specularmap_fragment:HY,specularmap_pars_fragment:TY,tonemapping_fragment:OY,tonemapping_pars_fragment:_Y,transmission_fragment:PY,transmission_pars_fragment:jY,uv_pars_fragment:WY,uv_pars_vertex:ZY,uv_vertex:VY,uv2_pars_fragment:zY,uv2_pars_vertex:XY,uv2_vertex:$Y,worldpos_vertex:Ax,background_vert:gx,background_frag:Ix,backgroundCube_vert:ex,backgroundCube_frag:ix,cube_vert:tx,cube_frag:Cx,depth_vert:ox,depth_frag:Bx,distanceRGBA_vert:ax,distanceRGBA_frag:rx,equirect_vert:sx,equirect_frag:Qx,linedashed_vert:Ex,linedashed_frag:nx,meshbasic_vert:hx,meshbasic_frag:lx,meshlambert_vert:cx,meshlambert_frag:Dx,meshmatcap_vert:dx,meshmatcap_frag:ux,meshnormal_vert:px,meshnormal_frag:yx,meshphong_vert:wx,meshphong_frag:Sx,meshphysical_vert:fx,meshphysical_frag:Gx,meshtoon_vert:kx,meshtoon_frag:Mx,points_vert:mx,points_frag:Ux,shadow_vert:Nx,shadow_frag:Fx,sprite_vert:Rx,sprite_frag:Kx},ag={common:{diffuse:{value:new Og(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new hi},uv2Transform:{value:new hi},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 sA(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 Og(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 Og(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new hi}},sprite:{diffuse:{value:new Og(16777215)},opacity:{value:1},center:{value:new sA(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new hi}}},so={basic:{uniforms:Oi([ag.common,ag.specularmap,ag.envmap,ag.aomap,ag.lightmap,ag.fog]),vertexShader:nI.meshbasic_vert,fragmentShader:nI.meshbasic_frag},lambert:{uniforms:Oi([ag.common,ag.specularmap,ag.envmap,ag.aomap,ag.lightmap,ag.emissivemap,ag.bumpmap,ag.normalmap,ag.displacementmap,ag.fog,ag.lights,{emissive:{value:new Og(0)}}]),vertexShader:nI.meshlambert_vert,fragmentShader:nI.meshlambert_frag},phong:{uniforms:Oi([ag.common,ag.specularmap,ag.envmap,ag.aomap,ag.lightmap,ag.emissivemap,ag.bumpmap,ag.normalmap,ag.displacementmap,ag.fog,ag.lights,{emissive:{value:new Og(0)},specular:{value:new Og(1118481)},shininess:{value:30}}]),vertexShader:nI.meshphong_vert,fragmentShader:nI.meshphong_frag},standard:{uniforms:Oi([ag.common,ag.envmap,ag.aomap,ag.lightmap,ag.emissivemap,ag.bumpmap,ag.normalmap,ag.displacementmap,ag.roughnessmap,ag.metalnessmap,ag.fog,ag.lights,{emissive:{value:new Og(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:nI.meshphysical_vert,fragmentShader:nI.meshphysical_frag},toon:{uniforms:Oi([ag.common,ag.aomap,ag.lightmap,ag.emissivemap,ag.bumpmap,ag.normalmap,ag.displacementmap,ag.gradientmap,ag.fog,ag.lights,{emissive:{value:new Og(0)}}]),vertexShader:nI.meshtoon_vert,fragmentShader:nI.meshtoon_frag},matcap:{uniforms:Oi([ag.common,ag.bumpmap,ag.normalmap,ag.displacementmap,ag.fog,{matcap:{value:null}}]),vertexShader:nI.meshmatcap_vert,fragmentShader:nI.meshmatcap_frag},points:{uniforms:Oi([ag.points,ag.fog]),vertexShader:nI.points_vert,fragmentShader:nI.points_frag},dashed:{uniforms:Oi([ag.common,ag.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nI.linedashed_vert,fragmentShader:nI.linedashed_frag},depth:{uniforms:Oi([ag.common,ag.displacementmap]),vertexShader:nI.depth_vert,fragmentShader:nI.depth_frag},normal:{uniforms:Oi([ag.common,ag.bumpmap,ag.normalmap,ag.displacementmap,{opacity:{value:1}}]),vertexShader:nI.meshnormal_vert,fragmentShader:nI.meshnormal_frag},sprite:{uniforms:Oi([ag.sprite,ag.fog]),vertexShader:nI.sprite_vert,fragmentShader:nI.sprite_frag},background:{uniforms:{uvTransform:{value:new hi},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:nI.background_vert,fragmentShader:nI.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:nI.backgroundCube_vert,fragmentShader:nI.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:nI.cube_vert,fragmentShader:nI.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:nI.equirect_vert,fragmentShader:nI.equirect_frag},distanceRGBA:{uniforms:Oi([ag.common,ag.displacementmap,{referencePosition:{value:new J},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:nI.distanceRGBA_vert,fragmentShader:nI.distanceRGBA_frag},shadow:{uniforms:Oi([ag.lights,ag.fog,{color:{value:new Og(0)},opacity:{value:1}}]),vertexShader:nI.shadow_vert,fragmentShader:nI.shadow_frag}};so.physical={uniforms:Oi([so.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new sA(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 Og(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new sA},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Og(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Og(1,1,1)},specularColorMap:{value:null}}]),vertexShader:nI.meshphysical_vert,fragmentShader:nI.meshphysical_frag};var Th={r:0,b:0,g:0};function Jx(g,A,I,e,i,t,C){let o=new Og(0),B=t===!0?0:1,a,s,r=null,Q=0,E=null;function n(l,c){let d=!1,u=c.isScene===!0?c.background:null;u&&u.isTexture&&(u=(c.backgroundBlurriness>0?I:A).get(u));let y=g.xr,f=y.getSession&&y.getSession();f&&f.environmentBlendMode==="additive"&&(u=null),u===null?h(o,B):u&&u.isColor&&(h(u,1),d=!0),(g.autoClear||d)&&g.clear(g.autoClearColor,g.autoClearDepth,g.autoClearStencil),u&&(u.isCubeTexture||u.mapping===Vn)?(s===void 0&&(s=new Qt(new Go(1,1,1),new te({name:"BackgroundCubeMaterial",uniforms:GQ(so.backgroundCube.uniforms),vertexShader:so.backgroundCube.vertexShader,fragmentShader:so.backgroundCube.fragmentShader,side:ni,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(k,M,G){this.matrixWorld.copyPosition(G.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),s.material.uniforms.envMap.value=u,s.material.uniforms.flipEnvMap.value=u.isCubeTexture&&u.isRenderTargetTexture===!1?-1:1,s.material.uniforms.backgroundBlurriness.value=c.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=c.backgroundIntensity,s.material.toneMapped=u.encoding!==sI,(r!==u||Q!==u.version||E!==g.toneMapping)&&(s.material.needsUpdate=!0,r=u,Q=u.version,E=g.toneMapping),s.layers.enableAll(),l.unshift(s,s.geometry,s.material,0,0,null)):u&&u.isTexture&&(a===void 0&&(a=new Qt(new FD(2,2),new te({name:"BackgroundMaterial",uniforms:GQ(so.background.uniforms),vertexShader:so.background.vertexShader,fragmentShader:so.background.fragmentShader,side:RC,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(a)),a.material.uniforms.t2D.value=u,a.material.uniforms.backgroundIntensity.value=c.backgroundIntensity,a.material.toneMapped=u.encoding!==sI,u.matrixAutoUpdate===!0&&u.updateMatrix(),a.material.uniforms.uvTransform.value.copy(u.matrix),(r!==u||Q!==u.version||E!==g.toneMapping)&&(a.material.needsUpdate=!0,r=u,Q=u.version,E=g.toneMapping),a.layers.enableAll(),l.unshift(a,a.geometry,a.material,0,0,null))}function h(l,c){l.getRGB(Th,LN(g)),e.buffers.color.setClear(Th.r,Th.g,Th.b,c,C)}return{getClearColor:function(){return o},setClearColor:function(l,c=1){o.set(l),B=c,h(o,B)},getClearAlpha:function(){return B},setClearAlpha:function(l){B=l,h(o,B)},render:n}}function vx(g,A,I,e){let i=g.getParameter(34921),t=e.isWebGL2?null:A.get("OES_vertex_array_object"),C=e.isWebGL2||t!==null,o={},B=l(null),a=B,s=!1;function r(_,gA,CA,AA,BA){let iA=!1;if(C){let rA=h(AA,CA,gA);a!==rA&&(a=rA,E(a.object)),iA=c(_,AA,CA,BA),iA&&d(_,AA,CA,BA)}else{let rA=gA.wireframe===!0;(a.geometry!==AA.id||a.program!==CA.id||a.wireframe!==rA)&&(a.geometry=AA.id,a.program=CA.id,a.wireframe=rA,iA=!0)}BA!==null&&I.update(BA,34963),(iA||s)&&(s=!1,G(_,gA,CA,AA),BA!==null&&g.bindBuffer(34963,I.get(BA).buffer))}function Q(){return e.isWebGL2?g.createVertexArray():t.createVertexArrayOES()}function E(_){return e.isWebGL2?g.bindVertexArray(_):t.bindVertexArrayOES(_)}function n(_){return e.isWebGL2?g.deleteVertexArray(_):t.deleteVertexArrayOES(_)}function h(_,gA,CA){let AA=CA.wireframe===!0,BA=o[_.id];BA===void 0&&(BA={},o[_.id]=BA);let iA=BA[gA.id];iA===void 0&&(iA={},BA[gA.id]=iA);let rA=iA[AA];return rA===void 0&&(rA=l(Q()),iA[AA]=rA),rA}function l(_){let gA=[],CA=[],AA=[];for(let BA=0;BA=0){let hA=BA[IA],QA=iA[IA];if(QA===void 0&&(IA==="instanceMatrix"&&_.instanceMatrix&&(QA=_.instanceMatrix),IA==="instanceColor"&&_.instanceColor&&(QA=_.instanceColor)),hA===void 0||hA.attribute!==QA||QA&&hA.data!==QA.data)return!0;rA++}return a.attributesNum!==rA||a.index!==AA}function d(_,gA,CA,AA){let BA={},iA=gA.attributes,rA=0,$=CA.getAttributes();for(let IA in $)if($[IA].location>=0){let hA=iA[IA];hA===void 0&&(IA==="instanceMatrix"&&_.instanceMatrix&&(hA=_.instanceMatrix),IA==="instanceColor"&&_.instanceColor&&(hA=_.instanceColor));let QA={};QA.attribute=hA,hA&&hA.data&&(QA.data=hA.data),BA[IA]=QA,rA++}a.attributes=BA,a.attributesNum=rA,a.index=AA}function u(){let _=a.newAttributes;for(let gA=0,CA=_.length;gA=0){let hA=BA[$];if(hA===void 0&&($==="instanceMatrix"&&_.instanceMatrix&&(hA=_.instanceMatrix),$==="instanceColor"&&_.instanceColor&&(hA=_.instanceColor)),hA!==void 0){let QA=hA.normalized,DA=hA.itemSize,eA=I.get(hA);if(eA===void 0)continue;let aA=eA.buffer,nA=eA.type,fA=eA.bytesPerElement;if(hA.isInterleavedBufferAttribute){let uA=hA.data,VA=uA.stride,yA=hA.offset;if(uA.isInstancedInterleavedBuffer){for(let LA=0;LA0&&g.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";M="mediump"}return M==="mediump"&&g.getShaderPrecisionFormat(35633,36337).precision>0&&g.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let C=typeof WebGL2RenderingContext<"u"&&g instanceof WebGL2RenderingContext,o=I.precision!==void 0?I.precision:"highp",B=t(o);B!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",B,"instead."),o=B);let a=C||A.has("WEBGL_draw_buffers"),s=I.logarithmicDepthBuffer===!0,r=g.getParameter(34930),Q=g.getParameter(35660),E=g.getParameter(3379),n=g.getParameter(34076),h=g.getParameter(34921),l=g.getParameter(36347),c=g.getParameter(36348),d=g.getParameter(36349),u=Q>0,y=C||A.has("OES_texture_float"),f=u&&y,k=C?g.getParameter(36183):0;return{isWebGL2:C,drawBuffers:a,getMaxAnisotropy:i,getMaxPrecision:t,precision:o,logarithmicDepthBuffer:s,maxTextures:r,maxVertexTextures:Q,maxTextureSize:E,maxCubemapSize:n,maxAttributes:h,maxVertexUniforms:l,maxVaryings:c,maxFragmentUniforms:d,vertexTextures:u,floatFragmentTextures:y,floatVertexTextures:f,maxSamples:k}}function bx(g){let A=this,I=null,e=0,i=!1,t=!1,C=new Nt,o=new hi,B={value:null,needsUpdate:!1};this.uniform=B,this.numPlanes=0,this.numIntersection=0,this.init=function(r,Q){let E=r.length!==0||Q||e!==0||i;return i=Q,e=r.length,E},this.beginShadows=function(){t=!0,s(null)},this.endShadows=function(){t=!1},this.setGlobalState=function(r,Q){I=s(r,Q,0)},this.setState=function(r,Q,E){let n=r.clippingPlanes,h=r.clipIntersection,l=r.clipShadows,c=g.get(r);if(!i||n===null||n.length===0||t&&!l)t?s(null):a();else{let d=t?0:e,u=d*4,y=c.clippingState||null;B.value=y,y=s(n,Q,u,E);for(let f=0;f!==u;++f)y[f]=I[f];c.clippingState=y,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=d}};function a(){B.value!==I&&(B.value=I,B.needsUpdate=e>0),A.numPlanes=e,A.numIntersection=0}function s(r,Q,E,n){let h=r!==null?r.length:0,l=null;if(h!==0){if(l=B.value,n!==!0||l===null){let c=E+h*4,d=Q.matrixWorldInverse;o.getNormalMatrix(d),(l===null||l.length0){let a=new $L(B.height/2);return a.fromEquirectangularTexture(g,C),A.set(C,a),C.addEventListener("dispose",i),I(a.texture,C.mapping)}else return null}}return C}function i(C){let o=C.target;o.removeEventListener("dispose",i);let B=A.get(o);B!==void 0&&(A.delete(o),B.dispose())}function t(){A=new WeakMap}return{get:e,dispose:t}}var Hw=class extends ZQ{constructor(g=-1,A=1,I=1,e=-1,i=.1,t=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=g,this.right=A,this.top=I,this.bottom=e,this.near=i,this.far=t,this.updateProjectionMatrix()}copy(g,A){return super.copy(g,A),this.left=g.left,this.right=g.right,this.top=g.top,this.bottom=g.bottom,this.near=g.near,this.far=g.far,this.zoom=g.zoom,this.view=g.view===null?null:Object.assign({},g.view),this}setViewOffset(g,A,I,e,i,t){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=g,this.view.fullHeight=A,this.view.offsetX=I,this.view.offsetY=e,this.view.width=i,this.view.height=t,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let g=(this.right-this.left)/(2*this.zoom),A=(this.top-this.bottom)/(2*this.zoom),I=(this.right+this.left)/2,e=(this.top+this.bottom)/2,i=I-g,t=I+g,C=e+A,o=e-A;if(this.view!==null&&this.view.enabled){let B=(this.right-this.left)/this.view.fullWidth/this.zoom,a=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=B*this.view.offsetX,t=i+B*this.view.width,C-=a*this.view.offsetY,o=C-a*this.view.height}this.projectionMatrix.makeOrthographic(i,t,C,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(g){let A=super.toJSON(g);return A.object.zoom=this.zoom,A.object.left=this.left,A.object.right=this.right,A.object.top=this.top,A.object.bottom=this.bottom,A.object.near=this.near,A.object.far=this.far,this.view!==null&&(A.object.view=Object.assign({},this.view)),A}},AQ=4,jf=[.125,.215,.35,.446,.526,.582],rr=20,eu=new Hw,Wf=new Og,iu=null,Cr=(1+Math.sqrt(5))/2,fs=1/Cr,Zf=[new J(1,1,1),new J(-1,1,1),new J(1,1,-1),new J(-1,1,-1),new J(0,Cr,fs),new J(0,Cr,-fs),new J(fs,0,Cr),new J(-fs,0,Cr),new J(Cr,fs,0),new J(-Cr,fs,0)],Vf=class{constructor(g){this._renderer=g,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(g,A=0,I=.1,e=100){iu=this._renderer.getRenderTarget(),this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(g,I,e,i),A>0&&this._blur(i,0,0,A),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(g,A=null){return this._fromTexture(g,A)}fromCubemap(g,A=null){return this._fromTexture(g,A)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$f(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xf(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(g){this._lodMax=Math.floor(Math.log2(g)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let g=0;g2?l:0,l,l),o.setRenderTarget(e),Q&&o.render(r,i),o.render(g,i)}r.geometry.dispose(),r.material.dispose(),o.toneMapping=a,o.autoClear=B,g.background=E}_textureToCubeUV(g,A){let I=this._renderer,e=g.mapping===Ur||g.mapping===Nr;e?(this._cubemapMaterial===null&&(this._cubemapMaterial=$f()),this._cubemapMaterial.uniforms.flipEnvMap.value=g.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xf());let i=e?this._cubemapMaterial:this._equirectMaterial,t=new Qt(this._lodPlanes[0],i),C=i.uniforms;C.envMap.value=g;let o=this._cubeSize;Oh(A,0,0,3*o,2*o),I.setRenderTarget(A),I.render(t,eu)}_applyPMREM(g){let A=this._renderer,I=A.autoClear;A.autoClear=!1;for(let e=1;err&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${rr}`);let l=[],c=0;for(let k=0;kd-AQ?e-d+AQ:0),f=4*(this._cubeSize-u);Oh(A,y,f,3*u,2*u),o.setRenderTarget(A),o.render(s,eu)}};function xx(g){let A=[],I=[],e=[],i=g,t=g-AQ+1+jf.length;for(let C=0;Cg-AQ?B=jf[C-g+AQ-1]:C===0&&(B=0),e.push(B);let a=1/(o-2),s=-a,r=1+a,Q=[s,s,r,s,r,r,s,s,r,r,s,r],E=6,n=6,h=3,l=2,c=1,d=new Float32Array(h*n*E),u=new Float32Array(l*n*E),y=new Float32Array(c*n*E);for(let k=0;k2?0:-1,v=[M,G,0,M+2/3,G,0,M+2/3,G+1,0,M,G,0,M+2/3,G+1,0,M,G+1,0];d.set(v,h*n*k),u.set(Q,l*n*k);let N=[k,k,k,k,k,k];y.set(N,c*n*k)}let f=new bg;f.setAttribute("position",new zg(d,h)),f.setAttribute("uv",new zg(u,l)),f.setAttribute("faceIndex",new zg(y,c)),A.push(f),i>AQ&&i--}return{lodPlanes:A,sizeLods:I,sigmas:e}}function zf(g,A,I){let e=new WI(g,A,I);return e.texture.mapping=Vn,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Oh(g,A,I,e,i){g.viewport.set(A,I,e,i),g.scissor.set(A,I,e,i)}function Hx(g,A,I){let e=new Float32Array(rr),i=new J(0,1,0);return new te({name:"SphericalGaussianBlur",defines:{n:rr,CUBEUV_TEXEL_WIDTH:1/A,CUBEUV_TEXEL_HEIGHT:1/I,CUBEUV_MAX_MIP:`${g}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Tw(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:je,depthTest:!1,depthWrite:!1})}function Xf(){return new te({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Tw(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:je,depthTest:!1,depthWrite:!1})}function $f(){return new te({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Tw(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:je,depthTest:!1,depthWrite:!1})}function Tw(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function Tx(g){let A=new WeakMap,I=null;function e(o){if(o&&o.isTexture){let B=o.mapping,a=B===Lp||B===bp,s=B===Ur||B===Nr;if(a||s)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let r=A.get(o);return I===null&&(I=new Vf(g)),r=a?I.fromEquirectangular(o,r):I.fromCubemap(o,r),A.set(o,r),r.texture}else{if(A.has(o))return A.get(o).texture;{let r=o.image;if(a&&r&&r.height>0||s&&r&&i(r)){I===null&&(I=new Vf(g));let Q=a?I.fromEquirectangular(o):I.fromCubemap(o);return A.set(o,Q),o.addEventListener("dispose",t),Q.texture}else return null}}}return o}function i(o){let B=0,a=6;for(let s=0;sA.maxTextureSize&&(O=Math.ceil(b/A.maxTextureSize),b=A.maxTextureSize);let H=new Float32Array(b*O*4*h),_=new vN(H,b,O,h);_.type=Rt,_.needsUpdate=!0;let gA=N*4;for(let CA=0;CA0)return g;let i=A*I,t=AG[i];if(t===void 0&&(t=new Float32Array(i),AG[i]=t),A!==0){e.toArray(t,0);for(let C=1,o=0;C!==A;++C)o+=I,g[C].toArray(t,o)}return t}function oi(g,A){if(g.length!==A.length)return!1;for(let I=0,e=g.length;I":" "} ${o}: ${I[C]}`)}return e.join(` +`)}function O2(g){switch(g){case fo:return["Linear","( value )"];case sI:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",g),["Linear","( value )"]}}function oG(g,A,I){let e=g.getShaderParameter(A,35713),i=g.getShaderInfoLog(A).trim();if(e&&i==="")return"";let t=/ERROR: 0:(\d+)/.exec(i);if(t){let C=parseInt(t[1]);return I.toUpperCase()+` + +`+i+` + +`+T2(g.getShaderSource(A),C)}else return i}function _2(g,A){let I=O2(A);return"vec4 "+g+"( vec4 value ) { return LinearTo"+I[0]+I[1]+"; }"}function P2(g,A){let I;switch(A){case Xq:I="Linear";break;case $q:I="Reinhard";break;case AL:I="OptimizedCineon";break;case gL:I="ACESFilmic";break;case IL:I="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",A),I="Linear"}return"vec3 "+g+"( vec3 color ) { return "+I+"ToneMapping( color ); }"}function j2(g){return[g.extensionDerivatives||g.envMapCubeUVHeight||g.bumpMap||g.tangentSpaceNormalMap||g.clearcoatNormalMap||g.flatShading||g.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(g.extensionFragDepth||g.logarithmicDepthBuffer)&&g.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",g.extensionDrawBuffers&&g.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(g.extensionShaderTextureLOD||g.envMap||g.transmission)&&g.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ZE).join(` +`)}function W2(g){let A=[];for(let I in g){let e=g[I];e!==!1&&A.push("#define "+I+" "+e)}return A.join(` +`)}function Z2(g,A){let I={},e=g.getProgramParameter(A,35721);for(let i=0;i/gm;function Op(g){return g.replace(V2,z2)}function z2(g,A){let I=nI[A];if(I===void 0)throw new Error("Can not resolve #include <"+A+">");return Op(I)}var X2=/#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 rG(g){return g.replace(X2,$2)}function $2(g,A,I,e){let i="";for(let t=parseInt(A);t0&&(l+=` +`),c=[E,n].filter(ZE).join(` +`),c.length>0&&(c+=` +`)):(l=[sG(I),"#define SHADER_NAME "+I.shaderName,n,I.instancing?"#define USE_INSTANCING":"",I.instancingColor?"#define USE_INSTANCING_COLOR":"",I.supportsVertexTextures?"#define VERTEX_TEXTURES":"",I.useFog&&I.fog?"#define USE_FOG":"",I.useFog&&I.fogExp2?"#define FOG_EXP2":"",I.map?"#define USE_MAP":"",I.envMap?"#define USE_ENVMAP":"",I.envMap?"#define "+s:"",I.lightMap?"#define USE_LIGHTMAP":"",I.aoMap?"#define USE_AOMAP":"",I.emissiveMap?"#define USE_EMISSIVEMAP":"",I.bumpMap?"#define USE_BUMPMAP":"",I.normalMap?"#define USE_NORMALMAP":"",I.normalMap&&I.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",I.normalMap&&I.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",I.clearcoatMap?"#define USE_CLEARCOATMAP":"",I.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",I.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",I.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",I.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",I.displacementMap&&I.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",I.specularMap?"#define USE_SPECULARMAP":"",I.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",I.specularColorMap?"#define USE_SPECULARCOLORMAP":"",I.roughnessMap?"#define USE_ROUGHNESSMAP":"",I.metalnessMap?"#define USE_METALNESSMAP":"",I.alphaMap?"#define USE_ALPHAMAP":"",I.transmission?"#define USE_TRANSMISSION":"",I.transmissionMap?"#define USE_TRANSMISSIONMAP":"",I.thicknessMap?"#define USE_THICKNESSMAP":"",I.sheenColorMap?"#define USE_SHEENCOLORMAP":"",I.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",I.vertexTangents?"#define USE_TANGENT":"",I.vertexColors?"#define USE_COLOR":"",I.vertexAlphas?"#define USE_COLOR_ALPHA":"",I.vertexUvs?"#define USE_UV":"",I.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",I.flatShading?"#define FLAT_SHADED":"",I.skinning?"#define USE_SKINNING":"",I.morphTargets?"#define USE_MORPHTARGETS":"",I.morphNormals&&I.flatShading===!1?"#define USE_MORPHNORMALS":"",I.morphColors&&I.isWebGL2?"#define USE_MORPHCOLORS":"",I.morphTargetsCount>0&&I.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",I.morphTargetsCount>0&&I.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+I.morphTextureStride:"",I.morphTargetsCount>0&&I.isWebGL2?"#define MORPHTARGETS_COUNT "+I.morphTargetsCount:"",I.doubleSided?"#define DOUBLE_SIDED":"",I.flipSided?"#define FLIP_SIDED":"",I.shadowMapEnabled?"#define USE_SHADOWMAP":"",I.shadowMapEnabled?"#define "+B:"",I.sizeAttenuation?"#define USE_SIZEATTENUATION":"",I.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",I.logarithmicDepthBuffer&&I.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(ZE).join(` +`),c=[E,sG(I),"#define SHADER_NAME "+I.shaderName,n,I.useFog&&I.fog?"#define USE_FOG":"",I.useFog&&I.fogExp2?"#define FOG_EXP2":"",I.map?"#define USE_MAP":"",I.matcap?"#define USE_MATCAP":"",I.envMap?"#define USE_ENVMAP":"",I.envMap?"#define "+a:"",I.envMap?"#define "+s:"",I.envMap?"#define "+r:"",Q?"#define CUBEUV_TEXEL_WIDTH "+Q.texelWidth:"",Q?"#define CUBEUV_TEXEL_HEIGHT "+Q.texelHeight:"",Q?"#define CUBEUV_MAX_MIP "+Q.maxMip+".0":"",I.lightMap?"#define USE_LIGHTMAP":"",I.aoMap?"#define USE_AOMAP":"",I.emissiveMap?"#define USE_EMISSIVEMAP":"",I.bumpMap?"#define USE_BUMPMAP":"",I.normalMap?"#define USE_NORMALMAP":"",I.normalMap&&I.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",I.normalMap&&I.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",I.clearcoat?"#define USE_CLEARCOAT":"",I.clearcoatMap?"#define USE_CLEARCOATMAP":"",I.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",I.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",I.iridescence?"#define USE_IRIDESCENCE":"",I.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",I.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",I.specularMap?"#define USE_SPECULARMAP":"",I.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",I.specularColorMap?"#define USE_SPECULARCOLORMAP":"",I.roughnessMap?"#define USE_ROUGHNESSMAP":"",I.metalnessMap?"#define USE_METALNESSMAP":"",I.alphaMap?"#define USE_ALPHAMAP":"",I.alphaTest?"#define USE_ALPHATEST":"",I.sheen?"#define USE_SHEEN":"",I.sheenColorMap?"#define USE_SHEENCOLORMAP":"",I.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",I.transmission?"#define USE_TRANSMISSION":"",I.transmissionMap?"#define USE_TRANSMISSIONMAP":"",I.thicknessMap?"#define USE_THICKNESSMAP":"",I.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",I.vertexTangents?"#define USE_TANGENT":"",I.vertexColors||I.instancingColor?"#define USE_COLOR":"",I.vertexAlphas?"#define USE_COLOR_ALPHA":"",I.vertexUvs?"#define USE_UV":"",I.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",I.gradientMap?"#define USE_GRADIENTMAP":"",I.flatShading?"#define FLAT_SHADED":"",I.doubleSided?"#define DOUBLE_SIDED":"",I.flipSided?"#define FLIP_SIDED":"",I.shadowMapEnabled?"#define USE_SHADOWMAP":"",I.shadowMapEnabled?"#define "+B:"",I.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",I.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",I.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",I.logarithmicDepthBuffer&&I.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",I.toneMapping!==DB?"#define TONE_MAPPING":"",I.toneMapping!==DB?nI.tonemapping_pars_fragment:"",I.toneMapping!==DB?P2("toneMapping",I.toneMapping):"",I.dithering?"#define DITHERING":"",I.opaque?"#define OPAQUE":"",nI.encodings_pars_fragment,_2("linearToOutputTexel",I.outputEncoding),I.useDepthPacking?"#define DEPTH_PACKING "+I.depthPacking:"",` +`].filter(ZE).join(` +`)),C=Op(C),C=BG(C,I),C=aG(C,I),o=Op(o),o=BG(o,I),o=aG(o,I),C=rG(C),o=rG(o),I.isWebGL2&&I.isRawShaderMaterial!==!0&&(d=`#version 300 es +`,l=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+l,c=["#define varying in",I.glslVersion===Jf?"":"layout(location = 0) out highp vec4 pc_fragColor;",I.glslVersion===Jf?"":"#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(` +`)+` +`+c);let u=d+l+C,y=d+c+o,f=CG(i,35633,u),k=CG(i,35632,y);if(i.attachShader(h,f),i.attachShader(h,k),I.index0AttributeName!==void 0?i.bindAttribLocation(h,0,I.index0AttributeName):I.morphTargets===!0&&i.bindAttribLocation(h,0,"position"),i.linkProgram(h),g.debug.checkShaderErrors){let v=i.getProgramInfoLog(h).trim(),N=i.getShaderInfoLog(f).trim(),b=i.getShaderInfoLog(k).trim(),O=!0,H=!0;if(i.getProgramParameter(h,35714)===!1){O=!1;let _=oG(i,f,"vertex"),gA=oG(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(h,35715)+` + +Program Info Log: `+v+` +`+_+` +`+gA)}else v!==""?console.warn("THREE.WebGLProgram: Program Info Log:",v):(N===""||b==="")&&(H=!1);H&&(this.diagnostics={runnable:O,programLog:v,vertexShader:{log:N,prefix:l},fragmentShader:{log:b,prefix:c}})}i.deleteShader(f),i.deleteShader(k);let M;this.getUniforms=function(){return M===void 0&&(M=new Zl(i,h)),M};let G;return this.getAttributes=function(){return G===void 0&&(G=Z2(i,h)),G},this.destroy=function(){e.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.name=I.shaderName,this.id=H2++,this.cacheKey=A,this.usedTimes=1,this.program=h,this.vertexShader=f,this.fragmentShader=k,this}var CH=0,oH=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(g){let A=g.vertexShader,I=g.fragmentShader,e=this._getShaderStage(A),i=this._getShaderStage(I),t=this._getShaderCacheForMaterial(g);return t.has(e)===!1&&(t.add(e),e.usedTimes++),t.has(i)===!1&&(t.add(i),i.usedTimes++),this}remove(g){let A=this.materialCache.get(g);for(let I of A)I.usedTimes--,I.usedTimes===0&&this.shaderCache.delete(I.code);return this.materialCache.delete(g),this}getVertexShaderID(g){return this._getShaderStage(g.vertexShader).id}getFragmentShaderID(g){return this._getShaderStage(g.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(g){let A=this.materialCache,I=A.get(g);return I===void 0&&(I=new Set,A.set(g,I)),I}_getShaderStage(g){let A=this.shaderCache,I=A.get(g);return I===void 0&&(I=new BH(g),A.set(g,I)),I}},BH=class{constructor(g){this.id=CH++,this.code=g,this.usedTimes=0}};function aH(g,A,I,e,i,t,C){let o=new bw,B=new oH,a=[],s=i.isWebGL2,r=i.logarithmicDepthBuffer,Q=i.vertexTextures,E=i.precision,n={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 h(G,v,N,b,O){let H=b.fog,_=O.geometry,gA=G.isMeshStandardMaterial?b.environment:null,CA=(G.isMeshStandardMaterial?I:A).get(G.envMap||gA),AA=CA&&CA.mapping===Vn?CA.image.height:null,BA=n[G.type];G.precision!==null&&(E=i.getMaxPrecision(G.precision),E!==G.precision&&console.warn("THREE.WebGLProgram.getParameters:",G.precision,"not supported, using",E,"instead."));let iA=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,rA=iA!==void 0?iA.length:0,$=0;_.morphAttributes.position!==void 0&&($=1),_.morphAttributes.normal!==void 0&&($=2),_.morphAttributes.color!==void 0&&($=3);let IA,hA,QA,DA;if(BA){let uA=so[BA];IA=uA.vertexShader,hA=uA.fragmentShader}else IA=G.vertexShader,hA=G.fragmentShader,B.update(G),QA=B.getVertexShaderID(G),DA=B.getFragmentShaderID(G);let eA=g.getRenderTarget(),aA=G.alphaTest>0,nA=G.clearcoat>0,fA=G.iridescence>0;return{isWebGL2:s,shaderID:BA,shaderName:G.type,vertexShader:IA,fragmentShader:hA,defines:G.defines,customVertexShaderID:QA,customFragmentShaderID:DA,isRawShaderMaterial:G.isRawShaderMaterial===!0,glslVersion:G.glslVersion,precision:E,instancing:O.isInstancedMesh===!0,instancingColor:O.isInstancedMesh===!0&&O.instanceColor!==null,supportsVertexTextures:Q,outputEncoding:eA===null?g.outputEncoding:eA.isXRRenderTarget===!0?eA.texture.encoding:fo,map:!!G.map,matcap:!!G.matcap,envMap:!!CA,envMapMode:CA&&CA.mapping,envMapCubeUVHeight:AA,lightMap:!!G.lightMap,aoMap:!!G.aoMap,emissiveMap:!!G.emissiveMap,bumpMap:!!G.bumpMap,normalMap:!!G.normalMap,objectSpaceNormalMap:G.normalMapType===uL,tangentSpaceNormalMap:G.normalMapType===dL,decodeVideoTexture:!!G.map&&G.map.isVideoTexture===!0&&G.map.encoding===sI,clearcoat:nA,clearcoatMap:nA&&!!G.clearcoatMap,clearcoatRoughnessMap:nA&&!!G.clearcoatRoughnessMap,clearcoatNormalMap:nA&&!!G.clearcoatNormalMap,iridescence:fA,iridescenceMap:fA&&!!G.iridescenceMap,iridescenceThicknessMap:fA&&!!G.iridescenceThicknessMap,displacementMap:!!G.displacementMap,roughnessMap:!!G.roughnessMap,metalnessMap:!!G.metalnessMap,specularMap:!!G.specularMap,specularIntensityMap:!!G.specularIntensityMap,specularColorMap:!!G.specularColorMap,opaque:G.transparent===!1&&G.blending===oQ,alphaMap:!!G.alphaMap,alphaTest:aA,gradientMap:!!G.gradientMap,sheen:G.sheen>0,sheenColorMap:!!G.sheenColorMap,sheenRoughnessMap:!!G.sheenRoughnessMap,transmission:G.transmission>0,transmissionMap:!!G.transmissionMap,thicknessMap:!!G.thicknessMap,combine:G.combine,vertexTangents:!!G.normalMap&&!!_.attributes.tangent,vertexColors:G.vertexColors,vertexAlphas:G.vertexColors===!0&&!!_.attributes.color&&_.attributes.color.itemSize===4,vertexUvs:!!G.map||!!G.bumpMap||!!G.normalMap||!!G.specularMap||!!G.alphaMap||!!G.emissiveMap||!!G.roughnessMap||!!G.metalnessMap||!!G.clearcoatMap||!!G.clearcoatRoughnessMap||!!G.clearcoatNormalMap||!!G.iridescenceMap||!!G.iridescenceThicknessMap||!!G.displacementMap||!!G.transmissionMap||!!G.thicknessMap||!!G.specularIntensityMap||!!G.specularColorMap||!!G.sheenColorMap||!!G.sheenRoughnessMap,uvsVertexOnly:!(G.map||G.bumpMap||G.normalMap||G.specularMap||G.alphaMap||G.emissiveMap||G.roughnessMap||G.metalnessMap||G.clearcoatNormalMap||G.iridescenceMap||G.iridescenceThicknessMap||G.transmission>0||G.transmissionMap||G.thicknessMap||G.specularIntensityMap||G.specularColorMap||G.sheen>0||G.sheenColorMap||G.sheenRoughnessMap)&&!!G.displacementMap,fog:!!H,useFog:G.fog===!0,fogExp2:H&&H.isFogExp2,flatShading:!!G.flatShading,sizeAttenuation:G.sizeAttenuation,logarithmicDepthBuffer:r,skinning:O.isSkinnedMesh===!0,morphTargets:_.morphAttributes.position!==void 0,morphNormals:_.morphAttributes.normal!==void 0,morphColors:_.morphAttributes.color!==void 0,morphTargetsCount:rA,morphTextureStride:$,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numClippingPlanes:C.numPlanes,numClipIntersection:C.numIntersection,dithering:G.dithering,shadowMapEnabled:g.shadowMap.enabled&&N.length>0,shadowMapType:g.shadowMap.type,toneMapping:G.toneMapped?g.toneMapping:DB,physicallyCorrectLights:g.physicallyCorrectLights,premultipliedAlpha:G.premultipliedAlpha,doubleSided:G.side===Ft,flipSided:G.side===ni,useDepthPacking:!!G.depthPacking,depthPacking:G.depthPacking||0,index0AttributeName:G.index0AttributeName,extensionDerivatives:G.extensions&&G.extensions.derivatives,extensionFragDepth:G.extensions&&G.extensions.fragDepth,extensionDrawBuffers:G.extensions&&G.extensions.drawBuffers,extensionShaderTextureLOD:G.extensions&&G.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||e.has("EXT_frag_depth"),rendererExtensionDrawBuffers:s||e.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:s||e.has("EXT_shader_texture_lod"),customProgramCacheKey:G.customProgramCacheKey()}}function l(G){let v=[];if(G.shaderID?v.push(G.shaderID):(v.push(G.customVertexShaderID),v.push(G.customFragmentShaderID)),G.defines!==void 0)for(let N in G.defines)v.push(N),v.push(G.defines[N]);return G.isRawShaderMaterial===!1&&(c(v,G),d(v,G),v.push(g.outputEncoding)),v.push(G.customProgramCacheKey),v.join()}function c(G,v){G.push(v.precision),G.push(v.outputEncoding),G.push(v.envMapMode),G.push(v.envMapCubeUVHeight),G.push(v.combine),G.push(v.vertexUvs),G.push(v.fogExp2),G.push(v.sizeAttenuation),G.push(v.morphTargetsCount),G.push(v.morphAttributeCount),G.push(v.numDirLights),G.push(v.numPointLights),G.push(v.numSpotLights),G.push(v.numSpotLightMaps),G.push(v.numHemiLights),G.push(v.numRectAreaLights),G.push(v.numDirLightShadows),G.push(v.numPointLightShadows),G.push(v.numSpotLightShadows),G.push(v.numSpotLightShadowsWithMaps),G.push(v.shadowMapType),G.push(v.toneMapping),G.push(v.numClippingPlanes),G.push(v.numClipIntersection),G.push(v.depthPacking)}function d(G,v){o.disableAll(),v.isWebGL2&&o.enable(0),v.supportsVertexTextures&&o.enable(1),v.instancing&&o.enable(2),v.instancingColor&&o.enable(3),v.map&&o.enable(4),v.matcap&&o.enable(5),v.envMap&&o.enable(6),v.lightMap&&o.enable(7),v.aoMap&&o.enable(8),v.emissiveMap&&o.enable(9),v.bumpMap&&o.enable(10),v.normalMap&&o.enable(11),v.objectSpaceNormalMap&&o.enable(12),v.tangentSpaceNormalMap&&o.enable(13),v.clearcoat&&o.enable(14),v.clearcoatMap&&o.enable(15),v.clearcoatRoughnessMap&&o.enable(16),v.clearcoatNormalMap&&o.enable(17),v.iridescence&&o.enable(18),v.iridescenceMap&&o.enable(19),v.iridescenceThicknessMap&&o.enable(20),v.displacementMap&&o.enable(21),v.specularMap&&o.enable(22),v.roughnessMap&&o.enable(23),v.metalnessMap&&o.enable(24),v.gradientMap&&o.enable(25),v.alphaMap&&o.enable(26),v.alphaTest&&o.enable(27),v.vertexColors&&o.enable(28),v.vertexAlphas&&o.enable(29),v.vertexUvs&&o.enable(30),v.vertexTangents&&o.enable(31),v.uvsVertexOnly&&o.enable(32),G.push(o.mask),o.disableAll(),v.fog&&o.enable(0),v.useFog&&o.enable(1),v.flatShading&&o.enable(2),v.logarithmicDepthBuffer&&o.enable(3),v.skinning&&o.enable(4),v.morphTargets&&o.enable(5),v.morphNormals&&o.enable(6),v.morphColors&&o.enable(7),v.premultipliedAlpha&&o.enable(8),v.shadowMapEnabled&&o.enable(9),v.physicallyCorrectLights&&o.enable(10),v.doubleSided&&o.enable(11),v.flipSided&&o.enable(12),v.useDepthPacking&&o.enable(13),v.dithering&&o.enable(14),v.specularIntensityMap&&o.enable(15),v.specularColorMap&&o.enable(16),v.transmission&&o.enable(17),v.transmissionMap&&o.enable(18),v.thicknessMap&&o.enable(19),v.sheen&&o.enable(20),v.sheenColorMap&&o.enable(21),v.sheenRoughnessMap&&o.enable(22),v.decodeVideoTexture&&o.enable(23),v.opaque&&o.enable(24),G.push(o.mask)}function u(G){let v=n[G.type],N;if(v){let b=so[v];N=WQ.clone(b.uniforms)}else N=G.uniforms;return N}function y(G,v){let N;for(let b=0,O=a.length;b0?e.push(c):E.transparent===!0?i.push(c):I.push(c)}function B(r,Q,E,n,h,l){let c=C(r,Q,E,n,h,l);E.transmission>0?e.unshift(c):E.transparent===!0?i.unshift(c):I.unshift(c)}function a(r,Q){I.length>1&&I.sort(r||sH),e.length>1&&e.sort(Q||QG),i.length>1&&i.sort(Q||QG)}function s(){for(let r=A,Q=g.length;r=t.length?(C=new EG,t.push(C)):C=t[i],C}function I(){g=new WeakMap}return{get:A,dispose:I}}function EH(){let g={};return{get:function(A){if(g[A.id]!==void 0)return g[A.id];let I;switch(A.type){case"DirectionalLight":I={direction:new J,color:new Og};break;case"SpotLight":I={position:new J,direction:new J,color:new Og,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":I={position:new J,color:new Og,distance:0,decay:0};break;case"HemisphereLight":I={direction:new J,skyColor:new Og,groundColor:new Og};break;case"RectAreaLight":I={color:new Og,position:new J,halfWidth:new J,halfHeight:new J};break}return g[A.id]=I,I}}}function nH(){let g={};return{get:function(A){if(g[A.id]!==void 0)return g[A.id];let I;switch(A.type){case"DirectionalLight":I={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sA};break;case"SpotLight":I={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sA};break;case"PointLight":I={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sA,shadowCameraNear:1,shadowCameraFar:1e3};break}return g[A.id]=I,I}}}var hH=0;function lH(g,A){return(A.castShadow?2:0)-(g.castShadow?2:0)+(A.map?1:0)-(g.map?1:0)}function cH(g,A){let I=new EH,e=nH(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let s=0;s<9;s++)i.probe.push(new J);let t=new J,C=new zA,o=new zA;function B(s,r){let Q=0,E=0,n=0;for(let b=0;b<9;b++)i.probe[b].set(0,0,0);let h=0,l=0,c=0,d=0,u=0,y=0,f=0,k=0,M=0,G=0;s.sort(lH);let v=r!==!0?Math.PI:1;for(let b=0,O=s.length;b0&&(A.isWebGL2||g.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ag.LTC_FLOAT_1,i.rectAreaLTC2=ag.LTC_FLOAT_2):g.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ag.LTC_HALF_1,i.rectAreaLTC2=ag.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=Q,i.ambient[1]=E,i.ambient[2]=n;let N=i.hash;(N.directionalLength!==h||N.pointLength!==l||N.spotLength!==c||N.rectAreaLength!==d||N.hemiLength!==u||N.numDirectionalShadows!==y||N.numPointShadows!==f||N.numSpotShadows!==k||N.numSpotMaps!==M)&&(i.directional.length=h,i.spot.length=c,i.rectArea.length=d,i.point.length=l,i.hemi.length=u,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=k+M-G,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=G,N.directionalLength=h,N.pointLength=l,N.spotLength=c,N.rectAreaLength=d,N.hemiLength=u,N.numDirectionalShadows=y,N.numPointShadows=f,N.numSpotShadows=k,N.numSpotMaps=M,i.version=hH++)}function a(s,r){let Q=0,E=0,n=0,h=0,l=0,c=r.matrixWorldInverse;for(let d=0,u=s.length;d=o.length?(B=new nG(g,A),o.push(B)):B=o[C],B}function i(){I=new WeakMap}return{get:e,dispose:i}}var ON=class extends zn{constructor(g){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=UB,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(g)}copy(g){return super.copy(g),this.depthPacking=g.depthPacking,this.map=g.map,this.alphaMap=g.alphaMap,this.displacementMap=g.displacementMap,this.displacementScale=g.displacementScale,this.displacementBias=g.displacementBias,this.wireframe=g.wireframe,this.wireframeLinewidth=g.wireframeLinewidth,this}},dH=class extends zn{constructor(g){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new J,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(g)}copy(g){return super.copy(g),this.referencePosition.copy(g.referencePosition),this.nearDistance=g.nearDistance,this.farDistance=g.farDistance,this.map=g.map,this.alphaMap=g.alphaMap,this.displacementMap=g.displacementMap,this.displacementScale=g.displacementScale,this.displacementBias=g.displacementBias,this}},uH=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,pH=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function yH(g,A,I){let e=new xw,i=new sA,t=new sA,C=new EI,o=new ON({depthPacking:UN}),B=new dH,a={},s=I.maxTextureSize,r={[RC]:ni,[ni]:RC,[Ft]:Ft},Q=new te({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new sA},radius:{value:4}},vertexShader:uH,fragmentShader:pH}),E=Q.clone();E.defines.HORIZONTAL_PASS=1;let n=new bg;n.setAttribute("position",new zg(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Qt(n,Q),l=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Jw,this.render=function(y,f,k){if(l.enabled===!1||l.autoUpdate===!1&&l.needsUpdate===!1||y.length===0)return;let M=g.getRenderTarget(),G=g.getActiveCubeFace(),v=g.getActiveMipmapLevel(),N=g.state;N.setBlending(je),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);for(let b=0,O=y.length;bs||i.y>s)&&(i.x>s&&(t.x=Math.floor(s/gA.x),i.x=t.x*gA.x,_.mapSize.x=t.x),i.y>s&&(t.y=Math.floor(s/gA.y),i.y=t.y*gA.y,_.mapSize.y=t.y)),_.map===null){let AA=this.type!==WE?{minFilter:ie,magFilter:ie}:{};_.map=new WI(i.x,i.y,AA),_.map.texture.name=H.name+".shadowMap",_.camera.updateProjectionMatrix()}g.setRenderTarget(_.map),g.clear();let CA=_.getViewportCount();for(let AA=0;AA0||f.map&&f.alphaTest>0){let O=N.uuid,H=f.uuid,_=a[O];_===void 0&&(_={},a[O]=_);let gA=_[H];gA===void 0&&(gA=N.clone(),_[H]=gA),N=gA}return N.visible=f.visible,N.wireframe=f.wireframe,v===WE?N.side=f.shadowSide!==null?f.shadowSide:f.side:N.side=f.shadowSide!==null?f.shadowSide:r[f.side],N.alphaMap=f.alphaMap,N.alphaTest=f.alphaTest,N.map=f.map,N.clipShadows=f.clipShadows,N.clippingPlanes=f.clippingPlanes,N.clipIntersection=f.clipIntersection,N.displacementMap=f.displacementMap,N.displacementScale=f.displacementScale,N.displacementBias=f.displacementBias,N.wireframeLinewidth=f.wireframeLinewidth,N.linewidth=f.linewidth,k.isPointLight===!0&&N.isMeshDistanceMaterial===!0&&(N.referencePosition.setFromMatrixPosition(k.matrixWorld),N.nearDistance=M,N.farDistance=G),N}function u(y,f,k,M,G){if(y.visible===!1)return;if(y.layers.test(f.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&G===WE)&&(!y.frustumCulled||e.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,y.matrixWorld);let N=A.update(y),b=y.material;if(Array.isArray(b)){let O=N.groups;for(let H=0,_=O.length;H<_;H++){let gA=O[H],CA=b[gA.materialIndex];if(CA&&CA.visible){let AA=d(y,CA,M,k.near,k.far,G);g.renderBufferDirect(k,null,N,AA,y,gA)}}}else if(b.visible){let O=d(y,b,M,k.near,k.far,G);g.renderBufferDirect(k,null,N,O,y,null)}}let v=y.children;for(let N=0,b=v.length;N=1):BA.indexOf("OpenGL ES")!==-1&&(AA=parseFloat(/^OpenGL ES (\d)/.exec(BA)[1]),CA=AA>=2);let iA=null,rA={},$=g.getParameter(3088),IA=g.getParameter(2978),hA=new EI().fromArray($),QA=new EI().fromArray(IA);function DA(lA,KA,WA){let Qg=new Uint8Array(4),Lg=g.createTexture();g.bindTexture(lA,Lg),g.texParameteri(lA,10241,9728),g.texParameteri(lA,10240,9728);for(let $g=0;$g"u"?!1:/OculusBrowser/g.test(navigator.userAgent),n=new WeakMap,h,l=new WeakMap,c=!1;try{c=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function d(V,W){return c?new OffscreenCanvas(V,W):Dc("canvas")}function u(V,W,wA,qA){let Ig=1;if((V.width>qA||V.height>qA)&&(Ig=qA/Math.max(V.width,V.height)),Ig<1||W===!0)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap){let jA=W?cc:Math.floor,dg=jA(Ig*V.width),Cg=jA(Ig*V.height);h===void 0&&(h=d(dg,Cg));let UA=wA?d(dg,Cg):h;return UA.width=dg,UA.height=Cg,UA.getContext("2d").drawImage(V,0,0,dg,Cg),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+V.width+"x"+V.height+") to ("+dg+"x"+Cg+")."),UA}else return"data"in V&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+V.width+"x"+V.height+")."),V;return V}function y(V){return Tp(V.width)&&Tp(V.height)}function f(V){return o?!1:V.wrapS!==Ke||V.wrapT!==Ke||V.minFilter!==ie&&V.minFilter!==cI}function k(V,W){return V.generateMipmaps&&W&&V.minFilter!==ie&&V.minFilter!==cI}function M(V){g.generateMipmap(V)}function G(V,W,wA,qA,Ig=!1){if(o===!1)return W;if(V!==null){if(g[V]!==void 0)return g[V];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let jA=W;return W===6403&&(wA===5126&&(jA=33326),wA===5131&&(jA=33325),wA===5121&&(jA=33321)),W===33319&&(wA===5126&&(jA=33328),wA===5131&&(jA=33327),wA===5121&&(jA=33323)),W===6408&&(wA===5126&&(jA=34836),wA===5131&&(jA=34842),wA===5121&&(jA=qA===sI&&Ig===!1?35907:32856),wA===32819&&(jA=32854),wA===32820&&(jA=32855)),(jA===33325||jA===33326||jA===33327||jA===33328||jA===34842||jA===34836)&&A.get("EXT_color_buffer_float"),jA}function v(V,W,wA){return k(V,wA)===!0||V.isFramebufferTexture&&V.minFilter!==ie&&V.minFilter!==cI?Math.log2(Math.max(W.width,W.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?W.mipmaps.length:1}function N(V){return V===ie||V===sf||V===md?9728:9729}function b(V){let W=V.target;W.removeEventListener("dispose",b),H(W),W.isVideoTexture&&n.delete(W)}function O(V){let W=V.target;W.removeEventListener("dispose",O),gA(W)}function H(V){let W=e.get(V);if(W.__webglInit===void 0)return;let wA=V.source,qA=l.get(wA);if(qA){let Ig=qA[W.__cacheKey];Ig.usedTimes--,Ig.usedTimes===0&&_(V),Object.keys(qA).length===0&&l.delete(wA)}e.remove(V)}function _(V){let W=e.get(V);g.deleteTexture(W.__webglTexture);let wA=V.source,qA=l.get(wA);delete qA[W.__cacheKey],C.memory.textures--}function gA(V){let W=V.texture,wA=e.get(V),qA=e.get(W);if(qA.__webglTexture!==void 0&&(g.deleteTexture(qA.__webglTexture),C.memory.textures--),V.depthTexture&&V.depthTexture.dispose(),V.isWebGLCubeRenderTarget)for(let Ig=0;Ig<6;Ig++)g.deleteFramebuffer(wA.__webglFramebuffer[Ig]),wA.__webglDepthbuffer&&g.deleteRenderbuffer(wA.__webglDepthbuffer[Ig]);else{if(g.deleteFramebuffer(wA.__webglFramebuffer),wA.__webglDepthbuffer&&g.deleteRenderbuffer(wA.__webglDepthbuffer),wA.__webglMultisampledFramebuffer&&g.deleteFramebuffer(wA.__webglMultisampledFramebuffer),wA.__webglColorRenderbuffer)for(let Ig=0;Ig=B&&console.warn("THREE.WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+B),CA+=1,V}function iA(V){let W=[];return W.push(V.wrapS),W.push(V.wrapT),W.push(V.wrapR||0),W.push(V.magFilter),W.push(V.minFilter),W.push(V.anisotropy),W.push(V.internalFormat),W.push(V.format),W.push(V.type),W.push(V.generateMipmaps),W.push(V.premultiplyAlpha),W.push(V.flipY),W.push(V.unpackAlignment),W.push(V.encoding),W.join()}function rA(V,W){let wA=e.get(V);if(V.isVideoTexture&&mg(V),V.isRenderTargetTexture===!1&&V.version>0&&wA.__version!==V.version){let qA=V.image;if(qA===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(qA.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{nA(wA,V,W);return}}I.bindTexture(3553,wA.__webglTexture,33984+W)}function $(V,W){let wA=e.get(V);if(V.version>0&&wA.__version!==V.version){nA(wA,V,W);return}I.bindTexture(35866,wA.__webglTexture,33984+W)}function IA(V,W){let wA=e.get(V);if(V.version>0&&wA.__version!==V.version){nA(wA,V,W);return}I.bindTexture(32879,wA.__webglTexture,33984+W)}function hA(V,W){let wA=e.get(V);if(V.version>0&&wA.__version!==V.version){fA(wA,V,W);return}I.bindTexture(34067,wA.__webglTexture,33984+W)}let QA={[hB]:10497,[Ke]:33071,[Yp]:33648},DA={[ie]:9728,[sf]:9984,[md]:9986,[cI]:9729,[eL]:9985,[SQ]:9987};function eA(V,W,wA){if(wA?(g.texParameteri(V,10242,QA[W.wrapS]),g.texParameteri(V,10243,QA[W.wrapT]),(V===32879||V===35866)&&g.texParameteri(V,32882,QA[W.wrapR]),g.texParameteri(V,10240,DA[W.magFilter]),g.texParameteri(V,10241,DA[W.minFilter])):(g.texParameteri(V,10242,33071),g.texParameteri(V,10243,33071),(V===32879||V===35866)&&g.texParameteri(V,32882,33071),(W.wrapS!==Ke||W.wrapT!==Ke)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),g.texParameteri(V,10240,N(W.magFilter)),g.texParameteri(V,10241,N(W.minFilter)),W.minFilter!==ie&&W.minFilter!==cI&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),A.has("EXT_texture_filter_anisotropic")===!0){let qA=A.get("EXT_texture_filter_anisotropic");if(W.magFilter===ie||W.minFilter!==md&&W.minFilter!==SQ||W.type===Rt&&A.has("OES_texture_float_linear")===!1||o===!1&&W.type===fQ&&A.has("OES_texture_half_float_linear")===!1)return;(W.anisotropy>1||e.get(W).__currentAnisotropy)&&(g.texParameterf(V,qA.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W.anisotropy,i.getMaxAnisotropy())),e.get(W).__currentAnisotropy=W.anisotropy)}}function aA(V,W){let wA=!1;V.__webglInit===void 0&&(V.__webglInit=!0,W.addEventListener("dispose",b));let qA=W.source,Ig=l.get(qA);Ig===void 0&&(Ig={},l.set(qA,Ig));let jA=iA(W);if(jA!==V.__cacheKey){Ig[jA]===void 0&&(Ig[jA]={texture:g.createTexture(),usedTimes:0},C.memory.textures++,wA=!0),Ig[jA].usedTimes++;let dg=Ig[V.__cacheKey];dg!==void 0&&(Ig[V.__cacheKey].usedTimes--,dg.usedTimes===0&&_(W)),V.__cacheKey=jA,V.__webglTexture=Ig[jA].texture}return wA}function nA(V,W,wA){let qA=3553;(W.isDataArrayTexture||W.isCompressedArrayTexture)&&(qA=35866),W.isData3DTexture&&(qA=32879);let Ig=aA(V,W),jA=W.source;I.bindTexture(qA,V.__webglTexture,33984+wA);let dg=e.get(jA);if(jA.version!==dg.__version||Ig===!0){I.activeTexture(33984+wA),g.pixelStorei(37440,W.flipY),g.pixelStorei(37441,W.premultiplyAlpha),g.pixelStorei(3317,W.unpackAlignment),g.pixelStorei(37443,0);let Cg=f(W)&&y(W.image)===!1,UA=u(W.image,Cg,!1,s);UA=hg(W,UA);let fg=y(UA)||o,Rg=t.convert(W.format,W.encoding),Ug=t.convert(W.type),ng=G(W.internalFormat,Rg,Ug,W.encoding,W.isVideoTexture);eA(qA,W,fg);let og,Zg=W.mipmaps,cg=o&&W.isVideoTexture!==!0,OI=dg.__version===void 0||Ig===!0,lA=v(W,UA,fg);if(W.isDepthTexture)ng=6402,o?W.type===Rt?ng=36012:W.type===oa?ng=33190:W.type===wr?ng=35056:ng=33189:W.type===Rt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),W.format===Sr&&ng===6402&&W.type!==GN&&W.type!==oa&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),W.type=oa,Ug=t.convert(W.type)),W.format===Fr&&ng===6402&&(ng=34041,W.type!==wr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),W.type=wr,Ug=t.convert(W.type))),OI&&(cg?I.texStorage2D(3553,1,ng,UA.width,UA.height):I.texImage2D(3553,0,ng,UA.width,UA.height,0,Rg,Ug,null));else if(W.isDataTexture)if(Zg.length>0&&fg){cg&&OI&&I.texStorage2D(3553,lA,ng,Zg[0].width,Zg[0].height);for(let KA=0,WA=Zg.length;KA>=1,WA>>=1}}else if(Zg.length>0&&fg){cg&&OI&&I.texStorage2D(3553,lA,ng,Zg[0].width,Zg[0].height);for(let KA=0,WA=Zg.length;KA0&&OI++,I.texStorage2D(34067,OI,og,UA[0].width,UA[0].height));for(let KA=0;KA<6;KA++)if(Cg){Zg?I.texSubImage2D(34069+KA,0,0,0,UA[KA].width,UA[KA].height,Ug,ng,UA[KA].data):I.texImage2D(34069+KA,0,og,UA[KA].width,UA[KA].height,0,Ug,ng,UA[KA].data);for(let WA=0;WA=34069&&Ig<=34074)&&g.framebufferTexture2D(36160,qA,Ig,e.get(wA).__webglTexture,0),I.bindFramebuffer(36160,null)}function VA(V,W,wA){if(g.bindRenderbuffer(36161,V),W.depthBuffer&&!W.stencilBuffer){let qA=33189;if(wA||$A(W)){let Ig=W.depthTexture;Ig&&Ig.isDepthTexture&&(Ig.type===Rt?qA=36012:Ig.type===oa&&(qA=33190));let jA=Eg(W);$A(W)?Q.renderbufferStorageMultisampleEXT(36161,jA,qA,W.width,W.height):g.renderbufferStorageMultisample(36161,jA,qA,W.width,W.height)}else g.renderbufferStorage(36161,qA,W.width,W.height);g.framebufferRenderbuffer(36160,36096,36161,V)}else if(W.depthBuffer&&W.stencilBuffer){let qA=Eg(W);wA&&$A(W)===!1?g.renderbufferStorageMultisample(36161,qA,35056,W.width,W.height):$A(W)?Q.renderbufferStorageMultisampleEXT(36161,qA,35056,W.width,W.height):g.renderbufferStorage(36161,34041,W.width,W.height),g.framebufferRenderbuffer(36160,33306,36161,V)}else{let qA=W.isWebGLMultipleRenderTargets===!0?W.texture:[W.texture];for(let Ig=0;Ig0&&$A(V)===!1){let Cg=jA?W:[W];wA.__webglMultisampledFramebuffer=g.createFramebuffer(),wA.__webglColorRenderbuffer=[],I.bindFramebuffer(36160,wA.__webglMultisampledFramebuffer);for(let UA=0;UA0&&$A(V)===!1){let W=V.isWebGLMultipleRenderTargets?V.texture:[V.texture],wA=V.width,qA=V.height,Ig=16384,jA=[],dg=V.stencilBuffer?33306:36096,Cg=e.get(V),UA=V.isWebGLMultipleRenderTargets===!0;if(UA)for(let fg=0;fg0&&A.has("WEBGL_multisampled_render_to_texture")===!0&&W.__useRenderToTexture!==!1}function mg(V){let W=C.render.frame;n.get(V)!==W&&(n.set(V,W),V.update())}function hg(V,W){let wA=V.encoding,qA=V.format,Ig=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||V.format===Hp||wA!==fo&&(wA===sI?o===!1?A.has("EXT_sRGB")===!0&&qA===$t?(V.format=Hp,V.minFilter=cI,V.generateMipmaps=!1):W=KN.sRGBToLinear(W):(qA!==$t||Ig!==vi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",wA)),W}this.allocateTextureUnit=BA,this.resetTextureUnits=AA,this.setTexture2D=rA,this.setTexture2DArray=$,this.setTexture3D=IA,this.setTextureCube=hA,this.rebindTextures=HA,this.setupRenderTarget=Ag,this.updateRenderTargetMipmap=gg,this.updateMultisampleRenderTarget=Dg,this.setupDepthRenderbuffer=LA,this.setupFrameBufferTexture=uA,this.useMultisampledRTT=$A}function fH(g,A,I){let e=I.isWebGL2;function i(t,C=null){let o;if(t===vi)return 5121;if(t===oL)return 32819;if(t===BL)return 32820;if(t===iL)return 5120;if(t===tL)return 5122;if(t===GN)return 5123;if(t===CL)return 5124;if(t===oa)return 5125;if(t===Rt)return 5126;if(t===fQ)return e?5131:(o=A.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(t===aL)return 6406;if(t===$t)return 6408;if(t===rL)return 6409;if(t===sL)return 6410;if(t===Sr)return 6402;if(t===Fr)return 34041;if(t===Hp)return o=A.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(t===QL)return 6403;if(t===EL)return 36244;if(t===kN)return 33319;if(t===nL)return 33320;if(t===hL)return 36249;if(t===Ud||t===Nd||t===Fd||t===Rd)if(C===sI)if(o=A.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(t===Ud)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(t===Nd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(t===Fd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(t===Rd)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=A.get("WEBGL_compressed_texture_s3tc"),o!==null){if(t===Ud)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Nd)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===Fd)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Rd)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(t===Qf||t===Ef||t===nf||t===hf)if(o=A.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(t===Qf)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===Ef)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===nf)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===hf)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(t===lL)return o=A.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(t===lf||t===cf)if(o=A.get("WEBGL_compressed_texture_etc"),o!==null){if(t===lf)return C===sI?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(t===cf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(t===Df||t===df||t===uf||t===pf||t===yf||t===wf||t===Sf||t===ff||t===Gf||t===kf||t===Mf||t===mf||t===Uf||t===Nf)if(o=A.get("WEBGL_compressed_texture_astc"),o!==null){if(t===Df)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(t===df)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(t===uf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(t===pf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(t===yf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(t===wf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(t===Sf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(t===ff)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(t===Gf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(t===kf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(t===Mf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(t===mf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(t===Uf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(t===Nf)return C===sI?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(t===Kd)if(o=A.get("EXT_texture_compression_bptc"),o!==null){if(t===Kd)return C===sI?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(t===cL||t===Ff||t===Rf||t===Kf)if(o=A.get("EXT_texture_compression_rgtc"),o!==null){if(t===Kd)return o.COMPRESSED_RED_RGTC1_EXT;if(t===Ff)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(t===Rf)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(t===Kf)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return t===wr?e?34042:(o=A.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):g[t]!==void 0?g[t]:null}return{convert:i}}var GH=class extends Ui{constructor(g=[]){super(),this.isArrayCamera=!0,this.cameras=g}},gQ=class extends ZI{constructor(){super(),this.isGroup=!0,this.type="Group"}},kH={type:"move"},Cu=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new gQ,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 gQ,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new J,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new J),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new gQ,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new J,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new J),this._grip}dispatchEvent(g){return this._targetRay!==null&&this._targetRay.dispatchEvent(g),this._grip!==null&&this._grip.dispatchEvent(g),this._hand!==null&&this._hand.dispatchEvent(g),this}connect(g){if(g&&g.hand){let A=this._hand;if(A)for(let I of g.hand.values())this._getHandJoint(A,I)}return this.dispatchEvent({type:"connected",data:g}),this}disconnect(g){return this.dispatchEvent({type:"disconnected",data:g}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(g,A,I){let e=null,i=null,t=null,C=this._targetRay,o=this._grip,B=this._hand;if(g&&A.session.visibilityState!=="visible-blurred"){if(B&&g.hand){t=!0;for(let n of g.hand.values()){let h=A.getJointPose(n,I),l=this._getHandJoint(B,n);h!==null&&(l.matrix.fromArray(h.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.jointRadius=h.radius),l.visible=h!==null}let a=B.joints["index-finger-tip"],s=B.joints["thumb-tip"],r=a.position.distanceTo(s.position),Q=.02,E=.005;B.inputState.pinching&&r>Q+E?(B.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:g.handedness,target:this})):!B.inputState.pinching&&r<=Q-E&&(B.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:g.handedness,target:this}))}else o!==null&&g.gripSpace&&(i=A.getPose(g.gripSpace,I),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1));C!==null&&(e=A.getPose(g.targetRaySpace,I),e===null&&i!==null&&(e=i),e!==null&&(C.matrix.fromArray(e.transform.matrix),C.matrix.decompose(C.position,C.rotation,C.scale),e.linearVelocity?(C.hasLinearVelocity=!0,C.linearVelocity.copy(e.linearVelocity)):C.hasLinearVelocity=!1,e.angularVelocity?(C.hasAngularVelocity=!0,C.angularVelocity.copy(e.angularVelocity)):C.hasAngularVelocity=!1,this.dispatchEvent(kH)))}return C!==null&&(C.visible=e!==null),o!==null&&(o.visible=i!==null),B!==null&&(B.visible=t!==null),this}_getHandJoint(g,A){if(g.joints[A.jointName]===void 0){let I=new gQ;I.matrixAutoUpdate=!1,I.visible=!1,g.joints[A.jointName]=I,g.add(I)}return g.joints[A.jointName]}},kQ=class extends ti{constructor(A,I,e,i,t,C,o,B,a,s){if(s=s!==void 0?s:Sr,s!==Sr&&s!==Fr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");e===void 0&&s===Sr&&(e=oa),e===void 0&&s===Fr&&(e=wr),super(null,i,t,C,o,B,s,e,a),this.isDepthTexture=!0,this.image={width:A,height:I},this.magFilter=o!==void 0?o:ie,this.minFilter=B!==void 0?B:ie,this.flipY=!1,this.generateMipmaps=!1}},MH=class extends Si{constructor(g,A){super();let I=this,e=null,i=1,t=null,C="local-floor",o=1,B=null,a=null,s=null,r=null,Q=null,E=null,n=A.getContextAttributes(),h=null,l=null,c=[],d=[],u=new Set,y=new Map,f=new Ui;f.layers.enable(1),f.viewport=new EI;let k=new Ui;k.layers.enable(2),k.viewport=new EI;let M=[f,k],G=new GH;G.layers.enable(1),G.layers.enable(2);let v=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let IA=c[$];return IA===void 0&&(IA=new Cu,c[$]=IA),IA.getTargetRaySpace()},this.getControllerGrip=function($){let IA=c[$];return IA===void 0&&(IA=new Cu,c[$]=IA),IA.getGripSpace()},this.getHand=function($){let IA=c[$];return IA===void 0&&(IA=new Cu,c[$]=IA),IA.getHandSpace()};function b($){let IA=d.indexOf($.inputSource);if(IA===-1)return;let hA=c[IA];hA!==void 0&&hA.dispatchEvent({type:$.type,data:$.inputSource})}function O(){e.removeEventListener("select",b),e.removeEventListener("selectstart",b),e.removeEventListener("selectend",b),e.removeEventListener("squeeze",b),e.removeEventListener("squeezestart",b),e.removeEventListener("squeezeend",b),e.removeEventListener("end",O),e.removeEventListener("inputsourceschange",H);for(let $=0;$=0&&(d[QA]=null,c[QA].disconnect(hA))}for(let IA=0;IA<$.added.length;IA++){let hA=$.added[IA],QA=d.indexOf(hA);if(QA===-1){for(let eA=0;eA=d.length){d.push(hA),QA=eA;break}else if(d[eA]===null){d[eA]=hA,QA=eA;break}if(QA===-1)break}let DA=c[QA];DA&&DA.connect(hA)}}let _=new J,gA=new J;function CA($,IA,hA){_.setFromMatrixPosition(IA.matrixWorld),gA.setFromMatrixPosition(hA.matrixWorld);let QA=_.distanceTo(gA),DA=IA.projectionMatrix.elements,eA=hA.projectionMatrix.elements,aA=DA[14]/(DA[10]-1),nA=DA[14]/(DA[10]+1),fA=(DA[9]+1)/DA[5],uA=(DA[9]-1)/DA[5],VA=(DA[8]-1)/DA[0],yA=(eA[8]+1)/eA[0],LA=aA*VA,HA=aA*yA,Ag=QA/(-VA+yA),gg=Ag*-VA;IA.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(gg),$.translateZ(Ag),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert();let Dg=aA+Ag,Eg=nA+Ag,$A=LA-gg,mg=HA+(QA-gg),hg=fA*nA/Eg*Dg,V=uA*nA/Eg*Dg;$.projectionMatrix.makePerspective($A,mg,hg,V,Dg,Eg)}function AA($,IA){IA===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(IA.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(e===null)return;G.near=k.near=f.near=$.near,G.far=k.far=f.far=$.far,(v!==G.near||N!==G.far)&&(e.updateRenderState({depthNear:G.near,depthFar:G.far}),v=G.near,N=G.far);let IA=$.parent,hA=G.cameras;AA(G,IA);for(let DA=0;DADA&&(y.set(QA,QA.lastChangedTime),I.dispatchEvent({type:"planechanged",data:QA}))}}E=null}let rA=new bN;rA.setAnimationLoop(iA),this.setAnimationLoop=function($){BA=$},this.dispose=function(){}}};function mH(g,A){function I(h,l){l.color.getRGB(h.fogColor.value,LN(g)),l.isFog?(h.fogNear.value=l.near,h.fogFar.value=l.far):l.isFogExp2&&(h.fogDensity.value=l.density)}function e(h,l,c,d,u){l.isMeshBasicMaterial||l.isMeshLambertMaterial?i(h,l):l.isMeshToonMaterial?(i(h,l),s(h,l)):l.isMeshPhongMaterial?(i(h,l),a(h,l)):l.isMeshStandardMaterial?(i(h,l),r(h,l),l.isMeshPhysicalMaterial&&Q(h,l,u)):l.isMeshMatcapMaterial?(i(h,l),E(h,l)):l.isMeshDepthMaterial?i(h,l):l.isMeshDistanceMaterial?(i(h,l),n(h,l)):l.isMeshNormalMaterial?i(h,l):l.isLineBasicMaterial?(t(h,l),l.isLineDashedMaterial&&C(h,l)):l.isPointsMaterial?o(h,l,c,d):l.isSpriteMaterial?B(h,l):l.isShadowMaterial?(h.color.value.copy(l.color),h.opacity.value=l.opacity):l.isShaderMaterial&&(l.uniformsNeedUpdate=!1)}function i(h,l){h.opacity.value=l.opacity,l.color&&h.diffuse.value.copy(l.color),l.emissive&&h.emissive.value.copy(l.emissive).multiplyScalar(l.emissiveIntensity),l.map&&(h.map.value=l.map),l.alphaMap&&(h.alphaMap.value=l.alphaMap),l.bumpMap&&(h.bumpMap.value=l.bumpMap,h.bumpScale.value=l.bumpScale,l.side===ni&&(h.bumpScale.value*=-1)),l.displacementMap&&(h.displacementMap.value=l.displacementMap,h.displacementScale.value=l.displacementScale,h.displacementBias.value=l.displacementBias),l.emissiveMap&&(h.emissiveMap.value=l.emissiveMap),l.normalMap&&(h.normalMap.value=l.normalMap,h.normalScale.value.copy(l.normalScale),l.side===ni&&h.normalScale.value.negate()),l.specularMap&&(h.specularMap.value=l.specularMap),l.alphaTest>0&&(h.alphaTest.value=l.alphaTest);let c=A.get(l).envMap;if(c&&(h.envMap.value=c,h.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1,h.reflectivity.value=l.reflectivity,h.ior.value=l.ior,h.refractionRatio.value=l.refractionRatio),l.lightMap){h.lightMap.value=l.lightMap;let y=g.physicallyCorrectLights!==!0?Math.PI:1;h.lightMapIntensity.value=l.lightMapIntensity*y}l.aoMap&&(h.aoMap.value=l.aoMap,h.aoMapIntensity.value=l.aoMapIntensity);let d;l.map?d=l.map:l.specularMap?d=l.specularMap:l.displacementMap?d=l.displacementMap:l.normalMap?d=l.normalMap:l.bumpMap?d=l.bumpMap:l.roughnessMap?d=l.roughnessMap:l.metalnessMap?d=l.metalnessMap:l.alphaMap?d=l.alphaMap:l.emissiveMap?d=l.emissiveMap:l.clearcoatMap?d=l.clearcoatMap:l.clearcoatNormalMap?d=l.clearcoatNormalMap:l.clearcoatRoughnessMap?d=l.clearcoatRoughnessMap:l.iridescenceMap?d=l.iridescenceMap:l.iridescenceThicknessMap?d=l.iridescenceThicknessMap:l.specularIntensityMap?d=l.specularIntensityMap:l.specularColorMap?d=l.specularColorMap:l.transmissionMap?d=l.transmissionMap:l.thicknessMap?d=l.thicknessMap:l.sheenColorMap?d=l.sheenColorMap:l.sheenRoughnessMap&&(d=l.sheenRoughnessMap),d!==void 0&&(d.isWebGLRenderTarget&&(d=d.texture),d.matrixAutoUpdate===!0&&d.updateMatrix(),h.uvTransform.value.copy(d.matrix));let u;l.aoMap?u=l.aoMap:l.lightMap&&(u=l.lightMap),u!==void 0&&(u.isWebGLRenderTarget&&(u=u.texture),u.matrixAutoUpdate===!0&&u.updateMatrix(),h.uv2Transform.value.copy(u.matrix))}function t(h,l){h.diffuse.value.copy(l.color),h.opacity.value=l.opacity}function C(h,l){h.dashSize.value=l.dashSize,h.totalSize.value=l.dashSize+l.gapSize,h.scale.value=l.scale}function o(h,l,c,d){h.diffuse.value.copy(l.color),h.opacity.value=l.opacity,h.size.value=l.size*c,h.scale.value=d*.5,l.map&&(h.map.value=l.map),l.alphaMap&&(h.alphaMap.value=l.alphaMap),l.alphaTest>0&&(h.alphaTest.value=l.alphaTest);let u;l.map?u=l.map:l.alphaMap&&(u=l.alphaMap),u!==void 0&&(u.matrixAutoUpdate===!0&&u.updateMatrix(),h.uvTransform.value.copy(u.matrix))}function B(h,l){h.diffuse.value.copy(l.color),h.opacity.value=l.opacity,h.rotation.value=l.rotation,l.map&&(h.map.value=l.map),l.alphaMap&&(h.alphaMap.value=l.alphaMap),l.alphaTest>0&&(h.alphaTest.value=l.alphaTest);let c;l.map?c=l.map:l.alphaMap&&(c=l.alphaMap),c!==void 0&&(c.matrixAutoUpdate===!0&&c.updateMatrix(),h.uvTransform.value.copy(c.matrix))}function a(h,l){h.specular.value.copy(l.specular),h.shininess.value=Math.max(l.shininess,1e-4)}function s(h,l){l.gradientMap&&(h.gradientMap.value=l.gradientMap)}function r(h,l){h.roughness.value=l.roughness,h.metalness.value=l.metalness,l.roughnessMap&&(h.roughnessMap.value=l.roughnessMap),l.metalnessMap&&(h.metalnessMap.value=l.metalnessMap),A.get(l).envMap&&(h.envMapIntensity.value=l.envMapIntensity)}function Q(h,l,c){h.ior.value=l.ior,l.sheen>0&&(h.sheenColor.value.copy(l.sheenColor).multiplyScalar(l.sheen),h.sheenRoughness.value=l.sheenRoughness,l.sheenColorMap&&(h.sheenColorMap.value=l.sheenColorMap),l.sheenRoughnessMap&&(h.sheenRoughnessMap.value=l.sheenRoughnessMap)),l.clearcoat>0&&(h.clearcoat.value=l.clearcoat,h.clearcoatRoughness.value=l.clearcoatRoughness,l.clearcoatMap&&(h.clearcoatMap.value=l.clearcoatMap),l.clearcoatRoughnessMap&&(h.clearcoatRoughnessMap.value=l.clearcoatRoughnessMap),l.clearcoatNormalMap&&(h.clearcoatNormalScale.value.copy(l.clearcoatNormalScale),h.clearcoatNormalMap.value=l.clearcoatNormalMap,l.side===ni&&h.clearcoatNormalScale.value.negate())),l.iridescence>0&&(h.iridescence.value=l.iridescence,h.iridescenceIOR.value=l.iridescenceIOR,h.iridescenceThicknessMinimum.value=l.iridescenceThicknessRange[0],h.iridescenceThicknessMaximum.value=l.iridescenceThicknessRange[1],l.iridescenceMap&&(h.iridescenceMap.value=l.iridescenceMap),l.iridescenceThicknessMap&&(h.iridescenceThicknessMap.value=l.iridescenceThicknessMap)),l.transmission>0&&(h.transmission.value=l.transmission,h.transmissionSamplerMap.value=c.texture,h.transmissionSamplerSize.value.set(c.width,c.height),l.transmissionMap&&(h.transmissionMap.value=l.transmissionMap),h.thickness.value=l.thickness,l.thicknessMap&&(h.thicknessMap.value=l.thicknessMap),h.attenuationDistance.value=l.attenuationDistance,h.attenuationColor.value.copy(l.attenuationColor)),h.specularIntensity.value=l.specularIntensity,h.specularColor.value.copy(l.specularColor),l.specularIntensityMap&&(h.specularIntensityMap.value=l.specularIntensityMap),l.specularColorMap&&(h.specularColorMap.value=l.specularColorMap)}function E(h,l){l.matcap&&(h.matcap.value=l.matcap)}function n(h,l){h.referencePosition.value.copy(l.referencePosition),h.nearDistance.value=l.nearDistance,h.farDistance.value=l.farDistance}return{refreshFogUniforms:I,refreshMaterialUniforms:e}}function UH(g,A,I,e){let i={},t={},C=[],o=I.isWebGL2?g.getParameter(35375):0;function B(d,u){let y=u.program;e.uniformBlockBinding(d,y)}function a(d,u){let y=i[d.id];y===void 0&&(n(d),y=s(d),i[d.id]=y,d.addEventListener("dispose",l));let f=u.program;e.updateUBOMapping(d,f);let k=A.render.frame;t[d.id]!==k&&(Q(d),t[d.id]=k)}function s(d){let u=r();d.__bindingPointIndex=u;let y=g.createBuffer(),f=d.__size,k=d.usage;return g.bindBuffer(35345,y),g.bufferData(35345,f,k),g.bindBuffer(35345,null),g.bindBufferBase(35345,u,y),y}function r(){for(let d=0;d0){k=y%f;let O=f-k;k!==0&&O-N.boundary<0&&(y+=f-k,v.__offset=y)}y+=N.storage}return k=y%f,k>0&&(y+=f-k),d.__size=y,d.__cache={},this}function h(d){let u={boundary:0,storage:0};return typeof d=="number"?(u.boundary=4,u.storage=4):d.isVector2?(u.boundary=8,u.storage=8):d.isVector3||d.isColor?(u.boundary=16,u.storage=12):d.isVector4?(u.boundary=16,u.storage=16):d.isMatrix3?(u.boundary=48,u.storage=48):d.isMatrix4?(u.boundary=64,u.storage=64):d.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",d),u}function l(d){let u=d.target;u.removeEventListener("dispose",l);let y=C.indexOf(u.__bindingPointIndex);C.splice(y,1),g.deleteBuffer(i[u.id]),delete i[u.id],delete t[u.id]}function c(){for(let d in i)g.deleteBuffer(i[d]);C=[],i={},t={}}return{bind:B,update:a,dispose:c}}function NH(){let g=Dc("canvas");return g.style.display="block",g}function _N(g={}){this.isWebGLRenderer=!0;let A=g.canvas!==void 0?g.canvas:NH(),I=g.context!==void 0?g.context:null,e=g.depth!==void 0?g.depth:!0,i=g.stencil!==void 0?g.stencil:!0,t=g.antialias!==void 0?g.antialias:!1,C=g.premultipliedAlpha!==void 0?g.premultipliedAlpha:!0,o=g.preserveDrawingBuffer!==void 0?g.preserveDrawingBuffer:!1,B=g.powerPreference!==void 0?g.powerPreference:"default",a=g.failIfMajorPerformanceCaveat!==void 0?g.failIfMajorPerformanceCaveat:!1,s;I!==null?s=I.getContextAttributes().alpha:s=g.alpha!==void 0?g.alpha:!1;let r=null,Q=null,E=[],n=[];this.domElement=A,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=fo,this.physicallyCorrectLights=!1,this.toneMapping=DB,this.toneMappingExposure=1;let h=this,l=!1,c=0,d=0,u=null,y=-1,f=null,k=new EI,M=new EI,G=null,v=A.width,N=A.height,b=1,O=null,H=null,_=new EI(0,0,v,N),gA=new EI(0,0,v,N),CA=!1,AA=new xw,BA=!1,iA=!1,rA=null,$=new zA,IA=new sA,hA=new J,QA={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function DA(){return u===null?b:1}let eA=I;function aA(z,mA){for(let vA=0;vA0?Q=n[n.length-1]:Q=null,E.pop(),E.length>0?r=E[E.length-1]:r=null};function qI(z,mA,vA,GA){if(z.visible===!1)return;if(z.layers.test(mA.layers)){if(z.isGroup)vA=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(mA);else if(z.isLight)Q.pushLight(z),z.castShadow&&Q.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||AA.intersectsSprite(z)){GA&&hA.setFromMatrixPosition(z.matrixWorld).applyMatrix4($);let Gg=Eg.update(z),Jg=z.material;Jg.visible&&r.push(z,Gg,Jg,vA,hA.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(z.isSkinnedMesh&&z.skeleton.frame!==VA.render.frame&&(z.skeleton.update(),z.skeleton.frame=VA.render.frame),!z.frustumCulled||AA.intersectsObject(z))){GA&&hA.setFromMatrixPosition(z.matrixWorld).applyMatrix4($);let Gg=Eg.update(z),Jg=z.material;if(Array.isArray(Jg)){let Xg=Gg.groups;for(let xg=0,tI=Xg.length;xg0&&be(bA,mA,vA),GA&&uA.viewport(k.copy(GA)),bA.length>0&&NI(bA,mA,vA),Gg.length>0&&NI(Gg,mA,vA),Jg.length>0&&NI(Jg,mA,vA),uA.buffers.depth.setTest(!0),uA.buffers.depth.setMask(!0),uA.buffers.color.setMask(!0),uA.setPolygonOffset(!1)}function be(z,mA,vA){let GA=fA.isWebGL2;rA===null&&(rA=new WI(1,1,{generateMipmaps:!0,type:nA.has("EXT_color_buffer_half_float")?fQ:vi,minFilter:SQ,samples:GA&&t===!0?4:0})),h.getDrawingBufferSize(IA),GA?rA.setSize(IA.x,IA.y):rA.setSize(cc(IA.x),cc(IA.y));let bA=h.getRenderTarget();h.setRenderTarget(rA),h.clear();let Gg=h.toneMapping;h.toneMapping=DB,NI(z,mA,vA),h.toneMapping=Gg,LA.updateMultisampleRenderTarget(rA),LA.updateRenderTargetMipmap(rA),h.setRenderTarget(bA)}function NI(z,mA,vA){let GA=mA.isScene===!0?mA.overrideMaterial:null;for(let bA=0,Gg=z.length;bA0&&LA.useMultisampledRTT(z)===!1?bA=yA.get(z).__webglMultisampledFramebuffer:bA=tI,k.copy(z.viewport),M.copy(z.scissor),G=z.scissorTest}else k.copy(_).multiplyScalar(b).floor(),M.copy(gA).multiplyScalar(b).floor(),G=CA;if(uA.bindFramebuffer(36160,bA)&&fA.drawBuffers&&GA&&uA.drawBuffers(z,bA),uA.viewport(k),uA.scissor(M),uA.setScissorTest(G),Gg){let Xg=yA.get(z.texture);eA.framebufferTexture2D(36160,36064,34069+mA,Xg.__webglTexture,vA)}else if(Jg){let Xg=yA.get(z.texture),xg=mA||0;eA.framebufferTextureLayer(36160,36064,Xg.__webglTexture,vA||0,xg)}y=-1},this.readRenderTargetPixels=function(z,mA,vA,GA,bA,Gg,Jg){if(!(z&&z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Xg=yA.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&Jg!==void 0&&(Xg=Xg[Jg]),Xg){uA.bindFramebuffer(36160,Xg);try{let xg=z.texture,tI=xg.format,uI=xg.type;if(tI!==$t&&Cg.convert(tI)!==eA.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let hI=uI===fQ&&(nA.has("EXT_color_buffer_half_float")||fA.isWebGL2&&nA.has("EXT_color_buffer_float"));if(uI!==vi&&Cg.convert(uI)!==eA.getParameter(35738)&&!(uI===Rt&&(fA.isWebGL2||nA.has("OES_texture_float")||nA.has("WEBGL_color_buffer_float")))&&!hI){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}mA>=0&&mA<=z.width-GA&&vA>=0&&vA<=z.height-bA&&eA.readPixels(mA,vA,GA,bA,Cg.convert(tI),Cg.convert(uI),Gg)}finally{let xg=u!==null?yA.get(u).__webglFramebuffer:null;uA.bindFramebuffer(36160,xg)}}},this.copyFramebufferToTexture=function(z,mA,vA=0){let GA=Math.pow(2,-vA),bA=Math.floor(mA.image.width*GA),Gg=Math.floor(mA.image.height*GA);LA.setTexture2D(mA,0),eA.copyTexSubImage2D(3553,vA,0,0,z.x,z.y,bA,Gg),uA.unbindTexture()},this.copyTextureToTexture=function(z,mA,vA,GA=0){let bA=mA.image.width,Gg=mA.image.height,Jg=Cg.convert(vA.format),Xg=Cg.convert(vA.type);LA.setTexture2D(vA,0),eA.pixelStorei(37440,vA.flipY),eA.pixelStorei(37441,vA.premultiplyAlpha),eA.pixelStorei(3317,vA.unpackAlignment),mA.isDataTexture?eA.texSubImage2D(3553,GA,z.x,z.y,bA,Gg,Jg,Xg,mA.image.data):mA.isCompressedTexture?eA.compressedTexSubImage2D(3553,GA,z.x,z.y,mA.mipmaps[0].width,mA.mipmaps[0].height,Jg,mA.mipmaps[0].data):eA.texSubImage2D(3553,GA,z.x,z.y,Jg,Xg,mA.image),GA===0&&vA.generateMipmaps&&eA.generateMipmap(3553),uA.unbindTexture()},this.copyTextureToTexture3D=function(z,mA,vA,GA,bA=0){if(h.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Gg=z.max.x-z.min.x+1,Jg=z.max.y-z.min.y+1,Xg=z.max.z-z.min.z+1,xg=Cg.convert(GA.format),tI=Cg.convert(GA.type),uI;if(GA.isData3DTexture)LA.setTexture3D(GA,0),uI=32879;else if(GA.isDataArrayTexture)LA.setTexture2DArray(GA,0),uI=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}eA.pixelStorei(37440,GA.flipY),eA.pixelStorei(37441,GA.premultiplyAlpha),eA.pixelStorei(3317,GA.unpackAlignment);let hI=eA.getParameter(3314),FI=eA.getParameter(32878),ce=eA.getParameter(3316),di=eA.getParameter(3315),Gi=eA.getParameter(32877),Ie=vA.isCompressedTexture?vA.mipmaps[0]:vA.image;eA.pixelStorei(3314,Ie.width),eA.pixelStorei(32878,Ie.height),eA.pixelStorei(3316,z.min.x),eA.pixelStorei(3315,z.min.y),eA.pixelStorei(32877,z.min.z),vA.isDataTexture||vA.isData3DTexture?eA.texSubImage3D(uI,bA,mA.x,mA.y,mA.z,Gg,Jg,Xg,xg,tI,Ie.data):vA.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),eA.compressedTexSubImage3D(uI,bA,mA.x,mA.y,mA.z,Gg,Jg,Xg,xg,Ie.data)):eA.texSubImage3D(uI,bA,mA.x,mA.y,mA.z,Gg,Jg,Xg,xg,tI,Ie),eA.pixelStorei(3314,hI),eA.pixelStorei(32878,FI),eA.pixelStorei(3316,ce),eA.pixelStorei(3315,di),eA.pixelStorei(32877,Gi),bA===0&&GA.generateMipmaps&&eA.generateMipmap(uI),uA.unbindTexture()},this.initTexture=function(z){z.isCubeTexture?LA.setTextureCube(z,0):z.isData3DTexture?LA.setTexture3D(z,0):z.isDataArrayTexture||z.isCompressedArrayTexture?LA.setTexture2DArray(z,0):LA.setTexture2D(z,0),uA.unbindTexture()},this.resetState=function(){c=0,d=0,u=null,uA.reset(),UA.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var FH=class extends _N{};FH.prototype.isWebGL1Renderer=!0;var PN=class{constructor(g,A=1,I=1e3){this.isFog=!0,this.name="",this.color=new Og(g),this.near=A,this.far=I}clone(){return new PN(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ca=class extends ZI{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(g,A){return super.copy(g,A),g.background!==null&&(this.background=g.background.clone()),g.environment!==null&&(this.environment=g.environment.clone()),g.fog!==null&&(this.fog=g.fog.clone()),this.backgroundBlurriness=g.backgroundBlurriness,this.backgroundIntensity=g.backgroundIntensity,g.overrideMaterial!==null&&(this.overrideMaterial=g.overrideMaterial.clone()),this.matrixAutoUpdate=g.matrixAutoUpdate,this}toJSON(g){let A=super.toJSON(g);return this.fog!==null&&(A.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(A.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(A.object.backgroundIntensity=this.backgroundIntensity),A}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(g){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=g}},RH=class{constructor(g,A){this.isInterleavedBuffer=!0,this.array=g,this.stride=A,this.count=g!==void 0?g.length/A:0,this.usage=xp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=IC()}onUploadCallback(){}set needsUpdate(g){g===!0&&this.version++}setUsage(g){return this.usage=g,this}copy(g){return this.array=new g.array.constructor(g.array),this.count=g.count,this.stride=g.stride,this.usage=g.usage,this}copyAt(g,A,I){g*=this.stride,I*=A.stride;for(let e=0,i=this.stride;eo)continue;r.applyMatrix4(this.matrixWorld);let f=g.ray.origin.distanceTo(r);fg.far||A.push({distance:f,point:s.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this})}}else{let h=Math.max(0,t.start),l=Math.min(n.count,t.start+t.count);for(let c=h,d=l-1;co)continue;r.applyMatrix4(this.matrixWorld);let u=g.ray.origin.distanceTo(r);ug.far||A.push({distance:u,point:s.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let g=this.geometry.morphAttributes,A=Object.keys(g);if(A.length>0){let I=g[A[0]];if(I!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=I.length;e=g.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},Fo=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(A,I){let e=this.getUtoTmapping(A);return this.getPoint(e,I)}getPoints(A=5){let I=[];for(let e=0;e<=A;e++)I.push(this.getPoint(e/A));return I}getSpacedPoints(A=5){let I=[];for(let e=0;e<=A;e++)I.push(this.getPointAt(e/A));return I}getLength(){let A=this.getLengths();return A[A.length-1]}getLengths(A=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===A+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let I=[],e,i=this.getPoint(0),t=0;I.push(0);for(let C=1;C<=A;C++)e=this.getPoint(C/A),t+=e.distanceTo(i),I.push(t),i=e;return this.cacheArcLengths=I,I}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(A,I){let e=this.getLengths(),i=0,t=e.length,C;I?C=I:C=A*e[t-1];let o=0,B=t-1,a;for(;o<=B;)if(i=Math.floor(o+(B-o)/2),a=e[i]-C,a<0)o=i+1;else if(a>0)B=i-1;else{B=i;break}if(i=B,e[i]===C)return i/(t-1);let s=e[i],r=e[i+1]-s,Q=(C-s)/r;return(i+Q)/(t-1)}getTangent(A,I){let e=A-1e-4,i=A+1e-4;e<0&&(e=0),i>1&&(i=1);let t=this.getPoint(e),C=this.getPoint(i),o=I||(t.isVector2?new sA:new J);return o.copy(C).sub(t).normalize(),o}getTangentAt(A,I){let e=this.getUtoTmapping(A);return this.getTangent(e,I)}computeFrenetFrames(A,I){let e=new J,i=[],t=[],C=[],o=new J,B=new zA;for(let E=0;E<=A;E++){let n=E/A;i[E]=this.getTangentAt(n,new J)}t[0]=new J,C[0]=new J;let a=Number.MAX_VALUE,s=Math.abs(i[0].x),r=Math.abs(i[0].y),Q=Math.abs(i[0].z);s<=a&&(a=s,e.set(1,0,0)),r<=a&&(a=r,e.set(0,1,0)),Q<=a&&e.set(0,0,1),o.crossVectors(i[0],e).normalize(),t[0].crossVectors(i[0],o),C[0].crossVectors(i[0],t[0]);for(let E=1;E<=A;E++){if(t[E]=t[E-1].clone(),C[E]=C[E-1].clone(),o.crossVectors(i[E-1],i[E]),o.length()>Number.EPSILON){o.normalize();let n=Math.acos(ii(i[E-1].dot(i[E]),-1,1));t[E].applyMatrix4(B.makeRotationAxis(o,n))}C[E].crossVectors(i[E],t[E])}if(I===!0){let E=Math.acos(ii(t[0].dot(t[A]),-1,1));E/=A,i[0].dot(o.crossVectors(t[0],t[A]))>0&&(E=-E);for(let n=1;n<=A;n++)t[n].applyMatrix4(B.makeRotationAxis(i[n],E*n)),C[n].crossVectors(i[n],t[n])}return{tangents:i,normals:t,binormals:C}}clone(){return new this.constructor().copy(this)}copy(A){return this.arcLengthDivisions=A.arcLengthDivisions,this}toJSON(){let A={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return A.arcLengthDivisions=this.arcLengthDivisions,A.type=this.type,A}fromJSON(A){return this.arcLengthDivisions=A.arcLengthDivisions,this}},KD=class extends Fo{constructor(g=0,A=0,I=1,e=1,i=0,t=Math.PI*2,C=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=g,this.aY=A,this.xRadius=I,this.yRadius=e,this.aStartAngle=i,this.aEndAngle=t,this.aClockwise=C,this.aRotation=o}getPoint(g,A){let I=A||new sA,e=Math.PI*2,i=this.aEndAngle-this.aStartAngle,t=Math.abs(i)e;)i-=e;i0?0:(Math.floor(Math.abs(C)/i)+1)*i:o===0&&C===i-1&&(C=i-2,o=1);let B,a;this.closed||C>0?B=e[(C-1)%i]:(Ph.subVectors(e[0],e[1]).add(e[0]),B=Ph);let s=e[C%i],r=e[(C+1)%i];if(this.closed||C+2e.length-2?e.length-1:t+1],s=e[t>e.length-3?e.length-1:t+2];return I.set(pG(C,o.x,B.x,a.x,s.x),pG(C,o.y,B.y,a.y,s.y)),I}copy(g){super.copy(g),this.points=[];for(let A=0,I=g.points.length;A=I){let t=e[i]-I,C=this.curves[i],o=C.getLength(),B=o===0?0:1-t/o;return C.getPointAt(B,A)}i++}return null}getLength(){let g=this.getCurveLengths();return g[g.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 g=[],A=0;for(let I=0,e=this.curves.length;I1&&!A[A.length-1].equals(A[0])&&A.push(A[0]),A}copy(g){super.copy(g),this.curves=[];for(let A=0,I=g.curves.length;A0){let s=B.getPoint(0);s.equals(this.currentPoint)||this.lineTo(s.x,s.y)}this.curves.push(B);let a=B.getPoint(1);return this.currentPoint.copy(a),this}copy(g){return super.copy(g),this.currentPoint.copy(g.currentPoint),this}toJSON(){let g=super.toJSON();return g.currentPoint=this.currentPoint.toArray(),g}fromJSON(g){return super.fromJSON(g),this.currentPoint.fromArray(g.currentPoint),this}},VN=class extends bg{constructor(g=[new sA(0,-.5),new sA(.5,0),new sA(0,.5)],A=12,I=0,e=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:g,segments:A,phiStart:I,phiLength:e},A=Math.floor(A),e=ii(e,0,Math.PI*2);let i=[],t=[],C=[],o=[],B=[],a=1/A,s=new J,r=new sA,Q=new J,E=new J,n=new J,h=0,l=0;for(let c=0;c<=g.length-1;c++)switch(c){case 0:h=g[c+1].x-g[c].x,l=g[c+1].y-g[c].y,Q.x=l*1,Q.y=-h,Q.z=l*0,n.copy(Q),Q.normalize(),o.push(Q.x,Q.y,Q.z);break;case g.length-1:o.push(n.x,n.y,n.z);break;default:h=g[c+1].x-g[c].x,l=g[c+1].y-g[c].y,Q.x=l*1,Q.y=-h,Q.z=l*0,E.copy(Q),Q.x+=n.x,Q.y+=n.y,Q.z+=n.z,Q.normalize(),o.push(Q.x,Q.y,Q.z),n.copy(E)}for(let c=0;c<=A;c++){let d=I+c*a*e,u=Math.sin(d),y=Math.cos(d);for(let f=0;f<=g.length-1;f++){s.x=g[f].x*u,s.y=g[f].y,s.z=g[f].x*y,t.push(s.x,s.y,s.z),r.x=c/A,r.y=f/(g.length-1),C.push(r.x,r.y);let k=o[3*f+0]*u,M=o[3*f+1],G=o[3*f+0]*y;B.push(k,M,G)}}for(let c=0;c0&&d(!0),A>0&&d(!1)),this.setIndex(a),this.setAttribute("position",new pg(s,3)),this.setAttribute("normal",new pg(r,3)),this.setAttribute("uv",new pg(Q,2));function c(){let u=new J,y=new J,f=0,k=(A-g)/I;for(let M=0;M<=i;M++){let G=[],v=M/i,N=v*(A-g)+g;for(let b=0;b<=e;b++){let O=b/e,H=O*o+C,_=Math.sin(H),gA=Math.cos(H);y.x=N*_,y.y=-v*I+h,y.z=N*gA,s.push(y.x,y.y,y.z),u.set(_,k,gA).normalize(),r.push(u.x,u.y,u.z),Q.push(O,1-v),G.push(E++)}n.push(G)}for(let M=0;M.9&&k<.1&&(d<.2&&(t[c+0]+=1),u<.2&&(t[c+2]+=1),y<.2&&(t[c+4]+=1))}}function r(c){i.push(c.x,c.y,c.z)}function Q(c,d){let u=c*3;d.x=g[u+0],d.y=g[u+1],d.z=g[u+2]}function E(){let c=new J,d=new J,u=new J,y=new J,f=new sA,k=new sA,M=new sA;for(let G=0,v=0;G80*I){o=a=g[0],B=s=g[1];for(let n=I;na&&(a=r),Q>s&&(s=Q);E=Math.max(a-o,s-B),E=E!==0?32767/E:0}return un(t,C,I,o,B,E,0),C}};function $N(g,A,I,e,i){let t,C;if(i===r1(g,A,I,e)>0)for(t=A;t=A;t-=e)C=yG(t,g[t],g[t+1],C);return C&&JD(C,C.next)&&(yn(C),C=C.next),C}function Rr(g,A){if(!g)return g;A||(A=g);let I=g,e;do if(e=!1,!I.steiner&&(JD(I,I.next)||ue(I.prev,I,I.next)===0)){if(yn(I),I=A=I.prev,I===I.next)break;e=!0}else I=I.next;while(e||I!==A);return A}function un(g,A,I,e,i,t,C){if(!g)return;!C&&t&&i1(g,e,i,t);let o=g,B,a;for(;g.prev!==g.next;){if(B=g.prev,a=g.next,t?VH(g,e,i,t):ZH(g)){A.push(B.i/I|0),A.push(g.i/I|0),A.push(a.i/I|0),yn(g),g=a.next,o=a.next;continue}if(g=a,g===o){C?C===1?(g=zH(Rr(g),A,I),un(g,A,I,e,i,t,2)):C===2&&XH(g,A,I,e,i,t):un(Rr(g),A,I,e,i,t,1);break}}}function ZH(g){let A=g.prev,I=g,e=g.next;if(ue(A,I,e)>=0)return!1;let i=A.x,t=I.x,C=e.x,o=A.y,B=I.y,a=e.y,s=it?i>C?i:C:t>C?t:C,E=o>B?o>a?o:a:B>a?B:a,n=e.next;for(;n!==A;){if(n.x>=s&&n.x<=Q&&n.y>=r&&n.y<=E&&IQ(i,o,t,B,C,a,n.x,n.y)&&ue(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function VH(g,A,I,e){let i=g.prev,t=g,C=g.next;if(ue(i,t,C)>=0)return!1;let o=i.x,B=t.x,a=C.x,s=i.y,r=t.y,Q=C.y,E=oB?o>a?o:a:B>a?B:a,l=s>r?s>Q?s:Q:r>Q?r:Q,c=Pp(E,n,A,I,e),d=Pp(h,l,A,I,e),u=g.prevZ,y=g.nextZ;for(;u&&u.z>=c&&y&&y.z<=d;){if(u.x>=E&&u.x<=h&&u.y>=n&&u.y<=l&&u!==i&&u!==C&&IQ(o,s,B,r,a,Q,u.x,u.y)&&ue(u.prev,u,u.next)>=0||(u=u.prevZ,y.x>=E&&y.x<=h&&y.y>=n&&y.y<=l&&y!==i&&y!==C&&IQ(o,s,B,r,a,Q,y.x,y.y)&&ue(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;u&&u.z>=c;){if(u.x>=E&&u.x<=h&&u.y>=n&&u.y<=l&&u!==i&&u!==C&&IQ(o,s,B,r,a,Q,u.x,u.y)&&ue(u.prev,u,u.next)>=0)return!1;u=u.prevZ}for(;y&&y.z<=d;){if(y.x>=E&&y.x<=h&&y.y>=n&&y.y<=l&&y!==i&&y!==C&&IQ(o,s,B,r,a,Q,y.x,y.y)&&ue(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function zH(g,A,I){let e=g;do{let i=e.prev,t=e.next.next;!JD(i,t)&&AF(i,e,e.next,t)&&pn(i,t)&&pn(t,i)&&(A.push(i.i/I|0),A.push(e.i/I|0),A.push(t.i/I|0),yn(e),yn(e.next),e=g=t),e=e.next}while(e!==g);return Rr(e)}function XH(g,A,I,e,i,t){let C=g;do{let o=C.next.next;for(;o!==C.prev;){if(C.i!==o.i&&o1(C,o)){let B=gF(C,o);C=Rr(C,C.next),B=Rr(B,B.next),un(C,A,I,e,i,t,0),un(B,A,I,e,i,t,0);return}o=o.next}C=C.next}while(C!==g)}function $H(g,A,I,e){let i=[],t,C,o,B,a;for(t=0,C=A.length;t=I.next.y&&I.next.y!==I.y){let Q=I.x+(C-I.y)*(I.next.x-I.x)/(I.next.y-I.y);if(Q<=t&&Q>e&&(e=Q,i=I.x=I.x&&I.x>=B&&t!==I.x&&IQ(Ci.x||I.x===i.x&&e1(i,I)))&&(i=I,s=r)),I=I.next;while(I!==o);return i}function e1(g,A){return ue(g.prev,g,A.prev)<0&&ue(A.next,g,g.next)<0}function i1(g,A,I,e){let i=g;do i.z===0&&(i.z=Pp(i.x,i.y,A,I,e)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==g);i.prevZ.nextZ=null,i.prevZ=null,t1(i)}function t1(g){let A,I,e,i,t,C,o,B,a=1;do{for(I=g,g=null,t=null,C=0;I;){for(C++,e=I,o=0,A=0;A0||B>0&&e;)o!==0&&(B===0||!e||I.z<=e.z)?(i=I,I=I.nextZ,o--):(i=e,e=e.nextZ,B--),t?t.nextZ=i:g=i,i.prevZ=t,t=i;I=e}t.nextZ=null,a*=2}while(C>1);return g}function Pp(g,A,I,e,i){return g=(g-I)*i|0,A=(A-e)*i|0,g=(g|g<<8)&16711935,g=(g|g<<4)&252645135,g=(g|g<<2)&858993459,g=(g|g<<1)&1431655765,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,g|A<<1}function C1(g){let A=g,I=g;do(A.x=(g-C)*(t-o)&&(g-C)*(e-o)>=(I-C)*(A-o)&&(I-C)*(t-o)>=(i-C)*(e-o)}function o1(g,A){return g.next.i!==A.i&&g.prev.i!==A.i&&!B1(g,A)&&(pn(g,A)&&pn(A,g)&&a1(g,A)&&(ue(g.prev,g,A.prev)||ue(g,A.prev,A))||JD(g,A)&&ue(g.prev,g,g.next)>0&&ue(A.prev,A,A.next)>0)}function ue(g,A,I){return(A.y-g.y)*(I.x-A.x)-(A.x-g.x)*(I.y-A.y)}function JD(g,A){return g.x===A.x&&g.y===A.y}function AF(g,A,I,e){let i=Wh(ue(g,A,I)),t=Wh(ue(g,A,e)),C=Wh(ue(I,e,g)),o=Wh(ue(I,e,A));return!!(i!==t&&C!==o||i===0&&jh(g,I,A)||t===0&&jh(g,e,A)||C===0&&jh(I,g,e)||o===0&&jh(I,A,e))}function jh(g,A,I){return A.x<=Math.max(g.x,I.x)&&A.x>=Math.min(g.x,I.x)&&A.y<=Math.max(g.y,I.y)&&A.y>=Math.min(g.y,I.y)}function Wh(g){return g>0?1:g<0?-1:0}function B1(g,A){let I=g;do{if(I.i!==g.i&&I.next.i!==g.i&&I.i!==A.i&&I.next.i!==A.i&&AF(I,I.next,g,A))return!0;I=I.next}while(I!==g);return!1}function pn(g,A){return ue(g.prev,g,g.next)<0?ue(g,A,g.next)>=0&&ue(g,g.prev,A)>=0:ue(g,A,g.prev)<0||ue(g,g.next,A)<0}function a1(g,A){let I=g,e=!1,i=(g.x+A.x)/2,t=(g.y+A.y)/2;do I.y>t!=I.next.y>t&&I.next.y!==I.y&&i<(I.next.x-I.x)*(t-I.y)/(I.next.y-I.y)+I.x&&(e=!e),I=I.next;while(I!==g);return e}function gF(g,A){let I=new jp(g.i,g.x,g.y),e=new jp(A.i,A.x,A.y),i=g.next,t=A.prev;return g.next=A,A.prev=g,I.next=i,i.prev=I,e.next=I,I.prev=e,t.next=e,e.prev=t,e}function yG(g,A,I,e){let i=new jp(g,A,I);return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function yn(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function jp(g,A,I){this.i=g,this.x=A,this.y=I,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function r1(g,A,I,e){let i=0;for(let t=A,C=I-e;t2&&g[A-1].equals(g[0])&&g.pop()}function SG(g,A){for(let I=0;I0)&&Q.push(d,u,f),(l!==I-1||o=i)){let C=A[1];g=i)break g}t=I,I=0;break I}break A}for(;I>>1;gI;)--C;if(++C,t!==0||C!==i){t>=C&&(C=Math.max(C,1),t=C-1);let o=this.getValueSize();this.times=TB(e,t,C),this.values=TB(this.values,t*o,C*o)}return this}validate(){let A=!0,I=this.getValueSize();I-Math.floor(I)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),A=!1);let e=this.times,i=this.values,t=e.length;t===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),A=!1);let C=null;for(let o=0;o!==t;o++){let B=e[o];if(typeof B=="number"&&isNaN(B)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,B),A=!1;break}if(C!==null&&C>B){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,B,C),A=!1;break}C=B}if(i!==void 0&&tF(i))for(let o=0,B=i.length;o!==B;++o){let a=i[o];if(isNaN(a)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,a),A=!1;break}}return A}optimize(){let A=TB(this.times),I=TB(this.values),e=this.getValueSize(),i=this.getInterpolation()===Jd,t=A.length-1,C=1;for(let o=1;o0){A[C]=A[t];for(let o=t*e,B=C*e,a=0;a!==e;++a)I[B+a]=I[o+a];++C}return C!==A.length?(this.times=TB(A,0,C),this.values=TB(I,0,C*e)):(this.times=A,this.values=I),this}clone(){let A=TB(this.times,0),I=TB(this.values,0),e=this.constructor,i=new e(this.name,A,I);return i.createInterpolant=this.createInterpolant,i}};Ro.prototype.TimeBufferType=Float32Array;Ro.prototype.ValueBufferType=Float32Array;Ro.prototype.DefaultInterpolation=nc;var zQ=class extends Ro{};zQ.prototype.ValueTypeName="bool";zQ.prototype.ValueBufferType=Array;zQ.prototype.DefaultInterpolation=Ec;zQ.prototype.InterpolantFactoryMethodLinear=void 0;zQ.prototype.InterpolantFactoryMethodSmooth=void 0;var BF=class extends Ro{};BF.prototype.ValueTypeName="color";var wc=class extends Ro{};wc.prototype.ValueTypeName="number";var n1=class extends vD{constructor(g,A,I,e){super(g,A,I,e)}interpolate_(g,A,I,e){let i=this.resultBuffer,t=this.sampleValues,C=this.valueSize,o=(I-A)/(e-A),B=g*C;for(let a=B+C;B!==a;B+=4)QI.slerpFlat(i,0,t,B-C,t,B,o);return i}},Ah=class extends Ro{InterpolantFactoryMethodLinear(g){return new n1(this.times,this.values,this.getValueSize(),g)}};Ah.prototype.ValueTypeName="quaternion";Ah.prototype.DefaultInterpolation=nc;Ah.prototype.InterpolantFactoryMethodSmooth=void 0;var XQ=class extends Ro{};XQ.prototype.ValueTypeName="string";XQ.prototype.ValueBufferType=Array;XQ.prototype.DefaultInterpolation=Ec;XQ.prototype.InterpolantFactoryMethodLinear=void 0;XQ.prototype.InterpolantFactoryMethodSmooth=void 0;var Sc=class extends Ro{};Sc.prototype.ValueTypeName="vector";var Wp=class{constructor(g,A=-1,I,e=qw){this.name=g,this.tracks=I,this.duration=A,this.blendMode=e,this.uuid=IC(),this.duration<0&&this.resetDuration()}static parse(g){let A=[],I=g.tracks,e=1/(g.fps||1);for(let t=0,C=I.length;t!==C;++t)A.push(l1(I[t]).scale(e));let i=new this(g.name,g.duration,A,g.blendMode);return i.uuid=g.uuid,i}static toJSON(g){let A=[],I=g.tracks,e={name:g.name,duration:g.duration,tracks:A,uuid:g.uuid,blendMode:g.blendMode};for(let i=0,t=I.length;i!==t;++i)A.push(Ro.toJSON(I[i]));return e}static CreateFromMorphTargetSequence(g,A,I,e){let i=A.length,t=[];for(let C=0;C1){let s=a[1],r=e[s];r||(e[s]=r=[]),r.push(B)}}let t=[];for(let C in e)t.push(this.CreateFromMorphTargetSequence(C,e[C],A,I));return t}static parseAnimation(g,A){if(!g)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let I=function(a,s,r,Q,E){if(r.length!==0){let n=[],h=[];CF(r,n,h,Q),n.length!==0&&E.push(new a(s,n,h))}},e=[],i=g.name||"default",t=g.fps||30,C=g.blendMode,o=g.length||-1,B=g.hierarchy||[];for(let a=0;a{A&&A(i),this.manager.itemEnd(g)},0),i;if(AB[g]!==void 0){AB[g].push({onLoad:A,onProgress:I,onError:e});return}AB[g]=[],AB[g].push({onLoad:A,onProgress:I,onError:e});let t=new Request(g,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),C=this.mimeType,o=this.responseType;fetch(t).then(B=>{if(B.status===200||B.status===0){if(B.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||B.body===void 0||B.body.getReader===void 0)return B;let a=AB[g],s=B.body.getReader(),r=B.headers.get("Content-Length")||B.headers.get("X-File-Size"),Q=r?parseInt(r):0,E=Q!==0,n=0,h=new ReadableStream({start(l){c();function c(){s.read().then(({done:d,value:u})=>{if(d)l.close();else{n+=u.byteLength;let y=new ProgressEvent("progress",{lengthComputable:E,loaded:n,total:Q});for(let f=0,k=a.length;f{switch(o){case"arraybuffer":return B.arrayBuffer();case"blob":return B.blob();case"document":return B.text().then(a=>new DOMParser().parseFromString(a,C));case"json":return B.json();default:if(C===void 0)return B.text();{let a=/charset="?([^;"\s]*)"?/i.exec(C),s=a&&a[1]?a[1].toLowerCase():void 0,r=new TextDecoder(s);return B.arrayBuffer().then(Q=>r.decode(Q))}}}).then(B=>{GG.add(g,B);let a=AB[g];delete AB[g];for(let s=0,r=a.length;s{let a=AB[g];if(a===void 0)throw this.manager.itemError(g),B;delete AB[g];for(let s=0,r=a.length;s{this.manager.itemEnd(g)}),this.manager.itemStart(g)}setResponseType(g){return this.responseType=g,this}setMimeType(g){return this.mimeType=g,this}},gh=class extends ZI{constructor(A,I=1){super(),this.isLight=!0,this.type="Light",this.color=new Og(A),this.intensity=I}dispose(){}copy(A,I){return super.copy(A,I),this.color.copy(A.color),this.intensity=A.intensity,this}toJSON(A){let I=super.toJSON(A);return I.object.color=this.color.getHex(),I.object.intensity=this.intensity,this.groundColor!==void 0&&(I.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(I.object.distance=this.distance),this.angle!==void 0&&(I.object.angle=this.angle),this.decay!==void 0&&(I.object.decay=this.decay),this.penumbra!==void 0&&(I.object.penumbra=this.penumbra),this.shadow!==void 0&&(I.object.shadow=this.shadow.toJSON()),I}},d1=class extends gh{constructor(g,A,I){super(g,I),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ZI.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Og(A)}copy(g,A){return super.copy(g,A),this.groundColor.copy(g.groundColor),this}},su=new zA,kG=new J,MG=new J,zw=class{constructor(g){this.camera=g,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new sA(512,512),this.map=null,this.mapPass=null,this.matrix=new zA,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xw,this._frameExtents=new sA(1,1),this._viewportCount=1,this._viewports=[new EI(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(g){let A=this.camera,I=this.matrix;kG.setFromMatrixPosition(g.matrixWorld),A.position.copy(kG),MG.setFromMatrixPosition(g.target.matrixWorld),A.lookAt(MG),A.updateMatrixWorld(),su.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix(su),I.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),I.multiply(su)}getViewport(g){return this._viewports[g]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(g){return this.camera=g.camera.clone(),this.bias=g.bias,this.radius=g.radius,this.mapSize.copy(g.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let g={};return this.bias!==0&&(g.bias=this.bias),this.normalBias!==0&&(g.normalBias=this.normalBias),this.radius!==1&&(g.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(g.mapSize=this.mapSize.toArray()),g.camera=this.camera.toJSON(!1).object,delete g.camera.matrix,g}},u1=class extends zw{constructor(){super(new Ui(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(g){let A=this.camera,I=dn*2*g.angle*this.focus,e=this.mapSize.width/this.mapSize.height,i=g.distance||A.far;(I!==A.fov||e!==A.aspect||i!==A.far)&&(A.fov=I,A.aspect=e,A.far=i,A.updateProjectionMatrix()),super.updateMatrices(g)}copy(g){return super.copy(g),this.focus=g.focus,this}},p1=class extends gh{constructor(g,A,I=0,e=Math.PI/3,i=0,t=2){super(g,A),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ZI.DEFAULT_UP),this.updateMatrix(),this.target=new ZI,this.distance=I,this.angle=e,this.penumbra=i,this.decay=t,this.map=null,this.shadow=new u1}get power(){return this.intensity*Math.PI}set power(g){this.intensity=g/Math.PI}dispose(){this.shadow.dispose()}copy(g,A){return super.copy(g,A),this.distance=g.distance,this.angle=g.angle,this.penumbra=g.penumbra,this.decay=g.decay,this.target=g.target.clone(),this.shadow=g.shadow.clone(),this}},mG=new zA,fE=new J,Qu=new J,y1=class extends zw{constructor(){super(new Ui(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new sA(4,2),this._viewportCount=6,this._viewports=[new EI(2,1,1,1),new EI(0,1,1,1),new EI(3,1,1,1),new EI(1,1,1,1),new EI(3,0,1,1),new EI(1,0,1,1)],this._cubeDirections=[new J(1,0,0),new J(-1,0,0),new J(0,0,1),new J(0,0,-1),new J(0,1,0),new J(0,-1,0)],this._cubeUps=[new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,1,0),new J(0,0,1),new J(0,0,-1)]}updateMatrices(g,A=0){let I=this.camera,e=this.matrix,i=g.distance||I.far;i!==I.far&&(I.far=i,I.updateProjectionMatrix()),fE.setFromMatrixPosition(g.matrixWorld),I.position.copy(fE),Qu.copy(I.position),Qu.add(this._cubeDirections[A]),I.up.copy(this._cubeUps[A]),I.lookAt(Qu),I.updateMatrixWorld(),e.makeTranslation(-fE.x,-fE.y,-fE.z),mG.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mG)}},w1=class extends gh{constructor(g,A,I=0,e=2){super(g,A),this.isPointLight=!0,this.type="PointLight",this.distance=I,this.decay=e,this.shadow=new y1}get power(){return this.intensity*4*Math.PI}set power(g){this.intensity=g/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(g,A){return super.copy(g,A),this.distance=g.distance,this.decay=g.decay,this.shadow=g.shadow.clone(),this}},S1=class extends zw{constructor(){super(new Hw(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},f1=class extends gh{constructor(g,A){super(g,A),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ZI.DEFAULT_UP),this.updateMatrix(),this.target=new ZI,this.shadow=new S1}dispose(){this.shadow.dispose()}copy(g){return super.copy(g),this.target=g.target.clone(),this.shadow=g.shadow.clone(),this}},G1=class extends bg{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(g){return super.copy(g),this.instanceCount=g.instanceCount,this}toJSON(){let g=super.toJSON();return g.instanceCount=this.instanceCount,g.isInstancedBufferGeometry=!0,g}},rF=class extends Vw{constructor(g){super(g)}load(g,A,I,e){let i=this,t=new Zp(i.manager);t.setPath(i.path),t.setRequestHeader(i.requestHeader),t.setWithCredentials(i.withCredentials),t.load(g,function(C){try{A(i.parse(JSON.parse(C)))}catch(o){e?e(o):console.error(o),i.manager.itemError(g)}},I,e)}parse(g){let A={},I={};function e(r,Q){if(A[Q]!==void 0)return A[Q];let E=r.interleavedBuffers[Q],n=i(r,E.buffer),h=Gh(E.type,n),l=new RH(h,E.stride);return l.uuid=E.uuid,A[Q]=l,l}function i(r,Q){if(I[Q]!==void 0)return I[Q];let E=r.arrayBuffers[Q],n=new Uint32Array(E).buffer;return I[Q]=n,n}let t=g.isInstancedBufferGeometry?new G1:new bg,C=g.data.index;if(C!==void 0){let r=Gh(C.type,C.array);t.setIndex(new zg(r,1))}let o=g.data.attributes;for(let r in o){let Q=o[r],E;if(Q.isInterleavedBufferAttribute){let n=e(g.data,Q.data);E=new _p(n,Q.itemSize,Q.offset,Q.normalized)}else{let n=Gh(Q.type,Q.array),h=Q.isInstancedBufferAttribute?JH:zg;E=new h(n,Q.itemSize,Q.normalized)}Q.name!==void 0&&(E.name=Q.name),Q.usage!==void 0&&E.setUsage(Q.usage),Q.updateRange!==void 0&&(E.updateRange.offset=Q.updateRange.offset,E.updateRange.count=Q.updateRange.count),t.setAttribute(r,E)}let B=g.data.morphAttributes;if(B)for(let r in B){let Q=B[r],E=[];for(let n=0,h=Q.length;n"u"?Date:performance).now()}var M1=class{constructor(g,A,I){this.binding=g,this.valueSize=I;let e,i,t;switch(A){case"quaternion":e=this._slerp,i=this._slerpAdditive,t=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(I*6),this._workIndex=5;break;case"string":case"bool":e=this._select,i=this._select,t=this._setAdditiveIdentityOther,this.buffer=new Array(I*5);break;default:e=this._lerp,i=this._lerpAdditive,t=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(I*5)}this._mixBufferRegion=e,this._mixBufferRegionAdditive=i,this._setIdentity=t,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(g,A){let I=this.buffer,e=this.valueSize,i=g*e+e,t=this.cumulativeWeight;if(t===0){for(let C=0;C!==e;++C)I[i+C]=I[C];t=A}else{t+=A;let C=A/t;this._mixBufferRegion(I,i,0,C,e)}this.cumulativeWeight=t}accumulateAdditive(g){let A=this.buffer,I=this.valueSize,e=I*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(A,e,0,g,I),this.cumulativeWeightAdditive+=g}apply(g){let A=this.valueSize,I=this.buffer,e=g*A+A,i=this.cumulativeWeight,t=this.cumulativeWeightAdditive,C=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let o=A*this._origIndex;this._mixBufferRegion(I,e,o,1-i,A)}t>0&&this._mixBufferRegionAdditive(I,e,this._addIndex*A,1,A);for(let o=A,B=A+A;o!==B;++o)if(I[o]!==I[o+A]){C.setValue(I,e);break}}saveOriginalState(){let g=this.binding,A=this.buffer,I=this.valueSize,e=I*this._origIndex;g.getValue(A,e);for(let i=I,t=e;i!==t;++i)A[i]=A[e+i%I];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let g=this.valueSize*3;this.binding.setValue(this.buffer,g)}_setAdditiveIdentityNumeric(){let g=this._addIndex*this.valueSize,A=g+this.valueSize;for(let I=g;I=.5)for(let t=0;t!==i;++t)g[A+t]=g[I+t]}_slerp(g,A,I,e){QI.slerpFlat(g,A,g,A,g,I,e)}_slerpAdditive(g,A,I,e,i){let t=this._workIndex*i;QI.multiplyQuaternionsFlat(g,t,g,A,g,I),QI.slerpFlat(g,A,g,A,g,t,e)}_lerp(g,A,I,e,i){let t=1-e;for(let C=0;C!==i;++C){let o=A+C;g[o]=g[o]*t+g[I+C]*e}}_lerpAdditive(g,A,I,e,i){for(let t=0;t!==i;++t){let C=A+t;g[C]=g[C]+g[I+t]*e}}},Xw="\\[\\]\\.:\\/",m1=new RegExp("["+Xw+"]","g"),$w="[^"+Xw+"]",U1="[^"+Xw.replace("\\.","")+"]",N1=/((?:WC+[\/:])*)/.source.replace("WC",$w),F1=/(WCOD+)?/.source.replace("WCOD",U1),R1=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",$w),K1=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",$w),J1=new RegExp("^"+N1+F1+R1+K1+"$"),v1=["material","materials","bones","map"],q1=class{constructor(g,A,I){let e=I||Ae.parseTrackName(A);this._targetGroup=g,this._bindings=g.subscribe_(A,e)}getValue(g,A){this.bind();let I=this._targetGroup.nCachedObjects_,e=this._bindings[I];e!==void 0&&e.getValue(g,A)}setValue(g,A){let I=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=I.length;e!==i;++e)I[e].setValue(g,A)}bind(){let g=this._bindings;for(let A=this._targetGroup.nCachedObjects_,I=g.length;A!==I;++A)g[A].bind()}unbind(){let g=this._bindings;for(let A=this._targetGroup.nCachedObjects_,I=g.length;A!==I;++A)g[A].unbind()}},Ae=class{constructor(A,I,e){this.path=I,this.parsedPath=e||Ae.parseTrackName(I),this.node=Ae.findNode(A,this.parsedPath.nodeName)||A,this.rootNode=A,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(A,I,e){return A&&A.isAnimationObjectGroup?new Ae.Composite(A,I,e):new Ae(A,I,e)}static sanitizeNodeName(A){return A.replace(/\s/g,"_").replace(m1,"")}static parseTrackName(A){let I=J1.exec(A);if(I===null)throw new Error("PropertyBinding: Cannot parse trackName: "+A);let e={nodeName:I[2],objectName:I[3],objectIndex:I[4],propertyName:I[5],propertyIndex:I[6]},i=e.nodeName&&e.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let t=e.nodeName.substring(i+1);v1.indexOf(t)!==-1&&(e.nodeName=e.nodeName.substring(0,i),e.objectName=t)}if(e.propertyName===null||e.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+A);return e}static findNode(A,I){if(I===void 0||I===""||I==="."||I===-1||I===A.name||I===A.uuid)return A;if(A.skeleton){let e=A.skeleton.getBoneByName(I);if(e!==void 0)return e}if(A.children){let e=function(t){for(let C=0;C0){let o=this._interpolants,B=this._propertyBindings;switch(this.blendMode){case DL:for(let a=0,s=o.length;a!==s;++a)o[a].evaluate(t),B[a].accumulateAdditive(C);break;case qw:default:for(let a=0,s=o.length;a!==s;++a)o[a].evaluate(t),B[a].accumulate(e,C)}}}_updateWeight(g){let A=0;if(this.enabled){A=this.weight;let I=this._weightInterpolant;if(I!==null){let e=I.evaluate(g)[0];A*=e,g>I.parameterPositions[1]&&(this.stopFading(),e===0&&(this.enabled=!1))}}return this._effectiveWeight=A,A}_updateTimeScale(g){let A=0;if(!this.paused){A=this.timeScale;let I=this._timeScaleInterpolant;if(I!==null){let e=I.evaluate(g)[0];A*=e,g>I.parameterPositions[1]&&(this.stopWarping(),A===0?this.paused=!0:this.timeScale=A)}}return this._effectiveTimeScale=A,A}_updateTime(g){let A=this._clip.duration,I=this.loop,e=this.time+g,i=this._loopCount,t=I===vw;if(g===0)return i===-1?e:t&&(i&1)===1?A-e:e;if(I===MN){i===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));A:{if(e>=A)e=A;else if(e<0)e=0;else{this.time=e;break A}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:g<0?-1:1})}}else{if(i===-1&&(g>=0?(i=0,this._setEndings(!0,this.repetitions===0,t)):this._setEndings(this.repetitions===0,!0,t)),e>=A||e<0){let C=Math.floor(e/A);e-=A*C,i+=Math.abs(C);let o=this.repetitions-i;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=g>0?A:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:g>0?1:-1});else{if(o===1){let B=g<0;this._setEndings(B,!B,t)}else this._setEndings(!1,!1,t);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:C})}}else this.time=e;if(t&&(i&1)===1)return A-e}return e}_setEndings(g,A,I){let e=this._interpolantSettings;I?(e.endingStart=$s,e.endingEnd=$s):(g?e.endingStart=this.zeroSlopeAtStart?$s:Xs:e.endingStart=hc,A?e.endingEnd=this.zeroSlopeAtEnd?$s:Xs:e.endingEnd=hc)}_scheduleFading(g,A,I){let e=this._mixer,i=e.time,t=this._weightInterpolant;t===null&&(t=e._lendControlInterpolant(),this._weightInterpolant=t);let C=t.parameterPositions,o=t.sampleValues;return C[0]=i,o[0]=A,C[1]=i+g,o[1]=I,this}},b1=new Float32Array(1),Y1=class extends Si{constructor(g){super(),this._root=g,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(g,A){let I=g._localRoot||this._root,e=g._clip.tracks,i=e.length,t=g._propertyBindings,C=g._interpolants,o=I.uuid,B=this._bindingsByRootAndName,a=B[o];a===void 0&&(a={},B[o]=a);for(let s=0;s!==i;++s){let r=e[s],Q=r.name,E=a[Q];if(E!==void 0)++E.referenceCount,t[s]=E;else{if(E=t[s],E!==void 0){E._cacheIndex===null&&(++E.referenceCount,this._addInactiveBinding(E,o,Q));continue}let n=A&&A._propertyBindings[s].binding.parsedPath;E=new M1(Ae.create(I,Q,n),r.ValueTypeName,r.getValueSize()),++E.referenceCount,this._addInactiveBinding(E,o,Q),t[s]=E}C[s].resultBuffer=E.buffer}}_activateAction(g){if(!this._isActiveAction(g)){if(g._cacheIndex===null){let I=(g._localRoot||this._root).uuid,e=g._clip.uuid,i=this._actionsByClip[e];this._bindAction(g,i&&i.knownActions[0]),this._addInactiveAction(g,e,I)}let A=g._propertyBindings;for(let I=0,e=A.length;I!==e;++I){let i=A[I];i.useCount++===0&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(g)}}_deactivateAction(g){if(this._isActiveAction(g)){let A=g._propertyBindings;for(let I=0,e=A.length;I!==e;++I){let i=A[I];--i.useCount===0&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(g)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let g=this;this.stats={actions:{get total(){return g._actions.length},get inUse(){return g._nActiveActions}},bindings:{get total(){return g._bindings.length},get inUse(){return g._nActiveBindings}},controlInterpolants:{get total(){return g._controlInterpolants.length},get inUse(){return g._nActiveControlInterpolants}}}}_isActiveAction(g){let A=g._cacheIndex;return A!==null&&A=0;--I)g[I].stop();return this}update(g){g*=this.timeScale;let A=this._actions,I=this._nActiveActions,e=this.time+=g,i=Math.sign(g),t=this._accuIndex^=1;for(let B=0;B!==I;++B)A[B]._update(e,g,i,t);let C=this._bindings,o=this._nActiveBindings;for(let B=0;B!==o;++B)C[B].apply(t);return this}setTime(g){this.time=0;for(let A=0;Athis.max.x||g.ythis.max.y)}containsBox(g){return this.min.x<=g.min.x&&g.max.x<=this.max.x&&this.min.y<=g.min.y&&g.max.y<=this.max.y}getParameter(g,A){return A.set((g.x-this.min.x)/(this.max.x-this.min.x),(g.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(g){return!(g.max.xthis.max.x||g.max.ythis.max.y)}clampPoint(g,A){return A.copy(g).clamp(this.min,this.max)}distanceToPoint(g){return RG.copy(g).clamp(this.min,this.max).sub(g).length()}intersect(g){return this.min.max(g.min),this.max.min(g.max),this}union(g){return this.min.min(g.min),this.max.max(g.max),this}translate(g){return this.min.add(g),this.max.add(g),this}equals(g){return g.min.equals(this.min)&&g.max.equals(this.max)}},KG=new J,Vh=new J,eC=class{constructor(A=new J,I=new J){this.start=A,this.end=I}set(A,I){return this.start.copy(A),this.end.copy(I),this}copy(A){return this.start.copy(A.start),this.end.copy(A.end),this}getCenter(A){return A.addVectors(this.start,this.end).multiplyScalar(.5)}delta(A){return A.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(A,I){return this.delta(I).multiplyScalar(A).add(this.start)}closestPointToPointParameter(A,I){KG.subVectors(A,this.start),Vh.subVectors(this.end,this.start);let e=Vh.dot(Vh),i=Vh.dot(KG)/e;return I&&(i=ii(i,0,1)),i}closestPointToPoint(A,I,e){let i=this.closestPointToPointParameter(A,I);return this.delta(e).multiplyScalar(i).add(this.start)}applyMatrix4(A){return this.start.applyMatrix4(A),this.end.applyMatrix4(A),this}equals(A){return A.start.equals(this.start)&&A.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},JG=new J,x1=class extends ZI{constructor(g,A){super(),this.light=g,this.matrix=g.matrixWorld,this.matrixAutoUpdate=!1,this.color=A,this.type="SpotLightHelper";let I=new bg,e=[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 t=0,C=1,o=32;tho(g)?g.slice(A.length):A===""?g:g.slice(A.length+1),concat:(g,A)=>ho(g)?(g=[...g],A&&g.push(A),g):A&&A.toString!==void 0?(g!==""&&(g+=GE),g0(A)?g+A.toString():g+A):g,initial:g=>{if(ho(g))return g.slice(0,-1);if(g==="")return g;let A=g.lastIndexOf(GE);return A===-1?"":g.slice(0,A)},last:g=>{if(ho(g))return g[g.length-1]||"";if(g==="")return g;let A=g.lastIndexOf(GE);return A===-1?g:g.slice(A+1)},walk:(g,A)=>{if(ho(g))for(let I of g)A(I);else if(g!==""){let I=0,e=g.indexOf(GE);if(e===-1)A(g);else for(;I{g&&(g=g[I])}),g}},Zt=P1;function j1(g){return typeof g=="object"&&typeof g.next=="function"}function W1(g,A,I,e,i){let t=g.next;if(A.name==="entries")g.next=function(){let C=t.call(this);return C.done===!1&&(C.value[0]=i(C.value[0],A,C.value[0],e),C.value[1]=i(C.value[1],A,C.value[0],e)),C};else if(A.name==="values"){let C=I[A0].keys();g.next=function(){let o=t.call(this);return o.done===!1&&(o.value=i(o.value,A,C.next().value,e)),o}}else g.next=function(){let C=t.call(this);return C.done===!1&&(C.value=i(C.value,A,C.value,e)),C};return g}function LG(g,A,I){return g.isUnsubscribed||A.ignoreSymbols&&g0(I)||A.ignoreUnderscores&&I.charAt(0)==="_"||"ignoreKeys"in A&&A.ignoreKeys.includes(I)}var Z1=class{constructor(g){this._equals=g,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(g){let A=this._getDescriptorCache(),I=A.get(g);return I===void 0&&(I={},A.set(g,I)),I}_getOwnPropertyDescriptor(g,A){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(g,A);let I=this._getProperties(g),e=I[A];return e===void 0&&(e=Reflect.getOwnPropertyDescriptor(g,A),I[A]=e),e}getProxy(g,A,I,e){if(this.isUnsubscribed)return g;let i=g[e],t=i||g;this._pathCache.set(t,A);let C=this._proxyCache.get(t);return C===void 0&&(C=i===void 0?new Proxy(g,I):g,this._proxyCache.set(t,C)),C}getPath(g){return this.isUnsubscribed?void 0:this._pathCache.get(g)}isDetached(g,A){return!Object.is(g,Zt.get(A,this.getPath(g)))}defineProperty(g,A,I){return Reflect.defineProperty(g,A,I)?(this.isUnsubscribed||(this._getProperties(g)[A]=I),!0):!1}setProperty(g,A,I,e,i){if(!this._equals(i,I)||!(A in g)){let t=this._getOwnPropertyDescriptor(g,A);return t!==void 0&&"set"in t?Reflect.set(g,A,I,e):Reflect.set(g,A,I)}return!0}deleteProperty(g,A,I){if(Reflect.deleteProperty(g,A)){if(!this.isUnsubscribed){let e=this._getDescriptorCache().get(g);e&&(delete e[A],this._pathCache.delete(I))}return!0}return!1}isSameDescriptor(g,A,I){let e=this._getOwnPropertyDescriptor(A,I);return g!==void 0&&e!==void 0&&Object.is(g.value,e.value)&&(g.writable||!1)===(e.writable||!1)&&(g.enumerable||!1)===(e.enumerable||!1)&&(g.configurable||!1)===(e.configurable||!1)&&g.get===e.get&&g.set===e.set}isGetInvariant(g,A){let I=this._getOwnPropertyDescriptor(g,A);return I!==void 0&&I.configurable!==!0&&I.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Xp(g){return toString.call(g)==="[object Object]"}function $h(){return!0}function Gs(g,A){return g.length!==A.length||g.some((I,e)=>A[e]!==I)}var nF=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),V1=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),hF={push:$h,pop:$h,shift:$h,unshift:$h,copyWithin:Gs,reverse:Gs,sort:Gs,splice:Gs,flat:Gs,fill:Gs},z1=new Set([...nF,...V1,...Object.keys(hF)]);function Al(g,A){if(g.size!==A.size)return!0;for(let I of g)if(!A.has(I))return!0;return!1}var lF=["keys","values","entries"],cF=new Set(["has","toString"]),DF={add:Al,clear:Al,delete:Al,forEach:Al},X1=new Set([...cF,...Object.keys(DF),...lF]);function gl(g,A){if(g.size!==A.size)return!0;let I;for(let[e,i]of g)if(I=A.get(e),I!==i||I===void 0&&!A.has(e))return!0;return!1}var $1=new Set([...cF,"get"]),dF={set:gl,clear:gl,delete:gl,forEach:gl},AT=new Set([...$1,...Object.keys(dF),...lF]),Ga=class{constructor(A,I,e,i){this._path=I,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=I===void 0?A:this._shallowClone(A)}static isHandledMethod(A){return nF.has(A)}_shallowClone(A){let I=A;if(Xp(A))I={...A};else if(ho(A))I=[...A];else if(A instanceof Date)I=new Date(A);else if(A instanceof Set)I=new Set([...A].map(e=>this._shallowClone(e)));else if(A instanceof Map){I=new Map;for(let[e,i]of A.entries())I.set(e,this._shallowClone(i))}return this._clonedCache.add(I),I}preferredThisArg(A,I,e,i){return A?(ho(i)?this._onIsChanged=hF[I]:i instanceof Set?this._onIsChanged=DF[I]:i instanceof Map&&(this._onIsChanged=dF[I]),i):e}update(A,I,e){let i=Zt.after(A,this._path);if(I!=="length"){let t=this.clone;Zt.walk(i,C=>{t&&t[C]&&(this._clonedCache.has(t[C])||(t[C]=this._shallowClone(t[C])),t=t[C])}),this._hasOnValidate&&this._changes.push({path:i,property:I,previous:e}),t&&t[I]&&(t[I]=e)}this._isChanged=!0}undo(A){let I;for(let e=this._changes.length-1;e!==-1;e--)I=this._changes[e],Zt.get(A,I.path)[I.property]=I.previous}isChanged(A){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,A)}},bG=class extends Ga{static isHandledMethod(g){return z1.has(g)}},gT=class extends Ga{undo(g){g.setTime(this.clone.getTime())}isChanged(g,A){return!A(this.clone.valueOf(),g.valueOf())}},YG=class extends Ga{static isHandledMethod(g){return X1.has(g)}undo(g){for(let A of this.clone)g.add(A);for(let A of g)this.clone.has(A)||g.delete(A)}},xG=class extends Ga{static isHandledMethod(g){return AT.has(g)}undo(g){for(let[A,I]of this.clone.entries())g.set(A,I);for(let A of g.keys())this.clone.has(A)||g.delete(A)}},IT=class extends Ga{constructor(g,A,I,e){super(void 0,A,I,e),this._arg1=I[0],this._weakValue=g.has(this._arg1)}isChanged(g){return this._weakValue!==g.has(this._arg1)}undo(g){this._weakValue&&!g.has(this._arg1)?g.add(this._arg1):g.delete(this._arg1)}},eT=class extends Ga{constructor(g,A,I,e){super(void 0,A,I,e),this._weakKey=I[0],this._weakHas=g.has(this._weakKey),this._weakValue=g.get(this._weakKey)}isChanged(g){return this._weakValue!==g.get(this._weakKey)}undo(g){let A=g.has(this._weakKey);this._weakHas&&!A?g.set(this._weakKey,this._weakValue):!this._weakHas&&A?g.delete(this._weakKey):this._weakValue!==g.get(this._weakKey)&&g.set(this._weakKey,this._weakValue)}},js=class{constructor(A){this._stack=[],this._hasOnValidate=A}static isHandledType(A){return Xp(A)||ho(A)||zp(A)}static isHandledMethod(A,I){return Xp(A)?Ga.isHandledMethod(I):ho(A)?bG.isHandledMethod(I):A instanceof Set?YG.isHandledMethod(I):A instanceof Map?xG.isHandledMethod(I):zp(A)}get isCloning(){return this._stack.length>0}start(A,I,e){let i=Ga;ho(A)?i=bG:A instanceof Date?i=gT:A instanceof Set?i=YG:A instanceof Map?i=xG:A instanceof WeakSet?i=IT:A instanceof WeakMap&&(i=eT),this._stack.push(new i(A,I,e,this._hasOnValidate))}update(A,I,e){this._stack[this._stack.length-1].update(A,I,e)}preferredThisArg(A,I,e){let{name:i}=A,t=js.isHandledMethod(e,i);return this._stack[this._stack.length-1].preferredThisArg(t,i,I,e)}isChanged(A,I,e){return this._stack[this._stack.length-1].isChanged(A,I,e)}undo(A){this._previousClone!==void 0&&this._previousClone.undo(A)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},iT={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},I0=(g,A,I={})=>{I={...iT,...I};let e=Symbol("ProxyTarget"),{equals:i,isShallow:t,ignoreDetached:C,details:o}=I,B=new Z1(i),a=typeof I.onValidate=="function",s=new js(a),r=(d,u,y,f,k)=>!a||s.isCloning||I.onValidate(Zt.concat(B.getPath(d),u),y,f,k)===!0,Q=(d,u,y,f)=>{!LG(B,I,u)&&!(C&&B.isDetached(d,g))&&E(B.getPath(d),u,y,f)},E=(d,u,y,f,k)=>{s.isCloning?s.update(d,u,f):A(Zt.concat(d,u),y,f,k)},n=d=>d&&(d[e]||d),h=(d,u,y,f)=>_1(d)||y==="constructor"||t&&!js.isHandledMethod(u,y)||LG(B,I,y)||B.isGetInvariant(u,y)||C&&B.isDetached(u,g)?d:(f===void 0&&(f=B.getPath(u)),B.getProxy(d,Zt.concat(f,y),l,e)),l={get(d,u,y){if(g0(u)){if(u===e||u===A0)return d;if(u===EF&&!B.isUnsubscribed&&B.getPath(d).length===0)return B.unsubscribe(),d}let f=zp(d)?Reflect.get(d,u):Reflect.get(d,u,y);return h(f,d,u)},set(d,u,y,f){y=n(y);let k=d[e]||d,M=k[u];if(i(M,y)&&u in d)return!0;let G=r(d,u,y,M);return G&&B.setProperty(k,u,y,f,M)?(Q(d,u,d[u],M),!0):!G},defineProperty(d,u,y){if(!B.isSameDescriptor(y,d,u)){let f=d[u];r(d,u,y.value,f)&&B.defineProperty(d,u,y,f)&&Q(d,u,y.value,f)}return!0},deleteProperty(d,u){if(!Reflect.has(d,u))return!0;let y=Reflect.get(d,u),f=r(d,u,void 0,y);return f&&B.deleteProperty(d,u,y)?(Q(d,u,void 0,y),!0):!f},apply(d,u,y){let f=u[e]||u;if(B.isUnsubscribed)return Reflect.apply(d,f,y);if((o===!1||o!==!0&&!o.includes(d.name))&&js.isHandledType(f)){let k=Zt.initial(B.getPath(d)),M=js.isHandledMethod(f,d.name);s.start(f,k,y);let G=Reflect.apply(d,s.preferredThisArg(d,u,f),M?y.map(b=>n(b)):y),v=s.isChanged(f,i),N=s.stop();if(js.isHandledType(G)&&M&&(u instanceof Map&&d.name==="get"&&(k=Zt.concat(k,y[0])),G=B.getProxy(G,k,l)),v){let b={name:d.name,args:y,result:G},O=s.isCloning?Zt.initial(k):k,H=s.isCloning?Zt.last(k):"";r(Zt.get(g,O),H,f,N,b)?E(O,H,f,N,b):s.undo(f)}return(u instanceof Map||u instanceof Set)&&j1(G)?W1(G,d,u,k,h):G}return Reflect.apply(d,u,y)}},c=B.getProxy(g,I.pathAsArray?[]:"",l);return A=A.bind(c),a&&(I.onValidate=I.onValidate.bind(c)),c};I0.target=g=>g&&g[A0]||g;I0.unsubscribe=g=>g[EF]||g;var HG=I0,tT=typeof global=="object"&&global&&global.Object===Object&&global,uF=tT,CT=typeof self=="object"&&self&&self.Object===Object&&self,oT=uF||CT||Function("return this")(),LC=oT,BT=LC.Symbol,tC=BT,pF=Object.prototype,aT=pF.hasOwnProperty,rT=pF.toString,kE=tC?tC.toStringTag:void 0;function sT(g){var A=aT.call(g,kE),I=g[kE];try{g[kE]=void 0;var e=!0}catch{}var i=rT.call(g);return e&&(A?g[kE]=I:delete g[kE]),i}var QT=sT,ET=Object.prototype,nT=ET.toString;function hT(g){return nT.call(g)}var lT=hT,cT="[object Null]",DT="[object Undefined]",TG=tC?tC.toStringTag:void 0;function dT(g){return g==null?g===void 0?DT:cT:TG&&TG in Object(g)?QT(g):lT(g)}var xr=dT;function uT(g){return g!=null&&typeof g=="object"}var wB=uT,pT="[object Symbol]";function yT(g){return typeof g=="symbol"||wB(g)&&xr(g)==pT}var qD=yT;function wT(g,A){for(var I=-1,e=g==null?0:g.length,i=Array(e);++I0){if(++A>=cO)return arguments[0]}else A=0;return g.apply(void 0,arguments)}}var pO=uO;function yO(g){return function(){return g}}var wO=yO,SO=function(){try{var g=Tr(Object,"defineProperty");return g({},"",{}),g}catch{}}(),kc=SO,fO=kc?function(g,A){return kc(g,"toString",{configurable:!0,enumerable:!1,value:wO(A),writable:!0})}:YT,GO=fO,kO=pO(GO),MO=kO;function mO(g,A){for(var I=-1,e=g==null?0:g.length;++I-1&&g%1==0&&g-1&&g%1==0&&g<=HO}var C0=TO;function OO(g){return g!=null&&C0(g.length)&&!SF(g)}var GF=OO,_O=Object.prototype;function PO(g){var A=g&&g.constructor,I=typeof A=="function"&&A.prototype||_O;return g===I}var o0=PO;function jO(g,A){for(var I=-1,e=Array(g);++I-1}var U3=m3;function N3(g,A){var I=this.__data__,e=LD(I,g);return e<0?(++this.size,I.push([g,A])):I[e][1]=A,this}var F3=N3;function AE(g){var A=-1,I=g==null?0:g.length;for(this.clear();++A0&&I(o)?A>1?KF(o,A-1,I,e,i):E0(i,o):e||(i[i.length]=o)}return i}var s4=KF;function Q4(g){var A=g==null?0:g.length;return A?s4(g,1):[]}var E4=Q4;function n4(g){return MO(xO(g,void 0,E4),g+"")}var JF=n4,h4=FF(Object.getPrototypeOf,Object),n0=h4,l4="[object Object]",c4=Function.prototype,D4=Object.prototype,vF=c4.toString,d4=D4.hasOwnProperty,u4=vF.call(Object);function p4(g){if(!wB(g)||xr(g)!=l4)return!1;var A=n0(g);if(A===null)return!0;var I=d4.call(A,"constructor")&&A.constructor;return typeof I=="function"&&I instanceof I&&vF.call(I)==u4}var y4=p4;function w4(g,A,I){var e=-1,i=g.length;A<0&&(A=-A>i?0:i+A),I=I>i?i:I,I<0&&(I+=i),i=A>I?0:I-A>>>0,A>>>=0;for(var t=Array(i);++eo))return!1;var a=t.get(g),s=t.get(A);if(a&&s)return a==A&&s==g;var r=-1,Q=!0,E=I&jj?new xj:void 0;for(t.set(g,A),t.set(A,g);++r=A||M<0||r&&G>=t}function c(){var k=lu();if(l(k))return d(k);o=setTimeout(c,h(k))}function d(k){return o=void 0,Q&&e?E(k):(e=i=void 0,C)}function u(){o!==void 0&&clearTimeout(o),a=0,e=B=i=o=void 0}function y(){return o===void 0?C:d(lu())}function f(){var k=lu(),M=l(k);if(e=arguments,i=this,B=k,M){if(o===void 0)return n(B);if(r)return clearTimeout(o),o=setTimeout(c,A),E(B)}return o===void 0&&(o=setTimeout(c,A)),C}return f.cancel=u,f.flush=y,f}var c0=K8;function J8(g){var A=g==null?0:g.length;return A?g[A-1]:void 0}var v8=J8;function q8(g,A){return A.length<2?g:RF(g,S4(A,0,-1))}var L8=q8;function b8(g,A){return w8(g,A)}var WF=b8;function Y8(g,A){return A=IE(A,g),g=L8(g,A),g==null||delete g[HD(v8(A))]}var x8=Y8;function H8(g){return y4(g)?void 0:g}var T8=H8,O8=1,_8=2,P8=4,j8=JF(function(g,A){var I={};if(g==null)return I;var e=!1;A=yF(A,function(t){return t=IE(t,g),e||(e=t.length>1),t}),Ih(g,xF(g),I),e&&(I=_F(I,O8|_8|P8,T8));for(var i=A.length;i--;)x8(I,A[i]);return I}),iy=j8;function W8(g,A,I,e){if(!KC(g))return g;A=IE(A,g);for(var i=-1,t=A.length,C=t-1,o=g;o!=null&&++itypeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),CW=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),oW=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||OD&&"ontouchend"in document,BW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,aW=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,rW=()=>{if(typeof window>"u")return!1;let g=navigator.userAgent,A=navigator.vendor;return/Safari/i.test(g)&&/Apple Computer/.test(A)},sW=()=>{if(typeof window>"u")return null;let g=navigator.userAgent.match(/Version\/(\d+\.\d)/);return g&&g[1]},QW=()=>{if(typeof window>"u")return;let g=new URLSearchParams(window.location.search).get("desktop-app-version");return g?(window.localStorage.setItem("desktop-app-version",g),g):window.localStorage.getItem("desktop-app-version")??"0.0.6"},EW=tW();EW&&QW();var OD=CW(),ZF=oW(),nW=BW(),Kt=aW(),uk=rW(),pk=Number(sW());function VF(g){return Array.isArray(g)?g:[g]}function hW(g,A){let I=0;for(;IA[I])return 1;I+=1}return I!==A.length?-1:I!==g.length?1:0}function el(g){return OD?g.metaKey:g.ctrlKey}var Pg=[],Nc={},VE={},$l={};function zF(g){Pg.includes(g)||Pg.push(g)}function aQ(g){delete Nc[g.pointerId];for(let A=0;A{AR=g}),il;function uW(){if(il)return il;async function g(){let A="https://unpkg.com/@splinetool/navmesh-wasm@0.9.483/build",I=Zn(()=>Promise.resolve().then(()=>_gA),void 0),[e,i]=await Promise.all([I,fetch(`${A}/navmesh.wasm`).then(o=>o.arrayBuffer())]),t=e.default,C=await t({wasmBinary:i});AR(C)}return il=g(),il}var gR,pW=new Promise(g=>{gR=g}),tl;function yW(){if(tl)return tl;async function g(){let A=await Zn(()=>Promise.resolve().then(()=>$gA),void 0);await A.init(),gR(A)}return tl=g(),tl}var lI=class{modifyById(A,I){let e=this;if(e[A]===void 0)throw new Error("not expected");{let i={...e,[A]:I};return Object.setPrototypeOf(i,lI.prototype),i}}add(A,I){var e;return((e=this.runOp({type:1,id:A,data:I}))==null?void 0:e.data)??this}runOp(A){let I=this;if(A.type===1){let e=I[A.id],i;e===void 0?i={type:2,id:A.id}:i={type:1,id:A.id,data:e};let{id:t,data:C}=A,o={...I,[t]:C};return Object.setPrototypeOf(o,lI.prototype),{data:o,actual:A,reverse:i}}else if(A.type===2){let{id:e}=A,i=I[e];if(i===void 0)return null;{let t={...I};return Object.setPrototypeOf(t,lI.prototype),delete t[e],{data:t,actual:A,reverse:{type:1,id:e,data:i}}}}return null}};function D0(g){if(g.deepFreeze!==void 0){g.deepFreeze(g);return}let A=Object.getOwnPropertyNames(g);for(let I of A){let e=g[I];e&&typeof e=="object"&&D0(e)}return Object.freeze(g)}function wW(g,A){let I=0;for(;IA[I])return 1;I+=1}return I!==A.length?-1:I!==g.length?1:0}var IR=class extends Error{};function Du(g){let A={...g};return Object.setPrototypeOf(A,Object.getPrototypeOf(g)),A}function Ba(g,A,I){if(g===void 0?A===void 0?(g=0,A=10):g=A-10:A===void 0&&(A=g+10),g>A){let t=g;g=A,A=t}let e=[],i=1/(I+1);for(let t=0;to.id===A);if(t<0)throw new Error("not expected");let C=i[t];return i=[...i],i[t]={...C,data:I},this.modifyArrayBy(e,i)}}modifyArrayBy(A,I){let e=A,i=I;for(;e!==null;){let C=i,o=e;if(e=this.parent(e),e===void 0)throw new Error;i=this.childrenArray(e);let B=i.findIndex(a=>a.id===o);if(B<0)throw new Error;i=[...i],i[B]={...i[B],children:C}}Object.setPrototypeOf(i,ht.prototype);let t=i;return t.fillCaches(),t}runOp(A){switch(A.type){case 7:return this.addOp(A);case 8:return this.deleteOp(A);case 9:return this.moveOp(A)}return null}checkDuplicatedIdRec({id:A,children:I}){if(this.get(A)!==void 0)return!0;for(let e of I)if(this.checkDuplicatedIdRec(e))return!0;return!1}addOp(A){let{parent:I,fi:e,id:i,data:t,children:C}=A;if(I!==null&&this.get(I)===void 0||this.checkDuplicatedIdRec(A))return null;{let o=I,B=this.childrenArray(o),a={fi:e,id:i,data:t,children:C};return B=[...B,a],B.sort((s,r)=>s.fi-r.fi),A.localIndex=B.indexOf(a),{data:this.modifyArrayBy(o,B),actual:A,reverse:{type:8,id:i}}}}deleteOp(A){let{id:I}=A;if(this.get(I)===null)return null;{let e=this.parent(I);if(e===void 0)return null;let i=this.childrenArray(e),t=i.findIndex(o=>o.id===I);A.localIndex=t,i=[...i];let C=i.splice(t,1)[0];return{data:this.modifyArrayBy(e,i),actual:A,reverse:{type:7,...C,parent:e}}}}moveOp(A){let{parent:I,fi:e,id:i}=A;if(I!==null&&this.get(I)===void 0)return this.deleteOp({type:8,id:i});if(I!==null){let Q=I;for(;Q!==null;){if(Q===void 0)throw new Error;if(Q===i)throw new IR("cyclic tree");Q=this.parent(Q)}}let t=this.parent(i);if(t===void 0)return null;let C=t,o=this.childrenArray(t),B=o.findIndex(Q=>Q.id===i);o=[...o];let a=o.splice(B,1)[0],s=this.modifyArrayBy(t,o);t=I,o=s.childrenArray(t);let r=a.fi;return a={...a,fi:e},o=[...o,a],o.sort((Q,E)=>Q.fi-E.fi),A.localIndex=o.indexOf(a),s=s.modifyArrayBy(t,o),{data:s,actual:A,reverse:{type:9,parent:C,fi:r,id:i}}}previous(A,I){if(I===null){let i=this.childrenArray(A);return i.length===0?null:i[i.length-1].id}let e=null;for(let i of this.childrenArray(A)){if(i.id===I)return e;e=i.id}return null}traverseSortNext(A){let I=this.parent(A);if(I!==void 0){let e=this.childrenArray(I),i=e.findIndex(t=>t.id===A)+1;if(i0?I[0].id:this.traverseSortNext(A)}traverseSortPrevious(A){let I=this.childrenArray(A);return I.length>0?this.traverseSortPrevious(I[I.length-1].id):A}sortPrevious(A){let I=this.parent(A);if(I!==void 0){let e=this.childrenArray(I),i=e.findIndex(t=>t.id===A)-1;return i>=0?this.traverseSortPrevious(e[i].id):I}}getAllSorted(A){let I=[];for(let e of A){let i=this.getWithSortKey(e.id);i!==void 0&&I.push({...e,...i})}I.sort((e,i)=>wW(e.sortKey,i.sortKey));for(let e of I)delete e.sortKey;return I}getWithSortKey(A){var I=A;let e=[],i=this.get(I),t=i;if(i!==void 0){for(;I;)e.splice(0,0,i.fi),I=this.parent(I),I!==null&&(i=this.get(I));return{...t,sortKey:e}}}insertBeforeHelper(A,I,e){return this.insertAfterHelper(A,this.previous(A,I),e)}insertAfterHelper(A,I,e){let i=this.childrenArray(A);if(I===null){if(i.length===0)return Ba(0,e,e);{let t=i[0].fi;return Ba(t-e,t,e)}}else{let t=this.get(I);if(t===void 0||this.parent(I)!==A)throw new Error("illegal args");let C=i.find(o=>o.fi>t.fi);if(C===void 0){let o=i[i.length-1].fi;return Ba(o,o+e,e)}else return Ba(t.fi,C.fi,e)}}},Rc;(g=>{function A(I,e){if(e.type!==0)return null;if(Array.isArray(I)){let i=e.props,t={},C=[...I],o=!1;if(i)for(let B of Object.keys(i)){let a=parseInt(B);if(isNaN(a))throw new Error("wrong index");t[B]=C[a],C[a]=i[B],o=!0}return o?{data:C,actual:e,reverse:{type:0,props:t}}:null}else{let i=e.props,t={},C={...I},o=!1;if(i)for(let B of Object.keys(i)){t[B]=C[B];let a=i[B];a===void 0?delete C[B]:C[B]=a,o=!0}return o?{data:C,actual:e,reverse:{type:0,props:t}}:null}}g.runOp=A})(Rc||(Rc={}));var _g=class extends Array{constructor(...A){super(...A),Object.setPrototypeOf(this,_g.prototype)}deepFreeze(){let A=0;for(;AC.id===A);if(i<0)throw new Error("not expected");let t=e[i];return e=[...e],e[i]={...t,data:I},this.modifyArrayBy(e)}}modifyArrayBy(A){Object.setPrototypeOf(A,_g.prototype);let I=A;return SW()||I.fillCaches(),I}runOp(A){switch(A.type){case 4:return this.addOp(A);case 5:return this.deleteOp(A);case 6:return this.moveOp(A)}return null}addOp(A){let{fi:I,id:e,data:i}=A,t=this,C={fi:I,id:e,data:i};return t=[...t,C],t.sort((o,B)=>o.fi-B.fi),A.localIndex=t.indexOf(C),{data:this.modifyArrayBy(t),actual:A,reverse:{type:5,id:e}}}deleteOp(A){let{id:I}=A,e=this,i=e.findIndex(C=>C.id===I);if(i===-1)return null;A.localIndex=i,e=[...e];let t=e.splice(i,1)[0];return{data:this.modifyArrayBy(e),actual:A,reverse:{type:4,...t}}}moveOp(A){let{fi:I,id:e}=A,i=this;i=[...i];let t=i.findIndex(B=>B.id===e);if(t===-1)return null;let C=i[t].fi,o={...i[t],fi:I};return i[t]=o,i.sort((B,a)=>B.fi-a.fi),A.localIndex=i.indexOf(o),{data:this.modifyArrayBy(i),actual:A,reverse:{type:6,fi:C,id:e}}}previous(A){if(A===null)return this.length===0?null:this[this.length-1].id;let I=null;for(let e of this){if(e.id===A)return I;I=e.id}return null}insertBeforeHelper(A,I){return this.insertAfterHelper(this.previous(A),I)}insertAfterHelper(A,I){let e=this;if(A===null){if(e.length===0)return Ba(0,I,I);{let i=e[0].fi;return Ba(i-I,i,I)}}else{let i=this.get(A);if(i===void 0)throw new Error("illegal args");let t=e.find(C=>C.fi>i.fi);if(t===void 0){let C=e[e.length-1].fi;return Ba(C,C+I,I)}else return Ba(i.fi,t.fi,I)}}};function mQ(g){return g&&typeof g=="object"&&g instanceof Ci}var Ci=class{unusedFunOverridesTable(A){}runOp(A){let I=[],e=this,i=0,t={};for(;i0;){if(Object.keys(e).length===0){let B=I[i-1];B&&(e=Du(B),delete e[A.path[i-1]])}else{let B=I[i-1];if(B){let a=Du(B);a[A.path[i-1]]=e,e=a}else{let a=new Ci;a[A.path[i-1]]=e,e=a}}i-=1}let C=Object.setPrototypeOf(e,Ci.prototype),o={...A,props:t};return{data:C,actual:A,reverse:o}}},Da;(g=>{function A(i,t){return Gn(i,t)??i}g.apply=A;function I(i,t){return p0(i,t)}g.merge=I;function e(i,t){let C=0,o=t.path,B=i;for(;C{let t=i.id,C=Gn(i.data,A[t]);if(I=I||C!==void 0,C===void 0&&(C=i.data),i.children){let o=u0(i.children,A);return o!==void 0?I=!0:o=i.children,{...i,id:t,data:C,children:o}}else return{...i,id:t,data:C}});if(I)return e}function fW(g,A){if(A===void 0)return;let I=!1,e=g.map(i=>{let t=i.id,C=Gn(i.data,A[t]);return I=I||C!==void 0,C===void 0&&(C=i.data),{...i,id:t,data:C}});if(I)return Object.setPrototypeOf(e,Object.getPrototypeOf(g)),e}function Gn(g,A){if(!mQ(A))return A;if(g instanceof ht){let I=u0(g,A);return I!==void 0&&Object.setPrototypeOf(I,Object.getPrototypeOf(g)),I}else{if(g instanceof _g)return fW(g,A);if(Array.isArray(g)){let I=!1,e=g.map((i,t)=>{let C=Gn(i,A[t]);return I=I||C!==void 0,C===void 0&&(C=i),C});return I?(Object.setPrototypeOf(e,Object.getPrototypeOf(g)),e):void 0}else{if(g instanceof Ci)return p0(g,A);if(g&&typeof g=="object"){let I={},e=!1;for(let[i,t]of Object.entries(g)){let C=Gn(t,A[i]);e=e||C!==void 0,C===void 0&&(C=t),I[i]=C}return e?(Object.setPrototypeOf(I,Object.getPrototypeOf(g)),I):void 0}}}}function p0(g,A){if(g===void 0)return A;if(A===void 0)return g;if(!mQ(A))return A;if(!mQ(g))return Da.apply(g,A);let I=new Set;for(let i of Object.keys(g))I.add(i);for(let i of Object.keys(A))I.add(i);let e=new Ci;for(let i of I){let t=p0(g===void 0?void 0:g[i],A===void 0?void 0:A[i]);e[i]=t}return e}function GW(g,A){let I={cur:[],result:[],len:0};return g=kn(g,A,I)??g,[g,I.result]}function Kc(g,A){return g===null?null:(g.cur[g.len]=A,g.len+=1,g)}function Jc(g){g&&(g.len-=1)}function kW(g){if(g===null)return null;g.result.push(g.cur.slice(0,g.len))}function tR(g,A,I){let e=!1,i=g.map(t=>{let C=t.id,o=A[C];if(o!==void 0&&typeof o=="string"&&(e=!0,C=o,I!==null))throw new Error("not supported");let B=kn(t.data,A,Kc(I,C));Jc(I),e=e||B!==void 0,B===void 0&&(B=t.data);let a=tR(t.children,A,I);return a!==void 0?e=!0:a=t.children,{...t,id:C,data:B,children:a}});if(e)return i}function MW(g,A,I){let e=!1,i=g.map(t=>{let C=t.id,o=A[C];if(o!==void 0&&typeof o=="string"&&(e=!0,C=o,I!==null))throw new Error("not supported");let B=kn(t.data,A,Kc(I,C));return Jc(I),e=e||B!==void 0,B===void 0&&(B=t.data),{...t,id:C,data:B}});if(e)return Object.setPrototypeOf(i,Object.getPrototypeOf(g)),i}function kn(g,A,I){if(g instanceof ht){let e=tR(g,A,I);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(g)),e}else{if(g instanceof _g)return MW(g,A,I);if(Array.isArray(g)){let e=!1,i=g.map((t,C)=>{let o=kn(t,A,Kc(I,C));return Jc(I),e=e||o!==void 0,o===void 0&&(o=t),o});return e?(Object.setPrototypeOf(i,Object.getPrototypeOf(g)),i):void 0}else if(g&&typeof g=="object"&&!d0(g)){let e={},i=!1;for(let[t,C]of Object.entries(g))if(t!=="name"){let o=A[t];if(typeof o=="string"){if(I!==null)throw new Error("not supported");i=!0,t=o}let B=kn(C,A,Kc(I,t));Jc(I),i=i||B!==void 0,B===void 0&&(B=C),e[t]=B}else e[t]=C;return i?(Object.setPrototypeOf(e,Object.getPrototypeOf(g)),e):void 0}else if(typeof g=="string"){let e=A[g];return e!==void 0&&kW(I),e}else return}}var ty;(g=>{function A(I,e){let i=ji.zoom(e,I.path);if(typeof i=="object"){let t={};for(let C of Object.keys(I.props))t[C]=i[C];return{...I,props:t}}else return{...I,props:{}}}g.replaceProps=A})(ty||(ty={}));var Fi;(g=>{function A(B,a){return{...B,path:B.path.slice(a)}}g.drop=A;function I(B,a){var s;return((s=e(B,a))==null?void 0:s.data)??B}g.applySimple=I;function e(B,a){var Q,E;let s=a.path;for(var r=[];;){let n;if(B instanceof Ci&&a.type===0&&(n=B.runOp({...a,path:s.slice(r.length)}),n===null&&(n=void 0)),n===void 0&&r.length===s.length&&(B instanceof ht||B instanceof _g||B instanceof lI?n=B.runOp(a):n=Rc.runOp(B,a)),n!==void 0)if(n!==null){let c=n.data;for(let d=r.length-1;d>=0;d--){let u=s[d],y=r[d];if(y instanceof ht){if(typeof u=="number")throw new Error("illegal arg");c=y.modifyById(u,c)}else if(y instanceof _g){if(typeof u=="number")throw new Error("illegal arg");c=y.modifyById(u,c)}else if(y instanceof lI){if(typeof u=="number")throw new Error("illegal arg");c=y.modifyById(u,c)}else if(y instanceof Ci){let f={...y,[u]:c};c=Object.setPrototypeOf(f,Ci.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof u=="string"&&(u=parseInt(u),isNaN(u)))throw new Error("Invalid path");let f=c;c=[...y],c[u]=f}else c={...y,[u]:c};else return null}return{data:c,actual:{...n.actual,path:s},reverse:{...n.reverse,path:s}}}else return null;let h=s[r.length],l;if(B instanceof ht){if(typeof h=="number")throw new Error("");l=(Q=B.get(h))==null?void 0:Q.data}else if(B instanceof _g){if(typeof h=="number")throw new Error("");l=(E=B.get(h))==null?void 0:E.data}else B!==null&&(l=B[h]);if(l!==void 0)r.push(B),B=l;else return null}}g.apply=e;function i(B,a){for(let s=0;sa.props[s]!==void 0):!1}g.subsumed=o})(Fi||(Fi={}));var Cy;(g=>{function A(){return[]}g.empty=A;function I(a,s){let r=[];for(let Q of a){let[E,...n]=Q.path;E===s&&r.push({...Q,path:n})}return r}g.removePrefix=I;function e(a,s){return a.map(r=>({...r,path:[s,...r.path]}))}g.addPrefix=e;function i(a,s){return[...a,...s]}g.concat=i;function t(a,s){return[...a.filter(r=>!s.some(Q=>Fi.subsumed(r,Q))),...s]}g.compress=t;function C(a,s){return a.every(r=>s.every(Q=>Fi.commutative(r,Q)))}g.commutative=C;function o(a,s){for(let r of s){let Q=B(a,r);Q!==null&&(a=Q.data)}return a}g.applyAll=o;function B(a,s){var r=a;let Q=[],E=[];for(let n of s)try{if(n.type===3||n.type===5&&n.path[n.path.length-1]==="variables"){let h,l,c;if(n.type===3?(h=ji.zoom(r,[...n.path,n.id]),c=Fi.apply(r,{...n,type:2})):(h=ji.zoom(r,[...n.path,n.id,"value"]),c=Fi.apply(r,n)),c!==null){r=c.data;let[d,u]=GW(r,{[n.id]:h});r=d;for(let y=0;yM.includes(N)?n.id:v),h=G,k=f.pop()}else{if(k==="alphaOverride"||k==="alpha"){h/=100;let M=h,G=ji.zoom(r,f.slice(0,f.length-2)),v=G.layers.map(N=>N.id===f[f.length-1]?{...N,data:{...N.data,[k]:M}}:N);Object.setPrototypeOf(v,Object.getPrototypeOf(G.layers)),G.layers=v}l=n.id}Q.push({type:0,path:f,props:{[k]:h}}),E.push({type:0,path:f,props:{[k]:l}})}E.push(c.reverse),Q.push(c.actual)}}else{let h=Fi.apply(r,n);h!==null&&(Q.push(h.actual),r=h.data,E.push(h.reverse))}}catch(h){if(h instanceof IR)return null;throw h}return{data:r,actual:Q,reverse:E.reverse()}}g.apply=B})(Cy||(Cy={}));var CR=Symbol(),mW=Symbol(),_D=Symbol(),eh=class{reportOp(g,A,I=[]){let e=this;if(A===null)return;e._current=A.data;let i=I;for(;!(e instanceof BR);){let t=e._path,C=e._current;if(t!==""&&i.splice(0,0,t),e=e._parent,e===null)return;e.update(t,C)}e.push(i,g,A.actual,A.reverse)}deleteChildren(g){if(this._children){let A=this._children[g];if(A){let I=A[_D];I&&I(),delete this._children[g]}}}},UW=class extends eh{constructor(g,A,I){super(),this._parent=g,this._path=A,this._current=I}update(g,A){if(Array.isArray(this._current)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");this._current=[...this._current],this._current[g]=A}else this._current={...this._current,[g]:A}}runOp(g){this.reportOp(g,Rc.runOp(this._current,g),g.path)}},NW=class extends eh{constructor(g,A,I){super(),this._parent=g,this._path=A,this._current=I}update(g,A){this._current={...this._current,[g]:A},Object.setPrototypeOf(this._current,lI.prototype)}runOp(g){this.reportOp(g,this._current.runOp(g))}},oR={get(g,A){if(A===_D)return()=>{g._parent=null};if(A===CR)return g._current;if(A===mW)return g;let{_current:I,_children:e}=g;if(A==="push"&&Array.isArray(I))throw new Error("not supported to expand array");let i=e===void 0?void 0:e[A];if(i!==void 0)return i;let t=I[A],C=PD(g,A,t);return C!==t?(e===void 0&&(e={},g._children=e),e[A]=C,C):t},has(g,A){return A in g._current},ownKeys(g){return Reflect.ownKeys(g._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(g){return Object.getPrototypeOf(g._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(g,A){let I=g._current,e=Reflect.getOwnPropertyDescriptor(I,A);return e&&{writable:!0,configurable:!0,enumerable:e.enumerable,value:I[A]}}},FW={...oR,set(g,A,I){let e={type:0,props:{[A]:We(I)??I}};return g.deleteChildren(A),g.runOp(e),!0},deleteProperty(g,A){let I={type:0,props:{[A]:void 0}};return g.deleteChildren(A),g.runOp(I),!0}},RW={...oR,set(g,A,I){return I===void 0?this.deleteProperty(g,A):(g.deleteChildren(A),g.runOp({type:1,id:A,data:I})),!0},deleteProperty(g,A){return g.runOp({type:2,id:A}),!0}},y0=class extends eh{constructor(g,A,I){super(),this._children={},this._parent=g,this._path=A,this._current=I,this[_D]=()=>{this._parent=null}}unproxy(){return this._current}update(g,A){this._current=this._current.modifyById(g,A)}runOp(g){this.reportOp(g,this._current.runOp(g))}randomId(){return this._current.randomId()}isDescendantOf(g,A){return this._current.isDescendantOf(g,A)}childrenOf(g){return this._current.childrenOf(g)}traverse(g){return this._current.traverse(g)}get(g){return this._current.get(g)}parent(g){return this._current.parent(g)}traverse(g){this._current.traverse((A,I)=>{g(A,this.data(A))})}data(g){var C;let{_current:A,_children:I}=this,e=I===void 0?void 0:I[g];if(e!==void 0)return e;let i=(C=A.get(g))==null?void 0:C.data,t=PD(this,g,i);return t!==i?(I===void 0&&(I={},this._children=I),I[g]=t,t):i}add(g,A,I,e,i){this.runOp({type:7,parent:g,fi:A,id:I,data:e,children:i})}move(g,A,I){this.runOp({type:9,parent:g,fi:A,id:I})}insertAfter(g,A,I){let e=this._current.insertAfterHelper(g,A,I.length);for(let i=0;i{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(g){let A=this.length;for(let I=0;I0){let e=g[g.length-1];if(e.type===0&&A.type===0&&ji.equal(e.path,I)){Object.assign(e.props,A.props);return}}g.push({...A,path:I})}var BR=class extends eh{constructor(g){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=g}update(g,A){if(g!=="")throw new Error("");this._current=A}push(g,A,I,e){du(this.ts,A,g),du(this.actual,I,g),du(this.reverse,e,g)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function PD(g,A,I){return I instanceof ht?new y0(g,A,I):I instanceof _g?new w0(g,A,I):I instanceof lI?new Proxy(new NW(g,A,I),RW):I!==null&&typeof I=="object"?d0(I)?I:new Proxy(new UW(g,A,I),FW):I}function aR(g){let A=new BR(g);return[PD(A,"",g),A]}function Mn(g,A){let[I,e]=aR(g);return A(I),e.result()}function We(g){return g instanceof y0||g instanceof w0?g._current:g!==null&&typeof g=="object"?g[CR]:g}var ji;(g=>{function A(t,C){if(C.length===t.length)for(var o=0;o{delete a[s]}),a}else return C}g.removeOverridden=I;function e(t,C){if((t instanceof ht||t instanceof y0)&&typeof C=="string"||(t instanceof _g||t instanceof w0)&&typeof C=="string")return t.data(C);if(typeof C=="number"&&Array.isArray(t)||typeof C=="string"&&typeof t=="object"&&t!==null)return t[C]}g.zoomOnce=e;function i(t,C,o=0){for(;o(ay(),this?this.unpack(A,I):vc.prototype.unpack.call(Sk,A,I)));da=I>-1?I:A.length,kA=0,lo=0,aa=null,Ut=null,wg=A;try{TI=A.dataView||(A.dataView=new DataView(A.buffer,A.byteOffset,A.byteLength))}catch(e){throw wg=null,A instanceof Uint8Array?e:new Error("Source must be a Uint8Array or Buffer but was a "+(A&&typeof A=="object"?A.constructor.name:typeof A))}if(this instanceof vc){if(rt=this,this.structures)return LI=this.structures,Cl();(!LI||LI.length>0)&&(LI=[])}else rt=Sk,(!LI||LI.length>0)&&(LI=[]);return Cl()}unpackMultiple(A,I){let e,i=0;try{UQ=!0;let t=A.length,C=this?this.unpack(A,t):WD.unpack(A,t);if(I){for(I(C);kA=32&&(t.highByte=e-32>>5))}A.sharedLength=A.length;for(let e in I||[])if(e>=0){let i=A[e],t=I[e];t&&(i&&((A.restoreStructures||(A.restoreStructures=[]))[e]=i),A[e]=t)}return this.structures=A}decode(A,I){return this.unpack(A,I)}};function Cl(){try{if(!rt.trusted&&!UQ){let A=LI.sharedLength||0;Ada){let A=new Error("Unexpected end of MessagePack data");throw A.incomplete=!0,A}else if(!UQ)throw new Error("Data read, but end of buffer not reached");return g}catch(g){throw LI.restoreStructures&&fk(),ay(),(g instanceof RangeError||g.message.startsWith("Unexpected end of buffer"))&&(g.incomplete=!0),g}}function fk(){for(let g in LI.restoreStructures)LI[g]=LI.restoreStructures[g];LI.restoreStructures=null}function Se(){let g=wg[kA++];if(g<160)if(g<128){if(g<64)return g;{let A=LI[g&63]||rt.getStructures&&ER()[g&63];return A?(A.read||(A.read=S0(A,g&63)),A.read()):g}}else if(g<144)if(g-=128,rt.mapsAsObjects){let A={};for(let I=0;I=kA)return aa.slice(kA-Vt,(kA+=A)-Vt);if(lo==0&&da<140){let I=A<16?f0(A):nR(A);if(I!=null)return I}return By(A)}else{let A;switch(g){case 192:return null;case 193:return Ut?(A=Se(),A>0?Ut[1].slice(Ut.position1,Ut.position1+=A):Ut[0].slice(Ut.position0,Ut.position0-=A)):QR;case 194:return!1;case 195:return!0;case 196:return uu(wg[kA++]);case 197:return A=TI.getUint16(kA),kA+=2,uu(A);case 198:return A=TI.getUint32(kA),kA+=4,uu(A);case 199:return $a(wg[kA++]);case 200:return A=TI.getUint16(kA),kA+=2,$a(A);case 201:return A=TI.getUint32(kA),kA+=4,$a(A);case 202:if(A=TI.getFloat32(kA),rt.useFloat32>2){let I=G0[(wg[kA]&127)<<1|wg[kA+1]>>7];return kA+=4,(I*A+(A>0?.5:-.5)>>0)/I}return kA+=4,A;case 203:return A=TI.getFloat64(kA),kA+=8,A;case 204:return wg[kA++];case 205:return A=TI.getUint16(kA),kA+=2,A;case 206:return A=TI.getUint32(kA),kA+=4,A;case 207:return rt.int64AsNumber?(A=TI.getUint32(kA)*4294967296,A+=TI.getUint32(kA+4)):A=TI.getBigUint64(kA),kA+=8,A;case 208:return TI.getInt8(kA++);case 209:return A=TI.getInt16(kA),kA+=2,A;case 210:return A=TI.getInt32(kA),kA+=4,A;case 211:return rt.int64AsNumber?(A=TI.getInt32(kA)*4294967296,A+=TI.getUint32(kA+4)):A=TI.getBigInt64(kA),kA+=8,A;case 212:if(A=wg[kA++],A==114)return Uk(wg[kA++]&63);{let I=$i[A];if(I)return I.read?(kA++,I.read(Se())):I.noBuffer?(kA++,I()):I(wg.subarray(kA,++kA));throw new Error("Unknown extension "+A)}case 213:return A=wg[kA],A==114?(kA++,Uk(wg[kA++]&63,wg[kA++])):$a(2);case 214:return $a(4);case 215:return $a(8);case 216:return $a(16);case 217:return A=wg[kA++],lo>=kA?aa.slice(kA-Vt,(kA+=A)-Vt):vW(A);case 218:return A=TI.getUint16(kA),kA+=2,lo>=kA?aa.slice(kA-Vt,(kA+=A)-Vt):qW(A);case 219:return A=TI.getUint32(kA),kA+=4,lo>=kA?aa.slice(kA-Vt,(kA+=A)-Vt):LW(A);case 220:return A=TI.getUint16(kA),kA+=2,kk(A);case 221:return A=TI.getUint32(kA),kA+=4,kk(A);case 222:return A=TI.getUint16(kA),kA+=2,Mk(A);case 223:return A=TI.getUint32(kA),kA+=4,Mk(A);default:if(g>=224)return g-256;if(g===void 0){let I=new Error("Unexpected end of MessagePack data");throw I.incomplete=!0,I}throw new Error("Unknown MessagePack token "+g)}}}var JW=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function S0(g,A){function I(){if(I.count++>2){let i=g.read=new Function("r","return function(){return {"+g.map(t=>JW.test(t)?t+":r()":"["+JSON.stringify(t)+"]:r()").join(",")+"}}")(Se);return g.highByte===0&&(g.read=Gk(A,g.read)),i()}let e={};for(let i=0,t=g.length;ifunction(){let I=wg[kA++];if(I===0)return A();let e=g<32?-(g+(I<<5)):g+(I<<5),i=LI[e]||ER()[e];if(!i)throw new Error("Record id is not defined for "+e);return i.read||(i.read=S0(i,g)),i.read()};function ER(){let g=DR(()=>(wg=null,rt.getStructures()));return LI=rt._mergeStructures(g,LI)}var By=jD,vW=jD,qW=jD,LW=jD;function jD(g){let A;if(g<16&&(A=f0(g)))return A;if(g>64&&oy)return oy.decode(wg.subarray(kA,kA+=g));let I=kA+g,e=[];for(A="";kA65535&&(B-=65536,e.push(B>>>10&1023|55296),B=56320|B&1023),e.push(B)}else e.push(i);e.length>=4096&&(A+=Qi.apply(String,e),e.length=0)}return e.length>0&&(A+=Qi.apply(String,e)),A}function kk(g){let A=new Array(g);for(let I=0;I0){kA=A;return}I[e]=i}return Qi.apply(String,I)}function f0(g){if(g<4)if(g<2){if(g===0)return"";{let A=wg[kA++];if((A&128)>1){kA-=1;return}return Qi(A)}}else{let A=wg[kA++],I=wg[kA++];if((A&128)>0||(I&128)>0){kA-=2;return}if(g<3)return Qi(A,I);let e=wg[kA++];if((e&128)>0){kA-=3;return}return Qi(A,I,e)}else{let A=wg[kA++],I=wg[kA++],e=wg[kA++],i=wg[kA++];if((A&128)>0||(I&128)>0||(e&128)>0||(i&128)>0){kA-=4;return}if(g<6){if(g===4)return Qi(A,I,e,i);{let t=wg[kA++];if((t&128)>0){kA-=5;return}return Qi(A,I,e,i,t)}}else if(g<8){let t=wg[kA++],C=wg[kA++];if((t&128)>0||(C&128)>0){kA-=6;return}if(g<7)return Qi(A,I,e,i,t,C);let o=wg[kA++];if((o&128)>0){kA-=7;return}return Qi(A,I,e,i,t,C,o)}else{let t=wg[kA++],C=wg[kA++],o=wg[kA++],B=wg[kA++];if((t&128)>0||(C&128)>0||(o&128)>0||(B&128)>0){kA-=8;return}if(g<10){if(g===8)return Qi(A,I,e,i,t,C,o,B);{let a=wg[kA++];if((a&128)>0){kA-=9;return}return Qi(A,I,e,i,t,C,o,B,a)}}else if(g<12){let a=wg[kA++],s=wg[kA++];if((a&128)>0||(s&128)>0){kA-=10;return}if(g<11)return Qi(A,I,e,i,t,C,o,B,a,s);let r=wg[kA++];if((r&128)>0){kA-=11;return}return Qi(A,I,e,i,t,C,o,B,a,s,r)}else{let a=wg[kA++],s=wg[kA++],r=wg[kA++],Q=wg[kA++];if((a&128)>0||(s&128)>0||(r&128)>0||(Q&128)>0){kA-=12;return}if(g<14){if(g===12)return Qi(A,I,e,i,t,C,o,B,a,s,r,Q);{let E=wg[kA++];if((E&128)>0){kA-=13;return}return Qi(A,I,e,i,t,C,o,B,a,s,r,Q,E)}}else{let E=wg[kA++],n=wg[kA++];if((E&128)>0||(n&128)>0){kA-=14;return}if(g<15)return Qi(A,I,e,i,t,C,o,B,a,s,r,Q,E,n);let h=wg[kA++];if((h&128)>0){kA-=15;return}return Qi(A,I,e,i,t,C,o,B,a,s,r,Q,E,n,h)}}}}}function uu(g){return rt.copyBuffers?Uint8Array.prototype.slice.call(wg,kA,kA+=g):wg.subarray(kA,kA+=g)}function $a(g){let A=wg[kA++];if($i[A])return $i[A](wg.subarray(kA,kA+=g));throw new Error("Unknown extension type "+A)}var mk=new Array(4096);function hR(){let g=wg[kA++];if(g>=160&&g<192){if(g=g-160,lo>=kA)return aa.slice(kA-Vt,(kA+=g)-Vt);if(!(lo==0&&da<180))return By(g)}else return kA--,Se();let A=(g<<5^(g>1?TI.getUint16(kA):g>0?wg[kA]:0))&4095,I=mk[A],e=kA,i=kA+g-3,t,C=0;if(I&&I.bytes==g){for(;e{var I=Se();let e=g;A!==void 0&&(g=g<32?-((A<<5)+g):(A<<5)+g,I.highByte=A);let i=LI[g];return i&&i.isShared&&((LI.restoreStructures||(LI.restoreStructures=[]))[g]=i),LI[g]=I,I.read=S0(I,e),I.read()},lR=typeof self=="object"?self:global;$i[0]=()=>{};$i[0].noBuffer=!0;$i[101]=()=>{let g=Se();return(lR[g[0]]||Error)(g[1])};$i[105]=g=>{let A=TI.getUint32(kA-4);uB||(uB=new Map);let I=wg[kA],e;I>=144&&I<160||I==220||I==221?e=[]:e={};let i={target:e};uB.set(A,i);let t=Se();return i.used?Object.assign(e,t):(i.target=t,t)};$i[112]=g=>{let A=TI.getUint32(kA-4),I=uB.get(A);return I.used=!0,I.target};$i[115]=()=>new Set(Se());var cR=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(g=>g+"Array");$i[116]=g=>{let A=g[0],I=cR[A];if(!I)throw new Error("Could not find typed array for code "+A);return new lR[I](Uint8Array.prototype.slice.call(g,1).buffer)};$i[120]=()=>{let g=Se();return new RegExp(g[0],g[1])};$i[98]=g=>{let A=(g[0]<<24)+(g[1]<<16)+(g[2]<<8)+g[3],I=kA;kA+=A-4,Ut=[Se(),Se()],Ut.position0=0,Ut.position1=0;let e=kA;kA=I;try{return Se()}finally{kA=e}};$i[255]=g=>g.length==4?new Date((g[0]*16777216+(g[1]<<16)+(g[2]<<8)+g[3])*1e3):g.length==8?new Date(((g[0]<<22)+(g[1]<<14)+(g[2]<<6)+(g[3]>>2))/1e6+((g[3]&3)*4294967296+g[4]*16777216+(g[5]<<16)+(g[6]<<8)+g[7])*1e3):g.length==12?new Date(((g[0]<<24)+(g[1]<<16)+(g[2]<<8)+g[3])/1e6+((g[4]&128?-281474976710656:0)+g[6]*1099511627776+g[7]*4294967296+g[8]*16777216+(g[9]<<16)+(g[10]<<8)+g[11])*1e3):new Date("invalid");function DR(g){let A=da,I=kA,e=Vt,i=lo,t=aa,C=uB,o=Ut,B=new Uint8Array(wg.slice(0,da)),a=LI,s=LI.slice(0,LI.length),r=rt,Q=UQ,E=g();return da=A,kA=I,Vt=e,lo=i,aa=t,uB=C,Ut=o,wg=B,UQ=Q,LI=a,LI.splice(0,LI.length,...s),rt=r,TI=new DataView(wg.buffer,wg.byteOffset,wg.byteLength),E}function ay(){wg=null,uB=null,LI=null}function bW(g){g.unpack?$i[g.type]=g.unpack:$i[g.type]=g}var G0=new Array(147);for(let g=0;g<256;g++)G0[g]=+("1e"+Math.floor(45.15-g*.30103));var WD=new vc({useRecords:!1});WD.unpack;WD.unpackMultiple;WD.unpack;var YW=new Float32Array(1);new Uint8Array(YW.buffer,0,4);var Ac;try{Ac=new TextEncoder}catch{}var qc,k0,ZD=typeof Buffer<"u",pu=ZD?Buffer.allocUnsafeSlow:Uint8Array,dR=ZD?Buffer:Uint8Array,Nk=ZD?4294967296:2144337920,PA,Ue,FA=0,VC,zC=null,xW=/[\u0080-\uFFFF]/,ME=Symbol("record-id"),uR=class extends vc{constructor(g){super(g),this.offset=0;let A,I,e,i,t,C=0,o=dR.prototype.utf8Write?function(k,M,G){return PA.utf8Write(k,M,G)}:Ac&&Ac.encodeInto?function(k,M){return Ac.encodeInto(k,PA.subarray(M)).written}:!1,B=this;g||(g={});let a=g&&g.sequential,s=g.structures||g.saveStructures,r=g.maxSharedStructures;if(r==null&&(r=s?32:0),r>8160)throw new Error("Maximum maxSharedStructure is 8160");let Q=g.maxOwnStructures;Q==null&&(Q=s?32:64),a&&!g.saveStructures&&(this.structures=[]);let E=r>32||Q+r>64,n=r+64,h=r+Q+64;if(h>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let l=[],c=0,d=0;this.pack=this.encode=function(k,M){if(PA||(PA=new pu(8192),Ue=new DataView(PA.buffer,0,8192),FA=0),VC=PA.length-10,VC-FA<2048?(PA=new pu(PA.length),Ue=new DataView(PA.buffer,0,PA.length),VC=PA.length-10,FA=0):FA=FA+7&2147483640,A=FA,t=B.structuredClone?new Map:null,B.bundleStrings?(zC=["",""],PA[FA++]=214,PA[FA++]=98,zC.position=FA-A,FA+=4):zC=null,I=B.structures,I){I.uninitialized&&(I=B._mergeStructures(B.getStructures()));let G=I.sharedLength||0;if(G>r)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+I.sharedLength);if(!I.transitions){I.transitions=Object.create(null);for(let v=0;vVC&&f(FA),B.offset=FA;let G=TW(PA.subarray(A,FA),t.idsToInsert);return t=null,G}return M&OW?(PA.start=A,PA.end=FA,PA):PA.subarray(A,FA)}finally{if(I){if(d<10&&d++,c>1e4)I.transitions=null,d=0,c=0,l.length>0&&(l=[]);else if(l.length>0&&!a){for(let G=0,v=l.length;GG&&(I=I.slice(0,G));let v=PA.subarray(A,FA);return B.saveStructures(I,C)===!1?(B._mergeStructures(B.getStructures()),B.pack(k)):(C=G,v)}}M&_W&&(FA=A)}};let u=k=>{FA>VC&&(PA=f(FA));var M=typeof k,G;if(M==="string"){let v=k.length;if(zC&&v>=8&&v<4096){let O=xW.test(k);zC[O?0:1]+=k,PA[FA++]=193,u(O?-v:v);return}let N;v<32?N=1:v<256?N=2:v<65536?N=3:N=5;let b=v*3;if(FA+b>VC&&(PA=f(FA+b)),v<64||!o){let O,H,_,gA=FA+N;for(O=0;O>6|192,PA[gA++]=H&63|128):(H&64512)===55296&&((_=k.charCodeAt(O+1))&64512)===56320?(H=65536+((H&1023)<<10)+(_&1023),O++,PA[gA++]=H>>18|240,PA[gA++]=H>>12&63|128,PA[gA++]=H>>6&63|128,PA[gA++]=H&63|128):(PA[gA++]=H>>12|224,PA[gA++]=H>>6&63|128,PA[gA++]=H&63|128);G=gA-FA-N}else G=o(k,FA+N,b);G<32?PA[FA++]=160|G:G<256?(N<2&&PA.copyWithin(FA+2,FA+1,FA+1+G),PA[FA++]=217,PA[FA++]=G):G<65536?(N<3&&PA.copyWithin(FA+3,FA+2,FA+2+G),PA[FA++]=218,PA[FA++]=G>>8,PA[FA++]=G&255):(N<5&&PA.copyWithin(FA+5,FA+3,FA+3+G),PA[FA++]=219,Ue.setUint32(FA,G),FA+=4),FA+=G}else if(M==="number")if(k>>>0===k)k<64?PA[FA++]=k:k<256?(PA[FA++]=204,PA[FA++]=k):k<65536?(PA[FA++]=205,PA[FA++]=k>>8,PA[FA++]=k&255):(PA[FA++]=206,Ue.setUint32(FA,k),FA+=4);else if(k>>0===k)k>=-32?PA[FA++]=256+k:k>=-128?(PA[FA++]=208,PA[FA++]=k+256):k>=-32768?(PA[FA++]=209,Ue.setInt16(FA,k),FA+=2):(PA[FA++]=210,Ue.setInt32(FA,k),FA+=4);else{let v;if((v=this.useFloat32)>0&&k<4294967296&&k>=-2147483648){PA[FA++]=202,Ue.setFloat32(FA,k);let N;if(v<4||(N=k*G0[(PA[FA]&127)<<1|PA[FA+1]>>7])>>0===N){FA+=4;return}else FA--}PA[FA++]=203,Ue.setFloat64(FA,k),FA+=8}else if(M==="object")if(!k)PA[FA++]=192;else{if(t){let N=t.get(k);if(N){if(!N.id){let b=t.idsToInsert||(t.idsToInsert=[]);N.id=b.push(N)}PA[FA++]=214,PA[FA++]=112,Ue.setUint32(FA,N.id),FA+=4;return}else t.set(k,{offset:FA-A})}let v=k.constructor;if(v===Object)y(k,!0);else if(v===Array){G=k.length,G<16?PA[FA++]=144|G:G<65536?(PA[FA++]=220,PA[FA++]=G>>8,PA[FA++]=G&255):(PA[FA++]=221,Ue.setUint32(FA,G),FA+=4);for(let N=0;N>8,PA[FA++]=G&255):(PA[FA++]=223,Ue.setUint32(FA,G),FA+=4);for(let[N,b]of k)u(N),u(b)}else{for(let N=0,b=qc.length;N(PA=_,_=null,FA+=BA,FA>VC&&f(FA),{target:PA,targetView:Ue,position:FA-BA}),u)}finally{_&&(PA=_,Ue=gA,FA=CA,VC=PA.length-10)}AA&&(AA.length+FA>VC&&f(AA.length+FA),FA=HW(AA,PA,FA,H.type));return}}y(k,!k.hasOwnProperty)}}else if(M==="boolean")PA[FA++]=k?195:194;else if(M==="bigint"){if(k=-(BigInt(1)<0)PA[FA++]=207,Ue.setBigUint64(FA,k);else if(this.largeBigIntToFloat)PA[FA++]=203,Ue.setFloat64(FA,Number(k));else throw new RangeError(k+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");FA+=8}else if(M==="undefined")this.encodeUndefinedAsNil?PA[FA++]=192:(PA[FA++]=212,PA[FA++]=0,PA[FA++]=0);else if(M==="function")u(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},y=this.useRecords===!1?this.variableMapSize?k=>{let M=Object.keys(k),G=M.length;G<16?PA[FA++]=128|G:G<65536?(PA[FA++]=222,PA[FA++]=G>>8,PA[FA++]=G&255):(PA[FA++]=223,Ue.setUint32(FA,G),FA+=4);let v;for(let N=0;N{PA[FA++]=222;let G=FA-A;FA+=2;let v=0;for(let N in k)(M||k.hasOwnProperty(N))&&(u(N),u(k[N]),v++);PA[G+++A]=v>>8,PA[G+A]=v&255}:k=>{let M=Object.keys(k),G,v=i.transitions||(i.transitions=Object.create(null)),N=0;for(let O=0,H=M.length;O=96&&E?(PA[FA++]=((b-=96)&31)+96,PA[FA++]=b>>5):PA[FA++]=b;else{b=i.nextId,b||(b=64),b=h&&(b=n),i.nextId=b+1);let O=M.highByte=b>=96&&E?b-96>>5:-1;v[ME]=b,i[b-64]=M,b=0?(PA[FA++]=(b&31)+96,PA[FA++]=O):PA[FA++]=b):(O>=0?(PA[FA++]=213,PA[FA++]=114,PA[FA++]=(b&31)+96,PA[FA++]=O):(PA[FA++]=212,PA[FA++]=114,PA[FA++]=b),N&&(c+=d*N),l.length>=Q&&(l.shift()[ME]=0),l.push(v),u(M))}for(let O=0,H=M.length;O{let M;if(k>16777216){if(k-A>Nk)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(Nk,Math.round(Math.max((k-A)*(k>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(k-A<<2,PA.length-1)>>12)+1<<12;let G=new pu(M);return Ue=new DataView(G.buffer,0,M),PA.copy?PA.copy(G,0,A,k):G.set(PA.slice(A,k)),FA-=A,A=0,VC=G.length-10,PA=G}}useBuffer(g){PA=g,Ue=new DataView(PA.buffer,PA.byteOffset,PA.byteLength),FA=0}};k0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,sR];qc=[{pack(g,A,I){let e=g.getTime()/1e3;if((this.useTimestamp32||g.getMilliseconds()===0)&&e>=0&&e<4294967296){let{target:i,targetView:t,position:C}=A(6);i[C++]=214,i[C++]=255,t.setUint32(C,e)}else if(e>0&&e<17179869184){let{target:i,targetView:t,position:C}=A(10);i[C++]=215,i[C++]=255,t.setUint32(C,g.getMilliseconds()*4e6+(e/1e3/4294967296>>0)),t.setUint32(C+4,e)}else if(isNaN(e)){if(this.onInvalidDate)return A(0),I(this.onInvalidDate());let{target:i,targetView:t,position:C}=A(3);i[C++]=212,i[C++]=255,i[C++]=255}else{let{target:i,targetView:t,position:C}=A(15);i[C++]=199,i[C++]=12,i[C++]=255,t.setUint32(C,g.getMilliseconds()*1e6),t.setBigInt64(C+4,BigInt(Math.floor(e)))}}},{pack(g,A,I){let e=Array.from(g),{target:i,position:t}=A(this.structuredClone?3:0);this.structuredClone&&(i[t++]=212,i[t++]=115,i[t++]=0),I(e)}},{pack(g,A,I){let{target:e,position:i}=A(this.structuredClone?3:0);this.structuredClone&&(e[i++]=212,e[i++]=101,e[i++]=0),I([g.name,g.message])}},{pack(g,A,I){let{target:e,position:i}=A(this.structuredClone?3:0);this.structuredClone&&(e[i++]=212,e[i++]=120,e[i++]=0),I([g.source,g.flags])}},{pack(g,A){this.structuredClone?Fk(g,16,A):Rk(ZD?Buffer.from(g):new Uint8Array(g),A)}},{pack(g,A){let I=g.constructor;I!==dR&&this.structuredClone?Fk(g,cR.indexOf(I.name),A):Rk(g,A)}},{pack(g,A){let{target:I,position:e}=A(1);I[e]=193}}];function Fk(g,A,I,e){let i=g.byteLength;if(i+1<256){var{target:t,position:C}=I(4+i);t[C++]=199,t[C++]=i+1}else if(i+1<65536){var{target:t,position:C}=I(5+i);t[C++]=200,t[C++]=i+1>>8,t[C++]=i+1&255}else{var{target:t,position:C,targetView:o}=I(7+i);t[C++]=201,o.setUint32(C,i+1),C+=4}t[C++]=116,t[C++]=A,t.set(new Uint8Array(g.buffer,g.byteOffset,g.byteLength),C)}function Rk(g,A){let I=g.byteLength;var e,i;if(I<256){var{target:e,position:i}=A(I+2);e[i++]=196,e[i++]=I}else if(I<65536){var{target:e,position:i}=A(I+3);e[i++]=197,e[i++]=I>>8,e[i++]=I&255}else{var{target:e,position:i,targetView:t}=A(I+5);e[i++]=198,t.setUint32(i,I),i+=4}e.set(g,i)}function HW(g,A,I,e){let i=g.length;switch(i){case 1:A[I++]=212;break;case 2:A[I++]=213;break;case 4:A[I++]=214;break;case 8:A[I++]=215;break;case 16:A[I++]=216;break;default:i<256?(A[I++]=199,A[I++]=i):i<65536?(A[I++]=200,A[I++]=i>>8,A[I++]=i&255):(A[I++]=201,A[I++]=i>>24,A[I++]=i>>16&255,A[I++]=i>>8&255,A[I++]=i&255)}return A[I++]=e,A.set(g,I),I+=i,I}function TW(g,A){let I,e=A.length*6,i=g.length-e;for(A.sort((t,C)=>t.offset>C.offset?1:-1);I=A.pop();){let t=I.offset,C=I.id;g.copyWithin(t+e,t,i),e-=6;let o=t+e;g[o++]=214,g[o++]=105,g[o++]=C>>24,g[o++]=C>>16&255,g[o++]=C>>8&255,g[o++]=C&255,i=t}return g}function iE(g){if(g.Class){if(!g.pack&&!g.write)throw new Error("Extension has no pack or write function");if(g.pack&&!g.type)throw new Error("Extension has no type (numeric code to identify the extension)");k0.unshift(g.Class),qc.unshift(g)}bW(g)}var pR=new uR({useRecords:!1});pR.pack;pR.pack;var OW=512,_W=1024,Kk=new uR({structuredClone:!0});iE({Class:lI.prototype.constructor,type:1,write(g){return{...g}},read(g){return Object.setPrototypeOf(g,lI.prototype),g}});iE({Class:_g.prototype.constructor,type:2,write(g){return[...g]},read(g){return Object.setPrototypeOf(g,_g.prototype),g}});iE({Class:ht.prototype.constructor,type:3,write(g){return[...g]},read(g){return Object.setPrototypeOf(g,ht.prototype),g}});iE({Class:yk.prototype.constructor,type:4,write(g){return g.id},read(g){return new yk(g)}});iE({Class:wk.prototype.constructor,type:5,write(g){return g.data},read(g){return new wk(g)}});iE({Class:Ci.prototype.constructor,type:6,write(g){return{...g}},read(g){return Object.setPrototypeOf(g,Ci.prototype),g}});function PW(g){var A=0;if(g.length===0)return A;for(let I=0;I{function A(i){return Kk.pack(i)}g.serialize=A;function I(i){return Kk.unpack(i)}g.deserialize=I;function e(i){return PW(A(ry(i))).toString()}g.checksum=e})(sy||(sy={}));var Jk;(g=>{function A(e){return e.type==="Conditional"?e.condition.type==="Distance"?"Distance":"StateChange":e.type}g.toEventUIType=A;function I(e){return e==="Distance"||e==="StateChange"?"Conditional":e}g.fromEventUIType=I})(Jk||(Jk={}));var Mt={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"]},vk;(g=>{function A(e){return e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"}g.is=A;function I(e){return e==="MouseDown"||e==="MouseUp"||e==="MousePress"?{type:e,mode:"Object",disabled:!1,runMode:"Once",actions:new _g}:{type:e,disabled:!1,key:void 0,runMode:"Once",actions:new _g}}g.defaultData=I})(vk||(vk={}));var Lc;(g=>{function A(I){return{type:"Property",value:[I??null,"position","x"]}}g.propertyDefaultData=A,g.valueDefaultData={type:"Literal",value:0}})(Lc||(Lc={}));var Qy;(g=>{function A(i){return{type:"Comparison",operator:"==",lOperand:Lc.propertyDefaultData(i),rOperand:{...Lc.valueDefaultData}}}g.comparisonDefaultData=A;function I(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}g.distanceDefaultData=I;function e(i,t){return{type:"State",object:i??null,state:t??null}}g.stateDefaultData=e})(Qy||(Qy={}));var qk;(g=>{function A(e){return e.type==="Conditional"}g.is=A;function I(e){return{type:"Conditional",disabled:!1,inActions:new _g,outActions:new _g,condition:Qy.distanceDefaultData(e)}}g.defaultData=I})(qk||(qk={}));var Lk;(g=>g.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 _g,drop:new _g}})(Lk||(Lk={}));var Ey;(g=>g.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 _g})(Ey||(Ey={}));var ny;(g=>g.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})(ny||(ny={}));var bk;(g=>{function A(e){return e.type==="MouseHover"}g.is=A;function I(){return{type:"MouseHover",disabled:!1,actions:new _g}}g.defaultData=I})(bk||(bk={}));var Yk;(g=>{function A(e){return e.type==="Scroll"}g.is=A;function I(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new _g}}g.defaultData=I})(Yk||(Yk={}));var xk;(g=>{function A(e){return e.type==="Start"}g.is=A;function I(){return{type:"Start",disabled:!1,actions:new _g}}g.defaultData=I})(xk||(xk={}));var Hk;(g=>{function A(e){return e.type==="Collision"}g.is=A;function I(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new _g}}g.defaultData=I})(Hk||(Hk={}));var Tk;(g=>{function A(e){return e.type==="Trigger"}g.is=A;function I(e,i){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new _g,triggerZone:"box",position:i.toArray(),rotation:[0,0,0],size:e.toArray(),radius:e.length()/2,helperVisible:!0}}g.defaultData=I})(Tk||(Tk={}));var hy;(g=>{g.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function A(C){return C.type==="Resize"}g.is=A;function I(C){return typeof C=="string"?C:"custom"}g.sizeToDevice=I;function e(C){return typeof C=="string"?[...g.defaultSizes[C]]:[...C]}g.deviceToSize=e;function i(){let C={size:"mobile",operator:"<",actions:new _g},o={size:"tablet",operator:"<",actions:new _g},B={size:[...g.defaultSizes.custom],operator:"<>",actions:new _g},a=new _g;return a.push({id:vg.generateUUID(),fi:0,data:C},{id:vg.generateUUID(),fi:1,data:o},{id:vg.generateUUID(),fi:2,data:B}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:a}}g.defaultData=i;function t(){return{size:[...g.defaultSizes.custom],operator:"<>",actions:new _g}}g.defaultBreakpointData=t})(hy||(hy={}));var ly;(g=>{g.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 A(e){return e.type==="VariableChange"}g.is=A;function I(){return{disabled:!1,type:"VariableChange",actions:new _g,variableId:"",objectId:null,property:"Position X"}}g.defaultData=I})(ly||(ly={}));var tE="personal camera",an="a218fcc3-276b-49b9-b485-49037fd14f5f",jW=2960946,CC=5526619,eQ;(g=>{function A(e,i){return e[0]===i[0]&&e[1]===i[1]}g.isEqual=A;function I(e,i,t){return[e[0]+(i[0]-e[0])*t,e[1]+(i[1]-e[1])*t]}g.lerp=I})(eQ||(eQ={}));var Gr;(g=>{function A(B,a){return B[0]===a[0]&&B[1]===a[1]&&B[2]===a[2]}g.isEqual=A;function I(B,a){return[B[0]+a[0],B[1]+a[1],B[2]+a[2]]}g.add=I;function e(B,a){return[B[0]-a[0],B[1]-a[1],B[2]-a[2]]}g.sub=e;function i(B,a){return[B[0]/a[0],B[1]/a[1],B[2]/a[2]]}g.div=i;function t(B,a){return[B[0]*a[0],B[1]*a[1],B[2]*a[2]]}g.mul=t;function C(B,a){return Math.hypot(B[0]-a[0],B[1]-a[1],B[2]-a[2])}g.dist=C;function o(B,a,s){return[B[0]+(a[0]-B[0])*s,B[1]+(a[1]-B[1])*s,B[2]+(a[2]-B[2])*s]}g.lerp=o})(Gr||(Gr={}));var bc;(g=>{function A(e,i){return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]}g.isEqual=A;function I(e,i,t){return[e[0]+(i[0]-e[0])*t,e[1]+(i[1]-e[1])*t,e[2]+(i[2]-e[2])*t,e[3]+(i[3]-e[3])*t]}g.lerp=I})(bc||(bc={}));var NQ;(g=>{g.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function A(i,t){for(let C=0;C<16;C++)if(i[C]!==t[C])return!1;return!0}g.isEqual=A;function I(i){return i??g.identity}g.simplify=I;function e(i,t){let C=t.slice(0);for(var o=0,B=t.length;o{function A(B){return typeof B=="object"&&typeof B.r=="number"&&typeof B.g=="number"&&typeof B.b=="number"}g.isRGB=A,g.white={r:1,g:1,b:1},g.red={r:1,g:0,b:0},g.black={r:0,g:0,b:0};function I(B){return{r:Math.round(B.r*255),g:Math.round(B.g*255),b:Math.round(B.b*255),a:1}}g.toRgb255a1=I;function e(B){return{r:B.r,g:B.g,b:B.b}}g.clone=e;function i(B){return B=Math.floor(B),{r:(B>>16&255)/255,g:(B>>8&255)/255,b:(B&255)/255}}g.fromHex=i;function t(B){return Math.round(B.r*255)*65536+Math.round(B.g*255)*256+Math.round(B.b*255)}g.toHex=t;function C(B,a){return B.r===a.r&&B.g===a.g&&B.b===a.b}g.equals=C;function o(B,a,s){return{r:B.r+(a.r-B.r)*s,g:B.g+(a.g-B.g)*s,b:B.b+(a.b-B.b)*s}}g.lerp=o})(_i||(_i={}));var MC;(g=>{g.white={..._i.white,a:1},g.transparent={..._i.white,a:0};function A(C){return{r:C[0],g:C[1],b:C[2],a:C[3]}}g.from0to1=A;function I(C,o){return{..._i.fromHex(C),a:o}}g.fromHexAndA=I;function e(C){return{r:Math.round(C.r*255),g:Math.round(C.g*255),b:Math.round(C.b*255),a:C.a}}g.toRgb255a1=e;function i(C,o){return _i.equals(C,o)&&C.a===o.a}g.equals=i;function t(C,o,B){return{r:C.r+(o.r-C.r)*B,g:C.g+(o.g-C.g)*B,b:C.b+(o.b-C.b)*B,a:C.a+(o.a-C.a)*B}}g.lerp=t})(MC||(MC={}));var cy;(g=>g.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(cy||(cy={}));var Ok;(g=>g.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Ok||(Ok={}));var _k;(g=>g.defaultData={control1:[.5,0],control2:[.5,1]})(_k||(_k={}));var Ia;(g=>(g.linear=[0,0,1,1],g.ease=[.25,.1,.25,1],g.easeIn=[.42,0,1,1],g.easeOut=[0,0,.58,1],g.easeInOut=[.42,0,.58,1]))(Ia||(Ia={}));function WW(g){return typeof g=="string"&&g.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(g):!1}var Kr;(g=>{g.all=["PerspectiveCamera","OrthographicCamera"];function A(I){return g.all.includes(I)}g.is=A})(Kr||(Kr={}));var FQ;(g=>{g.DefaultUp=[0,1,0],g.DefaultTargetOffset=1e3,g.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:g.DefaultUp,isUpVectorFlipped:!1,targetOffset:g.DefaultTargetOffset};function A(I){return I.type==="PerspectiveCamera"?I.perspective.zoom:I.orthographic.zoom}g.getZoom=A})(FQ||(FQ={}));var ra;(g=>{function A(e,i=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},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:[e[0]+e[0]*i,0,0]},grid:{count:[2,2,2],size:e.map(t=>t*(1+i)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}g.defaultData=A;function I(e,i){let t={...e};if(yR.forEach(C=>{Object.assign(t,{[C]:i[C]??e[C]})}),t.radial={...e.radial},i.radial){let C=e.radial,o=i.radial;wR.forEach(B=>{Object.assign(t.radial,{[B]:o[B]??C[B]})})}if(t.linear={...e.linear},i.linear){let C=e.linear,o=i.linear;SR.forEach(B=>{Object.assign(t.linear,{[B]:o[B]??C[B]})})}if(t.grid={...e.grid},i.grid){let C=e.grid,o=i.grid;fR.forEach(B=>{Object.assign(t.grid,{[B]:o[B]??C[B]})})}if(t.toObject={...e.toObject},i.toObject){let C=e.toObject,o=i.toObject;GR.forEach(B=>{Object.assign(t.toObject,{[B]:o[B]??C[B]})})}if(t.randomnessObject={...e.randomnessObject},i.randomnessObject){let C=e.randomnessObject,o=i.randomnessObject;kR.forEach(B=>{Object.assign(t.randomnessObject,{[B]:o[B]??C[B]})})}return t}g.merge=I})(ra||(ra={}));var Dy;(g=>{g.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let A=["radial","linear","grid","toObject","randomnessObject"];function I(e,i){let t=[];e.count!==void 0&&t.push({type:0,path:i,props:{count:e.count}});for(let C of A){let o=e[C];o&&Object.keys(o).length>0&&t.push({type:0,path:[...i,C],props:o})}return t}g.toOps=I})(Dy||(Dy={}));var yR=["count"],wR=["radius","start","end","position","scale","rotation"],SR=["position","scale","rotation"],fR=["count","size"],GR=["count","position","scale","rotation"],kR=["strength","scale","rotation","position","movement","seed","freqScale"],dy;(g=>{g.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function A(I){return g.all.includes(I)}g.is=A})(dy||(dy={}));var uy;(g=>{function A(e){return I(e)}g.defaultData=A;function I(e){if(e==="PointLight")return{type:e,color:MC.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(e==="SpotLight")return{type:e,color:MC.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(e==="DirectionalLight")return{type:e,color:MC.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(uy||(uy={}));var RQ;(g=>g.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]})(RQ||(RQ={}));var py;(g=>{g.defaultData={castShadow:!0,receiveShadow:!0};function A(I,e){return I.castShadow===e.castShadow&&I.receiveShadow===e.receiveShadow}g.equals=A})(py||(py={}));var yy;(g=>{g.defaultData={flatShading:!1,wireframe:!1,side:0};function A(I,e){return I.flatShading===e.flatShading&&I.side===e.side&&I.wireframe===e.wireframe}g.equals=A})(yy||(yy={}));var wy;(g=>g.defaultData={...yy.defaultData,...py.defaultData})(wy||(wy={}));var Pk;(g=>{function A(I,e){var t,C;let i=[];if("material"in I){let o=typeof I.material=="string"?e.materials[I.material]??((t=e.lib.materials[I.material])==null?void 0:t.asset):I.material;o&&i.push(o)}else if("materials"in I)for(let o of I.materials){let B=typeof o=="string"?e.materials[o]??((C=e.lib.materials[o])==null?void 0:C.asset):o;B&&i.push(B)}return i}g.getMaterialData=A})(Pk||(Pk={}));var Yc;(g=>(g.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},g.maxSize=3e7))(Yc||(Yc={}));var jk;(g=>{function A(I){return I==="texture"||I==="video"||I==="color"||I==="depth"||I==="normal"||I==="gradient"||I==="noise"||I==="fresnel"||I==="rainbow"||I==="toon"||I==="outline"||I==="transmission"||I==="matcap"||I==="displace"||I==="pattern"||I==="light"}g.is=A})(jk||(jk={}));function ZW(g){return g.type!=="displace"}var Wk;(g=>{function A(I){return I==="phong"||I==="toon"||I==="lambert"||I==="physical"}g.is=A})(Wk||(Wk={}));var MR=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],VW=["wrapping","image","video","name"],Bt;(g=>{function A(t,C){let{texture:o,...B}=C;if(Object.assign(t,B),o){let a=t.texture;a&&Object.assign(a,o)}}g.patch=A;function I(t,C){return t==="light"&&C?e(C):i(t)}g.defaultData=I;function e(t){let C={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(t){case"phong":return{...C,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...C,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...C,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...C,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function i(t){let C={alpha:1,mode:0,isMask:!1,visible:!0};switch(t){case"texture":return{...C,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{...C,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Yc.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...C,type:"color",color:_i.fromHex(CC)};case"depth":return{...C,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{...C,type:"normal",cnormal:[1,1,1]};case"gradient":return{...C,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{...C,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{..._i.fromHex(6710886),a:1},colorB:{..._i.fromHex(6710886),a:1},colorC:{..._i.fromHex(16777215),a:1},colorD:{..._i.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{...C,type:"fresnel",color:MC.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...C,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...C,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:MC.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...C,type:"outline",outlineColor:MC.fromHexAndA(0,1),contourColor:MC.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{...C,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...C,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{...C,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{..._i.fromHex(0),a:1},colorB:{..._i.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}}}})(Bt||(Bt={}));var Ki;(g=>{function A(a){return!a.layers.some(s=>s.data.type==="texture"&&s.data.projection!==0||s.data.type==="depth"&&!s.data.isWorldSpace||s.data.type==="noise"||s.data.type==="displace")}g.isMergable=A;function I(a){let s="";return a.layers.forEach(r=>{Object.entries(r.data).forEach(([Q,E])=>{s+=`${Q}${E}`,Array.isArray(E)?E.forEach(n=>s+=`${n}`):typeof E=="object"?Object.values(E).forEach(n=>{typeof n=="number"?s+=`${n.toFixed(4)}`:s+=`${n}`}):s+=`${E}`})}),s}g.getHash=I;function e(){return{layers:new _g}}g.defaultEmptyData=e;function i(a="layer1",s="layer2"){return C("phong",a,s)}g.defaultData=i;function t(a,s){return{...a,name:s}}g.withName=t;function C(a,s="layer1",r="layer2"){let Q=new _g;return Q.push({fi:0,data:Bt.defaultData("light",a),id:s}),Q.push({fi:1,data:Bt.defaultData("color"),id:r}),{layers:Q}}g.defaultTwoLayerData=C;function o(a,s="phong",r="layer1",Q="layer2"){let E=Bt.defaultData("texture");Object.assign(E.texture,{image:a});let n=new _g;return n.push({fi:0,data:E,id:r}),n.push({fi:1,data:Bt.defaultData("light",s),id:Q}),{layers:n}}g.defaultTwoLayerTextureData=o;function B(a,s="phong",r="layer1",Q="layer2"){let E=Bt.defaultData("video");Object.assign(E.texture,{video:a});let n=new _g;return n.push({fi:0,data:E,id:r}),n.push({fi:1,data:Bt.defaultData("light",s),id:Q}),{layers:n}}g.defaultTwoLayerVideoTextureData=B})(Ki||(Ki={}));var xc;(g=>{function A(){return{points:new _g,roundness:0,shapeHoles:[],isClosed:!1}}g.defaultData=A})(xc||(xc={}));var Hc;(g=>{function A(){return{points:new _g,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}g.defaultData=A})(Hc||(Hc={}));var mR={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Sy;(g=>{function A(I,e){let i={...I};return NR.forEach(t=>{Object.assign(i,{[t]:e[t]??I[t]})}),i}g.merge=A})(Sy||(Sy={}));var UR={shape:mR,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},NR=["depth","offset","angle","twist","startScale","endScale"],Tc;(g=>{function A(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}g.is2DParametricMesh=A;function I(e){return e==="PolygonGeometry"||e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"||e==="PathGeometry"||e==="VectorGeometry"||e==="ConeGeometry"||e==="CubeGeometry"||e==="CylinderGeometry"||e==="DodecahedronGeometry"||e==="HelixGeometry"||e==="IcosahedronGeometry"||e==="LatheGeometry"||e==="PyramidGeometry"||e==="SphereGeometry"||e==="PlaneGeometry"||e==="BackdropGeometry"||e==="TorusGeometry"||e==="TorusKnotGeometry"||e==="BooleanGeometry"||e==="TextGeometry"}g.isParametricMesh=I})(Tc||(Tc={}));var fy;(g=>{function A(I,e){let i={...I};return Object.assign(i,e),i.type==="PathGeometry"&&"extrusion"in e&&e.extrusion&&(i.extrusion={...I.extrusion},Object.assign(i.extrusion,Sy.merge(i.extrusion,e.extrusion))),i}g.merge=A})(fy||(fy={}));var rQ;(g=>{function A(I){if(I==="RectangleGeometry")return{width:320,height:320,type:I,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(I==="PathGeometry")return{type:I,width:1,height:1,depth:1,path:Hc.defaultData(),extrusion:UR};if(I==="VectorGeometry")return{width:1,height:1,type:I,subdivisions:12,shape:xc.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(I==="BooleanGeometry")return{type:I,operation:2,width:0,height:0,depth:0,phongAngle:35};if(I==="TextGeometry")return{type:I,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(I==="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")}g.defaultData=A})(rQ||(rQ={}));var Zk=["width","height","depth"],Gy;(g=>g.defaultData={enabled:!1,useBackgroundColor:!1,color:_i.white,near:.1,far:2e3})(Gy||(Gy={}));var Oc;(g=>{let A={opacity:1,blendFunction:13,enabled:!1};g.defaultData={enabled:!1,pixelation:{...A,blendFunction:16,granularity:15},bloom:{...A,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...A,offset:[2,2]},vignette:{...A,darkness:1,offset:0},hueSaturation:{...A,hue:3,saturation:0},brightnessContrast:{...A,brightness:.25,contrast:0},depthOfField:{...A,focalLength:2,focusDistance:2,bokehScale:2},noise:{...A,blendFunction:16}}})(Oc||(Oc={}));var ky;(g=>g.defaultData={softShadowQuality:"low"})(ky||(ky={}));var My;(g=>g.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(My||(My={}));var my;(g=>g.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(my||(my={}));var KQ;(g=>g.defaultData={usePhysics:!1,gravity:-10})(KQ||(KQ={}));var Uy;(g=>g.defaultData={playCamera:tE,gameControlObject:null})(Uy||(Uy={}));var Ny;(g=>g.defaultData={backgroundColor:MC.fromHexAndA(jW,1),postprocessing:Oc.defaultData,fog:Gy.defaultData,globalPhysics:KQ.defaultData,ambient:My.defaultData,ao:my.defaultData,shadow:ky.defaultData,publish:Uy.defaultData})(Ny||(Ny={}));var Vk;(g=>{function A(e){return e==="Component"||e==="Instance"}g.isComponentRelated=A;function I(e){return e==="Empty"||e==="Instance"}g.isEmptyOrComponent=I})(Vk||(Vk={}));var JQ;(g=>{g.identity={...cy.identity,hiddenMatrix:NQ.identity};function A(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}g.fromObject=A;function I(i,t){return{position:(t==null?void 0:t.position)||i.position,rotation:(t==null?void 0:t.rotation)||i.rotation,scale:(t==null?void 0:t.scale)||i.scale,hiddenMatrix:(t==null?void 0:t.hiddenMatrix)||i.hiddenMatrix}}g.merge=I;function e(i,t){return iW({position:Gr.isEqual(i.position,t.position)?void 0:t.position,rotation:Gr.isEqual(i.rotation,t.rotation)?void 0:t.rotation,scale:Gr.isEqual(i.scale,t.scale)?null:t.scale,hiddenMatrix:NQ.isEqual(i.hiddenMatrix,t.hiddenMatrix)?void 0:t.hiddenMatrix})}g.diff=e})(JQ||(JQ={}));var Xi;(g=>g.defaultData={states:new _g,events:new _g,visible:!0,raycastLock:!1,physics:RQ.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...JQ.identity,cloner:null})(Xi||(Xi={}));var Fy;(g=>g.defaultData={type:"Empty",...Xi.defaultData})(Fy||(Fy={}));var zk;(g=>g.defaultData={type:"Component",...Xi.defaultData})(zk||(zk={}));var sQ;(g=>g.defaultData={type:"Mesh",...Xi.defaultData,...wy.defaultData})(sQ||(sQ={}));var mn;(g=>g.defaultData={...Xi.defaultData,...JQ.identity,position:[0,0,FQ.DefaultTargetOffset],...FQ.defaultData})(mn||(mn={}));var Ry;(g=>{function A(I){return{...Xi.defaultData,...uy.defaultData(I)}}g.defaultData=A,g.defaultDirectionalLightData={...g.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ry||(Ry={}));var _c;(g=>{function A(e,i,t=0){for(;t{g.rootOverrideProps=["physics","events"],g.compositeNonOptionalOverrideProps=["geometry"],g.compositeEntireOverrideOverrideProps=["material"];function A(e,i){return{...Xi.defaultData,...i,component:e,overrides:new Ci,physics:void 0,events:void 0,type:"Instance"}}g.ofComponent=A;function I(e){let i=JQ.fromObject(e.data);return A(e.id,i)}g.fromComponentData=I})(sa||(sa={}));var vQ;(g=>g.defaultData={type:"Page",...Xi.defaultData,physics:{...RQ.defaultData,fusedBody:!1},...Ny.defaultData,camera:mn.defaultData})(vQ||(vQ={}));var Ky;(g=>(g.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:NQ.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:RQ.defaultData,states:new _g,events:new _g,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...FQ.defaultData},g.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"]},g.defaultMeshObject={name:"Rectangle",...Xi.defaultData,...sQ.defaultData,geometry:rQ.defaultData("RectangleGeometry"),material:Ki.defaultTwoLayerData("phong","layer1","layer2")},g.defaultBooleanObject={name:"Boolean",...Xi.defaultData,...sQ.defaultData,geometry:rQ.defaultData("BooleanGeometry"),material:Ki.defaultTwoLayerData("phong","layer1","layer2")},g.defaultTextObject={name:"Text",...Xi.defaultData,...sQ.defaultData,geometry:rQ.defaultData("TextGeometry"),material:Ki.defaultTwoLayerData("phong","layer1","layer2")}))(Ky||(Ky={}));var cr;(g=>{function A(t,C){let o={name:C};return t.type==="Mesh"?(o.geometry={},"material"in t&&(o.material={layers:new Ci}),"materials"in t&&(o.materials=t.materials.map(B=>({layers:new Ci})))):Kr.is(t.type)&&(o.perspective={},o.orthographic={}),o}g.newEmpty=A;function I(t,C){if(C===void 0)return t;let o={...t};return"material"in o&&"material"in C&&C.material&&(o.material=Mn(o.material,B=>{if(typeof B!="string")for(let[a,s]of Object.entries(C.material.layers)){let r=B.layers.data(a);r&&Bt.patch(r,s)}}).data),o.materials&&C.materials&&(o.materials=Mn(o.materials,B=>{var a,s;for(let r=0;r0){let c={path:[...r,"layers",E,"texture"],props:h,type:0};B.push(c)}if(Object.keys(l).length>0){let c={path:[...r,"layers",E],props:l,type:0};B.push(c)}}}for(let[r,Q]of Object.entries(C))if(r!=="name")if(r==="cloner")B.push(...Dy.toOps(Q,["cloner"]));else if(r==="pathSnapping")B.push({path:[r],props:{slide:Q.slide,offset:Q.offset},type:0});else if(r==="material")s(["material"],Q);else if(r==="materials")for(let[E,n]of Object.entries(Q))s(["materials",E],n);else if(a[r]===0){if(r==="geometry"&&Q.extrusion!==void 0){let E={path:[r,"extrusion"],props:Q.extrusion,type:0};B.push(E),Q={...Q},delete Q.extrusion}if(Object.keys(Q).length>0){let E={path:[r],props:Q,type:0};B.push(E)}}else o===void 0&&(o={path:[],props:{},type:0},B.push(o)),o.props[r]=Q;return B}g.toOps=e;function i(t,C){var B,a,s,r,Q,E;if(C===void 0)return t;let o={...t};if(Object.assign(o,JQ.merge(o,C)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:((B=C.pathSnapping)==null?void 0:B.slide)??((a=o.pathSnapping)==null?void 0:a.slide)??0,offset:((s=C.pathSnapping)==null?void 0:s.offset)??((r=o.pathSnapping)==null?void 0:r.offset)??0})}),Kr.is(t.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let n=C;((Q=n.orthographic)==null?void 0:Q.zoom)!==void 0&&(o.orthographic.zoom=n.orthographic.zoom),((E=n.perspective)==null?void 0:E.zoom)!==void 0&&(o.perspective.zoom=n.perspective.zoom),n.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=n.isUpVectorFlipped),n.targetOffset!==void 0&&(o.targetOffset=n.targetOffset)}else if(t.type==="Mesh")"geometry"in C&&Object.assign(o,{geometry:fy.merge(o.geometry,C.geometry)}),(C.material||C.materials)&&(o=I(o,C)),o.cloner&&"cloner"in C&&Object.assign(o,{cloner:ra.merge(o.cloner,C.cloner)});else if(t.type==="Empty")o.cloner&&"cloner"in C&&Object.assign(o,{cloner:ra.merge(o.cloner,C.cloner)});else if(dy.is(t.type)){let n=C;n.intensity!==void 0&&(o.intensity=n.intensity),n.color!==void 0&&(typeof n.color=="string"?o.color=n.color:o.color=_i.clone(n.color))}return o}g.patch=i})(cr||(cr={}));var Pc;(g=>g.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})(Pc||(Pc={}));var kr;(g=>g.defaultData={orbitControls:Pc.defaultData,playPage:an,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((A,I)=>{let e=0,i=0;return I<5?i=-30:I<10&&(i=30),I===0||I===10||I===5?e=30:(I===4||I===11||I===9)&&(e=-30),[120,[e,i],"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})(kr||(kr={}));var Jy;(g=>g.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Jy||(Jy={}));var vy;(g=>g.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(vy||(vy={}));var QQ;(g=>(g.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Jy.defaultData},isRandomSeed:!0,seed:g.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:vy.defaultData}),g.generateSeed=()=>Math.round(Math.random()*1e5)))(QQ||(QQ={}));var Un;(g=>{function A(e){return e.find(i=>i.data.type==="Page"&&i.data.globalPhysics.usePhysics)!==void 0}g.physicsEnabled=A;function I(e,i,t){e.scene.objects.traverseFrom(i,(C,o)=>{var B;if(o.type==="Instance"){let a=(B=Vc.getComponentData(e,o.component))==null?void 0:B.data;a&&t(C,o,a.events)}else t(C,o,o.events)})}g.traverseModuleInstances=I})(Un||(Un={}));var EQ;(g=>{g.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function A(i={withLight:!0,withSquare:!0}){let t=[],C=Ky.defaultMeshObject;i.withLight===!0&&t.push({fi:-1,data:Ry.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),i.withSquare===!0&&t.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:C,children:[]});let o=new ht;return o.push({fi:1,id:an,data:{...vQ.defaultData,name:"Scene 1"},children:t}),o}g.defaultData={objects:A(),publish:kr.defaultData,styles:QQ.defaultData()},g.emptyDataWithoutPage=function(){return{objects:new ht,publish:kr.defaultData,styles:QQ.defaultData()}},g.emptyDataWithPage=function(i){return{objects:A(i),publish:kr.defaultData,styles:QQ.defaultData()}};function I(i){return{...g.defaultData,objects:SB(i,ht.prototype)}}g.withObjs=I;function e(i,t){return I([{id:i,data:t,children:[],fi:0}])}g.withObj=e})(EQ||(EQ={}));var rn;(g=>g.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(rn||(rn={}));var jc;(g=>g.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(jc||(jc={}));var Jt;(g=>{function A(C){return C.textValue!==void 0}g.isTextValue=A;function I(C){return typeof C=="number"}g.isNumber=I;function e(C){return typeof C=="boolean"}g.isBoolean=e;function i(C){return A(C)?"string":e(C)?"boolean":"number"}g.typeOfVariable=i;function t(C){return g.isTextValue(C)?Array.isArray(C.textValue)?C.textValue.map(o=>o.toString().padStart(C.padding??2,"0")).join(C.deliminator??":")+(C.suffix!==void 0?" "+C.suffix:""):C.textValue.toString():g.isBoolean(C)?C?"True":"False":g.isNumber(C)?parseFloat(C.toFixed(3)).toString():C.toString()}g.getDisplayedValue=t})(Jt||(Jt={}));var qy;(g=>g.all=["images","videos","colors","audios","fonts","materials","variables"])(qy||(qy={}));var Xk;(g=>g.all=[...qy.all,"components"])(Xk||(Xk={}));var $k;(g=>{function A(){return{images:new lI,videos:new lI,colors:new lI,audios:new lI,fonts:new lI,materials:new lI,components:new lI,variables:new lI}}g.defaultData=A})($k||($k={}));var qQ;(g=>{function A(){return{images:new lI,videos:new lI,colors:new lI,audios:new lI,fonts:new lI,materials:new lI,components:new lI,variables:new lI}}g.defaultData=A})(qQ||(qQ={}));var fC;(g=>{function A(){let C={};return C["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},SB(C,lI.prototype)}g.defaultColors=A;function I(C){let o={};return C!=null&&C.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...jc.emptyImage,name:"AI generated image"}),SB(o,lI.prototype)}g.defaultImages=I;function e(){return{catelogs:new lI,materials:new lI,images:new lI,videos:new lI,colors:new lI,audios:new lI,fonts:new lI,variables:new _g,lib:qQ.defaultData()}}g.emptyData=e;function i(C){switch(C){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 o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,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",C)}}g.defaultVariables=i;function t(C,o){if(o.format==="HH:mm:ss"){let B=Math.floor(C/3600),a=Math.floor((C-B*3600)/60),s=Math.round(C-B*3600-a*60);return{textValue:[B,a,s]}}else if(o.format==="mm:ss"){let B=Math.floor(C/60),a=Math.round(C-B*60);return{textValue:[B,a]}}else return o.format==="number"?C=Math.round(C):C=Math.round(C*1e3)/1e3,C}g.getFormattedTimerTime=t})(fC||(fC={}));var Wc;(g=>g.list=["idle","move","jump","run"])(Wc||(Wc={}));var Zc;(g=>(g.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},g.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","▲"],["rotPosY","◀"],["rotNegX","▼"],["rotNegY","▶"],["jump","Space"],["run","⇧"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:g.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 _g,move:new _g,jump:new _g,run:new _g},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:MC.fromHexAndA(3728051,1)}}))(Zc||(Zc={}));function AM(g){g.layers.forEach(A=>{if(A.type==="depth"&&A.colorA!==void 0){let I=A.colorA,e=A.colorB,i=[[I.r,I.g,I.b,I.a],[e.r,e.g,e.b,e.a]],t=[0,1];for(let o=2;o<10;o++)i.push(i[1]),t.push(1);let C={...dB(We(A),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,A.near),far:Math.max(0,A.far),colors:i,steps:t,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(A,C)}else if(A.type==="depth"&&A.gradientType===1&&(A.near<0||A.far<0)){let I={...We(A),near:Math.max(A.near,0),far:Math.max(A.far,0)};Object.assign(A,I)}})}function ea(g,A){Object.values(g.shared.materials).forEach(I=>A(I))}function ia(g,A){g.scene.objects.traverse((I,e)=>{"materials"in e?e.materials.forEach((i,t)=>{i===void 0&&(e.materials[t]=Ki.defaultData(),i=e.materials[t]),typeof i!="string"&&A(i)}):"material"in e?typeof e.material!="string"&&(e.material===void 0&&(e.material=Ki.defaultData()),A(e.material)):e.type==="Mesh"&&(e.material===void 0&&(e.material=Ki.defaultData()),A(e.material)),"overrides"in e&&Object.values(e.overrides).forEach(i=>{i.material&&typeof i.material!="string"&&A(i.material)})})}function zW(g){Object.assign(g.scene.publish,{orbitControls:{...Pc.defaultData,...We(g.scene.publish.orbitControls)}})}function XW(g){Object.assign(g.scene.publish.settings,{video:{...kr.defaultData.settings.video,...We(g.scene.publish.settings.video)}})}function $W(g){function A(I){if(I.layers){for(let e of Object.values(I.layers))if(e){for(let[i,t]of Object.entries(e))if((MR.includes(i)||typeof t=="boolean")&&delete e[i],i==="texture")for(let[C,o]of Object.entries(t))(VW.includes(C)||typeof o=="boolean")&&delete t[C]}}}g.scene.objects.traverse((I,e)=>{e.states.forEach(i=>{let t=i;t.material?A(t.material):t.materials&&t.materials.forEach(C=>{A(C)})})})}function A5(g){g.scene.publish.withBackground=!0}function g5(g){g.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function I5(g){g.scene.objects.traverse((A,I)=>{let e=I.cloner;e&&(e.radial.scale=e.radial.scale.map(i=>i+1),e.linear.scale=e.linear.scale.map(i=>i+1))})}function e5(g){g.scene.objects.traverse((A,I)=>{let e=I.geometry;e&&(e.type==="DodecahedronGeometry"||e.type==="IcosahedronGeometry")&&(e.detail=Math.round(e.detail))})}function i5(g){g.scene.objects.traverse((A,I)=>{let e=g.scene.objects.unproxy().parent(A);if(e){let i=We(g.scene.objects.data(e));i&&i.type==="Mesh"&&i.geometry.type==="BooleanGeometry"&&I.type==="Mesh"&&(I.visible=We(I).booleanExclude!==!0)}})}function t5(g){g.scene.objects.traverse((A,I)=>{if(I.type==="Mesh"){let e=I;I.geometry.type==="NonParametricGeometry"?e.material!==void 0&&delete e.material:e.materials!==void 0&&delete e.materials}})}function C5(g){function A(e){Object.setPrototypeOf(e,Ci.prototype),e.texture&&Object.setPrototypeOf(e.texture,Ci.prototype)}function I(e){Object.setPrototypeOf(e,Ci.prototype);for(let i in e)A(e[i])}g.scene.objects.traverse((e,i)=>{i.states.forEach(t=>{let C=t;if(C.material){let o=We(C.material).layers;I(o),C.material.layers=o}if(C.materials)for(let o=0;o{if(A.type==="depth"&&A.colors.length===10){let I=[...A.colors];I.push(A.colors[9]);let e=[...A.steps];e.push(A.steps[9]);let i={...We(A),colors:I,steps:e};Object.assign(A,i)}})}function o5(g){g.scene.objects.traverse((A,I)=>{I.type==="Mesh"&&(I.geometry.type==="BooleanGeometry"||I.geometry.type==="SubdivGeometry")&&(I.geometry.phongAngle=35)})}function IM(g){g.scene.objects.traverse((A,I)=>{"materials"in I?I.materials.forEach(e=>{typeof e!="string"&&yu(e)}):"material"in I&&typeof I.material!="string"&&yu(I.material)}),Object.values(g.shared.materials).forEach(A=>yu(A))}function B5(g){g.scene.environment.ambientLight.softShadows=!1,g.scene.environment.ambientLight.softShadowQuality="low",g.scene.objects.traverse((A,I)=>{(I.type==="DirectionalLight"||I.type==="SpotLight")&&(I.shadowResolution=1024,I.shadowRadius=1,I.depth=1e5)}),g.shared.penumbraSize=new Array(5).fill(.5)}function a5(g){g.shared.audios=SB({},lI.prototype)}function r5(g){g.shared.videos=SB({},lI.prototype)}function s5(g){let A=g.shared.materials;Object.entries(A).forEach(([I,e])=>{if(!e.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(A,{[I]:i})}})}function Q5(g){Object.entries(We(g.shared.images)).filter(A=>A[1].asset===!1).map(A=>A[0]).forEach(A=>{delete g.shared.images[A]}),Object.entries(We(g.shared.audios)).filter(A=>A[1].asset===!1).map(A=>A[0]).forEach(A=>{delete g.shared.audios[A]})}function E5(g){g.scene.publish.settings.web.preload=!1}function eM(g){g.layers&&g.layers.forEach(A=>{A.type==="depth"&&A.num!==void 0&&(A.colors=A.colors.slice(0,A.num),A.steps=A.steps.slice(0,A.num),delete A.num)})}function iM(g){g.layers&&g.layers.forEach(A=>{ZW(A)&&A.isMask===void 0&&(A.isMask=!1),(A.type==="texture"||A.type==="video")&&A.blending===void 0&&(A.blending=0),(A.type==="noise"||A.type==="displace"&&A.displacementType==="noise")&&(A.voronoiStyle===void 0&&(A.voronoiStyle=0),A.highCut===void 0&&(A.highCut=1),A.lowCut===void 0&&(A.lowCut=0),A.smoothness===void 0&&(A.smoothness=.3),A.seed===void 0&&(A.seed=0),A.quality===void 0&&(A.quality=1))})}function n5(g){g.shared.fonts=SB({},lI.prototype)}function h5(g){return g.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(A=>A.charAt(0).toUpperCase()+A.slice(1)).join(" ")}function l5(g){let A=[];g.scene.objects.traverse((I,e)=>{let i=e;if(i.type==="TextFrame"){let t=Ki.defaultTwoLayerData("phong"),C=typeof i.color=="string"?g.shared.colors[i.color]:i.color;t.layers[1].data.color={r:C.r,g:C.g,b:C.b},t.layers[1].data.alpha=i.alpha;let o=h5(i.font);g.shared.fonts[o]===void 0&&(g.shared.fonts[o]={name:o});let B={name:i.name,...Xi.defaultData,...sQ.defaultData,flatShading:!1,wireframe:!1,geometry:{...rQ.defaultData("TextGeometry"),width:i.width,height:i.height,font:o,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:t,states:We(i.states),events:We(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},a=We(g.scene.objects).parent(I);g.scene.objects.insertAfter(a??null,I,[{id:I+"new",data:B,children:[]}]),A.push(I)}}),A.forEach(I=>{g.scene.objects.delete(I)})}function c5(g){let A={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};g.scene.objects.traverse((I,e)=>{e.events.forEach(i=>{if(A[Number(i.type)])if(Object.assign(i,{type:A[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new _g,move:new _g,jump:new _g}});else{let t=new _g;Object.assign(i,{actions:t}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&t.push({fi:0,id:vg.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((C,o,B)=>{let a={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},s={easing:C.easing,duration:C.duration};C.easing===6?Object.assign(s,dB(C,"mass","stiffness","damping","velocity")):C.easing===5&&Object.assign(s,{control1:{...C.control1},control2:{...C.control2}});let r={repeat:C.repeat?-1:0,delay:C.delay,delayDirection:C.delayDirection,direction:C.cycle&&C.rewind?"pingpong-rewind":C.cycle?"pingpong":"normal"},Q={state:C.state,...r,...s},E={allowSlerp:!0,type:"Transition",object:C.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new _g({fi:0,id:vg.generateUUID(),data:a},{fi:1,id:vg.generateUUID(),data:Q})};t.push({fi:B,id:o,data:E})}),delete i.targets)}})})}function D5(g){g.scene.objects.traverse((A,I)=>{function e(i,t){var B;let C=new _g,o=[];if(I.events.forEach((a,s,r)=>{if(a.type==="Audio"&&a.trigger===t){let Q;o.push(s),a.interaction==="play"?Q={...dB(a,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in a?a.after:void 0,toggle:"after"in a?a.toggle:void 0,type:"Audio"}:(a.interaction==="pause"||a.interaction==="stop")&&(Q={...dB(a,"interaction","delay","object","playAudio"),type:"Audio"}),Q&&C.push({fi:r,id:s,data:Q})}}),o.forEach(a=>I.events.delete(a)),C.length){let a=(B=I.events.find(s=>s.type===i))==null?void 0:B.data;a?"actions"in a&&a.actions.insertBefore(null,C):I.events.insertBefore(null,[{id:vg.generateUUID(),data:{type:i,actions:C}}])}}e("Start","start"),e("MouseDown","mouseDown"),e("MouseUp","mouseUp"),e("KeyDown","keyDown"),e("KeyUp","keyUp")})}function tM(g){var I;let A=(I=g.layers.find(e=>e.type==="light"))==null?void 0:I.data;if((A==null?void 0:A.category)==="basic"){let e=Bt.defaultData("light","phong"),i=A;Object.assign(i,e),i.visible=!1}}function CM(g){ea(g,tM),ia(g,tM)}function d5(g){g.scene.objects.traverse((A,I)=>{I.type==="Mesh"&&I.geometry.type==="SubdivGeometry"&&(I.geometry.scaleBaked||(I.geometry.scaleBaked=[1,1,1]))})}function u5(g){g.scene.objects.traverse((A,I)=>{(I.type==="Empty"||I.type==="Mesh")&&I.cloner&&!I.cloner.randomnessObject&&!I.cloner.toObject&&!I.cloner.randomness&&(I.cloner={...I.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 p5(g){g.scene.objects.traverse((A,I)=>{I.type==="Mesh"&&I.geometry.type==="NonParametricGeometry"&&!("material"in I)&&!("materials"in I)&&(I.material=Ki.defaultTwoLayerData("phong"))})}function y5(g){g.scene.publish.orbitControls.autoZoom===void 0&&(g.scene.publish.orbitControls.autoZoom=!1),g.scene.objects.traverse((A,I)=>{(I.type==="OrthographicCamera"||I.type==="PerspectiveCamera")&&(I.orthographic.autoZoom===void 0&&(I.orthographic.autoZoom=!1),I.orthographic.autoZoomFrustumSize===void 0&&(I.orthographic.autoZoomFrustumSize=790))})}function w5(g){g.scene.objects.traverse((A,I)=>{I.pathSnapping===void 0&&(I.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),I.pathSnapping.offset===void 0&&(I.pathSnapping.offset=0)})}function S5(g){g.scene.publish.mouseEventTarget===void 0&&(g.scene.publish.mouseEventTarget="canvas"),g.scene.publish.settings.web.hint===void 0&&(g.scene.publish.settings.web.hint=!1)}function f5(g){let{video:A}=g.scene.publish.settings;A.format==="gif"&&A.fps>48&&(A.fps=15)}function G5(g){g.scene.objects.traverse((A,I)=>{I.events.forEach(e=>{e.type==="GameControl"&&(e.resetYPosition=Math.abs(e.resetYPosition-I.position[1]))})})}function k5(g){let A=g.scene.environment.usePhysics;g.scene.objects.traverse((I,e)=>{A&&e.physics===null?e.collision=!1:e.collision="visibility"})}function M5(g){g.scene.objects.traverse((A,I)=>{I.events.forEach(e=>{e.type==="GameControl"&&(e.navmesh=Zc.defaultDataThirdPerson.navmesh)})})}function m5(g){g.scene.styles||(g.scene.styles=QQ.defaultData())}function oM(g){g.layers.forEach(A=>{A.type==="light"&&A.category!=="toon"&&A.occlusion===void 0&&(A.occlusion=!0)})}function U5(g){g.scene.environment.ambientLight.occlusion===void 0&&(g.scene.environment.ambientLight.occlusion=!1),g.scene.environment.ambientLight.aoFullRes===void 0&&(g.scene.environment.ambientLight.aoFullRes=!1),g.scene.environment.ambientLight.radius===void 0&&(g.scene.environment.ambientLight.radius=256),g.scene.environment.ambientLight.bias===void 0&&(g.scene.environment.ambientLight.bias=.5),g.scene.environment.ambientLight.aoColor===void 0&&(g.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ia(g,oM),ea(g,oM)}function N5(g){g.scene.objects.traverse((A,I)=>{I.events.forEach(e=>{e.type==="GameControl"&&Object.assign(e.gameActions,{run:new _g})})})}function F5(g){g.scene.objects.traverse((A,I)=>{I.events.forEach(e=>{e.type==="GameControl"&&(e.keyAssignments=[...e.keyAssignments,["run","⇧"],["none","Ctrl"]])})})}function BM(g){g.layers&&g.layers.forEach(A=>{A.type==="light"&&A.bumpMapIntensity===void 0&&(A.bumpMapIntensity=5)})}function R5(g,A){if(A<1&&(ia(g,AM),ea(g,AM),g.schema=1),A<2&&(zW(g),g.schema=2),A<3&&($W(g),g.schema=3),A<4&&(A5(g),g.schema=4),A<5&&(g5(g),g.schema=5),A<6&&(I5(g),g.schema=6),A<7&&(e5(g),g.schema=7),A<8&&(g.schema=8),A<9&&(IM(g),g.schema=9),A<10&&(o5(g),g.schema=10),A<11&&(B5(g),g.schema=11),A<12&&(IM(g),g.schema=12),A<13&&(a5(g),g.schema=13),A<14&&(s5(g),g.schema=14),A<15&&(Q5(g),g.schema=15),A<16&&(E5(g),g.schema=16),A<17&&(ia(g,eM),ea(g,eM),g.schema=17),A<18&&(ia(g,gM),ea(g,gM),g.schema=18),A<19&&(XW(g),g.schema=19),A<20&&(n5(g),l5(g),g.schema=20),A<21&&(c5(g),D5(g),g.schema=21),A<22&&(CM(g),g.schema=22),A<23&&(d5(g),g.schema=23),A<24&&(u5(g),g.schema=24),(A<25||g.shared.videos===void 0)&&(r5(g),A<25&&(g.schema=25)),A<26&&(i5(g),g.schema=26),A<27&&(t5(g),g.schema=27),A<28&&(CM(g),g.schema=28),A<29&&(C5(g),g.schema=29),A<30&&(p5(g),g.schema=30),A<31&&(y5(g),g.schema=31),A<33&&(w5(g),g.schema=33),A<34&&(S5(g),g.schema=34),A<35&&(f5(g),g.schema=35),A<36&&(G5(g),g.schema=36),A<37&&(k5(g),g.schema=37),A<38&&(ia(g,iM),ea(g,iM),g.schema=38),A<39&&(M5(g),g.schema=39),A<40&&(m5(g),g.schema=40),A<41&&(U5(g),g.schema=41),A<42&&(N5(g),g.schema=42),A<43&&(F5(g),g.schema=43),A<99){ia(g,BM),ea(g,BM),g.scene.publish.playCamera===null&&(g.scene.publish.playCamera=tE);let I=We(g.scene.objects),e=g.scene.objects;g.scene.publish.playPage=an,e.insertBefore(null,null,[{id:an,data:{...vQ.defaultData,backgroundColor:g.scene.backgroundColor,fog:g.scene.fog,postprocessing:g.scene.postprocessing,ao:dB(g.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:g.scene.publish.playCamera,gameControlObject:g.scene.publish.gameControlObject},shadow:dB(g.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...KQ.defaultData,...dB(g.scene.environment,"usePhysics","gravity")},camera:We(g.scene.ownerCamera)??vQ.defaultData.camera,name:"Scene"},children:[]}]);for(let C of I)C.id!==EQ.TRASH_CAN_ID&&e.move(an,C.fi,C.id);let i=0,t=0;g.shared.penumbraSize&&g.scene.objects.traverse((C,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=g.shared.penumbraSize[Math.min(i,2)],i+=1):o.type==="SpotLight"&&(o.penumbraSize=g.shared.penumbraSize[3+Math.min(t,1)],t+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,RQ.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),g.schema=99}}function aM(g){g.layers&&g.layers.forEach(A=>{A.type==="light"&&A.alphaOverride===void 0&&(A.alphaOverride=1)})}function K5(g){g.scene.objects.traverse((A,I)=>{let e=I.geometry;e&&e.type==="PathGeometry"&&(e.extrusion.capType="flat",e.extrusion.bevel=50,e.extrusion.bevelSides=6,e.extrusion.shape.type==="Custom"&&(e.extrusion.shape.shapeQuality="low"))})}var Ws=180/Math.PI;function rM(g){g.rotation=g.rotation.slice(0,3).map(A=>A*Ws)}function FR(g){var I,e;rM(g),g.type==="Page"&&rM(g.camera),(I=g.states)==null||I.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(t=>t*Ws))});let A=g.geometry;A&&A.type==="SphereGeometry"&&(A.thetaLength=A.thetaLength*Ws),A&&A.type==="TorusGeometry"&&(A.arc=A.arc*Ws),A&&A.type==="PathGeometry"&&(A.extrusion.angle*=Ws,A.extrusion.twist*=Ws),g.type==="Mesh"&&g.geometry.type==="TextGeometry"&&(g.geometry.text={textValue:g.geometry.text}),Array.isArray(We(g.events))&&((e=g.events)==null||e.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Once")}))}function J5(g){g.shared.variables=SB({},lI.prototype)}function v5(g){let A=We(g.shared.variables);g.shared.variables=SB(Object.entries(A??{}).map(([I,e],i)=>({fi:i,id:I,data:e})),_g.prototype)}var ta=107;function RR(g,A){A(g.data);for(let I of g.children)RR(I,A)}function q5(g){let A=g.schema??104;A!==ta&&A<105&&(RR(g.asset,FR),g.schema=105)}function KR(g){let A=g.schema??0;if(A!==ta){console.warn("updating from ",A,"to ",ta),R5(g,A),A<100&&(g.scene.publish.joystickSizeAndXYOffset===void 0&&(g.scene.publish.joystickSizeAndXYOffset=kr.defaultData.joystickSizeAndXYOffset),g.schema=100),A<101&&(ia(g,aM),ea(g,aM),g.schema=101),A<102&&(K5(g),g.schema=102),A<104&&(g.shared.catelogs=new lI,g.shared.lib=qQ.defaultData(),g.schema=104),A<105&&(J5(g),g.scene.objects.traverse((I,e)=>{FR(e)}),g.schema=105);for(let I of Object.values(g.shared.lib.components))q5(I);A<106&&(v5(g),g.schema=106),A<107&&(g.shared.lib.variables=qQ.defaultData().variables,g.schema=107)}}var Vc;(g=>{g.defaultData={schema:ta,scene:EQ.defaultData,frames:new lI().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",rn.defaultData),shared:{...fC.emptyData(),colors:fC.defaultColors()}},g.emptyDataForImports=function(i){let t=EQ.emptyDataWithPage(i);return{schema:ta,scene:t,frames:new lI().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",rn.defaultData),shared:{...fC.emptyData(),colors:fC.defaultColors(),images:fC.defaultImages(i)}}},g.emptyData=function(){return{schema:ta,scene:EQ.emptyDataWithPage(),frames:new lI().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",rn.defaultData),shared:fC.emptyData()}},g.collabHelper={...Cy,updateSchema(i){return(i.schema??0)I&&(I=i,A=e)}return A}function EM(g,A){A.set(g)}function nM(g,A,I){let e,i;for(let t=0;t<3;t++){let C=t+3;e=g[t],i=A[t],I[t]=ei?e:i}}function Bl(g,A,I){for(let e=0;e<3;e++){let i=A[g+2*e],t=A[g+2*e+1],C=i-t,o=i+t;CI[e+3]&&(I[e+3]=o)}}function mE(g){let A=g[3]-g[0],I=g[4]-g[1],e=g[5]-g[2];return 2*(A*I+I*e+e*A)}function b5(g,A){if(!g.index){let I=g.attributes.position.count,e=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;I>65535?i=new Uint32Array(new e(4*I)):i=new Uint16Array(new e(2*I)),g.setIndex(new zg(i,1));for(let t=0;ti-t);for(let i=0;iB&&(B=M),c&&yn&&(n=y);let G=g[d+2],v=g[d+3],N=G-v,b=G+v;Na&&(a=b),c&&Gh&&(h=G);let O=g[d+4],H=g[d+5],_=O-H,gA=O+H;_s&&(s=gA),c&&Ol&&(l=O)}e[0]=t,e[1]=C,e[2]=o,e[3]=B,e[4]=a,e[5]=s,c&&(i[0]=r,i[1]=Q,i[2]=E,i[3]=n,i[4]=h,i[5]=l)}function x5(g,A,I,e){let i=1/0,t=1/0,C=1/0,o=-1/0,B=-1/0,a=-1/0;for(let s=A*6,r=(A+I)*6;so&&(o=Q);let E=g[s+2];EB&&(B=E);let n=g[s+4];na&&(a=n)}e[0]=i,e[1]=t,e[2]=C,e[3]=o,e[4]=B,e[5]=a}function H5(g,A,I,e,i){let t=I,C=I+e-1,o=i.pos,B=i.axis*2;for(;;){for(;t<=C&&A[t*6+B]=o;)C--;if(tg.candidate-A.candidate,OB=new Array(CB).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),al=new Float32Array(6);function O5(g,A,I,e,i,t){let C=-1,o=0;if(t===0)C=QM(A),C!==-1&&(o=(A[C]+A[C+3])/2);else if(t===1)C=QM(g),C!==-1&&(o=_5(I,e,i,C));else if(t===2){let B=mE(g),a=1.25*i,s=e*6,r=(e+i)*6;for(let Q=0;Q<3;Q++){let E=A[Q],n=(A[Q+3]-E)/CB;if(i=f.candidate?Bl(d,I,f.rightCacheBounds):(Bl(d,I,f.leftCacheBounds),f.count++)}}for(let d=0;d=CB&&(d=CB-1);let u=OB[d];u.count++,Bl(c,I,u.bounds)}let h=OB[CB-1];EM(h.bounds,h.rightCacheBounds);for(let c=CB-2;c>=0;c--){let d=OB[c],u=OB[c+1];nM(d.bounds,u.rightCacheBounds,d.rightCacheBounds)}let l=0;for(let c=0;ck&&(k=u),y>k&&(k=y);let M=(k-f)/2,G=c*2;t[E+G+0]=f+M,t[E+G+1]=M+(Math.abs(f)+M)*L5,fA[c+3]&&(A[c+3]=k)}}return t}function j5(g,A){function I(c){Q&&Q(c/E)}function e(c,d,u,y=null,f=0){if(!n&&f>=B&&(n=!0,a&&(console.warn(`MeshBVH: Max depth of ${B} reached when generating BVH. Consider increasing maxDepth.`),console.warn(g))),u<=s||f>=B)return I(d+u),c.offset=d,c.count=u,c;let k=O5(c.boundingData,y,C,d,u,r);if(k.axis===-1)return I(d+u),c.offset=d,c.count=u,c;let M=H5(o,C,d,u,k);if(M===d||M===d+u)I(d+u),c.offset=d,c.count=u;else{c.splitAxis=k.axis;let G=new ol,v=d,N=M-d;c.left=G,G.boundingData=new Float32Array(6),wu(C,v,N,G.boundingData,t),e(G,v,N,t,f+1);let b=new ol,O=M,H=u-N;c.right=b,b.boundingData=new Float32Array(6),wu(C,O,H,b.boundingData,t),e(b,O,H,t,f+1)}return c}b5(g,A);let i=new Float32Array(6),t=new Float32Array(6),C=P5(g,i),o=g.index.array,B=A.maxDepth,a=A.verbose,s=A.maxLeafTris,r=A.strategy,Q=A.onProgress,E=g.index.count/3,n=!1,h=[],l=Y5(g);if(l.length===1){let c=l[0],d=new ol;d.boundingData=i,x5(C,c.offset,c.count,t),e(d,c.offset,c.count,t),h.push(d)}else for(let c of l){let d=new ol;d.boundingData=new Float32Array(6),wu(C,c.offset,c.count,d.boundingData,t),e(d,c.offset,c.count,t),h.push(d)}return h}function W5(g,A){let I=j5(g,A),e,i,t,C=[],o=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let s=0;sMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[Q+6]=u/4,u=a(u,c),i[Q+7]=d,u}}}var fB=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(A,I){let e=1/0,i=-1/0;for(let t=0,C=A.length;ti?o:i}this.min=e,this.max=i}setFromPoints(A,I){let e=1/0,i=-1/0;for(let t=0,C=I.length;ti?B:i}this.min=e,this.max=i}isSeparated(A){return this.min>A.max||A.min>this.max}};fB.prototype.setFromBox=function(){let g=new J;return function(A,I){let e=I.min,i=I.max,t=1/0,C=-1/0;for(let o=0;o<=1;o++)for(let B=0;B<=1;B++)for(let a=0;a<=1;a++){g.x=e.x*o+i.x*(1-o),g.y=e.y*B+i.y*(1-B),g.z=e.z*a+i.z*(1-a);let s=A.dot(g);t=Math.min(s,t),C=Math.max(s,C)}this.min=t,this.max=C}}();var Z5=function(){let g=new J,A=new J,I=new J;return function(e,i,t){let C=e.start,o=g,B=i.start,a=A;I.subVectors(C,B),g.subVectors(e.end,e.start),A.subVectors(i.end,i.start);let s=I.dot(a),r=a.dot(o),Q=a.dot(a),E=I.dot(o),n=o.dot(o)*Q-r*r,h,l;n!==0?h=(s*r-E*Q)/n:h=0,l=(s+h*r)/Q,t.x=h,t.y=l}}(),M0=function(){let g=new sA,A=new J,I=new J;return function(e,i,t,C){Z5(e,i,g);let o=g.x,B=g.y;if(o>=0&&o<=1&&B>=0&&B<=1){e.at(o,t),i.at(B,C);return}else if(o>=0&&o<=1){B<0?i.at(0,C):i.at(1,C),e.closestPointToPoint(C,!0,t);return}else if(B>=0&&B<=1){o<0?e.at(0,t):e.at(1,t),i.closestPointToPoint(t,!0,C);return}else{let a;o<0?a=e.start:a=e.end;let s;B<0?s=i.start:s=i.end;let r=A,Q=I;if(e.closestPointToPoint(s,!0,A),i.closestPointToPoint(a,!0,I),r.distanceToSquared(s)<=Q.distanceToSquared(a)){t.copy(r),C.copy(s);return}else{t.copy(a),C.copy(Q);return}}}}(),V5=function(){let g=new J,A=new J,I=new Nt,e=new eC;return function(i,t){let{radius:C,center:o}=i,{a:B,b:a,c:s}=t;if(e.start=B,e.end=a,e.closestPointToPoint(o,!0,g).distanceTo(o)<=C||(e.start=B,e.end=s,e.closestPointToPoint(o,!0,g).distanceTo(o)<=C)||(e.start=a,e.end=s,e.closestPointToPoint(o,!0,g).distanceTo(o)<=C))return!0;let r=t.getPlane(I);if(Math.abs(r.distanceToPoint(o))<=C){let Q=r.projectPoint(o,A);if(t.containsPoint(Q))return!0}return!1}}(),z5=1e-15;function ks(g){return Math.abs(g)new J),this.satBounds=new Array(4).fill().map(()=>new fB),this.points=[this.a,this.b,this.c],this.sphere=new ct,this.plane=new Nt,this.needsUpdate=!0}intersectsSphere(A){return V5(A,this)}update(){let A=this.a,I=this.b,e=this.c,i=this.points,t=this.satAxes,C=this.satBounds,o=t[0],B=C[0];this.getNormal(o),B.setFromPoints(o,i);let a=t[1],s=C[1];a.subVectors(A,I),s.setFromPoints(a,i);let r=t[2],Q=C[2];r.subVectors(I,e),Q.setFromPoints(r,i);let E=t[3],n=C[3];E.subVectors(e,A),n.setFromPoints(E,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,A),this.needsUpdate=!1}};GB.prototype.closestPointToSegment=function(){let g=new J,A=new J,I=new eC;return function(e,i=null,t=null){let{start:C,end:o}=e,B=this.points,a,s=1/0;for(let r=0;r<3;r++){let Q=(r+1)%3;I.start.copy(B[r]),I.end.copy(B[Q]),M0(I,e,g,A),a=g.distanceToSquared(A),a1-1e-10){let c=this.satBounds,d=this.satAxes;I[0]=Q.a,I[1]=Q.b,I[2]=Q.c;for(let f=0;f<4;f++){let k=c[f],M=d[f];if(e.setFromPoints(M,I),k.isSeparated(e))return!1}let u=Q.satBounds,y=Q.satAxes;A[0]=this.a,A[1]=this.b,A[2]=this.c;for(let f=0;f<4;f++){let k=u[f],M=y[f];if(e.setFromPoints(M,A),k.isSeparated(e))return!1}for(let f=0;f<4;f++){let k=d[f];for(let M=0;M<4;M++){let G=y[M];if(t.crossVectors(k,G),e.setFromPoints(t,A),i.setFromPoints(t,I),e.isSeparated(i))return!1}}return E&&(n||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),E.start.set(0,0,0),E.end.set(0,0,0)),!0}else{let c=this.points,d=!1,u=0;for(let H=0;H<3;H++){let _=c[H],gA=c[(H+1)%3];a.start.copy(_),a.end.copy(gA),a.delta(C);let CA=d?s.start:s.end,AA=ks(l.distanceToPoint(_));if(ks(l.normal.dot(C))&&AA){s.copy(a),u=2;break}if((l.intersectLine(a,CA)||AA)&&!ks(CA.distanceTo(gA))){if(u++,d)break;d=!0}}if(u===1&&Q.containsPoint(s.end))return E&&(E.start.copy(s.end),E.end.copy(s.end)),!0;if(u!==2)return!1;let y=Q.points,f=!1,k=0;for(let H=0;H<3;H++){let _=y[H],gA=y[(H+1)%3];a.start.copy(_),a.end.copy(gA),a.delta(o);let CA=f?r.start:r.end,AA=ks(h.distanceToPoint(_));if(ks(h.normal.dot(o))&&AA){r.copy(a),k=2;break}if((h.intersectLine(a,CA)||AA)&&!ks(CA.distanceTo(gA))){if(k++,f)break;f=!0}}if(k===1&&this.containsPoint(r.end))return E&&(E.start.copy(r.end),E.end.copy(r.end)),!0;if(k!==2)return!1;if(s.delta(C),r.delta(o),C.dot(o)<0){let H=r.start;r.start=r.end,r.end=H}let M=s.start.dot(C),G=s.end.dot(C),v=r.start.dot(C),N=r.end.dot(C),b=G0?E.start.copy(s.start):E.start.copy(r.start),B.subVectors(s.end,r.end),B.dot(C)<0?E.end.copy(s.end):E.end.copy(r.end)),!0)}}}();GB.prototype.distanceToPoint=function(){let g=new J;return function(A){return this.closestPointToPoint(A,g),A.distanceTo(g)}}();GB.prototype.distanceToTriangle=function(){let g=new J,A=new J,I=["a","b","c"],e=new eC,i=new eC;return function(t,C=null,o=null){let B=C||o?e:null;if(this.intersectsTriangle(t,B))return(C||o)&&(C&&B.getCenter(C),o&&B.getCenter(o)),0;let a=1/0;for(let s=0;s<3;s++){let r,Q=I[s],E=t[Q];this.closestPointToPoint(E,g),r=E.distanceToSquared(g),rnew J),this.satAxes=new Array(3).fill().map(()=>new J),this.satBounds=new Array(3).fill().map(()=>new fB),this.alignedSatBounds=new Array(3).fill().map(()=>new fB),this.needsUpdate=!1,A&&this.min.copy(A),I&&this.max.copy(I),e&&this.matrix.copy(e)}set(A,I,e){this.min.copy(A),this.max.copy(I),this.matrix.copy(e),this.needsUpdate=!0}copy(A){this.min.copy(A.min),this.max.copy(A.max),this.matrix.copy(A.matrix),this.needsUpdate=!0}};Mo.prototype.update=function(){return function(){let g=this.matrix,A=this.min,I=this.max,e=this.points;for(let B=0;B<=1;B++)for(let a=0;a<=1;a++)for(let s=0;s<=1;s++){let r=1*B|2*a|4*s,Q=e[r];Q.x=B?I.x:A.x,Q.y=a?I.y:A.y,Q.z=s?I.z:A.z,Q.applyMatrix4(g)}let i=this.satBounds,t=this.satAxes,C=e[0];for(let B=0;B<3;B++){let a=t[B],s=i[B],r=1<new eC),I=new Array(12).fill().map(()=>new eC),e=new J,i=new J;return function(t,C=0,o=null,B=null){if(this.needsUpdate&&this.update(),this.intersectsBox(t))return(o||B)&&(t.getCenter(i),this.closestPointToPoint(i,e),t.closestPointToPoint(e,i),o&&o.copy(e),B&&B.copy(i)),0;let a=C*C,s=t.min,r=t.max,Q=this.points,E=1/0;for(let h=0;h<8;h++){let l=Q[h];i.copy(l).clamp(s,r);let c=l.distanceToSquared(i);if(c0&&a.normal.multiplyScalar(-1));let s={a:t,b:C,c:o,normal:new J,materialIndex:0};Ni.getNormal(Ms,ms,Us,s.normal),a.face=s,a.faceIndex=t}return a}function JR(g,A,I,e,i){let t=e*3,C=g.index.getX(t),o=g.index.getX(t+1),B=g.index.getX(t+2),{position:a,normal:s,uv:r,uv1:Q}=g.attributes,E=$5(I,a,s,r,Q,C,o,B,A);return E?(E.faceIndex=e,i&&i.push(E),E):null}function AZ(g,A,I,e,i,t){for(let C=e,o=e+i;C=0,r,Q;s?(r=Fn(g),Q=Rn(g,o)):(r=Rn(g,o),Q=Fn(g));let E=Xc(r,t,e,zc)?by(r,A,I,e):null;if(E){let h=E.point[a];if(s?h<=t[Q+B]:h>=t[Q+B+3])return E}let n=Xc(Q,t,e,zc)?by(Q,A,I,e):null;return E&&n?E.distance<=n.distance?E:n:E||n||null}}var iZ=function(){let g,A,I=[],e=new vR(()=>new ve);return function(...t){g=e.getPrimitive(),A=e.getPrimitive(),I.push(g,A);let C=i(...t);e.releasePrimitive(g),e.releasePrimitive(A),I.pop(),I.pop();let o=I.length;return o>0&&(A=I[o-1],g=I[o-2]),C};function i(t,C,o,B,a=null,s=0,r=0){function Q(d){let u=d*2,y=ua,f=pa;for(;!Ca(u,y);)d=Fn(d),u=d*2;return nQ(d,f)}function E(d){let u=d*2,y=ua,f=pa;for(;!Ca(u,y);)d=Rn(d,f),u=d*2;return nQ(d,f)+Nn(u,y)}let n=t*2,h=CE,l=ua,c=pa;if(Ca(n,l)){let d=nQ(t,c),u=Nn(n,l);return co(t,h,g),B(d,u,!1,r,s+t,g)}else{let d=Fn(t),u=Rn(t,c),y=d,f=u,k,M,G,v;if(a&&(G=g,v=A,co(y,h,G),co(f,h,v),k=a(G),M=a(v),Mi.intersectsBox(k),intersectsTriangle:k=>{k.a.applyMatrix4(a),k.b.applyMatrix4(a),k.c.applyMatrix4(a),k.needsUpdate=!0;for(let M=y*3,G=(f+y)*3;Mnew GB),sn=class{static serialize(A,I={}){if(I.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),sn.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});I={cloneBuffers:!0,...I};let e=A.geometry,i=A._roots,t=e.getIndex(),C;return I.cloneBuffers?C={roots:i.map(o=>o.slice()),index:t.array.slice()}:C={roots:i,index:t.array},C}static deserialize(A,I,e={}){if(typeof e=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),sn.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});e={setIndex:!0,...e};let{index:i,roots:t}=A,C=new sn(I,{...e,[Su]:!0});if(C._roots=t,e.setIndex){let o=I.getIndex();if(o===null){let B=new zg(A.index,1,!1);I.setIndex(B)}else o.array!==i&&(o.array.set(i),o.needsUpdate=!0)}return C}constructor(A,I={}){if(A.isBufferGeometry){if(A.index&&A.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(I=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Su]:!1},I),I.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,I[Su]||(this._roots=W5(A,I),!A.boundingBox&&I.setBoundingBox&&(A.boundingBox=this.getBoundingBox(new ve))),this.geometry=A}refit(A=null){A&&Array.isArray(A)&&(A=new Set(A));let I=this.geometry,e=I.index.array,i=I.attributes.position,t,C,o,B,a=0,s=this._roots;for(let Q=0,E=s.length;Qf&&(f=b),Ok&&(k=O),HM&&(M=H)}return B[Q+0]!==d||B[Q+1]!==u||B[Q+2]!==y||B[Q+3]!==f||B[Q+4]!==k||B[Q+5]!==M?(B[Q+0]=d,B[Q+1]=u,B[Q+2]=y,B[Q+3]=f,B[Q+4]=k,B[Q+5]=M,!0):!1}else{let l=Q+8,c=C[Q+6],d=l+E,u=c+E,y=n,f=!1,k=!1;A?y||(f=A.has(d),k=A.has(u),y=!f&&!k):(f=!0,k=!0);let M=y||f,G=y||k,v=!1;M&&(v=r(l,E,y));let N=!1;G&&(N=r(c,E,y));let b=v||N;if(b)for(let O=0;O<3;O++){let H=l+O,_=c+O,gA=B[H],CA=B[H+3],AA=B[_],BA=B[_+3];B[Q+O]=gABA?CA:BA}return b}}}traverse(A,I=0){let e=this._roots[I],i=new Uint32Array(e),t=new Uint16Array(e);C(0);function C(o,B=0){let a=o*2,s=t[a+15]===65535;if(s){let r=i[o+6],Q=t[a+14];A(B,s,new Float32Array(e,o*4,6),r,Q)}else{let r=o+8,Q=i[o+6],E=i[o+7];A(B,s,new Float32Array(e,o*4,6),E)||(C(r,B+1),C(Q,B+1))}}}raycast(A,I=RC){let e=this._roots,i=this.geometry,t=[],C=I.isMaterial,o=Array.isArray(I),B=i.groups,a=C?I.side:I;for(let s=0,r=e.length;s{let c=n*3;return Q(E,c,c+1,c+2,h,l)}}A={boundsTraverseOrder:e,intersectsBounds:A,intersectsTriangle:I,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 t=XC.getPrimitive(),{boundsTraverseOrder:C,intersectsBounds:o,intersectsRange:B,intersectsTriangle:a}=A;if(B&&a){let Q=B;B=(E,n,h,l,c)=>Q(E,n,h,l,c)?!0:DM(E,n,i,a,h,l,t)}else B||(a?B=(Q,E,n,h)=>DM(Q,E,i,a,n,h,t):B=(Q,E,n)=>n);let s=!1,r=0;for(let Q of this._roots){if(zE(Q),s=iZ(0,i,o,B,C,r),nl(),s)break;r+=Q.byteLength}return XC.releasePrimitive(t),s}bvhcast(A,I,e){let{intersectsRanges:i,intersectsTriangles:t}=e,C=this.geometry.index,o=this.geometry.attributes.position,B=A.geometry.index,a=A.geometry.attributes.position;Ns.copy(I).invert();let s=XC.getPrimitive(),r=XC.getPrimitive();if(t){let E=function(n,h,l,c,d,u,y,f){for(let k=l,M=l+c;kGu.intersectsBox(E),intersectsRange:(E,n,h,l,c,d)=>(fu.copy(d),fu.applyMatrix4(Ns),A.shapecast({intersectsBounds:u=>fu.intersectsBox(u),intersectsRange:(u,y,f,k,M)=>i(E,n,u,y,l,c,k,M)}))});return XC.releasePrimitive(s),XC.releasePrimitive(r),Q}intersectsBox(A,I){return Ar.set(A.min,A.max,I),Ar.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Ar.intersectsBox(e),intersectsTriangle:e=>Ar.intersectsTriangle(e)})}intersectsSphere(A){return this.shapecast({intersectsBounds:I=>A.intersectsBox(I),intersectsTriangle:I=>I.intersectsSphere(A)})}closestPointToGeometry(A,I,e={},i={},t=0,C=1/0){A.boundingBox||A.computeBoundingBox(),Ar.set(A.boundingBox.min,A.boundingBox.max,I),Ar.needsUpdate=!0;let o=this.geometry,B=o.attributes.position,a=o.index,s=A.attributes.position,r=A.index,Q=XC.getPrimitive(),E=XC.getPrimitive(),n=hl,h=CZ,l=null,c=null;i&&(l=oZ,c=BZ);let d=1/0,u=null,y=null;return Ns.copy(I).invert(),UE.matrix.copy(Ns),this.shapecast({boundsTraverseOrder:f=>Ar.distanceToBox(f),intersectsBounds:(f,k,M)=>M{if(A.boundsTree)return A.boundsTree.shapecast({boundsTraverseOrder:M=>UE.distanceToBox(M),intersectsBounds:(M,G,v)=>v{for(let v=M*3,N=(M+G)*3;v(NE.copy(A).clamp(s.min,s.max),NE.distanceToSquared(A)),intersectsBounds:(s,r,Q)=>Q{s.closestPointToPoint(A,NE);let Q=A.distanceToSquared(NE);return Q{co(0,new Float32Array(I),dM),A.union(dM)}),A}},FE=Fa(pq()),aZ=.5*(Math.sqrt(3)-1),RE=(3-Math.sqrt(3))/6,rZ=1/3,$C=1/6,Qn=g=>Math.floor(g)|0,uM=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]),ku=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 Mu(g=Math.random){let A=qR(g),I=new Float64Array(A).map(i=>uM[i%12*2]),e=new Float64Array(A).map(i=>uM[i%12*2+1]);return function(i,t){let C=0,o=0,B=0,a=(i+t)*aZ,s=Qn(i+a),r=Qn(t+a),Q=(s+r)*RE,E=s-Q,n=r-Q,h=i-E,l=t-n,c,d;h>l?(c=1,d=0):(c=0,d=1);let u=h-c+RE,y=l-d+RE,f=h-1+2*RE,k=l-1+2*RE,M=s&255,G=r&255,v=.5-h*h-l*l;if(v>=0){let O=M+A[G],H=I[O],_=e[O];v*=v,C=v*v*(H*h+_*l)}let N=.5-u*u-y*y;if(N>=0){let O=M+c+A[G+d],H=I[O],_=e[O];N*=N,o=N*N*(H*u+_*y)}let b=.5-f*f-k*k;if(b>=0){let O=M+1+A[G+1],H=I[O],_=e[O];b*=b,B=b*b*(H*f+_*k)}return 70*(C+o+B)}}function sZ(g=Math.random){let A=qR(g),I=new Float64Array(A).map(t=>ku[t%12*3]),e=new Float64Array(A).map(t=>ku[t%12*3+1]),i=new Float64Array(A).map(t=>ku[t%12*3+2]);return function(t,C,o){let B,a,s,r,Q=(t+C+o)*rZ,E=Qn(t+Q),n=Qn(C+Q),h=Qn(o+Q),l=(E+n+h)*$C,c=E-l,d=n-l,u=h-l,y=t-c,f=C-d,k=o-u,M,G,v,N,b,O;y>=f?f>=k?(M=1,G=0,v=0,N=1,b=1,O=0):y>=k?(M=1,G=0,v=0,N=1,b=0,O=1):(M=0,G=0,v=1,N=1,b=0,O=1):fg){i=t;break}else g1&&(e=1-e,i=1-i),cC.a.fromBufferAttribute(this.positionAttribute,g*3),cC.b.fromBufferAttribute(this.positionAttribute,g*3+1),cC.c.fromBufferAttribute(this.positionAttribute,g*3+2),A.set(0,0,0).addScaledVector(cC.a,e).addScaledVector(cC.b,i).addScaledVector(cC.c,1-(e+i)),cC.getNormal(I),this}},EZ=Fa(pN()),nZ=new zA,hZ=new zA,lZ=new zA,Kn;(g=>{function A(I){return I&&I.__isSPEObject}g.is=A})(Kn||(Kn={}));var m0=g=>class extends g{constructor(){super(...arguments),this.previousModelViewMatrix=new zA,this.copyPreviousMatrix=!0,this.hiddenMatrix=new zA,this.matrixWorldRigid=new zA,this.shearScale=new zA,this.shearScaleInv=new zA}get __isSPEObject(){return!0}isDescendantOf(A){A instanceof ZI&&(A=A.uuid);let I=this;for(;I.parent;){if(I.parent.uuid===A)return!0;I=I.parent}return!1}updateMatrixWorld(A){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||A)&&(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,A=!0);for(let I of this.children)I.updateMatrixWorld(A)}updateWorldMatrix(A,I){let e=this.parent;if(A&&e!==null&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),I)for(let i of this.children)i.updateWorldMatrix(!1,!0)}traverseChildren(A,I=0){for(let e of this.children)Kn.is(e)&&e.traverseObject(A,I+1)}traverseObject(A,I=0){if(A(this,I)!==!0)for(let e of this.children)Kn.is(e)&&e.traverseObject(A,I+1)}updateMatrixWorldSVD(){let A=this.matrixWorld.elements,I=[[A[0],A[4],A[8]],[A[1],A[5],A[9]],[A[2],A[6],A[10]]],{u:e,v:i,q:t}=(0,EZ.SVD)(I),C=nZ.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),o=hZ.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),B=lZ.copy(o).transpose();this.shearScale.makeScale(t[0],t[1],t[2]).multiply(B).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(C,B).copyPosition(this.matrixWorld),t.every(a=>Math.abs(t[0]-a)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(A,I){this.updateWorldMatrix(!0,!1);let e=new zA().copy(this.matrixWorld).invert();return A.parent!==null&&(A.parent.updateWorldMatrix(!0,!1),e.multiply(A.parent.matrixWorld)),"hiddenMatrix"in A&&A.hiddenMatrix instanceof zA?A.hiddenMatrix.premultiply(e):A.applyMatrix4(e),A.updateWorldMatrix(!1,!1),this.add(A),I!==void 0&&(this.children.pop(),this.children.splice(I,0,A)),this}copy(A,I=!1){return super.copy(A,I),this.hasNonUniformScale=A.hasNonUniformScale,this}onAfterRender(A,I,e,i,t,C){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},cZ=class extends m0(ZI){},DZ=g=>g.type==="Mesh",Ri=class extends cZ{constructor(A){super(),this.object=A,this.matrixAutoUpdate=!1,this.hasNonUniformScale=A.hasNonUniformScale}raycast(A,I){}expand(){let A=0,I=this.object.entityChildren(A);for(;I;){let e=this.children[A];(e==null?void 0:e.object)!==I&&(e&&this.remove(e),e=new Ri(I),this.add(e),this.children.splice(A,0,this.children.pop()),e.matrixWorldNeedsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix=I.matrix,e.hiddenMatrix=I.hiddenMatrix),e.expand(),A+=1,I=this.object.entityChildren(A)}for(;this.children.length>A;)this.remove(this.children[A])}get visible(){var A;return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&((A=this.object.dataPatched.cloner)==null?void 0:A.hideBase)===!0}set visible(A){}get castShadow(){return this.object.castShadow}set castShadow(A){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(A){}get isMesh(){return DZ(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(A){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},sr=new J,Qr=new J,hQ=new zA,LR=[new J(-1,1,1),new J(-1,-1,1),new J(1,-1,1),new J(1,1,1),new J(-1,1,-1),new J(-1,-1,-1),new J(1,-1,-1),new J(1,1,-1)],dZ=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],uZ=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],pM=(g,A,I)=>{g.updateEntityBoxSize(sr,Qr),hQ.copy(A).multiply(g.matrixWorld),Qr.x===0&&Qr.y===0&&Qr.z===0?I.push(new J(sr.x,sr.y,sr.z).applyMatrix4(hQ)):LR.forEach(e=>{I.push(e.clone().multiply(Qr).add(sr).applyMatrix4(hQ))})},yM=class extends ve{constructor(){super(...arguments),this.matrix=new zA,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(g){return super.copy(g),this.matrix.copy(g.matrix),this.vertices=g.vertices.map(A=>A.clone()),this.faces=g.faces.map(A=>A.clone()),this.edges=g.edges.map(A=>A.clone()),this.centerEdges=g.centerEdges.map(A=>A.clone()),this}setFromObjectSize(g,A=!1){g.updateWorldMatrix(!1,A),this.makeEmpty(),this.matrix.copy(g.matrixWorld);let I=new zA().copy(g.matrixWorld).invert();return this.expandByObjectSize(g,I,A)}expandByObjectSize(g,A,I=!1){let e=[];return I===!0?g.traverseEntity(i=>{if(i.visible||i.cloner&&i.data.visible){if(!("geometry"in i)){e.push(new J);return}pM(i,A,e)}}):pM(g,A,e),this.setFromPoints(e)}getCenter(g){return g=super.getCenter(g),g.applyMatrix4(this.matrix),g}getPositionToCenter(g){return g=super.getCenter(g),g.applyMatrix4(hQ.copy(this.matrix).setPosition(0,0,0)),g}computeVertices(){this.getSize(Qr).multiplyScalar(.5),this.getCenter(sr),hQ.copy(this.matrix).setPosition(sr),this.vertices=LR.map(g=>g.clone().multiply(Qr).applyMatrix4(hQ))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=dZ.map(([g,A])=>new eC(this.vertices[g],this.vertices[A])),this.centerEdges=this.edges.map(g=>g.getCenter(new J))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=uZ.map(([g,A])=>this.vertices[g].clone().add(this.vertices[A]).multiplyScalar(.5))}},Qa={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},pZ=class extends ZN{constructor(){super()}getPoints(g=12){let A=[],I,e=this.getCurveLengths(),i=e[e.length-1]/e.length;for(let t=0,C=this.curves;t1&&!A[A.length-1].equals(A[0])&&A.push(A[0]),A}},xy=.001;function Hy(g,A,I){return A.clone().sub(g).cross(A.clone().sub(I)).length()<=xy}function mu(g,A){let I=new J(...g.position),e=new J(...g.controlNext.position),i=new J(...A.controlPrevious.position),t=new J(...A.position);return Hy(I,e,t)&&Hy(I,i,t)}function bR(g){let A=g.points.map(s=>new J(...s.data.position)),I=[g.points[0]],e=new J(...I[0].data.position);for(let s=0;sxy&&(h=new Vl(E.position,E.controlNext,n.controlPrevious,n.position));else{let l=E.position.clone(),c=n.position.clone();(E.removedLength!==0||n.removedLength!==0)&&(E.nextDir&&l.add(E.nextDir.clone().setLength(E.removedLength)),n.prevDir&&c.add(n.prevDir.clone().setLength(n.removedLength))),l.distanceTo(c)>xy&&(h=new Vl(l,l.clone().lerp(c,.3),c.clone().lerp(l,.3),c))}B[2*s+1]=h}for(let s=0;s{s&&a.add(s)}),a}var MI;(g=>{function A(I){return I&&I.__isEntity}g.is=A})(MI||(MI={}));var QB=g=>MI.is(g),yZ={type:"completeState",isfromEntity:!0},wZ=["x","y","z"],Uu=new J,SZ=new J().set(0,1,0),U0=g=>class extends m0(g){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 yM,this._recursiveBBox=new yM,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(A){let I=this.children[A];if(MI.is(I))return I}entityChildrenCount(){let A=this.children.length;for(;A--;)if(MI.is(this.children[A]))return A+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 A=this;for(;A.data.type!=="Instance";){let I=A.parent;if(MI.is(I))A=I;else return}return A}forInstancesRec(A){this.instances.forEach(I=>{I.disposed||A(I),I.forInstancesRec(A)})}super_Entity(A,I){typeof A=="string"&&(this.uuid=A),this.identity=A,this.data=I,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(A,I,e=!1){if(!(this.data.states.length===0&&!e)){for(let i of this.data.states)cr.toOps(this.data,i.data).forEach(t=>{let C=ty.replaceProps(t,this.data);this.dataPatched=this.data,this.updateByPatchedOp(C,this.data,I)});if(A!==null){let i=this.data.states.data(A);i&&(this.dataPatched=cr.patch(this.data,i),cr.toOps(this.data,i).forEach(t=>{this.updateByPatchedOp(t,this.dataPatched,I)}))}e&&this.updateTransformState(this.dataPatched,I),this.stateSelection=A,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(A,I){A.setScalar(0),I.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(A=>{QB(A)&&A.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(A=>{A.resetBBoxNeedsUpdateSelf()})}find(A){let I;return this.traverseEntity(e=>{e.uuid===A&&(I=e)}),I}traverseSortNextHelper(){let A=this.parent;if(A){let I=A.children,e=I.indexOf(this)+1;if(MI.is(I[e]))return I[e];if(MI.is(A))return A.traverseSortNextHelper()}}sortNext(){let A=this.children;return this.children.length>0&&MI.is(this.children[0])?A[0]:this.traverseSortNextHelper()}goUp(A){let I=this;for(;A>0&&I!==null;)I=I.parent,A-=1;return I}hasAnccestorOrSelf(A){return this===A||this.hasAnccestor(A)}hasAnccestor(A){let I=this.parent;for(;I;){if(A===I)return!0;I=I.parent}return!1}countToAccestor(A){let I=0,e=this;for(;e!==A;){if(e===null)return-1;e=e.parent,I+=1}return I}forEachEntity(A){for(let I of this.children)QB(I)&&A(I)}traverseEntityAncestors(A){this.traverseAncestors(I=>{MI.is(I)&&A(I)})}traverseConcreteEntity(A,I=0){if(A(this,I)!==!0)for(let e of this.children)QB(e)&&e.isConcreteEntity&&e.traverseEntity(A,I+1)}traverseEntity(A,I=0){if(A(this,I)!==!0)for(let e of this.children)QB(e)&&e.traverseEntity(A,I+1)}traverseVisibleEntity(A){A(this);for(let I of this.children)QB(I)&&I.visible&&I.traverseVisibleEntity(A)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(A){super.updateMatrixWorld(A),this.dispatchEvent({type:"updateMatrixWorld"})}copy(A,I=!1){return super.copy(A,I),this.dataPatched=A.dataPatched,this.raycastLock=A.raycastLock,this.scaleLock=A.scaleLock,this.hiddenMatrix.copy(A.hiddenMatrix),this}hasEntityChild(){return this.children.some(A=>QB(A))}isAncestorOf(A){if(this.uuid===A)return!1;let I=!1;return this.traverseEntity(e=>{e.uuid===A&&(I=!0)}),I}toObjectTransformState(A=[]){this.updateWorldMatrix(!0,!1);let I={position:this.position.toArray(),rotation:[this.rotation.x*vg.RAD2DEG,this.rotation.y*vg.RAD2DEG,this.rotation.z*vg.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return iy(I,A)}getTransformValues(A,I,e){return I[A].map((i,t)=>(e==null?void 0:e.shared.getVariable(i,[this.uuid,A,wZ[t]]))??i)}updateTransformState(A,I){let e=!1;return A.position&&(this.position.fromArray(this.getTransformValues("position",A,I)),e=!0),A.rotation&&(Uu.fromArray(this.getTransformValues("rotation",A,I)).multiplyScalar(vg.DEG2RAD),this.rotation.setFromVector3(Uu),e=!0),A.scale&&(this.scale.fromArray(this.getTransformValues("scale",A,I)),e=!0),A.hiddenMatrix!==void 0&&(e=!0,this.hiddenMatrix.fromArray(A.hiddenMatrix??NQ.identity)),e&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),A.position&&A.rotation&&A.scale&&A.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),e}onVariableUpdate(A=!1){if(A){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(I=>{I.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let A of this.children)MI.is(A)&&A.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(A=>{MI.is(A)&&A.disposeRecursively()})}toState(A=[]){let I={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(A)};return iy(I,A)}updateByObjUpdateOp(A,I){A!==void 0&&this.updateByOp({type:0,props:A,path:[]},{...this.data,...A},I,!1)}updateByOp(A,I,e,i){let t=this.data;this.data=I;let C=A,o=AC(A.path,["states","*"]);if(o!==null){if(A.type===0){let[B]=o;if((this==null?void 0:this.stateSelection)===B){let a={...A.props};if(delete a.name,Object.values(A.props).some(s=>s===void 0)){let s=this.data;if(s!==void 0){let r=ji.zoom(s,A.path.slice(2));if(r)for(let Q in A.props)A.props[Q]===void 0&&Q in r&&(a[Q]=r[Q])}}C={...A,props:a,path:A.path.slice(2)}}}}else if(A.type===0){let B=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(B!==void 0){if(A.props.name!==void 0&&B.name){let{name:s,...r}=B;B=r}if(A.props.material!==void 0&&"material"in B){let{material:s,...r}=B;B=r}let a=ji.removeOverridden(A.path,A.props,B);C={...A,props:a}}}if(this.updateByPatchedOpBase(C,cr.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),e),AC(A.path,["overrides"])){let B=[],a=[...A.path];for(B.push(a[1]),a.splice(0,2);a.length>0&&a[0]==="descendants";)B.push(a[1]),a.splice(0,2);if(B[B.length-1]===void 0){if(A.type===0)for(let s of Object.keys(A.props)){B[B.length-1]=s;let r=e.scene.findInstance([this.uuid,...B]);r&&(r.overrideData=A.props[s],r.updateState(Da.apply(r.component.data,r.overrideData),e))}}else{let s=e.scene.findInstance([this.uuid,...B]);if(s){let r=ji.zoom(s.component.data,a);if(A={...A,path:a},A.type===0){let Q=A.props;if(r)for(let[E,n]of Object.entries(A.props))n===void 0&&(Q===A.props&&(Q={...A.props}),Q[E]=r[E]);A={...A,props:Q}}s.overrideData=_c.resolve(I.overrides,B),s.updateByOp(A,Fi.applySimple(s.data,A),e,!1)}}}else if(this.instances.length>0){let B;if(A.path.length===0&&A.type===0){let a;for(let s of sa.rootOverrideProps)s in A.props&&(a===void 0&&(a={}),a[s]=A.props[s]);a&&(B={...A,props:a})}else for(let a of sa.rootOverrideProps)if(AC(A.path,[a])){B=A;break}B!==void 0&&this.instances.forEach(a=>{if(a.isInstanceRoot){let s=Da.filterOp(a.overrideData,B);s&&a.updateByOp(s,Fi.applySimple(a.data,s),e,!0)}}),this.instances.forEach(a=>{if(!a.isInstanceRoot){let s=Da.filterOp(a.overrideData,A);if(s){let r;t===a.data&&A===s?r=I:r=Fi.applySimple(a.data,s),a.updateByOp(s,r,e,!0)}}})}}updateByPatchedOpBase(A,I,e){if(this.dataPatched=I,A.path.length===0&&A.type===0)A.props.type!==void 0&&!Kr.is(A.props.type)&&Qa.changeEntityProptotype(this,I,e);else if(A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&"type"in A.props){Qa.changeEntityProptotype(this,I,e);for(let i of this.children)MI.is(i)&&i.updateVisible()}this.updateByPatchedOp(A,I,e)}updateByPatchedOp(A,I,e){if(A.path.length===0&&A.type===0&&this.updateState(A.props,e),AC(A.path,["pathSnapping"])!==null&&this.updatePathSnapping(I.pathSnapping),AC(A.path,["cloner"])!==null){let i=Fi.drop(A,1);i.path.length===0&&i.type===0&&i.props.disabled===!0?this.setFromClonerState(null,e):this.cloner?this.cloner.updateState(I.cloner,e.scene):(this.setFromClonerState(I.cloner,e),this.expandCloner(e.scene)),this.updateVisible()}}updatePathSnapping(A){this._updatedPathSnapping=A,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(A){var n,h,l,c,d;let I=((n=this._updatedPathSnapping)==null?void 0:n.pathId)??this.dataPatched.pathSnapping.pathId,e=((h=this._updatedPathSnapping)==null?void 0:h.slide)??this.dataPatched.pathSnapping.slide??0,i=((l=this._updatedPathSnapping)==null?void 0:l.offset)??this.dataPatched.pathSnapping.offset,t=((c=this._updatedPathSnapping)==null?void 0:c.orientation)??this.dataPatched.pathSnapping.orientation;if(I===null)return;let C=A.find(I);if(!C||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=C.data;if(o.geometry.path.points.length<=1)return;let B=bR(o.geometry.path),a=(e+i)%1;e+i===1&&a===0&&(a=1);let s=B.getPointAt(a),r=this.parent?(d=this.parent)==null?void 0:d.matrixWorld:new zA;C.updateMatrixWorld();let Q=new zA().multiplyMatrices(r.clone().invert(),C.matrixWorld);s.applyMatrix4(Q);let E={position:s.toArray(),rotation:o.rotation};if(t==="tangential"){let u=new zA().extractRotation(C.matrixWorld),y=B.getTangentAt(a).applyMatrix4(u).add(s),f=new zA().lookAt(s,y,SZ),k=Uu.setFromEuler(new Ei().setFromRotationMatrix(f)).multiplyScalar(vg.RAD2DEG);E={...E,rotation:k.toArray()}}this.updateTransformState(E),this.traverseEntity(u=>{u._cameraType&&u.dispatchEvent(yZ)})}updateVisible(){var A;this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||((A=this.dataPatched.cloner)==null?void 0:A.hideBase)!==!0)}updateState_Entity(A,I){A.name!==void 0&&(this.name=A.name),A.raycastLock!==void 0&&(this.raycastLock=A.raycastLock),A.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),I&&"cloner"in A&&A.cloner!==void 0&&(this.setFromClonerState(A.cloner,I),this.updateVisible()),this.updateTransformState(A,I)}get attachedSurfaceCloners(){return this.children.filter(A=>A instanceof Qa.Cloner&&A.parameters.type==="toObject")}setFromClonerState(A,I){this.disposed||(A===null||A.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Qa.Cloner(this,A),I.scene.addPendingExpandCloner(this)):this.cloner.updateState(A,I.scene))}expandCloner(A){!this.disposed&&this.cloner&&this.cloner.expandClones(A)}invalidateClonerTransform(A){this.cloner&&this.cloner.invalidateTransform(A)}},YR=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},g.parameters);I.thetaLength=vg.clamp(I.thetaLength,0,360);let e=I.width/2,i=I.radiusTop??e,t=I.radiusBottom??e;return i===t?(i=e,t=e):i>t?(i=e,t=t*e/i):(i=i*e/t,t=e),{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width),radiusTop:i,radiusBottom:t})}}static build(g){let{width:A,depth:I,height:e,radialSegments:i,heightSegments:t,openEnded:C,thetaStart:o,thetaLength:B,radiusTop:a,radiusBottom:s,cornerRadius:r,cornerSegments:Q,hollow:E}=g.parameters,n;return B===0?(n=new bg,n.setAttribute("position",new pg([],3))):r||E?n=new xR(a,s,e,i,t,C,o,B*Math.PI/180,r,r,Q,E):n=new jw(a,s,e,i,t,C,o,B*Math.PI/180),n.scale(1,1,I/A),Object.assign(n,{userData:{...g,type:"CylinderGeometry"}})}};function _B(g,A,I){I.x=g.x*A.x,I.y=g.y,I.z=g.x*A.y}function wM(g){return new sA(g.y,-g.x)}var xR=class extends bg{constructor(g,A,I,e,i,t,C,o,B,a,s,r,Q=!1){super(),this.type="RoundedCylinderBufferGeometry",g=g!==void 0?g:1,A=A!==void 0?A:1,I=I||1,e=Math.floor(e)||8,i=Math.floor(i)||1,t=t!==void 0?t:!1,C=C!==void 0?C:0,o=o!==void 0?o:Math.PI*2,t&&(B=0,a=0);let E=[],n=[],h=[],l=[],c=0,d=I/2,u=new J,y=new J;Q&&g==0&&(g=B),Q&&A==0&&(A=a);let f=new sA(g,d),k=new sA(A,-d),M=null,G=null,v=null,N=null,b=f.clone().sub(k),O=0,H=0,_=0;r>0&&(O=Math.min(g,A)*(1-r),H=g-O,_=A-O);let gA=f.clone();gA.x-=O;let CA=Math.PI-b.angle(),AA=b.angle(),BA=Math.tan(AA/2),iA=Math.tan(CA/2),rA=BA+iA,$=r?rA:iA,IA=r?rA:BA;if(B=Math.min(B,(g-H)/$,b.length()/rA),a=Math.min(a,(A-_)/IA,b.length()/rA),B>0){let nA=B/BA;M=f.clone().sub(new sA(nA,B)),r&&(v=M.clone(),v.x-=O-rA*B),f.sub(b.clone().setLength(nA))}if(a>0){let nA=a/iA;G=k.clone().sub(new sA(nA,-a)),k.add(b.clone().setLength(nA)),r&&(N=G.clone(),N.x-=O-rA*a,gA.sub(b.clone().setLength(nA)))}b=f.clone().sub(k);let hA=b.length()<.5,QA=[];for(let nA=0;nA<=e;nA++){let fA=[],uA=nA/e,VA=uA*o+C,yA=new sA(Math.sin(VA),Math.cos(VA));N&&G?(DA(fA,uA,yA,CA,a,N,-1,!0),DA(fA,uA,yA,AA,a,G,-1,!1)):G?(eA(fA,yA,G.x,0,-1),DA(fA,uA,yA,AA,a,G,-1,!1)):t||eA(fA,yA,A,_,-1);let LA=wM(b).normalize();if(_B(LA,yA,u),!hA)for(let HA=0;HA<=i;HA++){let Ag=HA/i,gg=b.clone().multiplyScalar(Ag).add(k);_B(gg,yA,y),n.push(y.x,y.y,y.z),h.push(u.x,u.y,u.z),l.push(uA,.5+y.y/I),fA.push(c++)}if(v&&M?(DA(fA,uA,yA,CA,B,M,1,!1),DA(fA,uA,yA,AA,B,v,1,!0)):M?(DA(fA,uA,yA,CA,B,M,1,!1),eA(fA,yA,M.x,0,1)):t||eA(fA,yA,g,H,1),r&&!hA){let HA=wM(b).multiplyScalar(-1).normalize();_B(HA,yA,u);for(let Ag=0;Ag<=i;Ag++){let gg=Ag/i,Dg=b.clone().multiplyScalar(-gg).add(gA);_B(Dg,yA,y),n.push(y.x,y.y,y.z),h.push(u.x,u.y,u.z),l.push(uA,.5+y.y/I),fA.push(c++)}}r&&!t&&fA.push(fA[0]),QA.push(fA)}for(let nA=0;nAE.push(Dg,Eg,$A):(Dg,Eg,$A)=>E.push(Dg,$A,Eg),Ag=new sA((g+A+H+_)/4,0);_B(Ag,VA,LA),n.push(LA.x,LA.y,LA.z),h.push(yA.x,0,yA.y),l.push(.5,.5);let gg=c++;for(let Dg of fA){let Eg=n.slice(Dg*3,Dg*3+3);n.push(...Eg),h.push(yA.x,0,yA.y);let $A=l.slice(Dg*2,Dg*2+2);l.push(...$A),c++}for(let Dg=gg+1;Dg0||s>0||B<360?Q=new xR(0,A/2,e,i,t,C,o,B*Math.PI/180,a,s,r,0,!0):Q=new zN(A/2,e,i,t,C),Q.scale(1,1,I/A),Object.assign(Q,{userData:{...g,type:"ConeGeometry"}})}},GZ=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},g.parameters);return{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width)})}}static build(g){let{width:A,height:I,depth:e,widthSegments:i,heightSegments:t,depthSegments:C,cornerRadius:o,cornerSegments:B}=g.parameters,a;return o==0?a=new Go(A,I,e,i,t,C):a=new kZ(A,I,e,i,t,C,o,B),Object.assign(a,{userData:{...g,type:"CubeGeometry"}})}},Nu=Math.PI/2,kZ=class extends bg{constructor(g=1,A=1,I=1,e=1,i=1,t=1,C=0,o=4){super(),this.type="BoxGeometry";let B=this;e=Math.floor(e),i=Math.floor(i),t=Math.floor(t),o=Math.floor(o),C=Math.min(C,g/2,A/2,I/2);let a=[],s=[],r=[],Q=[],E=0,n=0;h("z","y","x",-1,-1,I,A,g,t,i,0),h("z","y","x",1,-1,I,A,-g,t,i,1),h("x","z","y",1,1,g,I,A,e,t,2),h("x","z","y",1,-1,g,I,-A,e,t,3),h("x","y","z",1,-1,g,A,I,e,i,4),h("x","y","z",-1,-1,g,A,-I,e,i,5),C>0&&(l("z","y","x",-1,-1,1,I,A,g,t,0),l("z","y","x",1,-1,-1,I,A,g,t,1),l("z","y","x",-1,1,-1,I,A,g,t,1),l("z","y","x",1,1,1,I,A,g,t,0),l("x","y","z",-1,-1,-1,g,A,I,e,0),l("x","y","z",1,-1,1,g,A,I,e,1),l("x","y","z",-1,1,1,g,A,I,e,0),l("x","y","z",1,1,-1,g,A,I,e,1),l("y","x","z",-1,-1,1,A,g,I,i,0),l("y","x","z",1,-1,-1,A,g,I,i,1),l("y","x","z",1,1,1,A,g,I,i,1),l("y","x","z",-1,1,-1,A,g,I,i,0),c(1,1,1),c(-1,1,1),c(1,-1,1),c(-1,-1,1),c(1,1,-1),c(-1,1,-1),c(1,-1,-1),c(-1,-1,-1)),this.setIndex(a),this.setAttribute("position",new pg(s,3)),this.setAttribute("normal",new pg(r,3)),this.setAttribute("uv",new pg(Q,2));function h(d,u,y,f,k,M,G,v,N,b,O){let H=(M-2*C)/N,_=(G-2*C)/b,gA=M/2-C,CA=G/2-C,AA=v/2,BA=N+1,iA=b+1,rA=0,$=0,IA=new J;for(let hA=0;hA0?1:-1,r.push(IA.x,IA.y,IA.z),Q.push(DA/N),Q.push(1-hA/b),rA+=1}}for(let hA=0;hA0?(N,b,O)=>a.push(N,b,O):(N,b,O)=>a.push(N,O,b);for(let N=0;N<=o;N++){let b=[],O=Nu*(1-N/o),H=Math.cos(O),_=Math.sin(O),gA=0;for(let CA=0;CA<=N;CA++){let AA=Math.cos(gA),BA=Math.sin(gA);f.x=H*AA,f.y=_,f.z=H*BA;let iA=k.clone().addScaledVector(f,C);s.push(d*iA.x,u*iA.y,y*iA.z),r.push(d*f.x,u*f.y,y*f.z),Q.push(0,0),b.push(E++),gA+=Nu/N}M.push(b)}let v=M.length-1;for(let N=0;Nu.subVectors(iA,rA).normalize(),f=(iA,rA)=>Array(iA).fill(void 0).map(rA),k=f(A.length/3,(iA,rA)=>new J().fromArray(A,rA*3).setLength(i)),M=[],G=1e6;for(let iA=0;iAyA[0]==hA)}M.push(aA)}let v=[];{let iA=0,rA=0,$,IA,hA=Q==3;for(let QA=0;QA<=C;QA++){$=QA*(QA+1)/2,IA=(QA+1)*(QA+2)/2;for(let DA=0;DAf(Q,()=>E.clone()));for(let iA=0;iAaA.add(nA),QA).multiplyScalar(1/Q);for(let aA=0;aAuA[yA]);o.push(...VA.map(yA=>[yA.x,yA.y,yA.z]).flat()),a.push(...VA.map(yA=>(y(yA,N),[u.x,u.y,u.z])).flat())}}let AA=[];for(let iA=0;iADA%G==iA),hA=gA[iA][rA],QA=gA[$][IA];for(let DA=0;DA{o.push(uA[0].x,uA[0].y,uA[0].z),a.push(uA[1].x,uA[1].y,uA[1].z)})}AA.push(hA[0][0],QA[d][0],hA[d][0],QA[0][0])}}for(;AA.length;){let iA,rA,$,IA;[iA,rA]=AA.splice(0,2);let hA=[iA];for(;iA!=rA;)hA.push(rA),$=AA.indexOf(rA),IA=$%2,rA=AA.splice($-IA,2)[1-IA];u.subVectors(hA[0],hA[1]).cross(E.subVectors(hA[0],hA[2])).normalize();let QA=u.dot(hA[0])<0;QA&&u.negate();for(let DA=1;DA<=hA.length-2;DA++)[hA[DA+ +QA],hA[DA+1-+QA],hA[0]].forEach(eA=>{o.push(eA.x,eA.y,eA.z),a.push(u.x,u.y,u.z)})}}function r(){let Q=new J;for(let M=0;M{N<0&&M.x===1&&(B[G]=M.x-1),v.x===0&&v.z===0&&(B[G]=N/2/Math.PI+.5)};for(let M=0,G=0;M.9&&O<.1&&(G<.2&&(B[M+0]+=1),v<.2&&(B[M+2]+=1),N<.2&&(B[M+4]+=1))}function f(M){return Math.atan2(M.z,-M.x)}function k(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(A){return new N0(A.vertices,A.indices,A.radius,A.corner,A.cornerSides)}},MZ=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,detail:0,corner:0,cornerSides:4},g.parameters);return{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width)})}}static build(g){let{width:A,height:I,depth:e,detail:i,corner:t,cornerSides:C}=g.parameters,o=i===0&&t!==0?new HR(A*.5,t,C):new XN(A*.5,i);return o.scale(1,I/A,e/A),Object.assign(o,{userData:{...g,type:"DodecahedronGeometry"}})}},HR=class extends N0{constructor(g=1,A=.2,I=4){let e=(1+Math.sqrt(5))/2,i=1/e,t=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-e,0,-i,e,0,i,-e,0,i,e,-i,-e,0,-i,e,0,i,-e,0,i,e,0,-e,0,-i,e,0,-i,-e,0,i,e,0,i],C=[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],o="DodecahedronGeometry";super(t,C,o,g,A,I),this.type=o}static fromJSON(g){return new HR(g.radius,g.corner,g.cornerSides)}},KE=1e-12,F0=class{constructor(g){this.position=new sA,this.startPosition=new sA,this.uuid=vg.generateUUID(),this.position=g.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(g){this.position.copy(this.startPosition).add(g)}copy(g){return this.position.copy(g.position),this.startPosition.copy(g.startPosition),this}clone(){return new F0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ty=class extends F0{constructor(g){super(g.position),this.parent=g}copy(g){return super.copy(g),this}clone(){return new Ty(this.parent).copy(this)}},lQ=class extends F0{constructor(A,I){super(I),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=A,this.controls.push(new Ty(this),new Ty(this))}static create(A,I){let e=new lQ(A,new sA(...I.position));return e.controls[0].position.set(...I.controlPrevious.position),e.controls[1].position.set(...I.controlNext.position),e.roundness=I.roundness,e.areControlsDirectionsMirrored=I.areControlsDirectionsMirrored,e}getOppositeControl(A){let I=this.controls.indexOf(A);return I===0?this.controls[1]:I===1?this.controls[0]:null}applyOffsetToControls(A,I=1){for(let e=0,i=this.controls.length;eg,oE=new sA,VD=new sA,mZ=new sA,UZ=new sA,NZ=new sA,FZ=new sA,TR=new J,OR=new J;function RZ(g){let A=new sA;A.addVectors(g.v0,oE.subVectors(g.v1,g.v0).multiplyScalar(2/3));let I=new sA;return I.addVectors(g.v2,VD.subVectors(g.v1,g.v2).multiplyScalar(2/3)),new kC(g.v0,A,I,g.v2)}function XE(g,A,I=Number.EPSILON){return Math.abs(g-A)Math.PI&&(s*=-1),XE(a,o)?r=(o+a)*(e/s-.5)*8/3/(C-B):r=(C+B)*(e/s-.5)*8/3/(a-o),i.set(A.x-r*o,A.y+r*C),t.set(I.x+r*a,I.y-r*B),[i,t]}function fM(g,A){return g.position.equals(g.controls[1].position)&&A.position.equals(A.controls[0].position)}function GM(g,A){return Oy(g.position,g.controls[1].position,A.position)&&Oy(g.position,A.controls[0].position,A.position)}function YZ(g,A,I,e,i=.5){let t=oE.subVectors(A,g).multiplyScalar(i).add(g),C=VD.subVectors(I,A).multiplyScalar(i).add(A),o=mZ.subVectors(e,I).multiplyScalar(i).add(I),B=t,a=UZ.subVectors(C,t).multiplyScalar(i).add(t),s=NZ.subVectors(o,C).multiplyScalar(i).add(C),r=o,Q=FZ.subVectors(s,a).multiplyScalar(i).add(a);return[g.x,g.y,B.x,B.y,a.x,a.y,Q.x,Q.y,s.x,s.y,r.x,r.y,e.x,e.y]}function xZ(g,A,I=12,e=!0){let i=OR.set(0,0,0),t,C=0;for(let o=0;o1&&!(g.getX(C-1)===g.getX(0)&&g.getY(C-1)===g.getY(0)&&g.getZ(C-1)===g.getZ(0))&&(g.setXYZ(C,g.getX(0),g.getY(0),g.getZ(0)),C++),g}function HZ(g,A,I,e=12,i=!0){let t=OR.set(0,0,0),C=0,o=[];for(let B=0;B1&&!(g.getX(C-1)===g.getX(0)&&g.getY(C-1)===g.getY(0)&&g.getZ(C-1)===g.getZ(0))&&(g.setXYZ(C,g.getX(0),g.getY(0),g.getZ(0)),C++),o}function kM(g,A=12,I=!1){let e=[];for(let i=0,t=g.length;i0&&(e[i-1]+=B),o+=B}C.curveAfter!==void 0&&(o+=Mr(C.curveAfter,A)),e.push(o)}return g.length>0&&I&&g[0].roundedCurveCorner!==void 0&&(e[g.length-1]+=Mr(g[0].roundedCurveCorner,A)*.5),e}function Mr(g,A=12){return g&&g instanceof KD?A*2:g&&(g instanceof FC||g instanceof WN)?1:g&&g instanceof Pw?A*g.points.length:A}function TZ(g,A,I=12,e=!0){let i,t=0;for(let C=0;C1&&!(XE(g[t-1],g[1],KE)&&XE(g[t-2],g[0],KE))&&(g.push(g[0],g[1]),t++),g}var Fu=new sA,OZ=new sA,_Z=new sA,PZ=new sA,jZ=new sA,WZ=new sA,fe=class extends yc{constructor(A=100,I=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Nt(new J(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=vg.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=A,this._height=I}static createFromState(A,I,e){let i=new fe;return i.isClosed=A.isClosed,i.points=A.points.map(t=>lQ.create(t.id,t.data)),typeof A.roundness=="number"&&(i.roundness=A.roundness),i.shapeHoles=A.shapeHoles.map(t=>fe.createFromState(t)),I!==void 0&&e!==void 0&&i.applySize(I,e),i.update(),i}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(A){if(this._roundness!==A){this._roundness=A;for(let I=0,e=this.points.length;Ithis.getPointIndexById(I)).filter(I=>I>=0)}getPointIndexById(A){let I=this.points.length,e=this.points.findIndex(i=>i.uuid===A);if(e<0){let i=I;for(let t=0,C=this.shapeHoles.length;t0){let I=this.points.length;for(let e=0,i=this.shapeHoles.length;e=0)return I;if(I=this.points.length,this.shapeHoles.length>0)for(let e=0,i=this.shapeHoles.length;e=0)return I+C;I+=t.points.length}return-1}getAllPoints(){let A=[].concat(...this.shapeHoles.map(I=>I.points));return[...this.points,...A]}applySize(A,I){A===0&&(A=.001),I===0&&(I=.001),this._width=A,this._height=I}applyScale(A,I){let e=Fu.set(A,I);for(let i=0,t=this.points.length;i=0&&this.points.splice(I,1),this.needsUpdate=!0}removePointById(A){let I=this.points.find(e=>e.uuid===A);I&&this.removePoint(I)}update(){for(let A=0,I=this.shapeHoles.length;At+C,0)+1}computeCurveDivisions(A=12){return this.curveDivisions=kM(this.points,A,!1),this.roundedCurveDivisions=kM(this.points,A,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(A,I,e=12){return HZ(A,this.curves,I,e,this.autoClose).reduce((i,t)=>i+t,0)*2}extractShapePointsToFlatArray(A,I=12){return this.subdivision=I,this.curveDivisions===void 0&&this.computeCurveDivisions(I),TZ(A,this.roundedCurves,I,this.autoClose)}getCurveIndexFromVertexId(A,I=!1){let e=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=I?this.roundedCurveDivisions:this.curveDivisions,t=0;I&&this.points[0].roundedCurveCorner!==void 0&&(t=Mr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let C=A-t;C<0&&(C+=i.reduce((o,B)=>o+B,0));for(let o=0,B=i.length;o=this.points.length-1?0:A+1],C=this.curveDivisions,o=C[A];if(fM(i,t)){let a=i.position.distanceTo(t.position);return i.position.distanceTo(Fu.set(e.x,e.y))/a}let B=0;for(let a=0;a2){let I=0;for(let e=0,i=this.points.length;e0&&!a){let s=t.curveBefore,r=t.curveAfter;if(s===void 0||r===void 0)continue;let Q=t.roundedCurveBefore,E=t.roundedCurveAfter,n=s.getLength(),h=r.getLength(),l=Math.min(B,n*.499),c=Math.min(B,h*.499),d=Math.min(l,c),u=1-d/n,y=d/h,f=s.getPointAt(u,Fu),k=r.getPointAt(y,OZ);this._subSplitCurve(s,Q,u,f,void 0),this._subSplitCurve(r,E,y,void 0,k);let M;if(this.useCubicForRoundedCorners){let G=_R(f,t.position,k)/2,v=Math.tan(G)*f.distanceTo(t.position),[N,b]=qZ(f,k,v,_Z,PZ),O=LZ(N,b,t.position),[H,_]=bZ(O,f,k,v,jZ,WZ);M=new kC(f.clone(),H.clone(),_.clone(),k.clone())}else M=new fa(f.clone(),t.position.clone(),k.clone());t.roundedCurveCorner=M,this.roundedCurves.splice(e+I,0,M),I++}}}}_subSplitCurve(A,I,e,i,t){if(A instanceof FC)i!==void 0&&I.v2.copy(i),t!==void 0&&I.v1.copy(t);else{let C=A,o=I,B=C.getUtoTmapping(e,0),a=YZ(C.v0,C.v1,C.v2,C.v3,B);return i!==void 0&&(o.v0.set(a[0],a[1]),o.v1.set(a[2],a[3]),o.v2.set(a[4],a[5]),o.v3.set(a[6],a[7])),t!==void 0&&(o.v0.set(a[6],a[7]),o.v1.set(a[8],a[9]),o.v2.set(a[10],a[11]),o.v3.set(a[12],a[13])),o}return I}clone(){let A=new fe(this._width,this._height);return A.points=this.points.map(I=>I.clone()),A.isClosed=this.isClosed,A.roundness=this.roundness,A.isMesh2D=this.isMesh2D,A.shapeHoles=this.shapeHoles.map(I=>I.clone()),A}toJSON(){return{points:this.points.reduce((A,I)=>A.concat(I.toJSON()),[]),shapeHoles:this.shapeHoles.map(A=>A.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(A){var e;this.points=[],this.pointIDs=0;let I=A.points.length/7;for(let i=0;i{let t=new fe;return t.fromJSON(i),t}):[],this.isClosed=A.isClosed,this._roundness=A.roundness,this._update(),this}fromShape(A,I=!1){this.isText=I;let e=(t,C)=>{C instanceof kC&&C.v3.equals(t.position)&&t.controls[0].position.copy(C.v2)},i=t=>{let C=[],o,B;for(o=0,B=t.length;o0?t[o-1]:null,E;r instanceof kC?(E=this.createPoint(r.v0),E.controls[1].position.copy(r.v1)):r instanceof FC&&(E=this.createPoint(r.v1)),E!==void 0&&(Q!==null&&e(E,Q),C.push(E))}let a=t[t.length-1],s=!1;return a instanceof kC?a.v3.equals(C[0].position)&&(C[0].controls[0].position.copy(a.v2),s=!0):a instanceof FC&&a.v2.equals(C[0].position)&&(s=!0),this.isClosed=s,C};return this.points=i(A.curves),A instanceof yc&&(this.shapeHoles=A.holes.map(t=>{let C=new fe;return C.fromShape(t),C})),this.update(),this}updatePoint(A,I){let e=this.getPointByUuid(A);e&&(I.position!==void 0&&e.position.fromArray(I.position),I.roundness!==void 0&&(e.roundness=I.roundness),I.areControlsDirectionsMirrored!==void 0&&(e.areControlsDirectionsMirrored=I.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(A,I){var i;let e=(i=this.getPointByUuid(A))==null?void 0:i.controls[0];e&&(I.position&&e.position.fromArray(I.position),this.needsUpdate=!0)}updateNextControl(A,I){var i;let e=(i=this.getPointByUuid(A))==null?void 0:i.controls[1];e&&(I.position&&e.position.fromArray(I.position),this.needsUpdate=!0)}},_y=Math.PI*2;function Ru({x:g,y:A},I,e,i,t){return{x:g*I+i,y:A*e+t}}function ZZ(g,A){let I=A===1.5707963267948966?.551915024494:A===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(A/4),e=Math.cos(g),i=Math.sin(g),t=Math.cos(g+A),C=Math.sin(g+A);return[{x:e-i*I,y:i+e*I},{x:t+C*I,y:C-t*I},{x:t,y:C}]}function MM(g,A,I,e){let i=g*e-A*I<0?-1:1,t=Math.min(1,Math.max(-1,g*I+A*e));return i*Math.acos(t)}function VZ(g,A,I,e,i,t,C,o,B,a){let s=Math.pow(i,2),r=Math.pow(t,2),Q=Math.pow(C,2),E=Math.pow(o,2),n=s*r-s*E-r*Q;n<0&&(n=0),n/=s*E+r*Q,n=Math.sqrt(n)*(B===a?-1:1);let h=n*i/t*o,l=n*-t/i*C,c=h+(g+I)/2,d=l+(A+e)/2,u=(C-h)/i,y=(o-l)/t,f=(-C-h)/i,k=(-o-l)/t,M=MM(1,0,u,y),G=MM(u,y,f,k);return!a&&G>0&&(G-=_y),a&&G<0&&(G+=_y),{centerx:c,centery:d,ang1:M,ang2:G}}function zZ({px:g,py:A,cx:I,cy:e,rx:i,ry:t,largeArcFlag:C,sweepFlag:o}){let B=[];if(i===0||t===0)return[];let a=(g-I)/2,s=(A-e)/2;if(a===0&&s===0)return[];i=Math.abs(i),t=Math.abs(t);let r=Math.pow(a,2)/Math.pow(i,2)+Math.pow(s,2)/Math.pow(t,2);r>1&&(i*=Math.sqrt(r),t*=Math.sqrt(r));let Q=VZ(g,A,I,e,i,t,a,s,C,o),{ang1:E,ang2:n}=Q,{centerx:h,centery:l}=Q,c=Math.abs(n)/(_y/4);Math.abs(1-c)<1e-7&&(c=1);let d=Math.max(Math.ceil(c),1);n/=d;for(let u=0;u{let{x:y,y:f}=Ru(u[0],i,t,h,l),{x:k,y:M}=Ru(u[1],i,t,h,l),{x:G,y:v}=Ru(u[2],i,t,h,l);return{x1:y,y1:f,x2:k,y2:M,x:G,y:v}})}var jI;(function(g){g[g.ODD=0]="ODD",g[g.NONZERO=1]="NONZERO",g[g.POSITIVE=2]="POSITIVE",g[g.NEGATIVE=3]="NEGATIVE",g[g.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(jI||(jI={}));var Pe;(function(g){g[g.POLYGONS=0]="POLYGONS",g[g.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",g[g.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pe||(Pe={}));function jg(g,A){if(!g)throw A||"Assertion Failed!"}var Yg=function(){function g(){}return g.vertEq=function(A,I){return A.s===I.s&&A.t===I.t},g.vertLeq=function(A,I){return A.s0?i0?(I.t-e.t)*i+(I.t-A.t)*t:0},g.transEval=function(A,I,e){jg(g.transLeq(A,I)&&g.transLeq(I,e));var i=I.t-A.t,t=e.t-I.t;return i+t>0?i0?(I.s-e.s)*i+(I.s-A.s)*t:0},g.vertCCW=function(A,I,e){return A.s*(I.t-e.t)+I.s*(e.t-A.t)+e.s*(A.t-I.t)>=0},g.interpolate=function(A,I,e,i){return A=A<0?0:A,e=e<0?0:e,A<=e?e===0?(I+i)/2:I+(i-I)*(A/(A+e)):i+(I-i)*(e/(A+e))},g.intersect=function(A,I,e,i,t){var C,o,B;g.vertLeq(A,I)||(B=A,A=I,I=B),g.vertLeq(e,i)||(B=e,e=i,i=B),g.vertLeq(A,e)||(B=A,A=e,e=B,B=I,I=i,i=B),g.vertLeq(e,I)?g.vertLeq(I,i)?(C=g.edgeEval(A,e,I),o=g.edgeEval(e,I,i),C+o<0&&(C=-C,o=-o),t.s=g.interpolate(C,e.s,o,I.s)):(C=g.edgeSign(A,e,I),o=-g.edgeSign(A,i,I),C+o<0&&(C=-C,o=-o),t.s=g.interpolate(C,e.s,o,i.s)):t.s=(e.s+I.s)/2,g.transLeq(A,I)||(B=A,A=I,I=B),g.transLeq(e,i)||(B=e,e=i,i=B),g.transLeq(A,e)||(B=A,A=e,e=B,B=I,I=i,i=B),g.transLeq(e,I)?g.transLeq(I,i)?(C=g.transEval(A,e,I),o=g.transEval(e,I,i),C+o<0&&(C=-C,o=-o),t.t=g.interpolate(C,e.t,o,I.t)):(C=g.transSign(A,e,I),o=-g.transSign(A,i,I),C+o<0&&(C=-C,o=-o),t.t=g.interpolate(C,e.t,o,i.t)):t.t=(e.t+I.t)/2},g}(),JE=function(){function g(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return g}(),ll=function(){function g(A){this.side=A,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(g.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(A){this.Sym.Lface=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(A){this.Sym.Org=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(A){this.Sym.Lnext=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(A){this.Onext.Sym=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(A){this.Lnext.Sym=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(A){this.Sym.Onext=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(A){this.Sym.Onext.Sym=A},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(A){this.Sym.Lnext.Sym=A},enumerable:!0,configurable:!0}),g}(),Zs=function(){function g(){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 g}(),mM=function(){function g(){var A=new Zs,I=new JE,e=new ll(0),i=new ll(1);A.next=A.prev=A,A.anEdge=null,I.next=I.prev=I,e.next=e,e.Sym=i,i.next=i,i.Sym=e,this.vHead=A,this.fHead=I,this.eHead=e,this.eHeadSym=i}return g.prototype.makeEdge_=function(A){var I=new ll(0),e=new ll(1);A.Sym.sidethis.size||this.leq(e[i].key,e[t].key)){I[A].handle=i,e[i].node=A;break}I[A].handle=t,e[t].node=A,A=C}},g.prototype.floatUp_=function(A){var I=this.nodes,e=this.handles,i,t,C;for(i=I[A].handle;;){if(C=A>>1,t=I[C].handle,C===0||this.leq(e[t].key,e[i].key)){I[A].handle=i,e[i].node=A;break}I[A].handle=t,e[t].node=A,A=C}},g.prototype.init=function(){for(var A=this.size;A>=1;--A)this.floatDown_(A);this.initialized=!0},g.prototype.min=function(){return this.handles[this.nodes[1].handle].key},g.prototype.insert=function(A){var I,e;if(I=++this.size,I*2>this.max){this.max*=2;var i,t;for(t=this.nodes.length,this.nodes.length=this.max+1,i=t;i0&&(A[1].handle=A[this.size].handle,I[A[1].handle].node=1,I[e].key=null,I[e].node=this.freeList,this.freeList=e,--this.size,this.size>0&&this.floatDown_(1)),i},g.prototype.delete=function(A){var I=this.nodes,e=this.handles,i;jg(A>=1&&A<=this.max&&e[A].key!==null),i=e[A].node,I[i].handle=I[this.size].handle,e[I[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(e[I[i>>1].handle].key,e[I[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),e[A].key=null,e[A].node=this.freeList,this.freeList=A},g}(),Ku=function(){function g(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return g}(),FM=function(){function g(){this.key=null,this.next=null,this.prev=null}return g}(),$Z=function(){function g(A,I){this.frame=A,this.leq=I,this.head=new FM,this.head.next=this.head,this.head.prev=this.head}return g.prototype.min=function(){return this.head.next},g.prototype.max=function(){return this.head.prev},g.prototype.insert=function(A){return this.insertBefore(this.head,A)},g.prototype.search=function(A){var I=this.head;do I=I.next;while(I.key!==null&&!this.leq(this.frame,A,I.key));return I},g.prototype.insertBefore=function(A,I){do A=A.prev;while(A.key!==null&&!this.leq(this.frame,A.key,I));var e=new FM;return e.key=I,e.next=A.next,A.next.prev=e,e.prev=A,A.next=e,e},g.prototype.delete=function(A){A.next.prev=A.prev,A.prev.next=A.next},g}(),AV=function(){function g(){}return g.regionBelow=function(A){return A.nodeUp.prev.key},g.regionAbove=function(A){return A.nodeUp.next.key},g.debugEvent=function(A){},g.addWinding=function(A,I){A.winding+=I.winding,A.Sym.winding+=I.Sym.winding},g.edgeLeq=function(A,I,e){var i=A.event,t=I.eUp,C=e.eUp;if(t.Dst===i)return C.Dst===i?Yg.vertLeq(t.Org,C.Org)?Yg.edgeSign(C.Dst,t.Org,C.Org)<=0:Yg.edgeSign(t.Dst,C.Org,t.Org)>=0:Yg.edgeSign(C.Dst,i,C.Org)<=0;if(C.Dst===i)return Yg.edgeSign(t.Dst,i,t.Org)>=0;var o=Yg.edgeEval(t.Dst,i,t.Org),B=Yg.edgeEval(C.Dst,i,C.Org);return o>=B},g.deleteRegion=function(A,I){I.fixUpperEdge&&jg(I.eUp.winding===0),I.eUp.activeRegion=null,A.dict.delete(I.nodeUp)},g.fixUpperEdge=function(A,I,e){jg(I.fixUpperEdge),A.mesh.delete(I.eUp),I.fixUpperEdge=!1,I.eUp=e,e.activeRegion=I},g.topLeftRegion=function(A,I){var e=I.eUp.Org,i;do I=g.regionAbove(I);while(I.eUp.Org===e);if(I.fixUpperEdge){if(i=A.mesh.connect(g.regionBelow(I).eUp.Sym,I.eUp.Lnext),i===null)return null;g.fixUpperEdge(A,I,i),I=g.regionAbove(I)}return I},g.topRightRegion=function(A){var I=A.eUp.Dst;do A=g.regionAbove(A);while(A.eUp.Dst===I);return A},g.addRegionBelow=function(A,I,e){var i=new Ku;return i.eUp=e,i.nodeUp=A.dict.insertBefore(I.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,e.activeRegion=i,i},g.isWindingInside=function(A,I){switch(A.windingRule){case jI.ODD:return(I&1)!==0;case jI.NONZERO:return I!==0;case jI.POSITIVE:return I>0;case jI.NEGATIVE:return I<0;case jI.ABS_GEQ_TWO:return I>=2||I<=-2}throw new Error("Invalid winding rulle")},g.computeWinding=function(A,I){I.windingNumber=g.regionAbove(I).windingNumber+I.eUp.winding,I.inside=g.isWindingInside(A,I.windingNumber)},g.finishRegion=function(A,I){var e=I.eUp,i=e.Lface;i.inside=I.inside,i.anEdge=e,g.deleteRegion(A,I)},g.finishLeftRegions=function(A,I,e){for(var i,t=null,C=I,o=I.eUp;C!==e;){if(C.fixUpperEdge=!1,t=g.regionBelow(C),i=t.eUp,i.Org!=o.Org){if(!t.fixUpperEdge){g.finishRegion(A,C);break}i=A.mesh.connect(o.Lprev,i.Sym),g.fixUpperEdge(A,t,i)}o.Onext!==i&&(A.mesh.splice(i.Oprev,i),A.mesh.splice(o,i)),g.finishRegion(A,C),o=t.eUp,C=t}return o},g.addRightEdges=function(A,I,e,i,t,C){var o,B,a,s,r=!0;a=e;do jg(Yg.vertLeq(a.Org,a.Dst)),g.addRegionBelow(A,I,a.Sym),a=a.Onext;while(a!==i);for(t===null&&(t=g.regionBelow(I).eUp.Rprev),B=I,s=t;o=g.regionBelow(B),a=o.eUp.Sym,a.Org===s.Org;)a.Onext!==s&&(A.mesh.splice(a.Oprev,a),A.mesh.splice(s.Oprev,a)),o.windingNumber=B.windingNumber-a.winding,o.inside=g.isWindingInside(A,o.windingNumber),B.dirty=!0,!r&&g.checkForRightSplice(A,B)&&(g.addWinding(a,s),g.deleteRegion(A,B),A.mesh.delete(s)),r=!1,B=o,s=a;B.dirty=!0,jg(B.windingNumber-a.winding===o.windingNumber),C&&g.walkDirtyRegions(A,B)},g.spliceMergeVertices=function(A,I,e){A.mesh.splice(I,e)},g.vertexWeights=function(A,I,e){var i=Yg.vertL1dist(I,A),t=Yg.vertL1dist(e,A),C=.5*t/(i+t),o=.5*i/(i+t);A.coords[0]+=C*I.coords[0]+o*e.coords[0],A.coords[1]+=C*I.coords[1]+o*e.coords[1],A.coords[2]+=C*I.coords[2]+o*e.coords[2]},g.getIntersectData=function(A,I,e,i,t,C){I.coords[0]=I.coords[1]=I.coords[2]=0,I.idx=-1,g.vertexWeights(I,e,i),g.vertexWeights(I,t,C)},g.checkForRightSplice=function(A,I){var e=g.regionBelow(I),i=I.eUp,t=e.eUp;if(Yg.vertLeq(i.Org,t.Org)){if(Yg.edgeSign(t.Dst,i.Org,t.Org)>0)return!1;Yg.vertEq(i.Org,t.Org)?i.Org!==t.Org&&(A.pq.delete(i.Org.pqHandle),g.spliceMergeVertices(A,t.Oprev,i)):(A.mesh.splitEdge(t.Sym),A.mesh.splice(i,t.Oprev),I.dirty=e.dirty=!0)}else{if(Yg.edgeSign(i.Dst,t.Org,i.Org)<0)return!1;g.regionAbove(I).dirty=I.dirty=!0,A.mesh.splitEdge(i.Sym),A.mesh.splice(t.Oprev,i)}return!0},g.checkForLeftSplice=function(A,I){var e=g.regionBelow(I),i=I.eUp,t=e.eUp,C;if(jg(!Yg.vertEq(i.Dst,t.Dst)),Yg.vertLeq(i.Dst,t.Dst)){if(Yg.edgeSign(i.Dst,t.Dst,i.Org)<0)return!1;g.regionAbove(I).dirty=I.dirty=!0,C=A.mesh.splitEdge(i),A.mesh.splice(t.Sym,C),C.Lface.inside=I.inside}else{if(Yg.edgeSign(t.Dst,i.Dst,t.Org)>0)return!1;I.dirty=e.dirty=!0,C=A.mesh.splitEdge(t),A.mesh.splice(i.Lnext,t.Sym),C.Rface.inside=I.inside}return!0},g.checkForIntersect=function(A,I){var e=g.regionBelow(I),i=I.eUp,t=e.eUp,C=i.Org,o=t.Org,B=i.Dst,a=t.Dst,s,r,Q=new Zs,E,n;if(jg(!Yg.vertEq(a,B)),jg(Yg.edgeSign(B,A.event,C)<=0),jg(Yg.edgeSign(a,A.event,o)>=0),jg(C!==A.event&&o!==A.event),jg(!I.fixUpperEdge&&!e.fixUpperEdge),C===o||(s=Math.min(C.t,B.t),r=Math.max(o.t,a.t),s>r))return!1;if(Yg.vertLeq(C,o)){if(Yg.edgeSign(a,C,o)>0)return!1}else if(Yg.edgeSign(B,o,C)<0)return!1;return g.debugEvent(A),Yg.intersect(B,C,a,o,Q),jg(Math.min(C.t,B.t)<=Q.t),jg(Q.t<=Math.max(o.t,a.t)),jg(Math.min(a.s,B.s)<=Q.s),jg(Q.s<=Math.max(o.s,C.s)),Yg.vertLeq(Q,A.event)&&(Q.s=A.event.s,Q.t=A.event.t),E=Yg.vertLeq(C,o)?C:o,Yg.vertLeq(E,Q)&&(Q.s=E.s,Q.t=E.t),Yg.vertEq(Q,C)||Yg.vertEq(Q,o)?(g.checkForRightSplice(A,I),!1):!Yg.vertEq(B,A.event)&&Yg.edgeSign(B,A.event,Q)>=0||!Yg.vertEq(a,A.event)&&Yg.edgeSign(a,A.event,Q)<=0?a===A.event?(A.mesh.splitEdge(i.Sym),A.mesh.splice(t.Sym,i),I=g.topLeftRegion(A,I),i=g.regionBelow(I).eUp,g.finishLeftRegions(A,g.regionBelow(I),e),g.addRightEdges(A,I,i.Oprev,i,i,!0),!0):B===A.event?(A.mesh.splitEdge(t.Sym),A.mesh.splice(i.Lnext,t.Oprev),e=I,I=g.topRightRegion(I),n=g.regionBelow(I).eUp.Rprev,e.eUp=t.Oprev,t=g.finishLeftRegions(A,e,null),g.addRightEdges(A,I,t.Onext,i.Rprev,n,!0),!0):(Yg.edgeSign(B,A.event,Q)>=0&&(g.regionAbove(I).dirty=I.dirty=!0,A.mesh.splitEdge(i.Sym),i.Org.s=A.event.s,i.Org.t=A.event.t),Yg.edgeSign(a,A.event,Q)<=0&&(I.dirty=e.dirty=!0,A.mesh.splitEdge(t.Sym),t.Org.s=A.event.s,t.Org.t=A.event.t),!1):(A.mesh.splitEdge(i.Sym),A.mesh.splitEdge(t.Sym),A.mesh.splice(t.Oprev,i),i.Org.s=Q.s,i.Org.t=Q.t,i.Org.pqHandle=A.pq.insert(i.Org),g.getIntersectData(A,i.Org,C,B,o,a),g.regionAbove(I).dirty=I.dirty=e.dirty=!0,!1)},g.walkDirtyRegions=function(A,I){for(var e=g.regionBelow(I),i,t;;){for(;e.dirty;)I=e,e=g.regionBelow(e);if(!I.dirty&&(e=I,I=g.regionAbove(I),I===null||!I.dirty))return;if(I.dirty=!1,i=I.eUp,t=e.eUp,i.Dst!==t.Dst&&g.checkForLeftSplice(A,I)&&(e.fixUpperEdge?(g.deleteRegion(A,e),A.mesh.delete(t),e=g.regionBelow(I),t=e.eUp):I.fixUpperEdge&&(g.deleteRegion(A,I),A.mesh.delete(i),I=g.regionAbove(e),i=I.eUp)),i.Org!==t.Org)if(i.Dst!==t.Dst&&!I.fixUpperEdge&&!e.fixUpperEdge&&(i.Dst===A.event||t.Dst===A.event)){if(g.checkForIntersect(A,I))return}else g.checkForRightSplice(A,I);i.Org===t.Org&&i.Dst===t.Dst&&(g.addWinding(t,i),g.deleteRegion(A,I),A.mesh.delete(i),I=g.regionAbove(e))}},g.connectRightVertex=function(A,I,e){var i,t=e.Onext,C=g.regionBelow(I),o=I.eUp,B=C.eUp,a=!1;if(o.Dst!==B.Dst&&g.checkForIntersect(A,I),Yg.vertEq(o.Org,A.event)&&(A.mesh.splice(t.Oprev,o),I=g.topLeftRegion(A,I),t=g.regionBelow(I).eUp,g.finishLeftRegions(A,g.regionBelow(I),C),a=!0),Yg.vertEq(B.Org,A.event)&&(A.mesh.splice(e,B.Oprev),e=g.finishLeftRegions(A,C,null),a=!0),a){g.addRightEdges(A,I,e.Onext,t,t,!0);return}Yg.vertLeq(B.Org,o.Org)?i=B.Oprev:i=o,i=A.mesh.connect(e.Lprev,i),g.addRightEdges(A,I,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,g.walkDirtyRegions(A,I)},g.connectLeftDegenerate=function(A,I,e){var i,t,C,o,B;if(i=I.eUp,Yg.vertEq(i.Org,e)){jg(!1),g.spliceMergeVertices(A,i,e.anEdge);return}if(!Yg.vertEq(i.Dst,e)){A.mesh.splitEdge(i.Sym),I.fixUpperEdge&&(A.mesh.delete(i.Onext),I.fixUpperEdge=!1),A.mesh.splice(e.anEdge,i),g.sweepEvent(A,e);return}jg(!1),I=g.topRightRegion(I),B=g.regionBelow(I),C=B.eUp.Sym,t=o=C.Onext,B.fixUpperEdge&&(jg(t!==C),g.deleteRegion(A,B),A.mesh.delete(C),C=t.Oprev),A.mesh.splice(e.anEdge,C),Yg.edgeGoesLeft(t)||(t=null),g.addRightEdges(A,I,C.Onext,o,t,!0)},g.connectLeftVertex=function(A,I){var e,i,t,C,o,B,a=new Ku;if(a.eUp=I.anEdge.Sym,e=A.dict.search(a).key,i=g.regionBelow(e),!!i){if(C=e.eUp,o=i.eUp,Yg.edgeSign(C.Dst,I,C.Org)===0){g.connectLeftDegenerate(A,e,I);return}if(t=Yg.vertLeq(o.Dst,C.Dst)?e:i,e.inside||t.fixUpperEdge){if(t===e)B=A.mesh.connect(I.anEdge.Sym,C.Lnext);else{var s=A.mesh.connect(o.Dnext,I.anEdge);B=s.Sym}t.fixUpperEdge?g.fixUpperEdge(A,t,B):g.computeWinding(A,g.addRegionBelow(A,e,B)),g.sweepEvent(A,I)}else g.addRightEdges(A,e,I.anEdge,I.anEdge,null,!0)}},g.sweepEvent=function(A,I){A.event=I,g.debugEvent(A);for(var e=I.anEdge;e.activeRegion===null;)if(e=e.Onext,e===I.anEdge){g.connectLeftVertex(A,I);return}var i=g.topLeftRegion(A,e.activeRegion);jg(i!==null);var t=g.regionBelow(i),C=t.eUp,o=g.finishLeftRegions(A,t,null);o.Onext===C?g.connectRightVertex(A,i,o):g.addRightEdges(A,i,o.Onext,C,C,!0)},g.addSentinel=function(A,I,e,i){var t=new Ku,C=A.mesh.makeEdge();C.Org.s=e,C.Org.t=i,C.Dst.s=I,C.Dst.t=i,A.event=C.Dst,t.eUp=C,t.windingNumber=0,t.inside=!1,t.fixUpperEdge=!1,t.sentinel=!0,t.dirty=!1,t.nodeUp=A.dict.insert(t)},g.initEdgeDict=function(A){A.dict=new $Z(A,g.edgeLeq);var I=A.bmax[0]-A.bmin[0],e=A.bmax[1]-A.bmin[1],i=A.bmin[0]-I,t=A.bmax[0]+I,C=A.bmin[1]-e,o=A.bmax[1]+e;g.addSentinel(A,i,t,C),g.addSentinel(A,i,t,o)},g.doneEdgeDict=function(A){for(var I,e=0;(I=A.dict.min().key)!==null;)I.sentinel||(jg(I.fixUpperEdge),jg(++e===1)),jg(I.windingNumber===0),g.deleteRegion(A,I)},g.removeDegenerateEdges=function(A){var I,e,i,t=A.mesh.eHead;for(I=t.next;I!==t;I=e)e=I.next,i=I.Lnext,Yg.vertEq(I.Org,I.Dst)&&I.Lnext.Lnext!==I&&(g.spliceMergeVertices(A,i,I),A.mesh.delete(I),I=i,i=I.Lnext),i.Lnext===I&&(i!==I&&((i===e||i===e.Sym)&&(e=e.next),A.mesh.delete(i)),(I===e||I===e.Sym)&&(e=e.next),A.mesh.delete(I))},g.initPriorityQ=function(A){var I,e,i,t=0;for(i=A.mesh.vHead,e=i.next;e!==i;e=e.next)t++;for(t+=8,I=A.pq=new XZ(t,Yg.vertLeq),i=A.mesh.vHead,e=i.next;e!==i;e=e.next)e.pqHandle=I.insert(e);return e!==i?!1:(I.init(),!0)},g.donePriorityQ=function(A){A.pq=null},g.removeDegenerateFaces=function(A,I){var e,i,t;for(e=I.fHead.next;e!==I.fHead;e=i)i=e.next,t=e.anEdge,jg(t.Lnext!==t),t.Lnext.Lnext===t&&(g.addWinding(t.Onext,t),A.mesh.delete(t));return!0},g.computeInterior=function(A,I){I===void 0&&(I=!0);var e,i;if(g.removeDegenerateEdges(A),!g.initPriorityQ(A))return!1;for(g.initEdgeDict(A);(e=A.pq.extractMin())!==null;){for(;i=A.pq.min(),!(i===null||!Yg.vertEq(i,e));)i=A.pq.extractMin(),g.spliceMergeVertices(A,e.anEdge,i.anEdge);g.sweepEvent(A,e)}return A.event=A.dict.min().key.eUp.Org,g.debugEvent(A),g.doneEdgeDict(A),g.donePriorityQ(A),g.removeDegenerateFaces(A,A.mesh)?(I&&A.mesh.check(),!0):!1},g}(),gV=function(){function g(){this.mesh=new mM,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=jI.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 g.prototype.dot_=function(A,I){return A[0]*I[0]+A[1]*I[1]+A[2]*I[2]},g.prototype.normalize_=function(A){var I=A[0]*A[0]+A[1]*A[1]+A[2]*A[2];if(!I)throw"Zero-size vector!";I=Math.sqrt(I),A[0]/=I,A[1]/=I,A[2]/=I},g.prototype.longAxis_=function(A){var I=0;return Math.abs(A[1])>Math.abs(A[0])&&(I=1),Math.abs(A[2])>Math.abs(A[I])&&(I=2),I},g.prototype.computeNormal_=function(A){var I,e,i,t,C,o,B=[0,0,0],a=[0,0,0],s=[0,0,0],r=[0,0,0],Q=[0,0,0],E=[null,null,null],n=[null,null,null],h=this.mesh.vHead;I=h.next;for(var l=0;l<3;++l)t=I.coords[l],a[l]=t,n[l]=I,B[l]=t,E[l]=I;for(I=h.next;I!==h;I=I.next)for(var c=0;c<3;++c)t=I.coords[c],tB[c]&&(B[c]=t,E[c]=I);var d=0;if(B[1]-a[1]>B[0]-a[0]&&(d=1),B[2]-a[2]>B[d]-a[d]&&(d=2),a[d]>=B[d]){A[0]=0,A[1]=0,A[2]=1;return}for(o=0,e=n[d],i=E[d],s[0]=e.coords[0]-i.coords[0],s[1]=e.coords[1]-i.coords[1],s[2]=e.coords[2]-i.coords[2],I=h.next;I!==h;I=I.next)r[0]=I.coords[0]-i.coords[0],r[1]=I.coords[1]-i.coords[1],r[2]=I.coords[2]-i.coords[2],Q[0]=s[1]*r[2]-s[2]*r[1],Q[1]=s[2]*r[0]-s[0]*r[2],Q[2]=s[0]*r[1]-s[1]*r[0],C=Q[0]*Q[0]+Q[1]*Q[1]+Q[2]*Q[2],C>o&&(o=C,A[0]=Q[0],A[1]=Q[1],A[2]=Q[2]);o<=0&&(A[0]=A[1]=A[2]=0,A[this.longAxis_(s)]=1)},g.prototype.checkOrientation_=function(){for(var A=this.mesh.fHead,I,e=this.mesh.vHead,i,t=0,C=A.next;C!==A;C=C.next)if(i=C.anEdge,!(i.winding<=0))do t+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==C.anEdge);if(t<0){for(I=e.next;I!==e;I=I.next)I.t=-I.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},g.prototype.projectPolygon_=function(){var A=this.mesh.vHead,I=[0,0,0],e,i,t=!1;I[0]=this.normal[0],I[1]=this.normal[1],I[2]=this.normal[2],!I[0]&&!I[1]&&!I[2]&&(this.computeNormal_(I),t=!0),e=this.sUnit,i=this.tUnit;var C=this.longAxis_(I);e[C]=0,e[(C+1)%3]=1,e[(C+2)%3]=0,i[C]=0,i[(C+1)%3]=0,i[(C+2)%3]=I[C]>0?1:-1;for(var o=A.next;o!==A;o=o.next)o.s=this.dot_(o.coords,e),o.t=this.dot_(o.coords,i);t&&this.checkOrientation_();for(var B=!0,a=A.next;a!==A;a=a.next)B?(this.bmin[0]=this.bmax[0]=a.s,this.bmin[1]=this.bmax[1]=a.t,B=!1):(a.sthis.bmax[0]&&(this.bmax[0]=a.s),a.tthis.bmax[1]&&(this.bmax[1]=a.t))},g.prototype.addWinding_=function(A,I){A.winding+=I.winding,A.Sym.winding+=I.Sym.winding},g.prototype.tessellateMonoRegion_=function(A,I){var e,i;if(e=I.anEdge,!(e.Lnext!==e&&e.Lnext.Lnext!==e))throw"Mono region invalid";for(;Yg.vertLeq(e.Dst,e.Org);e=e.Lprev);for(;Yg.vertLeq(e.Org,e.Dst);e=e.Lnext);i=e.Lprev;for(var t=void 0;e.Lnext!==i;)if(Yg.vertLeq(e.Dst,i.Org)){for(;i.Lnext!==e&&(Yg.edgeGoesLeft(i.Lnext)||Yg.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)t=A.connect(i.Lnext,i),i=t.Sym;i=i.Lprev}else{for(;i.Lnext!==e&&(Yg.edgeGoesRight(e.Lprev)||Yg.edgeSign(e.Dst,e.Org,e.Lprev.Org)>=0);)t=A.connect(e,e.Lprev),e=t.Sym;e=e.Lnext}if(i.Lnext===e)throw"Mono region invalid";for(;i.Lnext.Lnext!==e;)t=A.connect(i.Lnext,i),i=t.Sym;return!0},g.prototype.tessellateInterior_=function(A){for(var I,e=A.fHead.next;e!==A.fHead;e=I)if(I=e.next,e.inside&&!this.tessellateMonoRegion_(A,e))return!1;return!0},g.prototype.discardExterior_=function(A){for(var I,e=A.fHead.next;e!==A.fHead;e=I)I=e.next,e.inside||A.zapFace(e)},g.prototype.setWindingNumber_=function(A,I,e){for(var i,t=A.eHead.next;t!==A.eHead;t=i)i=t.next,t.Rface.inside!==t.Lface.inside?t.winding=t.Lface.inside?I:-I:e?A.delete(t):t.winding=0},g.prototype.getNeighbourFace_=function(A){return!A.Rface||!A.Rface.inside?-1:A.Rface.n},g.prototype.outputPolymesh_=function(A,I,e,i){var t,C=0,o=0,B;e>3&&A.mergeConvexFaces(e);for(var a=A.vHead.next;a!==A.vHead;a=a.next)a.n=-1;for(var s=A.fHead.next;s!==A.fHead;s=s.next)if(s.n=-1,!!s.inside){t=s.anEdge,B=0;do{var a=t.Org;a.n===-1&&(a.n=o,o++),B++,t=t.Lnext}while(t!==s.anEdge);if(B>e)throw"Face vertex greater that support polygon";s.n=C,++C}this.elementCount=C,I===Pe.CONNECTED_POLYGONS&&(C*=2),this.elements=[],this.elements.length=C*e,this.vertexCount=o,this.vertices=[],this.vertices.length=o*i,this.vertexIndices=[],this.vertexIndices.length=o;for(var a=A.vHead.next;a!==A.vHead;a=a.next)if(a.n!==-1){var r=a.n*i;this.vertices[r+0]=a.coords[0],this.vertices[r+1]=a.coords[1],i>2&&(this.vertices[r+2]=a.coords[2]),this.vertexIndices[a.n]=a.idx}for(var Q=0,s=A.fHead.next;s!==A.fHead;s=s.next)if(s.inside){t=s.anEdge,B=0;do{var a=t.Org;this.elements[Q++]=a.n,B++,t=t.Lnext}while(t!==s.anEdge);for(var E=B;E2&&(this.vertices[B++]=e.Org.coords[2]),this.vertexIndices[a++]=this.vertexIdCallback?this.vertexIdCallback(e):e.Org.idx,C++,e=e.Lnext;while(e!==i);this.elements[s++]=t,this.elements[s++]=C,t+=C}},g.prototype.addContour=function(A,I){this.mesh===null&&(this.mesh=new mM),A<2&&(A=2),A>3&&(A=3);for(var e=null,i=0;i2?e.Org.coords[2]=I[i+2]:e.Org.coords[2]=0,e.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(e),e.winding=1,e.Sym.winding=-1},g.prototype.tesselate=function(A,I,e,i,t,C){if(A===void 0&&(A=jI.ODD),I===void 0&&(I=Pe.POLYGONS),C===void 0&&(C=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,t&&(this.normal[0]=t[0],this.normal[1]=t[1],this.normal[2]=t[2]),this.windingRule=A,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),AV.computeInterior(this,C);var o=this.mesh;return I===Pe.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),C&&o.check(),I===Pe.BOUNDARY_CONTOURS?this.outputContours_(o,i):this.outputPolymesh_(o,I,e,i),!0},g}();function Ea(g){var A=g.windingRule,I=A===void 0?jI.ODD:A,e=g.elementType,i=e===void 0?Pe.POLYGONS:e,t=g.polySize,C=t===void 0?3:t,o=g.vertexSize,B=o===void 0?2:o,a=g.normal,s=a===void 0?[0,0,1]:a,r=g.contours,Q=r===void 0?[]:r,E=g.strict,n=E===void 0?!0:E,h=g.debug,l=h===void 0?!1:h;if(!Q&&n)throw new Error("Contours can't be empty");if(Q){var c=new gV;g.edgeCreateCallback&&(c.edgeCreateCallback=g.edgeCreateCallback),g.vertexIdCallback&&(c.vertexIdCallback=g.vertexIdCallback);for(var d=0;dthis.capacity){let e=this.capacity;for(;A>e;)e*=2;this.realloc(e)}let I=this.size;return this.size=A,I}reserve(g){let A=this.size+g;A>this.capacity&&this.realloc(A)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} → ${this.size}`),this.realloc(this.size,!0)}},PR=Py;PR.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var IV=Fa(wq()),K0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jR={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},WR={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},Ju=(g,A)=>([I,e])=>(e=I?g:g+A)<=e),J0=class extends bg{constructor(A,I,e=0,i=12,t=3,C=jI.ODD,o=!1){super(),this.forPathBevel=o,this.type="ShapeGeometry",this.vertexCache={},this._shape=A,this._depth=I,this._curveSegments=i,this._bevelSegmentsInput=t;let B=this._shape.extractShapePointsToFlatArray([],i),a=this._shape.shapeHoles.map(N=>{let b=N.extractShapePointsToFlatArray([],i),O=[];for(let H=b.length-1;H>=1;H-=2){let _=b[H-1],gA=b[H-0];O.push(_,gA)}return O}),s=[],r=[];for(let N=0;NN.position)).getSize(new sA).length()*.1:s[0].length===0?Q=e:Q=(0,IV.default)(s).distance,e<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(e,Q,I/2),this._bevelSegments=Math.floor(t));let E;try{E=Ea({windingRule:C,elementType:Pe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B]})}catch{E=K0}let n;try{n=Ea({windingRule:jI.ODD,elementType:Pe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{n=jR}if(!E)throw new Error("error generating geometry");let h=E.elementCount;if(n){E.elementCount+=n.elementCount;for(let N=0;Nc&&(c=H),_u&&(u=_)}this._minX=l,this._minY=d,this._width=c-l,this._height=u-d,this._buffer=new PR(this._computeBufferEstimatedSize(E));let y=[],f=[];for(let N=E.elementCount-1;N>=0;N--){let b=N>=h,O=N*2,H=E.elements[O+0],_=E.elements[O+1],gA=H+_,CA={start:H,count:_,normals:[],continuous:[],concave:[]},AA=H,BA=gA-1,iA=H+1,rA=this._shape.roundedCurves.length;do{let DA=AA-H,eA=E.vertices[BA*2+0],aA=E.vertices[BA*2+1],nA=E.vertices[AA*2+0],fA=E.vertices[AA*2+1],uA=E.vertices[iA*2+0],VA=E.vertices[iA*2+1],yA=nA-eA,LA=fA-aA,HA=Math.sqrt(yA*yA+LA*LA);yA/=HA,LA/=HA;let Ag=nA-uA,gg=fA-VA,Dg=Math.sqrt(Ag*Ag+gg*gg);Ag/=Dg,gg/=Dg,CA.normals[DA*2+0]=-gg,CA.normals[DA*2+1]=Ag,CA.concave[DA]=yA*gg-LA*Ag>0;let Eg=E.vertexIndices[AA];if(Array.isArray(Eg))CA.continuous[DA]=!1;else{let[$A,mg]=this._shape.getCurveIndexFromVertexId(Eg-1,!0);if(mg>0&&mg<1)CA.continuous[DA]=!0;else{let hg=mg===1?$A+1:$A-1;hg=(hg+rA)%rA;let V=mg===1?0:1,W=this._shape.roundedCurves[$A].getTangent(mg),wA=this._shape.roundedCurves[hg].getTangent(V);CA.continuous[DA]=W.dot(wA)>.95}}b&&(CA.normals[DA*2+0]*=-1,CA.normals[DA*2+1]*=-1),[BA,AA,iA]=[AA,iA,iA+1],iA>=gA&&(iA-=_)}while(iA!==H+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:E.vertices.slice(H*2,gA*2),vertexCount:_,vertexIndices:new Array(_).fill(!0).map((DA,eA)=>[eA,eA]),elements:[0,_],elementCount:1,mesh:null},reverseMap:[],insetPoints:E.vertices.slice(H*2,gA*2)});let IA=0;for(let DA=1;DA<=this._bevelSegments;DA++){let eA=DA/this._bevelSegments*Math.PI/2,aA=(1-Math.cos(eA))*this._bevel,nA=[],fA=[],uA=0;for(let yA=0;yA<_;yA++){let LA=yA*2,HA=(yA-1+_)%_*2,Ag=E.vertices[CA.start*2+LA+0],gg=E.vertices[CA.start*2+LA+1],Dg=-CA.normals[HA+0]*aA,Eg=-CA.normals[HA+1]*aA,$A=-CA.normals[LA+0]*aA,mg=-CA.normals[LA+1]*aA;if(CA.concave[yA]||!CA.concave[yA]&&b){let hg=Math.atan2(Eg,Dg),V=Math.atan2(mg,$A);V>hg&&(V-=Math.PI*2);let W=V-hg;if(CA.continuous[yA]||b){let wA=hg+W/2,qA=Math.cos(wA)*aA,Ig=Math.sin(wA)*aA;nA[2*uA+0]=Ag+qA*(b?-1:1),nA[2*uA+1]=gg+Ig*(b?-1:1),fA[uA]=yA,uA++}else{let wA=Math.max(1,Math.floor(i/4*Math.abs(W)/Math.PI));for(let qA=0;qA<=wA;qA++){let Ig=hg+W*(qA/wA),jA=Math.cos(Ig)*aA,dg=Math.sin(Ig)*aA;nA[2*uA+0]=Ag+jA,nA[2*uA+1]=gg+dg,fA[uA]=yA,uA++}}}else nA[2*uA+0]=Ag+Dg,nA[2*uA+1]=gg+Eg,fA[uA]=yA,uA++,nA[2*uA+0]=Ag,nA[2*uA+1]=gg,fA[uA]=yA,uA++,nA[2*uA+0]=Ag+$A,nA[2*uA+1]=gg+mg,fA[uA]=yA,uA++}let VA=Ea({windingRule:jI.POSITIVE,elementType:Pe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[nA],edgeCreateCallback:yA=>{let LA=yA.Org.idx,HA=fA[LA],Ag=fA[(LA+1)%fA.length];yA.idx=[HA,Ag],yA.Sym.idx=[Ag,HA]},vertexIdCallback:yA=>{let LA=yA.Lprev.idx;return[LA?LA[1]:0,yA.idx?yA.idx[0]:0]}});if(!VA)throw console.log("Error"),new Error(`error generating bevel geometry for ${DA}'th loop`);if(!VA.vertexCount){let yA=(DA-1)/this._bevelSegments*Math.PI/2;IA=(1-Math.sin(yA))*this._bevel;break}for(let yA=0;yA{let nA=0,fA=DA.boundary.vertexIndices.length;for(;nAqA){let jA=wA/qA,dg=0;for(let Cg=1;Cg(dg+1)*jA&&(dg++,V=this._buildBevelVert(CA,aA,(HA+dg)%fA,dg/(qA-1),gg),y.push(mg.topN,hg.topP,V.topP),o===!1&&y.push(hg.bottomP,mg.bottomN,V.bottomP),mg=V)}else{let jA=qA/wA,dg=0;for(let Cg=1;Cg(dg+1)*jA&&(dg++,hg=this._buildBevelVert(CA,eA,(LA+dg)%nA,dg/(wA-1),gg),y.push($A.topN,hg.topP,mg.topN),o===!1&&y.push(hg.bottomP,$A.bottomN,mg.bottomN),$A=hg)}LA=(LA+wA)%nA,HA=(HA+qA)%fA,VA=(VA+1)%uA}while(VA!==Ag)}if(o===!1&&this._depth>this._bevel*2&&this._buildWall($,CA,y),b){let DA=[];for(let eA=y.length-1;eA>=QA+2;eA-=3){let aA=y[eA-2],nA=y[eA-1],fA=y[eA-0];DA.push(fA,nA,aA)}y.splice(QA,y.length-QA,...DA)}if(b){let DA=[];for(let eA=$[$.length-1].boundary.vertices.length-1;eA>=1;eA-=2){let aA=$[$.length-1].boundary.vertices[eA-1],nA=$[$.length-1].boundary.vertices[eA-0];DA.push(aA,nA)}f.push(DA)}if(!b){let DA=$[$.length-1],eA;try{eA=Ea({windingRule:$.length>1?jI.POSITIVE:jI.ODD,elementType:Pe.POLYGONS,vertexSize:2,strict:!0,contours:[DA.insetPoints,...f]})}catch{eA=WR}if(!eA)throw new Error("Error generating geometry for surface");a.length===0&&this._bevel0,r=A.continuous[a]||Q);let E=Math.cos(I.angle),n=Math.sin(I.angle),h=e*2,l=a*2,c=s*2,d=I.boundary.vertices[h+0],u=I.boundary.vertices[h+1],y=(1-n)*this._bevel,f=(d-this._minX)/this._width,k=(u-this._minY)/this._height;this.forPathBevel&&(t!==void 0&&(f=t),k=1);let M=A.normals[l+0],G=A.normals[l+1],v=A.normals[c+0],N=A.normals[c+1];if(Q){let gA=v-M,CA=N-G;M=M+gA*(1-i),G=G+CA*(1-i);let AA=Math.sqrt(M*M+G*G);M/=AA,G/=AA}let b=this.forPathBevel?this._buffer.get(r?1:2):this._buffer.get(r?2:4),O=b*3,H=b*2,_={i:e,fi:a,topP:b+0,topN:b+0,bottomP:b+1,bottomN:b+1,pathBevelUCoord:t};return this._buffer.positions[O+0]=d,this._buffer.positions[O+1]=u,this._buffer.positions[O+2]=(this.forPathBevel?this._bevel:this._depth)-y,this._buffer.normals[O+0]=M*E,this._buffer.normals[O+1]=G*E,this._buffer.normals[O+2]=n,this._buffer.uvs[H+0]=f,this._buffer.uvs[H+1]=k,this.forPathBevel===!1&&(this._buffer.positions[O+3]=d,this._buffer.positions[O+4]=u,this._buffer.positions[O+5]=y,this._buffer.normals[O+3]=M*E,this._buffer.normals[O+4]=G*E,this._buffer.normals[O+5]=-n,this._buffer.uvs[H+2]=k,this._buffer.uvs[H+3]=f),r||(this.forPathBevel?(b+=1,O+=3,H+=2):(b+=2,O+=6,H+=4),_.topP=b+0,_.bottomP=b+1,this._buffer.positions[O+0]=d,this._buffer.positions[O+1]=u,this._buffer.positions[O+2]=(this.forPathBevel?this._bevel:this._depth)-y,this._buffer.normals[O+0]=v*E,this._buffer.normals[O+1]=N*E,this._buffer.normals[O+2]=n,this._buffer.uvs[H+0]=f,this._buffer.uvs[H+1]=k,this.forPathBevel===!1&&(this._buffer.positions[O+3]=d,this._buffer.positions[O+4]=u,this._buffer.positions[O+5]=y,this._buffer.normals[O+3]=v*E,this._buffer.normals[O+4]=N*E,this._buffer.normals[O+5]=-n,this._buffer.uvs[H+2]=k,this._buffer.uvs[H+3]=f)),this.vertexCache[C]=_,_}clone(){let A=new J0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return A.userData=TD(this.userData),A}},ZR=class extends bg{constructor(g,A=12,I={}){super(),this.type="ShapeGeometry",this.windingRule=jI.ODD,this.elementType=Pe.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=g,this._curveSegments=A,this._triangulationOptions=Object.assign({windingRule:jI.ODD,elementType:Pe.POLYGONS,polySize:3,vertexSize:2,strict:!0},I);let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),i=this._shape.shapeHoles.map(Q=>Q.extractShapePointsToFlatArray([],this._curveSegments)),t,C=!0,o=!0,B,a;for(let Q=0,E=e.length/2;QE&&(E=f),kh&&(h=k)}let l=E-Q,c=h-n;for(let d=0,u=s;d0&&o.update());let a=o??new fe(i,t);return{parameters:Object.assign(e,{width:i,height:t,depth:C,roundness:B}),shape:a}}static build(A){let{depth:I,extrudeBevelSize:e,extrudeBevelSegments:i,subdivisions:t,roundness:C,windingRule:o}=A.parameters;A.shape.roundness=C;let B;return I<=0?B=new ZR(A.shape,t,{windingRule:o}):B=new VR(A.shape,I,e,t,i,o),Object.assign(B,{userData:{...A,type:"VectorGeometry"}})}},zR=Math.PI*2,v0=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},g.parameters);return I.angle=vg.clamp(I.angle,0,360),{shape:g.shape&&g.shape instanceof fe?g.shape:new fe,parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??0)})}}static build(g){let{width:A,height:I,spikes:e,angle:i,innerRadius:t,depth:C,extrudeBevelSize:o,extrudeBevelSegments:B}=g.parameters,a=g.shape,s=A*.5,r=I*.5,Q=eV(a,s,r,i*Math.PI/180,e,t);a.isClosed=!0,a.update();let E;return i===0?(E=new bg,E.setAttribute("position",new pg([],3))):E=Or.create({shape:a,parameters:{subdivisions:Q,depth:C,extrudeBevelSize:o,extrudeBevelSegments:B}}),Object.assign(E,{userData:{...g,type:"EllipseGeometry"}})}};function eV(g,A,I,e,i,t){if(e>=zR)return i>30||i%4===0?(tV(g,A,I,t),Math.round(i/4)):RM(g,e,i,A,I,t);e=Math.max(e,.001);let C={x:0,y:I},o=e+Math.PI*.5,B={x:Math.cos(o)*A,y:Math.sin(o)*I},a=zZ({px:C.x,py:C.y,cx:B.x,cy:B.y,rx:A,ry:I,largeArcFlag:e>Math.PI,sweepFlag:!0});return i>30||i%a.length===0?iV(g,C.x,C.y,a,i,A,I,t):RM(g,e,i,A,I,t)}function iV(g,A,I,e,i,t,C,o){let B=Math.round(i/e.length);g.addPoint(cQ(A,I));for(let a=0,s=e.length;a0?XR(g,t,C,o):g.addPoint(cQ(0,0)),B}function RM(g,A,I,e,i,t){let C=-A/I;for(let o=0;o<=I;o++){let B=C*o,a=Math.sin(B)*e,s=Math.cos(B)*i;g.addPoint(cQ(a,s))}return A0?XR(g,e,i,t):g.addPoint(cQ(0,0)):(g.removePoint(g.points[g.points.length-1]),t>0&&$R(g,e,i,t)),1}function tV(g,A,I,e=0,i=0,t=0){let C=.5522847498,o=A*C,B=I*C;g.addPoint(cl(i-A,t,i-A,t-B,i-A,t+B)),g.addPoint(cl(i,t+I,i-o,t+I,i+o,t+I)),g.addPoint(cl(i+A,t,i+A,t+B,i+A,t-B)),g.addPoint(cl(i,t-I,i+o,t-I,i-o,t-I)),e>0&&$R(g,A,I,e)}function cQ(g,A){return new lQ(vg.generateUUID(),new sA(g,A))}function cl(g,A,I,e,i,t){let C=cQ(g,A);return C.controls[0].position.set(I,e),C.controls[1].position.set(i,t),C}function XR(g,A,I,e){AK(g,A,I,e).forEach(i=>g.addPoint(i))}function $R(g,A,I,e){let i=AK(g,A,I,e),t=new fe;i.forEach(C=>t.addPoint(C)),t.isClosed=!0,g.shapeHoles.push(t)}function AK(g,A,I,e){let i=e*A/100,t=i*(Math.abs(I)/Math.abs(A)),C=new sA(i/A,t/I),o=g.points.map(B=>{let a=B.clone();return a.uuid=vg.generateUUID(),a}).reverse();return o.forEach(B=>{B.position.multiply(C);let a=B.controls[0].position.clone().multiply(C),s=B.controls[1].position.clone().multiply(C);B.controls[0].position.copy(s),B.controls[1].position.copy(a)}),o}var CV=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},g.parameters),e=Math.abs(I.width),i=Math.abs(I.height??e),t=Math.abs(I.depth??e),C=Math.abs(Math.min(e,t))/2;return{parameters:Object.assign(I,{width:e,height:i,depth:t,radius:C,segments:Math.round(I.segments),pathSegments:Math.round(I.pathSegments),cornerSegments:Math.round(I.cornerSegments)})}}static build(g){let{width:A,height:I,depth:e,radius:i,revolutions:t,segments:C,pathRadius:o,pathType:B,pathSegments:a,cornerRadius:s,cornerSegments:r}=g.parameters,Q=new gK(!1,A,I,e,i,t,C,o,B,a,s,r);return Object.assign(Q,{userData:{...g,type:"HelixGeometry"}})}},vu=new BQ([0,0,0],1),gK=class extends bg{constructor(g=!0,A=1,I=1,e=1,i=1,t=1,C=1,o=1,B=1,a=1,s=1,r=1){if(super(),t===0)return;let Q=g&&t===1;Q&&(r=0),s>100&&(s=100),s===0&&(r=0);let E=()=>new J,n=new J,h=E(),l=E(),c=E(),d,u,y,f,k,M,G,v,N=E(),b=E(),O=E(),H=E(),_=E(),gA=E(),CA=E(),AA=E(),BA=I-2*o+.001,iA=BA/t,rA=Math.ceil(C*t),$=rA+1,IA=BA/rA,hA=-BA/2,QA=a+1,DA=2*Math.PI/a,eA=Math.PI/2/r,aA=.01,nA=Math.min((1-s/100)*o,o-aA),fA=o-nA,uA=0,VA=2,yA=r*VA+VA,LA=QA*yA/VA,HA=LA+QA*$,Ag=Math.max(0,QA*($+yA)),[gg,Dg,Eg]=[3,3,2].map(UA=>Array(Ag*UA).fill(0)),$A=[],mg=i-o;function hg(UA,fg){let Rg=Math.PI/2;M=fg*IA,v=2*Math.PI*(M%iA)/iA+Rg,M+=hA,G=Math.sin(v)*mg,k=Math.cos(v)*mg,g?UA.set(k,G,M):UA.set(k,M,G)}hg(n,-1e-10),hg(h,0),N.copy(n),hg(n,1);let V=n.distanceTo(h),W=Q?0:fA+nA,wA=V*rA+2*W,qA=nA,Ig=wA-W;for(let UA=0;UA<=rA;UA++){hg(l,UA),AA.subVectors(l,N).normalize(),N.copy(l),gA.copy(l).setComponent(+g+1,0).normalize(),CA.crossVectors(AA,gA).normalize();let fg=UA===0,Rg=UA===rA,Ug=fg?3*Math.PI/2:eA,ng=fg?qA:Ig,og=fg?QA:HA,Zg=fg?0:Ag-QA,cg=AA.clone().multiplyScalar(fg?-fA:fA).add(l),OI=AA.clone().multiplyScalar(fg?-1:1).normalize();for(let lA=0;lA{gg[uA*3+WA]=cg.getComponent(WA),Dg[uA*3+WA]=OI.getComponent(WA)}),Eg[uA*2]=+Rg,Eg[uA*2+1]=lA/a),h.copy(O).multiplyScalar(nA),c.addVectors(l,h);for(let WA=0;WA{gg[uA*3+$g]=h.getComponent($g),Dg[uA*3+$g]=_.getComponent($g)});let Lg=+fg+Math.sin(Qg);Eg[uA*2]=(ng+fA*Lg)/wA,Eg[uA*2+1]=lA/a}}h.addVectors(l,b),uA=LA+UA*QA+lA,[0,1,2].forEach(WA=>{gg[uA*3+WA]=h.getComponent(WA),Dg[uA*3+WA]=O.getComponent(WA)}),Eg[uA*2]=(W+UA*V)/wA,Eg[uA*2+1]=lA/a}}let jA=$+2*r+VA,[dg,Cg]=[+Q,jA-1];for(let UA=dg;UA<=Cg-1;UA++){let fg=Q&&UA===Cg-1;for(let Rg=0;Rg{Array.isArray(i)&&(i.x=i[0],i.y=i[1])});let I=Object.assign({},(A==null?void 0:A.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}]},g.parameters);return{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width)})}}static build(g){let{points:A,segments:I,verticalSegments:e}=g.parameters,i=new yc;i.moveTo(A[0].x,A[0].y),i.bezierCurveTo(A[1].x,A[1].y,A[2].x,A[2].y,A[3].x,A[3].y);let t=new VN(i.extractPoints(e).shape,I);return t.rotateZ(Math.PI),Object.assign(t,{userData:{...g,type:"LatheGeometry"}})}},Ao=new zA,qu=new ZI,Dl=new J,$c=class extends Si{constructor(){super(),this.uuid=vg.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(A){let I=new hi().getNormalMatrix(A);for(let e=0,i=this.vertices.length;e0)for(let Q=0;Q0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let A=0,I=this.faces.length;A0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let I=0,e=this.faces.length;I=0;B--){let a=C[B];this.faces.splice(a,1);for(let s=0,r=this.faceVertexUvs.length;s0,y=h.vertexNormals.length>0,f=h.color.r!==1||h.color.g!==1||h.color.b!==1,k=h.vertexColors.length>0,M=0;if(M=s(M,0,0),M=s(M,1,l),M=s(M,2,c),M=s(M,3,d),M=s(M,4,u),M=s(M,5,y),M=s(M,6,f),M=s(M,7,k),e.push(M),e.push(h.a,h.b,h.c),e.push(h.materialIndex),d){let G=this.faceVertexUvs[0][n];e.push(E(G[0]),E(G[1]),E(G[2]))}if(u&&e.push(r(h.normal)),y){let G=h.vertexNormals;e.push(r(G[0]),r(G[1]),r(G[2]))}if(f&&e.push(Q(h.color)),k){let G=h.vertexColors;e.push(Q(G[0]),Q(G[1]),Q(G[2]))}}function s(n,h,l){return l?n|1<0&&(A.data.colors=C),B.length>0&&(A.data.uvs=[B]),A.data.faces=e,A}clone(){return new $c().copy(this)}copy(A){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=A.name;let I=A.vertices;for(let Q=0,E=I.length;Q0){let i=new Float32Array(A.normals.length*3);I.setAttribute("normal",dl.call(new zg(i,3),A.normals))}if(A.colors.length>0){let i=new Float32Array(A.colors.length*3);I.setAttribute("color",KM.call(new zg(i,3),A.colors))}if(A.uvs.length>0){let i=new Float32Array(A.uvs.length*2);I.setAttribute("uv",JM.call(new zg(i,2),A.uvs))}if(A.uvs2.length>0){let i=new Float32Array(A.uvs2.length*2);I.setAttribute("uv2",JM.call(new zg(i,2),A.uvs2))}I.groups=A.groups;for(let i in A.morphTargets){let t=[],C=A.morphTargets[i];for(let o=0,B=C.length;o0){let i=new pg(A.skinIndices.length*4,4);I.setAttribute("skinIndex",vM.call(i,A.skinIndices))}if(A.skinWeights.length>0){let i=new pg(A.skinWeights.length*4,4);I.setAttribute("skinWeight",vM.call(i,A.skinWeights))}return A.boundingSphere!==null&&(I.boundingSphere=A.boundingSphere.clone()),A.boundingBox!==null&&(I.boundingBox=A.boundingBox.clone()),I}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(A){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(A)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(A){let I=new bg,e=A.geometry;if(A.isPoints||A.isLine){let i=new pg(e.vertices.length*3,3),t=new pg(e.colors.length*3,3);if(I.setAttribute("position",dl.call(i,e.vertices)),I.setAttribute("color",KM.call(t,e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){let C=new pg(e.lineDistances.length,1);I.setAttribute("lineDistance",rV.call(C,e.lineDistances))}e.boundingSphere!==null&&(I.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(I.boundingBox=e.boundingBox.clone())}else A.isMesh&&(I=e.toBufferGeometry());return I}};$c.prototype.isGeometry=!0;var aV=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(g){let A=[],I,e,i,t=g.faces;for(e=0;e0,t=e[1]&&e[1].length>0,C=g.morphTargets,o=C.length,B;if(o>0){B=[];for(let l=0;l0){r=[];for(let l=0;l0&&A.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let l=0;l0;)this._smooth(g);return g.computeFaceNormals(),g.computeVertexNormals(),g}_smooth(g){let A=new J,I,e,i,t,C,o=g.vertices,B=g.faces,a=g.faceVertexUvs[0],s=a!==void 0&&a.length>0,r=[],Q=new Map;EV(o,B,r,Q);let E=[],n,h,l,c,d,u,y;for(let aA of Array.from(Q.keys())){for(h=Q.get(aA),l=new J,d=3/8,u=1/8,y=h.faces.length,y!=2&&(d=.5,u=0,y!=1),l.addVectors(h.a,h.b).multiplyScalar(d),A.set(0,0,0),t=0;t3&&(f=3/(8*I)),k=1-I*Number(f),M=f,I<=2&&(I==2?(k=3/4,M=1/8):I==1||I==0),b=N.clone().multiplyScalar(k),A.set(0,0,0),t=0;t0?(o===void 0||(C==null?void 0:C.subdivisions)!==i)&&(o===void 0&&(o=t),t=new nV(i).modify(o).toBufferGeometry()):(o!==void 0&&(t=o),o=void 0,t.getAttribute("normal")===void 0&&t.computeVertexNormals())}catch{o!==void 0&&(t=o),o=void 0,t.getAttribute("normal")===void 0&&t.computeVertexNormals()}return o!==void 0&&Object.assign(t,{originalGeometry:o}),delete g.geometry,Object.assign(t,{userData:{...g,type:"NonParametricGeometry"}})}static loadFromUrl(g,A,I){new rF(I).load(g,e=>{let i=this.normalizeInputs({geometry:e});e.boundingBox.getSize(Ai);let t=100/Ai.x;Object.assign(i.parameters,{width:100,height:Ai.y*t,depth:Ai.z*t}),A(this.build(i))})}},eK=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},g.parameters);return{shape:g.shape&&g.shape instanceof fe?g.shape:new fe,parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??0)})}}static build(g){let{width:A,height:I,spikes:e,cornerRadius:i,depth:t,extrudeBevelSize:C,extrudeBevelSegments:o}=g.parameters,B=g.shape,a=A*.5,s=I*.5,r=0,Q=0,E=2*Math.PI/e;for(let h=0;h0){{let Ag=BA.clone().add(iA).multiplyScalar(.5),gg=u.clone().sub(Ag).normalize(),Dg=d.clone().sub(Ag).normalize().add(gg).normalize().multiplyScalar(-1),Eg=IA.clone().sub($);gA(Ag,Eg,Dg,k.angle())}let LA,HA;{let Ag=new J;vE(v,fA,Ag);let gg=IA.clone().add(rA).multiplyScalar(.5);gg=cV(gg,iA,u);let Dg=IA.clone().sub(rA);[LA,HA]=gA(gg,Dg,Ag,b,rA.y)}{let Ag=LA,gg=Ag.clone().setY(0).normalize(),Dg=new J(0,-1,0),Eg=gg.clone().cross(Dg);CA(Ag,gg,Dg,Eg)}{let Ag=k.angle(),gg=Math.PI-Ag,Dg=u.clone();Dg.y-=t/Math.sin(Ag-Math.PI/2);let Eg=new J,$A=[];for(let hg=0;hgI&&k>e?Math.min(y*I/f,y*e/k):f>I?y*I/f:k>e?y*e/k:y}let E=[];E[0]=i[0]===0?0:Q(i[0],i[0]+i[3],i[0]+i[1]),E[1]=i[1]===0?0:Q(i[1],i[1]+i[2],i[1]+i[0]),E[2]=i[2]===0?0:Q(i[2],i[2]+i[1],i[2]+i[3]),E[3]=i[3]===0?0:Q(i[3],i[3]+i[0],i[3]+i[2]);let n=s.x,h=r.x,l=r.y,c=s.y;A.addPoint(A.createPoint(n,l)),A.addPoint(A.createPoint(h,l)),A.addPoint(A.createPoint(h,c)),A.addPoint(A.createPoint(n,c)),A.isClosed=!0;let d=!0;for(let y=0,f=A.points.length;y0&&E[y]!==E[y-1]&&(d=!1);d&&(A.roundness=E[0]),A.useCubicForRoundedCorners=t!==1,A.update();let u=Or.create({shape:A,parameters:{depth:C,extrudeBevelSize:o,extrudeBevelSegments:B}});return Object.assign(u,{userData:{...g,type:"RectangleGeometry"}})}},dV=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},g.parameters);return I.thetaLength=vg.clamp(I.thetaLength,0,180),{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width)})}}static build(g){let{width:A=100,height:I=A,depth:e=A,widthSegments:i=64,heightSegments:t=64,phiStart:C,phiLength:o,thetaStart:B,thetaLength:a}=g.parameters,s;return a===0?(s=new bg,s.setAttribute("position",new pg([],3))):s=new Zw(.5*A,i,t,C,o,B,a*vg.DEG2RAD),s.scale(1,I/A,e/A),Object.assign(s,{userData:{...g,type:"SphereGeometry"}})}},uV=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,depth:0,widthSegments:8,heightSegments:8},g.parameters);return{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:0})}}static build(g){let{width:A=100,height:I=A,widthSegments:e=8,heightSegments:i=8}=g.parameters,t=new FD(A,I,e,i);return t.scale(1,1,1),Object.assign(t,{userData:{...g,type:"PlaneGeometry"}})}},pV=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,angle:90,cornerRadius:24,cornerSegments:8},g.parameters);return{parameters:Object.assign(I,{width:Math.abs(I.width),height:Math.abs(I.height??I.width),depth:Math.abs(I.depth??I.width)})}}static build(g){let{width:A,height:I,depth:e,angle:i,cornerRadius:t,cornerSegments:C}=g.parameters,o=new yV(A,I,e,i,t,C);return Object.assign(o,{userData:{...g,type:"BackdropGeometry"}})}},yV=class extends bg{constructor(g=1,A=1,I=1,e=90,i=10,t=24){super(),this.type="BackdropGeometry";let C=[],o=[],B=[],a=.001;i==0&&(t=1),t=Math.max(1,Math.floor(t)),i=Math.min(i,100),e=Math.min(180-a,e),e*=Math.PI/180;let s=[],r=Math.PI/2,Q=(aA=0,nA=0,fA=0)=>new J(aA,nA,fA),E=Q(),n=Q(),[h,l,c]=[A/2,g/2,I/2],d=-l,u=+l,[y,f,k]=[Q(d,-h,+c),Q(d,-h,-c),Q(d,+h,-c)],M=(aA,nA=!1)=>Math.sin(aA-Math.PI/(1+ +nA)),G=(aA,nA=!1)=>Math.cos(aA-Math.PI/(1+ +nA));k.y=Math.sin(e)*A-h;let v=Math.cos(e)*A-c,N=y.z-a;e<=r?(k.z=Math.min(v,N),k.z==N&&(k.y-=(v-N)/Math.tan(r-e))):f.z=Math.min(f.z-v-c,y.z-a),E.subVectors(y,f),n.subVectors(k,f);let b=Math.min(E.length(),n.length())*i/100,O=b*Math.tan(e/2),H=b/Math.cos(e/2),_=E.clone().normalize().add(n.normalize()).setLength(H).add(f);E.set(0,M(e,!0),G(e,!0)),s.push([k,E.clone()]);let gA=(Math.PI-e)/t;for(let aA=0;aA<=t;aA++){let nA=r+e+aA*gA;E.set(0,Math.sin(nA)*O,Math.cos(nA)*O),E.add(_),n.set(0,M(nA),G(nA)),s.push([E.clone(),n.clone()])}s.push([y,Q(0,1,0)]);let CA=Math.sin(gA/2)*O*2,AA=s.length-1,BA=s[0][0].distanceTo(s[1][0]),iA=s[AA-1][0].distanceTo(s[AA][0]),rA=BA+CA*t+iA;s[0].push(1);for(let aA=0;aA<=t;aA++)s[aA+1].push(1-(BA+aA*CA)/rA);s[AA].push(0);let[$,IA,hA]=s[0],QA,DA,eA;for(let aA=1;aA{if(typeof A!="object"||!A.name||!A.init)throw new Error("Invalid JSEP plugin format");this.registered[A.name]||(A.init(this.jsep),this.registered[A.name]=A)})}},JA=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+JA.version}static addUnaryOp(A){return JA.max_unop_len=Math.max(A.length,JA.max_unop_len),JA.unary_ops[A]=1,JA}static addBinaryOp(A,I,e){return JA.max_binop_len=Math.max(A.length,JA.max_binop_len),JA.binary_ops[A]=I,e?JA.right_associative.add(A):JA.right_associative.delete(A),JA}static addIdentifierChar(A){return JA.additional_identifier_chars.add(A),JA}static addLiteral(A,I){return JA.literals[A]=I,JA}static removeUnaryOp(A){return delete JA.unary_ops[A],A.length===JA.max_unop_len&&(JA.max_unop_len=JA.getMaxKeyLen(JA.unary_ops)),JA}static removeAllUnaryOps(){return JA.unary_ops={},JA.max_unop_len=0,JA}static removeIdentifierChar(A){return JA.additional_identifier_chars.delete(A),JA}static removeBinaryOp(A){return delete JA.binary_ops[A],A.length===JA.max_binop_len&&(JA.max_binop_len=JA.getMaxKeyLen(JA.binary_ops)),JA.right_associative.delete(A),JA}static removeAllBinaryOps(){return JA.binary_ops={},JA.max_binop_len=0,JA}static removeLiteral(A){return delete JA.literals[A],JA}static removeAllLiterals(){return JA.literals={},JA}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(A){this.expr=A,this.index=0}static parse(A){return new JA(A).parse()}static getMaxKeyLen(A){return Math.max(0,...Object.keys(A).map(I=>I.length))}static isDecimalDigit(A){return A>=48&&A<=57}static binaryPrecedence(A){return JA.binary_ops[A]||0}static isIdentifierStart(A){return A>=65&&A<=90||A>=97&&A<=122||A>=128&&!JA.binary_ops[String.fromCharCode(A)]||JA.additional_identifier_chars.has(String.fromCharCode(A))}static isIdentifierPart(A){return JA.isIdentifierStart(A)||JA.isDecimalDigit(A)}throwError(A){let I=new Error(A+" at character "+this.index);throw I.index=this.index,I.description=A,I}runHook(A,I){if(JA.hooks[A]){let e={context:this,node:I};return JA.hooks.run(A,e),e.node}return I}searchHook(A){if(JA.hooks[A]){let I={context:this};return JA.hooks[A].find(function(e){return e.call(I.context,I),I.node}),I.node}}gobbleSpaces(){let A=this.code;for(;A===JA.SPACE_CODE||A===JA.TAB_CODE||A===JA.LF_CODE||A===JA.CR_CODE;)A=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let A=this.gobbleExpressions(),I=A.length===1?A[0]:{type:JA.COMPOUND,body:A};return this.runHook("after-all",I)}gobbleExpressions(A){let I=[],e,i;for(;this.index0;){if(JA.binary_ops.hasOwnProperty(A)&&(!JA.isIdentifierStart(this.code)||this.index+A.lengtht.right_a&&r.right_a?e>r.prec:e<=r.prec;for(;i.length>2&&s(i[i.length-2]);)o=i.pop(),I=i.pop().value,C=i.pop(),A={type:JA.BINARY_EXP,operator:I,left:C,right:o},i.push(A);A=this.gobbleToken(),A||this.throwError("Expected expression after "+a),i.push(t,A)}for(B=i.length-1,A=i[B];B>1;)A={type:JA.BINARY_EXP,operator:i[B-1].value,left:i[B-2],right:A},B-=2;return A}gobbleToken(){let A,I,e,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(A=this.code,JA.isDecimalDigit(A)||A===JA.PERIOD_CODE)return this.gobbleNumericLiteral();if(A===JA.SQUOTE_CODE||A===JA.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(A===JA.OBRACK_CODE)i=this.gobbleArray();else{for(I=this.expr.substr(this.index,JA.max_unop_len),e=I.length;e>0;){if(JA.unary_ops.hasOwnProperty(I)&&(!JA.isIdentifierStart(this.code)||this.index+I.length=I.length&&this.throwError("Unexpected token "+String.fromCharCode(A));break}else if(t===JA.COMMA_CODE){if(this.index++,i++,i!==I.length){if(A===JA.CPAREN_CODE)this.throwError("Unexpected token ,");else if(A===JA.CBRACK_CODE)for(let C=I.length;C":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"});JA.max_unop_len=JA.getMaxKeyLen(JA.unary_ops);JA.max_binop_len=JA.getMaxKeyLen(JA.binary_ops);var LQ=g=>new JA(g).parse(),FV=Object.getOwnPropertyNames(JA);FV.forEach(g=>{LQ[g]===void 0&&g!=="prototype"&&(LQ[g]=JA[g])});LQ.Jsep=JA;var RV="ConditionalExpression",KV={name:"ternary",init(g){g.hooks.add("after-expression",function(A){if(A.node&&this.code===g.QUMARK_CODE){this.index++;let I=A.node,e=this.gobbleExpression();if(e||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===g.COLON_CODE){this.index++;let i=this.gobbleExpression();if(i||this.throwError("Expected expression"),A.node={type:RV,test:I,consequent:e,alternate:i},I.operator&&g.binary_ops[I.operator]<=.9){let t=I;for(;t.right.operator&&g.binary_ops[t.right.operator]<=.9;)t=t.right;A.node.test=t.right,t.right=A.node,A.node=I}}else this.throwError("Expected :")}})}};LQ.plugins.register(KV);var JV=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],vV=["0","1","2","3","4","5","6","7","8","9","."],qV=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function LV(g){return typeof g!="string"?!1:!isNaN(g)&&!isNaN(parseFloat(g))}LQ.addBinaryOp("^",11,!0);function CK(g,A,I="number"){let e="";for(let C=0;C0&&"id"in B){console.error("Two variables in a row",g);return}let a=A.getVariable(o.id),s=Jt.getDisplayedValue(a);I==="number"&&Jt.isTextValue(a)&&Array.isArray(a.textValue)&&a.textValue.length===1?s=parseFloat(s).toString():I==="boolean"&&Jt.isBoolean(a)?s=a?"true":"false":I==="boolean"&&Jt.isTextValue(a)&&!Array.isArray(a.textValue)&&(s='"'+s+'"'),e+=s;continue}else if(I==="string"){o.name!=='"'&&o.name!=="+"&&(e+=o.name),o.name==="+"&&e[e.length-1]==="\\"&&(e=e.slice(0,-1)+o.name);continue}if(o.name==="and"){e+="&&";continue}if(o.name==="or"){e+="||";continue}if(o.name==="True"){e+="true";continue}if(o.name==="False"){e+="false";continue}if(I==="boolean"&&!LV(o.name)&&!vV.includes(o.name)&&!JV.includes(o.name)&&!qV.includes(o.name.replace(/\($/g,""))){e+='"'+o.name+'"';continue}e+=o.name}if(I==="string")return e;if(g.length===0){if(I==="number")return 0;if(I==="boolean")return!1}let i;try{i=LQ(e)}catch(C){console.error(e,C);return}let t;try{t=KI(i)}catch(C){console.error(e,i,C)}return t}function KI(g){switch(g.type){case"BinaryExpression":switch(g.operator){case"==":return+(KI(g.left)===KI(g.right));case"!=":return+(KI(g.left)!==KI(g.right));case">":return+(KI(g.left)>KI(g.right));case">=":return+(KI(g.left)>=KI(g.right));case"<":return+(KI(g.left)=1)try{A=KI(g.arguments[0])}catch(e){console.warn(e)}if(g.arguments.length>=2)try{I=KI(g.arguments[1])}catch(e){console.warn(e)}return A=Math.min(I,A),I=Math.max(I,A),A+Math.random()*(I-A)}return Math[g.callee.name].apply(null,g.arguments.map(KI))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+g.type)}}var bV=new zA,YV=new zA;function xV(g,A,I){let e=[new J,new J,new J],i=[new J,new J,new J];return g.extractBasis(e[0],e[1],e[2]),A.extractBasis(i[0],i[1],i[2]),e.forEach((t,C)=>{let o=i[C],B=vg.lerp(t.length(),o.length(),I);t.lerp(o,I).setLength(B)}),new zA().makeBasis(e[0],e[1],e[2])}var HV=class{static create(g){return this.build(this.normalizeInputs(g))}static normalizeInputs(g,A){let I=Object.assign({},(A==null?void 0:A.parameters)??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},g.parameters),e=Math.abs(I.width),i=Math.abs(I.height??I.width),t=Math.abs(I.depth??0),C=(A==null?void 0:A.shapeData)??v0.create({parameters:mR}).userData.shape;return{path:g.path??Hc.defaultData(),parameters:Object.assign(I,{width:e,height:i,depth:t,extrusion:{...UR,...I.extrusion}}),shapeData:C}}static build(g){if(g.path.points.length>=2){let A=new TV(g);return Object.assign(A,{userData:{...g,type:"PathGeometry"}})}else return Object.assign(new bg,{userData:{...g,type:"PathGeometry"}})}},TV=class extends bg{constructor(g){super(),this.type="PathExtrusionGeometry",this.inputs=g,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let g=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&g.depth===1)||!MV(g.twist,0)||g.startScale!==g.endScale}build(){let g=this._extractPathPoints();if(g.length<2)return;let A=this._computeBasisMatrices(g),{depth:I,offset:e}=this.inputs.parameters.extrusion,i=this.inputs.path.isClosed?g.length:g.length-1,t=Math.floor(e*i),C=this.inputs.path.isClosed?Math.ceil((I+e)*i):Math.ceil(Math.min(1,I+e)*i),o=Math.min(Math.max(2,C-t+1),i+2),B=[],a=[];for(let AA=0;AA{B[AA]=B[AA].clone().lerp(B[BA],iA),a[AA]=xV(a[AA],a[BA],iA)},r=0,Q=e*i%1;(!this.inputs.path.isClosed||I<=1)&&(Q||e===0)&&(r=Q,s(0,1,r));let E=0,n=(e+I)*i%1;if((this.inputs.path.isClosed&&I<=1||!this.inputs.path.isClosed&&e+I<1)&&n&&(E=n,s(B.length-1,B.length-2,1-E)),I===0){let AA=B.length-1;B[AA].copy(B[0]),a[AA].copy(a[0])}this._applyPathModifiers(a,r,E);let{bevel:h,bevelSides:l}=this.inputs.parameters.extrusion,c=h>0?this.inputs.parameters.extrusion.capType:"flat",d=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(d=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:u,infos:y,vertices:f}=this._computeShapePoints(d),k=0,M;c==="round"&&(M=new J0(this.inputs.shapeData,2*h,h,d,l,void 0,!0),k=M.getAttribute("position").count);let G=0,v=0;y.sort((AA,BA)=>AA.start-BA.start),y.forEach(AA=>{AA.verticesStart=G,AA.verticesCount=AA.continuous.reduce((BA,iA,rA)=>BA+(rA===0||!iA?2:1),0),v+=AA.verticesCount,G=v});let N=v*o,b,O=0;if(this._isOpenEnded()&&c==="flat"){try{b=Ea({windingRule:jI.ODD,elementType:Pe.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:u})}catch{b=WR}O=b.vertexCount}let H=N+2*O+k*2,_=N+2*O,gA={positions:new Float32Array(H*3),normals:new Float32Array(H*3),uvs:new Float32Array(H*2)},CA=[];if(y.forEach(AA=>{this._extrudeRegion(AA,f,a,B,gA,CA,this._isGeometryClosed()&&!this._isOpenEnded())}),b&&(this._closeEnd(b,N,CA,gA,a[0],B[0],!1),this._closeEnd(b,N+O,CA,gA,a[a.length-1],B[B.length-1],!0)),M){gA.positions.set(M.getAttribute("position").array,_*3),gA.normals.set(M.getAttribute("normal").array,_*3),gA.uvs.set(M.getAttribute("uv").array,_*2);let AA=CA.length;CA.push(...M.getIndex().array.map(rA=>rA+_)),_+=k,gA.positions.set(M.getAttribute("position").array,_*3),gA.normals.set(M.getAttribute("normal").array,_*3),gA.uvs.set(M.getAttribute("uv").array,_*2);let BA=CA.length;CA.push(...M.getIndex().array.map(rA=>rA+_)),this.setAttribute("position",new zg(gA.positions,3)),this.setAttribute("normal",new zg(gA.normals,3)),this.setAttribute("uv",new zg(gA.uvs,2)),this.setIndex(CA);let iA=bV;iA.copy(a[a.length-1]).setPosition(B[B.length-1]),this.applyMatrix4OnRange(iA,_,H),iA.copy(a[0]).setPosition(B[0]).multiply(YV.makeScale(1,1,-1)),this.applyMatrix4OnRange(iA,_-k,_),this.reverseIndicesOnRange(AA,BA)}else this.setAttribute("position",new zg(gA.positions,3)),this.setAttribute("normal",new zg(gA.normals,3)),this.setAttribute("uv",new zg(gA.uvs,2)),this.setIndex(CA)}_extractPathPoints(){let g=bR(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(g.length<2)return[];let A=[g[0]];return g.forEach(I=>{A[A.length-1].distanceToSquared(I)>.001&&A.push(I)}),this.inputs.path.isClosed&&A[A.length-1].distanceTo(A[0])<.001&&A.pop(),A}_computeBasisMatrices(g){let A=[],I=g.length,e=this.inputs.path.isClosed,i=new J,t=new J,C=new J,o=new J,B=new J(0,1,0);for(let n=0;n0&&(Q*=-1);for(let n=1;n{let Q=r===0?0:r===e-1?1:(r-A)/(e-(I===0?0:1)-(A+(1-I)));B.makeRotationZ(vg.lerp(i,i+t,Q)*vg.DEG2RAD);let E=vg.lerp(C,o,Q);a.makeScale(E,E,E),s.multiply(B).multiply(a)}),g}_computeShapePoints(g=12,A=jI.ODD){let I=this.inputs.shapeData,e=I.extractShapePointsToFlatArray([],g),i=I.shapeHoles.map(a=>{let s=a.extractShapePointsToFlatArray([],g),r=[];for(let Q=s.length-1;Q>=1;Q-=2){let E=s[Q-1],n=s[Q-0];r.push(E,n)}return r}),t;try{t=Ea({windingRule:A,elementType:Pe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[e]})}catch{t=K0}let C;try{C=Ea({windingRule:jI.ODD,elementType:Pe.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...i]})}catch{C=jR}if(!t)throw new Error("error generating geometry");let o=t.elementCount;if(C){t.elementCount+=C.elementCount;for(let a=0;a=0;a--){let s=a>=o,r=a*2,Q=t.elements[r+0],E=t.elements[r+1],n=Q+E,h={start:Q,count:E,normals:[],isHole:s,continuous:[],verticesStart:0,verticesCount:0};B.push(h);let l=Q,c=n-1,d=Q+1,u=I.roundedCurves.length;do{let y=l-Q;t.vertices[c*2+0],t.vertices[c*2+1];let f=t.vertices[l*2+0],k=t.vertices[l*2+1],M=t.vertices[d*2+0],G=t.vertices[d*2+1],v=f-M,N=k-G,b=Math.sqrt(v*v+N*N);v/=b,N/=b,h.normals[y*2+0]=-N,h.normals[y*2+1]=v;let O=t.vertexIndices[l];if(Array.isArray(O))h.continuous[y]=!1;else{let[H,_]=I.getCurveIndexFromVertexId(O-1,!0);if(_>0&&_<1)h.continuous[y]=!0;else{let gA=_===1?H+1:H-1;gA=(gA+u)%u;let CA=_===1?0:1,AA=I.roundedCurves[H].getTangent(_),BA=I.roundedCurves[gA].getTangent(CA);h.continuous[y]=AA.dot(BA)>.95}}s&&(h.normals[y*2+0]*=-1,h.normals[y*2+1]*=-1),[c,l,d]=[l,d,d+1],d>=n&&(d-=E)}while(d!==Q+1)}return{regions:[e,...i],infos:B,vertices:t.vertices}}_insertVertex(g,A,I,e,i){let t=A*2,C=A*3;g.positions[C+0]=I.x,g.positions[C+1]=I.y,g.positions[C+2]=I.z,g.normals[C+0]=e.x,g.normals[C+1]=e.y,g.normals[C+2]=e.z,g.uvs[t+0]=i.x,g.uvs[t+1]=i.y}_extrudeRegion(g,A,I,e,i,t,C){let o=new J,B=new J,a=new J,s=new J,r=new sA;I.forEach((E,n)=>{let h=e[n],l=g.verticesStart*I.length+g.verticesCount*n;for(let c=0;c{this.update(g),A==null||A.requestRender()})}async updateFont(g,A){let I=A.getFont(g);I&&(this.font=I,await I.loadingPromise)}update(g){let A=this.font;if(this.userData={parameters:g,type:"TextGeometry"},!(A!=null&&A.isLoaded)){console.warn("Cannot update text because its font is not loaded");return}let{width:I,height:e,depth:i,extrudeBevelSize:t,extrudeBevelSegments:C,text:o,textTransform:B}=g,a=Jt.getDisplayedValue(o),s=B===2?a.toUpperCase():B===3?a.toLowerCase():a,r=jV(g,A,s),{shapes:Q,charWidths:E,charCoords:n}=A.generateShapes(r,g),h=(typeof I=="number"?I:1)*.5,l=(typeof e=="number"?e:1)*.5,c=Q.map(y=>new fe().fromShape(y,!0));this.vectorShapes=c;let d=c.map(y=>Or.create({shape:y,parameters:{depth:i,extrudeBevelSegments:C,extrudeBevelSize:t,windingRule:i<=0?jI.NONZERO:jI.ODD,subdivisions:this.isLowResolution&&i>0?PV:_V}})),u=d.length?Dr(d):oK();u.translate(-h,l,0),this.dispose(),this.wrappedText=r,this.charCoords=n,this.charWidths=E,this.deleteAttribute("extrudeNormal"),Object.entries(u.attributes).forEach(([y,f])=>{this.setAttribute(y,f)}),this.setIndex(u.index),this.computeBoundingSphere()}clone(){let g=SB(new bg,BK.prototype);return g.copy(this),console.log("CloneGeometry",this,g),g}copy(g){return Object.entries(g.attributes).forEach(([A,I])=>{this.setAttribute(A,I)}),this.setIndex(g.index),this.userData={parameters:{...g.userData.parameters},type:"TextGeometry"},this}async setText(g){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:g})}get text(){return this.userData.parameters.text??""}};function jV(g,A,I){let e=[""],i="";for(let t of I)i+=t,t===" "||t===` +`?(e[e.length-1]+=i,i="",t===` +`&&e.push("")):A.getTextWidth(e[e.length-1]+i,g)>g.width&&(e[e.length-1].length&&e.push(""),A.getTextWidth(e[e.length-1]+i,g)>g.width&&(i.length===1?(e[e.length-1]+=i,i=""):(e[e.length-1]+=i.slice(0,-1),i=i[i.length-1],e.push(""))));return e[e.length-1]+=i,e}var aK,q0=new Promise(g=>{aK=g}),qM=!1,yl;function WV(){if(qM)return;if(yl)return yl;async function g(){let A="https://unpkg.com/@splinetool/modelling-wasm@0.9.483/build",I=Zn(()=>Promise.resolve().then(()=>gIA),void 0),[e,i]=await Promise.all([I,fetch(`${A}/process.wasm`).then(o=>o.arrayBuffer())]),t=e.default,C=await t({wasmBinary:i});aK(C),qM=!0}return yl=g(),yl}function AD(g,A,I,e){var a;let i,t,C;g.type==="PathGeometry"?(t=JSON.parse(JSON.stringify(g)),C=[[],["extrusion"]]):(t={...g},C=[[]]);for(let s of C){let r=t;for(let Q of s)r=r[Q];for(i in r){let Q=r[i];WW(Q)&&(r[i]=A.getVariable(Q,[e.uuid,"geometry",...s,i]))}}let o={parameters:t,type:t.type};if(t.type==="PathGeometry")o.path=t.path;else if(t.type==="VectorGeometry"){let s=fe.createFromState(t.shape,t.width,t.height);o.shape=s}else if(t.type==="NonParametricGeometry")t.data.groups&&((a=t.data.groups)==null||a.forEach(s=>s.materialIndex=Math.max(s.materialIndex??0,0))),o.geometry=new rF().parse(t);else if(t.type==="SubdivGeometry"){let s=new Pi(t,I);return s.data=g,s}else if(t.type==="TextGeometry")return new BK(t,A);let B;try{B=HM(o)}catch(s){console.error(s)}if(!B){let s=fe.createFromState(xc.defaultData(),100,100);o.shape=s,B=HM(o)}return B}var ZV=new zA;function Wy(g,A,I,e){let i=g.position.array,t=g.normal.array,C=ZV.makeScale(A,I,e).invert().elements,o,B,a;for(var s=0,r=i.length;s{Hg=g});var LM=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bM=new Uint32Array([0,1,2,3]),YM=new Uint8Array([4]),Pi=class extends bg{constructor(A,I){super(),this.data=A,this.flatShading=I,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(A,I){this.freeSubdivPointer();let e=this.data.scaleBaked,i=Gr.div(I,e);this.subdividedGeometry&&Wy(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Wy(this.originalGeometry.attributes,...i),this.data=A;let t=this.userData.parameters;this.userData.parameters={width:t.width*i[0],height:t.height*i[1],depth:t.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Rs.fromArray(i));let C=Rs.set(t.width,t.height,t.depth).length();this.originalGeometry.boundingSphere.radius=C/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let A,I,e;try{({originalGeometry:A,subdividedGeometry:I,subdivPointer:e}=Pi.build(this.data,void 0,!this.flatShading,void 0))}catch{A=new Go(100,100,100),e=0}this.subdivPointer=e,this.originalGeometry=A,this.subdividedGeometry=I??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Pi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new ct,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let I=A.attributes.position,e=A.boundingSphere.center;wl.setFromBufferAttribute(I),wl.getCenter(e),A.boundingSphere.radius=e.distanceTo(wl.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),wl.getSize(Rs);let i={width:Rs.x,height:Rs.y,depth:Rs.z};return this.userData.parameters=i,i}static build(A,I,e,i){let t,C,o,B=(A==null?void 0:A.phongAngle)??35;e===!1&&(B=-1),I&&(Hg.free_bvh(I),Hg.free_subdivision_surface(I));try{t=Pi.allocate(A,i)}catch(a){console.error(a,A),t=Pi.allocate({positionWASM:LM,indexWASM:bM,verticesPerFaceWASM:YM},i)}if(Hg.set_destination_refinement_level(t,0),C=Pi.buildLevel(t,!0,B),A.subdivisions>0)try{Hg.set_destination_refinement_level(t,A.subdivisions),o=Pi.buildLevel(t,!1,B)}catch{try{Hg.set_destination_refinement_level(t,A.subdivisions-1),o=Pi.buildLevel(t,!1,B)}catch{o=null}}else o=null;return{subdivPointer:t,originalGeometry:C,subdividedGeometry:o}}static primitiveToQuads(A,I,e){A.widthSegments>16&&(A.widthSegments=16),A.heightSegments>16&&(A.heightSegments=16),A.depthSegments>16&&(A.depthSegments=16),A.radialSegments>16&&(A.radialSegments=16),A.type==="DodecahedronGeometry"&&(A.detail=0);let i=A.shape!==void 0||A.path!==void 0?I.geometry:AD(A,e,!1),t;A.type==="TorusGeometry"&&A.arc===Math.PI*2?t=i.getClosedTorusIndicesForBooleanOrSubdiv():t=i.getIndex();let C,o,B,a;({positions:C,triIndices:a}=zD(i.getAttribute("position"),t));let s;if(A.type==="CylinderGeometry"&&A.cornerRadius===0&&A.hollow===0&&A.openEnded===!1){let r=A.radialSegments*A.heightSegments*3*2,Q=r+A.radialSegments*3;s=[r,Q]}return{indices:o,verticesPerFace:B}=rK(C,a,i,s),{positions:C,indices:o,verticesPerFace:B}}static allocate(A,I){var y;let e,i,t,C=[],o=[];A.positionWASM&&A.positionWASM.length>0?(e=A.positionWASM,i=A.indexWASM,t=A.verticesPerFaceWASM):(e=LM,i=bM,t=YM);let B=e.length,a=i.length,s=t.length,r=e.length+C.length+o.length,Q=i.length+t.length,E=r*Float32Array.BYTES_PER_ELEMENT+Q*Uint32Array.BYTES_PER_ELEMENT,n=r*Float32Array.BYTES_PER_ELEMENT,h=Hg._malloc(E),l=new Float32Array(Hg.HEAPF32.buffer,h,r),c=new Uint32Array(Hg.HEAPU32.buffer,h+n,Q);l.set(e,0),l.set(C,e.length),l.set(o,e.length+C.length),c.set(i,0),c.set(t,i.length);let d;(y=A==null?void 0:A.scaleBaked)!=null&&y.some(f=>f!==1)&&(d=new zA().makeScale(...A.scaleBaked)),I&&(d?d.premultiply(I):d=I);let u=d?Hg.alloc_subdivision_surface2(h,B,h+n,a,h+n+i.length*Uint32Array.BYTES_PER_ELEMENT,s,d.elements):Hg.alloc_subdivision_surface(h,B,h+n,a,h+n+i.length*Uint32Array.BYTES_PER_ELEMENT,s);return Hg._free(h),u}static buildLevel(A,I,e,i,t){let C=t?Hg.get_mesh_data2(A,I?Hg.Level.CONTROL:Hg.Level.REFINED,e,t.elements):Hg.get_mesh_data(A,I?Hg.Level.CONTROL:Hg.Level.REFINED,e),o=8,B=Hg.HEAPU32.subarray(C>>2,(C>>2)+o),a=B.subarray(4,4+4),s=0,r=Hg.HEAPU32[B[s]>>2],Q=Hg.HEAPF32.subarray(r>>2,(r>>2)+a[s]);s++;let E=Hg.HEAPU32[B[s]>>2],n=Hg.HEAPF32.subarray(E>>2,(E>>2)+a[s]);s++;let h=Hg.HEAPU32[B[s]>>2],l=Hg.HEAPU32.subarray(h>>2,(h>>2)+a[s]);s++;let c=Hg.HEAPU32[B[s]>>2],d=Hg.HEAPU32.subarray(c>>2,(c>>2)+a[s]);if(s++,i===void 0){let u=new bg;if(u.setIndex(new BQ(d,1)),u.setAttribute("position",new pg(Q,3)),u.setAttribute("normal",new pg(n,3)),I){u.setAttribute("faceMap",new BQ(l,1));let y=new Float32Array(n.length/3*4).fill(0);u.setAttribute("color",new zg(y,4))}return Hg.free_mesh_data(C),u.userData.type="SubdivGeometry",u}i.getAttribute("position").copyArray(Q),i.getAttribute("normal").copyArray(n),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Hg.free_mesh_data(C)}static freeSubdivPointer(A){Hg.free_bvh(A),Hg.free_subdivision_surface(A)}static buildControlCageWireframe(A,I,e){let i=Hg.get_wireframe_data_for_base_level(A),t=4,C=Hg.HEAPU32.subarray(i>>2,(i>>2)+t),o=C.subarray(2,2+2),B=0,a=Hg.HEAPU32[C[B]>>2],s=Hg.HEAPF32.subarray(a>>2,(a>>2)+o[B]);B++;let r=Hg.HEAPU32[C[B]>>2],Q=Hg.HEAPU32.subarray(r>>2,(r>>2)+o[B]);if(I===void 0){let E=new bg;E.setAttribute("position",new pg(s,3));let n=new Float32Array(s.length);for(let h=0,l=s.length;h>2,(t>>2)+C),B=o.subarray(3,3+3),a=0,s=Hg.HEAPU32[o[a]>>2],r=new Float32Array(Hg.HEAPF32.subarray(s>>2,(s>>2)+B[a]));a++;let Q=Hg.HEAPU32[o[a]>>2],E=new Uint32Array(Hg.HEAPU32.subarray(Q>>2,(Q>>2)+B[a]));a++;let n=Hg.HEAPU32[o[a]>>2],h=new Uint8Array(Hg.HEAPU32.subarray(n>>2,(n>>2)+B[a]));return Hg.free_topological_data(t),{positions:r,indices:E,verticesPerFace:h}}},xM=["getX","getY","getZ"];function zD(g,A){let I={},e=A?A.count:g.count,i=0,t=[],C=[],o=1e4;for(let a=0;a=360){let Q=B.length/2/a;B=B.filter((E,n)=>Math.floor(n/2)%Q===0)}let s=0;for(let Q=0;Q=0;Q-=2)g.push(B[Q],B[Q+1],0),i.push(r++);return t.push(r),{indices:i,verticesPerFace:t}}let C=new Float32Array([I.userData.parameters.depth])[0],o=0;for(;o.005||e&&e.some((a,s)=>s%2===1?!1:o>=e[s]&&oAz,calcBooleanTopological:()=>$V,freeMeshSet:()=>iz,getMeshSet:()=>gz,hasOpenEdges:()=>Iz,transformMeshSet:()=>ez});var sK,VV=new Promise(g=>{sK=g}),fl;function zV(){if(fl)return fl;async function g(){let A="https://unpkg.com/@splinetool/boolean-wasm@0.9.483/build",I=Zn(()=>Promise.resolve().then(()=>eIA),void 0),[e,i]=await Promise.all([I,fetch(`${A}/boolean.wasm`).then(o=>o.arrayBuffer())]),t=e.default,C=await t({wasmBinary:i});sK(C)}return fl=g(),fl}var yI,DQ;VV.then(g=>yI=g);function XV(g,A,I){let e,i;g.userData.parameters.type==="TorusGeometry"&&g.userData.parameters.arc===Math.PI*2?i=g.getClosedTorusIndicesForBooleanOrSubdiv():i=g.getIndex();let{positions:t,triIndices:C}=zD(g.getAttribute("position"),i),o;if(A&&I){let{indices:B,verticesPerFace:a}=rK(t,C,g);o=a.length,e=[];for(let s=0,r=0;s>2,(e>>2)+i),C=t.subarray(3,3+3),o=0,B=yI.HEAPU32[t[o]>>2],a=new Float32Array(yI.HEAPF32.subarray(B>>2,(B>>2)+C[o]));o++;let s=yI.HEAPU32[t[o]>>2],r=new Uint32Array(yI.HEAPU32.subarray(s>>2,(s>>2)+C[o]));o++;let Q=yI.HEAPU32[t[o]>>2],E=new Uint8Array(yI.HEAPU32.subarray(Q>>2,(Q>>2)+C[o]));return yI.free_mesh_data(e),{positions:a,indices:r,verticesPerFace:E}}function Az(g,A,I,e){DQ===void 0&&(DQ=yI.init_csg());let i=QK(g),t=yI.csg_calc(DQ,i,g.length,e,EK(A));yI._free(i);let C=5,o=yI.HEAPU32.subarray(t>>2,(t>>2)+C),B=o.subarray(2,2+3),a=0,s=yI.HEAPU32[o[a]>>2],r=yI.HEAPF32.subarray(s>>2,(s>>2)+B[a]);a++;let Q=yI.HEAPU32[o[a]>>2],E=yI.HEAPF32.subarray(Q>>2,(Q>>2)+B[a]);a++;let n=B[a];I.setAttribute("position",new pg(r,3)),I.setAttribute("normal",new pg(E,3));let h=yI.HEAPF32.subarray((t>>2)+5,(t>>2)+5+6);return I.boundingSphere===null&&(I.boundingSphere=new ct),I.boundingSphere.radius=-1,I.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},yI.free_mesh_data(t),n}function gz(g,A,I){if(yI===void 0)return-1;let e,i,t;if(A&&g.userData.positions!==void 0){let h=g.userData;t=h.verticesPerFace.length,e=h.positions,i=Array(h.verticesPerFace.reduce((l,c)=>l+c,0)+t);for(let l=0,c=0,d=0;ltz[g.type].create(g);function Ks(g){return g!==null&&"booleanOp"in g}var nK=class extends U0(Qt){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new zA}updateVisible(){super.updateVisible(),this.visible=!Ks(this.parent)&&this.visible,Ks(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(aB.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(g=!1){return g?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ks(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let g of this.children)g instanceof nK&&(g.freeBooleanPointer(),Ks(g)&&g.invalidateUpstreamBooleanData())}updateTransformState(g,A){let I=super.updateTransformState(g,A);return I&&Ks(this.parent)&&this.invalidateDownstreamBooleanData(!0),I}onVariableUpdate(g=!1){super.onVariableUpdate(g),Ks(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Gl=new ve;function L0(g,A=0,I=g.count,e,i){let t=1/0,C=1/0,o=1/0,B=-1/0,a=-1/0,s=-1/0;for(let r=A;rB&&(B=Q),E>a&&(a=E),n>s&&(s=n)}Gl.min.set(t,C,o),Gl.max.set(B,a,s),Gl.getCenter(e),Gl.getSize(i).multiplyScalar(.5)}var Cz=new bg,oz=new Xn,Dt=class extends nK{constructor(A,I){super(Cz,oz),this.super_Entity(A,I)}updateState(A,I){this.updateState_Entity(A,I)}updateEntityBoxSize(A,I){let e=this.geometry.getAttribute("position");e!==void 0?L0(e,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:e.count,A,I):super.updateEntityBoxSize(A,I)}},TM=class{constructor(g){g=g??{},this.name=g.name,this.type=g.type,this.node=g.node,this.size=g.size,this.needsUpdate=g.needsUpdate}get value(){return this.node.value}set value(g){this.node.value=g}},Ka=class{constructor(A){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=vg.generateUUID(),this.type=A,this.name=""}analyze(A,I){I=I??{},A.analyzing=!0,this.build(A.addFlow(I.slot,I.cache,I.context),"v4"),A.clearVertexNodeCode(),A.clearFragmentNodeCode(),A.removeFlow(),A.analyzing=!1}analyzeAndFlow(A,I,e){return e=e??{},this.analyze(A,e),this.flow(A,I,e)}flow(A,I,e){e=e??{},A.addFlow(e.slot,e.cache,e.context);let i={result:this.build(A,I),code:A.clearNodeCode(),extra:A.context.extra};return A.removeFlow(),i}build(A,I,e){I=I??this.getType(A,I);let i=A.getNodeData(e??this);return A.analyzing&&this.appendDepsNode(A,i,I),A.nodes.indexOf(this)===-1&&A.nodes.push(this),this.updateFrame!==void 0&&A.updaters.indexOf(this)===-1&&A.updaters.push(this),this.generate(A,I,e)}updateFrame(A){}generateReadonly(A,I,e,i,t,C){return""}generate(A,I,e,i,t){return""}parse(A,I,e,i){}appendDepsNode(A,I,e){I.deps=(I.deps||0)+1;let i=A.getTypeLength(e);(i>(I.outputMax||0)||this.getType(A,e))&&(I.outputMax=i,I.output=e)}setName(A){this.name=A}getName(){return this.name}getType(A,I){return I==="sampler2D"||I==="samplerCube"?I:this.type}getHash(){let A="{",I,e;for(I in this)e=this[I],e instanceof Ka&&(A+='"'+I+'":'+e.getHash()+",");if(this.hashProperties)for(let i=0;i0||this.getLabel()?(this.appendDepsNode(A,C,I),this.generate(A,I,e)):super.build(A,I,e);if(t)return C.name=C.name||super.build(A,I,e),C.name;if(!this.getLabel()&&(!this.getShared(A,o)||A.context.ignoreCache||C.deps===1))return super.build(A,I,e);e=this.getUUID(!1);let B=this.getTemp(A,e);if(B)return A.format(B,o,I);{B=super.generate(A,I,e,C.output,i);let a=this.generate(A,o,e);return A.addNodeCode(B+" = "+a+";"),A.format(B,o,I)}}return super.build(A,I,e)}getShared(A,I){return I!=="sampler2D"&&I!=="samplerCube"&&this.shared}getUnique(A,I){return this.unique}setLabel(A){return this.label=A,this}getLabel(){return this.label}getUUID(A){let I=this.uuid;return typeof this.scope=="string"&&(I=this.scope+"-"+I),I}getTemp(A,I){I=I||this.uuid;let e=A.getVars()[I];return e?e.name:void 0}generate(A,I,e,i,t){return this.getShared(A,I)||console.error("TempNode is not shared"),e=e??this.uuid,A.getTempVar(e,i??this.getType(A),t,this.getLabel()).name}},dt=class extends VI{constructor(A,I){I=I??{},I.shared=I.shared!==void 0?I.shared:!1,super(A,I),this.readonly=!1}setReadonly(A){return this.readonly=A,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(A,I,e,i,t,C){e=A.getUUID(e??this.getUUID()),i=i??this.getType(A);let o=A.getNodeData(e);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(A,I,e,i,t,C):A.isShader("vertex")?(o.vertex||(o.vertex=A.createVertexUniform(i,this,t,C,this.getLabel())),A.format(o.vertex.name,i,I)):(o.fragment||(o.fragment=A.createFragmentUniform(i,this,t,C,this.getLabel())),A.format(o.fragment.name,i,I))}},wi=class extends dt{constructor(A=0,I){super("v2"),this.nodeType="Vector2",this.value=A instanceof sA?A:new sA(A,I)}get x(){return this.value.x}set x(A){this.value.x=A}get y(){return this.value.y}set y(A){this.value.y=A}generateReadonly(A,I,e,i,t,C){return A.format("vec2("+this.value.x+", "+this.value.y+")",i,I)}},Wt=class extends dt{constructor(A=0,I,e){super("v3"),this.nodeType="Vector3",this.value=A instanceof J?A:new J(A,I,e)}get x(){return this.value.x}set x(A){this.value.x=A}get y(){return this.value.y}set y(A){this.value.y=A}get z(){return this.value.z}set z(A){this.value.z=A}generateReadonly(A,I,e,i,t,C){return A.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,I)}},lt=class extends Og{constructor(A,I,e,i){super(A,I,e),this.isColorA=!0,this.a=i}setRGBA(A,I,e,i){super.setRGB(A,I,e),this.a=i}copy(A){return super.copy(A),this.a="a"in A?A.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(A,I="srgb"){let e;if(A==="transparent")return this.setRGBA(0,0,0,0),this;if(e=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(A)){let i,t=e[1],C=e[2];switch(t){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))return this.a=t==="rgba"?parseFloat(i[4]):1,super.setStyle(A,I);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(C))return this.a=t==="hsla"?parseFloat(i[4]):1,super.setStyle(A,I);break}}return super.setStyle(A,I)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(A){this.r=A}set y(A){this.g=A}set z(A){this.b=A}set w(A){this.a=A}},rB=class extends dt{constructor(A){super("v4"),this.nodeType="Vector4",this.value=A instanceof lt?A:new lt(A.r,A.g,A.b,A.a)}generateReadonly(A,I,e,i,t,C){return A.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,I)}},az=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,OM=/[a-z_0-9]+/gi,rg=class extends VI{constructor(A,I,e,i,t){super(t),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=t===void 0,this.isInterface=!1,this.parse(A,I,e,i)}getShared(A,I){return!this.isMethod}getType(A){return A.getTypeByFormat(this.type)}getInputByName(A){if(this.inputs){let I=this.inputs.length;for(;I--;)if(this.inputs[I].name===A)return this.inputs[I]}}getIncludeByName(A){if(this.includes){let I=this.includes.length;for(;I--;)if(this.includes[I].name===A)return this.includes[I]}}generate(A,I,e,i,t){let C,o=0,B=this.src;if(this.includes)for(let s=0;s1?(C=B[1],t=B[2],o=B[3]):(t=this.src,C="f"),this.name=t,this.type=C,this.value=o}build(g,A){if(A==="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 g.include(this),g.format(this.name,this.getType(g),A)}generate(g,A,I,e,i){return g.format(this.name,this.getType(g),A)}},PI=hK;PI.PI="PI",PI.PI2="PI2",PI.RECIPROCAL_PI="RECIPROCAL_PI",PI.RECIPROCAL_PI2="RECIPROCAL_PI2",PI.LOG2="LOG2",PI.EPSILON="EPSILON";var sz=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.| +)*?)}`,"gim"),Qz=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),lK=class extends VI{constructor(g=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(g)}getType(g){return g.getTypeByFormat(this.name)}getInputByName(g){let A=this.inputs.length;for(;A--;)if(this.inputs[A].name===g)return this.inputs[A]}generate(g,A,I,e,i){return A==="source"?this.src+";":g.format("( "+this.src+" )",this.getType(g),A)}parse(g=""){this.src=g,this.inputs=[];let A=sz.exec(g);if(A){let I=A[2],e;for(;e=Qz.exec(I);)this.inputs.push({type:e[1],name:e[2]});this.name=A[1]}else this.name="";this.type=this.name}},b0=class extends VI{constructor(g){super("v2",{shared:!1}),this.nodeType="UV",this.index=g??0}generate(g,A){g.requires.uv[this.index]=!0;let I=this.index>0?this.index+1:"",e=g.isShader("vertex")?"uv"+I:"vUv"+I;return g.format(e,this.getType(g),A)}};st.addKeyword("uv",function(){return new b0});st.addKeyword("uv2",function(){return new b0(1)});var Vs=class extends VI{constructor(g,A){super("v4"),this.nodeType="ColorSpace",this.input=g,this.method=A??Vs.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(g){switch(g){case fo:return["Linear"];case sI:return["sRGB"];default:return[]}}generate(g,A){var C;let I=this.input.build(g,"v4"),e=this.getType(g),i=Vs.Nodes[this.method],t=g.include(i);if(t===Vs.LINEAR_TO_LINEAR)return g.format(I,e,A);if(((C=i.inputs)==null?void 0:C.length)===2){let o=this.factor.build(g,"f");return g.format(t+"( "+I+", "+o+" )",e,A)}else return g.format(t+"( "+I+" )",e,A)}fromEncoding(g){let A=Vs.getEncodingComponents(g);this.method="LinearTo"+A[0],this.factor=A[1]}fromDecoding(g){let A=Vs.getEncodingComponents(g);this.method=A[0]+"ToLinear",this.factor=A[1]}},uo=Vs;uo.Nodes={LinearToLinear:new rg(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(` +`)),sRGBToLinear:new rg(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(` +`)),LinearTosRGB:new rg(["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(` +`))},uo.LINEAR_TO_LINEAR="LinearToLinear",uo.SRGB_TO_LINEAR="sRGBToLinear",uo.LINEAR_TO_SRGB="LinearTosRGB";var se=class extends rg{constructor(A="",I,e,i,t){super(A,t,i,e,I),this.nodeType="Expression"}},nB=class extends dt{constructor(A=new ti,I,e,i){super("v4",{shared:!0}),this.nodeType="Texture",this.value=A,this.uv=I??new b0,this.bias=e,this.project=i!==void 0?i:!1}getTexture(A,I){return super.generate(A,I,this.value.uuid,"t")}generate(A,I){if(I==="sampler2D")return this.getTexture(A,I);let e=this.getTexture(A,I),i=this.uv.build(A,this.project?"v4":"v2"),t=this.bias?this.bias.build(A,"f"):void 0;t===void 0&&A.context.bias&&(t=A.context.bias.setTexture(this).build(A,"f"));let C,o;this.project?C="texture2DProj":C=t?"tex2DBias":"tex2D",t?o=C+"( "+e+", "+i+", "+t+" )":o=C+"( "+e+", "+i+" )";let B={include:A.isShader("vertex"),ignoreCache:!0},a=this.getType(A);return A.addContext(B),this.colorSpace=this.colorSpace??new uo(new se("",a)),this.colorSpace.fromDecoding(A.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(o),o=this.colorSpace.build(A,a),A.removeContext(),A.format(o,a,I)}},yg=class extends dt{constructor(A){super("f"),this.nodeType="Float",this.value=A??0}generateReadonly(A,I,e,i,t,C){return A.format(this.value+(this.value%1?"":".0"),i,I)}},_M=class extends VI{constructor(g,A){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=g,this.inputs=A??[]}getFunction(){return this.value}getType(g){return this.value.getType(g)}generate(g,A,I,e,i){e=this.getType(g);let t=this.value,C=t.build(g,A)+"( ",o=[];if(t.inputs){for(let B=0;Bg.getTypeLength(A)?I:A}generate(g,A){let I=this.getType(g);this.type=I;let e=this.a.build(g,I),i=this.b.build(g,I);return g.format("( "+e+" "+this.op+" "+i+" )",I,A)}},ot=cK;ot.ADD="+",ot.SUB="-",ot.MUL="*",ot.DIV="/";var _I=class extends VI{constructor(A,I=_I.ABS,e,i){super(),this.nodeType="Math",this.a=A,typeof I!="string"?this.b=I:i=I,typeof e!="string"?this.c=e:i=e,this.method=i,this.hashProperties=["method"]}getNumInputs(A){switch(this.method){case _I.MIX:case _I.CLAMP:case _I.REFRACT:case _I.SMOOTHSTEP:case _I.FACEFORWARD:return 3;case _I.MIN:case _I.MAX:case _I.MOD:case _I.STEP:case _I.REFLECT:case _I.DISTANCE:case _I.DOT:case _I.CROSS:case _I.POW:return 2;default:return 1}}getInputType(A){let I=A.getTypeLength(this.a.getType(A)),e=this.b?A.getTypeLength(this.b.getType(A)):0,i=this.c?A.getTypeLength(this.c.getType(A)):0;return I>e&&I>i?this.a.getType(A):e>i?this.b.getType(A):this.c.getType(A)}getType(A){switch(this.method){case _I.LENGTH:case _I.DISTANCE:case _I.DOT:return"f";case _I.CROSS:return"v3"}return this.getInputType(A)}generate(A,I){let e,i,t,C=this.a?A.getTypeLength(this.a.getType(A)):0,o=this.b?A.getTypeLength(this.b.getType(A)):0,B=this.c?A.getTypeLength(this.c.getType(A)):0,a=this.getInputType(A),s=this.getType(A);switch(this.type=s,this.method){case _I.NEGATE:return A.format("( -"+this.a.build(A,a)+" )",a,I);case _I.INVERT:return A.format("( 1.0 - "+this.a.build(A,a)+" )",a,I);case _I.CROSS:e=this.a.build(A,"v3"),i=this.b.build(A,"v3");break;case _I.STEP:e=this.a.build(A,C===1?"f":a),i=this.b.build(A,a);break;case _I.MIN:case _I.MAX:case _I.MOD:e=this.a.build(A,a),i=this.b.build(A,o===1?"f":a);break;case _I.REFRACT:e=this.a.build(A,a),i=this.b.build(A,a),t=this.c.build(A,"f");break;case _I.MIX:e=this.a.build(A,a),i=this.b.build(A,a),t=this.c.build(A,B===1?"f":a);break;default:e=this.a.build(A,a),this.b&&(i=this.b.build(A,a)),this.c&&(t=this.c.build(A,a));break}let r=[];r.push(e),i&&r.push(i),t&&r.push(t);let Q=this.getNumInputs(A);if(r.length!==Q)throw Error(`Arguments not match used in "${this.method}". Require ${Q}, currently ${r.length}.`);return A.format(this.method+"( "+r.join(", ")+" )",s,I)}},oI=_I;oI.RAD="radians",oI.DEG="degrees",oI.EXP="exp",oI.EXP2="exp2",oI.LOG="log",oI.LOG2="log2",oI.SQRT="sqrt",oI.INV_SQRT="inversesqrt",oI.FLOOR="floor",oI.CEIL="ceil",oI.NORMALIZE="normalize",oI.FRACT="fract",oI.SATURATE="saturate",oI.SIN="sin",oI.COS="cos",oI.TAN="tan",oI.ASIN="asin",oI.ACOS="acos",oI.ARCTAN="atan",oI.ABS="abs",oI.SIGN="sign",oI.LENGTH="length",oI.NEGATE="negate",oI.INVERT="invert",oI.MIN="min",oI.MAX="max",oI.MOD="mod",oI.STEP="step",oI.REFLECT="reflect",oI.DISTANCE="distance",oI.DOT="dot",oI.CROSS="cross",oI.POW="pow",oI.MIX="mix",oI.CLAMP="clamp",oI.REFRACT="refract",oI.SMOOTHSTEP="smoothstep",oI.FACEFORWARD="faceforward";var $E=class extends VI{constructor(g,A,I){super("v4"),this.nodeType="TextureCubeUV",this.value=g,this.uv=A,this.bias=I}bilinearCubeUV(g,A,I,e){let i=new _M($E.Nodes.bilinearCubeUV,[A,I,e]);this.colorSpaceTL=this.colorSpaceTL??new uo(new se("","v4")),this.colorSpaceTL.fromDecoding(g.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(i.build(g)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new uo(new se("","v4")),this.colorSpaceTR.fromDecoding(g.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(i.build(g)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new uo(new se("","v4")),this.colorSpaceBL.fromDecoding(g.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(i.build(g)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new uo(new se("","v4")),this.colorSpaceBR.fromDecoding(g.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(i.build(g)+".br");let t={include:g.isShader("vertex"),ignoreCache:!0};g.addContext(t),this.colorSpaceTLExp=new se(this.colorSpaceTL.build(g,"v4"),"v4"),this.colorSpaceTRExp=new se(this.colorSpaceTR.build(g,"v4"),"v4"),this.colorSpaceBLExp=new se(this.colorSpaceBL.build(g,"v4"),"v4"),this.colorSpaceBRExp=new se(this.colorSpaceBR.build(g,"v4"),"v4"),g.removeContext();let C=new se("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return C.keywords.cubeUV_TL=this.colorSpaceTLExp,C.keywords.cubeUV_TR=this.colorSpaceTRExp,C.keywords.cubeUV_BL=this.colorSpaceBLExp,C.keywords.cubeUV_BR=this.colorSpaceBRExp,C.keywords.cubeUV=i,C}generate(g,A){if(g.isShader("fragment")){let I=this.uv,e=this.bias||g.context.roughness,i=new _M($E.Nodes.roughnessToMip,[e]),t=new oI(i,$E.Nodes.m0,$E.Nodes.cubeUV_maxMipLevel,oI.CLAMP),C=new oI(t,oI.FLOOR),o=new oI(t,oI.FRACT),B=this.bilinearCubeUV(g,this.value,I,C),a=this.bilinearCubeUV(g,this.value,I,new ot(C,new yg(1).setReadonly(!0),ot.ADD)),s=new oI(B,a,o,oI.MIX);return g.format(s.build(g),"v4",A)}else return console.warn("TextureCubeUVNode is not compatible with "+g.shader+" shader."),g.format("vec4( 0.0 )",this.getType(g),A)}},Zy=$E;Zy.Nodes=function(){let g=new lK(`struct TextureCubeUVData { + vec4 tl; + vec4 tr; + vec4 br; + vec4 bl; + vec2 f; + }`),A=new PI("float cubeUV_maxMipLevel 8.0",!0),I=new PI("float cubeUV_minMipLevel 4.0",!0),e=new PI("float cubeUV_maxTileSize 256.0",!0),i=new PI("float cubeUV_minTileSize 16.0",!0),t=new rg(`float getFace(vec3 direction) { + vec3 absDirection = abs(direction); + float face = -1.0; + if (absDirection.x > absDirection.z) { + if (absDirection.x > absDirection.y) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if (absDirection.z > absDirection.y) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + }`);t.useKeywords=!1;let C=new rg(`vec2 getUV(vec3 direction, float face) { + vec2 uv; + if (face == 0.0) { + uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x + } else if (face == 1.0) { + uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y + } else if (face == 2.0) { + uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z + } else if (face == 3.0) { + uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x + } else if (face == 4.0) { + uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y + } else { + uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z + } + return 0.5 * (uv + 1.0); + }`);C.useKeywords=!1;let o=new rg(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) { + float face = getFace(direction); + float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0); + mipInt = max(mipInt, cubeUV_minMipLevel); + float faceSize = exp2(mipInt); + float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); + vec2 uv = getUV(direction, face) * (faceSize - 1.0); + vec2 f = fract(uv); + uv += 0.5 - f; + if (face > 2.0) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + if(mipInt < cubeUV_maxMipLevel){ + uv.y += 2.0 * cubeUV_maxTileSize; + } + uv.y += filterInt * 2.0 * cubeUV_minTileSize; + uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); + uv *= texelSize; + vec4 tl = texture2D(envMap, uv); + uv.x += texelSize; + vec4 tr = texture2D(envMap, uv); + uv.y += texelSize; + vec4 br = texture2D(envMap, uv); + uv.x -= texelSize; + vec4 bl = texture2D(envMap, uv); + return TextureCubeUVData( tl, tr, br, bl, f ); + }`,[g,t,C,A,I,e,i]);o.useKeywords=!1;let B=new PI("float r0 1.0",!0),a=new PI("float v0 0.339",!0),s=new PI("float m0 -2.0",!0),r=new PI("float r1 0.8",!0),Q=new PI("float v1 0.276",!0),E=new PI("float m1 -1.0",!0),n=new PI("float r4 0.4",!0),h=new PI("float v4 0.046",!0),l=new PI("float m4 2.0",!0),c=new PI("float r5 0.305",!0),d=new PI("float v5 0.016",!0),u=new PI("float m5 3.0",!0),y=new PI("float r6 0.21",!0),f=new PI("float v6 0.0038",!0),k=new PI("float m6 4.0",!0),M=[B,a,s,r,Q,E,n,h,l,c,d,u,y,f,k],G=new rg(`float roughnessToMip(float roughness) { + float mip = 0.0; + if (roughness >= r1) { + mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0; + } else if (roughness >= r4) { + mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1; + } else if (roughness >= r5) { + mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4; + } else if (roughness >= r6) { + mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5; + } else { + mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25 + } + return mip; + }`,M);return{bilinearCubeUV:o,roughnessToMip:G,m0:s,cubeUV_maxMipLevel:A}}();var zs=class extends VI{constructor(g){super("v3"),this.nodeType="Normal",this.scope=g??zs.VIEW}getShared(){return this.scope===zs.WORLD}build(g,A,I,e){let i=g.context[this.scope+"Normal"];return i?i.build(g,A,I,e):super.build(g,A,I)}generate(g,A,I,e,i){let t;switch(this.scope){case zs.VIEW:g.isShader("vertex")?t="transformedNormal":t="geometryNormal";break;case zs.LOCAL:g.isShader("vertex")?t="objectNormal":(g.requires.normal=!0,t="vObjectNormal");break;case zs.WORLD:g.isShader("vertex")?t="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(g.requires.worldNormal=!0,t="vWNormal");break}return g.format(t,this.getType(g),A)}},Et=zs;Et.LOCAL="local",Et.WORLD="world",Et.VIEW="view",Et.NORMAL="normal";st.addKeyword("viewNormal",function(){return new Et(Et.VIEW)});st.addKeyword("localNormal",function(){return new Et(Et.NORMAL)});st.addKeyword("worldNormal",function(){return new Et(Et.WORLD)});var oB=class extends VI{constructor(A){super("v3"),this.nodeType="Position",this.scope=A??oB.LOCAL}getType(){switch(this.scope){case oB.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case oB.LOCAL:case oB.WORLD:return!1}return!0}generate(A,I,e,i,t){let C;switch(this.scope){case oB.LOCAL:A.isShader("vertex")?C="transformed":(A.requires.position=!0,C="vPosition");break;case oB.WORLD:if(A.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";A.requires.worldPosition=!0,C="vWPosition";break;case oB.VIEW:C=A.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case oB.PROJECTION:C=A.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return A.format(C,this.getType(),I)}},mC=oB;mC.LOCAL="local",mC.WORLD="world",mC.VIEW="view",mC.PROJECTION="projection";st.addKeyword("position",function(){return new mC});st.addKeyword("worldPosition",function(){return new mC(mC.WORLD)});st.addKeyword("viewPosition",function(){return new mC(mC.VIEW)});var Bo=class extends VI{constructor(A){super("v3"),this.nodeType="Reflect",this.scope=A??Bo.CUBE}getUnique(A){return!A.context.viewNormal}getType(){switch(this.scope){case Bo.SPHERE:return"v2"}return this.type}generate(A,I){let e=this.getUnique(A);if(A.isShader("fragment")){let i;switch(this.scope){case Bo.VECTOR:{let t=new Et(Et.VIEW),C=A.context.roughness,o=t.build(A,"v3"),B=new mC(mC.VIEW).build(A,"v3"),a=C?C.build(A,"f"):void 0,s=`reflect( -normalize( ${B} ), ${o} )`;a&&(s=`normalize( mix( ${s}, ${o}, ${a} * ${a} ) )`);let r=`inverseTransformDirection( ${s}, viewMatrix )`;e?(A.addNodeCode(`vec3 reflectVec = ${r};`),i="reflectVec"):i=r;break}case Bo.CUBE:{let t=new Bo(Bo.VECTOR).build(A,"v3"),C="vec3( -"+t+".x, "+t+".yz )";e?(A.addNodeCode(`vec3 reflectCubeVec = ${C};`),i="reflectCubeVec"):i=C;break}case Bo.SPHERE:{let t="normalize( ( viewMatrix * vec4( "+new Bo(Bo.VECTOR).build(A,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";e?(A.addNodeCode(`vec2 reflectSphereVec = ${t};`),i="reflectSphereVec"):i=t;break}}return A.format(i,this.getType(),I)}else return console.warn("ReflectNode is not compatible with "+A.shader+" shader."),A.format("vec3( 0.0 )",this.type,I)}},dQ=Bo;dQ.CUBE="cube",dQ.SPHERE="sphere",dQ.VECTOR="vector";var Ez=class extends VI{constructor(g=new nB,A,I){super("v4"),this.nodeType="TextureCube",this.value=g,this.radianceNode=new Zy(this.value,A??new dQ(dQ.VECTOR),I),this.irradianceNode=new Zy(this.value,new Et(Et.WORLD),new yg(1).setReadonly(!0))}generate(g,A){return g.isShader("fragment")?(g.require("irradiance"),g.context.bias&&g.context.bias.setTexture(this.value),(g.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(g,A)):(console.warn("TextureCubeNode is not compatible with "+g.shader+" shader."),g.format("vec4( 0.0 )",this.getType(g),A))}},nz=class extends dt{constructor(g=new Yw,A,I){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=g,this.uv=A??new dQ,this.bias=I}getTexture(g,A){return super.generate(g,A,this.value.uuid,"tc")}generate(g,A){var B;if(A==="samplerCube")return this.getTexture(g,A);let I=this.getTexture(g,A),e=(B=this.uv)==null?void 0:B.build(g,"v3"),i=this.bias?this.bias.build(g,"f"):void 0;i===void 0&&g.context.bias&&(i=g.context.bias.setTexture(this).build(g,"f"));let t;i?t="texCubeBias( "+I+", "+e+", "+i+" )":t="texCube( "+I+", "+e+" )";let C={include:g.isShader("vertex"),ignoreCache:!0},o=this.getType(g);return g.addContext(C),this.colorSpace=this.colorSpace??new uo(new se("",o)),this.colorSpace.fromDecoding(g.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(t),t=this.colorSpace.build(g,o),g.removeContext(),g.format(t,o,A)}},hz=` +uniform int frameIndex; +uniform vec2 resolution; +uniform mat4 previousModelViewMatrix; +uniform mat4 previousProjectionMatrix; + +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; +`,lz=` +layout(location = 1) out vec4 gVelocity; + +uniform int frameIndex; +uniform vec2 resolution; + +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; + +const vec2 haltonSequence[16] = vec2[16]( +vec2( 0.000000,-0.333334), +vec2(-0.500000, 0.333334), +vec2( 0.500000,-0.777778), +vec2(-0.750000,-0.111112), +vec2( 0.250000, 0.555556), +vec2(-0.250000,-0.555556), +vec2( 0.750000, 0.111112), +vec2(-0.875000, 0.777778), +vec2(0.125000, -0.925926), +vec2(-0.375000, -0.259260), +vec2(0.625000, 0.407408), +vec2(-0.625000, -0.703704), +vec2(0.375000, -0.037038), +vec2(-0.125000, 0.629630), +vec2(0.875000, -0.481482), +vec2(-0.937500, 0.185186)); + +vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) { + const float goldenAngle = 2.399963f; // radians + float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount)); + float theta = float(sampleIndex) * goldenAngle + angle; + float sine = sin(theta); + float cosine = cos(theta); + return vec2(cosine, sine) * r; +} + +// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso +float getNoiseInterleavedGradient(vec2 screenPos) { + vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f); + return fract(magic.z * fract(dot(screenPos, magic.xy))); +} + +`,cz=` +// TODO: This could be generated CPU side and passed to the shader every frame +const vec2 haltonSequence[16] = vec2[16]( +vec2( 0.000000,-0.333334), +vec2(-0.500000, 0.333334), +vec2( 0.500000,-0.777778), +vec2(-0.750000,-0.111112), +vec2( 0.250000, 0.555556), +vec2(-0.250000,-0.555556), +vec2( 0.750000, 0.111112), +vec2(-0.875000, 0.777778), +vec2(0.125000, -0.925926), +vec2(-0.375000, -0.259260), +vec2(0.625000, 0.407408), +vec2(-0.625000, -0.703704), +vec2(0.375000, -0.037038), +vec2(-0.125000, 0.629630), +vec2(0.875000, -0.481482), +vec2(-0.937500, 0.185186)); + +// TODO: Pass correct view size +vec2 offset = haltonSequence[frameIndex]; +offset.x /= resolution.x; +offset.y /= resolution.y; + +vec4 currentPosition = gl_Position; +vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w); + +// We want to calculate the velocity with unjittered positions +// so that things that are not moving get a velocity = 0 +vCurrentPosition = currentPosition; +vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0); +#ifdef OUTLINE_COMPENSATION +vPreviousPosition.xy += OUTLINE_COMPENSATION; +#endif +gl_Position = currentPositionJittered; + +`,Dz=` +vec2 oldPos = vPreviousPosition.xy; + oldPos /= vPreviousPosition.w; + oldPos.xy = (oldPos.xy+1.)/2.0; + +vec2 newPos = vCurrentPosition.xy; + newPos /= vCurrentPosition.w; + newPos.xy = (newPos.xy+1.)/2.0; + +vec2 velocity = (newPos - oldPos); + +// Discard fully transparent pixels +if (gl_FragColor.a <= 0.0) discard; + +gVelocity = vec4(velocity, 0.0, 1.0); +`,PM=["x","y","z","w"],dz=["float","vec2","vec3","vec4"],uz={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},pz={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[]"},yz=class{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function g(A,I){return A.deps.length-I.deps.length}return function(A,I){let e=this.getIncludes(A,I);if(!e)return"";let i="";e=e.sort(g);for(let t=0;t","#include "].join(` +`),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(` +`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) { + accumAlpha += (1.0 - accumAlpha) * alpha; + }`,""].join(` +`)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(g,A){this.addVertexParsCode(hz),this.addFragmentParsCode(lz),this.buildShader("vertex",g),this.buildShader("fragment",A);for(let I=0;I0?I+1:"";this.addVaryCode("varying vec2 vUv"+e+";"),I>0&&this.addVertexParsCode("attribute vec2 uv"+e+";"),this.addVertexFinalCode("vUv"+e+" = uv"+e+";")}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(cz),this.addFragmentFinalCode(Dz)),this}buildShader(g,A){this.resultCode[g]=A.build(this.setShader(g),"v4")}setMaterial(g,A){return this.defines={},this}addFlow(g,A,I){return this.addSlot(g).addCache(A).addContext(I)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(g){return this.cache=g??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(g){return this.context=Object.assign({},this.context,g),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(g){return this.slot=g||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(g,A){this.fragmentVariables[g]===void 0&&(this.addFragmentCode(`${A} ${g};`),this.fragmentVariables[g]="")}addFragmentParsVariable(g,A){this.fragmentParsVariables[g]===void 0&&(this.addFragmentParsCode(`${A} ${g};`),this.fragmentParsVariables[g]="")}addVertexParsVariable(g,A){this.vertexParsVariables[g]===void 0&&(this.addVertexParsCode(`${A} ${g};`),this.vertexParsVariables[g]="")}addVertexCode(g){this.addCode(g,"vertex")}addFragmentCode(g){this.addCode(g,"fragment")}addCode(g,A){this.code[A??this.shader]+=g+` +`}addVertexNodeCode(g){this.addNodeCode(g,"vertex")}addFragmentNodeCode(g){this.addNodeCode(g,"fragment")}addNodeCode(g,A){this.nodeCode[A??this.shader]+=g+` +`}clearNodeCode(g){g=g??this.shader;let A=this.nodeCode[g];return this.nodeCode[g]="",A}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(g){this.addFinalCode(g,"vertex")}addFragmentFinalCode(g){this.addFinalCode(g,"fragment")}addFinalCode(g,A){this.finalCode[A??this.shader]+=g+` +`}addVertexParsCode(g){this.addParsCode(g,"vertex")}addFragmentParsCode(g){this.addParsCode(g,"fragment")}addParsCode(g,A){this.parsCode[A??this.shader]+=g+` +`}addVaryCode(g){this.addVertexParsCode(g),this.addFragmentParsCode(g)}isCache(g){return this.caches.indexOf(g)!==-1}isSlot(g){return this.slots.indexOf(g)!==-1}define(g,A){this.defines[g]=A===void 0?1:A}require(g){this.requires[g]=!0}isDefined(g){return this.defines[g]!==void 0}getVar(g,A,I,e="varying",i="V",t=""){let C=this.getVars(e),o=C[g];if(!o){let B=C.length;o={name:I||"node"+i+B+(t?"_"+t:""),type:A},C.push(o),C[g]=o}return o}getTempVar(g,A,I,e){return this.getVar(g,A,I,this.shader,"T",e)}getAttribute(g,A){if(!this.attributes[g]){let I=this.getVar(g,A);this.addVertexParsCode("attribute "+A+" "+g+";"),this.addVertexFinalCode(I.name+" = "+g+";"),this.attributes[g]={varying:I,name:g,type:A}}return this.attributes[g]}getCode(g){return[this.prefixCode,this.parsCode[g],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[g],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[g],"uniform"),this.getIncludesCode("consts",g),this.getIncludesCode("structs",g),this.getIncludesCode("functions",g),"void main() {",this.getVarListCode(this.getVars(g)),this.code[g],this.resultCode[g],this.finalCode[g],"}"].join(` +`)}getVarListCode(g,A){A=A??"";let I="";for(let e=0,i=g.length;e 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + }`);e=g.include(o);break;case 4:e=g.include(An.Nodes.triplanar);break;default:e=g.include(An.Nodes.uv);break}g.addFragmentVariable(this.calpha,"float");let i=[];if(i.push("normal"),i.push(this.texture.generate(g,"t")),i.push(this.textureSize.build(g,"v2")),i.push(this.crop.build(g,"f")),i.push(this.mat.build(g,"mat3")),i.push(this.size.build(g,"v2")),i.push(this.blending.build(g,"f")),i.push(this.isMask.build(g,"b")),i.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),i.push(this.alpha.build(g,"f")),i.push(this.mode.build(g,"i")),i.push(this.calpha),this.projection.value===4){let t=`${I}_writeUvs`,C=t+"0",o=t+"1",B=t+"2",a=`${I}_triplanarWeights`;g.addFragmentVariable(C,"vec2"),g.addFragmentVariable(o,"vec2"),g.addFragmentVariable(B,"vec2"),g.addFragmentVariable(a,"vec3"),i.push(C),i.push(o),i.push(B),i.push(a)}else{let t=`${I}_writeUvs`;g.addFragmentVariable(t,"vec2"),i.push(t)}return g.format(e+"("+i.join(",")+")",this.getType(g),A)}},x0=An;x0.Nodes=function(){let g=new rg(` +vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { + vec3 posN = normalize(position); + float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); + float scaledHeight = position.y / (size.y * 0.5); + float v = (scaledHeight / 2.) + .5; + + vec2 calculatedUv = vec2(u,v); + vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; + writeUv = uvs; + + vec2 df = fwidth(uvs); + if(df.x > 0.5) df.x = 0.; + + #ifdef GL_EXT_shader_texture_lod + vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #else + vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #endif + + vec3 col = tmp.rgb; + float lalpha = alpha * tmp.a; + if ( crop > 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + } +`),A=new rg(` +vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { + vec3 posN = normalize(vPosition); + float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); + float v = 0.5 + asin(posN.y) / 3.1415; + + vec2 calculatedUv = vec2(u,v); + vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; + writeUv = uvs; + + vec2 df = fwidth(uvs); + if(df.x > 0.5) df.x = 0.; + #ifdef GL_EXT_shader_texture_lod + vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #else + vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #endif + + vec3 col = tmp.rgb; + float lalpha = alpha * tmp.a; + if ( crop > 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + } +`),I=new rg(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { + vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; + writeUv = uvs; + + vec4 tmp = texture2D( tex, uvs ); + + vec3 col = tmp.rgb; + + float lalpha = alpha * tmp.a; + if ( crop > 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + }`),e=new rg(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) { + vec3 p = position; + vec2 uv0 = (1.0 + p.xy) / 2.0; + vec2 uv1 = (1.0 + p.zy) / 2.0; + vec2 uv2 = (1.0 + p.xz) / 2.0; + + uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + + // Range from 3 to 128 seems to be good + float exponent = (1.0 - blending) * 125.0 + 3.0; + + vec3 n = vObjectNormal; + vec3 weights = abs(normalize(n)); + weights = pow(weights, vec3(exponent)); + weights /= dot(weights, vec3(1.0)); + + // Write out all sets of UVs that we generated + writeUvs0 = uv0; + writeUvs1 = uv1; + writeUvs2 = uv2; + writeWeights = weights; + + // Derivatives for LOD + vec2 df0 = fwidth(uv0); + vec2 df1 = fwidth(uv1); + vec2 df2 = fwidth(uv2); + if (df0.x > 0.5) df0.x = 0.0; + if (df1.x > 0.5) df1.x = 0.0; + if (df2.x > 0.5) df2.x = 0.0; + + #ifdef GL_EXT_shader_texture_lod + vec4 tmp = + texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + + texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + + texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; + #else + vec4 tmp = + textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + + textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + + textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; + #endif + + vec3 col = tmp.rgb; + float lalpha = alpha * tmp.a; + + // Apply cropping across all 3 planes + if ( crop > 0.5 ) { + if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) { + lalpha = 0.0; + } + if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) { + lalpha = 0.0; + } + if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col;//n * 0.5 + 0.5; + } + `);return{cylindrical:g,spherical:A,uv:I,triplanar:e}}();var gn=class extends VI{constructor(g,A,I,e,i,t,C,o,B,a,s,r){super("v3"),this.nodeType="Depth",this.gradientType=g,this.smooth=A,this.near=I,this.far=e,this.isVector=i,this.isWorldSpace=t,this.origin=C,this.direction=o,this.colors=B,this.steps=a,this.isMask=r,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){let I=`g${this.uuid.toString().replace(/-/g,"")}`,e=new rg(`vec3 ${I}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${I}_MAX_COLORS], float steps[${I}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) { + vec4 color = colors[0]; + #ifdef ${I}_IS_VECTOR + #ifdef ${I}_LINEAR + #ifdef ${I}_WORLDSPACE + float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far); + #else + float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far); + #endif + #else + #ifdef ${I}_WORLDSPACE + float depth = vectorSphericalWorldSpaceDepth(origin, near, far); + #else + float depth = vectorSphericalObjectSpaceDepth(origin, near, far); + #endif + #endif + #else + float dist = length(vWPosition - cameraPosition); + float depth = ( dist - near ) / ( far - near ); + #endif + + + float p; + #ifdef ${I}_SMOOTH + for ( int i = 1; i < ${I}_MAX_COLORS; i++ ) { + p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); + color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); + } + #else + for ( int i = 1; i < ${I}_MAX_COLORS; i++ ) { + p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0); + color = mix(color, colors[i], p); + } + #endif + + float lalpha = alpha * color.a * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return color.rgb; + }`,[gn.Nodes.vectorLinearWorldSpaceDepth,gn.Nodes.vectorLinearObjectSpaceDepth,gn.Nodes.vectorSphericalObjectSpaceDepth,gn.Nodes.vectorSphericalWorldSpaceDepth]);if(g.isShader("fragment")){g.define(`${I}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&g.define(`${I}_SMOOTH`),this.isVector.value>.5&&g.define(`${I}_IS_VECTOR`),this.gradientType.value===0&&g.define(`${I}_LINEAR`),this.isWorldSpace.value>.5&&g.define(`${I}_WORLDSPACE`),g.require("worldPosition"),g.addFragmentVariable(this.calpha,"float");let i=g.include(e),t=[];return t.push(this.near.build(g,"f")),t.push(this.far.build(g,"f")),t.push(this.origin.build(g,"v3")),t.push(this.direction.build(g,"v3")),t.push(this.colors.build(g,"v4[]")),t.push(this.steps.build(g,"f[]")),t.push(this.isMask.build(g,"b")),t.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),t.push(this.alpha.build(g,"f")),t.push(this.calpha),g.format(i+"("+t.join(",")+")",this.getType(g),A)}else return console.warn("DepthNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},yK=gn;yK.Nodes=function(){let g=new rg(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) { + vec3 n = normalize(direction); + float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z)); + return ( dist - near ) / ( far - near ); + }`),A=new rg(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) { + vec3 n = normalize(direction); + float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z)); + return ( dist - near ) / ( far - near ); + }`),I=new rg(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) { + float dist = length(vWPosition - origin); + return ( dist - near ) / ( far - near ); + }`),e=new rg(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) { + float dist = length(position - origin); + return ( dist - near ) / ( far - near ); + }`);return{vectorLinearWorldSpaceDepth:g,vectorLinearObjectSpaceDepth:A,vectorSphericalWorldSpaceDepth:I,vectorSphericalObjectSpaceDepth:e}}();var fz=class extends VI{constructor(g,A,I,e,i,t,C,o){super("v3"),this.nodeType="Fresnel",this.color=g,this.bias=A,this.scale=I,this.intensity=e,this.factor=i,this.isMask=o,this.alpha=t,this.mode=C,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.require("vWorldViewDir"),g.require("worldNormal"),g.isShader("fragment")){g.addFragmentVariable(this.calpha,"float");let I=new rg(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) { + float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity ); + + float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return color; + }`),e=g.include(I),i=[];return i.push(this.color.build(g,"c")),i.push(this.bias.build(g,"f")),i.push(this.scale.build(g,"f")),i.push(this.intensity.build(g,"f")),i.push(this.factor.build(g,"f")),i.push(this.isMask.build(g,"b")),i.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),i.push(this.alpha.build(g,"f")),i.push(this.mode.build(g,"i")),i.push(this.calpha),g.format(e+"("+i.join(",")+")",this.getType(g),A)}else return console.warn("FresnelNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},wK=class extends VI{constructor(g,A,I,e,i,t,C,o,B){super("v3"),this.nodeType="Gradient",this.gradientType=g,this.smooth=A,this.colors=I,this.steps=e,this.offset=i,this.morph=t,this.angle=C,this.isMask=B,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.isShader("fragment")){g.define("GRAD_MAX",10),g.require("uv"),g.requires.uv=[!0],g.addFragmentVariable(this.calpha,"float");let I=g.include(wK.Nodes.gradient),e=[];return e.push(this.gradientType.build(g,"i")),e.push(this.smooth.build(g,"b")),e.push(this.colors.build(g,"v4[]")),e.push(this.steps.build(g,"f[]")),e.push(this.offset.build(g,"v2")),e.push(this.morph.build(g,"v2")),e.push(this.angle.build(g,"f")),e.push(this.isMask.build(g,"b")),e.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),e.push(this.alpha.build(g,"f")),e.push(this.calpha),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("GradientNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},SK=wK;SK.Nodes=function(){return{gradient:new rg(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) { + vec4 color = colors[0]; + vec2 m = morph / vUv.xy; + vec2 rot = vec2( 0.5 + m.x, m.y ); + vec2 dt = vec2( + cos( angle ) * rot.x - sin( angle ) * rot.y, + sin( angle ) * rot.x + cos( angle ) * rot.y + ); + vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0; + float t = dot( pt, dt ) / dot( dt, dt ); + if ( gradientType == 1 ) { + t = distance ( + ( vUv + morph ) * 3.0, + ( vUv + offset ) + 1.0 + ) + angle; + } else if ( gradientType == 2 ) { + float polar = atan( + vUv.x + morph.x - 0.5 + offset.x, + vUv.y + morph.y - 0.5 + offset.y + ) * -1.0; + t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) ); + } + + float p; + if (smoothed) { + for ( int i = 1; i < GRAD_MAX; i++ ) { + p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); + color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); + } + + } else { + for ( int i = 1; i < GRAD_MAX; i++ ) { + p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); + color = mix(color, colors[i], p); + } + } + + float lalpha = alpha * color.a * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return color.xyz; + }`)}}();var fK=class extends VI{constructor(g,A,I,e){super("v3"),this.nodeType="Matcap",this.texture=g,this.isMask=e,this.alpha=A,this.mode=I,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.isShader("fragment")){g.addFragmentVariable(this.calpha,"float");let I=g.include(fK.Nodes.matcap);g.require("normal"),g.requires.normal=!0;let e=[];return e.push(this.texture.generate(g,"t")),e.push("normal"),e.push(this.isMask.build(g,"b")),e.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),e.push(this.alpha.build(g,"f")),e.push(this.mode.build(g,"i")),e.push(this.calpha),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("MatcapNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},GK=fK;GK.Nodes=function(){return{matcap:new rg(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) { + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks + vec4 matcapColor = texture2D( matcapTex, uv ); + + float lalpha = alpha * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return matcapColor.rgb; + }`)}}();var H0=(g=>(g.SIMPLEX="simplex3d",g.SIMPLEX_FRACTAL="simplex3dFractal",g.ASHIMA="simplexAshima",g.FBM="fbm",g.PERLIN="perlin",g.VORONOI="voronoi",g))(H0||{}),at=function(){let g=new rg(`vec3 random3(vec3 c) { + float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); + vec3 r; + r.z = fract(512.0*j); + j *= .125; + r.x = fract(512.0*j); + j *= .125; + r.y = fract(512.0*j); + return r-0.5; + }`),A=new rg(`float simplex3d(vec3 p) { + vec3 s = floor(p + dot(p, vec3(F3))); + vec3 x = p - s + dot(s, vec3(G3)); + + vec3 e = step(vec3(0.0), x - x.yzx); + vec3 i1 = e*(1.0 - e.zxy); + vec3 i2 = 1.0 - e.zxy*(1.0 - e); + + vec3 x1 = x - i1 + G3; + vec3 x2 = x - i2 + 2.0*G3; + vec3 x3 = x - 1.0 + 3.0*G3; + + vec4 w, d; + + w.x = dot(x, x); + w.y = dot(x1, x1); + w.z = dot(x2, x2); + w.w = dot(x3, x3); + + w = max(0.6 - w, 0.0); + + d.x = dot(random3(s), x); + d.y = dot(random3(s + i1), x1); + d.z = dot(random3(s + i2), x2); + d.w = dot(random3(s + 1.0), x3); + + w *= w; + w *= w; + d *= w; + + return dot(d, vec4(52.0)); + }`,[g]);A.keywords.F3=new PI("float F3 0.3333333"),A.keywords.G3=new PI("float G3 0.1666667");let I=new rg(`float simplex3dFractal(vec3 m) { + mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4); + mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63); + mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56); + return 0.5333333 * simplex3d(m * rot1) + + 0.2666667 * simplex3d(2.0 * m * rot2) + + 0.1333333 * simplex3d(4.0 * m * rot3) + + 0.0666667 * simplex3d(8.0 * m); + }`,[A]),e=new rg("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new rg("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),t=new rg(`float simplexAshima(vec3 v) { + const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; + const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); + vec3 i = floor(v + dot(v, C.yyy) ); + vec3 x0 = v - i + dot(i, C.xxx) ; + vec3 g = step(x0.yzx, x0.xyz); + vec3 l = 1.0 - g; + vec3 i1 = min( g.xyz, l.zxy ); + vec3 i2 = max( g.xyz, l.zxy ); + vec3 x1 = x0 - i1 + 1.0 * C.xxx; + vec3 x2 = x0 - i2 + 2.0 * C.xxx; + vec3 x3 = x0 - 1. + 3.0 * C.xxx; + i = mod(i, 289.0 ); + vec4 p = permute( permute( permute( + i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); + float n_ = 1.0/7.0; // N=7 + vec3 ns = n_ * D.wyz - D.xzx; + vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N) + vec4 x_ = floor(j * ns.z); + vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) + vec4 x = x_ *ns.x + ns.yyyy; + vec4 y = y_ *ns.x + ns.yyyy; + vec4 h = 1.0 - abs(x) - abs(y); + vec4 b0 = vec4( x.xy, y.xy ); + vec4 b1 = vec4( x.zw, y.zw ); + vec4 s0 = floor(b0)*2.0 + 1.0; + vec4 s1 = floor(b1)*2.0 + 1.0; + vec4 sh = -step(h, vec4(0.0)); + vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; + vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; + vec3 p0 = vec3(a0.xy,h.x); + vec3 p1 = vec3(a0.zw,h.y); + vec3 p2 = vec3(a1.xy,h.z); + vec3 p3 = vec3(a1.zw,h.w); + vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); + m = m * m; + return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), + dot(p2,x2), dot(p3,x3) ) ); + }`,[e,i]),C=new rg("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),o=new rg("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[C]),B=new rg(`float noise(vec3 p){ + vec3 a = floor(p); + vec3 d = p - a; + d = d * d * (3.0 - 2.0 * d); + vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); + vec4 k1 = perm(b.xyxy); + vec4 k2 = perm(k1.xyxy + b.zzww); + vec4 c = k2 + a.zzzz; + vec4 k3 = perm(c); + vec4 k4 = perm(c + 1.0); + vec4 o1 = fract(k3 * (1.0 / 41.0)); + vec4 o2 = fract(k4 * (1.0 / 41.0)); + vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); + vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); + return o4.y * d.y + o4.x * (1.0 - d.y); + }`,[o]),a=new rg(`float fbm(vec3 x) { + float v = 0.0; + float a = 0.5; + vec3 shift = vec3(100); + for (int i = 0; i < NUM_OCTAVES; ++i) { + v += a * noise(x); + x = x * 2.0 + shift; + a *= 0.5; + } + return v; + }`,[B]);a.keywords.NUM_OCTAVES=new PI("int NUM_OCTAVES 5");let s=new rg("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),r=new rg(`float perlin(vec3 P){ + vec3 Pi0 = floor(P); + vec3 Pi1 = Pi0 + vec3(1.0); + Pi0 = mod(Pi0, 289.0); + Pi1 = mod(Pi1, 289.0); + vec3 Pf0 = fract(P); + vec3 Pf1 = Pf0 - vec3(1.0); + vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + vec4 iy = vec4(Pi0.yy, Pi1.yy); + vec4 iz0 = Pi0.zzzz; + vec4 iz1 = Pi1.zzzz; + vec4 ixy = permute(permute(ix) + iy); + vec4 ixy0 = permute(ixy + iz0); + vec4 ixy1 = permute(ixy + iz1); + vec4 gx0 = ixy0 / 7.0; + vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5; + gx0 = fract(gx0); + vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); + vec4 sz0 = step(gz0, vec4(0.0)); + gx0 -= sz0 * (step(0.0, gx0) - 0.5); + gy0 -= sz0 * (step(0.0, gy0) - 0.5); + vec4 gx1 = ixy1 / 7.0; + vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5; + gx1 = fract(gx1); + vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); + vec4 sz1 = step(gz1, vec4(0.0)); + gx1 -= sz1 * (step(0.0, gx1) - 0.5); + gy1 -= sz1 * (step(0.0, gy1) - 0.5); + vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); + vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); + vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); + vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); + vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); + vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); + vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); + vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); + vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); + g000 *= norm0.x; + g010 *= norm0.y; + g100 *= norm0.z; + g110 *= norm0.w; + vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); + g001 *= norm1.x; + g011 *= norm1.y; + g101 *= norm1.z; + g111 *= norm1.w; + float n000 = dot(g000, Pf0); + float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); + float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); + float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); + float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); + float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); + float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); + float n111 = dot(g111, Pf1); + vec3 fade_xyz = fade(Pf0); + vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); + vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); + float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); + return 2.2 * n_xyz; + }`,[e,i,s]),Q=new rg(`float hashwithoutsine13(vec3 p3) + { + p3 = fract(p3 * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),E=new rg(`vec3 hashwithoutsine33(vec3 p3) + { + p3 = fract(p3 * vec3(.1031, .1030, .0973)); + p3 += dot(p3, p3.yxz+33.33); + return fract((p3.xxy + p3.yxx)*p3.zyx); + }`),n=new rg(`float metric(in vec3 p) + { + // L2 + return length(p); + + // Chebyshev + // vec3 a = abs(p); + // return max(a.x, max(a.y, a.z)); + }`),h=new rg(`float smin( float a, float b, float k ) + { + float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k); + float correction = k * h * (1.0 - h); + return mix(b, a, h) - correction; + }`),l=new rg(`float smax( float a, float b, float k ) + { + float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k); + float correction = k * h * (1.0 - h); + return mix(a, b, h) + correction; + }`),c=new rg(`float remap(float value, float input_min, float input_max, float output_min, float output_max) { + // Compute width of each interval + float input_width = input_max - input_min; + float output_width = output_max - output_min; + + // Convert input range into a 0-1 range + float scaled = (value - input_min) / input_width; + + // Convert the 0-1 range into a value in output range + return output_min + (scaled * output_width); + }`),d=new rg(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) + { + // Integer and fractional parts of this point's coordinates + ivec3 p = ivec3(floor(x)); + vec3 f = fract(x); + + // Different variables that we will use to construct noise: + // + // f1: distance to the closest feature point + // f2: distance to the second closest feature point + // e: distance to the closest edge (cell boundary) + // + // We also compute "smooth" versions of all of the above quantites, essentially + // replacing "hard" minimums with "smooth" minimums (described by IQ) + float f1_smooth = 8.0; + float f1 = 8.0; + float f2_smooth = 8.0; + float f2 = 8.0; + float e_smooth = 8.0; + float e = 8.0; + + // Variables stored from closest cell + ivec3 mb; + vec3 mr; + + int steps = quality; + + for (int x = -steps; x <= steps; x++) + for (int y = -steps; y <= steps; y++) + for (int z = -steps; z <= steps; z++) + { + ivec3 b = ivec3(x, y, z); + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d = length(r); + + f1_smooth = smin(d, f1_smooth, smoothness); + + // Store un-smoothed distances too + if (d < f1) + { + f2 = f1; + f1 = d; + + mb = ivec3(x, y, z); + mr = r; + } + else if (d < f2) + { + f2 = d; + } + } + + float id = hashwithoutsine13(vec3(p + mb) + seed); + + // Second pass for edge distance + for (int x = -steps; x <= steps; x++) + for (int y = -steps; y <= steps; y++) + for (int z = -steps; z <= steps; z++) + { + // Start search at the cell that contains the closest point to "x" (found in 1st pass) + ivec3 b = mb + ivec3(x, y, z); + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version? + float d2 = dot(0.5 * (mr + r), normalize(r - mr)); + + e_smooth = smin(d1, e_smooth, smoothness); + + e = min(e, d2); + + // Also compute a smooth version of F2 in this pass + { + ivec3 b = ivec3(x, y, z); + if (b != mb) + { + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d = length(r); + + f2_smooth = smin(d, f2_smooth, smoothness); + } + } + } + + // Different visualization modes + if (style == 0) + { + return f1_smooth; + } + if (style == 1) + { + return f2_smooth; + } + if (style == 2) + { + return f2_smooth - f1_smooth; + + // "Pebbles" also cool + //return step(0.2, f2_smooth - f1_smooth); + } + if (style == 3) + { + // This one is really good for rock / stone effects + float a = f1; + float b = f2; + float k = 3.0; + float h = max(k - abs(a - b), 0.0) / k; + float final = min(a, b) - h * h * k * (1.0 / 4.0); + return final; + } + if (style == 4) + { + // Some random adjustments to make this style stand out more + return exp(5.0 * e_smooth); + } + if (style == 5) + { + return pow(f1_smooth, 3.0); + } + if (style == 6) + { + const float eps = 0.0125; + + // Thicker lines as the user increases the smoothness slider + float thickness = smoothness * 0.25 + eps; + + // Blurrier lines as the user increases the smoothness slider + float blur = pow(smoothness, 3.0) * 0.25 + eps; + + return smoothstep( + thickness - thickness * blur, + thickness + thickness * blur, + e + ); + } + if (style == 7) + { + return hashwithoutsine13(vec3(p + mb) + seed); + } + } + `,[Q,E,n,h,l,c]);return{simplex:A,simplexFractal:I,simplexAshima:t,fbm:a,perlin:r,voronoi:d}}(),kK=class extends VI{constructor(g,A,I,e,i,t,C,o,B,a,s,r,Q,E,n,h,l,c,d){super("v3"),this.nodeType="Noise",this.scale=g,this.size=A,this.move=I,this.fA=e,this.fB=i,this.distortion=t,this.colorA=C,this.colorB=o,this.colorC=B,this.colorD=a,this.noiseType=r,this.voronoiStyle=E,this.highCut=n,this.lowCut=h,this.smoothness=l,this.seed=c,this.quality=d,this.isMask=Q,this.alpha=s,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A,I,e,i){g.require("uv"),g.requires.uv=[!0],g.addFragmentVariable(this.calpha,"float");let t=Object.values(H0)[this.noiseType.value],C=t=="voronoi"?` + float v = ${t}(st + move, voronoiStyle, smoothness, seed, quality); + + // Apply clipping to colors + v = remap(v, lowCut, highCut, 0.0, 1.0); + v = smax(v, 0.0, smoothness * 0.25); + v = smin(v, 1.0, smoothness * 0.25); + + // Note that the voronoi mode only uses colors "A" and "C" from the UI + vec4 color = mix(colorA, colorC, v); + `:` + vec3 q = vec3(${t}(st), + ${t}(st + vec3(1.0)), + ${t}(st + vec3(1.0))); + vec3 r = vec3(${t}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move), + ${t}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), + ${t}(st * q)); + float f = ${t}(st + r); + vec4 color; + color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0)); + color = mix(color, colorC, clamp(length(q), 0.0, 1.0)); + color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0)); + `,o=new rg(`vec3 ${t}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) + { + // Prevent scale of zero + scale = max(abs(scale), 0.001); + + vec3 st = position / size; + st /= scale; + + ${C} + + float lalpha = alpha * color.a * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return clamp(color, 0.0, 1.0).rgb; + }`,[at.simplex,at.simplexFractal,at.simplexAshima,at.fbm,at.perlin,at.voronoi]),B=g.include(o),a=[];return a.push(this.scale.build(g,"f")),a.push(this.size.build(g,"v3")),a.push(this.move.build(g,"f")),a.push(this.fA.build(g,"v2")),a.push(this.fB.build(g,"v2")),a.push(this.distortion.build(g,"v2")),a.push(this.colorA.build(g,"v4")),a.push(this.colorB.build(g,"v4")),a.push(this.colorC.build(g,"v4")),a.push(this.colorD.build(g,"v4")),a.push(this.voronoiStyle.build(g,"i")),a.push(this.highCut.build(g,"f")),a.push(this.lowCut.build(g,"f")),a.push(this.smoothness.build(g,"f")),a.push(this.seed.build(g,"f")),a.push(this.quality.build(g,"i")),a.push(this.isMask.build(g,"b")),a.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),a.push(this.alpha.build(g,"f")),a.push(this.calpha),g.format(B+"("+a.join(",")+")",this.getType(g),A)}};kK.numOctaves=5;var MK=class extends VI{constructor(g,A,I,e,i,t,C,o,B,a,s,r,Q,E,n,h){super("v3"),this.nodeType="Outline",this.firstTime=!0,this.outlineColor=g,this.contourColor=A,this.outlineWidth=I,this.contourWidth=e,this.contourThreshold=i,this.outlineThreshold=t,this.contourFrequency=C,this.outlineSmoothing=o,this.contourDirection=B,this.positionalLines=a,this.compensation=s,this.resolution=r,this.normalMap=Q,this.depthMap=E,this.pixelRatio=n,this.alpha=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){let I=`g${this.uuid.toString().replace(/-/g,"")}`;if(g.require("vWorldViewDir"),g.require("worldNormal"),g.extensions.derivatives=!0,this.compensation.value&&g.define("OUTLINE_COMPENSATION",`${I}_offset`),this.firstTime){let e=this.outlineWidth.build(g,"f"),i=this.resolution.build(g,"v2"),t=this.compensation.build(g,"b"),C=this.pixelRatio.build(g,"f");g.addVertexParsVariable("randomColor","attribute vec3"),g.addVertexParsVariable("extrudeNormal","attribute vec3"),g.addVertexParsVariable(e,"uniform float"),g.addVertexParsVariable(i,"uniform vec2"),g.addVertexParsVariable(t,"uniform bool"),g.addVertexParsVariable(C,"uniform float"),g.addVertexParsVariable("vID","flat out float"),g.addFragmentParsVariable("vID","flat in float"),g.addVertexFinalCode(` + vID = randomColor.r; + vec2 ${I}_offset = vec2(0.0); + if (${t}) { + vec4 ${I}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0)); + // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the + // normals face the camera directly. So we hackily fix this by offsetting the normal + // by a tiny amount. + vec3 ${I}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001; + ${I}_offset = normalize(${I}_clipNormal.xy) / ${i} * (${e} / 2.0) * ${I}_clipPosition.w * 2.0 * ${C}; + ${I}_clipPosition.xy += ${I}_offset; + // TODO(MAX): To handle multiple outline layers, we only want to extrude + // if this offset is the biggest of all the potential offsets + gl_Position = ${I}_clipPosition; + } + `)}if(g.isShader("fragment")){g.require("uv"),g.requires.uv=[!0],g.addFragmentVariable(this.calpha,"float");let e=g.include(MK.Nodes.outline),i=[];return i.push(this.outlineColor.build(g,"c")),i.push(this.contourColor.build(g,"c")),i.push(this.outlineWidth.build(g,"f")),i.push(this.contourWidth.build(g,"f")),i.push(this.contourThreshold.build(g,"f")),i.push(this.outlineThreshold.build(g,"f")),i.push(this.contourFrequency.build(g,"f")),i.push(this.outlineSmoothing.build(g,"f")),i.push(this.contourDirection.build(g,"v3")),i.push(this.positionalLines.build(g,"b")),i.push(this.resolution.build(g,"v2")),i.push(this.normalMap.getTexture(g,"t")),i.push(this.depthMap.getTexture(g,"t")),i.push(this.pixelRatio.build(g,"f")),i.push(this.compensation.build(g,"b")),i.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),i.push(this.alpha.build(g,"f")),i.push(this.calpha),this.firstTime=!this.firstTime,g.format(e+"("+i.join(",")+")",this.getType(g),A)}else return console.warn("OutlineNode is not compatible with "+g.shader+" shader."),""}},mK=MK;mK.Nodes=function(){let g=new rg(` +float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio) +{ + vec2 halton = haltonSequence[frameIndex]; + float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); + float temporalAngle = temporalOffset * PI2; + + vec2 texelSize = (vec2(1.0) / resolution); + vec2 offsetSize = texelSize * outlineWidth * pixelRatio; + + vec2 uvSamples[9]; + vec4 normalSamples[9]; + + uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize); + uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize); + uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize); + uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize); + uvSamples[4] = uv; + uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize); + uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize); + uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize); + uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize); + + + normalSamples[0] = texture2D(t, uvSamples[0]); + normalSamples[1] = texture2D(t, uvSamples[1]); + normalSamples[2] = texture2D(t, uvSamples[2]); + normalSamples[3] = texture2D(t, uvSamples[3]); + normalSamples[4] = texture2D(t, uvSamples[4]); + normalSamples[5] = texture2D(t, uvSamples[5]); + normalSamples[6] = texture2D(t, uvSamples[6]); + normalSamples[7] = texture2D(t, uvSamples[7]); + normalSamples[8] = texture2D(t, uvSamples[8]); + + float depthBias = 0.0001; + // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?! + if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + + if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) { + float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias; + if (gl_FragCoord.z > depthAtSample) { + return 0.0; + } + } + + vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb); + vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb); + + float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v)); + return edgeNormal; +} +`);return{outline:new rg(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) { + vec3 result = outlineColor; + float resultAlpha = 0.0; + + vec3 N = normalize(vWNormal); + vec2 nuv = (gl_FragCoord.xy / resolution); + float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio); + resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample); + + //resultAlpha = 1.0; + //result = vec3(sobelSample); + + float t = 1.0 - contourThreshold; + if(positionalLines) { + vec3 NDir = position * contourDirection; + float NT = NDir.x + NDir.y + NDir.z; + float f = fract(NT * contourFrequency * 0.01); + float df = fwidth(NT * contourFrequency); + + float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f); + if (g < 1.0 && resultAlpha == 0.0) { + result = contourColor; + resultAlpha = 1.0; + } + } + else { + vec3 NDir = N * contourDirection; + float NT = NDir.x + NDir.y + NDir.z; + float df = fwidth(NT * contourThreshold); + float f = sin(NT * 1.0 * contourFrequency); + float g = smoothstep(0.0, df * contourWidth, 1.0 - f); + + if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) { + result = contourColor; + resultAlpha = 1.0 - g; + } + } + + float lalpha = alpha * resultAlpha * mask; + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * lalpha; + + return result; + }`,[g])}}();var BB=class extends VI{constructor(A,I,e,i,t,C,o,B,a,s,r,Q,E,n,h,l,c,d){super("v3"),this.nodeType="Pattern",this.style=A,this.projection=I,this.axis=e,this.blending=i,this.offset=t,this.colorA=C,this.colorB=o,this.frequency=B,this.size=a,this.variation=s,this.smoothness=r,this.zigzag=Q,this.rotation=E,this.vertical=n,this.horizontal=h,this.sides=l,this.isMask=d,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(A,I){if(A.isShader("fragment")){A.require("position"),A.require("uv"),A.requires.uv=[!0],A.require("normal"),A.requires.normal=!0,A.addFragmentVariable(this.calpha,"float");let e;switch(this.style.value){case 0:e="circle";break;case 1:e="ring";break;case 2:e="polygon";break;case 3:e="xcross";break;case 4:e="diamond";break;case 5:e="checkerboard";break;case 6:e="line";break;case 7:e="wave";break;default:e="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,t=new rg(`float hashwithoutsine12(vec2 p) + { + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),C=new rg(`vec2 rotate_uv(in vec2 uv, float a, bool repeat) + { + const float mid = 0.5; + float radians = a * (PI / 180.0); + vec2 rotated = vec2( + cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid, + cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid + ); + return repeat ? fract(rotated): rotated; + }`),o="";if(this.projection.value===4){let r=this.style.value===2?`${e}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${e}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,Q=this.style.value===2?`${e}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${e}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,E=this.style.value===2?`${e}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${e}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;o=` + vec3 p = position; + float factor = 0.0125; + vec2 uv0 = fract(p.xy * factor); + vec2 uv1 = fract(p.zy * factor); + vec2 uv2 = fract(p.xz * factor); + + uv0 = rotate_uv(uv0 + offset, rotation, true); + uv1 = rotate_uv(uv1 + offset, rotation, true); + uv2 = rotate_uv(uv2 + offset, rotation, true); + + float d0 = ${r}; + float d1 = ${Q}; + float d2 = ${E}; + + // Range from 3 to 128 seems to be good + float exponent = (1.0 - blending) * 125.0 + 3.0; + + vec3 n = vObjectNormal; + vec3 weights = abs(normalize(n)); + weights = pow(weights, vec3(exponent)); + weights /= dot(weights, vec3(1.0)); + d0 *= weights.z; + d1 *= weights.x; + d2 *= weights.y; + float draw = d0 + d1 + d2; + + vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y; + `}else{let r=this.style.value===2?`${e}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${e}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,Q="";this.axis.value===0?Q=`float radius = length(p); + float theta = atan(p.y, p.z); + float phi = acos(p.x / radius);`:this.axis.value===1?Q=`float radius = length(p); + float theta = atan(p.x, p.z); + float phi = acos(p.y / radius);`:(this.axis.value,Q=`float radius = length(p); + float theta = atan(p.y, p.x); + float phi = acos(p.z / radius);`);let E="";switch(this.projection.value){case 0:E="custom_uv = vUv.st;";break;case 1:break;case 2:E=` + vec3 p = position; + ${Q} + custom_uv = vec2(theta, phi); + custom_uv /= PI; + `;break}o=` + vec2 custom_uv; + ${E} + + custom_uv += offset; + custom_uv = fract(custom_uv); + custom_uv = rotate_uv(custom_uv, rotation, true); + + float draw = ${r}; + `}let B=new rg(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) { + const float TWO_PI = PI * 2.0; + float smoothness_remapped = pow(smoothness, 5.0); + + ${o} + + // Construct final output color + vec4 color = mix(colorA, colorB, draw); + color.a = clamp(color.a, 0.0, 1.0); + + // Apply cuts + color.a *= + step(vertical.x, custom_uv.y) * + step(custom_uv.y, vertical.y); + color.a *= + step(horizontal.x, abs(custom_uv.x)) * + step(abs(custom_uv.x), horizontal.y); + + // Accumulate alpha + float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return clamp(color, 0.0, 1.0).rgb; + }`,[C,t,BB.DrawFunctions.circle,BB.DrawFunctions.ring,BB.DrawFunctions.polygon,BB.DrawFunctions.cross,BB.DrawFunctions.diamond,BB.DrawFunctions.checkerboard,BB.DrawFunctions.line,BB.DrawFunctions.wave]),a=A.include(B),s=[];return s.push("normal"),s.push(this.blending.build(A,"f")),s.push(this.style.build(A,"i")),s.push(this.offset.build(A,"v2")),s.push(this.colorA.build(A,"v4")),s.push(this.colorB.build(A,"v4")),s.push(this.frequency.build(A,"v2")),s.push(this.size.build(A,"f")),s.push(this.variation.build(A,"f")),s.push(this.smoothness.build(A,"f")),s.push(this.zigzag.build(A,"f")),s.push(this.rotation.build(A,"f")),s.push(this.vertical.build(A,"v2")),s.push(this.horizontal.build(A,"v2")),s.push(this.sides.build(A,"i")),s.push(this.isMask.build(A,"b")),s.push(this.mask?`luminance(${this.mask.flow(A,"v3").result})`:"1.0"),s.push(this.alpha.build(A,"f")),s.push(this.calpha),A.format(a+"("+s.join(",")+")",this.getType(A),I)}else return console.warn("PatterNode is not compatible with "+A.shader+" shader."),A.format("vec3(0.0)",this.getType(A),I)}},UK=BB;UK.DrawFunctions=function(){let g=new rg(`float hashwithoutsine12(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * 0.1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),A=new rg(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) { + // Create tiles in UV-space + uv *= frequency; + + // Integer coords + vec2 i = floor(uv); + + // Offset every other row based on zigzag param, then compute fractional coords + float row_offset = mod(i.y, 2.0); + uv.x += row_offset * zigzag; + vec2 f = fract(uv); + + // Rotate the tile itself: + // const float mid = 0.5; + // f = vec2( + // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid, + // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid + // ); + // f = fract(f); + + f = f * 2.0 - 1.0; + + // Recompute integer coords after shifting - then, random value per tile + i = floor(uv); + float rand = (hashwithoutsine12(i) * 5.0 + 1.0); + float jitter = mix(1.0, rand, variation); + f *= jitter; + + return f; + }`,[g]),I=new rg(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep( + -smoothness, + smoothness, + length(f) - size + ); + }`,[A]),e=new rg(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + + float d = length(f); + const float inner_width = 0.5; + + float outer = smoothstep(-smoothness, smoothness, d - size); + float inner = smoothstep(-smoothness, smoothness, d - size * inner_width); + return outer + (1.0 - inner); + }`,[A]),i=new rg(`float sdf_ngon(in vec2 p, in float r, in int n) { + float an = (PI * 2.0) / float(n); + float he = r * tan(0.5 * an); + + // Rotate to first sector + p = -p.yx; + float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an); + vec2 cs = vec2(cos(bn), sin(bn)); + p = mat2(cs.x, -cs.y, cs.y, cs.x)*p; + + // Side of polygon + return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r); + } + + float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides)); + }`,[A]),t=new rg(`float sdf_cross(in vec2 p, in vec2 b, float r ) { + p = abs(p); + p = (p.y > p.x) ? p.yx : p.xy; + vec2 q = p - b; + float k = max(q.y, q.x); + vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k); + return sign(k) * length(max(w, 0.0)) + r; + } + + // Avoid namespace conflicts + float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness)); + }`,[A]),C=new rg(`float ndot(vec2 a, vec2 b) { + return a.x*b.x - a.y*b.y; + } + + float sdf_diamond(in vec2 p, in vec2 b) { + p = abs(p); + float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0); + float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h)); + return d * sign(p.x * b.y + p.y * b.x - b.x * b.y); + } + + float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size))); + }`,[A]),o=new rg(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + uv *= frequency; + vec2 i = floor(uv); + + float offset = mod(i.y, 2.0); + + uv.x += offset + zigzag * offset; + float x = floor(uv.x); + + return mod(x, 2.0); + }`),B=new rg(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation); + + // Different approach for variation param here + float row = floor(uv * frequency).y; + float rand = hashwithoutsine12(vec2(row)); + float s = mix(size, size * rand, variation); + + return smoothstep( + s - smoothness, + s + smoothness, + abs(f.y) + ); + }`,[A]),a=new rg(`// Uses bisection + float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) { + // Convert all data to a primitive cosine wave + p = c * (p - vec2(d, a)); + + const float TWO_PI = PI * 2.0; + + // Reduce to principal half cycle + p.x = mod(p.x, TWO_PI); + if (p.x > PI) { + p.x = TWO_PI - p.x; + } + + // Find zero of derivative (minimize distance) + float xa = 0.0; + float xb = TWO_PI; + + // 24 bit precision + for (int i = 0; i < 24; i++) { + float x = 0.5 * (xa + xb); + float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x)); + if (y < 0.0) xa = x; + else xb = x; + } + float x = 0.5 * (xa + xb); + + // Compute distance + vec2 q = vec2(x, b * c * cos(x)); + return length(p - q) / c; + } + + float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + float repeat = frequency.x; + uv *= repeat; + vec2 i = floor(uv); + float row_offset = mod(i.y, 2.0); + uv.x += row_offset * zigzag; + vec2 f = vec2(uv.x, fract(uv.y)); + + // Generalized cosine: y(x) = a + b * cos(cx + d) + const float amplitude = 0.125; + float wave_frequency = frequency.y * 0.1; + float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0); + + // Different approach for variation param here + float rand = hashwithoutsine12(vec2(i.y)); + float s = mix(size, size * rand, variation); + + return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5); + }`);return{tileAndCenter:A,circle:I,ring:e,polygon:i,cross:t,diamond:C,checkerboard:o,line:B,wave:a}}();var NK=class extends VI{constructor(g,A,I,e,i,t,C,o){super("v3"),this.nodeType="Rainbow",this.filmThickness=g,this.movement=A,this.wavelengths=I,this.noiseStrength=e,this.noiseScale=i,this.offset=t,this.isMask=o,this.alpha=C,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.require("vWorldViewDir"),g.require("worldNormal"),g.isShader("fragment")){g.require("uv"),g.requires.uv=[!0],g.addFragmentVariable(this.calpha,"float");let I=g.include(NK.Nodes.rainbow),e=[];return e.push(this.filmThickness.build(g,"f")),e.push(this.movement.build(g,"f")),e.push(this.wavelengths.build(g,"v3")),e.push(this.noiseStrength.build(g,"f")),e.push(this.noiseScale.build(g,"f")),e.push(this.offset.build(g,"v3")),e.push(this.isMask.build(g,"b")),e.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),e.push(this.alpha.build(g,"f")),e.push(this.calpha),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("RainbowNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},FK=NK;FK.Nodes=function(){let g=new rg(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) { + vec3 st = position / noiseScale; + vec3 q = vec3(simplex3d(st), + simplex3d(st + vec3(1.0)), + simplex3d(st + vec3(1.0))); + + vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)), + simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)), + simplex3d(st * q)); + + float noise = simplex3d(st + r); + + return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement); + }`,[at.simplex]);return{rainbow:new rg(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) { + vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0); + + float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0); + + float lalpha = alpha * rainbowContribution * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return res; + }`,[g])}}();var RK=class extends VI{constructor(g,A,I,e,i,t,C,o,B,a){super("v3"),this.nodeType="Toon",this.positioning=g,this.colors=A,this.steps=I,this.source=e,this.isWorldSpace=i,this.noiseStrength=t,this.noiseScale=C,this.shadowColor=o,this.offset=B,this.alpha=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.require("worldNormal"),g.require("worldPosition"),g.isShader("fragment")){g.define("COLORS_MAX",10),g.addFragmentVariable(this.calpha,"float");let I=g.include(RK.Nodes.toon),e=[];return e.push(this.positioning.build(g,"i")),e.push(this.colors.build(g,"v4[]")),e.push(this.steps.build(g,"f[]")),e.push(this.source.build(g,"v3")),e.push(this.isWorldSpace.build(g,"b")),e.push(this.noiseStrength.build(g,"f")),e.push(this.noiseScale.build(g,"f")),e.push(this.shadowColor.build(g,"v4")),e.push(this.offset.build(g,"v3")),e.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),e.push(this.alpha.build(g,"f")),e.push(this.calpha),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("ToonNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},KK=RK;KK.Nodes=function(){let g=new rg(`float rand(float n) { + return fract(sin(n) * 43758.5453123); + }`),A=new rg(`float hash1(float p) { + p = fract(p * 0.011); + p *= p + 7.5; + p *= p + p; + return fract(p); + }`),I=new rg(`float valueNoise(vec3 x) { + const vec3 step = vec3(110, 241, 171); + + vec3 i = floor(x); + vec3 f = fract(x); + + // For performance, compute the base input to a 1D hash from the integer part of the argument and the + // incremental change to the 1D based on the 3D -> 1D wrapping + float n = dot(i, step); + + vec3 u = f * f * (3.0 - 2.0 * f); + return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x), + mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y), + mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x), + mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z); + }`,[A]),e=new rg(`vec3 hash3(vec3 x) { + x = vec3(dot(x,vec3(127.1, 311.7, 74.7)), + dot(x,vec3(269.5, 183.3, 246.1)), + dot(x,vec3(113.5, 271.9, 124.6))); + + return fract(sin(x)*43758.5453123); + }`),i=new rg(`vec3 voronoiNoise(in vec3 x) + { + vec3 p = floor(x); + vec3 f = fract(x); + + float id = 0.0; + vec2 res = vec2(100.0); + + for(int k=-1; k<=1; k++) + for(int j=-1; j<=1; j++) + for(int i=-1; i<=1; i++) + { + vec3 b = vec3(float(i), float(j), float(k)); + + // Comment out the "+ hash(p + b);" part below to get "square" cells + vec3 r = vec3(b) - f + hash3(p + b); + float d = dot(r, r); + + if (d < res.x) + { + id = dot(p + b, vec3(1.0, 57.0, 113.0)); + res = vec2(d, res.x); + } + else if (d < res.y) + { + res.y = d; + } + } + + return vec3(sqrt(res), abs(id)); + } + `,[e]);return{toon:new rg(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) { + float t = 0.0; + float shadow = 1.0; + + if (positioning == 0) { + + // Can't do this mode if lighting is "none" + #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD)) + + // Algorithm from Chapter 10 of Graphics Shaders + const vec3 weights = vec3(0.2125, 0.7154, 0.0721); + vec3 lpos; + vec3 l; + float dproduct; + + #if (NUM_POINT_LIGHTS > 0) + + #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0) + PointLightShadow pointLightShadow; + #endif + + #pragma unroll_loop_start + for (int i = 0; i < NUM_POINT_LIGHTS; i++) { + // Light positions are in view-space for some reason? + lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; + l = normalize(lpos - worldPosition); + + dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; + + // TODO: we want to use "intensity" but it isn't available in the shader code + //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights); + + t = max(t, dproduct); + + // Accumulate shadow contribution + #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS) + pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX]; + shadow *= getPointShadow( + pointShadowMap[UNROLLED_LOOP_INDEX], + pointLightShadow.shadowMapSize, + pointLightShadow.shadowBias, + pointLightShadow.shadowRadius, + vPointShadowCoord[UNROLLED_LOOP_INDEX], + pointLightShadow.shadowCameraNear, + pointLightShadow.shadowCameraFar); + #endif + } + #pragma unroll_loop_end + + #endif + + #if NUM_DIR_LIGHTS > 0 + + #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0) + DirectionalLightShadow directionalLightShadow; + #endif + + #pragma unroll_loop_start + for (int i = 0; i < NUM_DIR_LIGHTS; i++) { + // Use the direction vector for directional lights instead + l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz; + + dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; + t = max(t, dproduct); + + // Accumulate shadow contribution + #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS) + directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX]; + shadow *= getShadow( + UNROLLED_LOOP_INDEX, + directionalShadowMap[UNROLLED_LOOP_INDEX], + directionalLightShadow.shadowMapSize, + directionalLightShadow.shadowBias, + directionalLightShadow.shadowRadius, + vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]); + #endif + } + #pragma unroll_loop_end + + #endif + + #if NUM_SPOT_LIGHTS > 0 + + #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0) + SpotLightShadow spotLightShadow; + #endif + + #pragma unroll_loop_start + for (int i = 0; i < NUM_SPOT_LIGHTS; i++) { + lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; + l = normalize(lpos - worldPosition); + + dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; + t = max(t, dproduct); + + // Accumulate shadow contribution + #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS) + spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX]; + shadow *= getShadow( + UNROLLED_LOOP_INDEX, + spotShadowMap[UNROLLED_LOOP_INDEX], + spotLightShadow.shadowMapSize, + spotLightShadow.shadowBias, + spotLightShadow.shadowRadius, + vSpotLightCoord[UNROLLED_LOOP_INDEX]); + #endif + } + #pragma unroll_loop_end + + #endif + + t = clamp(t, 0.0, 1.0); + + #endif + + } else if (positioning == 1) { + + vec3 origin = mix(position, worldPosition, float(isWorldSpace)); + vec3 direction = normalize(source - origin); + t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; + + } else { + + vec3 origin = worldPosition; + vec3 source = cameraPosition - offset; + vec3 direction = normalize(source - origin); + t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; + + } + + if (noiseStrength > 0.0) { + // Distort with noise + vec3 st = position / noiseScale; + + // Voronoi "smooth" noise + float noise = 1.0 - voronoiNoise(st).x; + + // Voronoi cellular noise + //float noise = 1.0 - rand(voronoiNoise(st).z); + + // Position warp noise + // vec3 offset = vec3( + // simplex3d(st), + // simplex3d(st + vec3(111.1, 143.89, 217.19)), + // simplex3d(st + vec3(171.1, 247.89, 117.23)) + // ); + // st += offset; + // float noise = valueNoise(st); + + t += noise * noiseStrength; + } + + t = clamp(t, 0.0, 1.0); + + // Compute ramp color + float p; + vec4 color = colors[0]; + for (int i = 1; i < COLORS_MAX; i++) { + p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0); + color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); + } + + // Incorporate custom shadow color + if (positioning == 0) { + + vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a); + color.rgb = mix(blendedShadow, color.rgb, shadow); + + } + + // Accumulate alpha as usual + float lalpha = alpha * color.a * mask; + calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); + accumAlpha += (1.0 - accumAlpha) * lalpha; + + return color.xyz; + + }`,[at.simplex,g,I,i])}}();var Gz=function(){return{textureBicubic:new rg(`float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + + // g0 and g1 are the two amplitude functions + float g0( float a ) { + return w0( a ) + w1( a ); + } + + float g1( float a ) { + return w2( a ) + w3( a ); + } + + // h0 and h1 are the two offset functions + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + }`)}}();function kz(g,A){return g>=A?new sA(A/g,1):new sA(1,g/A)}var JK=class extends VI{constructor(g,A,I,e,i,t,C,o){super("v3"),this.nodeType="Transmission",this.thickness=g,this.ior=A,this.roughness=I,this.transmissionSamplerSize=e,this.transmissionSamplerMap=i,this.transmissionDepthMap=t,this.aspectRatio=C,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(g,A){if(g.extensions.shaderTextureLOD=!0,g.extensions.derivatives=!0,g.isShader("fragment")){g.define("NUM_SAMPLES",6),g.define("BLUR_SLOD",Math.pow(2,Tg.transmissionLod.value)),g.require("worldPosition"),g.requires.worldNormal=!0,g.requires.modelMatrix=!0,g.requires.projectionMatrix=!0,g.addFragmentVariable(this.calpha,"float");let I=g.include(JK.Nodes.transmission),e=[];return e.push(this.thickness.build(g,"f")),e.push(this.ior.build(g,"f")),e.push(this.roughness.build(g,"f")),e.push(this.transmissionSamplerSize.build(g,"v2")),e.push(this.transmissionSamplerMap.getTexture(g,"t")),e.push(this.transmissionDepthMap.getTexture(g,"t")),e.push(this.aspectRatio.build(g,"v2")),e.push("normal"),e.push(this.mask?`luminance(${this.mask.flow(g,"v3").result})`:"1.0"),e.push(this.alpha.build(g,"f")),e.push(this.calpha),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("TransmissionNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},vK=JK;vK.Nodes=function(){let g=new rg(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) { + // Slightly modified version of this: + // https://www.shadertoy.com/view/ltScRG + + // Special case for blur == 0.0 + if (lod == 0.0) { + #ifdef TEXTURE_LOD_EXT + return texture2DLodEXT( sp, U, 0.0).rgb; + #else + return textureLod( sp, U, 0.0).rgb; + #endif + } + + vec2 texelSize = vec2(1.0) / resolution; + vec2 halton = haltonSequence[frameIndex]; + float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); + float temporalAngle = temporalOffset * PI2; + vec3 res = vec3(0.0); + vec2 uv = vec2(0.0); + vec2 offset = vec2(0.0); + vec2 vogelSample = vec2(0.0); + for (int i = 0; i < NUM_SAMPLES; i++) { + vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize; + offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20 + uv = U + offset; + float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod)); + if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) { + uv = unrefractedU; + lod = lod > 4.0 ? lod : lod / 2.0; + } + res += textureLod(sp, uv, lod).rgb; + } + return res / float(NUM_SAMPLES); + }`),A=new rg(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { + // Direction of refracted light. + vec3 refractionVector = refract( -v, n, 1.0 / ior ); + + // Compute rotation-independant scaling of the model matrix. + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + + // The thickness is specified in local space + return normalize( refractionVector ) * thickness * modelScale; + }`),I=new rg(`float applyIorToRoughness( float roughness, float ior ) { + // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and + // an IOR of 1.5 results in the default amount of microfacet refraction. + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + }`),e=new rg(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) { + // Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see + // also the code in convertTransmission.ts, which runs during export + #ifdef IS_THREEJS_EXPORT + float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior); + return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb; + #else + float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + float lod = applyIorToRoughness(roughness, ior); + return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio); + #endif + }`,[Gz.textureBicubic,I,g]),i=new rg(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 ); + vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w; + unrefractedCoords += 1.0; + unrefractedCoords /= 2.0; + + // Sample framebuffer to get pixel the refracted ray hits. + return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio ); + }`,[e,A]);return{transmission:new rg(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) { + vec3 v = vec3(0.); + if (isOrthographic) { + v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + v = normalize(vWPosition - cameraPosition); + } + vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio ); + + float lalpha = alpha * mask; + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * alpha; + + return transmission; + }`,[i])}}();var Xy=(g=>(g.NOISE="noise",g.MAP="map",g))(Xy||{}),qK=class extends VI{constructor(g,A,I,e,i,t,C,o,B,a,s){super("v3"),this.displacementTypeIndex=new ge(0),this.nodeType="VertexDisplacement",this.intensity=g,this.movementOrTexture=A,Object.values(Xy)[this.displacementTypeIndex.value]==="map"&&(this.mat=new DK(this.movementOrTexture.value.matrix)),this.cropOrOffset=I,this.scale=a,this.noiseFunctionIndex=s,this.voronoiStyle=e,this.smoothness=i,this.seed=t,this.highCut=C,this.lowCut=o,this.quality=B}generate(g,A){if(g.isShader("vertex")){g.define("USE_LAYER_DISPLACE");let I,e=[];switch(e.push("displaced_position"),e.push("displaced_normal"),Object.values(Xy)[this.displacementTypeIndex.value]){case"map":{I=g.include(qK.Nodes.map),e.push(this.movementOrTexture.getTexture(g,"t")),e.push("uv"),e.push(this.cropOrOffset.build(g,"f")),this.mat&&e.push(this.mat.build(g,"mat3"));break}case"noise":{let i=Object.values(H0)[this.noiseFunctionIndex.value],t=new rg(`vec3 orthogonal(vec3 v) { + return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); + }`),C=i=="voronoi"?` + float v = ${i}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality); + v = remap(v, lowCut, highCut, 0.0, 1.0); + v = smax(v, 0.0, smoothness * 0.25); + v = smin(v, 1.0, smoothness * 0.25); + + return p + n * v * intensity; + `:` + return p + n * ${i}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity; + `,o=new rg(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) { + ${C} + }`,[at.simplex,at.simplexFractal,at.simplexAshima,at.fbm,at.perlin,at.voronoi]),B=new rg(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) { + vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); + vec3 tangent1 = orthogonal(normal); + vec3 tangent2 = normalize(cross(normal, tangent1)); + + // TODO(Max): The distance to the neighbors was originally scaled by 0.1. + // This caused some small oval/circular visual artifacts in the lighting. + // For now, simply using neighbors further away betters the problem, + // but we should figure out the underlying cause when we have some time. + // Maybe its related to how we calculate the tangent and bitangent? + vec3 nearby1 = position + tangent1; + vec3 nearby2 = position + tangent2; + vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); + vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality); + displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); + return displaced_position; + }`,[o,t]);I=g.include(B),e.push(this.scale.build(g,"f")),e.push(this.cropOrOffset.build(g,"v3")),e.push(this.movementOrTexture.build(g,"f")),e.push(this.voronoiStyle.build(g,"i")),e.push(this.smoothness.build(g,"f")),e.push(this.seed.build(g,"f")),e.push(this.highCut.build(g,"f")),e.push(this.lowCut.build(g,"f")),e.push(this.quality.build(g,"i"));break}}return e.push(this.intensity.build(g,"f")),e.push("displaced_normal"),g.format(I+"("+e.join(",")+")",this.getType(g),A)}else return console.warn("VertexDisplacementNode is not compatible with "+g.shader+" shader."),g.format("vec3( 0.0 )",this.getType(g),A)}},LK=qK;LK.Nodes=function(){let g=new rg(`vec3 orthogonal(vec3 v) { + return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); + }`),A=new rg(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) { + vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset; + vec4 tmp = texture2D(tex, uvs); + vec3 col = tmp.rgb; + if (crop > 0.5) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + return 0.0; + } + } + return col.r; + }`);return{map:new rg(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) { + vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity; + vec3 tangent1 = normalize(orthogonal(normal)); + vec3 tangent2 = normalize(cross(normal, tangent1)); + vec3 nearby1 = position + tangent1 * 0.1; + vec3 nearby2 = position + tangent2 * 0.1; + vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; + vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; + displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); + return displaced_position; + }`,[g,A])}}();var Tg={normalRenderTarget:new nB,normalRenderTargetDepth:new nB,transmissionRenderTarget:new nB,aspectRatio:new wi,transmissionSize:new wi(2048,2048),transmissionRenderTargetDepth:new nB,aoRenderTarget:new nB,aoEnabled:new Wi,pixelRatioNode:new yg(1),resolution:new wi,penumbraSize:new Br(5,.5),frameIndex:new ge(0),transmissionLod:new ge(2)};for(let g of Object.values(Tg))g.isRenderGlobal=!0;var bK=class extends Ka{constructor(){super("basic"),this.nodeType="Basic",this.color=new Ge(CC),this.shadingAlpha=new yg(1),this.shadingBlend=new ge(0),this.previousModelViewMatrix=new mo,this.previouseProjectionMatrix=new mo}get category(){return"phong"}generate(g){let A;if(g.isShader("vertex")){let I=this.position?this.position.analyzeAndFlow(g,"v3",{cache:"position"}):void 0;g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({resolution:Tg.resolution}),g.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),g.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),g.mergeUniform(WQ.merge([ag.fog])),g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include "].join(` +`));let e=["#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #if defined( USE_LAYER_DISPLACE ) + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif /* !USE_LAYER_DISPLACE */ + `];I&&e.push(I.code,I.result?"displaced_position = "+I.result+";":""),e.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),e.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include "),e.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),A=e.join(` +`)}else{this.color===void 0&&(this.color=new Ge(CC)),this.color.analyze(g,{slot:"color"}),this.alpha&&this.alpha.analyze(g),this.afterColor&&this.afterColor.analyze(g,{slot:"afterColor"});let I=this.color.flow(g,"c",{slot:"color"}),e=this.alpha?this.alpha.flow(g,"f"):void 0,i=this.alphaOverride?this.alphaOverride.flow(g,"f"):void 0,t=this.afterColor?this.afterColor.flow(g,"c",{slot:"afterColor"}):void 0;g.requires.transparent=e!==void 0,g.addParsCode(["varying vec3 vWPosition;","#include ","#include ","varying vec3 vViewPosition;","#include "].join(` +`));let C=["#include ",I.code];e&&C.push(e.code,"#ifdef ALPHATEST"," if ( "+e.result+" <= ALPHATEST ) discard;","#endif"),t?C.push(t.code,`vec3 outgoingLight = ${I.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${t.result}, 1.0, SPE_BLENDING_NORMAL);`):C.push(`vec3 finalColor = ${I.result};`);let o="1.0";this.mask&&(this.mask.analyze(g),o=`luminance(${this.mask.flow(g,"v3").result})`),e?C.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${e.result} * ${o} );`):C.push("gl_FragColor = vec4("+I.result+", 1.0 );"),i&&C.push(`gl_FragColor.a *= ${i.result};`),C.push("#include ","#include "),A=C.join(` +`)}return A}},Mz=class extends Ka{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new Ge(CC),this.emissive=new Ge(0),this.emissiveIntensity=new yg(1),this.previousModelViewMatrix=new mo,this.previouseProjectionMatrix=new mo,this.shadingAlpha=new yg(1),this.shadingBlend=new ge(0),this.occlusion=new Wi(!0)}get category(){return"lambert"}build(g){let A;if(g.define("LAMBERT"),g.requires.lights=!0,g.extensions.derivatives=!0,g.isShader("vertex")){let I=this.position?this.position.analyzeAndFlow(g,"v3",{cache:"position"}):void 0;g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({resolution:Tg.resolution}),g.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),g.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),g.mergeUniform(WQ.merge([ag.fog,ag.lights])),g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let e=["#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #ifdef USE_LAYER_DISPLACE + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + `];I&&e.push(I.code,I.result?"displaced_position = "+I.result+";":""),e.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),e.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include ",` + vec3 diffuse = vec3( 1.0 ); + GeometricContext geometry; + geometry.position = mvPosition.xyz; + geometry.normal = normalize( transformedNormal ); + geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); + `),e.push(` + GeometricContext backGeometry; + backGeometry.position = geometry.position; + backGeometry.normal = -geometry.normal; + backGeometry.viewDir = geometry.viewDir; + vLightFront = vec3( 0.0 ); + vIndirectFront = vec3( 0.0 ); + #ifdef DOUBLE_SIDED + vLightBack = vec3( 0.0 ); + vIndirectBack = vec3( 0.0 ); + #endif + IncidentLight directLight; + float dotNL; + vec3 directLightColor_Diffuse; + vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); + vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); + #ifdef DOUBLE_SIDED + vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); + vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); + #endif + #if NUM_POINT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + getPointLightInfo( pointLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + getSpotLightInfo( spotLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_DIR_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_HEMI_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #ifdef DOUBLE_SIDED + vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); + #endif + } + #pragma unroll_loop_end + #endif + `," #include "," #include "),e.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),A=e.join(` +`)}else{g.mergeUniform({penumbraSize:Tg.penumbraSize}),g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({aoMap:Tg.aoRenderTarget}),g.mergeUniform({aoEnabled:Tg.aoEnabled}),this.color===void 0&&(this.color=new Ge(CC)),this.color.analyze(g,{slot:"color"}),this.shadingAlpha.analyze(g),this.shadingBlend.analyze(g),this.afterColor&&this.afterColor.analyze(g,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(g);let I=this.color.flow(g,"c",{slot:"color"}),e=this.emissive.flow(g,"c",{slot:"emissive"}),i=this.emissiveIntensity.flow(g,"f",{slot:"emissive"}),t=this.occlusion.flow(g,"b",{slot:"occlusion"}),C=this.shadingAlpha.flow(g,"f"),o=this.shadingBlend.flow(g,"i"),B=this.afterColor?this.afterColor.flow(g,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(g,"f"):void 0,s=this.alphaOverride?this.alphaOverride.flow(g,"f"):void 0;g.requires.transparent=a!==void 0,g.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include ","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let r=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx, viewdy)); + bool isFrontFacing = (dot(normal, faceNormal) >= 0.0); + `,"#include "];r.push(I.code,"vec3 diffuseColor = "+I.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),a&&r.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),r.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include ","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),e&&r.push(e.code,"reflectedLight.directDiffuse += "+e.result+" * "+i.result+";"),r.push("vec3 ao = aoEnabled && "+t.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let Q="1.0";this.mask&&(this.mask.analyze(g),Q=`luminance(${this.mask.flow(g,"v3").result})`),r.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${C.result} * ${Q} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${C.result} * ${Q}, ${o.result} ); + + outgoingLight *= ao; + } + `),B&&r.push(B.code,`outgoingLight = spe_blend(outgoingLight, ${B.result}, 1.0, SPE_BLENDING_NORMAL);`),a?r.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):r.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),s&&r.push(`gl_FragColor.a *= ${s.result};`),r.push("#include ","#include ","#include "),A=r.join(` +`)}return A}},bQ=function(){let g=new rg(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) { + + // Gradient of UVs w.r.t. X coordinate (in screen-space) + vec2 dSTdx = dFdx(bumpMapUv); + + // Gradient of UVs w.r.t. Y coordinate (in screen-space) + vec2 dSTdy = dFdy(bumpMapUv); + + // Forward differencing + float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb); + float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll; + float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll; + + return vec2( dBx, dBy ); + }`),A=new rg(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { + vec3 vSigmaX = dFdx( surf_pos.xyz ); + vec3 vSigmaY = dFdy( surf_pos.xyz ); + vec3 vN = surf_norm; // normalized + + vN = normalize(vN); + + vec3 R1 = cross( vSigmaY, vN ); + vec3 R2 = cross( vN, vSigmaX ); + + R1 = normalize(R1); + R2 = normalize(R2); + + float fDet = dot( vSigmaX, R1 ) * faceDirection; + + vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); + return normalize( abs( fDet ) * vN - vGrad ); + }`);return{dHdxy:g,perturbNormalArb:A}}(),mz=class extends Ka{constructor(){super("phong"),this.nodeType="Phong",this.color=new Ge(CC),this.specular=new Ge(1118481),this.shininess=new yg(30),this.previousModelViewMatrix=new mo,this.previouseProjectionMatrix=new mo,this.shadingAlpha=new yg(1),this.shadingBlend=new ge(0),this.occlusion=new Wi(!0)}get category(){return"phong"}build(g){let A;if(g.define("PHONG"),g.requires.lights=!0,g.extensions.derivatives=!0,g.isShader("vertex")){let I=this.position?this.position.analyzeAndFlow(g,"v3",{cache:"position"}):void 0;g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({resolution:Tg.resolution}),g.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),g.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),g.mergeUniform(WQ.merge([ag.fog,ag.lights])),g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include "].join(` +`));let e=["#include ",` + #include + #include + #ifndef USE_LAYER_DISPLACE + #include + #endif + + + vec3 displaced_position = position; + vec3 displaced_normal = objectNormal; + + #ifdef USE_LAYER_DISPLACE + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + `];I&&e.push(I.code,I.result?"displaced_position = "+I.result+";":""),e.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),e.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),e.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),A=e.join(` +`)}else{g.mergeUniform({penumbraSize:Tg.penumbraSize}),g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({aoMap:Tg.aoRenderTarget}),g.mergeUniform({aoEnabled:Tg.aoEnabled}),this.color===void 0&&(this.color=new Ge(CC)),this.color.analyze(g,{slot:"color"}),this.specular.analyze(g),this.shininess.analyze(g);let I=this.occlusion.flow(g,"b",{slot:"occlusion"});this.shadingAlpha.analyze(g),this.shadingBlend.analyze(g),this.afterColor&&this.afterColor.analyze(g,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(g);let e=this.color.flow(g,"c",{slot:"color"}),i=this.specular.flow(g,"c"),t=this.shininess.flow(g,"f"),C=this.shadingAlpha.flow(g,"f"),o=this.shadingBlend.flow(g,"i"),B=this.afterColor?this.afterColor.flow(g,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(g,"f"):void 0,s=this.alphaOverride?this.alphaOverride.flow(g,"f"):void 0;g.requires.transparent=a!==void 0,g.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let r=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," BlinnPhongMaterial material;"];if(this.bumpMap){g.include(bQ.dHdxy),g.include(bQ.perturbNormalArb);let E=this.bumpMap.texture.flow(g,"t"),n=this.bumpMap.flow(g,"v3"),h=this.bumpMapIntensity?this.bumpMapIntensity.flow(g,"f").result:"1.0",l="";this.bumpMap.projection.value===4?l=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${E.result}, uv0, ${h}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${E.result}, uv1, ${h}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${E.result}, uv2, ${h}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:l=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${E.result}, bumpMapCachedUv, ${h}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,r.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${n.result}; + ${l} + `)}r.push(e.code," vec3 diffuseColor = "+e.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",i.code," vec3 specular = "+i.result+";",t.code," float shininess = max( 0.0001, "+t.result+" );"," float specularStrength = 1.0;"),a&&r.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),r.push("material.diffuseColor = diffuseColor;"),r.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),r.push("vec3 ao = aoEnabled && "+I.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let Q="1.0";this.mask&&(this.mask.analyze(g),Q=`luminance(${this.mask.flow(g,"v3").result})`),r.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${C.result} * ${Q} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${C.result} * ${Q}, ${o.result} ); + + outgoingLight *= ao; + } + `),B&&r.push(B.code,`outgoingLight = spe_blend(outgoingLight, ${B.result}, 1.0, SPE_BLENDING_NORMAL);`),a?r.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result});`):r.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),s&&r.push(`gl_FragColor.a *= ${s.result};`),r.push("#include ","#include ","#include "),A=r.join(` +`)}return A}},Uz=class extends Ka{constructor(){super("standard"),this.nodeType="Standard",this.color=new Ge(CC),this.roughness=new yg(.3),this.metalness=new yg(0),this.reflectivity=new yg(.5),this.previousModelViewMatrix=new mo,this.previouseProjectionMatrix=new mo,this.shadingAlpha=new yg(1),this.shadingBlend=new ge(0),this.occlusion=new Wi(!0)}get category(){return"physical"}build(g){let A;if(g.define("STANDARD"),g.requires.lights=!0,g.extensions.derivatives=!0,g.extensions.shaderTextureLOD=!0,g.isShader("vertex")){let I=this.position?this.position.analyzeAndFlow(g,"v3",{cache:"position"}):void 0;g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({resolution:Tg.resolution}),g.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),g.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),g.mergeUniform(WQ.merge([ag.fog,ag.lights])),ag.LTC_1&&(g.uniforms.ltc_1={value:void 0},g.uniforms.ltc_2={value:void 0}),g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include "].join(` +`));let e=["#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #if defined( USE_LAYER_DISPLACE ) + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif /* !USE_LAYER_DISPLACE */ + `];I&&e.push(I.code,I.result?"displaced_position = "+I.result+";":""),e.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),e.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include ","#include "),e.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),A=e.join(` +`)}else{g.mergeUniform({penumbraSize:Tg.penumbraSize}),g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({aoMap:Tg.aoRenderTarget}),g.mergeUniform({aoEnabled:Tg.aoEnabled});let I={gamma:!0};this.color===void 0&&(this.color=new Ge(CC)),this.color.analyze(g,{slot:"color",context:I}),this.roughness.analyze(g),this.metalness.analyze(g);let e=this.occlusion.flow(g,"b",{slot:"occlusion"});this.shadingAlpha.analyze(g),this.shadingBlend.analyze(g),this.afterColor&&this.afterColor.analyze(g,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(g),this.reflectivity&&this.reflectivity.analyze(g);let i=this.color.flow(g,"c",{slot:"color",context:I}),t=this.roughness.flow(g,"f"),C=this.metalness.flow(g,"f"),o=this.shadingAlpha.flow(g,"f"),B=this.shadingBlend.flow(g,"i"),a=this.afterColor?this.afterColor.flow(g,"c",{slot:"afterColor"}):void 0,s=this.alpha?this.alpha.flow(g,"f"):void 0,r=this.alphaOverride?this.alphaOverride.flow(g,"f"):void 0,Q=this.reflectivity?this.reflectivity.flow(g,"f"):void 0;g.requires.transparent=s!==void 0,g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let E=["#include "," #include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){g.include(bQ.dHdxy),g.include(bQ.perturbNormalArb);let h=this.bumpMap.texture.flow(g,"t"),l=this.bumpMap.flow(g,"v3"),c=this.bumpMapIntensity?this.bumpMapIntensity.flow(g,"f").result:"1.0",d="";this.bumpMap.projection.value===4?d=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${h.result}, uv0, ${c}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${h.result}, uv1, ${c}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${h.result}, uv2, ${c}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:d=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${h.result}, bumpMapCachedUv, ${c}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,E.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${l.result}; + ${d} + `)}if(E.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",C.code," float metalnessFactor = "+C.result+";"),this.roughnessMap){let h=this.roughnessMap.texture.flow(g,"t"),l=this.roughnessMap.flow(g,"v3"),c="";this.roughnessMap.projection.value===4?c=` + float roughnessChange = 1.0; + { + vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + float r0 = luminance(texture(${h.result}, uv0).rgb) * roughnessScale; + float r1 = luminance(texture(${h.result}, uv1).rgb) * roughnessScale; + float r2 = luminance(texture(${h.result}, uv2).rgb) * roughnessScale; + + roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y); + } + float roughnessFactor = roughnessChange * ${t.result}; + `:c=` + vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs; + + vec4 vals = texture(${h.result}, roughnessMapCachedUv); + float roughnessFactor = luminance(vals.rgb) * ${t.result}; + `,E.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${l.result}; + + const float roughnessScale = 1.0; + + ${c} + `)}else E.push(t.code," float roughnessFactor = "+t.result+";");s&&E.push(s.code,"#ifdef ALPHATEST"," if ( "+s.result+" <= ALPHATEST ) discard;","#endif"),E.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),E.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 );"),Q?E.push(Q.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+Q.result+" ) ), diffuseColor, metalnessFactor );"):E.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),E.push("#include "),E.push("#include "),E.push("vec3 ao = aoEnabled && "+e.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let n="1.0";this.mask&&(this.mask.analyze(g),n=`luminance(${this.mask.flow(g,"v3").result})`),E.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${n} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${n}, ${B.result} ); + + outgoingLight *= ao; + } + `),a&&E.push(a.code,`outgoingLight = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`),s?E.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${s.result} );`):E.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),r&&E.push(`gl_FragColor.a *= ${r.result};`),E.push("#include ","#include ","#include "),A=E.join(` +`)}return A}},Nz=class extends Ka{constructor(){super("toon"),this.nodeType="Toon",this.color=new Ge(CC),this.specular=new Ge(1118481),this.shininess=new yg(30),this.previousModelViewMatrix=new mo,this.previouseProjectionMatrix=new mo,this.shadingAlpha=new yg(1),this.shadingBlend=new ge(0)}get category(){return"toon"}build(g){let A;if(g.define("TOON"),g.requires.lights=!0,g.extensions.derivatives=!0,g.isShader("vertex")){let I=this.position?this.position.analyzeAndFlow(g,"v3",{cache:"position"}):void 0;g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({resolution:Tg.resolution}),g.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),g.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),g.mergeUniform(WQ.merge([ag.fog,ag.lights])),g.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include "].join(` +`));let e=["#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #ifdef USE_LAYER_DISPLACE + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + `];I&&e.push(I.code,I.result?"displaced_position = "+I.result+";":""),e.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),e.push(" #include "," #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),e.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),A=e.join(` +`)}else{g.mergeUniform({penumbraSize:Tg.penumbraSize}),g.mergeUniform({frameIndex:Tg.frameIndex}),g.mergeUniform({aoMap:Tg.aoRenderTarget}),g.mergeUniform({aoEnabled:Tg.aoEnabled}),this.color===void 0&&(this.color=new Ge(CC)),this.color.analyze(g,{slot:"color"}),this.specular.analyze(g),this.shininess.analyze(g),this.shadingAlpha.analyze(g),this.shadingBlend.analyze(g),this.afterColor&&this.afterColor.analyze(g,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(g);let I=this.color.flow(g,"c",{slot:"color"}),e=this.specular.flow(g,"c"),i=this.shininess.flow(g,"f"),t=this.shadingAlpha.flow(g,"f"),C=this.shadingBlend.flow(g,"i"),o=this.afterColor?this.afterColor.flow(g,"c",{slot:"afterColor"}):void 0,B=this.alpha?this.alpha.flow(g,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(g,"f"):void 0;g.requires.transparent=B!==void 0,g.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include ",` + varying vec3 vViewPosition; + struct ToonMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; + }; + void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; + } + void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + } + #define RE_Direct RE_Direct_Toon + #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon + #define Material_LightProbeLOD( material ) (0) + `,"#include ","#include ","#include "].join(` +`));let s=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," ToonMaterial material;"];if(this.bumpMap){g.include(bQ.dHdxy),g.include(bQ.perturbNormalArb);let Q=this.bumpMap.texture.flow(g,"t"),E=this.bumpMap.flow(g,"v3"),n=this.bumpMapIntensity?this.bumpMapIntensity.flow(g,"f").result:"1.0",h="";this.bumpMap.projection.value===4?h=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${Q.result}, uv0, ${n}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${Q.result}, uv1, ${n}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${Q.result}, uv2, ${n}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:h=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${Q.result}, bumpMapCachedUv, ${n}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,s.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${E.result}; + ${h} + `)}s.push(I.code," vec3 diffuseColor = "+I.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",e.code," vec3 specular = "+e.result+";",i.code," float shininess = max( 0.0001, "+i.result+" );"," float specularStrength = 1.0;"),B&&s.push(B.code,"#ifdef ALPHATEST","if ( "+B.result+" <= ALPHATEST ) discard;","#endif"),s.push("material.diffuseColor = diffuseColor;"),s.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),s.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let r="1.0";this.mask&&(this.mask.analyze(g),r=`luminance(${this.mask.flow(g,"v3").result})`),s.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${t.result} * ${r} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${t.result} * ${r}, ${C.result} ); + } + `),o&&s.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),B?s.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${B.result} );`):s.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),a&&s.push(`gl_FragColor.a *= ${a.result};`),s.push("#include ","#include ","#include "),A=s.join(` +`)}return A}},Fz=class{constructor(g=1e3*10){this.timeout=g,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(...g){}remove(g){let A=this.cache.get(g);A&&(this.dispose(g,A.data),this.cache.delete(g),A.prev.next=A.next,A.next.prev=A.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let g=Date.now(),A=this.head.next;for(;A.time"u")return;this.disposeTextures(),this.loaded=!1;let A=()=>{this.loaded=!0;let e=[1e3,1001,1002];for(let i of e){let t=this[i];t&&(t.image=this.img,t.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 g!="string"){var I=new FileReader;I.readAsDataURL(new Blob([g],{type:"video/mp4"}));let e;await new Promise(i=>{I.onloadend=t=>{var C;e=(C=t.target)==null?void 0:C.result,i(null)}}),this.img.src=e}else this.img.src=g;this.img.onloadeddata=()=>{A()}}else this.img=new Image,this.img.src=Kz(g),this.img.onload=A}getTexture(g){let A=this[g];if(A)return A;{let I;return this.isVideo?I=new vH(this.img,void 0,g,g):I=new ti(this.img,void 0,g,g),this.loaded&&(I.needsUpdate=!0),this[g]=I,I}}disposeTextures(){var g,A,I;(g=this[1e3])==null||g.dispose(),this[1e3]=void 0,(A=this[1001])==null||A.dispose(),this[1001]=void 0,(I=this[1002])==null||I.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},dr=class extends YK{};function qz(g,A){var I=xz(A);return I.formatToParts?bz(I,g):Yz(I,g)}var Lz={year:0,month:1,day:2,hour:3,minute:4,second:5};function bz(g,A){try{for(var I=g.formatToParts(A),e=[],i=0;i=0&&(e[t]=parseInt(I[i].value,10))}return e}catch(C){if(C instanceof RangeError)return[NaN];throw C}}function Yz(g,A){var I=g.format(A).replace(/\u200E/g,""),e=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(I);return[e[3],e[1],e[2],e[4],e[5],e[6]]}var _u={};function xz(g){if(!_u[g]){var A=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")),I=A==="06/25/2014, 00:00:00"||A==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";_u[g]=I?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:g,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:g,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return _u[g]}function xK(g,A,I,e,i,t,C){var o=new Date(0);return o.setUTCFullYear(g,A,I),o.setUTCHours(e,i,t,C),o}var ZM=36e5,Hz=6e4,Pu={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function HK(g,A,I){var e,i;if(!g||(e=Pu.timezoneZ.exec(g),e))return 0;var t;if(e=Pu.timezoneHH.exec(g),e)return t=parseInt(e[1],10),VM(t)?-(t*ZM):NaN;if(e=Pu.timezoneHHMM.exec(g),e){t=parseInt(e[1],10);var C=parseInt(e[2],10);return VM(t,C)?(i=Math.abs(t)*ZM+C*Hz,t>0?-i:i):NaN}if(_z(g)){A=new Date(A||Date.now());var o=I?A:Tz(A),B=$y(o,g),a=I?B:Oz(A,B,g);return-a}return NaN}function Tz(g){return xK(g.getFullYear(),g.getMonth(),g.getDate(),g.getHours(),g.getMinutes(),g.getSeconds(),g.getMilliseconds())}function $y(g,A){var I=qz(g,A),e=xK(I[0],I[1]-1,I[2],I[3]%24,I[4],I[5],0).getTime(),i=g.getTime(),t=i%1e3;return i-=t>=0?t:1e3+t,e-i}function Oz(g,A,I){var e=g.getTime(),i=e-A,t=$y(new Date(i),I);if(A===t)return A;i-=t-A;var C=$y(new Date(i),I);return t===C?t:Math.max(t,C)}function VM(g,A){return-23<=g&&g<=23&&(A==null||0<=A&&A<=59)}var zM={};function _z(g){if(zM[g])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:g}),zM[g]=!0,!0}catch{return!1}}var Pz=Fa(Sq(),1),XM=Fa(fq(),1),jz=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,Wz=jz,ju=36e5,$M=6e4,Zz=2,Zi={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:Wz};function Vz(g,A){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(g===null)return new Date(NaN);var I=A||{},e=I.additionalDigits==null?Zz:(0,Pz.default)(I.additionalDigits);if(e!==2&&e!==1&&e!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(g instanceof Date||typeof g=="object"&&Object.prototype.toString.call(g)==="[object Date]")return new Date(g.getTime());if(typeof g=="number"||Object.prototype.toString.call(g)==="[object Number]")return new Date(g);if(!(typeof g=="string"||Object.prototype.toString.call(g)==="[object String]"))return new Date(NaN);var i=zz(g),t=Xz(i.date,e),C=t.year,o=t.restDateString,B=$z(o,C);if(isNaN(B))return new Date(NaN);if(B){var a=B.getTime(),s=0,r;if(i.time&&(s=AX(i.time),isNaN(s)))return new Date(NaN);if(i.timeZone||I.timeZone){if(r=HK(i.timeZone||I.timeZone,new Date(a+s)),isNaN(r))return new Date(NaN)}else r=(0,XM.default)(new Date(a+s)),r=(0,XM.default)(new Date(a+s+r));return new Date(a+s+r)}else return new Date(NaN)}function zz(g){var A={},I=Zi.dateTimePattern.exec(g),e;if(I?(A.date=I[1],e=I[3]):(I=Zi.datePattern.exec(g),I?(A.date=I[1],e=I[2]):(A.date=null,e=g)),e){var i=Zi.timeZone.exec(e);i?(A.time=e.replace(i[1],""),A.timeZone=i[1].trim()):A.time=e}return A}function Xz(g,A){var I=Zi.YYY[A],e=Zi.YYYYY[A],i;if(i=Zi.YYYY.exec(g)||e.exec(g),i){var t=i[1];return{year:parseInt(t,10),restDateString:g.slice(t.length)}}if(i=Zi.YY.exec(g)||I.exec(g),i){var C=i[1];return{year:parseInt(C,10)*100,restDateString:g.slice(C.length)}}return{year:null}}function $z(g,A){if(A===null)return null;var I,e,i,t;if(g.length===0)return e=new Date(0),e.setUTCFullYear(A),e;if(I=Zi.MM.exec(g),I)return e=new Date(0),i=parseInt(I[1],10)-1,gm(A,i)?(e.setUTCFullYear(A,i),e):new Date(NaN);if(I=Zi.DDD.exec(g),I){e=new Date(0);var C=parseInt(I[1],10);return eX(A,C)?(e.setUTCFullYear(A,0,C),e):new Date(NaN)}if(I=Zi.MMDD.exec(g),I){e=new Date(0),i=parseInt(I[1],10)-1;var o=parseInt(I[2],10);return gm(A,i,o)?(e.setUTCFullYear(A,i,o),e):new Date(NaN)}if(I=Zi.Www.exec(g),I)return t=parseInt(I[1],10)-1,Im(A,t)?Am(A,t):new Date(NaN);if(I=Zi.WwwD.exec(g),I){t=parseInt(I[1],10)-1;var B=parseInt(I[2],10)-1;return Im(A,t,B)?Am(A,t,B):new Date(NaN)}return null}function AX(g){var A,I,e;if(A=Zi.HH.exec(g),A)return I=parseFloat(A[1].replace(",",".")),Wu(I)?I%24*ju:NaN;if(A=Zi.HHMM.exec(g),A)return I=parseInt(A[1],10),e=parseFloat(A[2].replace(",",".")),Wu(I,e)?I%24*ju+e*$M:NaN;if(A=Zi.HHMMSS.exec(g),A){I=parseInt(A[1],10),e=parseInt(A[2],10);var i=parseFloat(A[3].replace(",","."));return Wu(I,e,i)?I%24*ju+e*$M+i*1e3:NaN}return null}function Am(g,A,I){A=A||0,I=I||0;var e=new Date(0);e.setUTCFullYear(g,0,4);var i=e.getUTCDay()||7,t=A*7+I+1-i;return e.setUTCDate(e.getUTCDate()+t),e}var gX=[31,28,31,30,31,30,31,31,30,31,30,31],IX=[31,29,31,30,31,30,31,31,30,31,30,31];function TK(g){return g%400===0||g%4===0&&g%100!==0}function gm(g,A,I){if(A<0||A>11)return!1;if(I!=null){if(I<1)return!1;var e=TK(g);if(e&&I>IX[A]||!e&&I>gX[A])return!1}return!0}function eX(g,A){if(A<1)return!1;var I=TK(g);return!(I&&A>366||!I&&A>365)}function Im(g,A,I){return!(A<0||A>52||I!=null&&(I<0||I>6))}function Wu(g,A,I){return!(g!=null&&(g<0||g>=25)||A!=null&&(A<0||A>=60)||I!=null&&(I<0||I>=60))}function iX(g,A,I){var e=Vz(g,I),i=HK(A,e,!0),t=new Date(e.getTime()-i),C=new Date(0);return C.setFullYear(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),C.setHours(t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()),C}function Vi(g,A){return A.color(g)}function em(g=new Date,A){let I=A.format,e=g.getSeconds(),i=g;A&&A.timeZone!==null&&(i=iX(new Date,A.timeZone));let t=i.getHours(),C=i.getMinutes(),o;A.format12h24h==="12ampm"&&(o=t>=12?"PM":"AM");let B=t;A.format12h24h!=="24"&&(B=t%12,B===0&&(B=12));let a,s;switch(I){case"HH:mm:ss":a=[B,C,e];break;case"HH:mm":a=[B,C];break;case"HH":a=[B],o=void 0;break;case"mm":a=[C],o=void 0;break;case"ss":a=[e],o=void 0;break;case"year":s=i.getFullYear();break;case"month":s=i.getMonth()+1;break;case"dayOfYear":s=Math.floor((i.getTime()-new Date(i.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":s=i.getDate();break;case"secondOfDay":s=t*60*60+C*60+e;break;default:console.error("Unknown time format",I),s=0;break}return a!==void 0?{textValue:a,suffix:o}:s}function tX(g,A){switch(g.type){case"fresnel":return BX(g,A);case"gradient":return aX(g,A);case"depth":return rX(g,A);case"normal":return sX(g,A);case"noise":return QX(g,A);case"rainbow":return EX(g,A);case"toon":return nX(g,A);case"outline":return hX(g,A);case"transmission":return lX(g,A);case"color":return oX(g,A);case"pattern":return cX(g,A)}}function CX(g){return{type:g.type}}function bC(g,A){let{alpha:I,mode:e,isMask:i}=g,t=typeof I=="string"?(Number(A.getVariable(I))??100)/100:I;return{...CX(g),alpha:t,mode:e,isMask:i}}function oX(g,A){return{...bC(g,A),color:Vi(g.color,A)}}function BX(g,A){let{bias:I,scale:e,intensity:i,factor:t,color:C}=g;return{...bC(g,A),color:Vi(C,A),bias:I,scale:e,intensity:i,factor:t}}function aX(g,A){let{gradientType:I,smooth:e,colors:i,steps:t,angle:C,offset:o,morph:B}=g;return{...bC(g,A),gradientType:I,smooth:e,colors:i.map(a=>new EI(a[0],a[1],a[2],a[3])),num:i.length,steps:t,offset:new sA(...o),morph:new sA(...B),angle:C}}function rX(g,A){let{gradientType:I,near:e,far:i,isVector:t,isWorldSpace:C,origin:o,direction:B,colors:a,steps:s,smooth:r}=g;return{...bC(g,A),gradientType:I,near:e,far:i,isVector:t,isWorldSpace:C,origin:new J(...o),direction:B?new J(...B):new J(1,0,0),colors:a.map(Q=>Q!==void 0?new EI(Q[0],Q[1],Q[2],Q[3]):new EI(0,0,0,0)),steps:s.slice(0,a.length),smooth:r}}function sX(g,A){let{cnormal:I}=g;return{...bC(g,A),cnormal:new J(I[0],I[1],I[2])}}function QX(g,A){return{...bC(g,A),scale:g.scale,move:g.move,fA:new sA(...g.fA),fB:new sA(...g.fB),size:new J(...g.size),distortion:new sA(...g.distortion),colorA:Vi(g.colorA,A),colorB:Vi(g.colorB,A),colorC:Vi(g.colorC,A),colorD:Vi(g.colorD,A),noiseType:g.noiseType,voronoiStyle:g.voronoiStyle,highCut:g.highCut,lowCut:g.lowCut,smoothness:g.smoothness,seed:g.seed,quality:g.quality}}function EX(g,A){return{...bC(g,A),filmThickness:g.filmThickness,movement:g.movement,wavelengths:new J(...g.wavelengths),noiseStrength:g.noiseStrength,noiseScale:g.noiseScale,offset:new J(...g.offset)}}function nX(g,A){return{...bC(g,A),positioning:g.positioning,colors:g.colors.map(I=>new EI(I[0],I[1],I[2],I[3])),num:g.colors.length,steps:g.steps,source:new J(...g.source),isWorldSpace:g.isWorldSpace,noiseStrength:g.noiseStrength,noiseScale:g.noiseScale,shadowColor:Vi(g.shadowColor,A),offset:new J(...g.offset)}}function hX(g,A){return{...bC(g,A),outlineColor:Vi(g.outlineColor,A),contourColor:Vi(g.contourColor,A),outlineWidth:g.outlineWidth,contourWidth:g.contourWidth,outlineThreshold:g.outlineThreshold,contourThreshold:g.contourThreshold,outlineSmoothing:g.outlineSmoothing,contourFrequency:g.contourFrequency,contourDirection:new J(...g.contourDirection),positionalLines:g.positionalLines,compensation:g.compensation}}function lX(g,A){return{...bC(g,A),thickness:g.thickness,ior:g.ior,roughness:g.roughness}}function cX(g,A){return{...bC(g,A),style:g.style,projection:g.projection,axis:g.axis,blending:g.blending,offset:new sA(...g.offset),colorA:Vi(g.colorA,A),colorB:Vi(g.colorB,A),frequency:new sA(...g.frequency),size:g.size,variation:g.variation,smoothness:g.smoothness,zigzag:g.zigzag,rotation:g.rotation,vertical:new sA(...g.vertical),horizontal:new sA(...g.horizontal),sides:g.sides}}var gD=class extends lt{},OK={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},_K={depth:["colors"]};function DX(g,A,I){var t,C;if(A==="isMask")return!0;let e=OK[g.type],i=_K[g.type];if(i!==void 0){let o=g.color;if(i.includes(A)){let B=(C=(t=o[A])==null?void 0:t.value)==null?void 0:C.length;if(B!==void 0&&B!==I.length)return!0}}return e!==void 0?e.includes(A):!1}function PK(g,A,I){let e=I.uniforms[`f${I.id}_texture`];if(!e)return!1;let i=!1,t=g;if("image"in t){let C=t.image,o=A.image(C),B=e;B.image instanceof dr||B.image.deref(),B.image=o}if("video"in t){let C=t.video,o=A.video(C),B=e;B.image instanceof dr||B.image.deref(),B.image=o}if("wrapping"in t){let C=e;C.wrap=t.wrapping}if("repeat"in t||"offset"in t){let C="mat",o=I.uniforms[`f${I.id}_${C}`];"repeat"in t&&(o.repeat=t.repeat),"offset"in t&&(o.offset=t.offset),o.updateMatrix()}return i}function dX(g,A,I,e){let i=!1;for(let[t,C]of Object.entries(g)){if(t==="bumpMap"||t==="roughnessMap"){i=!0;continue}if(!t||C===void 0)continue;if(WK(t,I,e,A)){t==="visible"&&I.type==="light"&&(i=!0);continue}I.visible=e.visible;let o=I.uniforms[`f${I.id}_${t}`];if(o&&!(o instanceof Y0))switch(i=i||DX(I,t,C),o.constructor){case Ge:if(typeof C=="string"){let B=A.getColor(C);B&&(o.value=B);break}else{let B=C;o.value instanceof gD?o.value=new lt(B.r,B.g,B.b,B.a):o.setRGBA(B);break}case rB:if(typeof C=="string"){let B=A.getColor(C);B&&(o.value=B);break}else{let B=C;o.value instanceof gD?o.value=new lt(B.r,B.g,B.b,B.a):o.value.setRGBA(B.r,B.g,B.b,B.a);break}case wi:{let B=C;o.value.setX(B[0]),o.value.setY(B[1]);break}case Wt:{let B=C;o.value.setX(B[0]),o.value.setY(B[1]),o.value.setZ(B[2]);break}case nB:{PK(C,A,I);break}case ar:{o.value=C.map(B=>new EI(...B));break}default:{o.value=C;break}}}return i}var Jr=(g,A,I)=>Math.max(0,Math.min(1,Number(A.getVariable(typeof g=="number"?g*100:g,I)??100)/100))??1,mr=class{constructor(A,I,e,i,t){this.id=A,this.uuid=I,this.data=e,this.uniforms={};for(let C in i)this.uniforms[`f${this.id}_${C}`]=i[C];for(let C in e)WK(C,this,e,t)}get type(){return this.data.type}static create(A,I,e,i){if(e.type==="light")return sB.createLigherLayer(A,I,e,i);if(e.type==="texture"||e.type==="video"){let t=e.type==="texture"?i.image(e.texture.image):i.video(e.texture.video),C=new Vy(t,e.texture.wrapping),o=new wz(t),B=new Sz(e.texture.repeat,e.texture.offset),a=new yg(e.crop?1:0),s=new ge(e.projection??0),r=new ge(["x","y","z"].indexOf(e.axis)??0),Q=new ge(e.side??0),E=new wi(e.size?new sA(e.size[0],e.size[1]):new sA(100,100)),n=new yg(e.blending??0),h=new yg(Jr(e.alpha,i)),l=new ge(e.mode??0),c=new Wi(e.isMask??!1),d=new x0(C,o,a,s,r,Q,E,n,B,h,l,c),u=new se(d.calpha,"f");return new we(A,I,e,{texture:C,textureSize:o,crop:a,projection:s,axis:r,side:Q,size:E,blending:n,mat:B,alpha:h,mode:l,isMask:c},d,l,u,c,i)}else if(e.type==="matcap"){let t=i.image(e.texture.image),C=new Vy(t,e.texture.wrapping),o=new yg(Jr(e.alpha,i)),B=new ge(e.mode??0),a=new Wi(e.isMask??!1),s=new GK(C,o,B,a),r=new se(s.calpha,"f");return new we(A,I,e,{texture:C,alpha:o,mode:B,isMask:a},s,B,r,a,i)}else if(e.type==="displace")if(e.displacementType==="noise"){let t=new Wt(new J(...e.offset)),C=new yg(e.scale??10),o=new yg(e.intensity??8),B=new yg(e.movement??1),a=new ge(e.noiseType??0),s=new ge(e.voronoiStyle??0),r=new yg(e.smoothness??.5),Q=new yg(e.seed??0),E=new yg(e.highCut??1),n=new yg(e.lowCut??0),h=new ge(e.quality??1),l=new LK(o,B,t,s,r,Q,E,n,h,C,a);return new jK(A,I,e,{offset:t,scale:C,intensity:o,movement:B,noiseType:a,voronoiStyle:s,smoothness:r,seed:Q,highCut:E,lowCut:n,quality:h},l,i)}else throw new Error;else return yX(A,I,e,i)}updateByOp(A,I,e){let i=A;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props||"visible"in i.props?(e.scene.markNeedsUpdateRendererDirty(),!0):dX(i.props,e.shared,this,I)}else if(i.path[0]==="texture")return"texture"in I||"video"in I?PK(i.props,e.shared,this):!0;return!1}dispose(){if(uX(this)){let A=this.uniforms[`f${this.id}_texture`];if(!A)return!1;let I=A;I.image instanceof dr||I.image.deref()}}hasValueByKey(A){return this.uniforms[A]!==void 0}hasValue(A){return this.hasValueByKey(`f${this.id}_${A}`)}setValue(A,I){let e=`f${this.id}_${A}`;this.hasValueByKey(e)&&I!==void 0&&(this.uniforms[e].value=I)}getNode(A){let I=`f${this.id}_${A}`;if(this.hasValueByKey(I))return this.uniforms[I]}getValue(A){let I=`f${this.id}_${A}`;if(this.hasValueByKey(I))return this.uniforms[I].value}getName(A){let I=/f\d+_(.*)/.exec(A);if(I&&I.length>1)return I[1];console.log(`Layer.getName: error ${A}`)}getNames(){let A=[];for(let I in this.uniforms){let e=this.getName(I);e&&A.push(e)}return A}},we=class extends mr{constructor(A,I,e,i,t,C,o,B,a){super(A,I,e,i,a),this.params=i,this.color=t,this.mode=C,this.alpha=o,this.isMask=B}},jK=class extends mr{constructor(g,A,I,e,i,t){super(g,A,I,e,t),this.position=i}},sB=class extends mr{constructor(A,I,e,i,t,C){super(A,I,e,t,C),this.node=i}static createLigherLayer(A,I,e,i){let t,C=new yg(Jr(e.alpha,i)),o=new ge(e.mode),B=new yg(e.bumpMapIntensity),a=new yg(Jr(e.alphaOverride,i)),s;if(!e.visible)t=new bK,s={};else if(e.category==="lambert"){t=new Mz;let r=new Ge(i.color(e.emissive)??0),Q=new Wi(e.occlusion??!0);s={emissive:r,occlusion:Q},t.emissive=r,t.occlusion=Q}else if(e.category==="toon"){t=new Nz;let r=new yg(e.shininess??30),Q=new Ge(i.color(e.specular)??1118481);s={shininess:r,specular:Q},t.shininess=r,t.specular=Q}else if(e.category==="physical"){t=new Uz;let r=new yg(e.roughness??.3),Q=new yg(e.metalness??0),E=new yg(e.reflectivity??.5),n=new Wi(e.occlusion??!0);s={roughness:r,metalness:Q,reflectivity:E,occlusion:n},t.roughness=r,t.metalness=Q,t.reflectivity=E,t.occlusion=n}else{t=new mz;let r=new yg(e.shininess??30),Q=new Ge(e.specular!==void 0?i.color(e.specular)??1118481:1118481),E=new Wi(e.occlusion??!0);s={shininess:r,specular:Q,occlusion:E},t.shininess=r,t.specular=Q,t.occlusion=E}return t.alpha=new yg(1),t.shadingAlpha=C,t.shadingBlend=o,t.bumpMapIntensity=B,t.alphaOverride=a,s.alpha=t.shadingAlpha,s.mode=t.shadingBlend,s.bumpMapIntensity=t.bumpMapIntensity,s.alphaOverride=t.alphaOverride,new sB(A,I,e,t,s,i)}get category(){return this.node.category}};function uX(g){let A=g instanceof mr?g.type:g;return A==="texture"||A==="video"||A==="displace_map"||A==="matcap"}function Tt(g){return{alpha:new yg(g.alpha??1),mode:new ge(g.mode??0),isMask:new Wi(g.isMask??!1)}}function pX(g,A,I,e,i){switch(g.type){case"color":{let t=new Ge(e.color??CC),C=Tt(e),o=new zy(t,C.alpha),B=new se(o.calpha,"f");return new we(A,I,g,{color:t,...C},o,C.mode,B,C.isMask,i)}case"fresnel":{let t=new Ge(e.color??16777215),C=new yg(e.bias??.1),o=new yg(e.scale??1),B=new yg(e.intensity??2),a=new yg(e.factor??1),s=Tt(e),r=new fz(t,C,o,B,a,s.alpha,s.mode,s.isMask),Q=new se(r.calpha,"f");return new we(A,I,g,{color:t,bias:C,scale:o,intensity:B,factor:a,...s},r,s.mode,Q,s.isMask,i)}case"rainbow":{let t=new yg(e.filmThickness??30),C=new yg(e.movement??0),o=new Wt(e.wavelengths??new J(0,0,0)),B=new yg(e.noiseStrength??0),a=new yg(e.noiseScale??1),s=new Wt(e.offset??new J(0,0,0)),r=Tt(e),Q=new FK(t,C,o,B,a,s,r.alpha,r.isMask),E=new se(Q.calpha,"f");return new we(A,I,g,{filmThickness:t,movement:C,wavelengths:o,noiseStrength:B,noiseScale:a,offset:s,...r},Q,r.mode,E,r.isMask,i)}case"transmission":{let t=new yg(e.thickness??10),C=new yg(e.ior??1.5),o=new yg(e.roughness??.5),B=Tg.transmissionSize,a=Tg.transmissionRenderTarget,s=Tg.transmissionRenderTargetDepth,r=window.innerWidth,Q=window.innerHeight,E=r>=Q?new wi(Q/r,1):new wi(1,r/Q),n=Tt(e),h=new vK(t,C,o,B,a,s,E,n.alpha),l=new se(h.calpha,"f");return new we(A,I,g,{thickness:t,ior:C,roughness:o,aspectRatio:E,...n},h,n.mode,l,n.isMask,i)}case"toon":{let t=new ge(e.positioning??0),C;e.colors?C=new ar(e.colors.length,e.colors):(C=new ar(10,new EI(0,0,0,1)),C.value[1]=new EI(1,1,1,1));let o;e.steps?o=new Br(e.steps.length,e.steps):(o=new Br(10,1),o.value[0]=0);let B=new Wt(e.source??new J(0,0,0)),a=new Wi(e.isWorldSpace??!0),s=new yg(e.noiseStrength??0),r=new yg(e.noiseScale??1),Q=new rB(e.shadowColor),E=new Wt(e.offset??new J(0,0,0)),n=Tt(e),h=new KK(t,C,o,B,a,s,r,Q,E,n.alpha),l=new se(h.calpha,"f");return new we(A,I,g,{positioning:t,colors:C,steps:o,source:B,isWorldSpace:a,noiseStrength:s,noiseScale:r,shadowColor:Q,offset:E,...n},h,n.mode,l,n.isMask,i)}case"outline":{let t=new Ge(e.outlineColor??16777215),C=new Ge(e.contourColor??16777215),o=new yg(e.outlineWidth??.1),B=new yg(e.contourWidth??.1),a=new yg(e.outlineThreshold??.1),s=new yg(e.contourThreshold??.1),r=new yg(e.outlineSmoothing??.1),Q=new yg(e.contourFrequency??.1),E=new Wt(e.contourDirection??new J(0,1,0)),n=new Wi(e.positionalLines??!1),h=new Wi(e.compensation??!0),l=Tg.normalRenderTarget,c=Tg.normalRenderTargetDepth,d=Tg.pixelRatioNode,u=Tg.resolution,y=Tt(e),f=new mK(t,C,o,B,a,s,r,Q,E,n,h,u,l,c,d,y.alpha),k=new se(f.calpha,"f");return new we(A,I,g,{outlineColor:t,contourColor:C,outlineWidth:o,contourWidth:B,outlineThreshold:a,contourThreshold:s,outlineSmoothing:r,contourFrequency:Q,contourDirection:E,positionalLines:n,compensation:h,...y},f,y.mode,k,y.isMask,i)}case"depth":{let t=new ge(e.gradientType??0),C=new Wi(e.smooth??!1),o=new yg(e.near??50),B=new yg(e.far??200),a=new yg(e.isVector??1),s=new yg(e.isWorldSpace??0),r=new Wt(e.origin??new J),Q=new Wt(e.direction??new J),E;e.colors?E=new ar(e.colors.length,e.colors):(E=new ar(2,new EI(0,0,0,1)),E.value[1]=new EI(1,1,1,1));let n;e.steps?n=new Br(e.steps.length,e.steps):(n=new Br(2,1),n.value[0]=0);let h=Tt(e),l=new yK(t,C,o,B,a,s,r,Q,E,n,h.alpha,h.isMask),c=new se(l.calpha,"f");return new we(A,I,g,{gradientType:t,smooth:C,near:o,far:B,isVector:a,isWorldSpace:s,origin:r,direction:Q,colors:E,steps:n,...h},l,h.mode,c,h.isMask,i)}case"noise":{let t=new yg(e.scale??1),C=new Wt(e.size??new J(100,100,100)),o=new yg(e.move??1),B=new wi(e.fA??new sA(1.7,9.2)),a=new wi(e.fB??new sA(8.3,2.8)),s=new wi(e.distortion??new sA(1,1)),r=new rB(e.colorA),Q=new rB(e.colorB),E=new rB(e.colorC),n=new rB(e.colorD),h=new ge(e.noiseType??0),l=new ge(e.voronoiStyle??0),c=new yg(e.highCut??1),d=new yg(e.lowCut??0),u=new yg(e.smoothness??.5),y=new yg(e.seed??.5),f=new ge(e.quality??1),k=Tt(e),M=new kK(t,C,o,B,a,s,r,Q,E,n,k.alpha,h,k.isMask,l,c,d,u,y,f),G=new se(M.calpha,"f");return new we(A,I,g,{scale:t,size:C,move:o,fA:B,fB:a,distortion:s,colorA:r,colorB:Q,colorC:E,colorD:n,noiseType:h,...k,voronoiStyle:l,highCut:c,lowCut:d,smoothness:u,seed:y,quality:f},M,k.mode,G,k.isMask,i)}case"normal":{let t=new Wt(e.cnormal??new J(1,1,1)),C=Tt(e),o=new pK(t,C.alpha),B=new se(o.calpha,"f");return new we(A,I,g,{cnormal:t,...C},o,C.mode,B,C.isMask,i)}case"gradient":{let t=new ge(e.gradientType??0),C=new Wi(e.smooth??!1),o;e.colors?o=new ar(e.colors.length,e.colors):(o=new ar(10,new EI(0,0,0,1)),o.value[1]=new EI(1,1,1,1));let B;e.steps?B=new Br(e.steps.length,e.steps):(B=new Br(10,1),B.value[0]=0);let a=new wi(e.offset??new sA(0,0)),s=new wi(e.morph??new sA(0,0)),r=new yg(e.angle??0),Q=Tt(e),E=new SK(t,C,o,B,a,s,r,Q.alpha,Q.isMask),n=new se(E.calpha,"f");return new we(A,I,g,{gradientType:t,smooth:C,colors:o,steps:B,offset:a,morph:s,angle:r,...Q},E,Q.mode,n,Q.isMask,i)}case"pattern":{let t=new ge(e.style??0),C=new ge(e.projection??0),o=new ge(["x","y","z"].indexOf(e.axis)??0),B=new yg(e.blending??0),a=new wi(e.offset??new sA(0,0)),s=new rB(e.colorA),r=new rB(e.colorB),Q=new wi(e.frequency??new sA(10,10)),E=new yg(e.size??.5),n=new yg(e.variation??0),h=new yg(e.smoothness??.5),l=new yg(e.zigzag??0),c=new yg(e.rotation??0),d=new wi(e.vertical??new sA(0,1)),u=new wi(e.horizontal??new sA(0,1)),y=new ge(e.sides??6),f=Tt(e),k=new UK(t,C,o,B,a,s,r,Q,E,n,h,l,c,d,u,y,f.alpha,f.isMask),M=new se(k.calpha,"f");return new we(A,I,g,{style:t,projection:C,axis:o,blending:B,offset:a,colorA:s,colorB:r,frequency:Q,size:E,variation:n,smoothness:h,zigzag:l,rotation:c,vertical:d,horizontal:u,sides:y,...f},k,f.mode,M,f.isMask,i)}default:{let t=new Ge(1,0,0,1),C=Tt(e),o=new zy(t,C.alpha),B=new se(o.calpha,"f");return new we(A,I,g,{color:t,...C},o,C.mode,B,C.isMask,i)}}}function yX(g,A,I,e){let i=tX(I,e);return pX(I,g,A,i,e)}function WK(g,A,I,e){if(I.type==="displace"&&(g==="intensity"||g==="visible")){let i=A.uniforms[`f${A.id}_intensity`];return i?(i.value=I.intensity*(I.visible?1:0),i):void 0}if(I.type!=="displace"&&(g==="alpha"||g==="visible")){let i=A.uniforms[`f${A.id}_alpha`];if(!i)return;if(i.value=Jr(I.alpha,e)*(I.visible?1:0),I.type==="outline"&&g==="visible"){let t=A.uniforms[`f${A.id}_compensation`];t&&(t.value=I.compensation&&I.visible)}return i}}function tQ(g,A){let I=0,e=g.layers.find(i=>i.data.type==="light");if(e){let i=e.data,t=Number(A.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?t/100:i.alphaOverride)<1)return!0}for(let i of g.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let t=i.data.visible?i.data.alpha:0;if(typeof t=="string"&&(t=Math.max(0,Math.min(1,Number(A.getVariable(t)??100)/100))),t===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let C of i.data.colors)if(C[3]<1){t=C[3];break}}else if(t===1&&i.data.type==="noise"){let C=A.color(i.data.colorA).a,o=A.color(i.data.colorB).a,B=A.color(i.data.colorC).a,a=A.color(i.data.colorD).a,s=Math.min(C,Math.min(o,Math.min(B,a)));s<1&&(t=s)}I+=(1-I)*t}}return I<1}var ka=class extends te{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}},wX=class extends ka{constructor(g,A,I,e){super(),this.flatShading=g,this.side=A,this.wireframe=I,this.root=e}updateAfterBuild(){let g=this.root;this.lights=g.lights,this.vertexShader=g.vertexShader,this.fragmentShader=g.fragmentShader,this.defines=g.defines,this.uniforms=g.uniforms,this.extensions=g.extensions,this.transparent=g.transparent,this.cacheKey=g.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(g,A){this.root.onBeforeCompile(g)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(g,A,I){return this.root.getFlavor(g,A,I)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(g){return this.root.getLayersOfType(g)}getLayerByUuid(g){return this.root.getLayerByUuid(g)}updateByOp(g,A,I){this.root.updateByOp(g,A,I)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},T0=class extends ka{constructor(g,A,I=!0){super(),this.data=g,this.allowVariableSaves=I,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(g,A)}get nodeMaterial(){return this}getFlavor(g,A,I){let e=I?6:(g?3:0)+A;if(e===0)return this;this.flavors===void 0&&(this.flavors=[]),e-=1;let i=this.flavors[e];return i===void 0&&(i=new wX(g,A,I,this),this.flavors[e]=i,i.flatShading=g,i.side=A,i.updateAfterBuild()),i}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){var g;return((g=this.lightLayer.getNode("occlusion"))==null?void 0:g.value)??!1}reset(g,A){this.data!==g&&this.reset0(g,A)}reset0(g,A){this.data=g;let I=g.layers??Ki.defaultTwoLayerData("phong").layers;try{this.layers=I.map(e=>mr.create(this.layerIdGen++,e.id,e.data,A.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=g.name??"Untitled Material",this.onUpdate(A.shared),this.transparent=tQ(g,A.shared),this.saveVariableLocations(A)}onVariableUpdate(g,A,I){if(g[0]==="alphaOverride")this.transparent=tQ(this.data,I.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(A)/100,1)));else if(g[0]==="layer"){let e=g[1],i=g[2];if(e&&i){let t=this.layers.find(C=>C.uuid===e);t!=null&&t.hasValue(i)&&(i==="alpha"?(this.transparent=tQ(this.data,I.shared),t.setValue(i,Math.max(0,Math.min(Number(A)/100,1)))):t.setValue(i,A))}}}saveVariableLocations(g){if(!this.allowVariableSaves)return;let A=this.data.layers.find(I=>I.data.type==="light");A&&g.shared.getVariable(A.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(I=>{"alpha"in I.data&&typeof I.data.alpha=="string"&&g.shared.getVariable(I.data.alpha,["material",this.uuid,"layer",I.id,"alpha"])})}getLayersOfType(g){return this.layers.filter(A=>A.type===g)}getLayerByUuid(g){return this.layers.find(A=>A.uuid===g)}onUpdate(g){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(A=>A instanceof sB),this.lightLayer===void 0&&(this.lightLayer=new sB(0,"",{...Bt.defaultData("light","phong"),visible:!1},new bK,{},g)),this.dispose();for(let A of this.flavors)A&&A.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let g=this.layers.find(i=>i instanceof sB);if(!g)return;let A=g.data,I=A.bumpMap,e=A.roughnessMap;g.node.bumpMap=void 0,g.node.roughnessMap=void 0;for(let i=0;io.uuid===g.id),C=this.layers[t];this.layers.splice(t,1),this.layers.splice(g.localIndex,0,C),I.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(I.shared)}else{g.type===0&&g.props.occlusion!==void 0&&I.scene.markNeedsUpdateRendererDirty();let t=this.layers.find(C=>C.uuid===i);if(t){let C=A.layers.data(i),o;if(g.type===0&&("alpha"in g.props||"alphaOverride"in g.props)&&("alpha"in g.props?o={...g.props,alpha:Jr(g.props.alpha,e,["material",this.uuid,"layer",i,"alpha"])}:o={...g.props,alphaOverride:Jr(g.props.alphaOverride,e,["material",this.uuid,"alphaOverride"])}),t.updateByOp({...g,...o?{props:o}:{},path:g.path.slice(2)},C,I)){let B=mr.create(this.layerIdGen++,i,C,e);this.layers.splice(this.layers.findIndex(a=>a.uuid===i),1,B),this.onUpdate(I.shared)}}}}else this.reset(A,I)}applyMasks(){for(let g=0;g0){let I=g-1,e=this.layers[I];e instanceof sB?e.node.mask=new ot(A.color,A.alpha,ot.MUL):e instanceof we&&(e.isMask.value||(e.color.mask=new ot(A.color,A.alpha,ot.MUL)))}}}blendColors(){let g=this.layers.findIndex(I=>I instanceof we),A=this.layers.findIndex(I=>I instanceof sB);if(g!==-1&&gI instanceof sB);if(this.layers.length>A+1){for(let I=A+1;IA instanceof jK);if(g.length>0){let A=g[0].position;for(let I=1;IMath.min(Math.max(e,i),t);for(let e of this.layers)if(e.type==="displace"){let i=I(e.uniforms[`f${e.id}_intensity`].value,g,A);e.uniforms[`f${e.id}_intensity`].value=i}}computeCacheKey(){let g="[";for(let{data:A}of this.data.layers)if(A.type==="light")g+=`"${A.visible?A.category.toUpperCase():"Basic"}"`;else{let I=(OK[A.type]??[]).map(o=>A[o]),e=(_K[A.type]??[]).map(o=>{var B;return((B=A[o])==null?void 0:B.length)??0}),i=[...I,...e],t="isMask"in A&&A.isMask,C=`"${A.type}-${A.visible}-${t}"`;i.length?g+=`[${C}, "${i.join('","')}"],`:g+=C}return g=g.slice(0,-1)+"]",g}updateFrame(g){for(let A=0;Ag.dispose()),super.dispose();for(let g of this.flavors)g&&g.dispose()}assetsLoaded(){for(let g of this.layers)if(g instanceof we){let A=g.params.texture;if(A instanceof Vy&&!A.image.loaded)return!1}return!0}getHash(){let g="{";return g+='"fragment":'+this.fragment.getHash(),g+="}",g}};Object.defineProperties(ka.prototype,{properties:{get:function(){return this.fragment.properties}}});var Aw=class extends T0{constructor(g,A,I){super(g,A,!1),this.uuid=I,this.allowVariableSaves=!0,this.saveVariableLocations(A)}},SX=Fa(Gq()),im=new Map;function fX(g){if(typeof g=="string")return g;let A=im.get(g);return A||(A={url:URL.createObjectURL(new Blob([g]))},im.set(g,A)),A.url}var In=class{constructor({src:A,volume:I,delay:e,loop:i}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let t;typeof A=="string"?t={src:A}:t={src:fX(A),format:"wav"},this.sound=new SX.Howl(t),this.sound.on("end",this.onEnd),this.src=A,I!==void 0&&(this.volume=I),e!==void 0&&(this.delay=e),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(A){this._volume=A,this.sound.volume(A)}get loop(){return this._loop}set loop(A){this._loop=A,this.loopsRemaining=A}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(A,I=1e3){A?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,I),this.clearFade()},A)):this.sound.fade(this._volume,0,I)}on(A,I,e){this.sound.on(A,I,e)}off(A,I,e){this.sound.off(A,I,e)}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(A=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},GX=class{constructor(){this.type="ShapePath",this.color=new Og,this.subPaths=[],this.currentPath=null}moveTo(g,A){return this.currentPath=new pc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(g,A),this}lineTo(g,A){var I;return(I=this.currentPath)==null||I.lineTo(g,A),this}quadraticCurveTo(g,A,I,e){var i;return(i=this.currentPath)==null||i.quadraticCurveTo(g,A,I,e),this}bezierCurveTo(g,A,I,e,i,t){var C;return(C=this.currentPath)==null||C.bezierCurveTo(g,A,I,e,i,t),this}splineThru(g){var A;return(A=this.currentPath)==null||A.splineThru(g),this}toShapes(){let g={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},A={loc:g.ORIGIN,t:0};function I(E,n,h,l){let c=E.x,d=n.x,u=h.x,y=l.x,f=E.y,k=n.y,M=h.y,G=l.y,v=(y-u)*(f-M)-(G-M)*(c-u),N=(d-c)*(f-M)-(k-f)*(c-u),b=(G-M)*(d-c)-(y-u)*(k-f),O=v/b,H=N/b;if(b===0&&v!==0||O<=0||O>=1||H<0||H>1)return null;if(v===0&&b===0){for(let _=0;_<2;_++)if(e(_===0?h:l,E,n),A.loc===g.ORIGIN){let gA=_===0?h:l;return{x:gA.x,y:gA.y,t:A.t}}else if(A.loc===g.BETWEEN){let gA=+(c+A.t*(d-c)).toPrecision(10),CA=+(f+A.t*(k-f)).toPrecision(10);return{x:gA,y:CA,t:A.t}}return null}else{for(let CA=0;CA<2;CA++)if(e(CA===0?h:l,E,n),A.loc===g.ORIGIN){let AA=CA===0?h:l;return{x:AA.x,y:AA.y,t:A.t}}let _=+(c+O*(d-c)).toPrecision(10),gA=+(f+O*(k-f)).toPrecision(10);return{x:_,y:gA,t:O}}}function e(E,n,h){let l=h.x-n.x,c=h.y-n.y,d=E.x-n.x,u=E.y-n.y,y=l*u-d*c;if(E.x===n.x&&E.y===n.y){A.loc=g.ORIGIN,A.t=0;return}if(E.x===h.x&&E.y===h.y){A.loc=g.DESTINATION,A.t=1;return}if(y<-Number.EPSILON){A.loc=g.LEFT;return}if(y>Number.EPSILON){A.loc=g.RIGHT;return}if(l*d<0||c*u<0){A.loc=g.BEHIND;return}if(Math.sqrt(l*l+c*c)G.t<=M.t+Number.EPSILON&&G.t>=M.t-Number.EPSILON)===void 0&&(h.push(M),l.push(new sA(M.x,M.y)))}}return l}function t(E,n,h){let l=new sA;n.getCenter(l);let c=[];return h.forEach(d=>{d.boundingBox.containsPoint(l)&&i(E,d.points).forEach(u=>{c.push({identifier:d.identifier,isCW:d.isCW,point:u})})}),c.sort((d,u)=>d.point.x-u.point.x),c}function C(E,n,h,l,c){(c==null||c==="")&&(c="nonzero");let d=new sA;E.boundingBox.getCenter(d);let u=[new sA(h,d.y),new sA(l,d.y)],y=t(u,E.boundingBox,n);y.sort((N,b)=>N.point.x-b.point.x);let f=[],k=[];y.forEach(N=>{N.identifier===E.identifier?f.push(N):k.push(N)});let M=f[0].point.x,G=[],v=0;for(;v0&&G[G.length-1]===k[v].identifier?G.pop():G.push(k[v].identifier),v++;if(G.push(E.identifier),c==="evenodd"){let N=G.length%2===0,b=G[G.length-2];return{identifier:E.identifier,isHole:N,for:b}}else if(c==="nonzero"){let N=!0,b=null,O=null;for(let H=0;H{let n=E.getPoints(),h=-999999999,l=999999999,c=-999999999,d=999999999;for(let u=0;uh&&(h=y.y),y.yc&&(c=y.x),y.x=d&&(B=d-1),n.length&&s.push({curves:E.curves,points:n,isCW:IF.isClockWise(n),identifier:o++,boundingBox:new QF(new sA(d,l),new sA(c,h))})});let r=s.map(E=>{var n;return C(E,s,B,a,(n=this.userData)==null?void 0:n.style.fillRule)}),Q=[];return s.forEach(E=>{let n=r[E.identifier];if(n&&!n.isHole){let h=new yc;h.curves=E.curves,r.filter(l=>(l==null?void 0:l.isHole)&&l.for===E.identifier).forEach(l=>{if(l){let c=s[l.identifier],d=new pc;d.curves=c.curves,h.holes.push(d)}}),Q.push(h)}}),Q}},ZK,tm=new Promise(g=>{ZK=g}),Cm=!1,kl;function kX(){if(Cm)return;if(kl)return kl;async function g(){let A=await Zn(()=>Promise.resolve().then(()=>SCA),void 0);ZK(A),Cm=!0}return kl=g(),kl}var MX=class{async load(g,A,I=()=>{}){let{load:e}=await tm;e(g,(i,t)=>{i||!t?I(i??"Something went wrong"):A(t)})}async parse(g){let{parse:A,Bidi:I}=await tm;try{let e=A(g),i=new I,t=C=>e.charToGlyphIndex(C.char);return i.registerModifier("glyphIndex",null,t),i.applyFeatures(e,e.defaultRenderOptions.features),{font:e,bidi:i}}catch(e){console.error(e)}}};async function mX(g){return await(await fetch(g)).arrayBuffer()}var UX=new MX;async function om(g){let A,I,e=!1;if(g.url?(A=await mX(g.url),I=g.url,e=g.url.startsWith("/")):g.data&&(A=g.data.buffer.slice(g.data.byteOffset,g.data.byteOffset+g.data.byteLength)),A){let i=await UX.parse(A);if(i)return{font:i.font,url:I,intercepted:e,arr:A,bidi:i.bidi}}}function NX(g,A){return A.state.glyphIndex===g||A.state.fina===g||A.state.medi===g||A.state.init===g}var FX=class{constructor(g){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=g.isUserFont??!1,this._loadingPromise=om(g).then(A=>{A&&(this._arrayBuffer=A.arr,this._url=A.url,this.font=A.font,this._intercepted=A.intercepted,this._isLoaded=!0,this._bidi=A.bidi)})}update(g){this._isLoaded=!1,this._isUserFont=g.isUserFont??!1,this._loadingPromise=om(g).then(A=>{A&&(this._arrayBuffer=A.arr,this._url=A.url,this.font=A.font,this._intercepted=A.intercepted,this._isLoaded=!0,this._bidi=A.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(g,A,I){if(!this._bidi)return[];let e=this._bidi;e.getTextGlyphs(A);let i=e.tokenizer.tokens,t=[],C=0,o=I.length===i.length;for(let B=0;BA.length&&(l=!0);t.push({char:s,index:a,replacements:n,replacementChars:Array.from(Q)}),C++}}return t}generateShapes(g,A){if(!this._isLoaded)return;let I=this.font,e=A.fontSize/this.unitsPerEm,i=A.fontSize*A.lineHeight,t=g.map(c=>this.getTextWidth(c,A)),C=A.width,o=this.getCharWidth(` +`,A),B=A.horizontalAlign===1?o:0,a=this.computeSpaceWidthForLine(g,0,A),s=this.getLineInitialOffsetX(t[0],C,A.horizontalAlign,g[0],o),r=this.getLineInitialOffsetY(i,g.length,A.height,e,A.verticalAlign),Q=[],E=g.map(c=>[]),n=g.map(c=>[]),h;for(let c=0;c(I.glyphs.get(AA).advanceWidth??0)*e),_=H.reduce((AA,BA)=>AA+=BA,0),gA=H.map(AA=>AA/_),CA=s;for(let AA=0;AA=0&&(g-=i),I===3?A*.5-g*.5:I===2?A-g:0}getLineInitialOffsetY(g,A,I,e,i){let t=A*g,C=Math.abs(this.ascender-this.descender)*e,o=g-C,B=-this.ascender*e-o/2;return i===3?-(I-t-B):i===2?-(I*.5-t*.5-B):B}createPath(g,A,I,e,i){var B;let t=g.getPath(I,-e,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!t){console.error('THREE.Font: character "'+g+'" does not exists in font family '+this.familyName+".");return}let C=new GX,o=(g.advanceWidth??1)*A;if(g)for(let a of t.commands){let s=(B=C.currentPath)==null?void 0:B.currentPoint;if(!(s&&a.type!=="Z"&&s.x===a.x&&-s.y===a.y))switch(a.type){case"M":C.moveTo(a.x,-a.y);break;case"L":C.lineTo(a.x,-a.y);break;case"Q":C.quadraticCurveTo(a.x1,-a.y1,a.x,-a.y);break;case"C":C.bezierCurveTo(a.x1,-a.y1,a.x2,-a.y2,a.x,-a.y);break}}return C.subPaths.forEach(a=>{let s=RX(a.curves);s!==void 0&&a.currentPoint.distanceTo(s)>0&&a.lineTo(s.x,s.y)}),{offsetX:o+i.fontSize*i.letterSpacing,path:C}}getCharWidth(g,A){var I;return((I=this.font)==null?void 0:I.getAdvanceWidth(g,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing}))??0}getTextWidth(g,A){var I;return((I=this.font)==null?void 0:I.getAdvanceWidth(g,A.fontSize,{kerning:!0,letterSpacing:A.letterSpacing}))??0}computeSpaceWidthForLine(g,A,I){let e=this.getCharWidth(" ",I),i=g[A];if(i){let t=this.countSpaces(i.trimEnd());if(I.horizontalAlign===4&&A{this.disposeObject(this.objects.get(g)),this.objects.delete(g)}),this.unreachable.clear()}dispose(){this.objects.forEach(g=>{this.disposeObject(g)}),this.objects.clear()}},Bm=class extends KX{constructor(g){super(),this.flatShading=g}disposeObject(g){g.dispose()}createObject(g,A,I){let e=AD(g,A,this.flatShading,I);return e.computeBoundingSphere(),e}},JX={markNeedsUpdateRendererDirty:()=>{}},vX=class extends vz{constructor(g){super(),this.shared=g}create(g){return new YK(g,this.shared)}},O0=class{constructor(g,A={}){if(this.data=g,this.geometryCache=new Bm(!0),this.geometryCache2=new Bm(!1),this.imageHolderCache=new vX(this),this.thisContext={scene:JX,shared:this},this.deletedMaterial=new Aw(Ki.defaultTwoLayerData("phong"),this.thisContext,""),this.deletedImage=new dr(jc.emptyImage,this),this.deletedVideo=new dr(Yc.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()},A.images)for(let[I,e]of Object.entries(A.images))this.addImage(I,e);if(A.videos)for(let[I,e]of Object.entries(A.videos))this.addVideo(I,e);if(A.audios)for(let[I,e]of Object.entries(A.audios))this.addAudio(I,e);this.reset(g)}setRequestRender(g){this._requestRender=g}setEntityOpContext(g){this.entityOpContext=g}reset(g,A=!1){this.resetLib(g.lib);for(let{id:I,data:e}of g.variables)this.addVariableHolder(I,e),A&&this.updateVariableHolder(I,e);for(let[I,e]of Object.entries(g.images))this.addImage(I,e);for(let[I,e]of Object.entries(g.videos))this.addVideo(I,e);for(let[I,e]of Object.entries(g.colors))this.addColor(I,e);for(let[I,e]of Object.entries(g.materials))this.addMaterial(I,e);for(let[I,e]of Object.entries(g.audios))this.addAudio(I,e);for(let[I,e]of Object.entries(g.fonts))this.addFont(I,e)}addMaterial(g,A){if(this.materials[g]){let I=this.materials[g];I.reset(A,this.thisContext),I.dispose()}else{let I=new Aw(A,this.thisContext,g);this.materials[g]=I}}deleteMaterial(g){this.materials[g]&&(this.materials[g].nodeMaterialDispose(),delete this.materials[g])}getMaterial(g){return this.materials[g]}getMaterialOrDeletedPlaceholder(g){return this.materials[g]??this.deletedMaterial}material(g){return typeof g=="string"?this.getMaterialOrDeletedPlaceholder(g):g==null?(console.error("material is undefined or null"),this.deletedMaterial):new T0(g,this.thisContext)}getMaterials(){return this.materials}addImage(g,A){return this.images[g]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[g].updateSrc(A.data),!0):(this.images[g]=new dr(A,this),!1)}deleteImage(g){let A=this.images[g];A&&(A.dispose(),delete this.images[g])}getDefaultImage(){return this.images.image_0}getImage(g){return this.images[g]??this.deletedImage}image(g){return typeof g=="string"?this.getImage(g):this.imageHolderCache.load(g)}addVideo(g,A){return this.videos[g]?(this.videos[g].updateSrc(A.data),!0):(this.videos[g]=new dr(A,this),!1)}deleteVideo(g){let A=this.videos[g];A&&(A.dispose(),delete this.videos[g])}getVideo(g){return this.videos[g]??this.deletedVideo}video(g){return typeof g=="string"?this.getVideo(g):this.imageHolderCache.load(g)}addColor(g,A){return this.colors[g]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in A?this.colors[g].setRGBA(A.r,A.g,A.b,A.a):this.colors[g].setRGBA(A.r,A.g,A.b,1),!0):("a"in A?this.colors[g]=new gD(A.r,A.g,A.b,A.a):this.colors[g]=new gD(A.r,A.g,A.b,1),!1)}updateColor(g,A){if(this.colors[g]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let I=this.colors[g];return this.colors[g].r=A.r??I.r,this.colors[g].g=A.g??I.g,this.colors[g].b=A.b??I.b,this.colors[g].a=A.a??I.a,!0}return!1}deleteColor(g){this.colors[g]&&delete this.colors[g]}getColor(g){return this.colors[g]}color(g){let A;if(typeof g=="string"){let I=this.getColor(g);I?A=I:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),A=new lt(0,0,0,0))}else return"a"in g?new lt(g.r,g.g,g.b,g.a):new lt(g.r,g.g,g.b,1);return A}addAudio(g,A){this.audios[g]=A}getAudio(g){let A=this.audios[g];if(A instanceof In)return A;{let I=new In({src:A.data});return this.audios[g]=I,I}}deleteAudio(g){let A=this.audios[g];A&&(A instanceof In&&A.dispose(),delete this.audios[g])}addFont(g,A){this.fonts[g]=new FX(A),this.fonts[g].loadingPromise.then(()=>this.requestRender())}getFont(g){return this.fonts[g]}deleteFont(g){this.fonts[g]&&delete this.fonts[g]}dispose(){Object.keys(this.materials).forEach(g=>this.deleteMaterial(g)),this._requestRender=void 0,Object.values(this.audios).forEach(g=>{g instanceof In&&g.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(g,A){return this.variables[g]===void 0?(this.variables[g]={value:A.value,locations:[]},"dynamicVariableType"in A&&(this.variables[g].dynamicVariablePlayState="Playing",this.variables[g].dynamicVariableToggleIsForward=void 0),!0):(this.variables[g].value=A.value,!1)}resetDynamicVariablePlayState(){for(let g in this.variables)this.variables[g].dynamicVariablePlayState!==void 0&&(this.variables[g].dynamicVariablePlayState="Playing",this.variables[g].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(g,A){this.updateVariable(g,A.value)}updateVariable(g,A){if(this.variables[g]===void 0)return!1;this.variables[g].value=A;let I=A;for(;typeof I=="string";)I=this.variables[I].value;let e=this.entityOpContext.scene;for(let i=this.variables[g].locations.length-1;i>=0;i--){let t=this.variables[g].locations[i];if(t[0]==="material"){let C=t[1],o=I,B={scene:e,shared:this},a=t.slice(2);e.traverseMaterial(r=>{let Q=r.root??r;Q.uuid===C&&Q.onVariableUpdate(a,o,B)});let s=this.materials[C];s&&s.onVariableUpdate(a,o,B)}else{let C=e.find(t[0]);if(C===void 0){this.variables[g].locations.splice(i,1);continue}if(t[1]!=="geometry"){for(let o=1;o{let s=a.dataPatched;a.chooseGeoemtryCache(this).forceDelete(s.geometry),a.createGeometryDelayed(this.entityOpContext),a.onVariableUpdate(!0)})}}}}return!0}deleteVariable(g){this.variables[g]&&delete this.variables[g]}getVariable(g,A){var I,e,i;if(Array.isArray(g)){if(g[0]==="mouse")return((I=this.mouseProperty)==null?void 0:I[g[1]])??0;if(g[0]==="raycast")return((e=this.raycastProperty)==null?void 0:e[g[1]])??0;let t=this.entityOpContext.scene.find(g[0]);if(g[1]==="width"||g[1]==="height"||g[1]==="depth")return t.geometry.userData.parameters[g[1]];for(let C=1;Cji.equal(B,A));o!==void 0&&o!==-1&&C.locations.splice(o,1)}if(typeof g=="string"){let t=g,C=g;do{if(C=t,this.variables[t]===void 0)break;t=this.variables[t].value}while(typeof t=="string");return A&&this.variables[C]!==void 0&&this.variables[C].locations.push(A),t}else return g}getVariables(){return this.variables}getDynamicVariablePlayState(g){var A;return(A=this.variables[g])==null?void 0:A.dynamicVariablePlayState}setDynamicVariablePlayState(g,A){this.variables[g]!==void 0&&(this.variables[g].dynamicVariablePlayState=A)}getDynamicVariableToggleIsForward(g){var A;return(A=this.variables[g])==null?void 0:A.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(g,A){this.variables[g]!==void 0&&(this.variables[g].dynamicVariableToggleIsForward=A)}resetLib(g){for(let[A,I]of Object.entries(g.images))this.addImage(A,I.asset);for(let[A,I]of Object.entries(g.audios))this.addAudio(A,I.asset);for(let[A,I]of Object.entries(g.colors))this.addColor(A,I.asset);for(let[A,I]of Object.entries(g.fonts))this.addFont(A,I.asset);for(let[A,I]of Object.entries(g.materials))this.addMaterial(A,I.asset);for(let[A,I]of Object.entries(g.videos))this.addVideo(A,I.asset);for(let[A,I]of Object.entries(g.variables))this.addVariableHolder(A,I.asset)}updateLibByOp(g,A){g.path[0]==="images"?g.path.length===1&&g.type===1?this.addImage(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteImage(g.id):g.path[0]==="videos"?g.path.length===1&&g.type===1?this.addVideo(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteVideo(g.id):g.path[0]==="audios"?g.path.length===1&&g.type===1?this.addAudio(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteAudio(g.id):g.path[0]==="colors"?g.path.length===1&&g.type===1?this.addColor(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteColor(g.id):g.path[0]==="materials"?g.path.length===1&&g.type===1?this.addMaterial(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteMaterial(g.id):g.path[0]==="fonts"?g.path.length===1&&g.type===1?this.addFont(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteFont(g.id):g.path[0]==="variables"?g.path.length===1&&g.type===1?this.addVariableHolder(g.id,g.data.asset):g.path.length===1&&g.type===2&&this.deleteVariable(g.id):g.path[0]==="components"&&A.updateByLibOp(g,this)}updateByOp(g,A,I){this.data=A,g.path[0]==="images"?g.path.length===2&&g.type===0?g.props.data&&this.getImage(g.path[1]).updateSrc(g.props.data):g.path.length===1&&g.type===1?this.addImage(g.id,g.data):g.path.length===1&&g.type===2&&this.deleteImage(g.id):g.path[0]==="videos"?g.path.length===2&&g.type===0?g.props.data&&this.getVideo(g.path[1]).updateSrc(g.props.data):g.path.length===1&&g.type===1?this.addVideo(g.id,g.data):g.path.length===1&&g.type===2&&this.deleteVideo(g.id):g.path[0]==="audios"?g.path.length===2&&g.type===0?g.props.data&&this.addAudio(g.path[1],A.audios[g.path[1]]):g.path.length===1&&g.type===1?this.addAudio(g.id,g.data):g.path.length===1&&g.type===2&&this.deleteAudio(g.id):g.path[0]==="colors"?g.path.length===2&&g.type===0?this.updateColor(g.path[1],g.props):g.path.length===1&&g.type===1?this.addColor(g.id,g.data):g.path.length===1&&g.type===2&&this.deleteColor(g.id):g.path[0]==="materials"?g.path.length===1&&g.type===1?this.addMaterial(g.id,g.data):g.path.length===1&&g.type===2?this.deleteMaterial(g.id):g.path.length>1&&this.getMaterial(g.path[1]).updateByOp(Fi.drop(g,2),A.materials[g.path[1]],{shared:this,scene:I}):g.path[0]==="fonts"?g.path.length===2&&g.type===0?this.updateFont(g.path[1],g,I):g.path.length===1&&g.type===1?this.addFont(g.id,g.data):g.path.length===1&&g.type===2&&this.deleteFont(g.id):g.path[0]==="variables"?g.path.length===2&&g.type===0&&"value"in g.props?this.updateVariable(g.path[1],g.props.value):g.path.length===1&&g.type===4?this.addVariableHolder(g.id,g.data):g.path.length===1&&g.type===5&&this.deleteVariable(g.id):g.path[0]==="lib"&&this.updateLibByOp(Fi.drop(g,1),I)}updateFont(g,A,I){if(A.props.url){let e=this.getFont(g),i={...this.data.fonts[g],url:A.props.url};e.update(i),e.loadingPromise.then(()=>this.requestRender()),I.updateFont(g,this)}}};new O0(fC.emptyData());var BE=class extends Dt{updateByPatchedOp(A,I,e){if(super.updateByPatchedOp(A,I,e),KW(A.path,["materials"])!==null&&A.type===0&&Array.isArray(this.material))for(let[i,t]of Object.entries(A.props)){let C=e.shared.material(t);this.material[Number(i)]=C}else if(AC(A.path,["material"])&&this.material instanceof ka)"material"in I&&typeof I.material!="string"&&this.material.updateByOp(Fi.drop(A,1),I.material,e);else if(AC(A.path,["materials","*"])&&Array.isArray(this.material)){let i=A.path[1];if("materials"in I&&iI.shared.material(C).getFlavor(e.flatShading,e.side,e.wireframe)),I.scene.markNeedsUpdateRendererDirty()):"material"in A&&A.material!==void 0&&(this.disposeMaterial(),this.material=[I.shared.material(A.material).getFlavor(e.flatShading,e.side,e.wireframe)],I.scene.markNeedsUpdateRendererDirty())),A.flatShading!==void 0||A.wireframe!==void 0||A.side!==void 0)if(Array.isArray(this.material))for(let C=0;C{A instanceof ka&&(A instanceof Aw||A.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}},am=new J,rm=new EI,sm=new EI,qX=new J,Qm=new zA,zi=class extends BE{constructor(A,I,e){super(A,I),this.data=I,this.localGeometry=void 0,I.bindMode&&I.bindMatrix&&(this.isSkinnedMesh=!0,this.bindMode=I.bindMode,this.bindMatrix=new zA().fromArray(I.bindMatrix),this.bindMatrixInverse=new zA)}chooseGeoemtryCache(A){return A.geometryCache}markGeometryAsReachable(A){this.geometryCreateDeleyed instanceof bg&&this.chooseGeoemtryCache(A).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof O0){let A=this.geometryCreateDeleyed,I=this.chooseGeoemtryCache(A);this.geometryCreateDeleyed=I.get(this.dataPatched.geometry,A,this)}return this.geometryCreateDeleyed}set geometry(A){this.localGeometry=A}get is2DAndNoDepth(){let A=this.dataPatched.geometry;return Tc.is2DParametricMesh(A.type)&&A.depth===0}get is2DType(){return Tc.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(A,I,e){super.updateByPatchedOp(A,I,e),AC(A.path,["geometry"])&&this.updateByPatchedOpGeometry(Fi.drop(A,1),I.geometry,e)}removeInteractionGeometry(){var A;(A=this.localGeometry)==null||A.dispose(),this.localGeometry=void 0}updateGeometryInteractions(A,I){var i;this.invalidateDownstreamBooleanData();let e=this.data.geometry.type;if(e==="NonParametricGeometry"||e==="SubdivGeometry"){let t=A;if(this.localGeometry===void 0){let s={...this.data.geometry,...t};this.localGeometry=AD(s,I,this.data.flatShading,this)}let C,o,B;t.scaleBaked?[C,o,B]=t.scaleBaked:{width:C,height:o,depth:B}=t;let a=this.localGeometry.userData;a.sxPrev!==void 0&&Wy(this.localGeometry.attributes,C/a.sxPrev,o/a.syPrev,B/a.szPrev),a.sxPrev=C,a.syPrev=o,a.szPrev=B}else{let t={...this.data.geometry,...A};(i=this.localGeometry)==null||i.dispose(),this.localGeometry=AD(t,I,this.data.flatShading,this)}}refreshAttachedCloners(A){for(let I of this.attachedSurfaceCloners)A.scene.addPendingUpdateCloner(I.object)}refreshAttachedPaths(A){for(let I of this.attachedPaths)A.scene.addPendingCommand(()=>I.updateShape())}createGeometryDelayed(A){this.geometryCreateDeleyed=A.shared,this.refreshAttachedCloners(A),this.refreshAttachedPaths(A)}updateByPatchedOpGeometry(A,I,e){var t;let i=!1;A.type===0&&A.path.length===0&&Object.keys(A.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Pi&&this.chooseGeoemtryCache(e.shared).mutateIfUnique(this.geometryCreateDeleyed.data,I)===this.geometryCreateDeleyed&&(i=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(I,A.props.scaleBaked),this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)),i||((t=e.scene)==null||t.markGeometryCacheDirty(),this.createGeometryDelayed(e)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(A,I){this.createGeometryDelayed(I)}updateState(A,I){A.geometry!==void 0&&this.updateGeometryOnStateUpdate(A.geometry,I),super.updateState(A,I)}updateGeometryGroupsIfNeeded(){var A;Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(((A=this.geometry.getIndex())==null?void 0:A.count)??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(A,I){let e=this.geometry.userData.parameters;this.is2DType?A.set(0,0,e.depth*.5):this.isNonParametric?(A.setScalar(0),this.geometry.boundingSphere&&A.copy(this.geometry.boundingSphere.center),I.set(e.width,e.height,e.depth??0).multiplyScalar(.5)):A.setScalar(0),I.set(e.width,e.height,e.depth??0).multiplyScalar(.5)}updateMatrixWorld(A){super.updateMatrixWorld(A),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(A,I){this.skeleton=A,I===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),I=this.matrixWorld),this.bindMatrix.copy(I),this.bindMatrixInverse.copy(I).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(A){let I=new EI,e=this.geometry.attributes.skinWeight;for(let i=0,t=e.count;i{for(let s of B.normals)B.result.add(s);B.result.divideScalar(B.normals.length)});for(let B=0;B{});var go=new ve,qE=new J;function YX(g){let A=!1;return g.scene.objects.traverse((I,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(A=!0)}),A}var Jn=class extends zi{constructor(A,I,e){super(A,I,e),this.data=I,this.hiddenMatrixOld=new zA,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(A){return this.dataPatched.flatShading?A.geometryCache:A.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(A,I){let e=this.geometry.userData.parameters;A.copy(this.originalGeometryNew.boundingSphere.center),I.set(e.width,e.height,e.depth??0).multiplyScalar(.5)}createGeometryByControls(A){var C,o,B;if(this.skipReactionUpdate===!0)return;let I=(C=this.localGeometry)==null?void 0:C.uuid,{originalGeometry:e,subdividedGeometry:i,subdivPointer:t}=Pi.build(A,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=t,e!==void 0&&((o=this.originalGeometry)==null||o.dispose(),this.originalGeometry=e),i!==void 0&&((B=this.subdividedGeometry)==null||B.dispose(),this.subdividedGeometry=i??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,_0(this),P0(this),this.calcBoundingBox(),I&&(this.localGeometry.uuid=I)}updateState(A,I){if(super.updateState(A,I),A.flatShading!==void 0){let e=this.material;this.material=e.getFlavor(!1,e.side,e.wireframe),this.smoothShading=!A.flatShading,this.createGeometryDelayed(I)}}updateMesh(A=!1){Pi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Pi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,A&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Pi.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Pi.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(A,I){let e=this.localGeometry;this.localGeometry=this.originalGeometryNew,Dt.prototype.raycast.call(this,A,I),this.localGeometry=e}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 A=this.originalGeometry;A.boundingSphere===null&&(A.boundingSphere=new ct,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=A.boundingSphere));let I=A.attributes.position,e=A.boundingSphere.center;go.setFromBufferAttribute(I),go.getCenter(e),A.boundingSphere.radius=e.distanceTo(go.max),isNaN(A.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),go.getSize(qE),this.hasNonUniformScale&&qE.divide(this.scale);let i={width:qE.x,height:qE.y,depth:qE.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(A){let I=this.originalGeometry;go.min.set(A[0],A[2],A[4]),go.max.set(A[1],A[3],A[5]),this.hasNonUniformScale&&(go.min.applyMatrix4(this.shearScaleInv),go.max.applyMatrix4(this.shearScaleInv)),I.boundingSphere===null&&(I.boundingSphere=new ct);let e=I.boundingSphere.center;go.getCenter(e),I.boundingSphere.radius=e.distanceTo(go.max)}freeSubdivPointer(){var A,I;this.subdivPointer&&(Pi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,(A=this.originalGeometry)==null||A.dispose(),(I=this.subdividedGeometry)==null||I.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(A,I,e){super.updateByPatchedOpGeometry(A,I,e),this.localGeometry&&this.createGeometryByControls(I)}},Em=-1,xX=1,HX={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},TX={polygon_center:0,edge:1,vertex:2},Ml=(g,A)=>(I,e)=>!A||I===0||g===0?0:g*e/100,rI=(g,A)=>{let I=Math.abs(A),e=I*-1;return(g-Em)*(I-e)/(xX-Em)+e};function OX(g){let A=[],I={};for(var e=0,i=g.length;eMath.round(C*1e4)/1e4));I[t]||(A.push(g[e]),I[t]=!0)}return A}var _X=new J,ml=new J,PX=new J,jX=new J;function uQ(g,A){let I=PX.fromArray(g),e=jX.fromArray(A);ml.copy(e).sub(I);let i=ml.length();return ml.normalize().multiplyScalar(i*.5),_X.copy(I).add(ml).toArray()}var Xt=new Ni,Ul=new J,ID=new J,Er=new J;function WX(g){let A=[];for(let I=0;I<=g.index.count;I++)if(Ul.fromArray(g.index.array,I*3),Xt.setFromAttributeAndIndices(g.attributes.position,Ul.x,Ul.y,Ul.z),Xt.getNormal(ID),Xt.getMidpoint(Er),!(isNaN(Er.x)||isNaN(Er.y)||isNaN(Er.z))){let{a:e,b:i,c:t}=Xt,C=e.toArray(),o=i.toArray(),B=t.toArray(),a=e.distanceTo(i),s=i.distanceTo(t),r=t.distanceTo(e),Q=uQ(C,o),E=uQ(o,B),n=uQ(B,C),h=[a,s,r],l=Math.max(...h),c=h.filter(y=>Math.round(y)===Math.round(l)).length>1,d=[],u=Xt.getMidpoint(Er).toArray();l===a&&!c&&(d=[E,n,n],u=Q),l===s&&!c&&(d=[Q,n,n],u=E),l===r&&!c&&(d=[Q,E,E],u=n),c&&(d=[Q,E,n]),A.push({vertices:[C,o,B],faceCenters:d,midpoint:u,norm:Xt.getNormal(ID).toArray()})}return A}function ZX(g){let A=[],{position:I}=g.attributes;for(let e=0;e.5*(1-Math.cos(g*Math.PI)),XX=class{constructor(){this.perlin=new Array(4095+1)}noise(g,A=0,I=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let l=0;l<4095+1;l++)this.perlin[l]=Math.random()}g<0&&(g=-g),A<0&&(A=-A),I<0&&(I=-I);let e=Math.floor(g),i=Math.floor(A),t=Math.floor(I),C=g-e,o=A-i,B=I-t,a,s,r=0,Q=.5,E,n,h;for(let l=0;l=1&&(e++,C--),o>=1&&(i++,o--),B>=1&&(t++,B--)}return r}noiseSeed(g){let A=(()=>{let I,e;return{setSeed(i){e=I=(i??Math.random()*4294967296)>>>0},getSeed(){return I},rand(){return e=(1664525*e+1013904223)%4294967296,e/4294967296}}})();A.setSeed(g),this.perlin=new Array(4095+1);for(let I=0;I<4095+1;I++)this.perlin[I]=A.rand()}},$X=XX,nm=new J,hm=new zA,lm=new jQ;function cm(g){let A=!1;return g.scene.objects.traverse((I,e)=>{e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(A=!0)}),A}var VK=class extends zi{constructor(g,A,I){super(g,A,I),this.data=A}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(){var A;let g=this.dataPatched;return((A=this.font)==null?void 0:A.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,g.geometry.height,this.fontScale,g.geometry.verticalAlign))??0}get fontScale(){let g=this.dataPatched;return this.font?g.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){var g;return(((g=this.font)==null?void 0:g.ascender)??1)*this.fontScale}get descender(){var g;return(((g=this.font)==null?void 0:g.descender)??1)*this.fontScale}get lineHeight(){let g=this.dataPatched;return g.geometry.fontSize*g.geometry.lineHeight}raycast(g,A){let{matrixWorld:I}=this;if(!(isNaN(g.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(hm.copy(I).invert(),lm.copy(g.ray).applyMatrix4(hm),lm.intersectBox(this.singleBBox,nm))){let e=nm.applyMatrix4(I),i=g.ray.origin.distanceTo(e);A.push({distance:i,point:e.clone(),object:this})}}},Hi=1e-4,Io,zK,XK,$K,Dm=new J,dm=new J;q0.then(g=>{Io=g,zK=[Io.get_face_center,Io.get_edge_midpoint,Io.get_vertex_position],XK=[Io.get_face_normal,Io.get_edge_normal,Io.get_vertex_normal],$K=[Io.face_count,Io.edge_count,Io.vertex_count]});var A9=new zA,g9=new zA,PB=new J,gr=new J,LE=new J,Vu=new J,I9=new J,e9=new J,gB=new $X,UC=class extends m0(ZI){constructor(A,I){super(),this.parameters=I,this.objectForSample=void 0,this._pendingMediaLoad=!1,this.object=A}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(A){if(this.parent===null)this.updateState(this.parameters,A);else for(let I of this.children)I instanceof Ri&&I.expand()}invalidateTransform(A){this.matrixWorldNeedsUpdate=!0,this.traverse(I=>{I instanceof Ri&&I.object===A&&(I.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 A of this.children)A.updateMatrix(),A.hasNonUniformScale&&(A.updateMatrixWorld(),A.updateMatrixWorldSVD())}_updateCount(A){let I;if(A!==void 0?I=A:I=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&&(I=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,t=this.children.length;i{let d=c.length,u=c.map(k=>k[0]).reduce((k,M)=>k+M,0),y=c.map(k=>k[1]).reduce((k,M)=>k+M,0),f=c.map(k=>k[2]).reduce((k,M)=>k+M,0);return[u/d,y/d,f/d]},r=c=>Math.round(c*1e6)/1e6;B.forEach(c=>{let d=B.filter(u=>r(c.pos[0])===r(u.pos[0])&&r(c.pos[1])===r(u.pos[1])&&r(c.pos[2])===r(u.pos[2]));d.length>1?a.push({pos:c.pos,norm:s(d.map(u=>u.norm))}):a.push(c)});let Q=OX(a);if(Q.length>0){let c=Math.round(Q.length*I.count/100);this._updateCount(c)}else{let c=this.objectForSample.geometry.getAttribute("position");if(!c||isNaN(c.count)||c.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 E=new QZ(this.objectForSample).build(),n=HX[I.axis],h=this.children;E.setRandomGenerator((0,FE.default)(this.object.uuid+I.seed));for(let[c,d]of h.entries()){let u=c*(i.freqScale/10)+i.movement,y=t?gB.noise(u):C(u,u),f=c+1,k=o(f,rI(y,i.rotation[0])),M=o(f,rI(y,i.rotation[1])),G=o(f,rI(y,i.rotation[2]));I.spreadType==="random"?E.sample(LE,Vu):(Q.length&&(LE.fromArray(Q[c].pos),Vu.fromArray(Q[c].norm)),this.objectForSample instanceof Jn&&LE.applyMatrix4(A9.copy(this.objectForSample.matrixWorld).invert())),LE.applyMatrix4(this.object.hiddenMatrix.clone().invert()),d.position.copy(LE),PB.fromArray(n);let v=I.align==="normal"?Vu:this.object.getWorldDirection(e9),N=gr.fromArray(I.position);gr.x+=gr.x+o(f,rI(y,i.position[0])),gr.y+=gr.y+o(f,rI(y,i.position[1])),gr.z+=gr.z+o(f,rI(y,i.position[2]));let b=Math.acos(v.dot(PB)),O=I9.crossVectors(PB,v).normalize(),H=g9.makeRotationAxis(O,b),_=v.clone().cross(this.object.up).normalize(),gA=_.clone().cross(v).normalize(),CA=new zA().makeBasis(_,v,gA),AA=new J(PB.y,PB.z,PB.x).normalize(),BA=AA.clone().cross(PB).normalize(),iA=new zA().makeBasis(AA,PB,BA).invert(),rA=new zA().multiplyMatrices(CA,iA);d.rotation.setFromRotationMatrix(rA),N.applyMatrix4(H),d.position.add(N),d.rotation.x=d.rotation.x+e.x+k,d.rotation.y=d.rotation.y+e.y+M,d.rotation.z=d.rotation.z+e.z+G,d.scale.setScalar(1),d.scale.x=d.scale.x+I.scale[0]+o(f,rI(y,i.scale[0]))||Hi,d.scale.y=d.scale.y+I.scale[1]+o(f,rI(y,i.scale[1]))||Hi,d.scale.z=d.scale.z+I.scale[2]+o(f,rI(y,i.scale[2]))||Hi,d.scale.multiply(this.object.scale),d.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let A=this.parameters.toObject.spreadType;if(A==="random")return[];if(this.objectForSample instanceof Jn){let I=this.objectForSample,e=TX[A],i=$K[e],t=zK[e],C=XK[e],o=[],B=i(I.subdivPointerNew);for(let a=0;a<=B-1;a++){let s=t(I.subdivPointerNew,a),r=C(I.subdivPointerNew,a);Dm.fromArray(s).applyMatrix4(I.matrixWorld),dm.fromArray(r),o.push({pos:Dm.toArray(),norm:dm.toArray()})}return o}else return(this.objectForSample.geometry.index?WX(this.objectForSample.geometry):ZX(this.objectForSample.geometry)).map((I,e)=>A==="polygon_center"?{pos:I.midpoint,norm:I.norm}:A==="vertex"?[{pos:I.vertices[0],norm:I.norm},{pos:I.vertices[1],norm:I.norm},{pos:I.vertices[2],norm:I.norm}]:A==="edge"?[{pos:I.faceCenters[0],norm:I.norm},{pos:I.faceCenters[1],norm:I.norm},{pos:I.faceCenters[2],norm:I.norm}]:[]).flat()}updateState(A,I){var e;if(this.parameters=TD(A),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),(e=this.object.parent)==null||e.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let i=I.find(this.parameters.toObject.object);i instanceof Dt?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new zA,this.hiddenMatrix=new zA,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}},ih=g=>{var A;return A=class extends g{},A.geometryHelper=new Go(30,30,30),A},Nl=new jQ,zu=new ct,um=new zA,th=(g,A,I,e,i=!1)=>{let t=A,C=g.matrixWorld;if(t.boundingSphere===null&&t.computeBoundingSphere(),zu.copy(t.boundingSphere),zu.applyMatrix4(C),I.ray.intersectsSphere(zu)===!1||(um.copy(C).invert(),Nl.copy(I.ray).applyMatrix4(um),t.boundingBox!==null&&Nl.intersectsBox(t.boundingBox)===!1))return;let o,B,a,s,r=t.index,Q=t.attributes.position,E=t.drawRange,n,h;if(i===!1){let c=Math.max(0,E.start),d=Math.min(r.count,E.start+E.count);for(n=c,h=d;nG)continue;f.applyMatrix4(g.matrixWorld);let H=I.ray.origin.distanceTo(f);HI.far||e.push({distance:H,point:y.clone().applyMatrix4(g.matrixWorld),object:g})}}function l(c,d,u,y,f,k,M){let G=new J,v=new J,N=new J,b=new J,O=new J;if(G.fromBufferAttribute(y,f),v.fromBufferAttribute(y,k),N.fromBufferAttribute(y,M),u.intersectTriangle(G,v,N,!1,b)===null)return null;O.copy(b),O.applyMatrix4(c.matrixWorld);let H=d.ray.origin.distanceTo(O);return Hd.far?null:{faceIndex:1,distance:H,point:O.clone(),object:c}}},Fl=new J,Ot=new ZQ,i9=class extends $n{constructor(g){let A=new bg,I=new Ra({color:16777215,vertexColors:!0,toneMapped:!1}),e=[],i=[],t={},C=new Og(15711266),o=new Og(15711266),B=new Og(2857471);a("n1","n2",C),a("n2","n4",C),a("n4","n3",C),a("n3","n1",C),a("f1","f2",C),a("f2","f4",C),a("f4","f3",C),a("f3","f1",C),a("n1","f1",C),a("n2","f2",C),a("n3","f3",C),a("n4","f4",C),a("p","n1",o),a("p","n2",o),a("p","n3",o),a("p","n4",o),a("u1","u2",B),a("u2","u3",B),a("u3","u1",B);function a(r,Q,E){s(r,E),s(Q,E)}function s(r,Q){e.push(0,0,0),i.push(Q.r,Q.g,Q.b),t[r]===void 0&&(t[r]=[]),t[r].push(e.length/3-1)}A.setAttribute("position",new pg(e,3)),A.setAttribute("color",new pg(i,3)),super(A,I),this.type="CameraHelper",this.camera=g,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=g.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=t,this.update()}update(){let g=this.geometry,A=this.pointMap;Ot.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let I=1,e=1,i=.8;DC("n1",A,g,Ot,-I,-e,i),DC("n2",A,g,Ot,I,-e,i),DC("n3",A,g,Ot,-I,e,i),DC("n4",A,g,Ot,I,e,i);let t=i;DC("f1",A,g,Ot,-I,-e,t),DC("f2",A,g,Ot,I,-e,t),DC("f3",A,g,Ot,-I,e,t),DC("f4",A,g,Ot,I,e,t);let C=t,o=.5;DC("u1",A,g,Ot,I*.7*o,e*1.1,C),DC("u2",A,g,Ot,-I*.7*o,e*1.1,C),DC("u3",A,g,Ot,0,e*(1.1+.9*o),C),g.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function DC(g,A,I,e,i,t,C){Fl.set(i,t,C).unproject(e);let o=A[g];if(o!==void 0){let B=I.getAttribute("position");for(let a=0,s=o.length;ag.is=A=>"objectHelper"in A)(gw||(gw={}));var Ch=(g,A)=>class extends U0(g){constructor(){super(...arguments),this.objectHelper=new A(this),this.gizmos={}}get geometryHelper(){return A.geometryHelper}raycast(I,e){this.objectHelper.raycast(I,e)}showGizmos(){for(let I in this.gizmos){let e=this.gizmos[I];e instanceof Gc&&(e.visible=!0)}}updateEntityBoxSize(I,e){this.objectHelper.visible&&this.geometryHelper instanceof Go?(I.setScalar(0),e.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(I,e)}hideGizmos(){for(let I in this.gizmos){let e=this.gizmos[I];e instanceof Gc&&(e.visible=!1)}}},Rl=790,Js=new J,Xu=new J,$u=new QI,Ap=new J,bE=new J,gp=new J,Ji=class extends Ch(ZQ,t9){constructor(A="",I={...mn.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=FQ.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this.super_Entity(A,I),this.previousProjectionMatrix=new zA,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let e=this.width,i=this.height;this.orthoCamera=new Hw(e*-.5,e*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new Ui(45,e/i,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(A){this.perspCamera.fov=A}get fov(){return this.perspCamera.fov}setNear(A,I){A==="PerspectiveCamera"?this.perspCamera.near=I:this.orthoCamera.near=I}setZoom(A,I){I>=0&&(A==="PerspectiveCamera"?this.perspCamera.zoom=I:this.orthoCamera.zoom=I)}set cameraType(A){A==="PerspectiveCamera"?this.toPerspective():A==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(A){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=A:this.orthoCamera.near=A}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(A){A>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=A:this.orthoCamera.zoom=A)}lookAt(A,I,e){typeof A=="number"&&(A=new J(A,I,e)),super.lookAt(A),this.getWorldPosition(Js),this.targetOffset=Js.distanceTo(A)}getTarget(A=new J){return this.getWorldDirection(Xu),this.getWorldPosition(Js),Xu.multiplyScalar(this.targetOffset),A.copy(Js).add(Xu),A}getDistanceToTarget(){let A=this.getTarget();return this.getWorldPosition(Js),Js.distanceTo(A)}updateUp(){this.getWorldQuaternion($u),Ap.set(0,0,1).applyQuaternion($u),bE.copy(ZI.DEFAULT_UP),this.isUpVectorFlipped&&bE.negate(),bE.applyQuaternion($u),gp.copy(ZI.DEFAULT_UP).projectOnPlane(Ap),this.angleOffsetFromUp=gp.angleTo(bE),this.angleOffsetFromUp*=gp.cross(bE).dot(Ap)>=0?1:-1}updateTransformState(A,I){let e=super.updateTransformState(A,I);return A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateUp(),e}getViewFrontToObject(A){let I=A.getWorldPosition(new J),e=A.getWorldDirection(new J).multiplyScalar(this.targetOffset);return{position:I.clone().add(e),target:I}}getViewToTarget(A){let I=this.getWorldDirection(new J).multiplyScalar(this.targetOffset);return{position:A.clone().sub(I),target:A}}getViewToObject(A){let I=new J;return A.getWorldPosition(I),this.getViewToTarget(I)}setViewplaneSize(A,I,e=!1){if(this.aspect=A/I,e){let i=A>I?this.aspect:1,t=A>I?1:this.aspect;this.left=-Rl*.5*i,this.right=Rl*.5*i,this.top=Rl*.5*(1/t),this.bottom=-Rl*.5*(1/t)}else this.left=-A*.5,this.right=A*.5,this.top=I*.5,this.bottom=-I*.5;this.updateProjectionMatrix()}copyViewPlaneSize(A){this.aspect=A.aspect,this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.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(A){this.perspCamera.setFocalLength(A),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(A,I,e,i,t,C){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(A,I,e,i,t,C):this.orthoCamera.setViewOffset(A,I,e,i,t,C)}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(A){super.updateMatrixWorld(A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(A,I){super.updateWorldMatrix(A,I),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(A,I){return super.copy(A,I),this.parent=A.parent,this.orthoCamera.copy(A.orthoCamera),this.perspCamera.copy(A.perspCamera),this.left=A.left,this.right=A.right,this.top=A.top,this.bottom=A.bottom,this.far=A.far,this.view=A.view===null?null:Object.assign({},A.view),this._cameraType=A._cameraType,this.aspect=A.aspect,this.fov=A.fov,this.focus=A.focus,this.filmGauge=A.filmGauge,this.filmOffset=A.filmOffset,this.targetOffset=A.targetOffset,this.updateProjectionMatrix(),this}toCameraState(A=[]){let I={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 iy(I,A)}updateCameraSubtype(A,I){let e=A==="perspective"?"PerspectiveCamera":"OrthographicCamera";I.zoom!==void 0&&this.setZoom(e,I.zoom),I.near!==void 0&&this.setNear(e,I.near),I.fov!==void 0&&e==="PerspectiveCamera"&&(this.fov=I.fov)}updateState(A,I){this.updateCameraState(A,I)}updateCameraState(A,I){this.updateState_Entity(A,I),A.far!==void 0&&(this.far=A.far),A.orthographic!==void 0&&this.updateCameraSubtype("orthographic",A.orthographic),A.perspective!==void 0&&this.updateCameraSubtype("perspective",A.perspective),A.type!==void 0&&(this.cameraType=A.type),A.up!==void 0&&this.up.fromArray(A.up),A.targetOffset!==void 0&&(this.targetOffset=A.targetOffset),A.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=A.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(A,I,e){super.updateByPatchedOp(A,I,e),A.path.length===1&&A.type===0&&this.updateCameraSubtype(A.path[0],A.props)}toState(A){return{...super.toState(A),...this.toCameraState(A),type:this.cameraType}}},vs=new zA,C9=new zA,Kl=new zA,pm=new J,ym=new J;function wm(g){let A=!1;return g.scene.objects.traverse((I,e)=>{var i;((i=e.geometry)==null?void 0:i.type)==="BooleanGeometry"&&(A=!0)}),A}var YQ=class extends BE{constructor(A,I,e){super(A,I),this.data=I,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new bg,this.onAfterRender=(i,t,C,o,B,a)=>{super.onAfterRender(i,t,C,o,B,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(A,I,e){super.updateByPatchedOp(A,I,e),A.path.length===1&&A.path[0]==="geometry"&&A.type===0&&A.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(A,I=!0){var i;if(this.booleanMeshSetAddress!==-1&&!A)return;for(let t=0;t0&&C.geometry.drawRange.count>0){if(vs.multiplyMatrices(C.hiddenMatrix,C.matrix),C.booleanMeshSetAddress===-1){if((C.geometry.index??C.geometry.getAttribute("position")).count/3<15e5&&(C.booleanMeshSetAddress=aB.getMeshSet(C.geometry,A===!0,I)),C.booleanMeshSetAddress===-1)return;aB.transformMeshSet(C.booleanMeshSetAddress,vs),C.booleanMatrixInvOld.copy(vs).invert(),C.booleanWasTransformed=!1}else C instanceof YQ&&C.needsTransformForDownstream===!0?(aB.transformMeshSet(C.booleanMeshSetAddress,vs),C.needsTransformForDownstream=!1):C.booleanWasTransformed===!0&&(aB.transformMeshSet(C.booleanMeshSetAddress,C9.multiplyMatrices(vs,C.booleanMatrixInvOld)),C.booleanMatrixInvOld.copy(vs).invert(),C.booleanWasTransformed=!1);aB.hasOpenEdges(C.booleanMeshSetAddress)===!1||t===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(C.booleanMeshSetAddress),C.geometry.userData.wasFilteredFromBoolean=!1):C.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new pg([],0)),this.geometry.setDrawRange(0,0);return}if(A===!0)return aB.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let e=this.geometry;e.dispose(),this.geometry=new bg,this.geometry.userData=e.userData,this.geometry.boundingSphere=e.boundingSphere;try{this.booleanMeshSetAddress=aB.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(t){this.booleanMeshSetAddress=0,console.error(t)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,_0(this),P0(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){var I;let A=super.recursiveBBox;return((I=this.geometry.boundingSphere)==null?void 0:I.radius)===-1&&(A.getCenter(this.geometry.boundingSphere.center),Kl.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(Kl),pm.copy(A.max).applyMatrix4(Kl),ym.copy(A.min).applyMatrix4(Kl),this.geometry.boundingSphere.radius=pm.distanceTo(ym)/2),A}},Iw;(g=>{function A(I){return MI.is(I)&&I instanceof gh}g.is=A})(Iw||(Iw={}));var j0=(g,A)=>class extends Ch(g,A){updateState_Light(I,e){this.updateState_Entity(I,e),I.color!==void 0&&(this.color=e.shared.color(I.color)),I.intensity!==void 0&&(this.intensity=I.intensity),I.depth!==void 0&&(this.shadow.camera.far=I.depth,this.shadow.needsUpdate=!0),I.shadows!==void 0&&(this.castShadow=I.shadows)}},GC=g=>g instanceof Dt,Do=g=>g!==null&&g instanceof YQ,o9=g=>g instanceof Ji,B9=g=>Iw.is(g),ew=g=>gw.is(g),XD=class extends ih(O1){constructor(A,I=15){super(I),this.object=A,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${A.uuid}`,this.matrix=A.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(A,I){th(this.object,XD.geometryHelper,A,I)}update(){}},vn=class extends Ch(gQ,XD){constructor(A,I){super(),this.super_Entity(A,I),this.objectHelper.update()}updateState(A,I){this.updateState_Entity(A,I)}},AJ={RED:0,GREEN:1,BLUE:2,ALPHA:3},oh="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",a9=`#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale; +#if PASS == 1 +uniform vec4 kernel64[32]; +#else +uniform vec4 kernel16[8]; +#endif +varying vec2 vUv;void main(){ +#ifdef FOREGROUND +vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale; +#else +float CoC=texture2D(cocBuffer,vUv).g*scale; +#endif +if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{ +#ifdef FOREGROUND +vec2 step=texelSize*max(CoC,CoCNearFar.g*scale); +#else +vec2 step=texelSize*CoC; +#endif +#if PASS == 1 +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; +#else +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; +#endif +}}`,Jl=class extends te{constructor(g=!1,A=!1){super({name:"BokehMaterial",defines:{PASS:g?"2":"1"},uniforms:{kernel64:new ZA(null),kernel16:new ZA(null),inputBuffer:new ZA(null),cocBuffer:new ZA(null),texelSize:new ZA(new sA),scale:new ZA(1)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:a9,vertexShader:oh}),this.toneMapped=!1,A&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}set cocBuffer(g){this.uniforms.cocBuffer.value=g}setCoCBuffer(g){this.uniforms.cocBuffer.value=g}get scale(){return this.uniforms.scale.value}set scale(g){this.uniforms.scale.value=g}getScale(g){return this.uniforms.scale.value=g}setScale(g){this.uniforms.scale.value=g}generateKernel(){let g=2.39996323,A=new Float32Array(128),I=new Float32Array(32),e=0,i=0;for(let o=0;o<80;++o){let B=o*g,a=Math.sqrt(o)/Math.sqrt(80),s=a*Math.cos(B),r=a*Math.sin(B);o%5===0?(I[i++]=s,I[i++]=r):(A[e++]=s,A[e++]=r)}let t=[],C=[];for(let o=0;o<128;)t.push(new EI(A[o++],A[o++],A[o++],A[o++]));for(let o=0;o<32;)C.push(new EI(I[o++],I[o++],I[o++],I[o++]));this.uniforms.kernel64.value=t,this.uniforms.kernel16.value=C}setTexelSize(g,A){this.uniforms.texelSize.value.set(g,A)}setSize(g,A){this.uniforms.texelSize.value.set(1/g,1/A)}};function Sm(g,A,I){return g*(A-I)-A}function iw(g,A,I){return Math.min(Math.max((g+A)/(A-I),0),1)}var r9=`#include +#include +#ifdef GL_FRAGMENT_PRECISION_HIGH +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +return unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +return texture2D(depthBuffer,uv).r; +#endif +}void main(){float depth=readDepth(vUv); +#ifdef PERSPECTIVE_CAMERA +float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar); +#else +float linearDepth=depth; +#endif +float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,s9=class extends te{constructor(g){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ZA(null),focusDistance:new ZA(0),focusRange:new ZA(0),cameraNear:new ZA(.3),cameraFar:new ZA(1e3)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:r9,vertexShader:oh}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(g)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(g){this.uniforms.depthBuffer.value=g}set depthPacking(g){this.defines.DEPTH_PACKING=g.toFixed(0),this.needsUpdate=!0}setDepthBuffer(g,A=UB){this.depthBuffer=g,this.depthPacking=A}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(g){this.uniforms.focusDistance.value=g}get worldFocusDistance(){return-Sm(this.focusDistance,this.near,this.far)}set worldFocusDistance(g){this.focusDistance=iw(-g,this.near,this.far)}getFocusDistance(g){this.uniforms.focusDistance.value=g}setFocusDistance(g){this.uniforms.focusDistance.value=g}get focalLength(){return this.focusRange}set focalLength(g){this.focusRange=g}get focusRange(){return this.uniforms.focusRange.value}set focusRange(g){this.uniforms.focusRange.value=g}get worldFocusRange(){return-Sm(this.focusRange,this.near,this.far)}set worldFocusRange(g){this.focusRange=iw(-g,this.near,this.far)}getFocalLength(g){return this.focusRange}setFocalLength(g){this.focusRange=g}adoptCameraSettings(g){g&&(this.uniforms.cameraNear.value=g.near,this.uniforms.cameraFar.value=g.far,g instanceof Ui?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},Q9=`#include +#include +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; +#include +#include +}`,E9="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);}",fm=class extends te{constructor(A=new sA){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new ZA(null),texelSize:new ZA(new sA),halfTexelSize:new ZA(new sA),kernel:new ZA(0),scale:new ZA(1)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:Q9,vertexShader:E9}),this.toneMapped=!1,this.setTexelSize(A.x,A.y)}set inputBuffer(A){this.uniforms.inputBuffer.value=A}setInputBuffer(A){this.inputBuffer=A}get scale(){return this.uniforms.scale.value}set scale(A){this.uniforms.scale.value=A}getScale(){return this.uniforms.scale.value}setScale(A){this.uniforms.scale.value=A}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(A){this.uniforms.kernel.value=A}setKernel(A){this.kernel=A}setTexelSize(A,I){this.uniforms.texelSize.value.set(A,I),this.uniforms.halfTexelSize.value.set(A,I).multiplyScalar(.5)}setSize(A,I){let e=this.uniforms;e.texelSize.value.set(1/A,1/I),e.halfTexelSize.value.copy(e.texelSize.value).multiplyScalar(.5)}},n9=`#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; +#include +}`,h9=class extends te{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new ZA(null),opacity:new ZA(1)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:n9,vertexShader:oh}),this.toneMapped=!1}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}getOpacity(g){return this.uniforms.opacity.value}setOpacity(g){this.uniforms.opacity.value=g}},l9=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; +#if THREE_REVISION < 143 +#define luminance(v) linearToRelativeLuminance(v) +#endif +#if EDGE_DETECTION_MODE != 0 +varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; +#endif +#if EDGE_DETECTION_MODE == 1 +#include +#endif +#if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1 +#ifdef GL_FRAGMENT_PRECISION_HIGH +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +return unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +return texture2D(depthBuffer,uv).r; +#endif +}vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);} +#elif PREDICATION_MODE == 2 +uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);} +#endif +#if PREDICATION_MODE != 0 +vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);} +#endif +#if EDGE_DETECTION_MODE != 0 +uniform sampler2D inputBuffer; +#endif +void main(){ +#if EDGE_DETECTION_MODE == 0 +const vec2 threshold=vec2(DEPTH_THRESHOLD); +#elif PREDICATION_MODE != 0 +vec2 threshold=calculatePredicatedThreshold(); +#else +const vec2 threshold=vec2(EDGE_THRESHOLD); +#endif +#if EDGE_DETECTION_MODE == 0 +vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0); +#elif EDGE_DETECTION_MODE == 1 +float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); +#elif EDGE_DETECTION_MODE == 2 +vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); +#endif +}`,c9=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; +#if EDGE_DETECTION_MODE != 0 +varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; +#endif +void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0); +#if EDGE_DETECTION_MODE != 0 +vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0); +#endif +gl_Position=vec4(position.xy,1.0,1.0);}`,$D={DEPTH:0,LUMA:1,COLOR:2},D9={DISABLED:0,DEPTH:1,CUSTOM:2},d9=class extends te{constructor(g=new sA,A=$D.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:PQ.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 ZA(null),depthBuffer:new ZA(null),predicationBuffer:new ZA(null),texelSize:new ZA(g)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:l9,vertexShader:c9}),this.toneMapped=!1,this.edgeDetectionMode=A}set depthBuffer(g){this.uniforms.depthBuffer.value=g}set depthPacking(g){this.defines.DEPTH_PACKING=g.toFixed(0),this.needsUpdate=!0}setDepthBuffer(g,A=UB){this.depthBuffer=g,this.depthPacking=A}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(g){this.defines.EDGE_DETECTION_MODE=g.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(g){this.edgeDetectionMode=g}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(g){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=g.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(g){this.localContrastAdaptationFactor=g}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(g){this.defines.EDGE_THRESHOLD=g.toFixed("6"),this.defines.DEPTH_THRESHOLD=(g*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(g){this.edgeDetectionThreshold=g}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(g){this.defines.PREDICATION_MODE=g.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(g){this.predicationMode=g}set predicationBuffer(g){this.uniforms.predicationBuffer.value=g}setPredicationBuffer(g){this.uniforms.predicationBuffer.value=g}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(g){this.defines.PREDICATION_THRESHOLD=g.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(g){this.predicationThreshold=g}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(g){this.defines.PREDICATION_SCALE=g.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(g){this.predicationScale=g}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(g){this.defines.PREDICATION_STRENGTH=g.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(g){this.predicationStrength=g}setSize(g,A){this.uniforms.texelSize.value.set(1/g,1/A)}},u9=`#include +#include +#include +#define packFloatToRGBA(v) packDepthToRGBA(v) +#define unpackRGBAToFloat(v) unpackRGBAToDepth(v) +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +#ifdef GL_FRAGMENT_PRECISION_HIGH +uniform highp sampler2D depthBuffer; +#else +uniform mediump sampler2D depthBuffer; +#endif +uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv; +#if THREE_REVISION < 143 +#define luminance(v) linearToRelativeLuminance(v) +#endif +#if THREE_REVISION >= 137 +vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);} +#endif +float readDepth(const in vec2 uv){ +#if DEPTH_PACKING == 3201 +return unpackRGBAToDepth(texture2D(depthBuffer,uv)); +#else +return texture2D(depthBuffer,uv).r; +#endif +}float getViewZ(const in float depth){ +#ifdef PERSPECTIVE_CAMERA +return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); +#else +return orthographicDepthToViewZ(depth,cameraNear,cameraFar); +#endif +}FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0; +#ifdef ENCODE_OUTPUT +#include +#endif +#include +}`,p9="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);}",dC={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"},tw=class extends te{constructor(g,A,I,e,i=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:PQ.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new ZA(null),depthBuffer:new ZA(null),resolution:new ZA(new sA),texelSize:new ZA(new sA),cameraNear:new ZA(.3),cameraFar:new ZA(1e3),aspect:new ZA(1),time:new ZA(0)},blending:je,depthWrite:!1,depthTest:!1,dithering:i}),this.toneMapped=!1,g&&this.setShaderParts(g),A&&this.setDefines(A),I&&this.setUniforms(I),this.adoptCameraSettings(e)}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(g){this.uniforms.depthBuffer.value=g}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(g){this.defines.DEPTH_PACKING=g.toFixed(0),this.needsUpdate=!0}setDepthBuffer(g,A=UB){this.depthBuffer=g,this.depthPacking=A}setShaderParts(g){return this.fragmentShader=u9.replace(dC.FRAGMENT_HEAD,g.get(dC.FRAGMENT_HEAD)).replace(dC.FRAGMENT_MAIN_UV,g.get(dC.FRAGMENT_MAIN_UV)).replace(dC.FRAGMENT_MAIN_IMAGE,g.get(dC.FRAGMENT_MAIN_IMAGE)),this.vertexShader=p9.replace(dC.VERTEX_HEAD,g.get(dC.VERTEX_HEAD)).replace(dC.VERTEX_MAIN_SUPPORT,g.get(dC.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(g){for(let A of g.entries())this.defines[A[0]]=A[1];return this.needsUpdate=!0,this}setUniforms(g){for(let A of g.entries())this.uniforms[A[0]]=A[1];return this}setExtensions(g){this.extensions={};for(let A of g)this.extensions[A]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(g){this.encodeOutput!==g&&(g?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(g){return this.encodeOutput}setOutputEncodingEnabled(g){this.encodeOutput=g}get time(){return this.uniforms.time.value}set time(g){this.uniforms.time.value=g}setDeltaTime(g){this.uniforms.time.value+=g}adoptCameraSettings(g){g&&(this.uniforms.cameraNear.value=g.near,this.uniforms.cameraFar.value=g.far,g instanceof Ui?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(g,A){let I=this.uniforms;I.resolution.value.set(g,A),I.texelSize.value.set(1/g,1/A),I.aspect.value=g/A}static get Section(){return dC}},y9=`#include +#if THREE_REVISION < 143 +#define luminance(v) linearToRelativeLuminance(v) +#endif +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +#ifdef RANGE +uniform vec2 range; +#elif defined(THRESHOLD) +uniform float threshold;uniform float smoothing; +#endif +varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb); +#ifdef RANGE +float low=step(range.x,l);float high=step(l,range.y);l*=low*high; +#elif defined(THRESHOLD) +l=smoothstep(threshold,threshold+smoothing,l); +#endif +#ifdef COLOR +gl_FragColor=vec4(texel.rgb*l,l); +#else +gl_FragColor=vec4(l); +#endif +}`,w9=class extends te{constructor(g=!1,A=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:PQ.replace(/\D+/g,"")},uniforms:{inputBuffer:new ZA(null),threshold:new ZA(0),smoothing:new ZA(1),range:new ZA(null)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:y9,vertexShader:oh}),this.toneMapped=!1,this.colorOutput=g,this.luminanceRange=A}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}get threshold(){return this.uniforms.threshold.value}set threshold(g){this.smoothing>0||g>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=g}getThreshold(){return this.threshold}setThreshold(g){this.threshold=g}get smoothing(){return this.uniforms.smoothing.value}set smoothing(g){this.threshold>0||g>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=g}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(g){this.smoothing=g}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(g){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(g){g?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(g){return this.colorOutput}setColorOutputEnabled(g){this.colorOutput=g}get useRange(){return this.luminanceRange!==null}set useRange(g){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(g){g!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=g,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(g){this.luminanceRange=g}},S9=`#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +#ifdef MASK_PRECISION_HIGH +uniform mediump sampler2D maskTexture; +#else +uniform lowp sampler2D maskTexture; +#endif +#if MASK_FUNCTION != 0 +uniform float strength; +#endif +varying vec2 vUv;void main(){ +#if COLOR_CHANNEL == 0 +float mask=texture2D(maskTexture,vUv).r; +#elif COLOR_CHANNEL == 1 +float mask=texture2D(maskTexture,vUv).g; +#elif COLOR_CHANNEL == 2 +float mask=texture2D(maskTexture,vUv).b; +#else +float mask=texture2D(maskTexture,vUv).a; +#endif +#if MASK_FUNCTION == 0 +#ifdef INVERTED +mask=step(mask,0.0); +#else +mask=1.0-step(mask,0.0); +#endif +#else +mask=clamp(mask*strength,0.0,1.0); +#ifdef INVERTED +mask=1.0-mask; +#endif +#endif +#if MASK_FUNCTION == 2 +gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask); +#else +gl_FragColor=mask*texture2D(inputBuffer,vUv); +#endif +}`,gJ={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},f9=class extends te{constructor(g=null){super({name:"MaskMaterial",uniforms:{maskTexture:new ZA(g),inputBuffer:new ZA(null),strength:new ZA(1)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:S9,vertexShader:oh}),this.toneMapped=!1,this.setColorChannel(AJ.RED),this.setMaskFunction(gJ.DISCARD)}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}set maskTexture(g){this.uniforms.maskTexture.value=g,delete this.defines.MASK_PRECISION_HIGH,g.type!==vi&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(g){this.maskTexture=g}set colorChannel(g){this.defines.COLOR_CHANNEL=g.toFixed(0),this.needsUpdate=!0}setColorChannel(g){this.colorChannel=g}set maskFunction(g){this.defines.MASK_FUNCTION=g.toFixed(0),this.needsUpdate=!0}setMaskFunction(g){this.maskFunction=g}get inverted(){return this.defines.INVERTED!==void 0}set inverted(g){this.inverted&&!g?delete this.defines.INVERTED:g&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(g){this.inverted=g}get strength(){return this.uniforms.strength.value}set strength(g){this.uniforms.strength.value=g}getStrength(){return this.strength}setStrength(g){this.strength=g}},G9=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize) +#if __VERSION__ < 300 +#define round(v) floor(v + 0.5) +#endif +#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D inputBuffer; +#else +uniform lowp sampler2D inputBuffer; +#endif +uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;iend&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;iend&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ +#if !defined(DISABLE_CORNER_DETECTION) +vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0); +#endif +}void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ +#if !defined(DISABLE_CORNER_DETECTION) +vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0); +#endif +}void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){ +#if !defined(DISABLE_DIAG_DETECTION) +weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){ +#endif +vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d); +#if !defined(DISABLE_DIAG_DETECTION) +}else{e.r=0.0;} +#endif +}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,k9="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);}",M9=class extends te{constructor(g=new sA,A=new sA){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 ZA(null),searchTexture:new ZA(null),areaTexture:new ZA(null),resolution:new ZA(A),texelSize:new ZA(g)},blending:je,depthWrite:!1,depthTest:!1,fragmentShader:G9,vertexShader:k9}),this.toneMapped=!1}set inputBuffer(g){this.uniforms.inputBuffer.value=g}setInputBuffer(g){this.uniforms.inputBuffer.value=g}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(g){this.uniforms.searchTexture.value=g}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(g){this.uniforms.areaTexture.value=g}setLookupTextures(g,A){this.searchTexture=g,this.areaTexture=A}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(g){let A=Math.min(Math.max(g,0),112);this.defines.MAX_SEARCH_STEPS_INT=A.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=A.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(g){this.orthogonalSearchSteps=g}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(g){let A=Math.min(Math.max(g,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=A.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=A.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(g){this.diagonalSearchSteps=g}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(g){g?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(g){this.diagonalDetection=g}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(g){let A=Math.min(Math.max(g,0),100);this.defines.CORNER_ROUNDING=A.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(A/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(g){this.cornerRounding=g}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(g){g?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(g){this.cornerDetection=g}setSize(g,A){let I=this.uniforms;I.texelSize.value.set(1/g,1/A),I.resolution.value.set(g,A)}},m9=new ZQ,jB=null;function U9(){if(jB===null){let g=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),A=new Float32Array([0,0,2,0,0,2]);jB=new bg,jB.setAttribute!==void 0?(jB.setAttribute("position",new zg(g,3)),jB.setAttribute("uv",new zg(A,2))):(jB.addAttribute("position",new zg(g,3)),jB.addAttribute("uv",new zg(A,2)))}return jB}var gt=class{constructor(A="Pass",I=new ca,e=m9){this.name=A,this.renderer=null,this.scene=I,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(A){if(this.rtt===A){let I=this.getFullscreenMaterial();I!==null&&(I.needsUpdate=!0),this.rtt=!A}}setRenderer(A){this.renderer=A}isEnabled(){return this.enabled}setEnabled(A){this.enabled=A}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(A){let I=this.screen;I!==null?I.material=A:(I=new Qt(U9(),A),I.frustumCulled=!1,this.scene===null&&(this.scene=new ca),this.scene.add(I),this.screen=I)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(A){this.fullscreenMaterial=A}getDepthTexture(){return null}setDepthTexture(A,I=UB){}render(A,I,e,i,t){throw new Error("Render method not implemented!")}setSize(A,I){}initialize(A,I,e){}dispose(){for(let A of Object.keys(this)){let I=this[A];if(I!==null&&typeof I.dispose=="function"){if(I instanceof ca||I===this.renderer)continue;this[A].dispose()}}}},Cw=class extends gt{constructor(g,A=!0){super("CopyPass"),this.fullscreenMaterial=new h9,this.needsSwap=!1,this.renderTarget=g,g===void 0&&(this.renderTarget=new WI(1,1,{minFilter:cI,magFilter:cI,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=A}get resize(){return this.autoResize}set resize(g){this.autoResize=g}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(g){this.autoResize=g}render(g,A,I,e,i){this.fullscreenMaterial.inputBuffer=A.texture,g.setRenderTarget(this.renderToScreen?null:this.renderTarget),g.render(this.scene,this.camera)}setSize(g,A){this.autoResize&&this.renderTarget.setSize(g,A)}initialize(g,A,I){I!==void 0&&(this.renderTarget.texture.type=I,I!==vi?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":g.outputEncoding===sI&&(this.renderTarget.texture.encoding=sI))}},N9=class extends gt{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(A,I,e,i,t){let C=A.state.buffers.stencil;C.setLocked(!1),C.setTest(!1)}},Ip=new Og,W0=class extends gt{constructor(g=!0,A=!0,I=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=g,this.depth=A,this.stencil=I,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(g,A,I){this.color=g,this.depth=A,this.stencil=I}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(g){this.overrideClearColor=g}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(g){this.overrideClearAlpha=g}render(g,A,I,e,i){let t=this.overrideClearColor,C=this.overrideClearAlpha,o=g.getClearAlpha(),B=t!==null,a=C>=0;B?(Ip.copy(g.getClearColor(Ip)),g.setClearColor(t,a?C:o)):a&&g.setClearAlpha(C),g.setRenderTarget(this.renderToScreen?null:A),g.clear(this.color,this.depth,this.stencil),B?g.setClearColor(Ip,o):a&&g.setClearAlpha(o)}},WB=-1,nt=class extends Si{constructor(A,I=WB,e=WB,i=1){super(),this.resizable=A,this.base=new sA(1,1),this.preferred=new sA(I,e),this.target=this.preferred,this.s=i}get width(){let{base:A,preferred:I,scale:e}=this,i;return I.width!==WB?i=I.width:I.height!==WB?i=Math.round(I.height*(A.width/Math.max(A.height,1))):i=Math.round(A.width*e),i}set width(A){this.preferredWidth=A}get height(){let{base:A,preferred:I,scale:e}=this,i;return I.height!==WB?i=I.height:I.width!==WB?i=Math.round(I.width/Math.max(A.width/Math.max(A.height,1),1)):i=Math.round(A.height*e),i}set height(A){this.preferredHeight=A}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(A){this.s!==A&&(this.s=A,this.preferred.setScalar(WB),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(A){this.scale=A}get baseWidth(){return this.base.width}set baseWidth(A){this.base.width!==A&&(this.base.width=A,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(A){this.base.width!==A&&(this.base.width=A,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(A){this.base.height!==A&&(this.base.height=A,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(A){this.baseHeight=A}setBaseSize(A,I){(this.base.width!==A||this.base.height!==I)&&(this.base.set(A,I),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(A){this.preferred.width!==A&&(this.preferred.width=A,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(A){this.preferredWidth=A}get preferredHeight(){return this.preferred.height}set preferredHeight(A){this.preferred.height!==A&&(this.preferred.height=A,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(A){this.preferredHeight=A}setPreferredSize(A,I){(this.preferred.width!==A||this.preferred.height!==I)&&(this.preferred.set(A,I),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(A){this.base.set(A.getBaseWidth(),A.getBaseHeight()),this.preferred.set(A.getPreferredWidth(),A.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return WB}},ep=!1,Gm=class{constructor(g=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(g),this.meshCount=0,this.replaceMaterial=A=>{if(A.isMesh){let I;if(A.material.flatShading)switch(A.material.side){case Ft:I=this.materialsFlatShadedDoubleSide;break;case ni:I=this.materialsFlatShadedBackSide;break;default:I=this.materialsFlatShaded;break}else switch(A.material.side){case Ft:I=this.materialsDoubleSide;break;case ni:I=this.materialsBackSide;break;default:I=this.materials;break}this.originalMaterials.set(A,A.material),A.isSkinnedMesh?A.material=I[2]:A.isInstancedMesh?A.material=I[1]:A.material=I[0],++this.meshCount}}}setMaterial(g){if(this.disposeMaterials(),this.material=g,g!==null){let A=this.materials=[g.clone(),g.clone(),g.clone()];for(let I of A)I.uniforms=Object.assign({},g.uniforms),I.side=RC;A[2].skinning=!0,this.materialsBackSide=A.map(I=>{let e=I.clone();return e.uniforms=Object.assign({},g.uniforms),e.side=ni,e}),this.materialsDoubleSide=A.map(I=>{let e=I.clone();return e.uniforms=Object.assign({},g.uniforms),e.side=Ft,e}),this.materialsFlatShaded=A.map(I=>{let e=I.clone();return e.uniforms=Object.assign({},g.uniforms),e.flatShading=!0,e}),this.materialsFlatShadedBackSide=A.map(I=>{let e=I.clone();return e.uniforms=Object.assign({},g.uniforms),e.flatShading=!0,e.side=ni,e}),this.materialsFlatShadedDoubleSide=A.map(I=>{let e=I.clone();return e.uniforms=Object.assign({},g.uniforms),e.flatShading=!0,e.side=Ft,e})}}render(g,A,I){let e=g.shadowMap.enabled;if(g.shadowMap.enabled=!1,ep){let i=this.originalMaterials;this.meshCount=0,A.traverse(this.replaceMaterial),g.render(A,I);for(let t of i)t[0].material=t[1];this.meshCount!==i.size&&i.clear()}else{let i=A.overrideMaterial;A.overrideMaterial=this.material,g.render(A,I),A.overrideMaterial=i}g.shadowMap.enabled=e}disposeMaterials(){if(this.material!==null){let g=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let A of g)A.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return ep}static set workaroundEnabled(g){ep=g}},F9=class extends gt{constructor(g,A,I=null){super("RenderPass",g,A),this.needsSwap=!1,this.clearPass=new W0,this.overrideMaterialManager=I===null?null:new Gm(I),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(g){super.renderToScreen=g,this.clearPass.renderToScreen=g}get overrideMaterial(){let g=this.overrideMaterialManager;return g!==null?g.material:null}set overrideMaterial(g){let A=this.overrideMaterialManager;g!==null?A!==null?A.setMaterial(g):this.overrideMaterialManager=new Gm(g):A!==null&&(A.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(g){this.overrideMaterial=g}get clear(){return this.clearPass.enabled}set clear(g){this.clearPass.enabled=g}getSelection(){return this.selection}setSelection(g){this.selection=g}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(g){this.ignoreBackground=g}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(g){this.skipShadowMapUpdate=g}getClearPass(){return this.clearPass}render(g,A,I,e,i){let t=this.scene,C=this.camera,o=this.selection,B=C.layers.mask,a=t.background,s=g.shadowMap.autoUpdate,r=this.renderToScreen?null:A;o!==null&&C.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(g.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(t.background=null),this.clearPass.enabled&&this.clearPass.render(g,A),g.setRenderTarget(r),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(g,t,C):g.render(t,C),C.layers.mask=B,t.background=a,g.shadowMap.autoUpdate=s}},km=class extends gt{constructor(g,A,{resolutionScale:I=1,width:e=nt.AUTO_SIZE,height:i=nt.AUTO_SIZE,renderTarget:t}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new F9(g,A,new ON({depthPacking:UN}));let C=this.renderPass;C.skipShadowMapUpdate=!0,C.ignoreBackground=!0;let o=C.getClearPass();o.overrideClearColor=new Og(16777215),o.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new WI(1,1,{minFilter:ie,magFilter:ie,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let B=this.resolution=new nt(this,e,i,I);B.addEventListener("change",a=>this.setSize(B.baseWidth,B.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(g){this.resolution.scale=g}render(g,A,I,e,i){let t=this.renderToScreen?null:this.renderTarget;this.renderPass.render(g,t)}setSize(g,A){let I=this.resolution;I.setBaseSize(g,A),this.renderTarget.setSize(I.width,I.height)}},UI={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},R9="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);}",K9="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));}",J9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",v9="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);}",q9="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);}",L9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",b9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",Y9="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);}",x9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",H9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",T9="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);}",O9="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);}",_9="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",P9="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);}",j9="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);}",W9="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);}",Z9="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);}",V9="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);}",z9=new Map([[UI.SKIP,null],[UI.ADD,R9],[UI.ALPHA,K9],[UI.AVERAGE,J9],[UI.COLOR_BURN,v9],[UI.COLOR_DODGE,q9],[UI.DARKEN,L9],[UI.DIFFERENCE,b9],[UI.EXCLUSION,Y9],[UI.LIGHTEN,x9],[UI.MULTIPLY,H9],[UI.DIVIDE,T9],[UI.NEGATION,O9],[UI.NORMAL,_9],[UI.OVERLAY,P9],[UI.REFLECT,j9],[UI.SCREEN,W9],[UI.SOFT_LIGHT,Z9],[UI.SUBTRACT,V9]]),X9=class extends Si{constructor(g,A=1){super(),this.f=g,this.opacity=new ZA(A)}getOpacity(){return this.opacity.value}setOpacity(g){this.opacity.value=g}get blendFunction(){return this.f}set blendFunction(g){this.f=g,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(g){this.blendFunction=g}getShaderCode(){return z9.get(this.blendFunction)}},wo={NONE:0,DEPTH:1,CONVOLUTION:2},Ko=class extends Si{constructor(A,I,{attributes:e=wo.NONE,blendFunction:i=UI.SCREEN,defines:t=new Map,uniforms:C=new Map,extensions:o=null,vertexShader:B=null}={}){super(),this.name=A,this.renderer=null,this.attributes=e,this.fragmentShader=I,this.vertexShader=B,this.defines=t,this.uniforms=C,this.extensions=o,this.blendMode=new X9(i),this.blendMode.addEventListener("change",a=>this.setChanged())}getName(){return this.name}setRenderer(A){this.renderer=A}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(A){this.attributes=A,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(A){this.fragmentShader=A,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(A){this.vertexShader=A,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(A,I=UB){}update(A,I,e){}setSize(A,I){}initialize(A,I,e){}dispose(){for(let A of Object.keys(this)){let I=this[A];if(I!==null&&typeof I.dispose=="function"){if(I instanceof ca||I===this.renderer)continue;this[A].dispose()}}}};function Mm(g,A,I){for(let e of A){let i="$1"+g+e.charAt(0).toUpperCase()+e.slice(1),t=new RegExp("([^\\.])(\\b"+e+"\\b)","g");for(let C of I.entries())C[1]!==null&&I.set(C[0],C[1].replace(t,i))}}function $9(g,A,I,e,i,t,C){let o=new Map([["fragment",A.getFragmentShader()],["vertex",A.getVertexShader()]]),B=o.get("fragment")!==void 0&&/mainImage/.test(o.get("fragment")),a=o.get("fragment")!==void 0&&/mainUv/.test(o.get("fragment")),s=[],r=[],Q=!1,E=!1;if(o.get("fragment")===void 0)console.error("Missing fragment shader",A);else if(a&&C&wo.CONVOLUTION)console.error("Effects that transform UV coordinates are incompatible with convolution effects",A);else if(!B&&!a)console.error("The fragment shader contains neither a mainImage nor a mainUv function",A);else{let n=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,h=tw.Section;if(a){let c=` ${g}MainUv(UV); +`;I.set(h.FRAGMENT_MAIN_UV,I.get(h.FRAGMENT_MAIN_UV)+c),Q=!0}if(o.get("vertex")!==null&&/mainSupport/.test(o.get("vertex"))){let c=` ${g}MainSupport(`;c+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get("vertex"))?`vUv); +`:`); +`,I.set(h.VERTEX_MAIN_SUPPORT,I.get(h.VERTEX_MAIN_SUPPORT)+c),s=s.concat([...o.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(d=>d[1])),r=r.concat(s).concat([...o.get("vertex").matchAll(n)].map(d=>d[1]))}r=r.concat([...o.get("fragment").matchAll(n)].map(c=>c[1])),r=r.concat([...A.defines.keys()].map(c=>c.replace(/\([\w\s,]*\)/g,""))),r=r.concat([...A.uniforms.keys()]),A.uniforms.forEach((c,d)=>t.set(g+d.charAt(0).toUpperCase()+d.slice(1),c)),A.defines.forEach((c,d)=>i.set(g+d.charAt(0).toUpperCase()+d.slice(1),c)),Mm(g,r,i),Mm(g,r,o);let l=A.blendMode;if(e.set(l.blendFunction,l),B){let c=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,d=`${g}MainImage(color0, UV, `;C&wo.DEPTH&&c.test(o.get("fragment"))&&(d+="depth, ",E=!0),d+=`color1); + `;let u=g+"BlendOpacity";t.set(u,l.opacity),d+=`color0 = blend${l.blendFunction}(color0, color1, ${u}); + + `,I.set(h.FRAGMENT_MAIN_IMAGE,I.get(h.FRAGMENT_MAIN_IMAGE)+d),d=`uniform float ${u}; + +`,I.set(h.FRAGMENT_HEAD,I.get(h.FRAGMENT_HEAD)+d)}I.set(h.FRAGMENT_HEAD,I.get(h.FRAGMENT_HEAD)+o.get("fragment")+` +`),o.get("vertex")!==null&&I.set(h.VERTEX_HEAD,I.get(h.VERTEX_HEAD)+o.get("vertex")+` +`)}return{varyings:s,transformedUv:Q,readDepth:E}}var eD=class extends gt{constructor(g,...A){super("EffectPass"),this.fullscreenMaterial=new tw(null,null,null,g),this.effects=A.sort((I,e)=>e.attributes-I.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(g){this.fullscreenMaterial.encodeOutput=g}get dithering(){return this.fullscreenMaterial.dithering}set dithering(g){let A=this.fullscreenMaterial;A.dithering=g,A.needsUpdate=!0}verifyResources(){let g=this.renderer.capabilities,A=Math.min(g.maxFragmentUniforms,g.maxVertexUniforms);this.uniformCount>A&&console.warn("The current rendering context doesn't support more than "+A+" uniforms, but "+this.uniformCount+" were defined"),A=g.maxVaryings,this.varyingCount>A&&console.warn("The current rendering context doesn't support more than "+A+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let g=tw.Section,A=new Map([[g.FRAGMENT_HEAD,""],[g.FRAGMENT_MAIN_UV,""],[g.FRAGMENT_MAIN_IMAGE,""],[g.VERTEX_HEAD,""],[g.VERTEX_MAIN_SUPPORT,""]]),I=new Map,e=new Map,i=new Map,t=new Set,C=0,o=0,B=0,a=!1,s=!1;for(let Q of this.effects)if(Q.blendMode.blendFunction===UI.SKIP)B|=Q.getAttributes()&wo.DEPTH;else if(B&Q.getAttributes()&wo.CONVOLUTION)console.error("Convolution effects cannot be merged",Q);else{B|=Q.getAttributes();let E="e"+C++,n=$9(E,Q,A,I,e,i,B);if(o+=n.varyings.length,a=a||n.transformedUv,s=s||n.readDepth,Q.extensions!==null)for(let h of Q.extensions)t.add(h)}let r=/\bblend\b/g;for(let Q of I.values()){let E=Q.getShaderCode().replace(r,`blend${Q.blendFunction}`);A.set(g.FRAGMENT_HEAD,A.get(g.FRAGMENT_HEAD)+E+` +`)}if(B&wo.DEPTH){if(s){let Q=`float depth = readDepth(UV); + + `;A.set(g.FRAGMENT_MAIN_IMAGE,Q+A.get(g.FRAGMENT_MAIN_IMAGE))}this.needsDepthTexture=this.getDepthTexture()===null}else this.needsDepthTexture=!1;if(a){let Q=`vec2 transformedUv = vUv; +`;A.set(g.FRAGMENT_MAIN_UV,Q+A.get(g.FRAGMENT_MAIN_UV)),e.set("UV","transformedUv")}else e.set("UV","vUv");A.forEach((Q,E,n)=>n.set(E,Q.trim().replace(/^#/,` +#`))),this.uniformCount=i.size,this.varyingCount=o,this.skipRendering=C===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(A).setExtensions(t).setUniforms(i).setDefines(e)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(g,A=UB){this.fullscreenMaterial.depthBuffer=g,this.fullscreenMaterial.depthPacking=A;for(let I of this.effects)I.setDepthTexture(g,A)}render(g,A,I,e,i){for(let t of this.effects)t.update(g,A,e);if(!this.skipRendering||this.renderToScreen){let t=this.fullscreenMaterial;t.inputBuffer=A.texture,t.time+=e,g.setRenderTarget(this.renderToScreen?null:I),g.render(this.scene,this.camera)}}setSize(g,A){this.fullscreenMaterial.setSize(g,A);for(let I of this.effects)I.setSize(g,A)}initialize(g,A,I){this.renderer=g;for(let e of this.effects)e.initialize(g,A,I),e.addEventListener("change",i=>this.handleEvent(i));this.updateMaterial(),this.verifyResources(),I!==void 0&&I!==vi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let g of this.effects)g.dispose()}handleEvent(g){switch(g.type){case"change":this.recompile();break}}},A6=[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])],IJ=class extends gt{constructor({resolutionScale:g=.5,width:A=nt.AUTO_SIZE,height:I=nt.AUTO_SIZE,kernelSize:e=Z0.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new WI(1,1,{minFilter:cI,magFilter:cI,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let i=this.resolution=new nt(this,A,I,g);i.addEventListener("change",t=>this.setSize(i.baseWidth,i.baseHeight)),this.blurMaterial=new fm,this.ditheredBlurMaterial=new fm,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=e}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(g){this.resolution.preferredWidth=g}get height(){return this.resolution.height}set height(g){this.resolution.preferredHeight=g}get scale(){return this.blurMaterial.scale}set scale(g){this.blurMaterial.scale=g}getScale(){return this.blurMaterial.scale}setScale(g){this.blurMaterial.scale=g}getKernelSize(){return this.kernelSize}setKernelSize(g){this.kernelSize=g}getResolutionScale(){return this.resolution.scale}setResolutionScale(g){this.resolution.scale=g}render(g,A,I,e,i){let t=this.scene,C=this.camera,o=this.renderTargetA,B=this.renderTargetB,a=A6[this.kernelSize],s=this.blurMaterial,r=A,Q,E;for(this.fullscreenMaterial=s,Q=0,E=a.length-1;Qthis.setSize(t.baseWidth,t.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(g,A,I,e,i){let t=this.fullscreenMaterial;t.inputBuffer=A.texture,g.setRenderTarget(this.renderToScreen?null:this.renderTarget),g.render(this.scene,this.camera)}setSize(g,A){let I=this.resolution;I.setBaseSize(g,A),this.renderTarget.setSize(I.width,I.height)}initialize(g,A,I){I!==void 0&&I!==vi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},I6=class extends gt{constructor(A,I){super("MaskPass",A,I),this.needsSwap=!1,this.clearPass=new W0(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(A){this.inverse=A}get clear(){return this.clearPass.enabled}set clear(A){this.clearPass.enabled=A}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(A){this.inverted=A}render(A,I,e,i,t){let C=A.getContext(),o=A.state.buffers,B=this.scene,a=this.camera,s=this.clearPass,r=this.inverted?0:1,Q=1-r;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(C.REPLACE,C.REPLACE,C.REPLACE),o.stencil.setFunc(C.ALWAYS,r,4294967295),o.stencil.setClear(Q),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?s.render(A,null):(s.render(A,I),s.render(A,e))),this.renderToScreen?(A.setRenderTarget(null),A.render(B,a)):(A.setRenderTarget(I),A.render(B,a),A.setRenderTarget(e),A.render(B,a)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(C.EQUAL,1,4294967295),o.stencil.setOp(C.KEEP,C.KEEP,C.KEEP),o.stencil.setLocked(!0)}},Eo=class extends gt{constructor(A,I="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=A,this.inputBufferUniform=null,this.setInput(I)}setInput(A){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let I=this.fullscreenMaterial.uniforms;I!==void 0&&I[A]!==void 0&&(this.inputBufferUniform=I[A])}}render(A,I,e,i,t){this.inputBufferUniform!==null&&I!==null&&(this.inputBufferUniform.value=I.texture),A.setRenderTarget(this.renderToScreen?null:e),A.render(this.scene,this.camera)}initialize(A,I,e){e!==void 0&&e!==vi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},ip=1/1e3,e6=1e3,i6=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(A){return this.fixedDeltaEnabled=A,this}isAutoResetEnabled(A){return this.autoReset}setAutoResetEnabled(A){return typeof document<"u"&&document.hidden!==void 0&&(A?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=A),this}getDelta(){return this.delta*ip}getFixedDelta(){return this.fixedDelta*ip}setFixedDelta(A){return this.fixedDelta=A*e6,this}getElapsed(){return this.elapsed*ip}getTimescale(){return this.timescale}setTimescale(A){return this.timescale=A,this}update(A){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=A!==void 0?A: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(A){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}},Z0={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},t6=`#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D map; +#else +uniform lowp sampler2D map; +#endif +uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`,C6=class extends Ko{constructor({blendFunction:A=UI.SCREEN,luminanceThreshold:I=.9,luminanceSmoothing:e=.025,resolutionScale:i=.5,intensity:t=1,width:C=nt.AUTO_SIZE,height:o=nt.AUTO_SIZE,kernelSize:B=Z0.LARGE}={}){super("BloomEffect",t6,{blendFunction:A,uniforms:new Map([["map",new ZA(null)],["intensity",new ZA(t)]])}),this.renderTarget=new WI(1,1,{minFilter:cI,magFilter:cI,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 g6({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=I,this.luminanceMaterial.smoothingFactor=e,this.blurPass=new IJ({resolutionScale:i,width:C,height:o,kernelSize:B});let a=this.blurPass.getResolution();a.addEventListener("change",s=>this.setSize(a.baseWidth,a.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(A){this.resolution.preferredWidth=A}get height(){return this.resolution.height}set height(A){this.resolution.preferredHeight=A}get dithering(){return this.blurPass.dithering}set dithering(A){this.blurPass.dithering=A}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(A){this.blurPass.kernelSize=A}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(A){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(A){this.uniforms.get("intensity").value=A}getIntensity(){return this.intensity}setIntensity(A){this.intensity=A}getResolutionScale(){return this.resolution.scale}setResolutionScale(A){this.resolution.scale=A}update(A,I,e){let i=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(A,I,i),this.blurPass.render(A,i,i)):this.blurPass.render(A,I,i)}setSize(A,I){let e=this.resolution;e.setBaseSize(A,I),this.renderTarget.setSize(e.width,e.height),this.luminancePass.resolution.copy(e)}initialize(A,I,e){this.blurPass.initialize(A,I,e),e!==void 0&&(this.renderTarget.texture.type=e,A.outputEncoding===sI&&(this.renderTarget.texture.encoding=sI))}},o6="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);}",B6=class extends Ko{constructor({blendFunction:A=UI.NORMAL,brightness:I=0,contrast:e=0}={}){super("BrightnessContrastEffect",o6,{blendFunction:A,uniforms:new Map([["brightness",new ZA(I)],["contrast",new ZA(e)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(A){this.uniforms.get("brightness").value=A}getBrightness(A){return this.brightness}setBrightness(A){this.brightness=A}get contrast(){return this.uniforms.get("contrast").value}set contrast(A){this.uniforms.get("contrast").value=A}getContrast(A){return this.contrast}setContrast(A){this.contrast=A}},a6="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",r6=class extends Ko{constructor(A=UI.NORMAL){super("ColorAverageEffect",a6,{blendFunction:A})}},s6="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));}",Q6="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;}",E6=class extends Ko{constructor({blendFunction:A=UI.NORMAL,offset:I=new sA(.001,5e-4)}={}){super("ChromaticAberrationEffect",s6,{vertexShader:Q6,blendFunction:A,attributes:wo.CONVOLUTION,uniforms:new Map([["offset",new ZA(I)]])})}get offset(){return this.uniforms.get("offset").value}set offset(A){this.uniforms.get("offset").value=A}getOffset(){return this.offset}setOffset(A){this.offset=A}},n6=`#ifdef FRAMEBUFFER_PRECISION_HIGH +uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer; +#else +uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer; +#endif +uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,h6=class extends Ko{constructor(A,{blendFunction:I=UI.NORMAL,worldFocusDistance:e,worldFocusRange:i,focusDistance:t=0,focalLength:C=.1,focusRange:o=C,bokehScale:B=1,width:a=nt.AUTO_SIZE,height:s=nt.AUTO_SIZE}={}){super("DepthOfFieldEffect",n6,{blendFunction:I,attributes:wo.DEPTH,uniforms:new Map([["nearColorBuffer",new ZA(null)],["farColorBuffer",new ZA(null)],["nearCoCBuffer",new ZA(null)],["scale",new ZA(1)]])}),this.camera=A,this.renderTarget=new WI(1,1,{minFilter:cI,magFilter:cI,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 Eo(new s9(A));let r=this.cocMaterial;r.focusDistance=t,r.focusRange=o,e!==void 0&&(r.worldFocusDistance=e),i!==void 0&&(r.worldFocusRange=i),this.blurPass=new IJ({kernelSize:Z0.MEDIUM,width:a,height:s});let Q=this.blurPass.getResolution();Q.addEventListener("change",n=>this.setSize(Q.getBaseWidth(),Q.getBaseHeight())),this.maskPass=new Eo(new f9(this.renderTargetCoC.texture));let E=this.maskPass.fullscreenMaterial;E.maskFunction=gJ.MULTIPLY,E.colorChannel=AJ.GREEN,this.bokehNearBasePass=new Eo(new Jl(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new Eo(new Jl(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new Eo(new Jl(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new Eo(new Jl(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=B}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(A){let I=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let e of I)e.fullscreenMaterial.setScale(A);this.maskPass.fullscreenMaterial.setStrength(A),this.uniforms.get("scale").value=A}getBokehScale(){return this.bokehScale}setBokehScale(A){this.bokehScale=A}getTarget(){return this.target}setTarget(A){this.target=A}calculateFocusDistance(A){let I=this.camera,e=I.position.distanceTo(A);return iw(-e,I.near,I.far)}setDepthTexture(A,I=UB){this.circleOfConfusionMaterial.depthBuffer=A,this.circleOfConfusionMaterial.depthPacking=I}update(A,I,e){let i=this.renderTarget,t=this.renderTargetCoC,C=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let B=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=B}this.cocPass.render(A,null,t),this.blurPass.render(A,t,C),this.maskPass.render(A,I,o),this.bokehFarBasePass.render(A,o,i),this.bokehFarFillPass.render(A,i,this.renderTargetFar),this.bokehNearBasePass.render(A,I,i),this.bokehNearFillPass.render(A,i,this.renderTargetNear)}setSize(A,I){let e=this.resolution;e.setBaseSize(A,I);let i=e.width,t=e.height,C=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];C.push(this.renderTargetCoC,this.renderTargetMasked),C.forEach(o=>o.setSize(A,I)),C=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],C.forEach(o=>o.setSize(i,t)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(o=>o.fullscreenMaterial.setSize(i,t))}initialize(A,I,e){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(i=>i.initialize(A,I,e)),this.blurPass.initialize(A,I,vi),e!==void 0&&(this.renderTarget.texture.type=e,this.renderTargetNear.texture.type=e,this.renderTargetFar.texture.type=e,this.renderTargetMasked.texture.type=e,A.outputEncoding===sI&&(this.renderTarget.texture.encoding=sI,this.renderTargetNear.texture.encoding=sI,this.renderTargetFar.texture.encoding=sI,this.renderTargetMasked.texture.encoding=sI))}};new J;new zA;var l6="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);}",c6=class extends Ko{constructor({blendFunction:A=UI.NORMAL,hue:I=0,saturation:e=0}={}){super("HueSaturationEffect",l6,{blendFunction:A,uniforms:new Map([["hue",new ZA(new J)],["saturation",new ZA(e)]])}),this.hue=I}get saturation(){return this.uniforms.get("saturation").value}set saturation(A){this.uniforms.get("saturation").value=A}getSaturation(){return this.saturation}setSaturation(A){this.saturation=A}get hue(){let A=this.uniforms.get("hue").value;return Math.acos((A.x*3-1)/2)}set hue(A){let I=Math.sin(A),e=Math.cos(A);this.uniforms.get("hue").value.set((2*e+1)/3,(-Math.sqrt(3)*I-e+1)/3,(Math.sqrt(3)*I-e+1)/3)}getHue(){return this.hue}setHue(A){this.hue=A}};new Og;var D6=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time)); +#ifdef PREMULTIPLY +outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); +#else +outputColor=vec4(noise,inputColor.a); +#endif +}`,d6=class extends Ko{constructor({blendFunction:A=UI.SCREEN,premultiply:I=!1}={}){super("NoiseEffect",D6,{blendFunction:A}),this.premultiply=I}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(A){this.premultiply!==A&&(A?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(A){this.premultiply=A}},u6="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));}}",p6=class extends Ko{constructor(A=30){super("PixelationEffect",u6,{uniforms:new Map([["active",new ZA(!1)],["d",new ZA(new sA)]])}),this.resolution=new sA,this.d=0,this.granularity=A}get granularity(){return this.d}set granularity(A){let I=Math.floor(A);I%2>0&&(I+=1),this.d=I,this.uniforms.get("active").value=I>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(A){this.granularity=A}setSize(A,I){this.resolution.set(A,I),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};new J;new J;var mm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",Um="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9Cbhl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gBTK0gQHiIAJddKq0ELQh+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",y6="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;}",w6="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);}",nr={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},eJ=class extends Ko{constructor({preset:g=nr.MEDIUM,edgeDetectionMode:A=$D.COLOR,predicationMode:I=D9.DISABLED}={}){super("SMAAEffect",y6,{vertexShader:w6,blendFunction:UI.NORMAL,attributes:wo.CONVOLUTION|wo.DEPTH,uniforms:new Map([["weightMap",new ZA(null)]])});let e,i;arguments.length>1&&(e=arguments[0],i=arguments[1],arguments.length>2&&(g=arguments[2]),arguments.length>3&&(A=arguments[3])),this.renderTargetEdges=new WI(1,1,{minFilter:cI,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 W0(!0,!1,!1),this.clearPass.overrideClearColor=new Og(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new Eo(new d9),this.edgeDetectionMaterial.edgeDetectionMode=A,this.edgeDetectionMaterial.predicationMode=I,this.weightsPass=new Eo(new M9);let t=new aF;t.onLoad=()=>{let C=new ti(e);C.name="SMAA.Search",C.magFilter=ie,C.minFilter=ie,C.generateMipmaps=!1,C.needsUpdate=!0,C.flipY=!0,this.weightsMaterial.searchTexture=C;let o=new ti(i);o.name="SMAA.Area",o.magFilter=cI,o.minFilter=cI,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!1,this.weightsMaterial.areaTexture=o,this.dispatchEvent({type:"load"})},t.itemStart("search"),t.itemStart("area"),e!==void 0&&i!==void 0?(t.itemEnd("search"),t.itemEnd("area")):typeof Image<"u"&&(e=new Image,i=new Image,e.addEventListener("load",()=>t.itemEnd("search")),i.addEventListener("load",()=>t.itemEnd("area")),e.src=mm,i.src=Um),this.applyPreset(g)}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(g){this.edgeDetectionMaterial.edgeDetectionThreshold=g}setOrthogonalSearchSteps(g){this.weightsMaterial.orthogonalSearchSteps=g}applyPreset(g){let A=this.edgeDetectionMaterial,I=this.weightsMaterial;switch(g){case nr.LOW:A.edgeDetectionThreshold=.15,I.orthogonalSearchSteps=4,I.diagonalDetection=!1,I.cornerDetection=!1;break;case nr.MEDIUM:A.edgeDetectionThreshold=.1,I.orthogonalSearchSteps=8,I.diagonalDetection=!1,I.cornerDetection=!1;break;case nr.HIGH:A.edgeDetectionThreshold=.1,I.orthogonalSearchSteps=16,I.diagonalSearchSteps=8,I.cornerRounding=25,I.diagonalDetection=!0,I.cornerDetection=!0;break;case nr.ULTRA:A.edgeDetectionThreshold=.05,I.orthogonalSearchSteps=32,I.diagonalSearchSteps=16,I.cornerRounding=25,I.diagonalDetection=!0,I.cornerDetection=!0;break}}setDepthTexture(g,A=UB){this.edgeDetectionMaterial.depthBuffer=g,this.edgeDetectionMaterial.depthPacking=A}update(g,A,I){this.clearPass.render(g,this.renderTargetEdges),this.edgeDetectionPass.render(g,A,this.renderTargetEdges),this.weightsPass.render(g,this.renderTargetEdges,this.renderTargetWeights)}setSize(g,A){this.edgeDetectionMaterial.setSize(g,A),this.weightsMaterial.setSize(g,A),this.renderTargetEdges.setSize(g,A),this.renderTargetWeights.setSize(g,A)}dispose(){let{searchTexture:g,areaTexture:A}=this.weightsMaterial;g!==null&&A!==null&&(g.dispose(),A.dispose()),super.dispose()}static get searchImageDataURL(){return mm}static get areaImageDataURL(){return Um}},S6=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; +#if VIGNETTE_TECHNIQUE == 0 +float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); +#else +vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); +#endif +outputColor=vec4(color,inputColor.a);}`,vl={DEFAULT:0,ESKIL:1},f6=class extends Ko{constructor({blendFunction:A=UI.NORMAL,technique:I=vl.DEFAULT,eskil:e=!1,offset:i=.5,darkness:t=.5}={}){super("VignetteEffect",S6,{blendFunction:A,defines:new Map([["VIGNETTE_TECHNIQUE",I.toFixed(0)]]),uniforms:new Map([["offset",new ZA(i)],["darkness",new ZA(t)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(A){this.technique!==A&&(this.defines.set("VIGNETTE_TECHNIQUE",A.toFixed(0)),this.setChanged())}get eskil(){return this.technique===vl.ESKIL}set eskil(A){this.technique=A?vl.ESKIL:vl.DEFAULT}getTechnique(){return this.technique}setTechnique(A){this.technique=A}get offset(){return this.uniforms.get("offset").value}set offset(A){this.uniforms.get("offset").value=A}getOffset(){return this.offset}setOffset(A){this.offset=A}get darkness(){return this.uniforms.get("darkness").value}set darkness(A){this.uniforms.get("darkness").value=A}getDarkness(){return this.darkness}setDarkness(A){this.darkness=A}},NB=class{constructor(A,I){this.enabled=!1,this.effect=new A(I),Object.defineProperty(this,"opacity",{enumerable:!0,set(e){this.effect.blendMode.opacity.value=e},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(e){this.effect.blendMode.setBlendFunction(Number(e))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=UI.NORMAL}},G6=class extends NB{constructor(){super(C6),this.blendFunction=UI.SCREEN}set intensity(g){this.effect.intensity=g}get intensity(){return this.effect.intensity}set luminanceThreshold(g){this.effect.luminanceMaterial.threshold=g}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(g){this.effect.luminanceMaterial.smoothing=g}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(g){this.effect.blurPass.scale=g}get blurScale(){return this.effect.blurPass.scale}set kernelSize(g){this.effect.blurPass.kernelSize=g}get kernelSize(){return this.effect.blurPass.kernelSize}},k6=class extends NB{constructor(){super(B6)}set contrast(g){this.effect.uniforms.get("contrast").value=g}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(g){this.effect.uniforms.get("brightness").value=g}get brightness(){return this.effect.uniforms.get("brightness").value}},M6=class extends NB{constructor(){super(E6),this.effect.offset=new sA(.01,.01)}set offset(g){this.effect.offset.set(g[0]/1e3,g[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}},m6=class extends NB{constructor(){super(r6)}},U6=class extends NB{constructor(){super(c6),this._hue=0}set hue(g){this._hue=g,this.effect.setHue(g)}get hue(){return this._hue}set saturation(g){this.effect.uniforms.get("saturation").value=g}get saturation(){return this.effect.uniforms.get("saturation").value}},N6=class extends NB{constructor(){super(d6),this.blendFunction=UI.OVERLAY}},F6=class extends NB{constructor(){super(f6)}get eskil(){return this.effect.eskil}set eskil(g){this.effect.eskil=g}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(g){this.effect.uniforms.get("darkness").value=g}get offset(){return this.effect.uniforms.get("offset").value}set offset(g){this.effect.uniforms.get("offset").value=g}},R6=class extends NB{constructor(g){super(h6,g)}set focalLength(g){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=g}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(g){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=g}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(g){this.effect.bokehScale=g}},K6=class extends NB{constructor(){super(p6)}get granularity(){return this.effect.getGranularity()}set granularity(g){this.effect.setGranularity(g)}},J6=`#define GLSLIFY 1 +varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`,v6=`#define GLSLIFY 1 +#include +varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution; +#define USE_YCOCG +#define USE_CATMULL_ROM +const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){ +#ifdef USE_YCOCG +vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a); +#else +return texture(tex,uv); +#endif +}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){ +#ifdef CHOOSE_LONGEST_MOTION_VECTOR +float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose; +#else +float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv); +#ifdef USE_CATMULL_ROM +vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution); +#else +vec4 previousColor=sample_color(historyBuffer,previousPixelPos); +#endif +#ifdef USE_YCOCG +previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a); +#endif +vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5); +#ifdef USE_YCOCG +vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center; +#endif +vec4 previousColorClipped=clamp(previousColor,cmin,cmax); +#ifdef LUMINANCE_DIFFERENCES +#ifdef USE_YCOCG +float lum0=currentColor.r;float lum1=previousColorClipped.r; +#else +float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb); +#endif +float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback)); +#else +const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha); +#endif +#ifdef USE_YCOCG +gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a); +#else +gl_FragColor=result; +#endif +}`,q6=`#define GLSLIFY 1 +varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`,L6=`#define GLSLIFY 1 +layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`,ow=class extends te{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new ZA(null)},blending:je,depthWrite:!1,depthTest:!1,vertexShader:q6,fragmentShader:L6})}set inputBuffer(g){this.uniforms.inputBuffer.value=g}},b6=class extends gt{constructor(){super("TAAResolvePass"),this.MRTCompatible=!0,this.needsSwap=!1,this.passThroughMaterial=new ow,this.resolutionVector=new sA,this.resolveMaterial=new te({name:"TAAResolveMaterial",uniforms:{inputBuffer:new ZA(null),historyBuffer:new ZA(null),velocityBuffer:new ZA(null),depthBuffer:new ZA(null),resolution:new ZA(new sA)},blending:je,depthWrite:!1,depthTest:!1,vertexShader:J6,fragmentShader:v6}),this.historyRenderTarget=new WI(1024,1024,{minFilter:cI,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new WI(1024,1024,{minFilter:cI,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(g,A){this.historyRenderTarget.setSize(g,A),this.resultRenderTarget.setSize(g,A)}render(g,A){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=A.texture[0],this.resolveMaterial.uniforms.velocityBuffer.value=A.texture[1],this.resolveMaterial.uniforms.depthBuffer.value=A.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(A.width,A.height),g.setRenderTarget(this.resultRenderTarget),g.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,g.setRenderTarget(this.historyRenderTarget),g.render(this.scene,this.camera);let I=this.renderToScreen?null:A;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,g.setRenderTarget(I),g.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}},Y6=class extends gt{constructor(g,A,I){super("TransmissionPass",void 0,A),this.MRTCompatible=!0,this.depthPass=new km(g,A,{renderTarget:I.transmissionDepthTarget}),this.passThroughMaterial=new ow,this.splineScene=g,this.needsSwap=!1}updatePasses(g){this.passThroughMaterial=new ow,this.depthPass=new km(this.splineScene,this.camera,{renderTarget:g.transmissionDepthTarget})}setCamera(g){this.camera=g}setScene(g){this.splineScene=g}render(g,A,I){let e=this.camera.layers.mask,i=g;i.setRenderTarget(i.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=A.texture[0],i.clear(),i.render(this.scene,this.camera),this.camera.layers.disable(3),this.depthPass.render(g,A,I),i.shadowMap.needsUpdate=!1,i.shadowMap.autoUpdate=!1;let t=this.renderToScreen?null:A;this.camera.layers.set(3),g.setRenderTarget(t),g.render(this.splineScene,this.camera),this.camera.layers.mask=e}},Nm=new ca,x6=new te({transparent:!0,vertexShader:` + void main() { + gl_Position = vec4(0.0); + } + `,fragmentShader:` + layout(location = 1) out vec4 gVelocity; + + void main() { + gl_FragColor = vec4(0.0); + gVelocity = vec4(0.0); + } + `}),Bw=class extends gt{constructor(g,A,I){super("OpaquePass",A??Nm,I),this.MRTCompatible=!0,this.hasTransmissionPass=!1,this.clear=!0,this.clearColorOnly=!1,this.clearDepth=!1,this.needsSwap=!1,this.originalMaterials=new Map,this.MRTCompatible=g}setCamera(g){this.camera=g}setScene(g){this.scene=g??Nm}getScene(){return this.scene}render(g,A){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.clear(),this.scene.traverse(e=>{e.layers.isEnabled(3)&&e instanceof Dt&&(this.originalMaterials.set(e.id,e.material),e.material=x6)}),g.shadowMap.needsUpdate=!0,g.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let I=this.renderToScreen?null:A;g.setRenderTarget(I),this.clearColorOnly&&g.clear(!0,!1,!0),this.clear&&g.clear(),g.render(this.scene,this.camera),this.clearDepth&&g.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach((e,i)=>{let t=this.scene.getObjectById(i);t&&(t.material=e)})}},H6=class{constructor(g,{depthBuffer:A=!0,stencilBuffer:I=!1,multisampling:e=0,frameBufferType:i=0}={}){this.renderer=g,this.helperStartIndex=0,this.copyPass=new Cw,this.depthTexture=null,this.timer=new i6,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(A,I,i,e,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(A,I,i,e,!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(A,I,i,e,!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(g)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(g){let A=this.inputBuffer,I=this.multisampling;I>0&&g>0?(this.inputBuffer.samples=g,this.outputBuffer.samples=g,this.inputBuffer.dispose(),this.outputBuffer.dispose()):I!==g&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(A.depthBuffer,A.stencilBuffer,A.texture.type,g,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(g){var A;if(this.renderer=g,g!==null){let I=g.getSize(new sA),e=((A=g.getContext().getContextAttributes())==null?void 0:A.alpha)??!1,i=this.inputBuffer.texture[0].type;i===vi&&g.outputEncoding===sI&&(this.inputBuffer.texture[0].encoding=sI,this.outputBuffer.texture[0].encoding=sI,this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("doing some kinda dispose??")),g.autoClear=!1,this.setSize(I.width,I.height,!1);for(let t of this.passes)t.initialize(g,e,i)}}replaceRenderer(g,A=!0){let I=this.renderer,e=I.domElement.parentNode;return this.setRenderer(g),A&&e!==null&&(e.removeChild(I.domElement),e.appendChild(g.domElement)),I}createDepthTexture(){let g=this.depthTexture=new kQ(this._width,this._height);return this.inputBuffer.depthTexture=g,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(g.format=Fr,g.type=wr):g.type=oa,g}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let g of this.passes)g.setDepthTexture(null)}}createBuffer(g,A,I,e,i,t){let C=this.renderer,o=C===null?new sA:C.getDrawingBufferSize(new sA),B={minFilter:cI,magFilter:cI,wrapS:Ke,wrapT:Ke,stencilBuffer:A,depthBuffer:g},a;return e>0?(a=new WI(o.width,o.height,B),a.samples=e):(i?(a=new LL(o.width,o.height,2,B),a.texture[1].type=fQ):a=new WI(o.width,o.height,B),a.depthTexture=new kQ(2048,2048),a.depthTexture.type=Rt),I===vi&&C!==null&&C.outputEncoding===sI&&(Array.isArray(a.texture)?a.texture.forEach(s=>s.encoding=sI):a.texture.encoding=sI),Array.isArray(a.texture)?a.texture.forEach((s,r)=>{s.name=`EffectComposer.Buffer ${i} ${r}`,s.generateMipmaps=!1}):(a.texture.name=`EffectComposer.Buffer ${i}`,a.texture.generateMipmaps=!1),a.name=t,a}addPass(g,A){var o;let I=this.passes,e=this.renderer,i=e.getDrawingBufferSize(new sA),t=((o=e.getContext().getContextAttributes())==null?void 0:o.alpha)??!1,C;if(g.MRTCompatible&&(C=this.inputBuffer.texture[0].type),g.MRTCompatible||(C=this.inputBuffer.texture.type),g.setRenderer(e),g.setSize(i.width,i.height),g.initialize(e,t,C),this.autoRenderToScreen&&(I.length>0&&(I[I.length-1].renderToScreen=!1),g.renderToScreen&&(this.autoRenderToScreen=!1)),A!==void 0?I.splice(A,0,g):I.push(g),this.autoRenderToScreen&&(I[I.length-1].renderToScreen=!0),g.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let B=this.createDepthTexture();for(g of I)g.setDepthTexture(B)}else g.setDepthTexture(this.depthTexture)}setHelperStartIndex(g){this.helperStartIndex=g}removePass(g){let A=this.passes,I=A.indexOf(g);if(I!==-1&&A.splice(I,1).length>0){if(this.depthTexture!==null){let e=(i,t)=>i||t.needsDepthTexture;A.reduce(e,!1)||(g.getDepthTexture()===this.depthTexture&&g.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&I===A.length&&(g.renderToScreen=!1,A.length>0&&(A[A.length-1].renderToScreen=!0))}}removeAllPasses(){let g=this.passes;this.deleteDepthTexture(),g.length>0&&(this.autoRenderToScreen&&(g[g.length-1].renderToScreen=!1),this.passes=[])}render(g){let A=this.renderer,I=this.copyPass,e=this.inputBuffer,i=this.outputBuffer,t=this.inputBufferSingle,C=this.outputBufferSingle,o=!1,B,a,s,r;g===void 0&&(g=this.timer.update().getDelta());for(let Q of this.passes)Q.enabled&&(Q.MRTCompatible?Q.render(A,e,i,g,o):Q.render(A,t,C,g,o),Q.needsSwap&&(o&&(I.renderToScreen=Q.renderToScreen,B=A.getContext(),a=A.state.buffers.stencil,a.setFunc(B.NOTEQUAL,1,4294967295),I.render(A,e,i,g,o),a.setFunc(B.EQUAL,1,4294967295)),s=e,r=t,e=i,t=C,i=s,C=r),Q instanceof I6?o=!0:Q instanceof N9&&(o=!1))}setSize(g,A,I){let e=this.renderer;if(this._width=g,this._height=A,g===void 0||A===void 0){let t=e.getSize(new sA);g=t.width,A=t.height}e.setSize(g,A,I);let i=e.getDrawingBufferSize(new sA);this.inputBuffer.setSize(i.width,i.height),this.outputBuffer.setSize(i.width,i.height),this.inputBufferSingle.setSize(i.width,i.height),this.outputBufferSingle.setSize(i.width,i.height);for(let t of this.passes)t.setSize(i.width,i.height)}reset(){let g=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(g)}dispose(){for(let g of this.passes)g.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()}},T6=new te({name:"CombineMaterial",uniforms:{inputBufferA:new ZA(null),inputBufferB:new ZA(null)},blending:je,depthWrite:!1,depthTest:!1,vertexShader:` +varying vec2 vUv; +void main() { + gl_Position = vec4(position.xy, 1.0, 1.0); + vUv = position.xy * 0.5 + 0.5; +} +`,fragmentShader:` + varying vec2 vUv; + uniform sampler2D inputBufferA; + uniform sampler2D inputBufferB; + + // TODO: Why do we need these when postpro of framemode is enabled??? + layout(location = 1) out vec4 gVelocity; + + void main() { + vec4 resA = texture2D(inputBufferA, vUv); + vec4 resB = texture2D(inputBufferB, vUv); + float a = resA.a + resB.a * ( 1.0 - resA.a ); + + vec4 res; + res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a)); + res.a = resA.a + resB.a * (1.0 - resA.a); + gl_FragColor = res; + gVelocity = vec4(0.0); + } +`}),O6=class extends gt{constructor(g){super("HelperPass",void 0,g),this.MRTCompatible=!1,this.fullscreenMaterial=T6,this.helperPass=new Bw(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new Bw(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let A=new eJ({preset:nr.LOW,edgeDetectionMode:$D.COLOR});this.effectPass=new eD(this.camera,A),this.rt=new WI(10,10,{minFilter:cI,magFilter:cI,wrapS:Ke,wrapT:Ke,depthBuffer:!0})}setSize(g,A){this.rt.setSize(g,A),this.effectPass.setSize(g,A)}set sceneHelpers(g){this.helperPass.setScene(g)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(g){this.helperPassOnTop.setScene(g)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(g){this.helperPass.setCamera(g),this.helperPassOnTop.setCamera(g)}initialize(g,A,I){super.initialize(g,A,I),this.effectPass.initialize(g,A,I)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(g,A,I){this.rt.depthTexture=A.depthTexture;let e=g.getClearAlpha();g.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(g,this.rt),this.helperPassOnTop.render(g,this.rt),this.effectPass.renderToScreen=!1,this.effectPass.render(g,this.rt,I),this.fullscreenMaterial.uniforms.inputBufferA.value=I.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=A.texture,g.setClearAlpha(e),g.setRenderTarget(null),g.clear(),g.render(this.scene,this.camera)}},_6=`#define GLSLIFY 1 +#include +out vec3 n;void main(){ +#include +#include +#include +#include +#include +#include +vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`,P6=`#define GLSLIFY 1 +in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`,j6=`#define GLSLIFY 1 +out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`,W6=`#define GLSLIFY 1 +in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`,Z6=`#define GLSLIFY 1 +out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`,V6=`#define GLSLIFY 1 +in vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){ +#ifdef DEBUG +float d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0); +#else +vec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao; +#endif +}`,YE=[[.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]],z6=new te({vertexShader:_6,fragmentShader:P6}),ql=new te({vertexShader:Z6,fragmentShader:V6,uniforms:{texture_ao_lrez:new ZA(null),texture_depth_lrez:new ZA(null),texture_depth_hrez:new ZA(null),near:new ZA(null),far:new ZA(null)}}),X6=class extends gt{constructor(g,A){super("AmbientOcclusionPass",void 0,A),this.fogEnabled=!1,this.fogNear=1,this.fogFar=1e3,this.frameIndex=0,this._runHalfRes=!0,this._width=1,this._height=1;let I=1024,e=1024;this.gBuffer=new WI(I,e,{type:Rt,depthTexture:new kQ(I,e),minFilter:cI,magFilter:cI}),this.depthBufferHighRes=new WI(I,e,{depthTexture:new kQ(I,e)}),this.aoBuffer=new WI(I,e,{minFilter:cI,magFilter:cI}),this.splineScene=g,this.splineCamera=A;let i=new Float32Array(YE.length*2);for(let C=0;C with size +float rectangle(vec2 st, vec2 size) { + size = vec2(0.5) - size * 0.5; + vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y)); + uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y)); + + return uv.x * uv.y; +} + +uniform vec2 uSize; +uniform float uScale; +uniform float uDPR; +uniform float uCurrent; +uniform vec3 uSceneColor; + +void main() { + vec2 screenUv = gl_FragCoord.xy / uResolution.xy; + screenUv *= 1.0 / uDPR; + + vec2 center = vec2(0.5, -0.5); + vec2 outsideUv = screenUv; + outsideUv += center; + outsideUv -= uCoords.xy / uResolution.xy; + outsideUv = (outsideUv - 0.5) + 0.5; + outsideUv -= center; + vec2 s = (uSize / uResolution) * uScale; + float isOutside = 1.0 - rectangle(outsideUv, s); + + vec2 mid = vec2(0.5); + vec2 insideUv = (screenUv - mid + s * mid) / s; + vec4 background = texture2D(tInput, screenUv); + vec4 image = texture2D(tMap, insideUv); + gl_FragColor = mix(image, background, isOutside); +} +`,g7=class extends Eo{constructor(){super(new te({vertexShader:$6,fragmentShader:A7,uniforms:{tInput:new ZA(null),tMap:new ZA(null),uResolution:new ZA(new sA),uSize:new ZA(new sA),uCoords:new ZA(new sA),uScale:new ZA(1),uSceneColor:new ZA(new Og(16711680)),uDPR:new ZA(1),uCurrent:new ZA(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(g){this.uniforms.tMap.value=g}},I7=` +void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`,e7=` +uniform sampler2D toScene; +uniform sampler2D fromScene; +uniform vec2 resolution; + +uniform vec2 uResolution; +uniform float uDPR; + +uniform float mixRatio; +uniform sampler2D tMixTexture; +uniform int useTexture; +uniform float threshold; + +void main() { + vec2 screenUv = gl_FragCoord.xy / uResolution.xy; + screenUv *= 1.0 / uDPR; + + vec4 texel1 = texture2D( fromScene, screenUv ); + vec4 texel2 = texture2D( toScene, screenUv ); + + if (useTexture==1) { + + vec4 transitionTexel = texture2D( tMixTexture, screenUv ); + float r = mixRatio * (1.0 + threshold * 2.0) - threshold; + float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0); + + gl_FragColor = mix( texel1, texel2, mixf ); + } else { + + gl_FragColor = mix( texel1, texel2, mixRatio ); + + } +} +`,i7=[],t7=class extends Eo{constructor(){super(new te({vertexShader:I7,fragmentShader:e7,uniforms:{toScene:new ZA(null),fromScene:new ZA(null),uResolution:new ZA(new sA),uDPR:new ZA(1),mixRatio:new ZA(0),threshold:new ZA(.1),useTexture:new ZA(0),tMixTexture:{value:i7[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(g){this.uniforms.fromScene.value=g}};function Fm(g,A){return A&&A.enabled&&g.push(A.effect),g}var C7=g=>Object.values(UI).includes(g)?g:UI.NORMAL,o7=class extends Si{constructor(g){super(),this.postprocessingState=Oc.defaultData,this._scene=new ca,this._camera=new Ji,this.effects=new Map,this.blueNoiseTexture=new dc,this._renderToScreen=!0,this.clock=new k1,this.renderer=g,this.debug=!1,this.effects.set("bloom",new G6),this.effects.set("chromaticAberration",new M6),this.effects.set("vignette",new F6),this.effects.set("noise",new N6),this.effects.set("colorAverage",new m6),this.effects.set("hueSaturation",new U6),this.effects.set("brightnessContrast",new k6),this.effects.set("depthOfField",new R6),this.effects.set("pixelation",new K6),this.effectComposer=new H6(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Bw(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new Y6(this.scene,this.camera,this.renderer),this.aoPass=new X6(this.scene,this.camera),this.taaPass=new b6,this.taaPass.renderToScreen=!1,this.helperPass=new O6(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new g7,this.overlayPass.enabled=!1,this.sceneTransitionPass=new t7,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(g){g!==void 0?(this.overlayPass.texture=g,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(g){this.helperPass.sceneHelpers=g}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(g){this.helperPass.sceneHelpersOnTop=g}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(g){this._scene=g,this.opaquePass.setScene(g),this.transmissionPass.setScene(g),this.aoPass.setScene(g)}get camera(){return this._camera}set camera(g){this._camera=g,this.opaquePass.setCamera(g),this.transmissionPass.setCamera(g),this.aoPass.setCamera(g),this.helperPass.setCamera(g)}updateRenderToScreen(){let g=!1;for(let A=this.effectComposer.passes.length-1;A>=0;A--){let I=this.effectComposer.passes[A];if(I.enabled===!0&&!g&&this._renderToScreen){I.renderToScreen=!0,g=!0;continue}I.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(g){this.blueNoiseTexture=new dc(g,128,128),this.blueNoiseTexture.wrapS=hB,this.blueNoiseTexture.wrapT=hB,this.blueNoiseTexture.minFilter=ie,this.blueNoiseTexture.magFilter=ie,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(g,A,I,e,i,t,C,o){this.aoPass.enabled=g,this.aoPass.radius=A,this.aoPass.bias=I,this.aoPass.aoColor=e,this.aoPass.fogEnabled=i,this.aoPass.fogNear=t,this.aoPass.fogFar=C,this.aoPass.runHalfRes!==!o&&(this.aoPass.runHalfRes=!o)}setTransmissionPassEnabled(g){this.transmissionPass.enabled=g,this.opaquePass.hasTransmissionPass=g}_initPasses(){var g,A;if((g=this.uvEffectPass)==null||g.dispose(),(A=this.effectPass)==null||A.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 I=[this.effects.get("pixelation")].reduce(Fm,[]);I.length>0&&(this.uvEffectPass=new eD(this.camera,...I),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let e=[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(Fm,[]);e.length>0&&(this.effectPass=new eD(this.camera,...e),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 g=new sA;this.renderer.getDrawingBufferSize(g),this._rt=new WI(g.x,g.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:hB,wrapT:hB}),this._rt.samples=0,this._savePass=new Cw(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(g){this._rt=g,this._savePass=new Cw(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(g){if(this._renderToScreen===g)return;let A=this.effectComposer;!A||(g===!0?A.removePass(this._savePass):A.addPass(this._savePass),this._renderToScreen=g,this.updateRenderToScreen())}set sceneTransitionFromTexture(g){g!==this.sceneTransitionPass.texture&&(g!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=g)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(g){let{enabled:A,...I}=g,e=!1;A!==this.postprocessingState.enabled&&(e=!0);for(let i of Object.entries(I)){let t=i[1],C=this.effects.get(i[0]);if(C){C.enabled!==t.enabled&&(e=!0),C.enabled=t.enabled;for(let[o,B]of Object.entries(t))o==="blendFunction"?C.blendFunction=C7(B):C[o]=B}}this.postprocessingState=g,e&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(g,A,I,e){g instanceof EI?(this.effectComposer.inputBuffer.scissor.set(g.x,g.y,g.z,g.w),this.effectComposer.outputBuffer.scissor.set(g.x,g.y,g.z,g.w)):(this.effectComposer.inputBuffer.scissor.set(g,A,I,e),this.effectComposer.outputBuffer.scissor.set(g,A,I,e));let i=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(i),this.effectComposer.outputBuffer.scissor.multiplyScalar(i),this.renderer.setScissor(g,A,I,e)}setScissorTest(g){this.effectComposer.inputBuffer.scissorTest=g,this.effectComposer.outputBuffer.scissorTest=g,this.renderer.setScissorTest(g)}setViewport(g,A,I,e){g instanceof EI?(this.effectComposer.inputBuffer.viewport.copy(g),this.effectComposer.outputBuffer.viewport.copy(g)):(this.effectComposer.inputBuffer.viewport.set(g,A,I,e),this.effectComposer.outputBuffer.viewport.set(g,A,I,e))}resize(g,A,I){if(this.effectComposer.setSize(g,A,I),this._rt){let e=this.renderer.getPixelRatio();this._rt.setSize(g*e,A*e)}}dispose(){var g,A;(g=this.uvEffectPass)==null||g.dispose(),(A=this.effectPass)==null||A.dispose(),this.effectComposer.dispose()}},B7=g=>` + +// PCSS implementation based on: +// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/ +// NOTE: This number affects how big the shadow blur can +// possibly get. Bigger number == bigger blur, but less precise results + +const float gPenumbraFilterSize = 80.0; +const int gPenumbraSamples = ${g}; +const int gShadowSamples = ${g}; +const float gShadowSamplesRpc = 1.0f / float(gShadowSamples); + +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + + #endif + + #if NUM_SPOT_LIGHT_SHADOWS > 0 + + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ]; + + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + + #endif + + #if NUM_POINT_LIGHT_SHADOWS > 0 + + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + + #endif + + /* + #if NUM_RECT_AREA_LIGHTS > 0 + + // TODO (abelnation): create uniforms for area light shadows + + #endif + */ + +float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius) +{ + float penumbra = 1.0; + float blockerDepthAvg = 0.0; + float blockerCount = 0.0; + + #pragma unroll_loop_start + for(int i = 0; i < gPenumbraSamples; i ++) + { + vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar; + float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ); + + if(depth < compare + 0.0001) + { + blockerDepthAvg += depth; + blockerCount++; + } + } + #pragma unroll_loop_end + + if (blockerCount > 0.0) + { + blockerDepthAvg /= blockerCount; + + // Compute penumbra + penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg); + penumbra *= penumbra; + penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows + + return clamp(penumbra, 0.00, 1.0); + } + return 0.0; +} + +float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius) +{ + float shadow = 0.0f; + + // NOTE: When using TAA, we should use screen space interleaved gradient noise + vec2 halton = haltonSequence[frameIndex]; + float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); + float temporalAngle = temporalOffset * PI2; + + float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.); + float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius); + if (penumbra == -1.0) { + return 1.0; + } + + #pragma unroll_loop_start + for (int i = 0; i < gShadowSamples; i++) + { + vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; + // Overall blurring offset + vec2 offset = vogelSample * (shadowRadius * 2.); + + // Penumbra offset + offset += vogelSample * (penumbra * texelScalar); + + shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) ); + } + #pragma unroll_loop_end + + return shadow * gShadowSamplesRpc; +} + + + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + + } + + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + + } + + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + + float occlusion = 1.0; + + vec2 distribution = texture2DDistribution( shadow, uv ); + + float hard_shadow = step( compare , distribution.x ); // Hard Shadow + + if (hard_shadow != 1.0 ) { + + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality + softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed + occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + + } + return occlusion; + + } + + float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + + float shadow = 1.0; + + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + + // if ( something && something ) breaks ATI OpenGL shader compiler + // if ( all( something, something ) ) using this instead + + bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); + bool inFrustum = all( inFrustumVec ); + + bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); + + bool frustumTest = all( frustumTestVec ); + + if ( frustumTest ) { + + #if defined( SHADOWMAP_TYPE_PCF ) + + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius ); + + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + + #elif defined( SHADOWMAP_TYPE_VSM ) + + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + + #else // no percentage-closer filtering: + + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + + #endif + + } + + return shadow; + + } + + // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D + // vector suitable for 2D texture mapping. This code uses the following layout for the + // 2D texture: + // + // xzXZ + // y Y + // + // Y - Positive y direction + // y - Negative y direction + // X - Positive x direction + // x - Negative x direction + // Z - Positive z direction + // z - Negative z direction + // + // Source and test bed: + // https://gist.github.com/tschw/da10c43c467ce8afd0c4 + + vec2 cubeToUV( vec3 v, float texelSizeY ) { + + // Number of texels to avoid at the edge of each square + + vec3 absV = abs( v ); + + // Intersect unit cube + + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + + // Apply scale to avoid seams + + // two texels less per square (one texel will do for NEAREST) + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + + // Unwrap + + // space: -1 ... 1 range for each square + // + // #X## dim := ( 4 , 2 ) + // # # center := ( 1 , 1 ) + + vec2 planar = v.xy; + + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + + if ( absV.z >= almostOne ) { + + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + + } else if ( absV.x >= almostOne ) { + + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + + } else if ( absV.y >= almostOne ) { + + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + + } + + // Transform to UV space + + // scale := 0.5 / dim + // translate := ( center + 0.5 ) / dim + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + + } + + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + + float shadow = 1.0; + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + + // for point lights, the uniform @vShadowCoord is re-purposed to hold + // the vector from the light to the world-space position of the fragment. + vec3 lightToPosition = shadowCoord.xyz; + + // dp = normalized distance from light to fragment position + float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp? + compare += shadowBias; + + // bd3D = base direction 3D + vec3 bd3D = normalize( lightToPosition ); + + vec2 halton = haltonSequence[frameIndex]; + float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); + float temporalAngle = temporalOffset * PI2; + + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) + for (int i = 0; i < gShadowSamples; i++) { + vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; + + // Overall blurring offset + vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); + + // NOTE: Removed for now + // Penumbra offset + //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize); + + shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); + + } + return shadow * gShadowSamplesRpc; + + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + for (int i = 0; i < 16; i++) { + vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; + + // Overall blurring offset + vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); + + shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); + + } + return shadow * (1.0 / 16.0); + #else // no percentage-closer filtering + + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare ); + + #endif + + } + +#endif +`,a7=nI.lights_fragment_begin,r7=nI.shadowmask_pars_fragment,Rm=null,s7=g=>{switch(g){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Q7=(g="medium")=>{if(Rm===g)return!1;Rm=g;let A=s7(g);nI.shadowmap_pars_fragment=B7(A);let I=a7.slice();I=I.replace("getShadow( spotShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX + 3, spotShadowMap[ i ]"),I=I.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),nI.lights_fragment_begin=I;let e=r7.slice();return e=e.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),nI.shadowmask_pars_fragment=e,!0},E7=` +attribute vec3 randomColor; +varying vec3 vNormal; +flat out vec3 vColor; + +void main() +{ +vNormal = normal; +vColor = randomColor; +gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0)); +} +`,n7=` +uniform float depthContrast; +varying vec3 vNormal; +flat in vec3 vColor; +void main() +{ +vec3 normal = (normalize(vNormal)).rgb; + +float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5; + +vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4); +gl_FragColor = vec4(resultColor, vColor.r); +} +`,tp=new te({vertexShader:E7,fragmentShader:n7,uniforms:{depthContrast:{value:1}}}),Km=new ti,h7=class extends _N{constructor(g){super(g),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new sA,this.pipeline=new o7(this),this.dummyCamra=new Ji,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(i=!0,t=!0,C=!0)=>{let o=this.getContext(),B=0;i&&(B|=o.COLOR_BUFFER_BIT),t&&(B|=o.DEPTH_BUFFER_BIT),C&&(B|=o.STENCIL_BUFFER_BIT),o.clear(B),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let A=this.setPixelRatio.bind(this),I=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Jw;let e=this.getContext();if(e&&"drawingBufferColorSpace"in e)try{e.drawingBufferColorSpace="display-p3"}catch(i){console.warn(i)}this.setPixelRatio=i=>{this._pixelRatio!==i&&(this._pixelRatio=i,A(i))},this.setSize=(i,t,C=!0)=>{var o,B;(this.viewportWidth!==i||this.viewportHeight!==t)&&(this.viewportWidth=i,this.viewportHeight=t,I(i,t,C),(o=this.normalRenderTarget)==null||o.setSize(i*this._pixelRatio,t*this._pixelRatio),this._resizeTransmission(i,t),(B=this.transmissionDepthTarget)==null||B.setSize(i*this._pixelRatio/2,t*this._pixelRatio/2),this.pipeline.resize(i,t,C))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new WI(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:cI,magFilter:cI,wrapS:Ke,wrapT:Ke,depthBuffer:!1}))}_resizeTransmission(g,A){var I,e;(I=this.transmissionRenderTarget)==null||I.setSize(g*this._pixelRatio/(this.hdTransmission?1:2),A*this._pixelRatio/(this.hdTransmission?1:2)),(e=this.aoRenderTarget)==null||e.setSize(g*this._pixelRatio/1,A*this._pixelRatio/1)}get hdTransmission(){return Tg.transmissionLod.value===1}set hdTransmission(g){Tg.transmissionLod.value=g===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new WI(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:SQ,magFilter:cI,wrapS:Ke,wrapT:Ke,depthBuffer:!1}),this.transmissionDepthTarget=new WI(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:ie,magFilter:ie,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new WI(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:ie,magFilter:ie,type:Rt,depthTexture:new kQ(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(g,A,I){this.normalRenderTarget&&(this.setClearColor(0),I.layers.enable(8),I.layers.disable(0),I.layers.disable(3),A.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),I instanceof Ji?tp.uniforms.depthContrast.value=(I.far-I.near)/1e4:tp.uniforms.depthContrast.value=1,A.overrideMaterial=tp,this.render(A,I),this.setClearColor(A.bgColor,A.bgColor.a),this.setRenderTarget(null),A.overrideMaterial=g.wireframeState?sw:null,I.layers.enable(0),I.layers.enable(3),A.traverseEntity(e=>{e.layers.isEnabled(8)&&(e.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(g,A,I=1){this.dummyCamra.updateCameraState(A.dataPatched);let e=A.height,i=A.width,t=this.viewportWidth/this.viewportHeight;i{Tg.penumbraSize.value[E]=Q}),Tg.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Tg.resolution.value.set(this.resolution.x,this.resolution.y):Tg.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),t!==void 0?(Tg.normalRenderTarget.value=t,Tg.normalRenderTargetDepth.value=Km):B.needsNormal()&&(this.createNormalRenderTarget(),Tg.normalRenderTarget.value=this.normalRenderTarget.texture,Tg.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(B,C,A));let a=C.data.ao,s=a.occlusion;s&&(this.createAORenderTarget(),Tg.aoRenderTarget.value=this.aoRenderTarget.texture),Tg.aoEnabled.value=s,this.pipeline.setAmbientOcclusionParams(a.occlusion,a.radius,a.bias,C.aoColor,C.fog!==null,C.backupFog.near,C.backupFog.far,a.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let r=!1;if(i!==void 0)Tg.transmissionRenderTarget.value=i,Tg.transmissionRenderTargetDepth.value=Km,this.pipeline.setTransmissionPassEnabled(!1);else{let Q=B.needsTransmission();Q&&(this.transmissionRenderTarget===void 0&&(r=!0),this.createTransmissionRenderTarget(),Tg.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Tg.aspectRatio.value=kz(this.viewportWidth,this.viewportHeight),Tg.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(Q)}A.layers.enable(3),A.layers.enable(8),this.pipeline.sceneHelpers=I,this.pipeline.sceneHelpersOnTop=e,this.pipeline.scene=C,this.pipeline.camera=A,r&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==C.postprocessing&&(this.pipeline.updatePostprocessing(C.postprocessing),!I&&!e&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),C.overrideMaterial=B.wireframeState?sw:null,this.pipeline.render(),Tg.frameIndex.value=(Tg.frameIndex.value+1)%16,A instanceof Ji&&A.copyHistory(),C.visible=o}renderFromSceneForSceneTransitionPass(g,A,I){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(g,A),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=I,this.sceneTransitionTimeRemaining=I,this.pipeline.renderToScreen=!0;let e=this.pipeline.sceneTransitionPass.uniforms;e.uDPR.value=window.devicePixelRatio,e.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){var g,A,I,e,i,t;this._superDispose(),this.pipeline.dispose(),(g=this.aoRenderTarget)==null||g.dispose(),(A=this.transmissionRenderTarget)==null||A.dispose(),(I=this.transmissionDepthTarget)==null||I.dispose(),(e=this.normalRenderTarget)==null||e.dispose(),(t=(i=this.normalRenderTarget)==null?void 0:i.depthTexture)==null||t.dispose()}},iJ=class extends ih(T1){constructor(g,A=15,I=10066329){super(g,A,I),this.object=g,this.added=!1,this.name=`DirectionalLightHelper: ${g.uuid}`}raycast(g,A){th(this.object,iJ.geometryHelper,g,A)}},tJ=class extends ih(H1){constructor(g,A=15,I=6710886){super(g,A,I),this.object=g,this.name=`PointLightHelper: ${g.uuid}`}raycast(g,A){th(this.object,tJ.geometryHelper,g,A)}},aw=class extends ih(x1){constructor(g,A=6710886){super(g,A),this.object=g,this.name=`SpotLightHelper: ${g.uuid}`}raycast(g,A){th(this.object,aw.geometryHelper,g,A)}update(){if(this.object!==void 0){let g=aw._vector,A=this.object.distance?this.object.distance:1e3,I=A*Math.tan(this.object.angle);this.cone.scale.set(I,I,A),g.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(g);let e=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let i=0,t=this.cone.material.length;i{if(A instanceof BE)if(Array.isArray(A.material))for(let I of A.material)I.needsUpdate=!0;else A.material.needsUpdate=!0,A.material.dispose()})}updateShadow(A){A.softShadowQuality!==void 0&&this.isActive&&Q7(A.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(A,I){if(A.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let e=this.scene;e.fog=this.fog}this.fogUseBGColor=A.useBackgroundColor,A.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Vi(A.color,I),this.backupFog.near=A.near,this.backupFog.far=A.far}updateAo(A,I){A.aoColor!==void 0&&(this.aoColor=Vi(A.aoColor,I))}updateByOp(A,I,e,i){super.updateByOp(A,I,e,i);let t=I;AC(A.path,["fog"])?this.updateFog(t.fog,e.shared):AC(A.path,["ao"])?this.updateAo(t.ao,e.shared):AC(A.path,["ambient"])?this.updateAmbientLight(t.ambient,e.shared):AC(A.path,["shadow"])&&this.updateShadow(t.shadow)}updateState(A,I){this.updateState_Entity(A,I),A.backgroundColor!==void 0&&this.setBackgroundColor(Vi(A.backgroundColor,I.shared)),A.fog!==void 0&&this.updateFog(A.fog,I.shared),A.ambient!==void 0&&this.updateAmbientLight(A.ambient,I.shared),A.ao!==void 0&&this.updateAo(A.ao,I.shared),A.shadow!==void 0&&this.updateShadow(A.shadow)}raycast(A,I){super.raycast(A,I)}switchActiveCamera(A){A&&A.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=A,A.objectHelper.visible=!1)}get playCamera(){var A;return((A=this.scene)==null?void 0:A.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 A=0,I=0;this.traverseEntity(e=>{if(!e.visible)return!0;e instanceof oJ&&e.visible&&A<3&&(this.penumbraSizeArrayCache[A]=e.data.penumbraSize,A+=1),e instanceof BJ&&e.visible&&A<5-3&&(this.penumbraSizeArrayCache[3+I]=e.data.penumbraSize,I+=1)})}raycastWithClones(A){let I=[],e=i=>{for(let t of i.children){let C=t.cloner;MI.is(t)&&(t.visible||C!=null&&C.object.data.visible)&&((GC(t)||ew(t)&&this.scene.enableHelpers&&t.objectHelper.visible)&&(A.intersectObject(t,!1,I),rw(t,A,I,!0)),e(t))}};return e(this),I}},c7=class extends j0(w1,tJ){constructor(g,A,I){super(),this.super_Entity(g,A),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let e=this.shadow.camera;e.fov=90,e.aspect=1,e.near=100,e.far=2500;let i=new J(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),t=new J(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z),C=new ve(i,t),o=new Gc(C,new Og(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let g in this.gizmos){let A=this.gizmos[g];if(A instanceof Gc){let I=this.shadow.camera,e=new J(-I.far+this.position.x,-I.far+this.position.y,-I.far+this.position.z),i=new J(I.far+this.position.x,I.far+this.position.y,I.far+this.position.z);A.box.set(e,i),A.updateMatrixWorld(!0)}}}updateMatrixWorld(g){super.updateMatrixWorld(g),this.objectHelper&&this.objectHelper.update()}updateState(g,A){this.updateState_Light(g,A),g.distance!==void 0&&(this.distance=g.distance),g.decay!==void 0&&(this.decay=g.decay),g.shadowRadius!==void 0&&(this.shadow.radius=g.shadowRadius),g.shadowResolution!==void 0&&(this.shadow.mapSize.set(g.shadowResolution,g.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},D7=class extends zi{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(g,A){let I=this.geometry.getAttribute("position");I!==void 0?L0(I,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:I.count,g,A):super.updateEntityBoxSize(g,A)}},V0=class extends zi{constructor(g,A,I){super(g,A,I),this._shapeId=null,this._context=I}updateState(g,A){super.updateState(g,A),this.updateShape()}updateShape(){var e;let g={...this.data.geometry.extrusion.shape};for(let i in g)typeof g[i]=="string"&&(g[i]=this._context.shared.getVariable(g[i],[this.uuid,"geometry","extrusion","shape",i]));let A;if(g.type==="Custom"){let i=g.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let t=this._context.scene.find(i);t!=null&&t.data&&(t.attachedPaths.add(this),A=(e=t.geometry.userData)==null?void 0:e.shape),A||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(g.type){case"Rectangle":i=iK;break;case"Ellipse":i=v0;break;case"Polygon":i=eK;break;case"Star":i=tK;break;default:throw new Error(`Unknown shape type: ${g.type}`)}A=i.create({parameters:g}).userData.shape}let I=this.geometry;A&&I.inputs&&(I.inputs.shapeData=A,I.build(),this.attachedSurfaceCloners.forEach(i=>i.update()))}detachShape(){var g;this._shapeId!==null&&((g=this._context.scene.find(this._shapeId))==null||g.attachedPaths.delete(this))}createGeometryDelayed(g){this.geometryCreateDeleyed=g.shared,this.updateShape(),this.refreshAttachedPaths(g)}updateTransformState(g,A){return super.updateTransformState(g,A)}updateGeometryInteractions(g,A){super.updateGeometryInteractions(g,A),this.updateShape()}updateEntityBoxSize(g,A){let I=this.geometry.getAttribute("position");I!==void 0?L0(I,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:I.count,g,A):super.updateEntityBoxSize(g,A)}},pQ=class extends Ch(gQ,XD){constructor(A,I,e){super(),I.type==="Instance"&&typeof A=="string"&&(I=this.transformAssignData(I,e)),this.super_Entity(A,I),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(A,I){let e=Vc.getComponentData({scene:I.scene.data,shared:I.shared.data},A.component);if(e){let i,t;for(let C of sa.rootOverrideProps)A[C]===void 0?(i===void 0&&(i={...A}),i[C]=e.data[C]):(t===void 0&&(t={}),t[C]=A[C],i===void 0&&(i={...A}),i[C]=Da.apply(e.data[C],A[C]));return this.overrideData=t,i}else return{...Xi.defaultData,...A,...dB(Xi.defaultData,sa.rootOverrideProps)}}updateByOp(A,I,e,i){let t;if(this.isInstanceRoot&&!i){if(I=this.transformAssignData(I,e),A.type===0&&A.path.length===0&&this.component)for(let C of sa.rootOverrideProps)C in A.props&&A.props[C]===void 0&&(t===void 0&&(t={...A,props:{...A.props}}),t.props[C]=this.component.data[C]);else if(A.type===0&&A.path.length>0&&sa.rootOverrideProps.includes(A.path[0])){let C=A.path[0];t===void 0&&(t={...A,path:[],props:{[C]:I[C]}})}}super.updateByOp(t??A,I,e,i)}updateState(A,I){this.updateState_Entity(A,I)}expandInstanceChildren(A){let I=this.data;if(this.component===void 0){let e=A.scene.find(I.component)??null,i=!1;if(e!==this.oldComponent){if(this.oldComponent){let t=0;for(let C of this.children)if(MI.is(C))A.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(C),z0(C),t+=1;else break;this.children.splice(0,t)}i=!0}if(e){let t={};aJ(A,[this.uuid],I.overrides,this,e,e,0,i,t);for(let C of this.children)if(MI.is(C)){let o=C.data;o.type==="Empty"&&o.animations&&C.traverseEntity(B=>{if(B instanceof zi&&B.isSkinnedMesh){let a=B.dataPatched;if(a.bones&&a.boneInverses){let s=a.bones.map(E=>A.scene.find(t[E])),r=a.boneInverses.map(E=>new zA().fromArray(E)),Q=new Ow(s,r);B.bind(Q,B.bindMatrix)}}else B.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function z0(g){if(g.component){let A=g.component.instances.indexOf(g);A>=0&&g.component.instances.splice(A,1);for(let I of g.children)MI.is(I)&&z0(I)}}function Lm(g,A,I,e){return g.component===A&&WF(g.identity,e)?g.overrideData===I?2:1:0}function aJ(g,A,I,e,i,t,C,o,B){if(C>50)return!1;if(e.component!==i){if(e.component){let s=e.component.instances.indexOf(e);s>=0&&e.component.instances.splice(s,1)}i.instances.push(e),e.component=i}i instanceof pQ&&i.isInstanceRoot&&i.expandInstanceChildren(g);let a=0;for(let s of i.children)if(MI.is(s)){let r=[...A,...typeof s.identity=="string"?[s.identity]:s.identity],Q=_c.resolve(I,r,1);Q!=null&&!(Q instanceof Ci)&&(Object.setPrototypeOf(Q,Ci.prototype),console.error("wrong prototype"));let E=null,n;if(!o){let h=e.children[a];if(E=MI.is(h)?h:null,E!==null){let l=Lm(E,s,Q,r);n=l>=1?E.stateSelection:void 0,l!==2&&(E=null)}if(E===null&&(E=g.scene.findInstance(r)??null,E!==null)){let l=Lm(E,s,Q,r);if(n=l>=1?E.stateSelection:void 0,l!==2)E=null;else{let c=E.parent.children.indexOf(E);E.parent.children.splice(c,1),e.children.splice(a,0,E),E.parent===e?c<=a&&console.error("not possible"):(E.parent=e,E.matrixWorldNeedsUpdate=!0,E.resetBBoxNeedsUpdate(),E.updateVisible(),g.pendingDeletes.delete(E))}}}if(E===null){let h=Q?Da.apply(s.data,Q):s.data;Kr.is(h.type)&&(h={...h,type:"Empty"}),E=Qa.createEntity(r,h,g),E.overrideData=Q,e.add(E),e.children.splice(e.children.length-1,1),e.children.splice(a,0,E),E.updateState(E.data,g),n&&E.changeSelectedState(n,g),g.scene.registerInstanceAndSetUuid(E)}if(E.isBone){let h=E.identity[E.identity.length-1];B[h]=E.uuid}a+=1,aJ(g,A,I,E,s,t,C+1,o,B)}if(!o){let s=a;for(;;){let r=e.children[a];if(MI.is(r))g.pendingDeletes.add(r);else break;a+=1}e.children.splice(s,a-s)}return!0}var d7=class extends Ch(jN,XD){constructor(g,A){super(),this.super_Entity(g,A),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(g,A){this.updateState_Entity(g,A)}};function u7(g,A,I){let e;return A.geometry.type==="TextGeometry"?new VK(g,A,I):(A.geometry.type==="SubdivGeometry"?e=new Jn(g,A,I):A.geometry.type==="PathGeometry"?e=new V0(g,A,I):A.geometry.type==="VectorGeometry"?e=new D7(g,A,I):A.geometry.type==="BooleanGeometry"?e=new YQ(g,A,I):e=new zi(g,A,I),e)}function X0(g,A,I){return A.type==="Mesh"?u7(g,A,I):A.type==="Empty"?new vn(g,A):A.type==="Bone"?new d7(g,A):A.type==="Page"?new ya(g,A):A.type==="PointLight"?new c7(g,A,I):A.type==="SpotLight"?new BJ(g,A,I):A.type==="DirectionalLight"?new oJ(g,A,I):A.type==="Component"||A.type==="Instance"?new pQ(g,A,I):Kr.is(A.type)?new Ji(g,A):(console.error(A),new vn(g,A))}Qa.createEntity=X0;function p7(g,A,I){let e=X0(g.identity,A,I),i=g.children,t=g.attachedPaths,C=g.parent,o=g.component,B=g.instances,a=g.overrideData,s=g.uuid,r=g.stateSelection;g.dispose();for(let Q of Object.keys(g))delete g[Q];Object.setPrototypeOf(g,Object.getPrototypeOf(e));for(let Q of Object.keys(e))g[Q]=e[Q];g.children=[...g.children,...i],g.attachedPaths=t,g.parent=C,g.component=o,g.instances=B,g.uuid=s,g.overrideData=a,g.updateState(g.data,I),r&&g.changeSelectedState(r,I),g.resetBBoxNeedsUpdate()}Qa.changeEntityProptotype=p7;Qa.Cloner=UC;function y7(g,A,I,e){g.updateByOp(A,I,e,!1)}function bm(g,A){let I=!1,e=A.getLayersOfType("transmission"),i=A.getLayersOfType("outline");return i.length>0&&(g.layers.set(8),e.length>0&&g.layers.enable(3),I=!0,P0(g),_0(g)),e.length===0&&i.length===0&&g.layers.set(0),g instanceof BE&&g.needsAO&&g.layers.enable(5),I}function Ym(g,A){if(!A.layers)return!1;let I=!1,e=A.getLayersOfType("transmission").filter(t=>t.data.visible),i=A.getLayersOfType("outline").filter(t=>t.data.visible);return e.length>0&&(g.layers.set(3),i.length>0&&g.layers.enable(8),I=!0),e.length===0&&i.length===0&&g.layers.set(0),g.needsAO&&g.layers.enable(5),I}function w7(g){let A=!1;return g.traverseEntity(I=>{if(I instanceof BE)if(Array.isArray(I.material))for(let e=0;e{if(I instanceof BE)if(Array.isArray(I.material))for(let e=0;e0&&I.push({...s[0],object:e?t:g})}}var M7=class{constructor(){this._constraints=new Map}setConstraint(g,A){A===null?this._constraints.delete(g):this._constraints.set(g,A)}removeDependencies(g){this._constraints.delete(g)}applyConstraints(g){let A=new Set;this._constraints.forEach((I,e)=>{let i=[e,I],t=I;for(;this._constraints.has(t);)t=this._constraints.get(t),A.has(t)||i.push(t);for(let C=i.length-2;C>=0;C--)if(!A.has(i[C])){let o=g.find(i[C]);o?o.applyPathSnapping(g):console.warn(`missing entity ${i[C]}`),A.add(i[C])}})}findDependency(g,A){let I=g;for(;this._constraints.has(I);)if(I=this._constraints.get(I),I===A)return!0;return!1}},sw=new Xn;sw.wireframe=!0;var xm=new J,$0=class extends ca{constructor(A,I){super(),this.data=A,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new M7,this.errorPage=new ya("fdasfa",{...vQ.defaultData,name:""}),this.invisibleObjects=new vn("jflkdsafjasdifjaslk",{...Fy.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(A,I),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=S7(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=w7(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(A){let I=A.identity.join("-"),e=this.entityIdentityToEntity[I];e&&(A.uuid=e.uuid),this.entityIdentityToEntity[I]=A,this.entityByUuid[A.uuid]=A}markPenumbraSizeDirty(){for(let A of this.children)A instanceof ya&&(A.penumbraSizeArrayCache=null)}findInstance(A){return this.entityIdentityToEntity[A.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(A){let I=this.find(A);if(I===void 0)return;let e=[],i=I;for(;i!==this;){let t=i;i=i.parent;let C=i.children.indexOf(t);e.splice(0,0,C)}return{entity:I,sortKey:e}}getAllSorted(A){let I=[];for(let e of A){let i=this.getWithSortKey(e.id);i!==void 0&&I.push(i)}return I.sort((e,i)=>hW(e.sortKey,i.sortKey)),I.map(e=>e.entity)}nonExistOrDescendantOf(A,I){let e=this.find(A);if(e===void 0)return!0;for(;e;){if(e.uuid===I)return!0;e=e.parent}return!1}find(A){if(this.activePage&&this.activePage.personalCamera.parent){if(A==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(A===tE)return this.activePage.personalCamera}if(A===""||A===void 0)return;let I=this.entityByUuid[A];return I===void 0?this.getObjectByProperty("uuid",A):I}debugEnsureEntity(A){let I=this.find(A);if(I){if(Array.isArray(I.identity)&&this.findInstance(I.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(A){this.toExpandCloner.add(A)}addPendingUpdateCloner(A){this.toUpdateCloner.add(A)}markToExpandCloner(A){this.toExpandCloner.add(A),A.traverseEntityAncestors(I=>{this.toExpandCloner.add(I)})}doPendingExpandCloner(){this.toExpandCloner.forEach(A=>{A.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(A=>{var I;(I=A.cloner)==null||I.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(A){this.pendingCommands.push(A)}applyPendingCommands(){this.pendingCommands.forEach(A=>A()),this.pendingCommands.length=0}updateByLibOp(A,I){A.path.length===1&&A.path[0]==="components"&&A.type===1&&this.createChildrenObjects([{...A.data.asset,id:A.id}],this.invisibleObjects,I)}updateTreeByOp(A,I){var e;if(A.path.length===0&&A.type===7){let i=A.parent===null?this:this.find(A.parent);if(i===void 0)throw new Error("unexpected");let t=this.createObject(A.id,A.data,A.children,i,A.localIndex,I);t.updateVisible(),t.resetBBoxNeedsUpdate(),GC(t)&&Do(t.parent)&&(t.invalidateUpstreamBooleanData(),t.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(t),this.markToExpandCloner(t),this.markPenumbraSizeDirty()}else if(A.path.length===0&&A.type===8){let i=this.find(A.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let t=i.parent;this.markNeedsRecomputeInstancesForAncessors(t),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Do(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),GC(i)&&(i.freeBooleanPointer(),t instanceof YQ&&t.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof V0&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(A.path.length===0&&A.type===9){let i=this.find(A.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let t=i.parent;this.markNeedsRecomputeInstancesForAncessors(t),(e=i.cloner)==null||e.resetOnMove(),this.markToExpandCloner(i);let C=A.parent===null?this:this.find(A.parent);if(C===void 0)throw new Error("unexpected");C.add(i),this.markNeedsRecomputeInstancesForAncessors(C),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let o=A.localIndex;C.children.splice(o,0,C.children.pop()),GC(i)&&(i.invalidateUpstreamBooleanData(),Do(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():t instanceof YQ&&t.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(A){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let I of this.children)I instanceof ya&&(I.visible=I.uuid===A,I.visible&&(this.activePage=I,this.activePage.onActive(this)))}updateEntityByOp(A,I,e,i){if(I.type===0){if(("overrides"in I.props||"component"in I.props)&&this.markNeedsRecomputeInstances(),"visible"in I.props&&this.markPenumbraSizeDirty(),I.path.includes("overrides")&&"states"in I.props){let{rest:C}=I.props;I={...I,props:C},this.markNeedsRecomputeInstances()}I.path[0]==="pathSnapping"&&I.props.pathId!==void 0&&this.pathConstraints.setConstraint(A,I.props.pathId)}let t=this.find(A);if(t)try{y7(t,I,e,{scene:this,shared:i}),t instanceof zi&&t.updateGeometryGroupsIfNeeded()}catch(C){console.error(C)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(A){this.activePage.switchActiveCamera(A)}isInvisibleObjects(A){return A===this.invisibleObjects||A.hasAnccestor(this.invisibleObjects)}init(A,I){let e=Object.entries(I.data.lib.components).map((i,t)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[0],fi:t}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:I}),this.add(this.invisibleObjects),this.createChildrenObjects(e,this.invisibleObjects,I),this.createChildrenObjects(A.objects,this,I),this.updatePage(A.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(I,!0),this.traverseEntity(i=>{Do(i)&&i.recomputeBoolean(),i instanceof Ji&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(A){A.traverseEntity(I=>{(I.data.type==="Component"||I.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(A){MI.is(A)&&(A.data.type==="Component"&&this.markNeedsRecomputeInstances(),A.traverseAncestors(I=>{MI.is(I)&&I.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(A,I,e,i,t,C,o){if(A){let B=i.find(A);B&&B!==i&&t.forInstancesRec(a=>{a.data=Mn(a.data,s=>{let r=s.events.data(o.id),Q=a.goUp(C);if(Q){let E=[...VF(Q.identity),A].join("-"),n=this.entityIdentityToEntity[E];if(n){let h=n.uuid,l=ji.zoom(r,I);l[e]=h}else console.warn("cannot find instance")}}).data})}}rewriteActions(A,I,e,i,t,C){A.forEach(o=>{o.data.type==="Transition"?this.relativeizeInner(o.data.object,[...I,o.id],"object",e,i,t,C):o.data.type==="Animation"&&this.relativeizeInner(o.data.object,[...I,o.id],"object",e,i,t,C)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(A=>{if(A instanceof pQ&&typeof A.identity=="string"&&A.data.type==="Component")return A.traverseEntity((I,e)=>{I.data.events.forEach(i=>{if(i.data.type==="GameControl"){let t=!1;if(I.forInstancesRec(C=>{C.data=Mn(C.data,o=>{C.isInstanceRoot||(o.events.delete(i.id),t=!0)}).data}),t===!1)for(let C of Wc.list)this.rewriteActions(i.data.gameActions[C],["gameActions",C],A,I,e,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",A,I,e,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",A,I,e,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",A,I,e,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,A,I,e,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,A,I,e,i)),this.rewriteActions(i.data.inActions,["inActions"],A,I,e,i),this.rewriteActions(i.data.outActions,["outActions"],A,I,e,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],A,I,e,i)})}),!0})}expandInstances(A,I,e){let i=new Set;this.traverseEntity(t=>{if(t instanceof pQ&&t.isInstanceRoot)return t.expandInstanceChildren({scene:this,shared:A,pendingDeletes:i}),I||t.resetBBoxNeedsUpdate(),e&&t.traverseEntity(C=>{e.addClip(C)}),!0});for(let t of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(t),z0(t)}recomputeInstances(A,I){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(e=>{e instanceof pQ&&e.isInstanceRoot&&(e.component=void 0)}),this.expandInstances(A,!1,I))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(A){A.traverseEntity(I=>{let e=typeof I.identity=="string"?I.identity:I.identity.join("-");this.entityIdentityToEntity[e]===I&&(delete this.entityByUuid[I.uuid],delete this.entityIdentityToEntity[e]),I.dispose()})}clearScene(){for(let A of this.children)MI.is(A)&&A.disposeRecursively();this.children.length=0}resetAfterClear(A,I){this.init(A,I)}raycast(A){return this.raycast1(A,!1)}raycast1(A,I){let e=[],i=t=>{for(let C of t.children){let o=C.cloner;if(MI.is(C)&&!C.raycastLock&&(C.visible||o!=null&&o.object.data.visible))if(I===!0&&C.isInstanceRoot){let B=[];if(A.intersectObject(C,!0,B),B.length){let a=B[0];a.object=C,a.point.applyMatrix4(a.object.matrixWorld);let s=C.matrixWorld.clone().invert();a.point.applyMatrix4(s),e.push(a)}}else(GC(C)||ew(C)&&this.enableHelpers&&C.objectHelper.visible)&&(A.intersectObject(C,!1,e),rw(C,A,e)),i(C)}};return i(this),e}raycastWithClones(A){let I=[],e=i=>{for(let t of i.children){let C=t.cloner;MI.is(t)&&(t.visible||C!=null&&C.object.data.visible)&&((GC(t)||ew(t)&&this.enableHelpers&&t.objectHelper.visible)&&(A.intersectObject(t,!1,I),rw(t,A,I,!0)),e(t))}};return e(this),I}forEachEntity(A){for(let I of this.children)MI.is(I)&&A(I)}traverseConcreteEntity(A){for(let I of this.children)MI.is(I)&&I.isConcreteEntity&&I.traverseEntity(A)}traverseEntity(A){for(let I of this.children)MI.is(I)&&I.traverseEntity(A)}updateFont(A,I){this.traverseEntity(e=>{if(e instanceof zi&&e.data.type==="Mesh"&&e.data.geometry.type==="TextGeometry"&&e.data.geometry.font===A){let i=e.geometry,t=e.data.geometry;i.updateFont(A,I).then(()=>{i.update(t);let C=e.invalidateDownstreamBooleanData();Do(C)&&C.recomputeBoolean()})}})}traverseObject(A){for(let I of this.children)Kn.is(I)&&I.traverseObject(A)}traverseVisibleEntity(A){for(let I of this.children)MI.is(I)&&I.visible&&I.traverseVisibleEntity(A)}dispose(){this.clearScene()}createChildrenObjects(A,I,e){let i=0;for(let t of A)this.createObject(t.id,t.data,t.children,I,i,e),i+=1}registerObjectCreatedInLegacy(A){this.entityByUuid[A.uuid]=A}unregisterObject(A){delete this.entityByUuid[A.uuid];for(let I of A.children)this.unregisterObject(I)}createObject(A,I,e,i,t,C){var a;let o={scene:this,shared:C},B=X0(A,I,o);return B&&(this.entityByUuid[A]=B,i.add(B),i.children.splice(t,0,i.children.pop()),e.length>0&&(B.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(e,B,C)),B.updateState(I,o),B instanceof zi&&B.updateGeometryGroupsIfNeeded(),B.updateVisible(),B.cloner&&this.toExpandCloner.add(B),(a=I.pathSnapping)!=null&&a.pathId&&this.pathConstraints.setConstraint(A,I.pathSnapping.pathId)),I.type==="Empty"&&I.animations&&B.traverseEntity(s=>{if(s instanceof zi&&s.isSkinnedMesh){let r=s.dataPatched;if(r.bones&&r.boneInverses){let Q=r.bones.map(h=>this.find(h)),E=r.boneInverses.map(h=>new zA().fromArray(h)),n=new Ow(Q,E);s.bind(n,s.bindMatrix)}}else s.matrixAutoUpdate=!0}),B}getCenter(A){let I=[];for(let i=0,t=A.length;i{if(I instanceof Dt)if(Array.isArray(I.material))for(let e=0;e{i instanceof Ji&&i.setViewplaneSize(A,I,e)})}},Ic=(g,A)=>{let I=A.x-g.x,e=A.y-g.y;return Math.sqrt(I*I+e*e)},m7=(g,A)=>{let I=A.x-g.x,e=A.y-g.y;return N7(Math.atan2(e,I))},U7=(g,A,I)=>{let e={x:0,y:0};return I=Qw(I),e.x=g.x-A*Math.cos(I),e.y=g.y-A*Math.sin(I),e},Qw=g=>g*(Math.PI/180),N7=g=>g*(180/Math.PI),F7=g=>isNaN(g.buttons)?g.pressure!==0:g.buttons!==0,Cp=new Map,Hm=g=>{Cp.has(g)&&clearTimeout(Cp.get(g)),Cp.set(g,setTimeout(g,100))},iD=(g,A,I)=>{let e=A.split(/[ ,]+/g),i;for(let t=0;t{let e=A.split(/[ ,]+/g),i;for(let t=0;t(g.preventDefault(),g.type.match(/^touch/)?g.changedTouches:g),Om=()=>{if(typeof window>"u")return;let g=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,A=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:g,y:A}},Ew=(g,A)=>{A.top||A.right||A.bottom||A.left?(g.style.top=A.top,g.style.right=A.right,g.style.bottom=A.bottom,g.style.left=A.left):(g.style.left=A.x+"px",g.style.top=A.y+"px")},AS=(g,A,I)=>{let e=sJ(g);for(let i in e)if(e.hasOwnProperty(i))if(typeof A=="string")e[i]=A+" "+I;else{let t="";for(let C=0,o=A.length;C{let I=sJ(g);for(let e in I)I.hasOwnProperty(e)&&(I[e]=A);return I},sJ=g=>{let A={};return A[g]="",["webkit","Moz","o"].forEach(function(I){A[I+g.charAt(0).toUpperCase()+g.slice(1)]=""}),A},op=(g,A)=>{for(let I in A)A.hasOwnProperty(I)&&(g[I]=A[I]);return g},K7=(g,A)=>{let I={};for(let e in g)g.hasOwnProperty(e)&&A.hasOwnProperty(e)?I[e]=A[e]:g.hasOwnProperty(e)&&(I[e]=g[e]);return I},nw=(g,A)=>{if(g.length)for(let I=0,e=g.length;I({x:Math.min(Math.max(g.x,A.x-I),A.x+I),y:Math.min(Math.max(g.y,A.y-I),A.y+I)});typeof window<"u"&&(QJ="ontouchstart"in window,EJ=!!window.PointerEvent,nJ=!!window.MSPointerEvent);var QJ,EJ,nJ,xE={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"}},CQ,qn={};EJ?CQ=xE.pointer:nJ?CQ=xE.MSPointer:QJ?(CQ=xE.touch,qn=xE.mouse):CQ=xE.mouse;function _r(){}_r.prototype.on=function(g,A){var I=this,e=g.split(/[ ,]+/g),i;I._handlers_=I._handlers_||{};for(var t=0;t=0&&I._handlers_[g].splice(I._handlers_[g].indexOf(A),1),I};_r.prototype.trigger=function(g,A){var I=this,e=g.split(/[ ,]+/g),i;I._handlers_=I._handlers_||{};for(var t=0;tI&&A-I&&A<=I&&!g.lockY?i="left":A>-I*3&&A<=-I&&!g.lockX?i="down":g.lockY||(i="right"),g.lockY||(A>-e&&A0?C="up":C="down"),g.force>this.options.threshold){var o={},B;for(B in this.direction)this.direction.hasOwnProperty(B)&&(o[B]=this.direction[B]);var a={};this.direction={x:t,y:C,angle:i},g.direction=this.direction;for(B in o)o[B]===this.direction[B]&&(a[B]=!0);if(a.x&&a.y&&a.angle)return g;(!a.x||!a.y)&&this.trigger("plain",g),a.x||this.trigger("plain:"+t,g),a.y||this.trigger("plain:"+C,g),a.angle||this.trigger("dir dir:"+i,g)}else this.resetDirection();return g};var v7=ai;function qe(g,A){var I=this;I.nipples=[],I.idles=[],I.actives=[],I.ids=[],I.pressureIntervals={},I.manager=g,I.id=qe.id,qe.id+=1,I.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},I.config(A),(I.options.mode==="static"||I.options.mode==="semi")&&(I.options.multitouch=!1),I.options.multitouch||(I.options.maxNumberOfNipples=1);let e=getComputedStyle(I.options.zone.parentElement);return e&&e.display==="flex"&&(I.parentIsFlex=!0),I.updateBox(),I.prepareNipples(),I.bindings(),I.begin(),I.nipples}qe.prototype=new gS;qe.constructor=qe;qe.id=0;qe.prototype.prepareNipples=function(){var g=this,A=g.nipples;A.on=g.on.bind(g),A.off=g.off.bind(g),A.options=g.options,A.destroy=g.destroy.bind(g),A.ids=g.ids,A.id=g.id,A.processOnMove=g.processOnMove.bind(g),A.processOnEnd=g.processOnEnd.bind(g),A.get=function(I){if(I===void 0)return A[0];for(var e=0,i=A.length;e