diff --git a/3d-scene/index-runtime.js b/3d-scene/index-runtime.js new file mode 100644 index 0000000..c386926 --- /dev/null +++ b/3d-scene/index-runtime.js @@ -0,0 +1,6492 @@ +var w3=Object.create;var Lm=Object.defineProperty;var S3=Object.getOwnPropertyDescriptor;var A3=Object.getOwnPropertyNames;var _3=Object.getPrototypeOf,E3=Object.prototype.hasOwnProperty;var M3=(i,t,e)=>t in i?Lm(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Gn=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),T3=(i,t)=>{for(var e in t)Lm(i,e,{get:t[e],enumerable:!0})},C3=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A3(t))!E3.call(i,n)&&n!==e&&Lm(i,n,{get:()=>t[n],enumerable:!(r=S3(t,n))||r.enumerable});return i};var pn=(i,t,e)=>(e=i!=null?w3(_3(i)):{},C3(t||!i||!i.__esModule?Lm(e,"default",{value:i,enumerable:!0}):e,i));var mn=(i,t,e)=>(M3(i,typeof t!="symbol"?t+"":t,e),e);var B2=Gn((wS,N2)=>{(function(i,t){typeof wS=="object"?N2.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(wS,function(){"use strict";return i.importState=function(e){var r=new i;return r.importState(e),r},i;function i(){return function(e){var r=0,n=0,s=0,o=1;e.length==0&&(e=[+new Date]);var a=t();r=a(" "),n=a(" "),s=a(" ");for(var l=0;l>>0,o-=e,o*=e,e=o>>>0,o-=e,e+=o*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var AS=Gn((gv,z2)=>{(function(i,t){typeof gv=="object"&&typeof z2<"u"?t(gv):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(gv,function(i){"use strict";i.SVD=function(t,e,r,n,s){if(e=e===void 0||e,r=r===void 0||r,s=1e-64/(n=n||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var o,a,l,u,c,h,d,f,p,m,g,y,v=t[0].length,x=t.length;if(x{(function(i,t){typeof US=="object"&&typeof GS<"u"?GS.exports=t():typeof define=="function"&&define.amd?define(t):(i=i||self,i.TinyQueue=t())})(US,function(){"use strict";var i=function(r,n){if(r===void 0&&(r=[]),n===void 0&&(n=t),this.data=r,this.length=this.data.length,this.compare=n,this.length>0)for(var s=(this.length>>1)-1;s>=0;s--)this._down(s)};i.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},i.prototype.pop=function(){if(this.length!==0){var r=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),r}},i.prototype.peek=function(){return this.data[0]},i.prototype._up=function(r){for(var n=this,s=n.data,o=n.compare,a=s[r];r>0;){var l=r-1>>1,u=s[l];if(o(a,u)>=0)break;s[r]=u,r=l}s[r]=a},i.prototype._down=function(r){for(var n=this,s=n.data,o=n.compare,a=this.length>>1,l=s[r];r=0)break;s[r]=c,r=u}s[r]=l};function t(e,r){return er?1:0}return i})});var mD=Gn((kfe,HS)=>{"use strict";var Sv=fD();Sv.default&&(Sv=Sv.default);HS.exports=pD;HS.exports.default=pD;function pD(i,t,e){t=t||1;for(var r,n,s,o,a=0;as)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var u=s-r,c=o-n,h=Math.min(u,c),d=h/2;if(h===0){var f=[r,n];return f.distance=0,f}for(var p=new Sv(void 0,V8),m=r;my.d&&(y=v);for(var x=p.length;p.length;){var w=p.pop();w.d>y.d&&(y=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,x)),!(w.max-y.d<=t)&&(d=w.h/2,p.push(new cl(w.x-d,w.y-d,d,i)),p.push(new cl(w.x+d,w.y-d,d,i)),p.push(new cl(w.x-d,w.y+d,d,i)),p.push(new cl(w.x+d,w.y+d,d,i)),x+=4)}e&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var S=[y.x,y.y];return S.distance=y.d,S}function V8(i,t){return t.max-i.max}function cl(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=z8(i,t,r),this.max=this.d+this.h*Math.SQRT2}function z8(i,t,e){for(var r=!1,n=1/0,s=0;st!=h[1]>t&&i<(h[0]-c[0])*(t-c[1])/(h[1]-c[1])+c[0]&&(r=!r),n=Math.min(n,G8(i,t,c,h))}return n===0?0:(r?1:-1)*Math.sqrt(n)}function U8(i){for(var t=0,e=0,r=0,n=i[0],s=0,o=n.length,a=o-1;s1?(n=r[0],s=r[1]):l>0&&(n+=o*l,s+=a*l)}return o=i-n,a=t-s,o*o+a*a}});var dI=Gn((Yv,hI)=>{"use strict";Object.defineProperty(Yv,"__esModule",{value:!0});Yv.default=Vq;function Vq(i){if(i===null||i===!0||i===!1)return NaN;var t=Number(i);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}hI.exports=Yv.default});var pI=Gn((Xv,fI)=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});Xv.default=zq;function zq(i){var t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds()));return t.setUTCFullYear(i.getFullYear()),i.getTime()-t.getTime()}fI.exports=Xv.default});var _I=Gn(Zv=>{(function(){"use strict";var i=function(){this.init()};i.prototype={init:function(){var c=this||t;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var h=this||t;if(c=parseFloat(c),h.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(h._volume=c,h._muted)return h;h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c,t.ctx.currentTime);for(var d=0;d=0;h--)c._howls[h].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||t)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||t;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var h=new Audio;typeof h.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var h=new Audio;h.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||t,h=null;try{h=typeof Audio<"u"?new Audio:null}catch{return c}if(!h||typeof h.canPlayType!="function")return c;var d=h.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",p=f.match(/OPR\/([0-6].)/g),m=p&&parseInt(p[0].split("/")[1],10)<33,g=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,y=f.match(/Version\/(.*?) /),v=g&&y&&parseInt(y[1],10)<15;return c._codecs={mp3:!!(!m&&(d||h.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!h.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(h.canPlayType('audio/wav; codecs="1"')||h.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!h.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!h.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(h.canPlayType("audio/x-m4b;")||h.canPlayType("audio/m4b;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(h.canPlayType("audio/x-mp4;")||h.canPlayType("audio/mp4;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!v&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!h.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(h.canPlayType("audio/x-flac;")||h.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||t;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var h=function(d){for(;c._html5AudioPool.length"u"?v.noteOn(0):v.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),v.onended=function(){v.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",h,!0),document.removeEventListener("touchend",h,!0),document.removeEventListener("click",h,!0),document.removeEventListener("keydown",h,!0);for(var x=0;x"u"||!t.usingWebAudio)){for(var h=0;h"u"||!t.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var h=0;h"u"&&(c="__default",!d._playLock)){for(var p=0,m=0;m0?g._seek:d._sprite[c][0]/1e3),x=Math.max(0,(d._sprite[c][0]+d._sprite[c][1])/1e3-v),w=x*1e3/Math.abs(g._rate),S=d._sprite[c][0]/1e3,A=(d._sprite[c][0]+d._sprite[c][1])/1e3;g._sprite=c,g._ended=!1;var E=function(){g._paused=!1,g._seek=v,g._start=S,g._stop=A,g._loop=!!(g._loop||d._sprite[c][2])};if(v>=A){d._ended(g);return}var b=g._node;if(d._webAudio){var M=function(){d._playLock=!1,E(),d._refreshBuffer(g);var D=g._muted||d._muted?0:g._volume;b.gain.setValueAtTime(D,t.ctx.currentTime),g._playStart=t.ctx.currentTime,typeof b.bufferSource.start>"u"?g._loop?b.bufferSource.noteGrainOn(0,v,86400):b.bufferSource.noteGrainOn(0,v,x):g._loop?b.bufferSource.start(0,v,86400):b.bufferSource.start(0,v,x),w!==1/0&&(d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w)),h||setTimeout(function(){d._emit("play",g._id),d._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?M():(d._playLock=!0,d.once("resume",M),d._clearTimer(g._id))}else{var T=function(){b.currentTime=v,b.muted=g._muted||d._muted||t._muted||b.muted,b.volume=g._volume*t.volume(),b.playbackRate=g._rate;try{var D=b.play();if(D&&typeof Promise<"u"&&(D instanceof Promise||typeof D.then=="function")?(d._playLock=!0,E(),D.then(function(){d._playLock=!1,b._unlocked=!0,h?d._loadQueue():d._emit("play",g._id)}).catch(function(){d._playLock=!1,d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),g._ended=!0,g._paused=!0})):h||(d._playLock=!1,E(),d._emit("play",g._id)),b.playbackRate=g._rate,b.paused){d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||g._loop?d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w):(d._endTimers[g._id]=function(){d._ended(g),b.removeEventListener("ended",d._endTimers[g._id],!1)},b.addEventListener("ended",d._endTimers[g._id],!1))}catch(I){d._emit("playerror",g._id,I)}};b.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(b.src=d._src,b.load());var C=window&&window.ejecta||!b.readyState&&t._navigator.isCocoonJS;if(b.readyState>=3||C)T();else{d._playLock=!0,d._state="loading";var P=function(){d._state="loaded",T(),b.removeEventListener(t._canPlayEvent,P,!1)};b.addEventListener(t._canPlayEvent,P,!1),d._clearTimer(g._id)}}return g._id},pause:function(c){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"pause",action:function(){h.pause(c)}}),h;for(var d=h._getSoundIds(c),f=0;f"u"?p._node.bufferSource.noteOff(0):p._node.bufferSource.stop(0),h._cleanBuffer(p._node)}else(!isNaN(p._node.duration)||p._node.duration===1/0)&&p._node.pause();arguments[1]||h._emit("pause",p?p._id:null)}return h},stop:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(c)}}),d;for(var f=d._getSoundIds(c),p=0;p"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&d._clearSound(m._node))),h||d._emit("stop",m._id))}return d},mute:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(c,h)}}),d;if(typeof h>"u")if(typeof c=="boolean")d._muted=c;else return d._muted;for(var f=d._getSoundIds(h),p=0;p"u"){var p=c._getSoundIds(),m=p.indexOf(h[0]);m>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length>=2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d<"u"&&d>=0&&d<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,h)}}),c;typeof f>"u"&&(c._volume=d),f=c._getSoundIds(f);for(var y=0;y"u")}}return p},_startFadeInterval:function(c,h,d,f,p,m){var g=this,y=h,v=d-h,x=Math.abs(v/.01),w=Math.max(4,x>0?f/x:f),S=Date.now();c._fadeTo=d,c._interval=setInterval(function(){var A=(Date.now()-S)/f;S=Date.now(),y+=v*A,y=Math.round(y*100)/100,v<0?y=Math.max(d,y):y=Math.min(d,y),g._webAudio?c._volume=y:g.volume(y,c._id,!0),m&&(g._volume=y),(dh&&y>=d)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,g.volume(d,c._id),g._emit("fade",c._id))},w)},_stopFade:function(c){var h=this,d=h._soundById(c);return d&&d._interval&&(h._webAudio&&d._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(d._interval),d._interval=null,h.volume(d._fadeTo,c),d._fadeTo=null,h._emit("fade",c)),h},loop:function(){var c=this,h=arguments,d,f,p;if(h.length===0)return c._loop;if(h.length===1)if(typeof h[0]=="boolean")d=h[0],c._loop=d;else return p=c._soundById(parseInt(h[0],10)),p?p._loop:!1;else h.length===2&&(d=h[0],f=parseInt(h[1],10));for(var m=c._getSoundIds(f),g=0;g=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,h)}}),c;typeof f>"u"&&(c._rate=d),f=c._getSoundIds(f);for(var y=0;y=0?f=parseInt(h[0],10):c._sounds.length&&(f=c._sounds[0]._id,d=parseFloat(h[0]))}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));if(typeof f>"u")return 0;if(typeof d=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,h)}}),c;var g=c._soundById(f);if(g)if(typeof d=="number"&&d>=0){var y=c.playing(f);y&&c.pause(f,!0),g._seek=d,g._ended=!1,c._clearTimer(f),!c._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=d);var v=function(){y&&c.play(f,!0),c._emit("seek",f)};if(y&&!c._webAudio){var x=function(){c._playLock?setTimeout(x,0):v()};setTimeout(x,0)}else v()}else if(c._webAudio){var w=c.playing(f)?t.ctx.currentTime-g._playStart:0,S=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(S+w*Math.abs(g._rate))}else return g._node.currentTime;return c},playing:function(c){var h=this;if(typeof c=="number"){var d=h._soundById(c);return d?!d._paused:!1}for(var f=0;f=0&&t._howls.splice(f,1);var p=!0;for(d=0;d=0){p=!1;break}return n&&p&&delete n[c._src],t.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,h,d,f){var p=this,m=p["_on"+c];return typeof h=="function"&&m.push(f?{id:d,fn:h,once:f}:{id:d,fn:h}),p},off:function(c,h,d){var f=this,p=f["_on"+c],m=0;if(typeof h=="number"&&(d=h,h=null),h||d)for(m=0;m=0;m--)(!p[m].id||p[m].id===h||c==="load")&&(setTimeout(function(g){g.call(this,h,d)}.bind(f,p[m].fn),0),p[m].once&&f.off(c,p[m].fn,p[m].id));return f._loadQueue(c),f},_loadQueue:function(c){var h=this;if(h._queue.length>0){var d=h._queue[0];d.event===c&&(h._queue.shift(),h._loadQueue()),c||d.action()}return h},_ended:function(c){var h=this,d=c._sprite;if(!h._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime=0;f--){if(d<=h)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),d--)}}},_getSoundIds:function(c){var h=this;if(typeof c>"u"){for(var d=[],f=0;f=0;if(t._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),d))try{c.bufferSource.buffer=t._scratchBuffer}catch{}return c.bufferSource=null,h},_clearSound:function(c){var h=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);h||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var r=function(c){this._parent=c,this.init()};r.prototype={init:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,h._sounds.push(c),c.create(),c},create:function(){var c=this,h=c._parent,d=t._muted||c._muted||c._parent._muted?0:c._volume;return h._webAudio?(c._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),c._node.gain.setValueAtTime(d,t.ctx.currentTime),c._node.paused=!0,c._node.connect(t.masterGain)):t.noAudio||(c._node=t._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(t._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=h._src,c._node.preload=h._preload===!0?"auto":h._preload,c._node.volume=d*t.volume(),c._node.load()),c},reset:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++t._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,h=c._parent;h._duration=Math.ceil(c._node.duration*10)/10,Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,h._duration*1e3]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue()),c._node.removeEventListener(t._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,h=c._parent;h._duration===1/0&&(h._duration=Math.ceil(c._node.duration*10)/10,h._sprite.__default[1]===1/0&&(h._sprite.__default[1]=h._duration*1e3),h._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var n={},s=function(c){var h=c._src;if(n[h]){c._duration=n[h].duration,l(c);return}if(/^data:[^;]+;base64,/.test(h)){for(var d=atob(h.split(",")[1]),f=new Uint8Array(d.length),p=0;p0?(n[h._src]=p,l(h,p)):d()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(c).then(f).catch(d):t.ctx.decodeAudioData(c,f,d)},l=function(c,h){h&&!c._duration&&(c._duration=h.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),h=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=h?parseInt(h[1],10):null;if(c&&d&&d<9){var f=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!f&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:t,Howl:e}}),typeof Zv<"u"&&(Zv.Howler=t,Zv.Howl=e),typeof global<"u"?(global.HowlerGlobal=i,global.Howler=t,global.Howl=e,global.Sound=r):typeof window<"u"&&(window.HowlerGlobal=i,window.Howler=t,window.Howl=e,window.Sound=r)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var r=e._howls.length-1;r>=0;r--)e._howls[r].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,r){var n=this;if(!n.ctx||!n.ctx.listener)return n;if(e=typeof e!="number"?n._pos[1]:e,r=typeof r!="number"?n._pos[2]:r,typeof t=="number")n._pos=[t,e,r],typeof n.ctx.listener.positionX<"u"?(n.ctx.listener.positionX.setTargetAtTime(n._pos[0],Howler.ctx.currentTime,.1),n.ctx.listener.positionY.setTargetAtTime(n._pos[1],Howler.ctx.currentTime,.1),n.ctx.listener.positionZ.setTargetAtTime(n._pos[2],Howler.ctx.currentTime,.1)):n.ctx.listener.setPosition(n._pos[0],n._pos[1],n._pos[2]);else return n._pos;return n},HowlerGlobal.prototype.orientation=function(t,e,r,n,s,o){var a=this;if(!a.ctx||!a.ctx.listener)return a;var l=a._orientation;if(e=typeof e!="number"?l[1]:e,r=typeof r!="number"?l[2]:r,n=typeof n!="number"?l[3]:n,s=typeof s!="number"?l[4]:s,o=typeof o!="number"?l[5]:o,typeof t=="number")a._orientation=[t,e,r,n,s,o],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(o,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(t,e,r,n,s,o);else return l;return a},Howl.prototype.init=function(t){return function(e){var r=this;return r._orientation=e.orientation||[1,0,0],r._stereo=e.stereo||null,r._pos=e.pos||null,r._pannerAttr={coneInnerAngle:typeof e.coneInnerAngle<"u"?e.coneInnerAngle:360,coneOuterAngle:typeof e.coneOuterAngle<"u"?e.coneOuterAngle:360,coneOuterGain:typeof e.coneOuterGain<"u"?e.coneOuterGain:0,distanceModel:typeof e.distanceModel<"u"?e.distanceModel:"inverse",maxDistance:typeof e.maxDistance<"u"?e.maxDistance:1e4,panningModel:typeof e.panningModel<"u"?e.panningModel:"HRTF",refDistance:typeof e.refDistance<"u"?e.refDistance:1,rolloffFactor:typeof e.rolloffFactor<"u"?e.rolloffFactor:1},r._onstereo=e.onstereo?[{fn:e.onstereo}]:[],r._onpos=e.onpos?[{fn:e.onpos}]:[],r._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,e){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(t,e)}}),r;var n=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof t=="number")r._stereo=t,r._pos=[t,0,0];else return r._stereo;for(var s=r._getSoundIds(e),o=0;o"u")if(typeof t=="number")s._pos=[t,e,r];else return s._pos;for(var o=s._getSoundIds(n),a=0;a"u")if(typeof t=="number")s._orientation=[t,e,r];else return s._orientation;for(var o=s._getSoundIds(n),a=0;a"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),t._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:t._panningModel});else return s=t._soundById(parseInt(e[0],10)),s?s._pannerAttr:t._pannerAttr;else e.length===2&&(r=e[0],n=parseInt(e[1],10));for(var o=t._getSoundIds(n),a=0;a{"use strict";function g7(i){for(var t=new Array(i),e=0;e{$O.exports=function(i){return i!=null&&(JO(i)||y7(i)||!!i._isBuffer)};function JO(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function y7(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&JO(i.slice(0,0))}});var Zd=Gn((QOe,tR)=>{var v7=ZO(),x7=eR(),b7=typeof Float64Array<"u";function w7(i,t){return i[0]-t[0]}function S7(){var i=this.stride,t=new Array(i.length),e;for(e=0;eMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&n.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):n.push("ORDER})")),n.push("proto.set=function "+e+"_set("+o.join(",")+",v){"),r?n.push("return this.data.set("+a+",v)}"):n.push("return this.data["+a+"]=v}"),n.push("proto.get=function "+e+"_get("+o.join(",")+"){"),r?n.push("return this.data.get("+a+")}"):n.push("return this.data["+a+"]}"),n.push("proto.index=function "+e+"_index(",o.join(),"){return "+a+"}"),n.push("proto.hi=function "+e+"_hi("+o.join(",")+"){return new "+e+"(this.data,"+s.map(function(g){return["(typeof i",g,"!=='number'||i",g,"<0)?this.shape[",g,"]:i",g,"|0"].join("")}).join(",")+","+s.map(function(g){return"this.stride["+g+"]"}).join(",")+",this.offset)}");var c=s.map(function(g){return"a"+g+"=this.shape["+g+"]"}),h=s.map(function(g){return"c"+g+"=this.stride["+g+"]"});n.push("proto.lo=function "+e+"_lo("+o.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var d=0;d=0){d=i"+d+"|0;b+=c"+d+"*d;a"+d+"-=d}");n.push("return new "+e+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"c"+g}).join(",")+",b)}"),n.push("proto.step=function "+e+"_step("+o.join(",")+"){var "+s.map(function(g){return"a"+g+"=this.shape["+g+"]"}).join(",")+","+s.map(function(g){return"b"+g+"=this.stride["+g+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var d=0;d=0){c=(c+this.stride["+d+"]*i"+d+")|0}else{a.push(this.shape["+d+"]);b.push(this.stride["+d+"])}");n.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),n.push("return function construct_"+e+"(data,shape,stride,offset){return new "+e+"(data,"+s.map(function(g){return"shape["+g+"]"}).join(",")+","+s.map(function(g){return"stride["+g+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",n.join(` +`));return m(O0[i],S7)}function _7(i){if(x7(i))return"buffer";if(b7)switch(Object.prototype.toString.call(i)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(i)?"array":"generic"}var O0={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function E7(i,t,e,r){if(i===void 0){var u=O0.array[0];return u([])}else typeof i=="number"&&(i=[i]);t===void 0&&(t=[i.length]);var n=t.length;if(e===void 0){e=new Array(n);for(var s=n-1,o=1;s>=0;--s)e[s]=o,o*=t[s]}if(r===void 0){r=0;for(var s=0;s{"use strict";function M7(i,t){for(var e=1,r=i.length,n=i[0],s=i[0],o=1;o{"use strict";var P7=nR();function iR(i,t,e){var r=i.length,n=t.arrayArgs.length,s=t.indexArgs.length>0,o=[],a=[],l=0,u=0,c,h;for(c=0;c0&&o.push("var "+a.join(",")),c=r-1;c>=0;--c)l=i[c],o.push(["for(i",c,"=0;i",c,"0&&o.push(["index[",u,"]-=s",u].join("")),o.push(["++index[",l,"]"].join(""))),o.push("}")}return o.join(` +`)}function D7(i,t,e,r){for(var n=t.length,s=e.arrayArgs.length,o=e.blockSize,a=e.indexArgs.length>0,l=[],u=0;u0;){"].join("")),l.push(["if(j",u,"<",o,"){"].join("")),l.push(["s",t[u],"=j",u].join("")),l.push(["j",u,"=0"].join("")),l.push(["}else{s",t[u],"=",o].join("")),l.push(["j",u,"-=",o,"}"].join("")),a&&l.push(["index[",t[u],"]=j",u].join(""));for(var u=0;u0&&(e=e&&t[r]===t[r-1])}return e?t[0]:t.join("")}function R7(i,t){for(var e=t[1].length-Math.abs(i.arrayBlockIndices[0])|0,r=new Array(i.arrayArgs.length),n=new Array(i.arrayArgs.length),s=0;s0&&m.push("shape=SS.slice(0)"),i.indexArgs.length>0){for(var g=new Array(e),s=0;s0&&p.push("var "+m.join(","));for(var s=0;s3&&p.push(l1(i.pre,i,n));var w=l1(i.body,i,n),S=I7(c);S3&&p.push(l1(i.post,i,n)),i.debug&&console.log("-----Generated cwise routine for ",t,`: +`+p.join(` +`)+` +----------`);var A=[i.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",S,O7(n)].join(""),E=new Function(["function ",A,"(",f.join(","),"){",p.join(` +`),"} return ",A].join(""));return E()}sR.exports=R7});var lR=Gn((JOe,aR)=>{"use strict";var L7=oR();function N7(i){var t=["'use strict'","var CACHED={}"],e=[],r=i.funcName+"_cwise_thunk";t.push(["return function ",r,"(",i.shimArgs.join(","),"){"].join(""));for(var n=[],s=[],o=[["array",i.arrayArgs[0],".shape.slice(",Math.max(0,i.arrayBlockIndices[0]),i.arrayBlockIndices[0]<0?","+i.arrayBlockIndices[0]+")":")"].join("")],a=[],l=[],u=0;u0&&(a.push("array"+i.arrayArgs[0]+".shape.length===array"+c+".shape.length+"+(Math.abs(i.arrayBlockIndices[0])-Math.abs(i.arrayBlockIndices[u]))),l.push("array"+i.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,i.arrayBlockIndices[0])+"]===array"+c+".shape[shapeIndex+"+Math.max(0,i.arrayBlockIndices[u])+"]"))}i.arrayArgs.length>1&&(t.push("if (!("+a.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+i.arrayArgs[0]+".shape.length-"+Math.abs(i.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var u=0;u{"use strict";var B7=lR();function F7(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function k7(i){var t=new F7;t.pre=i.pre,t.body=i.body,t.post=i.post;var e=i.args.slice(0);t.argTypes=e;for(var r=0;r0)throw new Error("cwise: pre() block may not reference array args");if(r0)throw new Error("cwise: post() block may not reference array args")}else if(n==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(n==="index"){if(t.indexArgs.push(r),r0)throw new Error("cwise: pre() block may not reference array index");if(r0)throw new Error("cwise: post() block may not reference array index")}else if(n==="shape"){if(t.shapeArgs.push(r),re.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!i.printCode||!!i.debug,t.funcName=i.funcName||"cwise",t.blockSize=i.blockSize||64,B7(t)}cR.exports=k7});var Jd=Gn(bt=>{"use strict";var Ai=uR(),R0={body:"",args:[],thisVars:[],localVars:[]};function c1(i){if(!i)return R0;for(var t=0;t>",rrshift:">>>"};(function(){for(var i in hR){var t=hR[i];bt[i]=Sr({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:i}),bt[i+"eq"]=Sr({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:i+"eq"}),bt[i+"s"]=Sr({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:i+"s"}),bt[i+"seq"]=Sr({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:i+"seq"})}})();var dR={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var i in dR){var t=dR[i];bt[i]=Sr({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:i}),bt[i+"eq"]=Sr({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:i+"eq"})}})();var fR={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var i in fR){var t=fR[i];bt[i]=Sr({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:i}),bt[i+"s"]=Sr({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:i+"s"}),bt[i+"eq"]=Sr({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:i+"eq"}),bt[i+"seq"]=Sr({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:i+"seq"})}})();var pR=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;ithis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});bt.norm1=Ai({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});bt.sup=Ai({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});bt.inf=Ai({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});bt.random=Sr({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});bt.assign=Sr({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});bt.assigns=Sr({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});bt.equals=Ai({args:["array","array"],pre:R0,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var p3=Gn((IUe,f3)=>{f3.exports=function(t,e){for(var r=t.split("."),n=e.split("."),s=0;s<3;s++){var o=Number(r[s]),a=Number(n[s]);if(o>a)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!isNaN(a))return-1}return 0}});var qo="149";var Oi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},P3=0,b_=1,D3=2;var Ng=1,I3=2,Ef=3,Pi=0,Qr=1,Ln=2;var Vt=0,_a=1,w_=2,S_=3,A_=4,O3=5,eu=100,R3=101,L3=102,__=103,E_=104,N3=200,B3=201,F3=202,k3=203,ZE=204,JE=205,V3=206,z3=207,U3=208,G3=209,H3=210,j3=0,W3=1,q3=2,fb=3,Y3=4,X3=5,Q3=6,K3=7,$E=0,Z3=1,J3=2,Uo=0,$3=1,eN=2,tN=3,rN=4,nN=5,eM=300,Ma=301,Ta=302,pb=303,mb=304,Cu=306,ms=1e3,sr=1001,gb=1002,kt=1003,M_=1004;var Dx=1005;var Je=1006,iN=1007;var Ul=1008;var lr=1009,sN=1010,oN=1011,tM=1012,aN=1013,ps=1014,Xr=1015,Go=1016,lN=1017,cN=1018,Ea=1020,uN=1021,$n=1023,hN=1024,dN=1025,Vl=1026,Ca=1027,fN=1028,pN=1029,Pu=1030,mN=1031,Xb=1033,Ix=33776,Ox=33777,Rx=33778,Lx=33779,T_=35840,C_=35841,P_=35842,D_=35843,gN=36196,I_=37492,O_=37496,R_=37808,L_=37809,N_=37810,B_=37811,F_=37812,k_=37813,V_=37814,z_=37815,U_=37816,G_=37817,H_=37818,j_=37819,W_=37820,q_=37821,Nx=36492,yN=36283,Y_=36284,X_=36285,Q_=36286,Qb=2200,Kb=2201,Yf=2202,cg=2300,ug=2301,Bx=2302,tu=2400,ru=2401,hg=2402,Zb=2500,vN=2501;var Di=3e3,et=3001,vn=3200,Jb=3201,xN=0,bN=1;var Gs="srgb",Of="srgb-linear";var Fx=7680;var wN=519,yb=35044,rM=35048;var K_="300 es",vb=1035,Yt=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let r=this._listeners;return r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let n=this._listeners[t];if(n!==void 0){let s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let r=this._listeners[t.type];if(r!==void 0){t.target=this;let n=r.slice(0);for(let s=0,o=n.length;s>8&255]+Hn[i>>16&255]+Hn[i>>24&255]+"-"+Hn[t&255]+Hn[t>>8&255]+"-"+Hn[t>>16&15|64]+Hn[t>>24&255]+"-"+Hn[e&63|128]+Hn[e>>8&255]+"-"+Hn[e>>16&255]+Hn[e>>24&255]+Hn[r&255]+Hn[r>>8&255]+Hn[r>>16&255]+Hn[r>>24&255]).toLowerCase()}function Yr(i,t,e){return Math.max(t,Math.min(e,i))}function $b(i,t){return(i%t+t)%t}function SN(i,t,e,r,n){return r+(i-t)*(n-r)/(e-t)}function AN(i,t,e){return i!==t?(e-i)/(t-i):0}function Cf(i,t,e){return(1-e)*i+e*t}function _N(i,t,e,r){return Cf(i,t,1-Math.exp(-e*r))}function EN(i,t=1){return t-Math.abs($b(i,t*2)-t)}function MN(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function TN(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function CN(i,t){return i+Math.floor(Math.random()*(t-i+1))}function PN(i,t){return i+Math.random()*(t-i)}function DN(i){return i*(.5-Math.random())}function IN(i){i!==void 0&&(Z_=i);let t=Z_+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function ON(i){return i*Tf}function RN(i){return i*Rf}function xb(i){return(i&i-1)===0&&i!==0}function nM(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function dg(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function LN(i,t,e,r,n){let s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),u=s((t+r)/2),c=o((t+r)/2),h=s((t-r)/2),d=o((t-r)/2),f=s((r-t)/2),p=o((r-t)/2);switch(n){case"XYX":i.set(a*c,l*h,l*d,a*u);break;case"YZY":i.set(l*d,a*c,l*h,a*u);break;case"ZXZ":i.set(l*h,l*d,a*c,a*u);break;case"XZX":i.set(a*c,l*p,l*f,a*u);break;case"YXY":i.set(l*f,a*c,l*p,a*u);break;case"ZYZ":i.set(l*p,l*f,a*c,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function zo(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Kt(i,t){switch(t.constructor){case Float32Array:return i;case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Se=Object.freeze({__proto__:null,DEG2RAD:Tf,RAD2DEG:Rf,ceilPowerOfTwo:nM,clamp:Yr,damp:_N,degToRad:ON,denormalize:zo,euclideanModulo:$b,floorPowerOfTwo:dg,generateUUID:Ui,inverseLerp:AN,isPowerOfTwo:xb,lerp:Cf,mapLinear:SN,normalize:Kt,pingpong:EN,radToDeg:RN,randFloat:PN,randFloatSpread:DN,randInt:CN,seededRandom:IN,setQuaternionFromProperEuler:LN,smootherstep:TN,smoothstep:MN}),N=class{constructor(t=0,e=0){N.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let r=Math.cos(e),n=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*n+t.x,this.y=s*n+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Gt=class{constructor(){Gt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,r,n,s,o,a,l,u){let c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,n=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],u=r[1],c=r[4],h=r[7],d=r[2],f=r[5],p=r[8],m=n[0],g=n[3],y=n[6],v=n[1],x=n[4],w=n[7],S=n[2],A=n[5],E=n[8];return s[0]=o*m+a*v+l*S,s[3]=o*g+a*x+l*A,s[6]=o*y+a*w+l*E,s[1]=u*m+c*v+h*S,s[4]=u*g+c*x+h*A,s[7]=u*y+c*w+h*E,s[2]=d*m+f*v+p*S,s[5]=d*g+f*x+p*A,s[8]=d*y+f*w+p*E,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8];return e*o*c-e*a*u-r*s*c+r*a*l+n*s*u-n*o*l}invert(){let t=this.elements,e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=c*o-a*u,d=a*l-c*s,f=u*s-o*l,p=e*h+r*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return t[0]=h*m,t[1]=(n*u-c*r)*m,t[2]=(a*r-n*o)*m,t[3]=d*m,t[4]=(c*e-n*l)*m,t[5]=(n*s-a*e)*m,t[6]=f*m,t[7]=(r*l-u*e)*m,t[8]=(o*e-r*s)*m,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,n,s,o,a){let l=Math.cos(s),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*o+u*a)+o+t,-n*u,n*l,-n*(-u*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(kx.makeScale(t,e)),this}rotate(t){return this.premultiply(kx.makeRotation(-t)),this}translate(t,e){return this.premultiply(kx.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,r=t.elements;for(let n=0;n<9;n++)if(e[n]!==r[n])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}},kx=new Gt;function iM(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}var NN={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Nm(i,t){return new NN[i](t)}function fg(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function zl(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function lg(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Vx={[Gs]:{[Of]:zl},[Of]:{[Gs]:lg}},Kn={legacyMode:!0,get workingColorSpace(){return Of},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.legacyMode||t===e||!t||!e)return i;if(Vx[t]&&Vx[t][e]!==void 0){let r=Vx[t][e];return i.r=r(i.r),i.g=r(i.g),i.b=r(i.b),i}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)}},sM={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},en={r:0,g:0,b:0},hs={h:0,s:0,l:0},Bm={h:0,s:0,l:0};function zx(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}function Fm(i,t){return t.r=i.r,t.g=i.g,t.b=i.b,t}var Re=class{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,e===void 0&&r===void 0?this.set(t):this.setRGB(t,e,r)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Gs){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kn.toWorkingColorSpace(this,e),this}setRGB(t,e,r,n=Kn.workingColorSpace){return this.r=t,this.g=e,this.b=r,Kn.toWorkingColorSpace(this,n),this}setHSL(t,e,r,n=Kn.workingColorSpace){if(t=$b(t,1),e=Yr(e,0,1),r=Yr(r,0,1),e===0)this.r=this.g=this.b=r;else{let s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=zx(o,s,t+1/3),this.g=zx(o,s,t),this.b=zx(o,s,t-1/3)}return Kn.toWorkingColorSpace(this,n),this}setStyle(t,e=Gs){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Kn.toWorkingColorSpace(this,e),r(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Kn.toWorkingColorSpace(this,e),r(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,u=parseFloat(s[2])/100,c=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,u,c,e)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=n[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Kn.toWorkingColorSpace(this,e),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Kn.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=Gs){let r=sM[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=zl(t.r),this.g=zl(t.g),this.b=zl(t.b),this}copyLinearToSRGB(t){return this.r=lg(t.r),this.g=lg(t.g),this.b=lg(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Gs){return Kn.fromWorkingColorSpace(Fm(this,en),t),Yr(en.r*255,0,255)<<16^Yr(en.g*255,0,255)<<8^Yr(en.b*255,0,255)<<0}getHexString(t=Gs){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kn.workingColorSpace){Kn.fromWorkingColorSpace(Fm(this,en),e);let r=en.r,n=en.g,s=en.b,o=Math.max(r,n,s),a=Math.min(r,n,s),l,u,c=(a+o)/2;if(a===o)l=0,u=0;else{let h=o-a;switch(u=c<=.5?h/(o+a):h/(2-o-a),o){case r:l=(n-s)/h+(n"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{zc===void 0&&(zc=fg("canvas")),zc.width=t.width,zc.height=t.height;let r=zc.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=zc}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=fg("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);let n=r.getImageData(0,0,t.width,t.height),s=n.data;for(let o=0;o0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==eM)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ms:t.x=t.x-Math.floor(t.x);break;case sr:t.x=t.x<0?0:1;break;case gb:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case ms:t.y=t.y-Math.floor(t.y);break;case sr:t.y=t.y<0?0:1;break;case gb:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}};or.DEFAULT_IMAGE=null;or.DEFAULT_MAPPING=eM;or.DEFAULT_ANISOTROPY=1;var Xe=class{constructor(t=0,e=0,r=0,n=1){Xe.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,r=this.y,n=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,n,s,l=t.elements,u=l[0],c=l[4],h=l[8],d=l[1],f=l[5],p=l[9],m=l[2],g=l[6],y=l[10];if(Math.abs(c-d)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(u+f+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let x=(u+1)/2,w=(f+1)/2,S=(y+1)/2,A=(c+d)/4,E=(h+m)/4,b=(p+g)/4;return x>w&&x>S?x<.01?(r=0,n=.707106781,s=.707106781):(r=Math.sqrt(x),n=A/r,s=E/r):w>S?w<.01?(r=.707106781,n=0,s=.707106781):(n=Math.sqrt(w),r=A/n,s=b/n):S<.01?(r=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),r=E/s,n=b/s),this.set(r,n,s,e),this}let v=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(h-m)/v,this.z=(d-c)/v,this.w=Math.acos((u+f+y-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},ht=class extends Yt{constructor(t=1,e=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Xe(0,0,t,e),this.scissorTest=!1,this.viewport=new Xe(0,0,t,e);let n={width:t,height:e,depth:1};this.texture=new or(n,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Je,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(t,e,r=1){(this.width!==t||this.height!==e||this.depth!==r)&&(this.width=t,this.height=e,this.depth=r,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new mg(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},gg=class extends or{constructor(t=null,e=1,r=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:r,depth:n},this.magFilter=kt,this.minFilter=kt,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var yg=class extends or{constructor(t=null,e=1,r=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:r,depth:n},this.magFilter=kt,this.minFilter=kt,this.wrapR=sr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var vg=class extends ht{constructor(t=1,e=1,r=1,n={}){super(t,e,n),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let o=0;o=0?1:-1,x=1-y*y;if(x>Number.EPSILON){let S=Math.sqrt(x),A=Math.atan2(S,y*v);g=Math.sin(g*A)/S,a=Math.sin(a*A)/S}let w=a*v;if(l=l*g+d*w,u=u*g+f*w,c=c*g+p*w,h=h*g+m*w,g===1-a){let S=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=S,u*=S,c*=S,h*=S}}t[e]=l,t[e+1]=u,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,n,s,o){let a=r[n],l=r[n+1],u=r[n+2],c=r[n+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+c*h+l*f-u*d,t[e+1]=l*p+c*d+u*h-a*f,t[e+2]=u*p+c*f+a*d-l*h,t[e+3]=c*p-a*h-l*d-u*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let r=t._x,n=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,u=a(r/2),c=a(n/2),h=a(s/2),d=l(r/2),f=l(n/2),p=l(s/2);switch(o){case"XYZ":this._x=d*c*h+u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*h-d*f*p;break;case"YXZ":this._x=d*c*h+u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h+d*f*p;break;case"ZXY":this._x=d*c*h-u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*h-d*f*p;break;case"ZYX":this._x=d*c*h-u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h+d*f*p;break;case"YZX":this._x=d*c*h+u*f*p,this._y=u*f*h+d*c*p,this._z=u*c*p-d*f*h,this._w=u*c*h-d*f*p;break;case"XZY":this._x=d*c*h-u*f*p,this._y=u*f*h-d*c*p,this._z=u*c*p+d*f*h,this._w=u*c*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],n=e[4],s=e[8],o=e[1],a=e[5],l=e[9],u=e[2],c=e[6],h=e[10],d=r+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(c-l)*f,this._y=(s-u)*f,this._z=(o-n)*f}else if(r>a&&r>h){let f=2*Math.sqrt(1+r-a-h);this._w=(c-l)/f,this._x=.25*f,this._y=(n+o)/f,this._z=(s+u)/f}else if(a>h){let f=2*Math.sqrt(1+a-r-h);this._w=(s-u)/f,this._x=(n+o)/f,this._y=.25*f,this._z=(l+c)/f}else{let f=2*Math.sqrt(1+h-r-a);this._w=(o-n)/f,this._x=(s+u)/f,this._y=(l+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return rMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Yr(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let n=Math.min(1,e/r);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let r=t._x,n=t._y,s=t._z,o=t._w,a=e._x,l=e._y,u=e._z,c=e._w;return this._x=r*c+o*a+n*u-s*l,this._y=n*c+o*l+s*a-r*u,this._z=s*c+o*u+r*l-n*a,this._w=o*c-r*a-n*l-s*u,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,n=this._y,s=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-e;return this._w=f*o+e*this._w,this._x=f*r+e*this._x,this._y=f*n+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,a),h=Math.sin((1-e)*c)/u,d=Math.sin(e*c)/u;return this._w=o*h+this._w*d,this._x=r*h+this._x*d,this._y=n*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){let t=Math.random(),e=Math.sqrt(1-t),r=Math.sqrt(t),n=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(n),r*Math.sin(s),r*Math.cos(s),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},_=class{constructor(t=0,e=0,r=0){_.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(J_.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(J_.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,r=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*n,this.y=s[1]*e+s[4]*r+s[7]*n,this.z=s[2]*e+s[5]*r+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,r=this.y,n=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*n+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*n+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*n+s[14])*o,this}applyQuaternion(t){let e=this.x,r=this.y,n=this.z,s=t.x,o=t.y,a=t.z,l=t.w,u=l*e+o*n-a*r,c=l*r+a*e-s*n,h=l*n+s*r-o*e,d=-s*e-o*r-a*n;return this.x=u*l+d*-s+c*-a-h*-o,this.y=c*l+d*-o+h*-s-u*-a,this.z=h*l+d*-a+u*-o-c*-s,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,r=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*n,this.y=s[1]*e+s[5]*r+s[9]*n,this.z=s[2]*e+s[6]*r+s[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let r=t.x,n=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=n*l-s*a,this.y=s*o-r*l,this.z=r*a-n*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Gx.copy(this).projectOnVector(t),this.sub(Gx)}reflect(t){return this.sub(Gx.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let r=this.dot(t)/e;return Math.acos(Yr(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){let n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,r=Math.sqrt(1-t**2);return this.x=r*Math.cos(e),this.y=r*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Gx=new _,J_=new He,Pt=class{constructor(t=new _(1/0,1/0,1/0),e=new _(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,r=1/0,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=t.length;ls&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,n),this.max.set(s,o,a),this}setFromBufferAttribute(t){let e=1/0,r=1/0,n=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=t.count;ls&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,n),this.max.set(s,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ll),Ll.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(yf),km.subVectors(this.max,yf),Uc.subVectors(t.a,yf),Gc.subVectors(t.b,yf),Hc.subVectors(t.c,yf),xa.subVectors(Gc,Uc),ba.subVectors(Hc,Gc),Nl.subVectors(Uc,Hc);let e=[0,-xa.z,xa.y,0,-ba.z,ba.y,0,-Nl.z,Nl.y,xa.z,0,-xa.x,ba.z,0,-ba.x,Nl.z,0,-Nl.x,-xa.y,xa.x,0,-ba.y,ba.x,0,-Nl.y,Nl.x,0];return!jx(e,Uc,Gc,Hc,km)||(e=[1,0,0,0,1,0,0,0,1],!jx(e,Uc,Gc,Hc,km))?!1:(Vm.crossVectors(xa,ba),e=[Vm.x,Vm.y,Vm.z],jx(e,Uc,Gc,Hc,km))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Ll.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=this.getSize(Ll).length()*.5,t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ro[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ro[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ro[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ro[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ro[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ro[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ro[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ro[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ro),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Ro=[new _,new _,new _,new _,new _,new _,new _,new _],Ll=new _,Hx=new Pt,Uc=new _,Gc=new _,Hc=new _,xa=new _,ba=new _,Nl=new _,yf=new _,km=new _,Vm=new _,Bl=new _;function jx(i,t,e,r,n){for(let s=0,o=i.length-3;s<=o;s+=3){Bl.fromArray(i,s);let a=n.x*Math.abs(Bl.x)+n.y*Math.abs(Bl.y)+n.z*Math.abs(Bl.z),l=t.dot(Bl),u=e.dot(Bl),c=r.dot(Bl);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>a)return!1}return!0}var FN=new Pt,vf=new _,Wx=new _,fr=class{constructor(t=new _,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let r=this.center;e!==void 0?r.copy(e):FN.setFromPoints(t).getCenter(r);let n=0;for(let s=0,o=t.length;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;vf.subVectors(t,this.center);let e=vf.lengthSq();if(e>this.radius*this.radius){let r=Math.sqrt(e),n=(r-this.radius)*.5;this.center.addScaledVector(vf,n/r),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Wx.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(vf.copy(t.center).add(Wx)),this.expandByPoint(vf.copy(t.center).sub(Wx))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Lo=new _,qx=new _,zm=new _,wa=new _,Yx=new _,Um=new _,Xx=new _,gs=class{constructor(t=new _,e=new _(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Lo)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=Lo.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Lo.copy(this.direction).multiplyScalar(e).add(this.origin),Lo.distanceToSquared(t))}distanceSqToSegment(t,e,r,n){qx.copy(t).add(e).multiplyScalar(.5),zm.copy(e).sub(t).normalize(),wa.copy(this.origin).sub(qx);let s=t.distanceTo(e)*.5,o=-this.direction.dot(zm),a=wa.dot(this.direction),l=-wa.dot(zm),u=wa.lengthSq(),c=Math.abs(1-o*o),h,d,f,p;if(c>0)if(h=o*l-a,d=o*a-l,p=s*c,h>=0)if(d>=-p)if(d<=p){let m=1/c;h*=m,d*=m,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+u}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d<=-p?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u):d<=p?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+u):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;return r&&r.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(zm).multiplyScalar(d).add(qx),f}intersectSphere(t,e){Lo.subVectors(t.center,this.origin);let r=Lo.dot(this.direction),n=Lo.dot(Lo)-r*r,s=t.radius*t.radius;if(n>s)return null;let o=Math.sqrt(s-n),a=r-o,l=r+o;return a<0&&l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){let r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,n,s,o,a,l,u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return u>=0?(r=(t.min.x-d.x)*u,n=(t.max.x-d.x)*u):(r=(t.max.x-d.x)*u,n=(t.min.x-d.x)*u),c>=0?(s=(t.min.y-d.y)*c,o=(t.max.y-d.y)*c):(s=(t.max.y-d.y)*c,o=(t.min.y-d.y)*c),r>o||s>n||((s>r||isNaN(r))&&(r=s),(o=0?(a=(t.min.z-d.z)*h,l=(t.max.z-d.z)*h):(a=(t.max.z-d.z)*h,l=(t.min.z-d.z)*h),r>l||a>n)||((a>r||r!==r)&&(r=a),(l=0?r:n,e)}intersectsBox(t){return this.intersectBox(t,Lo)!==null}intersectTriangle(t,e,r,n,s){Yx.subVectors(e,t),Um.subVectors(r,t),Xx.crossVectors(Yx,Um);let o=this.direction.dot(Xx),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;wa.subVectors(this.origin,t);let l=a*this.direction.dot(Um.crossVectors(wa,Um));if(l<0)return null;let u=a*this.direction.dot(Yx.cross(wa));if(u<0||l+u>o)return null;let c=-a*wa.dot(Xx);return c<0?null:this.at(c/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ie=class{constructor(){ie.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,r,n,s,o,a,l,u,c,h,d,f,p,m,g){let y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=n,y[1]=s,y[5]=o,y[9]=a,y[13]=l,y[2]=u,y[6]=c,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ie().fromArray(this.elements)}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){let e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,r=t.elements,n=1/jc.setFromMatrixColumn(t,0).length(),s=1/jc.setFromMatrixColumn(t,1).length(),o=1/jc.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,r=t.x,n=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(n),u=Math.sin(n),c=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*c,f=o*h,p=a*c,m=a*h;e[0]=l*c,e[4]=-l*h,e[8]=u,e[1]=f+p*u,e[5]=d-m*u,e[9]=-a*l,e[2]=m-d*u,e[6]=p+f*u,e[10]=o*l}else if(t.order==="YXZ"){let d=l*c,f=l*h,p=u*c,m=u*h;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*u,e[1]=o*h,e[5]=o*c,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=o*l}else if(t.order==="ZXY"){let d=l*c,f=l*h,p=u*c,m=u*h;e[0]=d-m*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*c,e[9]=m-d*a,e[2]=-o*u,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){let d=o*c,f=o*h,p=a*c,m=a*h;e[0]=l*c,e[4]=p*u-f,e[8]=d*u+m,e[1]=l*h,e[5]=m*u+d,e[9]=f*u-p,e[2]=-u,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){let d=o*l,f=o*u,p=a*l,m=a*u;e[0]=l*c,e[4]=m-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*c,e[9]=-a*c,e[2]=-u*c,e[6]=f*h+p,e[10]=d-m*h}else if(t.order==="XZY"){let d=o*l,f=o*u,p=a*l,m=a*u;e[0]=l*c,e[4]=-h,e[8]=u*c,e[1]=d*h+m,e[5]=o*c,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*c,e[10]=m*h+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(kN,t,VN)}lookAt(t,e,r){let n=this.elements;return Ti.subVectors(t,e),Ti.lengthSq()===0&&(Ti.z=1),Ti.normalize(),Sa.crossVectors(r,Ti),Sa.lengthSq()===0&&(Math.abs(r.z)===1?Ti.x+=1e-4:Ti.z+=1e-4,Ti.normalize(),Sa.crossVectors(r,Ti)),Sa.normalize(),Gm.crossVectors(Ti,Sa),n[0]=Sa.x,n[4]=Gm.x,n[8]=Ti.x,n[1]=Sa.y,n[5]=Gm.y,n[9]=Ti.y,n[2]=Sa.z,n[6]=Gm.z,n[10]=Ti.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,n=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],u=r[12],c=r[1],h=r[5],d=r[9],f=r[13],p=r[2],m=r[6],g=r[10],y=r[14],v=r[3],x=r[7],w=r[11],S=r[15],A=n[0],E=n[4],b=n[8],M=n[12],T=n[1],C=n[5],P=n[9],D=n[13],I=n[2],R=n[6],U=n[10],F=n[14],V=n[3],G=n[7],H=n[11],Y=n[15];return s[0]=o*A+a*T+l*I+u*V,s[4]=o*E+a*C+l*R+u*G,s[8]=o*b+a*P+l*U+u*H,s[12]=o*M+a*D+l*F+u*Y,s[1]=c*A+h*T+d*I+f*V,s[5]=c*E+h*C+d*R+f*G,s[9]=c*b+h*P+d*U+f*H,s[13]=c*M+h*D+d*F+f*Y,s[2]=p*A+m*T+g*I+y*V,s[6]=p*E+m*C+g*R+y*G,s[10]=p*b+m*P+g*U+y*H,s[14]=p*M+m*D+g*F+y*Y,s[3]=v*A+x*T+w*I+S*V,s[7]=v*E+x*C+w*R+S*G,s[11]=v*b+x*P+w*U+S*H,s[15]=v*M+x*D+w*F+S*Y,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[4],n=t[8],s=t[12],o=t[1],a=t[5],l=t[9],u=t[13],c=t[2],h=t[6],d=t[10],f=t[14],p=t[3],m=t[7],g=t[11],y=t[15];return p*(+s*l*h-n*u*h-s*a*d+r*u*d+n*a*f-r*l*f)+m*(+e*l*f-e*u*d+s*o*d-n*o*f+n*u*c-s*l*c)+g*(+e*u*h-e*a*f-s*o*h+r*o*f+s*a*c-r*u*c)+y*(-n*a*c-e*l*h+e*a*d+n*o*h-r*o*d+r*l*c)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){let n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=r),this}invert(){let t=this.elements,e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],y=t[15],v=h*g*u-m*d*u+m*l*f-a*g*f-h*l*y+a*d*y,x=p*d*u-c*g*u-p*l*f+o*g*f+c*l*y-o*d*y,w=c*m*u-p*h*u+p*a*f-o*m*f-c*a*y+o*h*y,S=p*h*l-c*m*l-p*a*d+o*m*d+c*a*g-o*h*g,A=e*v+r*x+n*w+s*S;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/A;return t[0]=v*E,t[1]=(m*d*s-h*g*s-m*n*f+r*g*f+h*n*y-r*d*y)*E,t[2]=(a*g*s-m*l*s+m*n*u-r*g*u-a*n*y+r*l*y)*E,t[3]=(h*l*s-a*d*s-h*n*u+r*d*u+a*n*f-r*l*f)*E,t[4]=x*E,t[5]=(c*g*s-p*d*s+p*n*f-e*g*f-c*n*y+e*d*y)*E,t[6]=(p*l*s-o*g*s-p*n*u+e*g*u+o*n*y-e*l*y)*E,t[7]=(o*d*s-c*l*s+c*n*u-e*d*u-o*n*f+e*l*f)*E,t[8]=w*E,t[9]=(p*h*s-c*m*s-p*r*f+e*m*f+c*r*y-e*h*y)*E,t[10]=(o*m*s-p*a*s+p*r*u-e*m*u-o*r*y+e*a*y)*E,t[11]=(c*a*s-o*h*s-c*r*u+e*h*u+o*r*f-e*a*f)*E,t[12]=S*E,t[13]=(c*m*n-p*h*n+p*r*d-e*m*d-c*r*g+e*h*g)*E,t[14]=(p*a*n-o*m*n-p*r*l+e*m*l+o*r*g-e*a*g)*E,t[15]=(o*h*n-c*a*n+c*r*l-e*h*l-o*r*d+e*a*d)*E,this}scale(t){let e=this.elements,r=t.x,n=t.y,s=t.z;return e[0]*=r,e[4]*=n,e[8]*=s,e[1]*=r,e[5]*=n,e[9]*=s,e[2]*=r,e[6]*=n,e[10]*=s,e[3]*=r,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))}makeTranslation(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let r=Math.cos(e),n=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,u=s*o,c=s*a;return this.set(u*o+r,u*a-n*l,u*l+n*a,0,u*a+n*l,c*a+r,c*l-n*o,0,u*l-n*a,c*l+n*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,n,s,o){return this.set(1,r,s,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,r){let n=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,u=s+s,c=o+o,h=a+a,d=s*u,f=s*c,p=s*h,m=o*c,g=o*h,y=a*h,v=l*u,x=l*c,w=l*h,S=r.x,A=r.y,E=r.z;return n[0]=(1-(m+y))*S,n[1]=(f+w)*S,n[2]=(p-x)*S,n[3]=0,n[4]=(f-w)*A,n[5]=(1-(d+y))*A,n[6]=(g+v)*A,n[7]=0,n[8]=(p+x)*E,n[9]=(g-v)*E,n[10]=(1-(d+m))*E,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,r){let n=this.elements,s=jc.set(n[0],n[1],n[2]).length(),o=jc.set(n[4],n[5],n[6]).length(),a=jc.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],ds.copy(this);let u=1/s,c=1/o,h=1/a;return ds.elements[0]*=u,ds.elements[1]*=u,ds.elements[2]*=u,ds.elements[4]*=c,ds.elements[5]*=c,ds.elements[6]*=c,ds.elements[8]*=h,ds.elements[9]*=h,ds.elements[10]*=h,e.setFromRotationMatrix(ds),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,n,s,o){let a=this.elements,l=2*s/(e-t),u=2*s/(r-n),c=(e+t)/(e-t),h=(r+n)/(r-n),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=u,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,r,n,s,o){let a=this.elements,l=1/(e-t),u=1/(r-n),c=1/(o-s),h=(e+t)*l,d=(r+n)*u,f=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*u,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){let e=this.elements,r=t.elements;for(let n=0;n<16;n++)if(e[n]!==r[n])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}},jc=new _,ds=new ie,kN=new _(0,0,0),VN=new _(1,1,1),Sa=new _,Gm=new _,Ti=new _,$_=new ie,eE=new He,Zt=class{constructor(t=0,e=0,r=0,n=Zt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,n=this._order){return this._x=t,this._y=e,this._z=r,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){let n=t.elements,s=n[0],o=n[4],a=n[8],l=n[1],u=n[5],c=n[9],h=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(Yr(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Yr(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Yr(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Yr(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Yr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Yr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return $_.makeRotationFromQuaternion(t),this.setFromRotationMatrix($_,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return eE.setFromEuler(this),this.setFromQuaternion(eE,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Zt.DEFAULT_ORDER="XYZ";var Lf=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let r=0;r0&&(r=r.concat(o))}return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xf,t,UN),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xf,GN,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let r=0,n=e.length;r0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let u=0,c=l.length;u0){n.children=[];for(let a=0;a0){n.animations=[];for(let a=0;a0&&(r.geometries=a),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),c.length>0&&(r.images=c),h.length>0&&(r.shapes=h),d.length>0&&(r.skeletons=d),f.length>0&&(r.animations=f),p.length>0&&(r.nodes=p)}return r.object=n,r;function o(a){let l=[];for(let u in a){let c=a[u];delete c.metadata,l.push(c)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,r,n,s){fs.subVectors(n,e),Bo.subVectors(r,e),Qx.subVectors(t,e);let o=fs.dot(fs),a=fs.dot(Bo),l=fs.dot(Qx),u=Bo.dot(Bo),c=Bo.dot(Qx),h=o*u-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(u*l-a*c)*d,p=(o*c-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,r,n){return this.getBarycoord(t,e,r,n,Fo),Fo.x>=0&&Fo.y>=0&&Fo.x+Fo.y<=1}static getUV(t,e,r,n,s,o,a,l){return this.getBarycoord(t,e,r,n,Fo),l.set(0,0),l.addScaledVector(s,Fo.x),l.addScaledVector(o,Fo.y),l.addScaledVector(a,Fo.z),l}static isFrontFacing(t,e,r,n){return fs.subVectors(r,e),Bo.subVectors(t,e),fs.cross(Bo).dot(n)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,r,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return fs.subVectors(this.c,this.b),Bo.subVectors(this.a,this.b),fs.cross(Bo).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return dr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return dr.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,n,s){return dr.getUV(t,this.a,this.b,this.c,e,r,n,s)}containsPoint(t){return dr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return dr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let r=this.a,n=this.b,s=this.c,o,a;qc.subVectors(n,r),Yc.subVectors(s,r),Kx.subVectors(t,r);let l=qc.dot(Kx),u=Yc.dot(Kx);if(l<=0&&u<=0)return e.copy(r);Zx.subVectors(t,n);let c=qc.dot(Zx),h=Yc.dot(Zx);if(c>=0&&h<=c)return e.copy(n);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return o=l/(l-c),e.copy(r).addScaledVector(qc,o);Jx.subVectors(t,s);let f=qc.dot(Jx),p=Yc.dot(Jx);if(p>=0&&f<=p)return e.copy(s);let m=f*u-l*p;if(m<=0&&u>=0&&p<=0)return a=u/(u-p),e.copy(r).addScaledVector(Yc,a);let g=c*p-f*h;if(g<=0&&h-c>=0&&f-p>=0)return oE.subVectors(s,n),a=(h-c)/(h-c+(f-p)),e.copy(n).addScaledVector(oE,a);let y=1/(g+m+d);return o=m*y,a=d*y,e.copy(r).addScaledVector(qc,o).addScaledVector(Yc,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},jN=0,Gl=class extends Yt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jN++}),this.uuid=Ui(),this.name="",this.type="Material",this.blending=_a,this.side=Pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=ZE,this.blendDst=JE,this.blendEquation=eu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=fb,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wN,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Fx,this.stencilZFail=Fx,this.stencilZPass=Fx,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let r=t[e];if(r===void 0){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}let n=this[e];if(n===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]=r}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==_a&&(r.blending=this.blending),this.side!==Pi&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(r.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function n(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(e){let s=n(t.textures),o=n(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,r=null;if(e!==null){let n=e.length;r=new Array(n);for(let s=0;s!==n;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Ho=class extends Gl{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$E,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},qr=new _,jm=new N,Ge=class{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=yb,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let n=0,s=this.itemSize;n0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(t[u]=l[u]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let r=this.attributes;for(let l in r){let u=r[l];t.data.attributes[l]=u.toJSON(t.data)}let n={},s=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],c=[];for(let h=0,d=u.length;h0&&(n[l]=c,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let r=t.index;r!==null&&this.setIndex(r.clone(e));let n=t.attributes;for(let u in n){let c=n[u];this.setAttribute(u,c.clone(e))}let s=t.morphAttributes;for(let u in s){let c=[],h=s[u];for(let d=0,f=h.length;d0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;se.far?null:{distance:u,point:Qm.clone(),object:i}}function Km(i,t,e,r,n,s,o,a,l){i.getVertexPosition(o,wf),i.getVertexPosition(a,Sf),i.getVertexPosition(l,Af);let u=qN(i,t,e,r,wf,Sf,Af,rb);if(u){n&&(qm.fromBufferAttribute(n,o),Ym.fromBufferAttribute(n,a),Xm.fromBufferAttribute(n,l),u.uv=dr.getUV(rb,wf,Sf,Af,qm,Ym,Xm,new N)),s&&(qm.fromBufferAttribute(s,o),Ym.fromBufferAttribute(s,a),Xm.fromBufferAttribute(s,l),u.uv2=dr.getUV(rb,wf,Sf,Af,qm,Ym,Xm,new N));let c={a:o,b:a,c:l,normal:new _,materialIndex:0};dr.getNormal(wf,Sf,Af,c.normal),u.face=c}return u}var yn=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o};let a=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o);let l=[],u=[],c=[],h=[],d=0,f=0;p("z","y","x",-1,-1,r,e,t,o,s,0),p("z","y","x",1,-1,r,e,-t,o,s,1),p("x","z","y",1,1,t,r,e,n,o,2),p("x","z","y",1,-1,t,r,-e,n,o,3),p("x","y","z",1,-1,t,e,r,n,s,4),p("x","y","z",-1,-1,t,e,-r,n,s,5),this.setIndex(l),this.setAttribute("position",new be(u,3)),this.setAttribute("normal",new be(c,3)),this.setAttribute("uv",new be(h,2));function p(m,g,y,v,x,w,S,A,E,b,M){let T=w/E,C=S/b,P=w/2,D=S/2,I=A/2,R=E+1,U=b+1,F=0,V=0,G=new _;for(let H=0;H0?1:-1,c.push(G.x,G.y,G.z),h.push(k/E),h.push(1-H/b),F+=1}}for(let H=0;H0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let r={};for(let n in this.extensions)this.extensions[n]===!0&&(r[n]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}},ys=class extends gt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ie,this.projectionMatrix=new ie,this.projectionMatrixInverse=new ie}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Ir=class extends ys{constructor(t=50,e=1,r=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Rf*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Tf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Rf*2*Math.atan(Math.tan(Tf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,r,n,s,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Tf*.5*this.fov)/this.zoom,r=2*e,n=this.aspect*r,s=-.5*n,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,u=o.fullHeight;s+=o.offsetX*n/l,e-=o.offsetY*r/u,n*=o.width/l,r*=o.height/u}let a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-r,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},Kc=-90,Zc=1,bb=class extends gt{constructor(t,e,r){super(),this.type="CubeCamera",this.renderTarget=r;let n=new Ir(Kc,Zc,t,e);n.layers=this.layers,n.up.set(0,1,0),n.lookAt(1,0,0),this.add(n);let s=new Ir(Kc,Zc,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let o=new Ir(Kc,Zc,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new Ir(Kc,Zc,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new Ir(Kc,Zc,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let u=new Ir(Kc,Zc,t,e);u.layers=this.layers,u.up.set(0,1,0),u.lookAt(0,0,-1),this.add(u)}update(t,e){this.parent===null&&this.updateMatrixWorld();let r=this.renderTarget,[n,s,o,a,l,u]=this.children,c=t.getRenderTarget(),h=t.toneMapping,d=t.xr.enabled;t.toneMapping=Uo,t.xr.enabled=!1;let f=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,n),t.setRenderTarget(r,1),t.render(e,s),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,a),t.setRenderTarget(r,4),t.render(e,l),r.texture.generateMipmaps=f,t.setRenderTarget(r,5),t.render(e,u),t.setRenderTarget(c),t.toneMapping=h,t.xr.enabled=d,r.texture.needsPMREMUpdate=!0}},au=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){t=t!==void 0?t:[],e=e!==void 0?e:Ma,super(t,e,r,n,s,o,a,l,u,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},wb=class extends ht{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let r={width:t,height:t,depth:1},n=[r,r,r,r,r,r];this.texture=new au(n,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Je}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let r={uniforms:{tEquirect:{value:null}},vertexShader:` + + 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 ); + + } + `},n=new yn(5,5,5),s=new at({name:"CubemapFromEquirect",uniforms:ou(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Qr,blending:Vt});s.uniforms.tEquirect.value=e;let o=new _r(n,s),a=e.minFilter;return e.minFilter===Ul&&(e.minFilter=Je),new bb(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,r,n){let s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,r,n);t.setRenderTarget(s)}},nb=new _,KN=new _,ZN=new Gt,Or=class{constructor(t=new _(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,r,n){return this.normal.set(t,e,r),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){let n=nb.subVectors(r,e).cross(KN.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){let r=t.delta(nb),n=this.normal.dot(r);if(n===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let s=-(t.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:e.copy(r).multiplyScalar(s).add(t.start)}intersectsLine(t){let e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let r=e||ZN.getNormalMatrix(t),n=this.coplanarPoint(nb).applyMatrix4(t),s=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Jc=new fr,Zm=new _,Nf=class{constructor(t=new Or,e=new Or,r=new Or,n=new Or,s=new Or,o=new Or){this.planes=[t,e,r,n,s,o]}set(t,e,r,n,s,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(s),a[5].copy(o),this}copy(t){let e=this.planes;for(let r=0;r<6;r++)e[r].copy(t.planes[r]);return this}setFromProjectionMatrix(t){let e=this.planes,r=t.elements,n=r[0],s=r[1],o=r[2],a=r[3],l=r[4],u=r[5],c=r[6],h=r[7],d=r[8],f=r[9],p=r[10],m=r[11],g=r[12],y=r[13],v=r[14],x=r[15];return e[0].setComponents(a-n,h-l,m-d,x-g).normalize(),e[1].setComponents(a+n,h+l,m+d,x+g).normalize(),e[2].setComponents(a+s,h+u,m+f,x+y).normalize(),e[3].setComponents(a-s,h-u,m-f,x-y).normalize(),e[4].setComponents(a-o,h-c,m-p,x-v).normalize(),e[5].setComponents(a+o,h+c,m+p,x+v).normalize(),this}intersectsObject(t){let e=t.geometry;return e.boundingSphere===null&&e.computeBoundingSphere(),Jc.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Jc)}intersectsSprite(t){return Jc.center.set(0,0,0),Jc.radius=.7071067811865476,Jc.applyMatrix4(t.matrixWorld),this.intersectsSphere(Jc)}intersectsSphere(t){let e=this.planes,r=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(r)0?t.max.x:t.min.x,Zm.y=n.normal.y>0?t.max.y:t.min.y,Zm.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Zm)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function aM(){let i=null,t=!1,e=null,r=null;function n(s,o){e(s,o),r=i.requestAnimationFrame(n)}return{start:function(){t!==!0&&e!==null&&(r=i.requestAnimationFrame(n),t=!0)},stop:function(){i.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function JN(i,t){let e=t.isWebGL2,r=new WeakMap;function n(u,c){let h=u.array,d=u.usage,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,h,d),u.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(e)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:f,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version}}function s(u,c,h){let d=c.array,f=c.updateRange;i.bindBuffer(h,u),f.count===-1?i.bufferSubData(h,0,d):(e?i.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):i.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),c.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function a(u){u.isInterleavedBufferAttribute&&(u=u.data);let c=r.get(u);c&&(i.deleteBuffer(c.buffer),r.delete(u))}function l(u,c){if(u.isGLBufferAttribute){let d=r.get(u);(!d||d.version 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`,lB=`#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`,cB=`#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`,uB=`#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`,dB=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,fB=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,pB=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,mB=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,gB=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + varying vec3 vColor; +#endif`,yB=`#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`,vB=`#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 ); +}`,xB=`#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`,bB=`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`,wB=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,SB=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); +#endif`,AB=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,_B=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,EB="gl_FragColor = linearToOutputTexel( gl_FragColor );",MB=`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 ); +}`,TB=`#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`,CB=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,PB=`#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`,DB=`#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`,IB=`#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`,OB=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,RB=`#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`,NB=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,BB=`#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 +}`,FB=`#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + reflectedLight.indirectDiffuse += lightMapIrradiance; +#endif`,kB=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,VB=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,zB=`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`,UB=`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`,GB=`#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`,HB=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,jB=`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`,WB=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,qB=`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`,YB=`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 ); +}`,QB=` +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`,KB=`#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`,ZB=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); +#endif`,JB=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,$B=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,eF=`#ifdef USE_LOGDEPTHBUF + #ifdef USE_LOGDEPTHBUF_EXT + varying float vFragDepth; + varying float vIsPerspective; + #else + uniform float logDepthBufFC; + #endif +#endif`,tF=`#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`,rF=`#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`,nF=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,iF=`#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`,sF=`#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`,oF=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vUv ); + metalnessFactor *= texelMetalness.b; +#endif`,aF=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,lF=`#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`,cF=`#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`,uF=`#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`,hF=`#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`,dF=`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;`,fF=`#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`,pF=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,mF=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,gF=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,yF=`#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`,vF=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = geometryNormal; +#endif`,xF=`#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`,bF=`#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`,wF=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,SF=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha + 0.1; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,AF=`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 ); +}`,_F=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,EF=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,MF=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,TF=`#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`,CF=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vUv ); + roughnessFactor *= texelRoughness.g; +#endif`,PF=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,DF=`#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`,IF=`#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`,OF=`#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`,RF=`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; +}`,LF=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,NF=`#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`,BF=`#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`,FF=`#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`,kF=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,VF=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,zF=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,UF=`#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; }`,GF=`#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`,HF=`#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`,jF=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) + varying vec2 vUv; +#endif`,WF=`#ifdef USE_UV + #ifdef UVS_VERTEX_ONLY + vec2 vUv; + #else + varying vec2 vUv; + #endif + uniform mat3 uvTransform; +#endif`,qF=`#ifdef USE_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; +#endif`,YF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + varying vec2 vUv2; +#endif`,XF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + attribute vec2 uv2; + varying vec2 vUv2; + uniform mat3 uv2Transform; +#endif`,QF=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; +#endif`,KF=`#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`,ZF=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,JF=`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 +}`,$F=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,ek=`#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 +}`,tk=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,rk=`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 +}`,nk=`#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; +}`,ik=`#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 +}`,sk=`#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; +}`,ok=`#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 ); +}`,ak=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,lk=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,ck=`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 +}`,uk=`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 +}`,hk=`#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 +}`,dk=`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 +}`,fk=`#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 +}`,pk=`#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 +}`,mk=`#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; +}`,gk=`#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 +}`,yk=`#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 +}`,vk=`#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 +}`,xk=`#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 +}`,bk=`#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 +}`,wk=`#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 +}`,Sk=`#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 +}`,Ak=`#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 +}`,_k=`#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 +}`,Ek=`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 +}`,Mk=`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 +}`,Tk=`#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Ck=`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 +}`,Pk=`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 +}`,Dk=`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 +}`,ut={alphamap_fragment:$N,alphamap_pars_fragment:eB,alphatest_fragment:tB,alphatest_pars_fragment:rB,aomap_fragment:nB,aomap_pars_fragment:iB,begin_vertex:sB,beginnormal_vertex:oB,bsdfs:aB,iridescence_fragment:lB,bumpmap_pars_fragment:cB,clipping_planes_fragment:uB,clipping_planes_pars_fragment:hB,clipping_planes_pars_vertex:dB,clipping_planes_vertex:fB,color_fragment:pB,color_pars_fragment:mB,color_pars_vertex:gB,color_vertex:yB,common:vB,cube_uv_reflection_fragment:xB,defaultnormal_vertex:bB,displacementmap_pars_vertex:wB,displacementmap_vertex:SB,emissivemap_fragment:AB,emissivemap_pars_fragment:_B,encodings_fragment:EB,encodings_pars_fragment:MB,envmap_fragment:TB,envmap_common_pars_fragment:CB,envmap_pars_fragment:PB,envmap_pars_vertex:DB,envmap_physical_pars_fragment:GB,envmap_vertex:IB,fog_vertex:OB,fog_pars_vertex:RB,fog_fragment:LB,fog_pars_fragment:NB,gradientmap_pars_fragment:BB,lightmap_fragment:FB,lightmap_pars_fragment:kB,lights_lambert_fragment:VB,lights_lambert_pars_fragment:zB,lights_pars_begin:UB,lights_toon_fragment:HB,lights_toon_pars_fragment:jB,lights_phong_fragment:WB,lights_phong_pars_fragment:qB,lights_physical_fragment:YB,lights_physical_pars_fragment:XB,lights_fragment_begin:QB,lights_fragment_maps:KB,lights_fragment_end:ZB,logdepthbuf_fragment:JB,logdepthbuf_pars_fragment:$B,logdepthbuf_pars_vertex:eF,logdepthbuf_vertex:tF,map_fragment:rF,map_pars_fragment:nF,map_particle_fragment:iF,map_particle_pars_fragment:sF,metalnessmap_fragment:oF,metalnessmap_pars_fragment:aF,morphcolor_vertex:lF,morphnormal_vertex:cF,morphtarget_pars_vertex:uF,morphtarget_vertex:hF,normal_fragment_begin:dF,normal_fragment_maps:fF,normal_pars_fragment:pF,normal_pars_vertex:mF,normal_vertex:gF,normalmap_pars_fragment:yF,clearcoat_normal_fragment_begin:vF,clearcoat_normal_fragment_maps:xF,clearcoat_pars_fragment:bF,iridescence_pars_fragment:wF,output_fragment:SF,packing:AF,premultiplied_alpha_fragment:_F,project_vertex:EF,dithering_fragment:MF,dithering_pars_fragment:TF,roughnessmap_fragment:CF,roughnessmap_pars_fragment:PF,shadowmap_pars_fragment:DF,shadowmap_pars_vertex:IF,shadowmap_vertex:OF,shadowmask_pars_fragment:RF,skinbase_vertex:LF,skinning_pars_vertex:NF,skinning_vertex:BF,skinnormal_vertex:FF,specularmap_fragment:kF,specularmap_pars_fragment:VF,tonemapping_fragment:zF,tonemapping_pars_fragment:UF,transmission_fragment:GF,transmission_pars_fragment:HF,uv_pars_fragment:jF,uv_pars_vertex:WF,uv_vertex:qF,uv2_pars_fragment:YF,uv2_pars_vertex:XF,uv2_vertex:QF,worldpos_vertex:KF,background_vert:ZF,background_frag:JF,backgroundCube_vert:$F,backgroundCube_frag:ek,cube_vert:tk,cube_frag:rk,depth_vert:nk,depth_frag:ik,distanceRGBA_vert:sk,distanceRGBA_frag:ok,equirect_vert:ak,equirect_frag:lk,linedashed_vert:ck,linedashed_frag:uk,meshbasic_vert:hk,meshbasic_frag:dk,meshlambert_vert:fk,meshlambert_frag:pk,meshmatcap_vert:mk,meshmatcap_frag:gk,meshnormal_vert:yk,meshnormal_frag:vk,meshphong_vert:xk,meshphong_frag:bk,meshphysical_vert:wk,meshphysical_frag:Sk,meshtoon_vert:Ak,meshtoon_frag:_k,points_vert:Ek,points_frag:Mk,shadow_vert:Tk,shadow_frag:Ck,sprite_vert:Pk,sprite_frag:Dk},we={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Gt},uv2Transform:{value:new Gt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new N(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Re(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Gt}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new N(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Gt}}},Hs={basic:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.fog]),vertexShader:ut.meshbasic_vert,fragmentShader:ut.meshbasic_frag},lambert:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new Re(0)}}]),vertexShader:ut.meshlambert_vert,fragmentShader:ut.meshlambert_frag},phong:{uniforms:Jn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:ut.meshphong_vert,fragmentShader:ut.meshphong_frag},standard:{uniforms:Jn([we.common,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.roughnessmap,we.metalnessmap,we.fog,we.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag},toon:{uniforms:Jn([we.common,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.gradientmap,we.fog,we.lights,{emissive:{value:new Re(0)}}]),vertexShader:ut.meshtoon_vert,fragmentShader:ut.meshtoon_frag},matcap:{uniforms:Jn([we.common,we.bumpmap,we.normalmap,we.displacementmap,we.fog,{matcap:{value:null}}]),vertexShader:ut.meshmatcap_vert,fragmentShader:ut.meshmatcap_frag},points:{uniforms:Jn([we.points,we.fog]),vertexShader:ut.points_vert,fragmentShader:ut.points_frag},dashed:{uniforms:Jn([we.common,we.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ut.linedashed_vert,fragmentShader:ut.linedashed_frag},depth:{uniforms:Jn([we.common,we.displacementmap]),vertexShader:ut.depth_vert,fragmentShader:ut.depth_frag},normal:{uniforms:Jn([we.common,we.bumpmap,we.normalmap,we.displacementmap,{opacity:{value:1}}]),vertexShader:ut.meshnormal_vert,fragmentShader:ut.meshnormal_frag},sprite:{uniforms:Jn([we.sprite,we.fog]),vertexShader:ut.sprite_vert,fragmentShader:ut.sprite_frag},background:{uniforms:{uvTransform:{value:new Gt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ut.background_vert,fragmentShader:ut.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ut.backgroundCube_vert,fragmentShader:ut.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ut.cube_vert,fragmentShader:ut.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ut.equirect_vert,fragmentShader:ut.equirect_frag},distanceRGBA:{uniforms:Jn([we.common,we.displacementmap,{referencePosition:{value:new _},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ut.distanceRGBA_vert,fragmentShader:ut.distanceRGBA_frag},shadow:{uniforms:Jn([we.lights,we.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:ut.shadow_vert,fragmentShader:ut.shadow_frag}};Hs.physical={uniforms:Jn([Hs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new N(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Re(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new N},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null}}]),vertexShader:ut.meshphysical_vert,fragmentShader:ut.meshphysical_frag};var Jm={r:0,b:0,g:0};function Ik(i,t,e,r,n,s,o){let a=new Re(0),l=s===!0?0:1,u,c,h=null,d=0,f=null;function p(g,y){let v=!1,x=y.isScene===!0?y.background:null;x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x));let w=i.xr,S=w.getSession&&w.getSession();S&&S.environmentBlendMode==="additive"&&(x=null),x===null?m(a,l):x&&x.isColor&&(m(x,1),v=!0),(i.autoClear||v)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),x&&(x.isCubeTexture||x.mapping===Cu)?(c===void 0&&(c=new _r(new yn(1,1,1),new at({name:"BackgroundCubeMaterial",uniforms:ou(Hs.backgroundCube.uniforms),vertexShader:Hs.backgroundCube.vertexShader,fragmentShader:Hs.backgroundCube.fragmentShader,side:Qr,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,E,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=x.encoding!==et,(h!==x||d!==x.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,f=i.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(u===void 0&&(u=new _r(new jo(2,2),new at({name:"BackgroundMaterial",uniforms:ou(Hs.background.uniforms),vertexShader:Hs.background.vertexShader,fragmentShader:Hs.background.fragmentShader,side:Pi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(u)),u.material.uniforms.t2D.value=x,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=x.encoding!==et,x.matrixAutoUpdate===!0&&x.updateMatrix(),u.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||f!==i.toneMapping)&&(u.material.needsUpdate=!0,h=x,d=x.version,f=i.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null))}function m(g,y){g.getRGB(Jm,oM(i)),r.buffers.color.setClear(Jm.r,Jm.g,Jm.b,y,o)}return{getClearColor:function(){return a},setClearColor:function(g,y=1){a.set(g),l=y,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,m(a,l)},render:p}}function Ok(i,t,e,r){let n=i.getParameter(34921),s=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=g(null),u=l,c=!1;function h(I,R,U,F,V){let G=!1;if(o){let H=m(F,U,R);u!==H&&(u=H,f(u.object)),G=y(I,F,U,V),G&&v(I,F,U,V)}else{let H=R.wireframe===!0;(u.geometry!==F.id||u.program!==U.id||u.wireframe!==H)&&(u.geometry=F.id,u.program=U.id,u.wireframe=H,G=!0)}V!==null&&e.update(V,34963),(G||c)&&(c=!1,b(I,R,U,F),V!==null&&i.bindBuffer(34963,e.get(V).buffer))}function d(){return r.isWebGL2?i.createVertexArray():s.createVertexArrayOES()}function f(I){return r.isWebGL2?i.bindVertexArray(I):s.bindVertexArrayOES(I)}function p(I){return r.isWebGL2?i.deleteVertexArray(I):s.deleteVertexArrayOES(I)}function m(I,R,U){let F=U.wireframe===!0,V=a[I.id];V===void 0&&(V={},a[I.id]=V);let G=V[R.id];G===void 0&&(G={},V[R.id]=G);let H=G[F];return H===void 0&&(H=g(d()),G[F]=H),H}function g(I){let R=[],U=[],F=[];for(let V=0;V=0){let X=V[k],q=G[k];if(q===void 0&&(k==="instanceMatrix"&&I.instanceMatrix&&(q=I.instanceMatrix),k==="instanceColor"&&I.instanceColor&&(q=I.instanceColor)),X===void 0||X.attribute!==q||q&&X.data!==q.data)return!0;H++}return u.attributesNum!==H||u.index!==F}function v(I,R,U,F){let V={},G=R.attributes,H=0,Y=U.getAttributes();for(let k in Y)if(Y[k].location>=0){let X=G[k];X===void 0&&(k==="instanceMatrix"&&I.instanceMatrix&&(X=I.instanceMatrix),k==="instanceColor"&&I.instanceColor&&(X=I.instanceColor));let q={};q.attribute=X,X&&X.data&&(q.data=X.data),V[k]=q,H++}u.attributes=V,u.attributesNum=H,u.index=F}function x(){let I=u.newAttributes;for(let R=0,U=I.length;R=0){let j=V[Y];if(j===void 0&&(Y==="instanceMatrix"&&I.instanceMatrix&&(j=I.instanceMatrix),Y==="instanceColor"&&I.instanceColor&&(j=I.instanceColor)),j!==void 0){let X=j.normalized,q=j.itemSize,z=e.get(j);if(z===void 0)continue;let J=z.buffer,Z=z.type,K=z.bytesPerElement;if(j.isInterleavedBufferAttribute){let W=j.data,ye=W.stride,fe=j.offset;if(W.isInstancedInterleavedBuffer){for(let se=0;se0&&i.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";E="mediump"}return E==="mediump"&&i.getShaderPrecisionFormat(35633,36337).precision>0&&i.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext,a=e.precision!==void 0?e.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let u=o||t.has("WEBGL_draw_buffers"),c=e.logarithmicDepthBuffer===!0,h=i.getParameter(34930),d=i.getParameter(35660),f=i.getParameter(3379),p=i.getParameter(34076),m=i.getParameter(34921),g=i.getParameter(36347),y=i.getParameter(36348),v=i.getParameter(36349),x=d>0,w=o||t.has("OES_texture_float"),S=x&&w,A=o?i.getParameter(36183):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:n,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:v,vertexTextures:x,floatFragmentTextures:w,floatVertexTextures:S,maxSamples:A}}function Nk(i){let t=this,e=null,r=0,n=!1,s=!1,o=new Or,a=new Gt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||r!==0||n;return n=d,r=h.length,f},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){e=c(h,d,0)},this.setState=function(h,d,f){let p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,y=i.get(h);if(!n||p===null||p.length===0||s&&!g)s?c(null):u();else{let v=s?0:r,x=v*4,w=y.clippingState||null;l.value=w,w=c(p,d,x,f);for(let S=0;S!==x;++S)w[S]=e[S];y.clippingState=w,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function u(){l.value!==e&&(l.value=e,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(h,d,f,p){let m=h!==null?h.length:0,g=null;if(m!==0){if(g=l.value,p!==!0||g===null){let y=f+m*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length0){let u=new wb(l.height/2);return u.fromEquirectangularTexture(i,o),t.set(o,u),o.addEventListener("dispose",n),e(u.texture,o.mapping)}else return null}}return o}function n(o){let a=o.target;a.removeEventListener("dispose",n);let l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function s(){t=new WeakMap}return{get:r,dispose:s}}var lu=class extends ys{constructor(t=-1,e=1,r=1,n=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=n,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,r,n,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,n=(this.top+this.bottom)/2,s=r-t,o=r+t,a=n+e,l=n-e;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,a-=c*this.view.offsetY,l=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},nu=4,lE=[.125,.215,.35,.446,.526,.582],kl=20,ib=new lu,cE=new Re,sb=null,Fl=(1+Math.sqrt(5))/2,$c=1/Fl,uE=[new _(1,1,1),new _(-1,1,1),new _(1,1,-1),new _(-1,1,-1),new _(0,Fl,$c),new _(0,Fl,-$c),new _($c,0,Fl),new _(-$c,0,Fl),new _(Fl,$c,0),new _(-Fl,$c,0)],bg=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,r=.1,n=100){sb=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,r,n,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=fE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=dE(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?x:0,x,x),c.setRenderTarget(n),m&&c.render(p,a),c.render(t,a)}p.geometry.dispose(),p.material.dispose(),c.toneMapping=d,c.autoClear=h,t.background=g}_textureToCubeUV(t,e){let r=this._renderer,n=t.mapping===Ma||t.mapping===Ta;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=fE()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=dE());let s=n?this._cubemapMaterial:this._equirectMaterial,o=new _r(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;let l=this._cubeSize;$m(e,0,0,3*l,2*l),r.setRenderTarget(e),r.render(o,ib)}_applyPMREM(t){let e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let n=1;nkl&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${kl}`);let y=[],v=0;for(let E=0;Ex-nu?n-x+nu:0),A=4*(this._cubeSize-w);$m(e,S,A,3*w,2*w),l.setRenderTarget(e),l.render(h,ib)}};function Fk(i){let t=[],e=[],r=[],n=i,s=i-nu+1+lE.length;for(let o=0;oi-nu?l=lE[o-i+nu-1]:o===0&&(l=0),r.push(l);let u=1/(a-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=6,p=6,m=3,g=2,y=1,v=new Float32Array(m*p*f),x=new Float32Array(g*p*f),w=new Float32Array(y*p*f);for(let A=0;A2?0:-1,M=[E,b,0,E+2/3,b,0,E+2/3,b+1,0,E,b,0,E+2/3,b+1,0,E,b+1,0];v.set(M,m*p*A),x.set(d,g*p*A);let T=[A,A,A,A,A,A];w.set(T,y*p*A)}let S=new Ae;S.setAttribute("position",new Ge(v,m)),S.setAttribute("uv",new Ge(x,g)),S.setAttribute("faceIndex",new Ge(w,y)),t.push(S),n>nu&&n--}return{lodPlanes:t,sizeLods:e,sigmas:r}}function hE(i,t,e){let r=new ht(i,t,e);return r.texture.mapping=Cu,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function $m(i,t,e,r,n){i.viewport.set(t,e,r,n),i.scissor.set(t,e,r,n)}function kk(i,t,e){let r=new Float32Array(kl),n=new _(0,1,0);return new at({name:"SphericalGaussianBlur",defines:{n:kl,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:ew(),fragmentShader:` + + 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:Vt,depthTest:!1,depthWrite:!1})}function dE(){return new at({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ew(),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:Vt,depthTest:!1,depthWrite:!1})}function fE(){return new at({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ew(),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:Vt,depthTest:!1,depthWrite:!1})}function ew(){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 Vk(i){let t=new WeakMap,e=null;function r(a){if(a&&a.isTexture){let l=a.mapping,u=l===pb||l===mb,c=l===Ma||l===Ta;if(u||c)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=t.get(a);return e===null&&(e=new bg(i)),h=u?e.fromEquirectangular(a,h):e.fromCubemap(a,h),t.set(a,h),h.texture}else{if(t.has(a))return t.get(a).texture;{let h=a.image;if(u&&h&&h.height>0||c&&h&&n(h)){e===null&&(e=new bg(i));let d=u?e.fromEquirectangular(a):e.fromCubemap(a);return t.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,u=6;for(let c=0;ct.maxTextureSize&&(C=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);let P=new Float32Array(T*C*4*m),D=new gg(P,T,C,m);D.type=Xr,D.needsUpdate=!0;let I=M*4;for(let U=0;U0)return i;let n=t*e,s=pE[n];if(s===void 0&&(s=new Float32Array(n),pE[n]=s),t!==0){r.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function tn(i,t){if(i.length!==t.length)return!1;for(let e=0,r=i.length;e":" "} ${a}: ${e[o]}`)}return r.join(` +`)}function FV(i){switch(i){case Di:return["Linear","( value )"];case et:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",i),["Linear","( value )"]}}function wE(i,t,e){let r=i.getShaderParameter(t,35713),n=i.getShaderInfoLog(t).trim();if(r&&n==="")return"";let s=/ERROR: 0:(\d+)/.exec(n);if(s){let o=parseInt(s[1]);return e.toUpperCase()+` + +`+n+` + +`+BV(i.getShaderSource(t),o)}else return n}function kV(i,t){let e=FV(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function VV(i,t){let e;switch(t){case $3:e="Linear";break;case eN:e="Reinhard";break;case tN:e="OptimizedCineon";break;case rN:e="ACESFilmic";break;case nN:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function zV(i){return[i.extensionDerivatives||!!i.envMapCubeUVHeight||i.bumpMap||i.tangentSpaceNormalMap||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Mf).join(` +`)}function UV(i){let t=[];for(let e in i){let r=i[e];r!==!1&&t.push("#define "+e+" "+r)}return t.join(` +`)}function GV(i,t){let e={},r=i.getProgramParameter(t,35721);for(let n=0;n/gm;function Eb(i){return i.replace(HV,jV)}function jV(i,t){let e=ut[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return Eb(e)}var WV=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function _E(i){return i.replace(WV,qV)}function qV(i,t,e,r){let n="";for(let s=parseInt(t);s0&&(g+=` +`),y=[f,p].filter(Mf).join(` +`),y.length>0&&(y+=` +`)):(g=[EE(e),"#define SHADER_NAME "+e.shaderName,p,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.supportsVertexTextures?"#define VERTEX_TEXTURES":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.displacementMap&&e.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Mf).join(` +`),y=[f,EE(e),"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Uo?"#define TONE_MAPPING":"",e.toneMapping!==Uo?ut.tonemapping_pars_fragment:"",e.toneMapping!==Uo?VV("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",ut.encodings_pars_fragment,kV("linearToOutputTexel",e.outputEncoding),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Mf).join(` +`)),o=Eb(o),o=SE(o,e),o=AE(o,e),a=Eb(a),a=SE(a,e),a=AE(a,e),o=_E(o),a=_E(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,y=["#define varying in",e.glslVersion===K_?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===K_?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+y);let x=v+g+o,w=v+y+a,S=bE(n,35633,x),A=bE(n,35632,w);if(n.attachShader(m,S),n.attachShader(m,A),e.index0AttributeName!==void 0?n.bindAttribLocation(m,0,e.index0AttributeName):e.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m),i.debug.checkShaderErrors){let M=n.getProgramInfoLog(m).trim(),T=n.getShaderInfoLog(S).trim(),C=n.getShaderInfoLog(A).trim(),P=!0,D=!0;if(n.getProgramParameter(m,35714)===!1){P=!1;let I=wE(n,S,"vertex"),R=wE(n,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,35715)+` + +Program Info Log: `+M+` +`+I+` +`+R)}else M!==""?console.warn("THREE.WebGLProgram: Program Info Log:",M):(T===""||C==="")&&(D=!1);D&&(this.diagnostics={runnable:P,programLog:M,vertexShader:{log:T,prefix:g},fragmentShader:{log:C,prefix:y}})}n.deleteShader(S),n.deleteShader(A);let E;this.getUniforms=function(){return E===void 0&&(E=new su(n,m)),E};let b;return this.getAttributes=function(){return b===void 0&&(b=GV(n,m)),b},this.destroy=function(){r.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.name=e.shaderName,this.id=NV++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=S,this.fragmentShader=A,this}var $V=0,Mb=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,r=t.fragmentShader,n=this._getShaderStage(e),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(t);return o.has(n)===!1&&(o.add(n),n.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let r of e)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,r=e.get(t);return r===void 0&&(r=new Set,e.set(t,r)),r}_getShaderStage(t){let e=this.shaderCache,r=e.get(t);return r===void 0&&(r=new Tb(t),e.set(t,r)),r}},Tb=class{constructor(t){this.id=$V++,this.code=t,this.usedTimes=0}};function ez(i,t,e,r,n,s,o){let a=new Lf,l=new Mb,u=[],c=n.isWebGL2,h=n.logarithmicDepthBuffer,d=n.vertexTextures,f=n.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(b,M,T,C,P){let D=C.fog,I=P.geometry,R=b.isMeshStandardMaterial?C.environment:null,U=(b.isMeshStandardMaterial?e:t).get(b.envMap||R),F=!!U&&U.mapping===Cu?U.image.height:null,V=p[b.type];b.precision!==null&&(f=n.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let G=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,H=G!==void 0?G.length:0,Y=0;I.morphAttributes.position!==void 0&&(Y=1),I.morphAttributes.normal!==void 0&&(Y=2),I.morphAttributes.color!==void 0&&(Y=3);let k,j,X,q;if(V){let ye=Hs[V];k=ye.vertexShader,j=ye.fragmentShader}else k=b.vertexShader,j=b.fragmentShader,l.update(b),X=l.getVertexShaderID(b),q=l.getFragmentShaderID(b);let z=i.getRenderTarget(),J=b.alphaTest>0,Z=b.clearcoat>0,K=b.iridescence>0;return{isWebGL2:c,shaderID:V,shaderName:b.type,vertexShader:k,fragmentShader:j,defines:b.defines,customVertexShaderID:X,customFragmentShaderID:q,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,instancing:P.isInstancedMesh===!0,instancingColor:P.isInstancedMesh===!0&&P.instanceColor!==null,supportsVertexTextures:d,outputEncoding:z===null?i.outputEncoding:z.isXRRenderTarget===!0?z.texture.encoding:Di,map:!!b.map,matcap:!!b.matcap,envMap:!!U,envMapMode:U&&U.mapping,envMapCubeUVHeight:F,lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,objectSpaceNormalMap:b.normalMapType===bN,tangentSpaceNormalMap:b.normalMapType===xN,decodeVideoTexture:!!b.map&&b.map.isVideoTexture===!0&&b.map.encoding===et,clearcoat:Z,clearcoatMap:Z&&!!b.clearcoatMap,clearcoatRoughnessMap:Z&&!!b.clearcoatRoughnessMap,clearcoatNormalMap:Z&&!!b.clearcoatNormalMap,iridescence:K,iridescenceMap:K&&!!b.iridescenceMap,iridescenceThicknessMap:K&&!!b.iridescenceThicknessMap,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,specularIntensityMap:!!b.specularIntensityMap,specularColorMap:!!b.specularColorMap,opaque:b.transparent===!1&&b.blending===_a,alphaMap:!!b.alphaMap,alphaTest:J,gradientMap:!!b.gradientMap,sheen:b.sheen>0,sheenColorMap:!!b.sheenColorMap,sheenRoughnessMap:!!b.sheenRoughnessMap,transmission:b.transmission>0,transmissionMap:!!b.transmissionMap,thicknessMap:!!b.thicknessMap,combine:b.combine,vertexTangents:!!b.normalMap&&!!I.attributes.tangent,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,vertexUvs:!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatMap||!!b.clearcoatRoughnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||!!b.displacementMap||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||!!b.sheenColorMap||!!b.sheenRoughnessMap,uvsVertexOnly:!(!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||b.transmission>0||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||b.sheen>0||!!b.sheenColorMap||!!b.sheenRoughnessMap)&&!!b.displacementMap,fog:!!D,useFog:b.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:!!b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:h,skinning:P.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Y,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:i.shadowMap.enabled&&T.length>0,shadowMapType:i.shadowMap.type,toneMapping:b.toneMapped?i.toneMapping:Uo,physicallyCorrectLights:i.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Ln,flipSided:b.side===Qr,useDepthPacking:!!b.depthPacking,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionDerivatives:b.extensions&&b.extensions.derivatives,extensionFragDepth:b.extensions&&b.extensions.fragDepth,extensionDrawBuffers:b.extensions&&b.extensions.drawBuffers,extensionShaderTextureLOD:b.extensions&&b.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:b.customProgramCacheKey()}}function g(b){let M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(let T in b.defines)M.push(T),M.push(b.defines[T]);return b.isRawShaderMaterial===!1&&(y(M,b),v(M,b),M.push(i.outputEncoding)),M.push(b.customProgramCacheKey),M.join()}function y(b,M){b.push(M.precision),b.push(M.outputEncoding),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.combine),b.push(M.vertexUvs),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function v(b,M){a.disableAll(),M.isWebGL2&&a.enable(0),M.supportsVertexTextures&&a.enable(1),M.instancing&&a.enable(2),M.instancingColor&&a.enable(3),M.map&&a.enable(4),M.matcap&&a.enable(5),M.envMap&&a.enable(6),M.lightMap&&a.enable(7),M.aoMap&&a.enable(8),M.emissiveMap&&a.enable(9),M.bumpMap&&a.enable(10),M.normalMap&&a.enable(11),M.objectSpaceNormalMap&&a.enable(12),M.tangentSpaceNormalMap&&a.enable(13),M.clearcoat&&a.enable(14),M.clearcoatMap&&a.enable(15),M.clearcoatRoughnessMap&&a.enable(16),M.clearcoatNormalMap&&a.enable(17),M.iridescence&&a.enable(18),M.iridescenceMap&&a.enable(19),M.iridescenceThicknessMap&&a.enable(20),M.displacementMap&&a.enable(21),M.specularMap&&a.enable(22),M.roughnessMap&&a.enable(23),M.metalnessMap&&a.enable(24),M.gradientMap&&a.enable(25),M.alphaMap&&a.enable(26),M.alphaTest&&a.enable(27),M.vertexColors&&a.enable(28),M.vertexAlphas&&a.enable(29),M.vertexUvs&&a.enable(30),M.vertexTangents&&a.enable(31),M.uvsVertexOnly&&a.enable(32),b.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.skinning&&a.enable(4),M.morphTargets&&a.enable(5),M.morphNormals&&a.enable(6),M.morphColors&&a.enable(7),M.premultipliedAlpha&&a.enable(8),M.shadowMapEnabled&&a.enable(9),M.physicallyCorrectLights&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.specularIntensityMap&&a.enable(15),M.specularColorMap&&a.enable(16),M.transmission&&a.enable(17),M.transmissionMap&&a.enable(18),M.thicknessMap&&a.enable(19),M.sheen&&a.enable(20),M.sheenColorMap&&a.enable(21),M.sheenRoughnessMap&&a.enable(22),M.decodeVideoTexture&&a.enable(23),M.opaque&&a.enable(24),b.push(a.mask)}function x(b){let M=p[b.type],T;if(M){let C=Hs[M];T=vs.clone(C.uniforms)}else T=b.uniforms;return T}function w(b,M){let T;for(let C=0,P=u.length;C0?r.push(y):f.transparent===!0?n.push(y):e.push(y)}function l(h,d,f,p,m,g){let y=o(h,d,f,p,m,g);f.transmission>0?r.unshift(y):f.transparent===!0?n.unshift(y):e.unshift(y)}function u(h,d){e.length>1&&e.sort(h||rz),r.length>1&&r.sort(d||ME),n.length>1&&n.sort(d||ME)}function c(){for(let h=t,d=i.length;h=s.length?(o=new TE,s.push(o)):o=s[n],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function iz(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new _,color:new Re};break;case"SpotLight":e={position:new _,direction:new _,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new _,color:new Re,distance:0,decay:0};break;case"HemisphereLight":e={direction:new _,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":e={color:new Re,position:new _,halfWidth:new _,halfHeight:new _};break}return i[t.id]=e,e}}}function sz(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new N,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var oz=0;function az(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function lz(i,t){let e=new iz,r=sz(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let c=0;c<9;c++)n.probe.push(new _);let s=new _,o=new ie,a=new ie;function l(c,h){let d=0,f=0,p=0;for(let C=0;C<9;C++)n.probe[C].set(0,0,0);let m=0,g=0,y=0,v=0,x=0,w=0,S=0,A=0,E=0,b=0;c.sort(az);let M=h!==!0?Math.PI:1;for(let C=0,P=c.length;C0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=we.LTC_FLOAT_1,n.rectAreaLTC2=we.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(n.rectAreaLTC1=we.LTC_HALF_1,n.rectAreaLTC2=we.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),n.ambient[0]=d,n.ambient[1]=f,n.ambient[2]=p;let T=n.hash;(T.directionalLength!==m||T.pointLength!==g||T.spotLength!==y||T.rectAreaLength!==v||T.hemiLength!==x||T.numDirectionalShadows!==w||T.numPointShadows!==S||T.numSpotShadows!==A||T.numSpotMaps!==E)&&(n.directional.length=m,n.spot.length=y,n.rectArea.length=v,n.point.length=g,n.hemi.length=x,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=A+E-b,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=b,T.directionalLength=m,T.pointLength=g,T.spotLength=y,T.rectAreaLength=v,T.hemiLength=x,T.numDirectionalShadows=w,T.numPointShadows=S,T.numSpotShadows=A,T.numSpotMaps=E,n.version=oz++)}function u(c,h){let d=0,f=0,p=0,m=0,g=0,y=h.matrixWorldInverse;for(let v=0,x=c.length;v=a.length?(l=new CE(i,t),a.push(l)):l=a[o],l}function n(){e=new WeakMap}return{get:r,dispose:n}}var Bf=class extends Gl{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=vn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Cb=class extends Gl{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new _,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},uz=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,hz=`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 dz(i,t,e){let r=new Nf,n=new N,s=new N,o=new Xe,a=new Bf({depthPacking:Jb}),l=new Cb,u={},c=e.maxTextureSize,h={[Pi]:Qr,[Qr]:Pi,[Ln]:Ln},d=new at({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new N},radius:{value:4}},vertexShader:uz,fragmentShader:hz}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new Ae;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new _r(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ng,this.render=function(w,S,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let E=i.getRenderTarget(),b=i.getActiveCubeFace(),M=i.getActiveMipmapLevel(),T=i.state;T.setBlending(Vt),T.buffers.color.setClear(1,1,1,1),T.buffers.depth.setTest(!0),T.setScissorTest(!1);for(let C=0,P=w.length;Cc||n.y>c)&&(n.x>c&&(s.x=Math.floor(c/R.x),n.x=s.x*R.x,I.mapSize.x=s.x),n.y>c&&(s.y=Math.floor(c/R.y),n.y=s.y*R.y,I.mapSize.y=s.y)),I.map===null){let F=this.type!==Ef?{minFilter:kt,magFilter:kt}:{};I.map=new ht(n.x,n.y,F),I.map.texture.name=D.name+".shadowMap",I.camera.updateProjectionMatrix()}i.setRenderTarget(I.map),i.clear();let U=I.getViewportCount();for(let F=0;F0||S.map&&S.alphaTest>0){let P=T.uuid,D=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let R=I[D];R===void 0&&(R=T.clone(),I[D]=R),T=R}return T.visible=S.visible,T.wireframe=S.wireframe,M===Ef?T.side=S.shadowSide!==null?S.shadowSide:S.side:T.side=S.shadowSide!==null?S.shadowSide:h[S.side],T.alphaMap=S.alphaMap,T.alphaTest=S.alphaTest,T.map=S.map,T.clipShadows=S.clipShadows,T.clippingPlanes=S.clippingPlanes,T.clipIntersection=S.clipIntersection,T.displacementMap=S.displacementMap,T.displacementScale=S.displacementScale,T.displacementBias=S.displacementBias,T.wireframeLinewidth=S.wireframeLinewidth,T.linewidth=S.linewidth,A.isPointLight===!0&&T.isMeshDistanceMaterial===!0&&(T.referencePosition.setFromMatrixPosition(A.matrixWorld),T.nearDistance=E,T.farDistance=b),T}function x(w,S,A,E,b){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===Ef)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,w.matrixWorld);let C=t.update(w),P=w.material;if(Array.isArray(P)){let D=C.groups;for(let I=0,R=D.length;I=1):V.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),U=F>=2);let G=null,H={},Y=i.getParameter(3088),k=i.getParameter(2978),j=new Xe().fromArray(Y),X=new Xe().fromArray(k);function q(Q,ce,ve){let Ve=new Uint8Array(4),Fe=i.createTexture();i.bindTexture(Q,Fe),i.texParameteri(Q,10241,9728),i.texParameteri(Q,10240,9728);for(let Et=0;Et"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(L,O){return y?new OffscreenCanvas(L,O):fg("canvas")}function x(L,O,re,ue){let me=1;if((L.width>ue||L.height>ue)&&(me=ue/Math.max(L.width,L.height)),me<1||O===!0)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap){let De=O?dg:Math.floor,Te=De(me*L.width),Ee=De(me*L.height);m===void 0&&(m=v(Te,Ee));let le=re?v(Te,Ee):m;return le.width=Te,le.height=Ee,le.getContext("2d").drawImage(L,0,0,Te,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+L.width+"x"+L.height+") to ("+Te+"x"+Ee+")."),le}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+L.width+"x"+L.height+")."),L;return L}function w(L){return xb(L.width)&&xb(L.height)}function S(L){return a?!1:L.wrapS!==sr||L.wrapT!==sr||L.minFilter!==kt&&L.minFilter!==Je}function A(L,O){return L.generateMipmaps&&O&&L.minFilter!==kt&&L.minFilter!==Je}function E(L){i.generateMipmap(L)}function b(L,O,re,ue,me=!1){if(a===!1)return O;if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let De=O;return O===6403&&(re===5126&&(De=33326),re===5131&&(De=33325),re===5121&&(De=33321)),O===33319&&(re===5126&&(De=33328),re===5131&&(De=33327),re===5121&&(De=33323)),O===6408&&(re===5126&&(De=34836),re===5131&&(De=34842),re===5121&&(De=ue===et&&me===!1?35907:32856),re===32819&&(De=32854),re===32820&&(De=32855)),(De===33325||De===33326||De===33327||De===33328||De===34842||De===34836)&&t.get("EXT_color_buffer_float"),De}function M(L,O,re){return A(L,re)===!0||L.isFramebufferTexture&&L.minFilter!==kt&&L.minFilter!==Je?Math.log2(Math.max(O.width,O.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?O.mipmaps.length:1}function T(L){return L===kt||L===M_||L===Dx?9728:9729}function C(L){let O=L.target;O.removeEventListener("dispose",C),D(O),O.isVideoTexture&&p.delete(O)}function P(L){let O=L.target;O.removeEventListener("dispose",P),R(O)}function D(L){let O=r.get(L);if(O.__webglInit===void 0)return;let re=L.source,ue=g.get(re);if(ue){let me=ue[O.__cacheKey];me.usedTimes--,me.usedTimes===0&&I(L),Object.keys(ue).length===0&&g.delete(re)}r.remove(L)}function I(L){let O=r.get(L);i.deleteTexture(O.__webglTexture);let re=L.source,ue=g.get(re);delete ue[O.__cacheKey],o.memory.textures--}function R(L){let O=L.texture,re=r.get(L),ue=r.get(O);if(ue.__webglTexture!==void 0&&(i.deleteTexture(ue.__webglTexture),o.memory.textures--),L.depthTexture&&L.depthTexture.dispose(),L.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)i.deleteFramebuffer(re.__webglFramebuffer[me]),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer[me]);else{if(i.deleteFramebuffer(re.__webglFramebuffer),re.__webglDepthbuffer&&i.deleteRenderbuffer(re.__webglDepthbuffer),re.__webglMultisampledFramebuffer&&i.deleteFramebuffer(re.__webglMultisampledFramebuffer),re.__webglColorRenderbuffer)for(let me=0;me=l&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+l),U+=1,L}function G(L){let O=[];return O.push(L.wrapS),O.push(L.wrapT),O.push(L.wrapR||0),O.push(L.magFilter),O.push(L.minFilter),O.push(L.anisotropy),O.push(L.internalFormat),O.push(L.format),O.push(L.type),O.push(L.generateMipmaps),O.push(L.premultiplyAlpha),O.push(L.flipY),O.push(L.unpackAlignment),O.push(L.encoding),O.join()}function H(L,O){let re=r.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&re.__version!==L.version){let ue=L.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(re,L,O);return}}e.bindTexture(3553,re.__webglTexture,33984+O)}function Y(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(35866,re.__webglTexture,33984+O)}function k(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){Z(re,L,O);return}e.bindTexture(32879,re.__webglTexture,33984+O)}function j(L,O){let re=r.get(L);if(L.version>0&&re.__version!==L.version){K(re,L,O);return}e.bindTexture(34067,re.__webglTexture,33984+O)}let X={[ms]:10497,[sr]:33071,[gb]:33648},q={[kt]:9728,[M_]:9984,[Dx]:9986,[Je]:9729,[iN]:9985,[Ul]:9987};function z(L,O,re){if(re?(i.texParameteri(L,10242,X[O.wrapS]),i.texParameteri(L,10243,X[O.wrapT]),(L===32879||L===35866)&&i.texParameteri(L,32882,X[O.wrapR]),i.texParameteri(L,10240,q[O.magFilter]),i.texParameteri(L,10241,q[O.minFilter])):(i.texParameteri(L,10242,33071),i.texParameteri(L,10243,33071),(L===32879||L===35866)&&i.texParameteri(L,32882,33071),(O.wrapS!==sr||O.wrapT!==sr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(L,10240,T(O.magFilter)),i.texParameteri(L,10241,T(O.minFilter)),O.minFilter!==kt&&O.minFilter!==Je&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let ue=t.get("EXT_texture_filter_anisotropic");if(O.magFilter===kt||O.minFilter!==Dx&&O.minFilter!==Ul||O.type===Xr&&t.has("OES_texture_float_linear")===!1||a===!1&&O.type===Go&&t.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(i.texParameterf(L,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,n.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function J(L,O){let re=!1;L.__webglInit===void 0&&(L.__webglInit=!0,O.addEventListener("dispose",C));let ue=O.source,me=g.get(ue);me===void 0&&(me={},g.set(ue,me));let De=G(O);if(De!==L.__cacheKey){me[De]===void 0&&(me[De]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,re=!0),me[De].usedTimes++;let Te=me[L.__cacheKey];Te!==void 0&&(me[L.__cacheKey].usedTimes--,Te.usedTimes===0&&I(O)),L.__cacheKey=De,L.__webglTexture=me[De].texture}return re}function Z(L,O,re){let ue=3553;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(ue=35866),O.isData3DTexture&&(ue=32879);let me=J(L,O),De=O.source;e.bindTexture(ue,L.__webglTexture,33984+re);let Te=r.get(De);if(De.version!==Te.__version||me===!0){e.activeTexture(33984+re),i.pixelStorei(37440,O.flipY),i.pixelStorei(37441,O.premultiplyAlpha),i.pixelStorei(3317,O.unpackAlignment),i.pixelStorei(37443,0);let Ee=S(O)&&w(O.image)===!1,le=x(O.image,Ee,!1,c);le=Ue(O,le);let Ke=w(le)||a,ke=s.convert(O.format,O.encoding),Ne=s.convert(O.type),We=b(O.internalFormat,ke,Ne,O.encoding,O.isVideoTexture);z(ue,O,Ke);let $e,_t=O.mipmaps,ir=a&&O.isVideoTexture!==!0,Gr=Te.__version===void 0||me===!0,Q=M(O,le,Ke);if(O.isDepthTexture)We=6402,a?O.type===Xr?We=36012:O.type===ps?We=33190:O.type===Ea?We=35056:We=33189:O.type===Xr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Vl&&We===6402&&O.type!==tM&&O.type!==ps&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=ps,Ne=s.convert(O.type)),O.format===Ca&&We===6402&&(We=34041,O.type!==Ea&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=Ea,Ne=s.convert(O.type))),Gr&&(ir?e.texStorage2D(3553,1,We,le.width,le.height):e.texImage2D(3553,0,We,le.width,le.height,0,ke,Ne,null));else if(O.isDataTexture)if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce>=1,ve>>=1}}else if(_t.length>0&&Ke){ir&&Gr&&e.texStorage2D(3553,Q,We,_t[0].width,_t[0].height);for(let ce=0,ve=_t.length;ce0&&Gr++,e.texStorage2D(34067,Gr,$e,le[0].width,le[0].height));for(let ce=0;ce<6;ce++)if(Ee){_t?e.texSubImage2D(34069+ce,0,0,0,le[ce].width,le[ce].height,Ne,We,le[ce].data):e.texImage2D(34069+ce,0,$e,le[ce].width,le[ce].height,0,Ne,We,le[ce].data);for(let ve=0;ve=34069&&me<=34074)&&i.framebufferTexture2D(36160,ue,me,r.get(re).__webglTexture,0),e.bindFramebuffer(36160,null)}function ye(L,O,re){if(i.bindRenderbuffer(36161,L),O.depthBuffer&&!O.stencilBuffer){let ue=33189;if(re||Me(O)){let me=O.depthTexture;me&&me.isDepthTexture&&(me.type===Xr?ue=36012:me.type===ps&&(ue=33190));let De=Pe(O);Me(O)?d.renderbufferStorageMultisampleEXT(36161,De,ue,O.width,O.height):i.renderbufferStorageMultisample(36161,De,ue,O.width,O.height)}else i.renderbufferStorage(36161,ue,O.width,O.height);i.framebufferRenderbuffer(36160,36096,36161,L)}else if(O.depthBuffer&&O.stencilBuffer){let ue=Pe(O);re&&Me(O)===!1?i.renderbufferStorageMultisample(36161,ue,35056,O.width,O.height):Me(O)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,O.width,O.height):i.renderbufferStorage(36161,34041,O.width,O.height),i.framebufferRenderbuffer(36160,33306,36161,L)}else{let ue=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let me=0;me0&&Me(L)===!1){let Ee=De?O:[O];re.__webglMultisampledFramebuffer=i.createFramebuffer(),re.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,re.__webglMultisampledFramebuffer);for(let le=0;le0&&Me(L)===!1){let O=L.isWebGLMultipleRenderTargets?L.texture:[L.texture],re=L.width,ue=L.height,me=16384,De=[],Te=L.stencilBuffer?33306:36096,Ee=r.get(L),le=L.isWebGLMultipleRenderTargets===!0;if(le)for(let Ke=0;Ke0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ze(L){let O=o.render.frame;p.get(L)!==O&&(p.set(L,O),L.update())}function Ue(L,O){let re=L.encoding,ue=L.format,me=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||L.format===vb||re!==Di&&(re===et?a===!1?t.has("EXT_sRGB")===!0&&ue===$n?(L.format=vb,L.minFilter=Je,L.generateMipmaps=!1):O=pg.sRGBToLinear(O):(ue!==$n||me!==lr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",re)),O}this.allocateTextureUnit=V,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=Y,this.setTexture3D=k,this.setTextureCube=j,this.rebindTextures=_e,this.setupRenderTarget=xe,this.updateRenderTargetMipmap=Oe,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=W,this.useMultisampledRTT=Me}function mz(i,t,e){let r=e.isWebGL2;function n(s,o=null){let a;if(s===lr)return 5121;if(s===lN)return 32819;if(s===cN)return 32820;if(s===sN)return 5120;if(s===oN)return 5122;if(s===tM)return 5123;if(s===aN)return 5124;if(s===ps)return 5125;if(s===Xr)return 5126;if(s===Go)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===uN)return 6406;if(s===$n)return 6408;if(s===hN)return 6409;if(s===dN)return 6410;if(s===Vl)return 6402;if(s===Ca)return 34041;if(s===vb)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===fN)return 6403;if(s===pN)return 36244;if(s===Pu)return 33319;if(s===mN)return 33320;if(s===Xb)return 36249;if(s===Ix||s===Ox||s===Rx||s===Lx)if(o===et)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ix)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ix)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ox)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Rx)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Lx)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===T_||s===C_||s===P_||s===D_)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===T_)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===C_)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===P_)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===D_)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===gN)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===I_||s===O_)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===I_)return o===et?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===O_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===R_||s===L_||s===N_||s===B_||s===F_||s===k_||s===V_||s===z_||s===U_||s===G_||s===H_||s===j_||s===W_||s===q_)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===R_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===L_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===N_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===B_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===F_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===k_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===V_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===z_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===U_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===G_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===H_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===j_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===W_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===q_)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Nx)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===Nx)return o===et?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===yN||s===Y_||s===X_||s===Q_)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===Nx)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Y_)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===X_)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Q_)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ea?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:n}}var Pb=class extends Ir{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},js=class extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}},gz={type:"move"},Pf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new js,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 js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new _,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new _),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new _,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new _),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let n=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(u&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(u,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,p=.005;u.inputState.pinching&&d>f+p?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!u.inputState.pinching&&d<=f-p&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(n=e.getPose(t.targetRaySpace,r),n===null&&s!==null&&(n=s),n!==null&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(gz)))}return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new js;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},Gi=class extends or{constructor(t,e,r,n,s,o,a,l,u,c){if(c=c!==void 0?c:Vl,c!==Vl&&c!==Ca)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&c===Vl&&(r=ps),r===void 0&&c===Ca&&(r=Ea),super(null,n,s,o,a,l,c,r,u),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:kt,this.minFilter=l!==void 0?l:kt,this.flipY=!1,this.generateMipmaps=!1}},Db=class extends Yt{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,u=null,c=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],w=new Set,S=new Map,A=new Ir;A.layers.enable(1),A.viewport=new Xe;let E=new Ir;E.layers.enable(2),E.viewport=new Xe;let b=[A,E],M=new Pb;M.layers.enable(1),M.layers.enable(2);let T=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let j=v[k];return j===void 0&&(j=new Pf,v[k]=j),j.getTargetRaySpace()},this.getControllerGrip=function(k){let j=v[k];return j===void 0&&(j=new Pf,v[k]=j),j.getGripSpace()},this.getHand=function(k){let j=v[k];return j===void 0&&(j=new Pf,v[k]=j),j.getHandSpace()};function P(k){let j=x.indexOf(k.inputSource);if(j===-1)return;let X=v[j];X!==void 0&&X.dispatchEvent({type:k.type,data:k.inputSource})}function D(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",I);for(let k=0;k=0&&(x[q]=null,v[q].disconnect(X))}for(let j=0;j=x.length){x.push(X),q=J;break}else if(x[J]===null){x[J]=X,q=J;break}if(q===-1)break}let z=v[q];z&&z.connect(X)}}let R=new _,U=new _;function F(k,j,X){R.setFromMatrixPosition(j.matrixWorld),U.setFromMatrixPosition(X.matrixWorld);let q=R.distanceTo(U),z=j.projectionMatrix.elements,J=X.projectionMatrix.elements,Z=z[14]/(z[10]-1),K=z[14]/(z[10]+1),W=(z[9]+1)/z[5],ye=(z[9]-1)/z[5],fe=(z[8]-1)/z[0],se=(J[8]+1)/J[0],_e=Z*fe,xe=Z*se,Oe=q/(-fe+se),Ie=Oe*-fe;j.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(Ie),k.translateZ(Oe),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();let Pe=Z+Oe,Me=K+Oe,ze=_e-Ie,Ue=xe+(q-Ie),L=W*K/Me*Pe,O=ye*K/Me*Pe;k.projectionMatrix.makePerspective(ze,Ue,L,O,Pe,Me)}function V(k,j){j===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(j.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(n===null)return;M.near=E.near=A.near=k.near,M.far=E.far=A.far=k.far,(T!==M.near||C!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,C=M.far);let j=k.parent,X=M.cameras;V(M,j);for(let z=0;zz&&(S.set(q,q.lastChangedTime),r.dispatchEvent({type:"planechanged",data:q}))}}p=null}let Y=new aM;Y.setAnimationLoop(H),this.setAnimationLoop=function(k){G=k},this.dispose=function(){}}};function yz(i,t){function e(m,g){g.color.getRGB(m.fogColor.value,oM(i)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?n(m,g):g.isMeshToonMaterial?(n(m,g),c(m,g)):g.isMeshPhongMaterial?(n(m,g),u(m,g)):g.isMeshStandardMaterial?(n(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(n(m,g),f(m,g)):g.isMeshDepthMaterial?n(m,g):g.isMeshDistanceMaterial?(n(m,g),p(m,g)):g.isMeshNormalMaterial?n(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function n(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===Qr&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===Qr&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let w=i.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function c(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Qr&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function vz(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(35375):0;function l(v,x){let w=x.program;r.uniformBlockBinding(v,w)}function u(v,x){let w=n[v.id];w===void 0&&(p(v),w=c(v),n[v.id]=w,v.addEventListener("dispose",g));let S=x.program;r.updateUBOMapping(v,S);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function c(v){let x=h();v.__bindingPointIndex=x;let w=i.createBuffer(),S=v.__size,A=v.usage;return i.bindBuffer(35345,w),i.bufferData(35345,S,A),i.bindBuffer(35345,null),i.bindBufferBase(35345,x,w),w}function h(){for(let v=0;v0){A=w%S;let P=S-A;A!==0&&P-T.boundary<0&&(w+=S-A,M.__offset=w)}w+=T.storage}return A=w%S,A>0&&(w+=S-A),v.__size=w,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let w=o.indexOf(x.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function y(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:u,dispose:y}}function xz(){let i=fg("canvas");return i.style.display="block",i}function tw(i={}){this.isWebGLRenderer=!0;let t=i.canvas!==void 0?i.canvas:xz(),e=i.context!==void 0?i.context:null,r=i.depth!==void 0?i.depth:!0,n=i.stencil!==void 0?i.stencil:!0,s=i.antialias!==void 0?i.antialias:!1,o=i.premultipliedAlpha!==void 0?i.premultipliedAlpha:!0,a=i.preserveDrawingBuffer!==void 0?i.preserveDrawingBuffer:!1,l=i.powerPreference!==void 0?i.powerPreference:"default",u=i.failIfMajorPerformanceCaveat!==void 0?i.failIfMajorPerformanceCaveat:!1,c;e!==null?c=e.getContextAttributes().alpha:c=i.alpha!==void 0?i.alpha:!1;let h=null,d=null,f=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Di,this.physicallyCorrectLights=!1,this.toneMapping=Uo,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,w=-1,S=null,A=new Xe,E=new Xe,b=null,M=t.width,T=t.height,C=1,P=null,D=null,I=new Xe(0,0,M,T),R=new Xe(0,0,M,T),U=!1,F=new Nf,V=!1,G=!1,H=null,Y=new ie,k=new N,j=new _,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return x===null?C:1}let z=e;function J(B,te){for(let he=0;he0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Hr(B,te,he,ee){if(B.visible===!1)return;if(B.layers.test(te.layers)){if(B.isGroup)he=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(te);else if(B.isLight)d.pushLight(B),B.castShadow&&d.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||F.intersectsSprite(B)){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;mt.visible&&h.push(B,dt,mt,he,j.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(B.isSkinnedMesh&&B.skeleton.frame!==ye.render.frame&&(B.skeleton.update(),B.skeleton.frame=ye.render.frame),!B.frustumCulled||F.intersectsObject(B))){ee&&j.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Y);let dt=Pe.update(B),mt=B.material;if(Array.isArray(mt)){let xt=dt.groups;for(let Lt=0,Mt=xt.length;Lt0&&Dl(pe,te,he),ee&&W.viewport(A.copy(ee)),pe.length>0&&hr(pe,te,he),st.length>0&&hr(st,te,he),dt.length>0&&hr(dt,te,he),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Dl(B,te,he){let ee=K.isWebGL2;H===null&&(H=new ht(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?Go:lr,minFilter:Ul,samples:ee&&s===!0?4:0})),m.getDrawingBufferSize(k),ee?H.setSize(k.x,k.y):H.setSize(dg(k.x),dg(k.y));let pe=m.getRenderTarget();m.setRenderTarget(H),m.clear();let st=m.toneMapping;m.toneMapping=Uo,hr(B,te,he),m.toneMapping=st,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),m.setRenderTarget(pe)}function hr(B,te,he){let ee=te.isScene===!0?te.overrideMaterial:null;for(let pe=0,st=B.length;pe0&&se.useMultisampledRTT(B)===!1?pe=fe.get(B).__webglMultisampledFramebuffer:pe=Mt,A.copy(B.viewport),E.copy(B.scissor),b=B.scissorTest}else A.copy(I).multiplyScalar(C).floor(),E.copy(R).multiplyScalar(C).floor(),b=U;if(W.bindFramebuffer(36160,pe)&&K.drawBuffers&&ee&&W.drawBuffers(B,pe),W.viewport(A),W.scissor(E),W.setScissorTest(b),st){let xt=fe.get(B.texture);z.framebufferTexture2D(36160,36064,34069+te,xt.__webglTexture,he)}else if(dt){let xt=fe.get(B.texture),Lt=te||0;z.framebufferTextureLayer(36160,36064,xt.__webglTexture,he||0,Lt)}w=-1},this.readRenderTargetPixels=function(B,te,he,ee,pe,st,dt){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let mt=fe.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&dt!==void 0&&(mt=mt[dt]),mt){W.bindFramebuffer(36160,mt);try{let xt=B.texture,Lt=xt.format,Mt=xt.type;if(Lt!==$n&&Ee.convert(Lt)!==z.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Tt=Mt===Go&&(Z.has("EXT_color_buffer_half_float")||K.isWebGL2&&Z.has("EXT_color_buffer_float"));if(Mt!==lr&&Ee.convert(Mt)!==z.getParameter(35738)&&!(Mt===Xr&&(K.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!Tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}te>=0&&te<=B.width-ee&&he>=0&&he<=B.height-pe&&z.readPixels(te,he,ee,pe,Ee.convert(Lt),Ee.convert(Mt),st)}finally{let xt=x!==null?fe.get(x).__webglFramebuffer:null;W.bindFramebuffer(36160,xt)}}},this.copyFramebufferToTexture=function(B,te,he=0){let ee=Math.pow(2,-he),pe=Math.floor(te.image.width*ee),st=Math.floor(te.image.height*ee);se.setTexture2D(te,0),z.copyTexSubImage2D(3553,he,0,0,B.x,B.y,pe,st),W.unbindTexture()},this.copyTextureToTexture=function(B,te,he,ee=0){let pe=te.image.width,st=te.image.height,dt=Ee.convert(he.format),mt=Ee.convert(he.type);se.setTexture2D(he,0),z.pixelStorei(37440,he.flipY),z.pixelStorei(37441,he.premultiplyAlpha),z.pixelStorei(3317,he.unpackAlignment),te.isDataTexture?z.texSubImage2D(3553,ee,B.x,B.y,pe,st,dt,mt,te.image.data):te.isCompressedTexture?z.compressedTexSubImage2D(3553,ee,B.x,B.y,te.mipmaps[0].width,te.mipmaps[0].height,dt,te.mipmaps[0].data):z.texSubImage2D(3553,ee,B.x,B.y,dt,mt,te.image),ee===0&&he.generateMipmaps&&z.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(B,te,he,ee,pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let st=B.max.x-B.min.x+1,dt=B.max.y-B.min.y+1,mt=B.max.z-B.min.z+1,xt=Ee.convert(ee.format),Lt=Ee.convert(ee.type),Mt;if(ee.isData3DTexture)se.setTexture3D(ee,0),Mt=32879;else if(ee.isDataArrayTexture)se.setTexture2DArray(ee,0),Mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(37440,ee.flipY),z.pixelStorei(37441,ee.premultiplyAlpha),z.pixelStorei(3317,ee.unpackAlignment);let Tt=z.getParameter(3314),jr=z.getParameter(32878),Ei=z.getParameter(3316),Oo=z.getParameter(3315),Il=z.getParameter(32877),Wr=he.isCompressedTexture?he.mipmaps[0]:he.image;z.pixelStorei(3314,Wr.width),z.pixelStorei(32878,Wr.height),z.pixelStorei(3316,B.min.x),z.pixelStorei(3315,B.min.y),z.pixelStorei(32877,B.min.z),he.isDataTexture||he.isData3DTexture?z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr.data):he.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Wr.data)):z.texSubImage3D(Mt,pe,te.x,te.y,te.z,st,dt,mt,xt,Lt,Wr),z.pixelStorei(3314,Tt),z.pixelStorei(32878,jr),z.pixelStorei(3316,Ei),z.pixelStorei(3315,Oo),z.pixelStorei(32877,Il),pe===0&&ee.generateMipmaps&&z.generateMipmap(Mt),W.unbindTexture()},this.initTexture=function(B){B.isCubeTexture?se.setTextureCube(B,0):B.isData3DTexture?se.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?se.setTexture2DArray(B,0):se.setTexture2D(B,0),W.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,W.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Ib=class extends tw{};Ib.prototype.isWebGL1Renderer=!0;var cu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new Re(t),this.near=e,this.far=r}clone(){return new cu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Nn=class extends gt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},wg=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=yb,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,s=this.stride;nl)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);bt.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,w=v-1;xl)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);At.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var ji=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,u;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),u=r[n]-o,u<0)a=n+1;else if(u>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let c=r[n],d=r[n+1]-c,f=(o-c)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new N:new _);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new _,n=[],s=[],o=[],a=new _,l=new ie;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new _)}s[0]=new _,o[0]=new _;let u=Number.MAX_VALUE,c=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);c<=u&&(u=c,r.set(1,0,0)),h<=u&&(u=h,r.set(0,1,0)),d<=u&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Yr(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(Yr(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Wl=class extends ji{constructor(t=0,e=0,r=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new N,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)n;)s-=n;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=n[(a-1)%s]:(tg.subVectors(n[0],n[1]).add(n[0]),u=tg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(NE(a,l.x,u.x,c.x,h.x),NE(a,l.y,u.y,c.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let r=0,n=this.curves.length;r1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},du=class extends Ae{constructor(t=[new N(0,-.5),new N(.5,0),new N(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=Yr(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/e,h=new _,d=new N,f=new _,p=new _,m=new _,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*c*n,w=Math.sin(x),S=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*w,h.y=t[A].y,h.z=t[A].x*S,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let E=l[3*A+0]*w,b=l[3*A+1],M=l[3*A+0]*S;u.push(E,b,M)}}for(let v=0;v0&&x(!0),e>0&&x(!1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function v(){let w=new _,S=new _,A=0,E=(e-t)/r;for(let b=0;b<=s;b++){let M=[],T=b/s,C=T*(e-t)+t;for(let P=0;P<=n;P++){let D=P/n,I=D*l+a,R=Math.sin(I),U=Math.cos(I);S.x=C*R,S.y=-T*r+g,S.z=C*U,h.push(S.x,S.y,S.z),w.set(R,E,U).normalize(),d.push(w.x,w.y,w.z),f.push(D,1-T),M.push(p++)}m.push(M)}for(let b=0;b.9&&E<.1&&(x<.2&&(o[v+0]+=1),w<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let w=v*3;x.x=t[w+0],x.y=t[w+1],x.z=t[w+2]}function p(){let v=new _,x=new _,w=new _,S=new _,A=new N,E=new N,b=new N;for(let M=0,T=0;M80*e){a=u=i[0],l=c=i[1];for(let p=e;pu&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?32767/f:0}return zf(s,o,e,a,l,f,0),o}};function dM(i,t,e,r,n){let s,o;if(n===Wz(i,t,e,r)>0)for(s=t;s=t;s-=r)o=BE(s,i[s],i[s+1],o);return o&&Fg(o,o.next)&&(Gf(o),o=o.next),o}function Ql(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(Fg(e,e.next)||vr(e.prev,e,e.next)===0)){if(Gf(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function zf(i,t,e,r,n,s,o){if(!i)return;!o&&s&&Vz(i,r,n,s);let a=i,l,u;for(;i.prev!==i.next;){if(l=i.prev,u=i.next,s?Iz(i,r,n,s):Dz(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(u.i/e|0),Gf(i),i=u.next,a=u.next;continue}if(i=u,i===a){o?o===1?(i=Oz(Ql(i),t,e),zf(i,t,e,r,n,s,2)):o===2&&Rz(i,t,e,r,n,s):zf(Ql(i),t,e,r,n,s,1);break}}}function Dz(i){let t=i.prev,e=i,r=i.next;if(vr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,u=r.y,c=ns?n>o?n:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u,p=r.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&iu(n,a,s,l,o,u,p.x,p.y)&&vr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Iz(i,t,e,r){let n=i.prev,s=i,o=i.next;if(vr(n,s,o)>=0)return!1;let a=n.x,l=s.x,u=o.x,c=n.y,h=s.y,d=o.y,f=al?a>u?a:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,y=Nb(f,p,t,e,r),v=Nb(m,g,t,e,r),x=i.prevZ,w=i.nextZ;for(;x&&x.z>=y&&w&&w.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==n&&x!==o&&iu(a,c,l,h,u,d,x.x,x.y)&&vr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=v;){if(w.x>=f&&w.x<=m&&w.y>=p&&w.y<=g&&w!==n&&w!==o&&iu(a,c,l,h,u,d,w.x,w.y)&&vr(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Oz(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!Fg(n,s)&&fM(n,r,r.next,s)&&Uf(n,s)&&Uf(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Gf(r),Gf(r.next),r=i=s),r=r.next}while(r!==i);return Ql(r)}function Rz(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Gz(o,a)){let l=pM(o,a);o=Ql(o,o.next),l=Ql(l,l.next),zf(o,t,e,r,n,s,0),zf(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function Lz(i,t,e,r){let n=[],s,o,a,l,u;for(s=0,o=t.length;s=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x=e.x&&e.x>=l&&s!==e.x&&iu(on.x||e.x===n.x&&kz(n,e)))&&(n=e,c=h)),e=e.next;while(e!==a);return n}function kz(i,t){return vr(i.prev,i,t.prev)<0&&vr(t.next,i,i.next)<0}function Vz(i,t,e,r){let n=i;do n.z===0&&(n.z=Nb(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,zz(n)}function zz(i){let t,e,r,n,s,o,a,l,u=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,u*=2}while(o>1);return i}function Nb(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Uz(i){let t=i,e=i;do(t.x=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function Gz(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Hz(i,t)&&(Uf(i,t)&&Uf(t,i)&&jz(i,t)&&(vr(i.prev,i,t.prev)||vr(i,t.prev,t))||Fg(i,t)&&vr(i.prev,i,i.next)>0&&vr(t.prev,t,t.next)>0)}function vr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Fg(i,t){return i.x===t.x&&i.y===t.y}function fM(i,t,e,r){let n=ng(vr(i,t,e)),s=ng(vr(i,t,r)),o=ng(vr(e,r,i)),a=ng(vr(e,r,t));return!!(n!==s&&o!==a||n===0&&rg(i,e,t)||s===0&&rg(i,r,t)||o===0&&rg(e,i,r)||a===0&&rg(e,t,r))}function rg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function ng(i){return i>0?1:i<0?-1:0}function Hz(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&fM(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Uf(i,t){return vr(i.prev,i,i.next)<0?vr(i,t,i.next)>=0&&vr(i,i.prev,t)>=0:vr(i,t,i.prev)<0||vr(i,i.next,t)<0}function jz(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function pM(i,t){let e=new Bb(i.i,i.x,i.y),r=new Bb(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function BE(i,t,e,r){let n=new Bb(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Gf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Bb(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Wz(i,t,e,r){let n=0;for(let s=t,o=e-r;s2&&i[t-1].equals(i[0])&&i.pop()}function kE(i,t){for(let e=0;e0)&&f.push(x,w,A),(y!==r-1||l=s)){let a=e[1];t=s)break t}o=r,r=0;break r}break e}for(;r>>1;te;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Aa(r,s,o),this.values=Aa(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,n=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(n!==void 0&&mM(n))for(let a=0,l=n.length;a!==l;++a){let u=n[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}return t}optimize(){let t=Aa(this.times),e=Aa(this.values),r=this.getValueSize(),n=this.getInterpolation()===Bx,s=t.length-1,o=1;for(let a=1;a0){t[o]=t[s];for(let a=s*r,l=o*r,u=0;u!==r;++u)e[l+u]=e[a+u];++o}return o!==t.length?(this.times=Aa(t,0,o),this.values=Aa(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Aa(this.times,0),e=Aa(this.values,0),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};Wi.prototype.TimeBufferType=Float32Array;Wi.prototype.ValueBufferType=Float32Array;Wi.prototype.DefaultInterpolation=ug;var Ia=class extends Wi{};Ia.prototype.ValueTypeName="bool";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=cg;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;var _g=class extends Wi{};_g.prototype.ValueTypeName="color";var bu=class extends Wi{};bu.prototype.ValueTypeName="number";var Vb=class extends xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),u=t*a;for(let c=u+a;u!==c;u+=4)He.slerpFlat(s,0,o,u-a,o,u,l);return s}},Zl=class extends Wi{InterpolantFactoryMethodLinear(t){return new Vb(this.times,this.values,this.getValueSize(),t)}};Zl.prototype.ValueTypeName="quaternion";Zl.prototype.DefaultInterpolation=ug;Zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Oa=class extends Wi{};Oa.prototype.ValueTypeName="string";Oa.prototype.ValueBufferType=Array;Oa.prototype.DefaultInterpolation=cg;Oa.prototype.InterpolantFactoryMethodLinear=void 0;Oa.prototype.InterpolantFactoryMethodSmooth=void 0;var wu=class extends Wi{};wu.prototype.ValueTypeName="vector";var Su=class{constructor(t,e=-1,r,n=Zb){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=Ui(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(Xz(r[o]).scale(n));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(Wi.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a1){let h=c[1],d=n[h];d||(n[h]=d=[]),d.push(u)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];gM(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,u=t.hierarchy||[];for(let h=0;h{e&&e(s),this.manager.itemEnd(t)},0),s;if(ko[t]!==void 0){ko[t].push({onLoad:e,onProgress:r,onError:n});return}ko[t]=[],ko[t].push({onLoad:e,onProgress:r,onError:n});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=ko[t],h=u.body.getReader(),d=u.headers.get("Content-Length")||u.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:w})=>{if(x)y.close();else{m+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,E=c.length;A{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(p=>f.decode(p))}}}).then(u=>{zE.add(t,u);let c=ko[t];delete ko[t];for(let h=0,d=c.length;h{let c=ko[t];if(c===void 0)throw this.manager.itemError(t),u;delete ko[t];for(let h=0,d=c.length;h{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var Ra=class extends gt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Re(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Eg=class extends Ra{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Re(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},hb=new ie,UE=new _,GE=new _,jf=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new N(512,512),this.map=null,this.mapPass=null,this.matrix=new ie,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nf,this._frameExtents=new N(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;UE.setFromMatrixPosition(t.matrixWorld),e.position.copy(UE),GE.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(GE),e.updateMatrixWorld(),hb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(hb)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Ub=class extends jf{constructor(){super(new Ir(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Rf*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Mg=class extends Ra{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ub}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},HE=new ie,_f=new _,db=new _,Gb=class extends jf{constructor(){super(new Ir(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new N(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new _(1,0,0),new _(-1,0,0),new _(0,0,1),new _(0,0,-1),new _(0,1,0),new _(0,-1,0)],this._cubeUps=[new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,1,0),new _(0,0,1),new _(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),_f.setFromMatrixPosition(t.matrixWorld),r.position.copy(_f),db.copy(r.position),db.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(db),r.updateMatrixWorld(),n.makeTranslation(-_f.x,-_f.y,-_f.z),HE.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HE)}},Tg=class extends Ra{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new Gb}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Hb=class extends jf{constructor(){super(new lu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Cg=class extends Ra{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new Hb}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Wf=class extends Ae{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Eu=class extends Au{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new _u(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=Nm(g.type,y),x=new wg(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new Wf:new Ae,a=t.data.index;if(a!==void 0){let f=Nm(a.type,a.array);o.setIndex(new Ge(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=n(t.data,p.data);m=new Hl(g,p.itemSize,p.offset,p.normalized)}else{let g=Nm(p.type,p.array),y=p.isInstancedBufferAttribute?uu:Ge;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let u=t.data.morphAttributes;if(u)for(let f in u){let p=u[f],m=[];for(let g=0,y=p.length;g"u"?Date:performance).now()}var jb=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,u=e+e;l!==u;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){He.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;He.multiplyQuaternionsFlat(t,o,t,e,t,r),He.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},nw="\\[\\]\\.:\\/",Kz=new RegExp("["+nw+"]","g"),iw="[^"+nw+"]",Zz="[^"+nw.replace("\\.","")+"]",Jz=/((?:WC+[\/:])*)/.source.replace("WC",iw),$z=/(WCOD+)?/.source.replace("WCOD",Zz),eU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",iw),tU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",iw),rU=new RegExp("^"+Jz+$z+eU+tU+"$"),nU=["material","materials","bones","map"],Wb=class{constructor(t,e,r){let n=r||Ft.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},Ft=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Ft.parseTrackName(e),this.node=Ft.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new Ft.Composite(t,e,r):new Ft(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Kz,"")}static parseTrackName(t){let e=rU.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);nU.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o0){let l=this._interpolants,u=this._propertyBindings;switch(this.blendMode){case vN:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulateAdditive(a);break;case Zb:default:for(let c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,n=this.time+t,s=this._loopCount,o=r===Yf;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Qb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let u=t<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=ru,n.endingEnd=ru):(t?n.endingStart=this.zeroSlopeAtStart?ru:tu:n.endingStart=hg,e?n.endingEnd=this.zeroSlopeAtEnd?ru:tu:n.endingEnd=hg)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},iU=new Float32Array(1),Dg=class extends Yt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,u=this._bindingsByRootAndName,c=u[l];c===void 0&&(c={},u[l]=c);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=c[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new jb(Ft.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let u=0;u!==r;++u)e[u]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let u=0;u!==l;++u)a[u].apply(o);return this}setTime(t){this.time=0;for(let e=0;ethis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return qE.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},YE=new _,sg=new _,nn=class{constructor(t=new _,e=new _){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){YE.subVectors(t,this.start),sg.subVectors(this.end,this.start);let r=sg.dot(sg),s=sg.dot(YE)/r;return e&&(s=Yr(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},XE=new _,Ig=class extends gt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ae,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o>-u-14,r[l|256]=1024>>-u-14|32768,n[l]=-u-1,n[l|256]=-u-1):u<=15?(r[l]=u+15<<10,r[l|256]=u+15<<10|32768,n[l]=13,n[l|256]=13):u<128?(r[l]=31744,r[l|256]=64512,n[l]=24,n[l|256]=24):(r[l]=31744,r[l|256]=64512,n[l]=13,n[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:n,mantissaTable:s,exponentTable:o,offsetTable:a}}function oU(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=Yr(i,-65504,65504),Vo.floatView[0]=i;let t=Vo.uint32View[0],e=t>>23&511;return Vo.baseTable[e]+((t&8388607)>>Vo.shiftTable[e])}function aU(i){let t=i>>10;return Vo.uint32View[0]=Vo.mantissaTable[Vo.offsetTable[t]+(i&1023)]+Vo.exponentTable[t],Vo.floatView[0]}var yM=Object.freeze({__proto__:null,fromHalfFloat:aU,toHalfFloat:oU});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qo);var Iu=".",Xf=Symbol("target"),sw=Symbol("unsubscribe");function Qf(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function vM(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Ri=Array.isArray;function Jl(i){return typeof i=="symbol"}var lU={after:(i,t)=>Ri(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Ri(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=Iu),Jl(t)?i+t.toString():i+t):i,initial:i=>{if(Ri(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?"":i.slice(0,t)},last:i=>{if(Ri(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(Iu);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Ri(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(Iu);if(r===-1)t(i);else for(;e{i&&(i=i[e])}),i}},ei=lU;function ow(i){return typeof i=="object"&&typeof i.next=="function"}function aw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[Xf].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function kg(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Jl(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Kf=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,ei.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,n,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Ou(i){return toString.call(i)==="[object Object]"}function Ru(){return!0}function Ba(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var Vg=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var cU=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),lw={push:Ru,pop:Ru,shift:Ru,unshift:Ru,copyWithin:Ba,reverse:Ba,sort:Ba,splice:Ba,flat:Ba,fill:Ba},xM=new Set([...Vg,...cU,...Object.keys(lw)]);function Lu(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var cw=["keys","values","entries"],uw=new Set(["has","toString"]),hw={add:Lu,clear:Lu,delete:Lu,forEach:Lu},bM=new Set([...uw,...Object.keys(hw),...cw]);function Nu(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var uU=new Set([...uw,"get"]),dw={set:Nu,clear:Nu,delete:Nu,forEach:Nu},wM=new Set([...uU,...Object.keys(dw),...cw]);var xn=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Vg.has(t)}_shallowClone(t){let e=t;if(Ou(t))e={...t};else if(Ri(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Ri(n)?this._onIsChanged=lw[e]:n instanceof Set?this._onIsChanged=hw[e]:n instanceof Map&&(this._onIsChanged=dw[e]),n):r}update(t,e,r){let n=ei.after(t,this._path);if(e!=="length"){let s=this.clone;ei.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],ei.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var Bu=class extends xn{static isHandledMethod(t){return xM.has(t)}};var Zf=class extends xn{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var Fu=class extends xn{static isHandledMethod(t){return bM.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var ku=class extends xn{static isHandledMethod(t){return wM.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Jf=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var $f=class extends xn{constructor(t,e,r,n){super(void 0,e,r,n),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var xs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return Ou(t)||Ri(t)||Qf(t)}static isHandledMethod(t,e){return Ou(t)?xn.isHandledMethod(e):Ri(t)?Bu.isHandledMethod(e):t instanceof Set?Fu.isHandledMethod(e):t instanceof Map?ku.isHandledMethod(e):Qf(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=xn;Ri(t)?n=Bu:t instanceof Date?n=Zf:t instanceof Set?n=Fu:t instanceof Map?n=ku:t instanceof WeakSet?n=Jf:t instanceof WeakMap&&(n=$f),this._stack.push(new n(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:n}=t,s=xs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var hU={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},fw=(i,t,e={})=>{e={...hU,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Kf(n),u=typeof e.onValidate=="function",c=new xs(u),h=(v,x,w,S,A)=>!u||c.isCloning||e.onValidate(ei.concat(l.getPath(v),x),w,S,A)===!0,d=(v,x,w,S)=>{!kg(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,w,S)},f=(v,x,w,S,A)=>{c.isCloning?c.update(v,x,S):t(ei.concat(v,x),w,S,A)},p=v=>v&&(v[r]||v),m=(v,x,w,S)=>vM(v)||w==="constructor"||s&&!xs.isHandledMethod(x,w)||kg(l,e,w)||l.isGetInvariant(x,w)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,ei.concat(S,w),g,r)),g={get(v,x,w){if(Jl(x)){if(x===r||x===Xf)return v;if(x===sw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Qf(v)?Reflect.get(v,x):Reflect.get(v,x,w);return m(S,v,x)},set(v,x,w,S){w=p(w);let A=v[r]||v,E=A[x];if(n(E,w)&&x in v)return!0;let b=h(v,x,w,E);return b&&l.setProperty(A,x,w,S,E)?(d(v,x,v[x],E),!0):!b},defineProperty(v,x,w){if(!l.isSameDescriptor(w,v,x)){let S=v[x];h(v,x,w.value,S)&&l.defineProperty(v,x,w,S)&&d(v,x,w.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let w=Reflect.get(v,x),S=h(v,x,void 0,w);return S&&l.deleteProperty(v,x,w)?(d(v,x,void 0,w),!0):!S},apply(v,x,w){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,w);if((a===!1||a!==!0&&!a.includes(v.name))&&xs.isHandledType(S)){let A=ei.initial(l.getPath(v)),E=xs.isHandledMethod(S,v.name);c.start(S,A,w);let b=Reflect.apply(v,c.preferredThisArg(v,x,S),E?w.map(C=>p(C)):w),M=c.isChanged(S,n),T=c.stop();if(xs.isHandledType(b)&&E&&(x instanceof Map&&v.name==="get"&&(A=ei.concat(A,w[0])),b=l.getProxy(b,A,g)),M){let C={name:v.name,args:w,result:b},P=c.isCloning?ei.initial(A):A,D=c.isCloning?ei.last(A):"";h(ei.get(i,P),D,S,T,C)?f(P,D,S,T,C):c.undo(S)}return(x instanceof Map||x instanceof Set)&&ow(b)?aw(b,v,x,A,m):b}return Reflect.apply(v,x,w)}},y=l.getProxy(i,e.pathAsArray?[]:"",g);return t=t.bind(y),u&&(e.onValidate=e.onValidate.bind(y)),y};fw.target=i=>i&&i[Xf]||i;fw.unsubscribe=i=>i[sw]||i;var pw=fw;var dU=typeof global=="object"&&global&&global.Object===Object&&global,zg=dU;var fU=typeof self=="object"&&self&&self.Object===Object&&self,pU=zg||fU||Function("return this")(),Er=pU;var mU=Er.Symbol,bn=mU;var SM=Object.prototype,gU=SM.hasOwnProperty,yU=SM.toString,ep=bn?bn.toStringTag:void 0;function vU(i){var t=gU.call(i,ep),e=i[ep];try{i[ep]=void 0;var r=!0}catch{}var n=yU.call(i);return r&&(t?i[ep]=e:delete i[ep]),n}var AM=vU;var xU=Object.prototype,bU=xU.toString;function wU(i){return bU.call(i)}var _M=wU;var SU="[object Null]",AU="[object Undefined]",EM=bn?bn.toStringTag:void 0;function _U(i){return i==null?i===void 0?AU:SU:EM&&EM in Object(i)?AM(i):_M(i)}var Li=_U;function EU(i){return i!=null&&typeof i=="object"}var Bn=EU;var MU="[object Symbol]";function TU(i){return typeof i=="symbol"||Bn(i)&&Li(i)==MU}var Fa=TU;function CU(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e0){if(++t>=dG)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var GM=mG;function gG(i){return function(){return i}}var HM=gG;var yG=function(){try{var i=ci(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Vu=yG;var vG=Vu?function(i,t){return Vu(i,"toString",{configurable:!0,enumerable:!1,value:HM(t),writable:!0})}:RM,jM=vG;var xG=GM(jM),WM=xG;function bG(i,t){for(var e=-1,r=i==null?0:i.length;++e-1&&i%1==0&&i-1&&i%1==0&&i<=IG}var Hu=OG;function RG(i){return i!=null&&Hu(i.length)&&!Gg(i)}var qg=RG;var LG=Object.prototype;function NG(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||LG;return i===e}var ju=NG;function BG(i,t){for(var e=-1,r=Array(i);++e-1}var yT=rH;function nH(i,t){var e=this.__data__,r=ka(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var vT=nH;function Qu(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t0&&e(a)?t>1?IT(a,t-1,e,r,n):Zu(n,a):r||(n[n.length]=a)}return n}var OT=IT;function EH(i){var t=i==null?0:i.length;return t?OT(i,1):[]}var RT=EH;function MH(i){return WM(XM(i,void 0,RT),i+"")}var Zg=MH;var TH=Qg(Object.getPrototypeOf,Object),Ju=TH;var CH="[object Object]",PH=Function.prototype,DH=Object.prototype,LT=PH.toString,IH=DH.hasOwnProperty,OH=LT.call(Object);function RH(i){if(!Bn(i)||Li(i)!=CH)return!1;var t=Ju(i);if(t===null)return!0;var e=IH.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&<.call(e)==OH}var NT=RH;function LH(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++ra))return!1;var u=s.get(i),c=s.get(t);if(u&&c)return u==t&&c==i;var h=-1,d=!0,f=e&Dj?new _C:void 0;for(s.set(i,t),s.set(t,i);++h=t||E<0||h&&b>=s}function y(){var A=uy();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),u=0,r=l=n=a=void 0}function w(){return a===void 0?o:v(uy())}function S(){var A=uy(),E=g(A);if(r=arguments,n=this,l=A,E){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return S.cancel=x,S.flush=w,S}var rc=lW;function cW(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var UC=cW;function uW(i,t){return t.length<2?i:Kg(i,BT(t,0,-1))}var GC=uW;function hW(i,t){return FC(i,t)}var np=hW;function dW(i,t){return t=Yi(t,i),i=GC(i,t),i==null||delete i[Ga(UC(t))]}var HC=dW;function fW(i){return NT(i)?void 0:i}var jC=fW;var pW=1,mW=2,gW=4,yW=Zg(function(i,t){var e={};if(i==null)return e;var r=!1;t=Ug(t,function(s){return s=Yi(s,i),r||(r=s.length>1),s}),qs(i,ty(i),e),r&&(e=oy(e,pW|mW|gW,jC));for(var n=t.length;n--;)HC(e,t[n]);return e}),ih=yW;function vW(i,t,e,r){if(!Kr(i))return i;t=Yi(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++ntypeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),EW=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),MW=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||nc&&"ontouchend"in document,TW=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,CW=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,PW=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},DW=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},IW=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},OW=_W(),Xse=OW?IW():void 0,nc=EW(),sh=MW(),QC=TW(),on=CW(),Sw=PW(),Aw=Number(DW());function hy(i){return Array.isArray(i)?i:[i]}function KC(i,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function ip(i){return nc?i.metaKey:i.ctrlKey}var qe=[],fy={},sp={},dy={};function ZC(i){qe.includes(i)||qe.push(i)}function oh(i){delete fy[i.pointerId];for(let t=0;t{nP=i});var gy;function sP(){if(gy)return gy;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@0.9.521/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});nP(l)}return gy=i(),gy}var oP,aP=new Promise(i=>{oP=i});var yy;function lP(){if(yy)return yy;async function i(){let e=await import("./physics.js");await e.init(),oP(e)}return yy=i(),yy}var rt=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,rt.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,rt.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,rt.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function op(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&op(r)}return Object.freeze(i)}function cP(i,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ah=class extends Error{};function vy(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function Ys(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;sc.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,pr.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:n,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(u=>u.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new ah("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:n},l=[...l,c],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>cP(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return Ys(0,n,n);{let o=s[0].fi;return Ys(o-n,o,n)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ys(l,l+n,n)}else return Ys(o.fi,a.fi,n)}}};var ch;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let u=n[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(ch||(ch={}));var Le=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Le.prototype)}deepFreeze(){let e=0;for(;eu.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,Le.prototype);let r=e;return uP()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(c=>c.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return Ys(0,r,r);{let s=n[0].fi;return Ys(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return Ys(a,a+r,r)}else return Ys(s.fi,o.fi,r)}}};function uh(i){return i&&typeof i=="object"&&i instanceof Jt}var Jt=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=vy(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let u=vy(l);u[t.path[n-1]]=r,r=u}else{let u=new Jt;u[t.path[n-1]]=r,r=u}}n-=1}let o=Object.setPrototypeOf(r,Jt.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},Xs;(r=>{function i(n,s){return ap(n,s)??n}r.apply=i;function t(n,s){return Ew(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o{let s=n.id,o=ap(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=_w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function RW(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=ap(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function ap(i,t){if(!uh(t))return t;if(i instanceof pr){let e=_w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Le)return RW(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=ap(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Jt)return Ew(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=ap(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Ew(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!uh(t))return t;if(!uh(i))return Xs.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new Jt;for(let n of e){let s=Ew(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function fP(i,t){let e={cur:[],result:[],len:0};return i=lp(i,t,e)??i,[i,e.result]}function xy(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function by(i){i&&(i.len-=1)}function LW(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function pP(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=lp(s.data,t,xy(e,o));by(e),r=r||l!==void 0,l===void 0&&(l=s.data);let u=pP(s.children,t,e);return u!==void 0?r=!0:u=s.children,{...s,id:o,data:l,children:u}});if(r)return n}function NW(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=lp(s.data,t,xy(e,o));return by(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function lp(i,t,e){if(i instanceof pr){let r=pP(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Le)return NW(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=lp(s,t,xy(e,o));return by(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!lh(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=lp(o,t,xy(e,s));by(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&LW(e),r}else return}}var wy;(t=>{function i(e,r){let n=Rr.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(wy||(wy={}));var Lr;(a=>{function i(l,u){return{...l,path:l.path.slice(u)}}a.drop=i;function t(l,u){return e(l,u)?.data??l}a.applySimple=t;function e(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Jt&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===c.length&&(l instanceof pr||l instanceof Le||l instanceof rt?d=l.runOp(u):d=ch.runOp(l,u)),d!==void 0)if(d!==null){let m=d.data;for(let g=h.length-1;g>=0;g--){let y=c[g],v=h[g];if(v instanceof pr){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Le){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof rt){if(typeof y=="number")throw new Error("illegal arg");m=v.modifyById(y,m)}else if(v instanceof Jt){let x={...v,[y]:m};m=Object.setPrototypeOf(x,Jt.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let x=m;m=[...v],m[y]=x}else m={...v,[y]:m};else return null}return{data:m,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],p;if(l instanceof pr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof Le){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,u){for(let c=0;cu.props[c]!==void 0):!1}a.subsumed=o})(Lr||(Lr={}));var cp;(l=>{function i(){return[]}l.empty=i;function t(u,c){let h=[];for(let d of u){let[f,...p]=d.path;f===c&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function n(u,c){return[...u.filter(d=>!c.some(f=>Lr.subsumed(d,f))),...c]}l.compress=n;function s(u,c){return u.every(h=>c.every(d=>Lr.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let p of c)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let m,g,y;if(p.type===3?(m=Rr.zoom(h,[...p.path,p.id]),y=Lr.apply(h,{...p,type:2})):(m=Rr.zoom(h,[...p.path,p.id,"value"]),y=Lr.apply(h,p)),y!==null){h=y.data;let[v,x]=fP(h,{[p.id]:m});h=v;for(let w=0;wE.includes(T)?p.id:M),m=b,A=S.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let E=m,b=Rr.zoom(h,S.slice(0,S.length-2)),M=b.layers.map(T=>T.id===S[S.length-1]?{...T,data:{...T.data,[A]:E}}:T);Object.setPrototypeOf(M,Object.getPrototypeOf(b.layers)),b.layers=M}g=p.id}d.push({type:0,path:S,props:{[A]:m}}),f.push({type:0,path:S,props:{[A]:g}})}f.push(y.reverse),d.push(y.actual)}}else{let m=Lr.apply(h,p);m!==null&&(d.push(m.actual),h=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ah)return null;throw m}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(cp||(cp={}));var mP=Symbol(),BW=Symbol(),Ay=Symbol(),ic=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Sy);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Ay];r&&r(),delete this._children[t]}}}},Tw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ch.runOp(this._current,t),t.path)}},Cw=class extends ic{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,rt.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},gP={get(i,t){if(t===Ay)return()=>{i._parent=null};if(t===mP)return i._current;if(t===BW)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=_y(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},FW={...gP,set(i,t,e){let r={type:0,props:{[t]:xr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},kW={...gP,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},hh=class extends ic{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Ay]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=_y(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Rr.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Sy=class extends ic{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){Mw(this.ts,e,t),Mw(this.actual,r,t),Mw(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function _y(i,t,e){return e instanceof pr?new hh(i,t,e):e instanceof Le?new dh(i,t,e):e instanceof rt?new Proxy(new Cw(i,t,e),kW):e!==null&&typeof e=="object"?lh(e)?e:new Proxy(new Tw(i,t,e),FW):e}function Pw(i){let t=new Sy(i);return[_y(t,"",i),t]}function Ha(i,t){let[e,r]=Pw(i);return t(e),r.result()}function xr(i){return i instanceof hh||i instanceof dh?i._current:i!==null&&typeof i=="object"?i[mP]:i}var Rr;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a{delete u[c]}),u}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof pr||s instanceof hh)&&typeof o=="string")return s.data(o);if((s instanceof Le||s instanceof dh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}n.zoomOnce=e;function r(s,o,a=0){for(;a(Ty(),this?this.unpack(t,e):Ks.prototype.unpack.call(vP,t,e)));Wa=e>-1?e:t.length,$=0,Rw=0,Qs=0,ja=null,Ow=EP,Bi=null,Be=t;try{Ht=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw Be=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Ks){if(hi=this,this.structures)return Nt=this.structures,My();(!Nt||Nt.length>0)&&(Nt=[])}else hi=vP,(!Nt||Nt.length>0)&&(Nt=[]);return My()}unpackMultiple(t,e){let r,n=0;try{fh=!0;let s=t.length,o=this?this.unpack(t,s):Dy.unpack(t,s);if(e){for(e(o);$=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function My(){try{if(!hi.trusted&&!fh){let t=Nt.sharedLength||0;tWa){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!fh)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Nt.restoreStructures&&xP(),Ty(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function xP(){for(let i in Nt.restoreStructures)Nt[i]=Nt.restoreStructures[i];Nt.restoreStructures=null}function Mr(){let i=Be[$++];if(i<160)if(i<128){if(i<64)return i;{let t=Nt[i&63]||hi.getStructures&&MP()[i&63];return t?(t.read||(t.read=Bw(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,hi.mapsAsObjects){let t={};for(let e=0;e=$)return ja.slice($-Xi,($+=t)-Xi);if(Qs==0&&Wa<140){let e=t<16?Fw(t):TP(t);if(e!=null)return e}return Lw(t)}else{let t;switch(i){case 192:return null;case 193:return Bi?(t=Mr(),t>0?Bi[1].slice(Bi.position1,Bi.position1+=t):Bi[0].slice(Bi.position0,Bi.position0-=t)):Nw;case 194:return!1;case 195:return!0;case 196:return Dw(Be[$++]);case 197:return t=Ht.getUint16($),$+=2,Dw(t);case 198:return t=Ht.getUint32($),$+=4,Dw(t);case 199:return sc(Be[$++]);case 200:return t=Ht.getUint16($),$+=2,sc(t);case 201:return t=Ht.getUint32($),$+=4,sc(t);case 202:if(t=Ht.getFloat32($),hi.useFloat32>2){let e=Py[(Be[$]&127)<<1|Be[$+1]>>7];return $+=4,(e*t+(t>0?.5:-.5)>>0)/e}return $+=4,t;case 203:return t=Ht.getFloat64($),$+=8,t;case 204:return Be[$++];case 205:return t=Ht.getUint16($),$+=2,t;case 206:return t=Ht.getUint32($),$+=4,t;case 207:return hi.int64AsNumber?(t=Ht.getUint32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigUint64($),$+=8,t;case 208:return Ht.getInt8($++);case 209:return t=Ht.getInt16($),$+=2,t;case 210:return t=Ht.getInt32($),$+=4,t;case 211:return hi.int64AsNumber?(t=Ht.getInt32($)*4294967296,t+=Ht.getUint32($+4)):t=Ht.getBigInt64($),$+=8,t;case 212:if(t=Be[$++],t==114)return _P(Be[$++]&63);{let e=ti[t];if(e)return e.read?($++,e.read(Mr())):e.noBuffer?($++,e()):e(Be.subarray($,++$));throw new Error("Unknown extension "+t)}case 213:return t=Be[$],t==114?($++,_P(Be[$++]&63,Be[$++])):sc(2);case 214:return sc(4);case 215:return sc(8);case 216:return sc(16);case 217:return t=Be[$++],Qs>=$?ja.slice($-Xi,($+=t)-Xi):zW(t);case 218:return t=Ht.getUint16($),$+=2,Qs>=$?ja.slice($-Xi,($+=t)-Xi):UW(t);case 219:return t=Ht.getUint32($),$+=4,Qs>=$?ja.slice($-Xi,($+=t)-Xi):GW(t);case 220:return t=Ht.getUint16($),$+=2,wP(t);case 221:return t=Ht.getUint32($),$+=4,wP(t);case 222:return t=Ht.getUint16($),$+=2,SP(t);case 223:return t=Ht.getUint32($),$+=4,SP(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var VW=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Bw(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>VW.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Mr);return i.highByte===0&&(i.read=bP(t,i.read)),n()}let r={};for(let n=0,s=i.length;nfunction(){let e=Be[$++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Nt[r]||MP()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=Bw(n,i)),n.read()};function MP(){let i=DP(()=>(Be=null,hi.getStructures()));return Nt=hi._mergeStructures(i,Nt)}var Lw=Cy,zW=Cy,UW=Cy,GW=Cy;function Cy(i){let t;if(i<16&&(t=Fw(i)))return t;if(i>64&&Iw)return Iw.decode(Be.subarray($,$+=i));let e=$+i,r=[];for(t="";$65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=Sn.apply(String,r),r.length=0)}return r.length>0&&(t+=Sn.apply(String,r)),t}function wP(i){let t=new Array(i);for(let e=0;e0){$=t;return}e[r]=n}return Sn.apply(String,e)}function Fw(i){if(i<4)if(i<2){if(i===0)return"";{let t=Be[$++];if((t&128)>1){$-=1;return}return Sn(t)}}else{let t=Be[$++],e=Be[$++];if((t&128)>0||(e&128)>0){$-=2;return}if(i<3)return Sn(t,e);let r=Be[$++];if((r&128)>0){$-=3;return}return Sn(t,e,r)}else{let t=Be[$++],e=Be[$++],r=Be[$++],n=Be[$++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){$-=4;return}if(i<6){if(i===4)return Sn(t,e,r,n);{let s=Be[$++];if((s&128)>0){$-=5;return}return Sn(t,e,r,n,s)}}else if(i<8){let s=Be[$++],o=Be[$++];if((s&128)>0||(o&128)>0){$-=6;return}if(i<7)return Sn(t,e,r,n,s,o);let a=Be[$++];if((a&128)>0){$-=7;return}return Sn(t,e,r,n,s,o,a)}else{let s=Be[$++],o=Be[$++],a=Be[$++],l=Be[$++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){$-=8;return}if(i<10){if(i===8)return Sn(t,e,r,n,s,o,a,l);{let u=Be[$++];if((u&128)>0){$-=9;return}return Sn(t,e,r,n,s,o,a,l,u)}}else if(i<12){let u=Be[$++],c=Be[$++];if((u&128)>0||(c&128)>0){$-=10;return}if(i<11)return Sn(t,e,r,n,s,o,a,l,u,c);let h=Be[$++];if((h&128)>0){$-=11;return}return Sn(t,e,r,n,s,o,a,l,u,c,h)}else{let u=Be[$++],c=Be[$++],h=Be[$++],d=Be[$++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){$-=12;return}if(i<14){if(i===12)return Sn(t,e,r,n,s,o,a,l,u,c,h,d);{let f=Be[$++];if((f&128)>0){$-=13;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f)}}else{let f=Be[$++],p=Be[$++];if((f&128)>0||(p&128)>0){$-=14;return}if(i<15)return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p);let m=Be[$++];if((m&128)>0){$-=15;return}return Sn(t,e,r,n,s,o,a,l,u,c,h,d,f,p,m)}}}}}function Dw(i){return hi.copyBuffers?Uint8Array.prototype.slice.call(Be,$,$+=i):Be.subarray($,$+=i)}function sc(i){let t=Be[$++];if(ti[t])return ti[t](Be.subarray($,$+=i));throw new Error("Unknown extension type "+t)}var AP=new Array(4096);function CP(){let i=Be[$++];if(i>=160&&i<192){if(i=i-160,Qs>=$)return ja.slice($-Xi,($+=i)-Xi);if(!(Qs==0&&Wa<180))return Lw(i)}else return $--,Mr();let t=(i<<5^(i>1?Ht.getUint16($):i>0?Be[$]:0))&4095,e=AP[t],r=$,n=$+i-3,s,o=0;if(e&&e.bytes==i){for(;r{var e=Mr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Nt[i];return n&&n.isShared&&((Nt.restoreStructures||(Nt.restoreStructures=[]))[i]=n),Nt[i]=e,e.read=Bw(e,r),e.read()},PP=typeof self=="object"?self:global;ti[0]=()=>{};ti[0].noBuffer=!0;ti[101]=()=>{let i=Mr();return(PP[i[0]]||Error)(i[1])};ti[105]=i=>{let t=Ht.getUint32($-4);Jo||(Jo=new Map);let e=Be[$],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};Jo.set(t,n);let s=Mr();return n.used?Object.assign(r,s):(n.target=s,s)};ti[112]=i=>{let t=Ht.getUint32($-4),e=Jo.get(t);return e.used=!0,e.target};ti[115]=()=>new Set(Mr());var kw=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");ti[116]=i=>{let t=i[0],e=kw[t];if(!e)throw new Error("Could not find typed array for code "+t);return new PP[e](Uint8Array.prototype.slice.call(i,1).buffer)};ti[120]=()=>{let i=Mr();return new RegExp(i[0],i[1])};ti[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=$;$+=t-4,Bi=[Mr(),Mr()],Bi.position0=0,Bi.position1=0;let r=$;$=e;try{return Mr()}finally{$=r}};ti[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function DP(i){let t=Wa,e=$,r=Rw,n=Xi,s=Qs,o=ja,a=Ow,l=Jo,u=Bi,c=new Uint8Array(Be.slice(0,Wa)),h=Nt,d=Nt.slice(0,Nt.length),f=hi,p=fh,m=i();return Wa=t,$=e,Rw=r,Xi=n,Qs=s,ja=o,Ow=a,Jo=l,Bi=u,Be=c,fh=p,Nt=h,Nt.splice(0,Nt.length,...d),hi=f,Ht=new DataView(Be.buffer,Be.byteOffset,Be.byteLength),m}function Ty(){Be=null,Jo=null,Nt=null}function IP(i){i.unpack?ti[i.type]=i.unpack:ti[i.type]=i}var Py=new Array(147);for(let i=0;i<256;i++)Py[i]=+("1e"+Math.floor(45.15-i*.30103));var Dy=new Ks({useRecords:!1}),HW=Dy.unpack,jW=Dy.unpackMultiple,WW=Dy.unpack,Iy={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},qW=new Float32Array(1),sae=new Uint8Array(qW.buffer,0,4);var Oy;try{Oy=new TextEncoder}catch{}var Ry,zw,Ly=typeof Buffer<"u",Vw=Ly?Buffer.allocUnsafeSlow:Uint8Array,NP=Ly?Buffer:Uint8Array,OP=Ly?4294967296:2144337920,de,Nr,ne=0,Zs,Js=null,YW=/[\u0080-\uFFFF]/,fp=Symbol("record-id"),oc=class extends Ks{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,u=NP.prototype.utf8Write?function(b,M,T){return de.utf8Write(b,M,T)}:Oy&&Oy.encodeInto?function(b,M){return Oy.encodeInto(b,de.subarray(M)).written}:!1,c=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let m=f>32||p+f>64,g=f+64,y=f+p+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,w=0;this.pack=this.encode=function(b,M){if(de||(de=new Vw(8192),Nr=new DataView(de.buffer,0,8192),ne=0),Zs=de.length-10,Zs-ne<2048?(de=new Vw(de.length),Nr=new DataView(de.buffer,0,de.length),Zs=de.length-10,ne=0):ne=ne+7&2147483640,r=ne,a=c.structuredClone?new Map:null,c.bundleStrings?(Js=["",""],de[ne++]=214,de[ne++]=98,Js.position=ne-r,ne+=4):Js=null,n=c.structures,n){n.uninitialized&&(n=c._mergeStructures(c.getStructures()));let T=n.sharedLength||0;if(T>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;CZs&&E(ne),c.offset=ne;let T=QW(de.subarray(r,ne),a.idsToInsert);return a=null,T}return M&FP?(de.start=r,de.end=ne,de):de.subarray(r,ne)}finally{if(n){if(w<10&&w++,x>1e4)n.transitions=null,w=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let T=0,C=v.length;TT&&(n=n.slice(0,T));let C=de.subarray(r,ne);return c.saveStructures(n,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(b)):(l=T,C)}}M&r6&&(ne=r)}};let S=b=>{ne>Zs&&(de=E(ne));var M=typeof b,T;if(M==="string"){let C=b.length;if(Js&&C>=8&&C<4096){let I=YW.test(b);Js[I?0:1]+=b,de[ne++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let D=C*3;if(ne+D>Zs&&(de=E(ne+D)),C<64||!u){let I,R,U,F=ne+P;for(I=0;I>6|192,de[F++]=R&63|128):(R&64512)===55296&&((U=b.charCodeAt(I+1))&64512)===56320?(R=65536+((R&1023)<<10)+(U&1023),I++,de[F++]=R>>18|240,de[F++]=R>>12&63|128,de[F++]=R>>6&63|128,de[F++]=R&63|128):(de[F++]=R>>12|224,de[F++]=R>>6&63|128,de[F++]=R&63|128);T=F-ne-P}else T=u(b,ne+P,D);T<32?de[ne++]=160|T:T<256?(P<2&&de.copyWithin(ne+2,ne+1,ne+1+T),de[ne++]=217,de[ne++]=T):T<65536?(P<3&&de.copyWithin(ne+3,ne+2,ne+2+T),de[ne++]=218,de[ne++]=T>>8,de[ne++]=T&255):(P<5&&de.copyWithin(ne+5,ne+3,ne+3+T),de[ne++]=219,Nr.setUint32(ne,T),ne+=4),ne+=T}else if(M==="number")if(b>>>0===b)b<64?de[ne++]=b:b<256?(de[ne++]=204,de[ne++]=b):b<65536?(de[ne++]=205,de[ne++]=b>>8,de[ne++]=b&255):(de[ne++]=206,Nr.setUint32(ne,b),ne+=4);else if(b>>0===b)b>=-32?de[ne++]=256+b:b>=-128?(de[ne++]=208,de[ne++]=b+256):b>=-32768?(de[ne++]=209,Nr.setInt16(ne,b),ne+=2):(de[ne++]=210,Nr.setInt32(ne,b),ne+=4);else{let C;if((C=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){de[ne++]=202,Nr.setFloat32(ne,b);let P;if(C<4||(P=b*Py[(de[ne]&127)<<1|de[ne+1]>>7])>>0===P){ne+=4;return}else ne--}de[ne++]=203,Nr.setFloat64(ne,b),ne+=8}else if(M==="object")if(!b)de[ne++]=192;else{if(a){let P=a.get(b);if(P){if(!P.id){let D=a.idsToInsert||(a.idsToInsert=[]);P.id=D.push(P)}de[ne++]=214,de[ne++]=112,Nr.setUint32(ne,P.id),ne+=4;return}else a.set(b,{offset:ne-r})}let C=b.constructor;if(C===Object)A(b,!0);else if(C===Array){T=b.length,T<16?de[ne++]=144|T:T<65536?(de[ne++]=220,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=221,Nr.setUint32(ne,T),ne+=4);for(let P=0;P>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);for(let[P,D]of b)S(P),S(D)}else{for(let P=0,D=Ry.length;P(de=U,U=null,ne+=H,ne>Zs&&E(ne),{target:de,targetView:Nr,position:ne-H}),S)}finally{U&&(de=U,Nr=F,ne=V,Zs=de.length-10)}G&&(G.length+ne>Zs&&E(G.length+ne),ne=XW(G,de,ne,R.type));return}}A(b,!b.hasOwnProperty)}}else if(M==="boolean")de[ne++]=b?195:194;else if(M==="bigint"){if(b=-(BigInt(1)<0)de[ne++]=207,Nr.setBigUint64(ne,b);else if(this.largeBigIntToFloat)de[ne++]=203,Nr.setFloat64(ne,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ne+=8}else if(M==="undefined")this.encodeUndefinedAsNil?de[ne++]=192:(de[ne++]=212,de[ne++]=0,de[ne++]=0);else if(M==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?b=>{let M=Object.keys(b),T=M.length;T<16?de[ne++]=128|T:T<65536?(de[ne++]=222,de[ne++]=T>>8,de[ne++]=T&255):(de[ne++]=223,Nr.setUint32(ne,T),ne+=4);let C;for(let P=0;P{de[ne++]=222;let T=ne-r;ne+=2;let C=0;for(let P in b)(M||b.hasOwnProperty(P))&&(S(P),S(b[P]),C++);de[T+++r]=C>>8,de[T+r]=C&255}:b=>{let M=Object.keys(b),T,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,R=M.length;I=96&&m?(de[ne++]=((D-=96)&31)+96,de[ne++]=D>>5):de[ne++]=D;else{D=o.nextId,D||(D=64),D=y&&(D=g),o.nextId=D+1);let I=M.highByte=D>=96&&m?D-96>>5:-1;C[fp]=D,o[D-64]=M,D=0?(de[ne++]=(D&31)+96,de[ne++]=I):de[ne++]=D):(I>=0?(de[ne++]=213,de[ne++]=114,de[ne++]=(D&31)+96,de[ne++]=I):(de[ne++]=212,de[ne++]=114,de[ne++]=D),P&&(x+=w*P),v.length>=p&&(v.shift()[fp]=0),v.push(C),S(M))}for(let I=0,R=M.length;I{let M;if(b>16777216){if(b-r>OP)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(OP,Math.round(Math.max((b-r)*(b>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(b-r<<2,de.length-1)>>12)+1<<12;let T=new Vw(M);return Nr=new DataView(T.buffer,0,M),de.copy?de.copy(T,0,r,b):T.set(de.slice(r,b)),ne-=r,r=0,Zs=T.length-10,de=T}}useBuffer(t){de=t,Nr=new DataView(de.buffer,de.byteOffset,de.byteLength),ne=0}};zw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,dp];Ry=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?RP(i,16,t):LP(Ly?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==NP&&this.structuredClone?RP(i,kw.indexOf(e.name),t):LP(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function RP(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function LP(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function XW(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function QW(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function qa(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");zw.unshift(i.Class),Ry.unshift(i)}IP(i)}var BP=new oc({useRecords:!1}),KW=BP.pack,ZW=BP.pack;var{NEVER:JW,ALWAYS:$W,DECIMAL_ROUND:e6,DECIMAL_FIT:t6}=Iy,FP=512,r6=1024;var kP=new oc({structuredClone:!0});qa({Class:rt.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,rt.prototype),i}});qa({Class:Le.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Le.prototype),i}});qa({Class:pr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,pr.prototype),i}});qa({Class:up.prototype.constructor,type:4,write(i){return i.id},read(i){return new up(i)}});qa({Class:hp.prototype.constructor,type:5,write(i){return i.data},read(i){return new hp(i)}});qa({Class:Jt.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Jt.prototype),i}});function n6(i){var t=0;if(i.length===0)return t;for(let e=0;e{function i(n){return kP.pack(n)}r.serialize=i;function t(n){return kP.unpack(n)}r.deserialize=t;function e(n){return n6(i(Uw(n))).toString()}r.checksum=e})(Ny||(Ny={}));var VP;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(VP||(VP={}));var di={["LookAt"]:[],["Follow"]:["Create"],["DragDrop"]:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],["MouseHover"]:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],["Scroll"]:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],["Start"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Conditional"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MouseUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["MousePress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyDown"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyUp"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["KeyPress"]:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],["GameControl"]:["Transition","Animation","Audio","Create","Conditional"],["Collision"]:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Trigger"]:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["Resize"]:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],["VariableChange"]:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},zP;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new Le}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new Le}}e.defaultData=t})(zP||(zP={}));var By;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(By||(By={}));var Gw;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:By.propertyDefaultData(n),rOperand:{...By.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(Gw||(Gw={}));var UP;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new Le,outActions:new Le,condition:Gw.distanceDefaultData(r)}}e.defaultData=t})(UP||(UP={}));var GP;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Le,drop:new Le}})(GP||(GP={}));var Fy;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Le})(Fy||(Fy={}));var ky;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(ky||(ky={}));var HP;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new Le}}e.defaultData=t})(HP||(HP={}));var jP;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Le}}e.defaultData=t})(jP||(jP={}));var WP;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new Le}}e.defaultData=t})(WP||(WP={}));var qP;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new Le}}e.defaultData=t})(qP||(qP={}));var YP;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new Le,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(YP||(YP={}));var Vy;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function n(){let a={size:"mobile",operator:"<",actions:new Le},l={size:"tablet",operator:"<",actions:new Le},u={size:[...o.defaultSizes.custom],operator:"<>",actions:new Le},c=new Le;return c.push({id:Se.generateUUID(),fi:0,data:a},{id:Se.generateUUID(),fi:1,data:l},{id:Se.generateUUID(),fi:2,data:u}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:c}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new Le}}o.defaultBreakpointData=s})(Vy||(Vy={}));var zy;(r=>{r.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new Le,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(zy||(zy={}));var Qi="personal camera",Xa="a218fcc3-276b-49b9-b485-49037fd14f5f",KP=2960946,an=5526619;var ac;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s]}e.lerp=t})(ac||(ac={}));var $s;(a=>{function i(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}a.isEqual=i;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}a.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}a.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}a.div=r;function n(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}a.mul=n;function s(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}a.dist=s;function o(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}a.lerp=o})($s||($s={}));var pp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(pp||(pp={}));var Ya;(n=>{n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,u=o.length;l{function i(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}c.isRGB=i,c.white={r:1,g:1,b:1},c.red={r:1,g:0,b:0},c.black={r:0,g:0,b:0};function n(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}c.toRgb255a1=n;function s(h){return{r:h.r,g:h.g,b:h.b}}c.clone=s;function o(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}c.fromHex=o;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}c.toHex=a;function l(h,d){return h.r===d.r&&h.g===d.g&&h.b===d.b}c.equals=l;function u(h,d,f){return{r:h.r+(d.r-h.r)*f,g:h.g+(d.g-h.g)*f,b:h.b+(d.b-h.b)*f}}c.lerp=u})(An||(An={}));var ri;(a=>{a.white={...An.white,a:1},a.transparent={...An.white,a:0};function e(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=e;function r(l,u){return{...An.fromHex(l),a:u}}a.fromHexAndA=r;function n(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=n;function s(l,u){return An.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(ri||(ri={}));var Uy;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Uy||(Uy={}));var XP;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(XP||(XP={}));var QP;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(QP||(QP={}));var $o;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))($o||($o={}));function Hw(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var bs;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(bs||(bs={}));var Qa;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}n.getZoom=r})(Qa||(Qa={}));var eo;(e=>{function i(r,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=i;function t(r,n){let s={...r};if(jw.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;Ww.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;qw.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;Yw.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;Xw.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;Qw.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(eo||(eo={}));var Gy;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Gy||(Gy={}));var jw=["count"],Ww=["radius","start","end","position","scale","rotation"],qw=["position","scale","rotation"],Yw=["count","size"],Xw=["count","position","scale","rotation"],Qw=["strength","scale","rotation","position","movement","seed","freqScale"];var Hy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Hy||(Hy={}));var jy;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:ri.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:ri.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:ri.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(jy||(jy={}));var Ka;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Ka||(Ka={}));var Kw;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(Kw||(Kw={}));var Zw;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(Zw||(Zw={}));var Wy;(t=>t.defaultData={...Zw.defaultData,...Kw.defaultData})(Wy||(Wy={}));var ZP;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&n.push(o)}return n}t.getMaterialData=i})(ZP||(ZP={}));var ph;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ph||(ph={}));var JP;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(JP||(JP={}));function e2(i){return i.type!=="displace"}var $P;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})($P||($P={}));var qy=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],t2=["wrapping","image","video","name"],_n;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let u=s.texture;u&&Object.assign(u,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ph.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...o,type:"color",color:An.fromHex(an)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...An.fromHex(6710886),a:1},colorB:{...An.fromHex(6710886),a:1},colorC:{...An.fromHex(16777215),a:1},colorD:{...An.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:ri.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:ri.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:ri.fromHexAndA(0,1),contourColor:ri.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...An.fromHex(0),a:1},colorB:{...An.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(_n||(_n={}));var Br;(l=>{function i(u){return!u.layers.some(h=>h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")}l.isMergable=i;function t(u){let c="";return u.layers.forEach(h=>{Object.entries(h.data).forEach(([d,f])=>{c+=`${d}${f}`,Array.isArray(f)?f.forEach(p=>c+=`${p}`):typeof f=="object"?Object.values(f).forEach(p=>{typeof p=="number"?c+=`${p.toFixed(4)}`:c+=`${p}`}):c+=`${f}`})}),c}l.getHash=t;function e(){return{layers:new Le}}l.defaultEmptyData=e;function r(u="layer1",c="layer2"){return s("phong",u,c)}l.defaultData=r;function n(u,c){return{...u,name:c}}l.withName=n;function s(u,c="layer1",h="layer2"){let d=new Le;return d.push({fi:0,data:_n.defaultData("light",u),id:c}),d.push({fi:1,data:_n.defaultData("color"),id:h}),{layers:d}}l.defaultTwoLayerData=s;function o(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("texture");Object.assign(f.texture,{image:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerTextureData=o;function a(u,c="phong",h="layer1",d="layer2"){let f=_n.defaultData("video");Object.assign(f.texture,{video:u});let p=new Le;return p.push({fi:0,data:f,id:h}),p.push({fi:1,data:_n.defaultData("light",c),id:d}),{layers:p}}l.defaultTwoLayerVideoTextureData=a})(Br||(Br={}));var mh;(t=>{function i(){return{points:new Le,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(mh||(mh={}));var gh;(t=>{function i(){return{points:new Le,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(gh||(gh={}));var Jw={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Yy;(t=>{function i(e,r){let n={...e};return $w.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Yy||(Yy={}));var Xy={shape:Jw,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},$w=["depth","offset","angle","twist","startScale","endScale"];var mp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=i;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})(mp||(mp={}));var Qy;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Yy.merge(n.extrusion,r.extrusion))),n}t.merge=i})(Qy||(Qy={}));var Za;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:gh.defaultData(),extrusion:Xy};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:mh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Za||(Za={}));var eS=["width","height","depth"];var Ky;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:An.white,near:.1,far:2e3})(Ky||(Ky={}));var yh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focalLength:2,focusDistance:2,bokehScale:2},noise:{...i,blendFunction:16}}})(yh||(yh={}));var tS;(t=>t.defaultData={softShadowQuality:"low"})(tS||(tS={}));var rS;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(rS||(rS={}));var nS;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(nS||(nS={}));var Ja;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ja||(Ja={}));var iS;(t=>t.defaultData={playCamera:Qi,gameControlObject:null})(iS||(iS={}));var Zy;(t=>t.defaultData={backgroundColor:ri.fromHexAndA(KP,1),postprocessing:yh.defaultData,fog:Ky.defaultData,globalPhysics:Ja.defaultData,ambient:rS.defaultData,ao:nS.defaultData,shadow:tS.defaultData,publish:iS.defaultData})(Zy||(Zy={}));var r2;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(r2||(r2={}));var vh;(n=>{n.identity={...Uy.identity,hiddenMatrix:Ya.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}n.merge=e;function r(s,o){return XC({position:$s.isEqual(s.position,o.position)?void 0:o.position,rotation:$s.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:$s.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Ya.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(vh||(vh={}));var Fn;(t=>t.defaultData={states:new Le,events:new Le,visible:!0,raycastLock:!1,physics:Ka.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...vh.identity,cloner:null})(Fn||(Fn={}));var Jy;(t=>t.defaultData={type:"Empty",...Fn.defaultData})(Jy||(Jy={}));var n2;(t=>t.defaultData={type:"Component",...Fn.defaultData})(n2||(n2={}));var lc;(t=>t.defaultData={type:"Mesh",...Fn.defaultData,...Wy.defaultData})(lc||(lc={}));var cc;(t=>t.defaultData={...Fn.defaultData,...vh.identity,position:[0,0,Qa.DefaultTargetOffset],...Qa.defaultData})(cc||(cc={}));var $y;(e=>{function i(r){return{...Fn.defaultData,...jy.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var xh;(e=>{function i(r,n,s=0){for(;s{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{...Fn.defaultData,...a,component:o,overrides:new Jt,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=vh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(to||(to={}));var ea;(t=>t.defaultData={type:"Page",...Fn.defaultData,physics:{...Ka.defaultData,fusedBody:!1},...Zy.defaultData,camera:cc.defaultData})(ea||(ea={}));var ev;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ya.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ka.defaultData,states:new Le,events:new Le,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Qa.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("RectangleGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("BooleanGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Fn.defaultData,...lc.defaultData,geometry:Za.defaultData("TextGeometry"),material:Br.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var ta;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new Jt}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new Jt})))):bs.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=Ha(a.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(o.material.layers)){let h=l.layers.data(u);h&&_n.patch(h,c)}}).data),a.materials&&o.materials&&(a.materials=Ha(a.materials,l=>{for(let u=0;u0){let y={path:[...h,"layers",f,"texture"],props:m,type:0};l.push(y)}if(Object.keys(g).length>0){let y={path:[...h,"layers",f],props:g,type:0};l.push(y)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Gy.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")c(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))c(["materials",f],p);else if(u[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,vh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),bs.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:Qy.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:eo.merge(a.cloner,o.cloner)});else if(Hy.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=An.clone(l.color))}return a}n.patch=r})(ta||(ta={}));var wh;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(wh||(wh={}));var ro;(t=>t.defaultData={orbitControls:wh.defaultData,playPage:Xa,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(ro||(ro={}));var sS;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(sS||(sS={}));var oS;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(oS||(oS={}));var $a;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...sS.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:oS.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))($a||($a={}));var el;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=Sh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(el||(el={}));var tl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(l={withLight:!0,withSquare:!0}){let u=[],c=ev.defaultMeshObject;l.withLight===!0&&u.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),l.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:c,children:[]});let h=new pr;return h.push({fi:1,id:Xa,data:{...ea.defaultData,name:"Scene 1"},children:u}),h}a.defaultData={objects:t(),publish:ro.defaultData,styles:$a.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new pr,publish:ro.defaultData,styles:$a.defaultData()}},a.emptyDataWithPage=function(l){return{objects:t(l),publish:ro.defaultData,styles:$a.defaultData()}};function s(l){return{...a.defaultData,objects:ui(l,pr.prototype)}}a.withObjs=s;function o(l,u){return s([{id:l,data:u,children:[],fi:0}])}a.withObj=o})(tl||(tl={}));var Ah;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ah||(Ah={}));var _h;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(_h||(_h={}));var En;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=n})(En||(En={}));var aS;(t=>t.all=["images","videos","colors","audios","fonts","materials","variables"])(aS||(aS={}));var i2;(t=>t.all=[...aS.all,"components"])(i2||(i2={}));var s2;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(s2||(s2={}));var rl;(t=>{function i(){return{images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,materials:new rt,components:new rt,variables:new rt}}t.defaultData=i})(rl||(rl={}));var fi;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ui(o,rt.prototype)}s.defaultColors=i;function t(o){let a={};return o?.withAITexture&&(a["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={..._h.emptyImage,name:"AI generated image"}),ui(a,rt.prototype)}s.defaultImages=t;function e(){return{catelogs:new rt,materials:new rt,images:new rt,videos:new rt,colors:new rt,audios:new rt,fonts:new rt,variables:new Le,lib:rl.defaultData()}}s.emptyData=e;function r(o){switch(o){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",o)}}s.defaultVariables=r;function n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),u=Math.floor((o-l*3600)/60),c=Math.round(o-l*3600-u*60);return{textValue:[l,u,c]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),u=Math.round(o-l*60);return{textValue:[l,u]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(fi||(fi={}));var Eh;(t=>t.list=["idle","move","jump","run"])(Eh||(Eh={}));var Mh;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Le,move:new Le,jump:new Le,run:new Le},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:ri.fromHexAndA(3728051,1)}}))(Mh||(Mh={}));function o2(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)n.push(n[1]),s.push(1);let o={...Ni(xr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...xr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ra(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function na(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=Br.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Br.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&t(n.material)})})}function s6(i){Object.assign(i.scene.publish,{orbitControls:{...wh.defaultData,...xr(i.scene.publish.orbitControls)}})}function o6(i){Object.assign(i.scene.publish.settings,{video:{...ro.defaultData.settings.video,...xr(i.scene.publish.settings.video)}})}function a6(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((qy.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(t2.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function l6(i){i.scene.publish.withBackground=!0}function c6(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function u6(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function h6(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function d6(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=xr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=xr(e).booleanExclude!==!0)}})}function f6(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function p6(i){function t(r){Object.setPrototypeOf(r,Jt.prototype),r.texture&&Object.setPrototypeOf(r.texture,Jt.prototype)}function e(r){Object.setPrototypeOf(r,Jt.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=xr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...xr(t),colors:e,steps:r};Object.assign(t,n)}})}function m6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function l2(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&lS(r)}):"material"in e&&typeof e.material!="string"&&lS(e.material)}),Object.values(i.shared.materials).forEach(t=>lS(t))}function g6(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function y6(i){i.shared.audios=ui({},rt.prototype)}function v6(i){i.shared.videos=ui({},rt.prototype)}function x6(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:n})}})}function b6(i){Object.entries(xr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(xr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function w6(i){i.scene.publish.settings.web.preload=!1}function c2(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function u2(i){i.layers&&i.layers.forEach(t=>{e2(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function S6(i){i.shared.fonts=ui({},rt.prototype)}function A6(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function _6(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=Br.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=A6(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,...Fn.defaultData,...lc.defaultData,flatShading:!1,wireframe:!1,geometry:{...Za.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:xr(n.states),events:xr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},u=xr(i.scene.objects).parent(e);i.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function E6(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new Le,move:new Le,jump:new Le}});else{let s=new Le;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:Se.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Ni(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Le({fi:0,id:Se.generateUUID(),data:u},{fi:1,id:Se.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function M6(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new Le,a=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Ni(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Ni(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(u=>u.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:Se.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function h2(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=_n.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function d2(i){ra(i,h2),na(i,h2)}function T6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function C6(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function P6(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Br.defaultTwoLayerData("phong"))})}function D6(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function I6(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function O6(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function R6(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function L6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function N6(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function B6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Mh.defaultDataThirdPerson.navmesh)})})}function F6(i){i.scene.styles||(i.scene.styles=$a.defaultData())}function f2(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function k6(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),na(i,f2),ra(i,f2)}function V6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Le})})})}function z6(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function p2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function m2(i,t){if(t<1&&(na(i,o2),ra(i,o2),i.schema=1),t<2&&(s6(i),i.schema=2),t<3&&(a6(i),i.schema=3),t<4&&(l6(i),i.schema=4),t<5&&(c6(i),i.schema=5),t<6&&(u6(i),i.schema=6),t<7&&(h6(i),i.schema=7),t<8&&(i.schema=8),t<9&&(l2(i),i.schema=9),t<10&&(m6(i),i.schema=10),t<11&&(g6(i),i.schema=11),t<12&&(l2(i),i.schema=12),t<13&&(y6(i),i.schema=13),t<14&&(x6(i),i.schema=14),t<15&&(b6(i),i.schema=15),t<16&&(w6(i),i.schema=16),t<17&&(na(i,c2),ra(i,c2),i.schema=17),t<18&&(na(i,a2),ra(i,a2),i.schema=18),t<19&&(o6(i),i.schema=19),t<20&&(S6(i),_6(i),i.schema=20),t<21&&(E6(i),M6(i),i.schema=21),t<22&&(d2(i),i.schema=22),t<23&&(T6(i),i.schema=23),t<24&&(C6(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(v6(i),t<25&&(i.schema=25)),t<26&&(d6(i),i.schema=26),t<27&&(f6(i),i.schema=27),t<28&&(d2(i),i.schema=28),t<29&&(p6(i),i.schema=29),t<30&&(P6(i),i.schema=30),t<31&&(D6(i),i.schema=31),t<33&&(I6(i),i.schema=33),t<34&&(O6(i),i.schema=34),t<35&&(R6(i),i.schema=35),t<36&&(L6(i),i.schema=36),t<37&&(N6(i),i.schema=37),t<38&&(na(i,u2),ra(i,u2),i.schema=38),t<39&&(B6(i),i.schema=39),t<40&&(F6(i),i.schema=40),t<41&&(k6(i),i.schema=41),t<42&&(V6(i),i.schema=42),t<43&&(z6(i),i.schema=43),t<99){na(i,p2),ra(i,p2),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=Qi);let e=xr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Xa,r.insertBefore(null,null,[{id:Xa,data:{...ea.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Ni(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Ni(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ja.defaultData,...Ni(i.scene.environment,"usePhysics","gravity")},camera:xr(i.scene.ownerCamera)??ea.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==tl.TRASH_CAN_ID&&r.move(Xa,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,Ka.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function g2(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function U6(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var Th=180/Math.PI;function y2(i){i.rotation=i.rotation.slice(0,3).map(t=>t*Th)}function v2(i){y2(i),i.type==="Page"&&y2(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Th))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Th),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Th),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Th,t.extrusion.twist*=Th),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(xr(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function G6(i){i.shared.variables=ui({},rt.prototype)}function H6(i){let t=xr(i.shared.variables);i.shared.variables=ui(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),Le.prototype)}var ia=107;function x2(i,t){t(i.data);for(let e of i.children)x2(e,t)}function j6(i){let t=i.schema??104;t!==ia&&t<105&&(x2(i.asset,v2),i.schema=105)}function tv(i){let t=i.schema??0;if(t!==ia){console.warn("updating from ",t,"to ",ia),m2(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=ro.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(na(i,g2),ra(i,g2),i.schema=101),t<102&&(U6(i),i.schema=102),t<104&&(i.shared.catelogs=new rt,i.shared.lib=rl.defaultData(),i.schema=104),t<105&&(G6(i),i.scene.objects.traverse((e,r)=>{v2(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))j6(e);t<106&&(H6(i),i.schema=106),t<107&&(i.shared.lib.variables=rl.defaultData().variables,i.schema=107)}}var Sh;(a=>{a.defaultData={schema:ia,scene:tl.defaultData,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors()}},a.emptyDataForImports=function(l){let u=tl.emptyDataWithPage(l);return{schema:ia,scene:u,frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:{...fi.emptyData(),colors:fi.defaultColors(),images:fi.defaultImages(l)}}},a.emptyData=function(){return{schema:ia,scene:tl.emptyDataWithPage(),frames:new rt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ah.defaultData),shared:fi.emptyData()}},a.collabHelper={...cp,updateSchema(l){return(l.schema??0)e&&(e=n,t=r)}return t}function uS(i,t){t.set(i)}function hS(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=rn?r:n}}function gp(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;oe[r+3]&&(e[r+3]=a)}}function Ch(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function Y6(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ge(n,1));for(let s=0;sn-s);for(let n=0;nl&&(l=E),y&&wp&&(p=w);let b=i[v+2],M=i[v+3],T=b-M,C=b+M;Tu&&(u=C),y&&bm&&(m=b);let P=i[v+4],D=i[v+5],I=P-D,R=P+D;Ic&&(c=R),y&&Pg&&(g=P)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=u,r[5]=c,y&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=m,n[5]=g)}function Q6(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t*6,h=(t+e)*6;ca&&(a=d);let f=i[c+2];fl&&(l=f);let p=i[c+4];pu&&(u=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=u}function K6(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]=a;)o--;if(si.candidate-t.candidate,nl=new Array(sa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),rv=new Float32Array(6);function J6(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=cS(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=cS(i),o!==-1&&(a=$6(e,r,n,o));else if(s===2){let l=Ch(i),u=1.25*n,c=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],g=(t[d+3]-f)/sa;if(n=E.candidate?gp(w,e,E.rightCacheBounds):(gp(w,e,E.leftCacheBounds),E.count++)}}for(let w=0;w=sa&&(A=sa-1);let E=nl[A];E.count++,gp(x,e,E.bounds)}let y=nl[sa-1];uS(y.bounds,y.rightCacheBounds);for(let x=sa-2;x>=0;x--){let w=nl[x],S=nl[x+1];hS(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let v=0;for(let x=0;xA&&(A=x),w>A&&(A=w);let E=(A-S)/2,b=y*2;s[f+b+0]=S+E,s[f+b+1]=E+(Math.abs(S)+E)*w2,St[y+3]&&(t[y+3]=A)}}return s}function t8(i,t){function e(y){d&&d(y/f)}function r(y,v,x,w=null,S=0){if(!p&&S>=l&&(p=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=c||S>=l)return e(v+x),y.offset=v,y.count=x,y;let A=J6(y.boundingData,w,o,v,x,h);if(A.axis===-1)return e(v+x),y.offset=v,y.count=x,y;let E=K6(a,o,v,x,A);if(E===v||E===v+x)e(v+x),y.offset=v,y.count=x;else{y.splitAxis=A.axis;let b=new uc,M=v,T=E-v;y.left=b,b.boundingData=new Float32Array(6),fS(o,M,T,b.boundingData,s),r(b,M,T,s,S+1);let C=new uc,P=E,D=x-T;y.right=C,C.boundingData=new Float32Array(6),fS(o,P,D,C.boundingData,s),r(C,P,D,s,S+1)}return y}Y6(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=e8(i,n),a=i.index.array,l=t.maxDepth,u=t.verbose,c=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,m=[],g=X6(i);if(g.length===1){let y=g[0],v=new uc;v.boundingData=n,Q6(o,y.offset,y.count,s),r(v,y.offset,y.count,s),m.push(v)}else for(let y of g){let v=new uc;v.boundingData=new Float32Array(6),fS(o,y.offset,y.count,v.boundingData,s),r(v,y.offset,y.count,s),m.push(v)}return m}function _2(i,t){let e=t8(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=u(x,y),n[d+7]=v,x}}}var pi=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;sn?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;sn?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};pi.prototype.setFromBox=function(){let i=new _;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){i.x=n.x*l+s.x*(1-l),i.y=n.y*u+s.y*(1-u),i.z=n.z*c+s.z*(1-c);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var ohe=function(){let i=new pi;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,u=r.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var r8=function(){let i=new _,t=new _,e=new _;return function(n,s,o){let a=n.start,l=i,u=s.start,c=t;e.subVectors(a,u),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(c),d=c.dot(l),f=c.dot(c),p=e.dot(l),g=l.dot(l)*f-d*d,y,v;g!==0?y=(h*d-p*f)/g:y=0,v=(h+y*d)/f,o.x=y,o.y=v}}(),yp=function(){let i=new N,t=new _,e=new _;return function(n,s,o,a){r8(n,s,i);let l=i.x,u=i.y;if(l>=0&&l<=1&&u>=0&&u<=1){n.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=n.start:c=n.end;let h;u<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(c,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),E2=function(){let i=new _,t=new _,e=new Or,r=new nn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(r.start=u,r.end=c,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){let y=m.projectPoint(l,t);if(o.containsPoint(y))return!0}return!1}}();var n8=1e-15;function Ph(i){return Math.abs(i)new _),this.satBounds=new Array(4).fill().map(()=>new pi),this.points=[this.a,this.b,this.c],this.sphere=new fr,this.plane=new Or,this.needsUpdate=!0}intersectsSphere(t){return E2(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let u=s[1],c=o[1];u.subVectors(t,e),c.setFromPoints(u,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};mi.prototype.closestPointToSegment=function(){let i=new _,t=new _,e=new nn;return function(n,s=null,o=null){let{start:a,end:l}=n,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(u[d]),e.end.copy(u[f]),yp(e,n,i,t),c=i.distanceToSquared(t),c1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let A=0;A<4;A++){let E=v[A],b=x[A];if(r.setFromPoints(b,e),E.isSeparated(r))return!1}let w=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let A=0;A<4;A++){let E=w[A],b=S[A];if(r.setFromPoints(b,t),E.isSeparated(r))return!1}for(let A=0;A<4;A++){let E=x[A];for(let b=0;b<4;b++){let M=S[b];if(s.crossVectors(E,M),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))return!1}}return p&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,x=!1,w=0;for(let I=0;I<3;I++){let R=v[I],U=v[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(o);let F=x?c.start:c.end,V=Ph(y.distanceToPoint(R));if(Ph(y.normal.dot(o))&&V){c.copy(u),w=2;break}if((y.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(w++,x)break;x=!0}}if(w===1&&f.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(w!==2)return!1;let S=f.points,A=!1,E=0;for(let I=0;I<3;I++){let R=S[I],U=S[(I+1)%3];u.start.copy(R),u.end.copy(U),u.delta(a);let F=A?h.start:h.end,V=Ph(g.distanceToPoint(R));if(Ph(g.normal.dot(a))&&V){h.copy(u),E=2;break}if((g.intersectLine(u,F)||V)&&!Ph(F.distanceTo(U))){if(E++,A)break;A=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let I=h.start;h.start=h.end,h.end=I}let b=c.start.dot(o),M=c.end.dot(o),T=h.start.dot(o),C=h.end.dot(o),P=M0?p.start.copy(c.start):p.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?p.end.copy(c.end):p.end.copy(h.end)),!0)}}}();mi.prototype.distanceToPoint=function(){let i=new _;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();mi.prototype.distanceToTriangle=function(){let i=new _,t=new _,e=["a","b","c"],r=new nn,n=new nn;return function(o,a=null,l=null){let u=a||l?r:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),dnew _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new pi),this.alignedSatBounds=new Array(3).fill().map(()=>new pi),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};gi.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=n[d];f.x=u?r.x:e.x,f.y=c?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<new nn),e=new Array(12).fill().map(()=>new nn),r=new _,n=new _;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),u&&u.copy(n)),0;let c=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let g=0;g<8;g++){let y=f[g];n.copy(y).clamp(h,d);let v=y.distanceToSquared(n);if(v0&&u.normal.multiplyScalar(-1));let c={a:s,b:o,c:a,normal:new _,materialIndex:0};dr.getNormal(Dh,Ih,Oh,c.normal),u.face=c,u.faceIndex=s}return u}function mS(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:u,normal:c,uv:h,uv1:d}=i.attributes,f=s8(e,u,c,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function P2(i,t,e,r,n,s){for(let o=r,a=r+n;o=0,f,p;d?(f=Nh(i),p=Bh(i,a)):(f=Bh(i,a),p=Nh(i));let g=dv(f,s,r,cv)?hv(f,t,e,r):null;if(g){let x=g.point[c];if(d?x<=s[p+u]:x>=s[p+u+3])return g}let v=dv(p,s,r,cv)?hv(p,t,e,r):null;return g&&v?g.distance<=v.distance?g:v:g||v||null}}var O2=function(){let i,t,e=[],r=new Rh(()=>new Pt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,u=null,c=0,h=0){function d(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Nh(x),w=x*2;return hc(x,A)}function f(x){let w=x*2,S=il,A=sl;for(;!oa(w,S);)x=Bh(x,A),w=x*2;return hc(x,A)+Lh(w,S)}let p=s*2,m=kh,g=il,y=sl;if(oa(p,g)){let x=hc(s,y),w=Lh(p,g);return Ki(s,m,i),l(x,w,!1,h,c+s,i)}else{let x=Nh(s),w=Bh(s,y),S=x,A=w,E,b,M,T;if(u&&(M=i,T=t,Ki(S,m,M),Ki(A,m,T),E=u(M),b=u(T),bn.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(u),b.b.applyMatrix4(u),b.c.applyMatrix4(u),b.needsUpdate=!0;for(let M=S*3,T=(A+S)*3;Mnew mi),io=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),io.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),io.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new io(e,{...r,[vS]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ge(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[vS]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[vS]||(this._roots=_2(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new Pt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,u=0,c=this._roots;for(let d=0,f=c.length;dA&&(A=P),DE&&(E=D),Ib&&(b=I)}return l[d+0]!==x||l[d+1]!==w||l[d+2]!==S||l[d+3]!==A||l[d+4]!==E||l[d+5]!==b?(l[d+0]=x,l[d+1]=w,l[d+2]=S,l[d+3]=A,l[d+4]=E,l[d+5]=b,!0):!1}else{let y=d+8,v=o[d+6],x=y+f,w=v+f,S=p,A=!1,E=!1;t?S||(A=t.has(x),E=t.has(w),S=!A&&!E):(A=!0,E=!0);let b=S||A,M=S||E,T=!1;b&&(T=h(y,f,S));let C=!1;M&&(C=h(v,f,S));let P=T||C;if(P)for(let D=0;D<3;D++){let I=y+D,R=v+D,U=l[I],F=l[I+3],V=l[R],G=l[R+3];l[d+D]=UG?F:G}return P}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=n[a+6],d=s[u+14];t(l,c,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,c,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Pi){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,u=o?e.side:e;for(let c=0,h=r.length;c{let y=p*3;return d(f,y,y+1,y+2,m,g)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=no.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=t;if(l&&u){let d=l;l=(f,p,m,g,y)=>d(f,p,m,g,y)?!0:gS(f,p,n,u,m,g,s)}else l||(u?l=(d,f,p,m)=>gS(d,f,n,u,p,m,s):l=(d,f,p)=>p);let c=!1,h=0;for(let d of this._roots){if(Vh(d),c=O2(0,n,a,l,o,h),vp(),c)break;h+=d.byteLength}return no.releasePrimitive(s),c}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,u=t.geometry.attributes.position;zh.copy(e).invert();let c=no.getPrimitive(),h=no.getPrimitive();if(s){let f=function(p,m,g,y,v,x,w,S){for(let A=g,E=g+y;AbS.intersectsBox(f),intersectsRange:(f,p,m,g,y,v)=>(xS.copy(v),xS.applyMatrix4(zh),t.shapecast({intersectsBounds:x=>xS.intersectsBox(x),intersectsRange:(x,w,S,A,E)=>n(f,p,x,w,g,y,A,E)}))});return no.releasePrimitive(c),no.releasePrimitive(h),d}intersectsBox(t,e){return dc.set(t.min,t.max,e),dc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>dc.intersectsBox(r),intersectsTriangle:r=>dc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),dc.set(t.boundingBox.min,t.boundingBox.max,e),dc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=t.attributes.position,h=t.index,d=no.getPrimitive(),f=no.getPrimitive(),p=fv,m=l8,g=null,y=null;n&&(g=c8,y=u8);let v=1/0,x=null,w=null;return zh.copy(e).invert(),xp.matrix.copy(zh),this.shapecast({boundsTraverseOrder:S=>dc.distanceToBox(S),intersectsBounds:(S,A,E)=>E{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>xp.distanceToBox(E),intersectsBounds:(E,b,M)=>M{for(let M=E*3,T=(E+b)*3;M(bp.copy(t).clamp(c.min,c.max),bp.distanceToSquared(t)),intersectsBounds:(c,h,d)=>d{c.closestPointToPoint(t,bp);let d=t.distanceToSquared(bp);return d{Ki(0,new Float32Array(r),L2),t.union(L2)}),t}};var Id=pn(B2());var h8=.5*(Math.sqrt(3)-1),wp=(3-Math.sqrt(3))/6,d8=1/3,so=1/6,$he=(Math.sqrt(5)-1)/4,ede=(5-Math.sqrt(5))/20,Sp=i=>Math.floor(i)|0,F2=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]),SS=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function pv(i=Math.random){let t=V2(i),e=new Float64Array(t).map(n=>F2[n%12*2]),r=new Float64Array(t).map(n=>F2[n%12*2+1]);return function(s,o){let a=0,l=0,u=0,c=(s+o)*h8,h=Sp(s+c),d=Sp(o+c),f=(h+d)*wp,p=h-f,m=d-f,g=s-p,y=o-m,v,x;g>y?(v=1,x=0):(v=0,x=1);let w=g-v+wp,S=y-x+wp,A=g-1+2*wp,E=y-1+2*wp,b=h&255,M=d&255,T=.5-g*g-y*y;if(T>=0){let D=b+t[M],I=e[D],R=r[D];T*=T,a=T*T*(I*g+R*y)}let C=.5-w*w-S*S;if(C>=0){let D=b+v+t[M+x],I=e[D],R=r[D];C*=C,l=C*C*(I*w+R*S)}let P=.5-A*A-E*E;if(P>=0){let D=b+1+t[M+1],I=e[D],R=r[D];P*=P,u=P*P*(I*A+R*E)}return 70*(a+l+u)}}function k2(i=Math.random){let t=V2(i),e=new Float64Array(t).map(s=>SS[s%12*3]),r=new Float64Array(t).map(s=>SS[s%12*3+1]),n=new Float64Array(t).map(s=>SS[s%12*3+2]);return function(o,a,l){let u,c,h,d,f=(o+a+l)*d8,p=Sp(o+f),m=Sp(a+f),g=Sp(l+f),y=(p+m+g)*so,v=p-y,x=m-y,w=g-y,S=o-v,A=a-x,E=l-w,b,M,T,C,P,D;S>=A?A>=E?(b=1,M=0,T=0,C=1,P=1,D=0):S>=E?(b=1,M=0,T=0,C=1,P=0,D=1):(b=0,M=0,T=1,C=1,P=0,D=1):At){s=o;break}else t1&&(n=1-n,s=1-s),Ss.a.fromBufferAttribute(this.positionAttribute,t*3),Ss.b.fromBufferAttribute(this.positionAttribute,t*3+1),Ss.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(Ss.a,n).addScaledVector(Ss.b,s).addScaledVector(Ss.c,1-(n+s)),Ss.getNormal(r),this}};var U2=pn(AS()),f8=new ie,p8=new ie,m8=new ie,Uh;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(Uh||(Uh={}));var Gh=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ie;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ie;this.matrixWorldRigid=new ie;this.shearScale=new ie;this.shearScaleInv=new ie}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof gt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)Uh.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)Uh.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,U2.SVD)(n),l=f8.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),u=p8.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),c=m8.copy(u).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ie().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ie?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var _S=class extends Gh(gt){},g8=i=>i.type==="Mesh",mr=class extends _S{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new mr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return g8(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var fc=new _,pc=new _,Hh=new ie,H2=[new _(-1,1,1),new _(-1,-1,1),new _(1,-1,1),new _(1,1,1),new _(-1,1,-1),new _(-1,-1,-1),new _(1,-1,-1),new _(1,1,-1)],y8=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],v8=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],G2=(i,t,e)=>{i.updateEntityBoxSize(fc,pc),Hh.copy(t).multiply(i.matrixWorld),pc.x===0&&pc.y===0&&pc.z===0?e.push(new _(fc.x,fc.y,fc.z).applyMatrix4(Hh)):H2.forEach(r=>{e.push(r.clone().multiply(pc).add(fc).applyMatrix4(Hh))})},Ap=class extends Pt{constructor(){super(...arguments);this.matrix=new ie;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ie().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new _);return}G2(o,r,s)}}):G2(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Hh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(pc).multiplyScalar(.5),this.getCenter(fc),Hh.copy(this.matrix).setPosition(fc),this.vertices=H2.map(e=>e.clone().multiply(pc).applyMatrix4(Hh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=y8.map(([e,r])=>new nn(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new _))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=v8.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var As={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var MS=class extends Vf{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var TS=.001;function CS(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=TS}function ES(i,t){let e=new _(...i.position),r=new _(...i.controlNext.position),n=new _(...t.controlPrevious.position),s=new _(...t.position);return CS(e,r,s)&&CS(e,n,s)}function yv(i){let t=i.points.map(c=>new _(...c.data.position)),e=[i.points[0]],r=new _(...e[0].data.position);for(let c=0;cTS&&(m=new ql(f.position,f.controlNext,p.controlPrevious,p.position));else{let g=f.position.clone(),y=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&g.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&y.add(p.prevDir.clone().setLength(p.removedLength))),g.distanceTo(y)>TS&&(m=new ql(g,g.clone().lerp(y,.3),y.clone().lerp(g,.3),y))}l[2*c+1]=m}for(let c=0;c{c&&u.add(c)}),u}var lt;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(lt||(lt={}));var oo=i=>lt.is(i),x8={type:"completeState",isfromEntity:!0},b8=["x","y","z"],PS=new _,w8=new _().set(0,1,0),jh=i=>class extends Gh(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Ap;this._recursiveBBox=new Ap;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(lt.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(lt.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let n=r.parent;if(lt.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ta.toOps(this.data,o.data).forEach(l=>{let u=wy.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ta.patch(this.data,o),ta.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(r,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{oo(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(lt.is(n[s]))return n[s];if(lt.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&<.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)oo(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{lt.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)oo(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)oo(n)&&n.visible&&n.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>oo(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*Se.RAD2DEG,this.rotation.y*Se.RAD2DEG,this.rotation.z*Se.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ih(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,b8[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(PS.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(Se.DEG2RAD),this.rotation.setFromVector3(PS),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Ya.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)lt.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{lt.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ih(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,u=qn(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Rr.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:d,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:d,...f}=c;c=f}let h=Rr.removeOverridden(r.path,r.props,c);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ta.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),qn(r.path,["overrides"])){let c=[],h=[...r.path];for(c.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)c.push(h[1]),h.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){c[c.length-1]=d;let f=s.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[d],f.updateState(Xs.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...c]);if(d){let f=Rr.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[m,g]of Object.entries(r.props))g===void 0&&(p===r.props&&(p={...r.props}),p[m]=f[m]);r={...r,props:p}}d.overrideData=xh.resolve(n.overrides,c),d.updateByOp(r,Lr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let h;for(let d of to.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(c={...r,props:h})}else for(let h of to.rootOverrideProps)if(qn(r.path,[h])){c=r;break}c!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,c);d&&h.updateByOp(d,Lr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=Xs.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Lr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!bs.is(r.props.type)&&As.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){As.changeEntityProptotype(this,n,s);for(let o of this.children)lt.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),qn(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),qn(r.path,["cloner"])!==null){let o=Lr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let n=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=l.data;if(u.geometry.path.points.length<=1)return;let c=yv(u.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=c.getPointAt(h);if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ie;l.updateMatrixWorld();let p=new ie().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let m={position:d.toArray(),rotation:u.rotation};if(a==="tangential"){let g=new ie().extractRotation(l.matrixWorld),y=c.getTangentAt(h).applyMatrix4(g).add(d),v=new ie().lookAt(d,y,w8),x=PS.setFromEuler(new Zt().setFromRotationMatrix(v)).multiplyScalar(Se.RAD2DEG);m={...m,rotation:x.toArray()}}this.updateTransformState(m),this.traverseEntity(g=>{g._cameraType&&g.dispatchEvent(x8)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof As.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new As.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}};var vv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=Se.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ae,p.setAttribute("position",new be([],3))):h||f?p=new _p(u,c,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Xl(u,c,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function ol(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function j2(i){return new N(i.y,-i.x)}var _p=class extends Ae{constructor(t,e,r,n,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let p=[],m=[],g=[],y=[],v=0,x=r/2,w=new _,S=new _;f&&t==0&&(t=u),f&&e==0&&(e=c);let A=new N(t,x),E=new N(e,-x),b=null,M=null,T=null,C=null,P=A.clone().sub(E),D=0,I=0,R=0;d>0&&(D=Math.min(t,e)*(1-d),I=t-D,R=e-D);let U=A.clone();U.x-=D;let F=Math.PI-P.angle(),V=P.angle(),G=Math.tan(V/2),H=Math.tan(F/2),Y=G+H,k=d?Y:H,j=d?Y:G;if(u=Math.min(u,(t-I)/k,P.length()/Y),c=Math.min(c,(e-R)/j,P.length()/Y),u>0){let K=u/G;b=A.clone().sub(new N(K,u)),d&&(T=b.clone(),T.x-=D-Y*u),A.sub(P.clone().setLength(K))}if(c>0){let K=c/H;M=E.clone().sub(new N(K,-c)),E.add(P.clone().setLength(K)),d&&(C=M.clone(),C.x-=D-Y*c,U.sub(P.clone().setLength(K)))}P=A.clone().sub(E);let X=P.length()<.5,q=[];for(let K=0;K<=n;K++){let W=[],ye=K/n,fe=ye*l+a,se=new N(Math.sin(fe),Math.cos(fe));C&&M?(z(W,ye,se,F,c,C,-1,!0),z(W,ye,se,V,c,M,-1,!1)):M?(J(W,se,M.x,0,-1),z(W,ye,se,V,c,M,-1,!1)):o||J(W,se,e,R,-1);let _e=j2(P).normalize();if(ol(_e,se,w),!X)for(let xe=0;xe<=s;xe++){let Oe=xe/s,Ie=P.clone().multiplyScalar(Oe).add(E);ol(Ie,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}if(T&&b?(z(W,ye,se,F,u,b,1,!1),z(W,ye,se,V,u,T,1,!0)):b?(z(W,ye,se,F,u,b,1,!1),J(W,se,b.x,0,1)):o||J(W,se,t,I,1),d&&!X){let xe=j2(P).multiplyScalar(-1).normalize();ol(xe,se,w);for(let Oe=0;Oe<=s;Oe++){let Ie=Oe/s,Pe=P.clone().multiplyScalar(-Ie).add(U);ol(Pe,se,S),m.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),y.push(ye,.5+S.y/r),W.push(v++)}}d&&!o&&W.push(W[0]),q.push(W)}for(let K=0;Kp.push(Pe,Me,ze):(Pe,Me,ze)=>p.push(Pe,ze,Me),Oe=new N((t+e+I+R)/4,0);ol(Oe,fe,_e),m.push(_e.x,_e.y,_e.z),g.push(se.x,0,se.y),y.push(.5,.5);let Ie=v++;for(let Pe of W){let Me=m.slice(Pe*3,Pe*3+3);m.push(...Me),g.push(se.x,0,se.y);let ze=y.slice(Pe*2,Pe*2+2);y.push(...ze),v++}for(let Pe=Ie+1;Pe0||c>0||l<360?d=new _p(0,t/2,r,n,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new fu(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var q2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,u;return a==0?u=new yn(t,e,r,n,s,o):u=new IS(t,e,r,n,s,o,a,l),Object.assign(u,{userData:{...i,type:"CubeGeometry"}})}},DS=Math.PI/2,IS=class extends Ae{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let u=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let c=[],h=[],d=[],f=[],p=0,m=0;g("z","y","x",-1,-1,r,e,t,o,s,0),g("z","y","x",1,-1,r,e,-t,o,s,1),g("x","z","y",1,1,t,r,e,n,o,2),g("x","z","y",1,-1,t,r,-e,n,o,3),g("x","y","z",1,-1,t,e,r,n,s,4),g("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,o,0),y("z","y","x",1,-1,-1,r,e,t,o,1),y("z","y","x",-1,1,-1,r,e,t,o,1),y("z","y","x",1,1,1,r,e,t,o,0),y("x","y","z",-1,-1,-1,t,e,r,n,0),y("x","y","z",1,-1,1,t,e,r,n,1),y("x","y","z",-1,1,1,t,e,r,n,0),y("x","y","z",1,1,-1,t,e,r,n,1),y("y","x","z",-1,-1,1,e,t,r,s,0),y("y","x","z",1,-1,-1,e,t,r,s,1),y("y","x","z",1,1,1,e,t,r,s,1),y("y","x","z",-1,1,-1,e,t,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new be(h,3)),this.setAttribute("normal",new be(d,3)),this.setAttribute("uv",new be(f,2));function g(x,w,S,A,E,b,M,T,C,P,D){let I=(b-2*a)/C,R=(M-2*a)/P,U=b/2-a,F=M/2-a,V=T/2,G=C+1,H=P+1,Y=0,k=0,j=new _;for(let X=0;X0?1:-1,d.push(j.x,j.y,j.z),f.push(z/C),f.push(1-X/P),Y+=1}}for(let X=0;X0?(C,P,D)=>c.push(C,P,D):(C,P,D)=>c.push(C,D,P);for(let C=0;C<=l;C++){let P=[],D=DS*(1-C/l),I=Math.cos(D),R=Math.sin(D),U=0;for(let F=0;F<=C;F++){let V=Math.cos(U),G=Math.sin(U);A.x=I*V,A.y=R,A.z=I*G;let H=E.clone().addScaledVector(A,a);h.push(x*H.x,w*H.y,S*H.z),d.push(x*A.x,w*A.y,S*A.z),f.push(0,0),P.push(p++),U+=DS/C}b.push(P)}let T=b.length-1;for(let C=0;Cw.subVectors(G,H).normalize(),A=(G,H)=>Array(G).fill(void 0).map(H),E=A(t.length/3,(G,H)=>new _().fromArray(t,H*3).setLength(n)),b=[],M=1e6;for(let G=0;Gfe[0]==j)}b.push(J)}let T=[];{let G=0,H=0,Y,k,j=f==3;for(let X=0;X<=o;X++){Y=X*(X+1)/2,k=(X+1)*(X+2)/2;for(let q=0;qA(f,()=>p.clone()));for(let G=0;GJ.add(Z),X).multiplyScalar(1/f);for(let J=0;JW[fe]);a.push(...ye.map(fe=>[fe.x,fe.y,fe.z]).flat()),u.push(...ye.map(fe=>(S(fe,C),[w.x,w.y,w.z])).flat())}}let V=[];for(let G=0;Gq%M==G),j=U[G][H],X=U[Y][k];for(let q=0;q{a.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}V.push(j[0][0],X[x][0],j[x][0],X[0][0])}}for(;V.length;){let G,H,Y,k;[G,H]=V.splice(0,2);let j=[G];for(;G!=H;)j.push(H),Y=V.indexOf(H),k=Y%2,H=V.splice(Y-k,2)[1-k];w.subVectors(j[0],j[1]).cross(p.subVectors(j[0],j[2])).normalize();let X=w.dot(j[0])<0;X&&w.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +X],j[q+1-+X],j[0]].forEach(z=>{a.push(z.x,z.y,z.z),u.push(w.x,w.y,w.z)})}}function h(){let d=new _;for(let E=0;E{T<0&&E.x===1&&(l[b]=E.x-1),M.x===0&&M.z===0&&(l[b]=T/2/Math.PI+.5)};for(let E=0,b=0;E.9&&P<.1&&(b<.2&&(l[E+0]+=1),M<.2&&(l[E+2]+=1),T<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function A(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new al(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var Y2=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new Ep(t*.5,s,o):new mu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},Ep=class extends al{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new Ep(t.radius,t.corner,t.cornerSides)}};var Mp=1e-12,Wh=class{constructor(t){this.position=new N;this.startPosition=new N;this.uuid=Se.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Wh(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},qh=class extends Wh{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new qh(this.parent).copy(this)}},_s=class extends Wh{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new qh(this),new qh(this))}static create(e,r){let n=new _s(e,new N(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,s=this.controls.length;ni,Yh=new N,xv=new N,S8=new N,A8=new N,_8=new N,E8=new N,K2=new _,Z2=new _;function J2(i){let t=new N;t.addVectors(i.v0,Yh.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new N;return e.addVectors(i.v2,xv.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new jn(i.v0,t,e,i.v2)}function Tp(i,t,e=Number.EPSILON){return Math.abs(i-t)Math.PI&&(c*=-1),Tp(u,a)?h=(a+u)*(r/c-.5)*8/3/(o-l):h=(o+l)*(r/c-.5)*8/3/(u-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*u,e.y-h*l),[n,s]}function NS(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function Q2(i,t){return OS(i.position,i.controls[1].position,t.position)&&OS(i.position,t.controls[0].position,t.position)}function nD(i,t,e,r,n=.5){let s=Yh.subVectors(t,i).multiplyScalar(n).add(i),o=xv.subVectors(e,t).multiplyScalar(n).add(t),a=S8.subVectors(r,e).multiplyScalar(n).add(e),l=s,u=A8.subVectors(o,s).multiplyScalar(n).add(s),c=_8.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=E8.subVectors(c,u).multiplyScalar(n).add(u);return[i.x,i.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,r.x,r.y]}function iD(i,t,e=12,r=!0){let n=Z2.set(0,0,0),s,o=0,a=[];for(let l=0;l1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function sD(i,t,e,r=12,n=!0){let s=Z2.set(0,0,0),o=0,a=[];for(let l=0;l1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function BS(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=ll(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=ll(i[0].roundedCurveCorner,t)*.5),r}function ll(i,t=12){return i&&i instanceof Wl?t*2:i&&(i instanceof Wn||i instanceof kf)?1:i&&i instanceof hu?t*i.points.length:t}function oD(i,t,e=12,r=!0){let n,s=0;for(let o=0;o1&&!(Tp(i[s-1],i[1],Mp)&&Tp(i[s-2],i[0],Mp))&&(i.push(i[0],i[1]),s++),i}var FS=new N,C8=new N,P8=new N,D8=new N,I8=new N,O8=new N,Ot=class extends Wo{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Or(new _(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Se.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Ot;return s.isClosed=e.isClosed,s.points=e.points.map(o=>_s.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Ot.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;rthis.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=FS.set(e,r);for(let s=0,o=this.points.length;s=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;eo+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=BS(this.points,e,!1),this.roundedCurveDivisions=BS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return sD(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),oD(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=ll(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(NS(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(FS.set(n.x,n.y))/h}let u=0;for(let h=0;h2){let r=0;for(let n=0,s=this.points.length;n0&&!c){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,m=h.getLength(),g=d.getLength(),y=Math.min(u,m*.499),v=Math.min(u,g*.499),x=Math.min(y,v),w=1-x/m,S=x/g,A=h.getPointAt(w,FS),E=d.getPointAt(S,C8);this._subSplitCurve(h,f,w,A,void 0),this._subSplitCurve(d,p,S,void 0,E);let b;if(this.useCubicForRoundedCorners){let M=LS(A,o.position,E)/2,T=Math.tan(M)*A.distanceTo(o.position),[C,P]=eD(A,E,T,P8,D8),D=tD(C,P,o.position),[I,R]=rD(D,A,E,T,I8,O8);b=new jn(A.clone(),I.clone(),R.clone(),E.clone())}else b=new Ii(A.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=b,this.roundedCurves.splice(n+r,0,b),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof Wn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,u=a.getUtoTmapping(n,0),c=nD(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new Ot(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n{let s=new Ot;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof jn&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,u;for(l=0,u=o.length;l0?o[l-1]:null,p;d instanceof jn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof Wn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let c=o[o.length-1],h=!1;return c instanceof jn?c.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(c.v2),h=!0):c instanceof Wn&&c.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof Wo&&(this.shapeHoles=e.holes.map(o=>{let a=new Ot;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var VS=Math.PI*2;function kS({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function R8(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function aD(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function L8(i,t,e,r,n,s,o,a,l,u){let c=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=c*h-c*f-h*d;p<0&&(p=0),p/=c*f+h*d,p=Math.sqrt(p)*(l===u?-1:1);let m=p*n/s*a,g=p*-s/n*o,y=m+(i+e)/2,v=g+(t+r)/2,x=(o-m)/n,w=(a-g)/s,S=(-o-m)/n,A=(-a-g)/s,E=aD(1,0,x,w),b=aD(x,w,S,A);return!u&&b>0&&(b-=VS),u&&b<0&&(b+=VS),{centerx:y,centery:v,ang1:E,ang2:b}}function lD({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let u=(i-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=L8(i,t,e,r,n,s,u,c,o,a),{ang1:f,ang2:p}=d,{centerx:m,centery:g}=d,y=Math.abs(p)/(VS/4);Math.abs(1-y)<1e-7&&(y=1);let v=Math.max(Math.ceil(y),1);p/=v;for(let x=0;x{let{x:w,y:S}=kS(x[0],n,s,m,g),{x:A,y:E}=kS(x[1],n,s,m,g),{x:b,y:M}=kS(x[2],n,s,m,g);return{x1:w,y1:S,x2:A,y2:E,x:b,y:M}})}var St;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(St||(St={}));var br;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(br||(br={}));function nt(i,t){if(!i)throw t||"Assertion Failed!"}var Ze=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s0?n0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){nt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),Cp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),bv=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Xh=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),cD=function(){function i(){var t=new Xh,e=new Cp,r=new bv(0),n=new bv(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new bv(0),r=new bv(1);t.Sym.sidethis.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;nt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),zS=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),dD=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),B8=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new dD,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new dD;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),F8=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?Ze.vertLeq(s.Org,o.Org)?Ze.edgeSign(o.Dst,s.Org,o.Org)<=0:Ze.edgeSign(s.Dst,o.Org,s.Org)>=0:Ze.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return Ze.edgeSign(s.Dst,n,s.Org)>=0;var a=Ze.edgeEval(s.Dst,n,s.Org),l=Ze.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&nt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){nt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new zS;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case St.ODD:return(e&1)!==0;case St.NONZERO:return e!==0;case St.POSITIVE:return e>0;case St.NEGATIVE:return e<0;case St.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,u,c,h=!0;u=r;do nt(Ze.vertLeq(u.Org,u.Dst)),i.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,c=s;a=i.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(u,c),i.deleteRegion(t,l),t.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,nt(l.windingNumber-u.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Ze.vertL1dist(e,t),s=Ze.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(Ze.vertLeq(n.Org,s.Org)){if(Ze.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;Ze.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(Ze.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(nt(!Ze.vertEq(n.Dst,s.Dst)),Ze.vertLeq(n.Dst,s.Dst)){if(Ze.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(Ze.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,u=s.Dst,c,h,d=new Xh,f,p;if(nt(!Ze.vertEq(u,l)),nt(Ze.edgeSign(l,t.event,o)<=0),nt(Ze.edgeSign(u,t.event,a)>=0),nt(o!==t.event&&a!==t.event),nt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(Ze.vertLeq(o,a)){if(Ze.edgeSign(u,o,a)>0)return!1}else if(Ze.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),Ze.intersect(l,o,u,a,d),nt(Math.min(o.t,l.t)<=d.t),nt(d.t<=Math.max(a.t,u.t)),nt(Math.min(u.s,l.s)<=d.s),nt(d.s<=Math.max(a.s,o.s)),Ze.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=Ze.vertLeq(o,a)?o:a,Ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ze.vertEq(d,o)||Ze.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,d)>=0||!Ze.vertEq(u,t.event)&&Ze.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(Ze.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Ze.edgeSign(u,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,u),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),Ze.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),u=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),u=!0),u){i.addRightEdges(t,e,r.Onext,s,s,!0);return}Ze.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,Ze.vertEq(n.Org,r)){nt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Ze.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}nt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(nt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),Ze.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,u=new zS;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,Ze.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=Ze.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var c=t.mesh.connect(a.Dnext,e.anEdge);l=c.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);nt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new zS,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new B8(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(nt(e.fixUpperEdge),nt(++r===1)),nt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,Ze.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new N8(s,Ze.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,nt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Ze.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),k8=function(){function i(){this.mesh=new cD,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=St.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],m=this.mesh.vHead;e=m.next;for(var g=0;g<3;++g)s=e.coords[g],u[g]=s,p[g]=e,l[g]=s,f[g]=e;for(e=m.next;e!==m;e=e.next)for(var y=0;y<3;++y)s=e.coords[y],sl[y]&&(l[y]=s,f[y]=e);var v=0;if(l[1]-u[1]>l[0]-u[0]&&(v=1),l[2]-u[2]>l[v]-u[v]&&(v=2),u[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],c[0]=r.coords[0]-n.coords[0],c[1]=r.coords[1]-n.coords[1],c[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,n);s&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.sthis.bmax[0]&&(this.bmax[0]=u.s),u.tthis.bmax[1]&&(this.bmax[1]=u.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(Ze.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Ze.edgeGoesLeft(n.Lnext)||Ze.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,e===br.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var h=u.n*n;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],n>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[c++]=s,this.elements[c++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new cD),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=St.ODD),e===void 0&&(e=br.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),F8.computeInterior(this,o);var a=this.mesh;return e===br.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===br.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function Es(i){var t=i.windingRule,e=t===void 0?St.ODD:t,r=i.elementType,n=r===void 0?br.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,u=i.normal,c=u===void 0?[0,0,1]:u,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,m=i.debug,g=m===void 0?!1:m;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var y=new k8;i.edgeCreateCallback&&(y.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(y.vertexIdCallback=i.vertexIdCallback);for(var v=0;vthis.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Pp=wv;Pp.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var gD=pn(mD()),Dp={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},WS={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},qS={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},jS=(i,t)=>([e,r])=>(r=e?i:i+t)<=r),ul=class extends Ae{constructor(e,r,n=0,s=12,o=3,a=St.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let u=this._shape.extractShapePointsToFlatArray([],s),c=this._shape.shapeHoles.map(C=>{let P=C.extractShapePointsToFlatArray([],s),D=[];for(let I=P.length-1;I>=1;I-=2){let R=P[I-1],U=P[I-0];D.push(R,U)}return D}),h=[],d=[];for(let C=0;CP.position)).getSize(new N).length()*.1:h[0].length===0?f=n:f=(0,gD.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=Es({windingRule:a,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{p=Dp}let m;try{m=Es({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=WS}if(!p)throw new Error("error generating geometry");let g=p.elementCount;if(m){p.elementCount+=m.elementCount;for(let C=0;Cv&&(v=I),Rw&&(w=R)}this._minX=y,this._minY=x,this._width=v-y,this._height=w-x,this._buffer=new Pp(this._computeBufferEstimatedSize(p));let S=[],A=[];for(let C=p.elementCount-1;C>=0;C--){let P=C>=g,D=C*2,I=p.elements[D+0],R=p.elements[D+1],U=I+R,F={start:I,count:R,normals:[],continuous:[],concave:[]},V=I,G=U-1,H=I+1,Y=this._shape.roundedCurves.length;do{let z=V-I,J=p.vertices[G*2+0],Z=p.vertices[G*2+1],K=p.vertices[V*2+0],W=p.vertices[V*2+1],ye=p.vertices[H*2+0],fe=p.vertices[H*2+1],se=K-J,_e=W-Z,xe=Math.sqrt(se*se+_e*_e);se/=xe,_e/=xe;let Oe=K-ye,Ie=W-fe,Pe=Math.sqrt(Oe*Oe+Ie*Ie);Oe/=Pe,Ie/=Pe,F.normals[z*2+0]=-Ie,F.normals[z*2+1]=Oe,F.concave[z]=se*Ie-_e*Oe>0;let Me=p.vertexIndices[V];if(Array.isArray(Me))F.continuous[z]=!1;else{let[ze,Ue]=this._shape.getCurveIndexFromVertexId(Me-1,!0);if(Ue>0&&Ue<1)F.continuous[z]=!0;else{let L=Ue===1?ze+1:ze-1;L=(L+Y)%Y;let O=Ue===1?0:1,re=this._shape.roundedCurves[ze].getTangent(Ue),ue=this._shape.roundedCurves[L].getTangent(O);F.continuous[z]=re.dot(ue)>.95}}P&&(F.normals[z*2+0]*=-1,F.normals[z*2+1]*=-1),[G,V,H]=[V,H,H+1],H>=U&&(H-=R)}while(H!==I+1);let k=[];k.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(I*2,U*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((z,J)=>[J,J]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(I*2,U*2)});let j=0;for(let z=1;z<=this._bevelSegments;z++){let J=z/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(J))*this._bevel,K=[],W=[],ye=[],fe=[],se=0;for(let xe=0;xere&&(ue-=Math.PI*2);let me=ue-re;if(F.continuous[xe]||P){let De=re+me/2,Te=Math.cos(De)*Z,Ee=Math.sin(De)*Z;K[2*se+0]=Pe+Te*(P?-1:1),K[2*se+1]=Me+Ee*(P?-1:1),fe[se]=xe,se++}else{let De=Math.max(1,Math.floor(s/4*Math.abs(me)/Math.PI));for(let Te=0;Te<=De;Te++){let Ee=re+me*(Te/De),le=Math.cos(Ee)*Z,Ke=Math.sin(Ee)*Z;K[2*se+0]=Pe+le,K[2*se+1]=Me+Ke,fe[se]=xe,se++}}}else K[2*se+0]=Pe+ze,K[2*se+1]=Me+Ue,fe[se]=xe,W[xe]=se,se++,K[2*se+0]=Pe,K[2*se+1]=Me,fe[se]=xe,se++,K[2*se+0]=Pe+L,K[2*se+1]=Me+O,fe[se]=xe,ye[xe]=se,se++}let _e=Es({windingRule:St.POSITIVE,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[K],edgeCreateCallback:xe=>{let Ie=xe.Org.idx,Pe=fe[Ie],Me=fe[(Ie+1)%fe.length];xe.idx=[Pe,Me],xe.Sym.idx=[Me,Pe]},vertexIdCallback:xe=>{let Oe=xe.Lprev.idx;return[Oe?Oe[1]:0,xe.idx?xe.idx[0]:0]}});if(!_e)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!_e.vertexCount){let xe=(z-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(xe))*this._bevel;break}for(let xe=0;xe<_e.vertexIndices.length;xe++){let[Oe,Ie]=_e.vertexIndices[xe];if(Oe===Ie)continue;let Pe=Ie;Ie{let K=0,W=z.boundary.vertexIndices.length;for(;Kme){let Te=ue/me,Ee=0;for(let le=1;le(Ee+1)*Te&&(Ee++,O=this._buildBevelVert(F,Z,(xe+Ee)%W,Ee/(me-1),Ie),S.push(Ue.topN,L.topP,O.topP),l===!1&&S.push(L.bottomP,Ue.bottomN,O.bottomP),Ue=O)}else{let Te=me/ue,Ee=0;for(let le=1;le(Ee+1)*Te&&(Ee++,L=this._buildBevelVert(F,J,(_e+Ee)%K,Ee/(ue-1),Ie),S.push(ze.topN,L.topP,Ue.topN),l===!1&&S.push(L.bottomP,ze.bottomN,Ue.bottomN),ze=L)}_e=(_e+ue)%K,xe=(xe+me)%W,fe=(fe+1)%ye}while(fe!==Oe)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(k,F,S),P){let z=[];for(let J=S.length-1;J>=q+2;J-=3){let Z=S[J-2],K=S[J-1],W=S[J-0];z.push(W,K,Z)}S.splice(q,S.length-q,...z)}if(P){let z=[];for(let J=k[k.length-1].boundary.vertices.length-1;J>=1;J-=2){let Z=k[k.length-1].boundary.vertices[J-1],K=k[k.length-1].boundary.vertices[J-0];z.push(Z,K)}A.push(z)}if(!P){let z=k[k.length-1],J;try{J=Es({windingRule:k.length>1?St.POSITIVE:St.ODD,elementType:br.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...A]})}catch{J=qS}if(!J)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel0,d=e.continuous[c]||f);let p=Math.cos(r.angle),m=Math.sin(r.angle),g=n*2,y=c*2,v=h*2,x=r.boundary.vertices[g+0],w=r.boundary.vertices[g+1],S=(1-m)*this._bevel,A=(x-this._minX)/this._width,E=(w-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(A=o),E=1);let b=e.normals[y+0],M=e.normals[y+1],T=e.normals[v+0],C=e.normals[v+1];if(f){let U=T-b,F=C-M;b=b+U*(1-s),M=M+F*(1-s);let V=Math.sqrt(b*b+M*M);b/=V,M/=V}let P=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),D=P*3,I=P*2,R={i:n,fi:c,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:o};return this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=b*p,this._buffer.normals[D+1]=M*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=b*p,this._buffer.normals[D+4]=M*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A),d||(this.forPathBevel?(P+=1,D+=3,I+=2):(P+=2,D+=6,I+=4),R.topP=P+0,R.bottomP=P+1,this._buffer.positions[D+0]=x,this._buffer.positions[D+1]=w,this._buffer.positions[D+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[D+0]=T*p,this._buffer.normals[D+1]=C*p,this._buffer.normals[D+2]=m,this._buffer.uvs[I+0]=A,this._buffer.uvs[I+1]=E,this.forPathBevel===!1&&(this._buffer.positions[D+3]=x,this._buffer.positions[D+4]=w,this._buffer.positions[D+5]=S,this._buffer.normals[D+3]=T*p,this._buffer.normals[D+4]=C*p,this._buffer.normals[D+5]=-m,this._buffer.uvs[I+2]=E,this._buffer.uvs[I+3]=A)),this.vertexCache[a]=R,R}clone(){let e=new ul(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var Qh=class extends Ae{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=St.ODD;this.elementType=br.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let p=0,m=s.length/2;pm&&(m=E),by&&(y=b)}let v=m-p,x=y-g;for(let w=0,S=d;w0&&o.update());let l=o??new Ot(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Qh(i.shape,n,{windingRule:o}):a=new Kh(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var vD=Math.PI*2,Jh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=Se.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,u=i.shape,c=t*.5,h=e*.5,d=H8(u,c,h,n*Math.PI/180,r,s);u.isClosed=!0,u.update();let f;return n===0?(f=new Ae,f.setAttribute("position",new be([],3))):f=yi.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function H8(i,t,e,r,n,s){if(r>=vD)return n>30||n%4===0?(W8(i,t,e,s),Math.round(n/4)):yD(i,r,n,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},u=lD({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%u.length===0?j8(i,o.x,o.y,u,n,t,e,s):yD(i,r,n,t,e,s)}function j8(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Zh(t,e));for(let u=0,c=r.length;u0?xD(i,s,o,a):i.addPoint(Zh(0,0)),l}function yD(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,u=Math.sin(l)*r,c=Math.cos(l)*n;i.addPoint(Zh(u,c))}return t0?xD(i,r,n,s):i.addPoint(Zh(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&bD(i,r,n,s)),1}function W8(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(Av(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(Av(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(Av(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(Av(n,s-e,n+a,s-e,n-a,s-e)),r>0&&bD(i,t,e,r)}function Zh(i,t){return new _s(Se.generateUUID(),new N(i,t))}function Av(i,t,e,r,n,s){let o=Zh(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function xD(i,t,e,r){wD(i,t,e,r).forEach(s=>i.addPoint(s))}function bD(i,t,e,r){let n=wD(i,t,e,r),s=new Ot;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function wD(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new N(n/t,s/e),a=i.points.map(l=>{let u=l.clone();return u.uuid=Se.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var SD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=i.parameters,d=new Ip(!1,t,e,r,n,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},YS=new Ws([0,0,0],1),Ip=class extends Ae{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new _,m=new _,g=p(),y=p(),v=p(),x,w,S,A,E,b,M,T,C=p(),P=p(),D=p(),I=p(),R=p(),U=p(),F=p(),V=p(),G=r-2*l+.001,H=G/o,Y=Math.ceil(a*o),k=Y+1,j=G/Y,X=-G/2,q=c+1,z=2*Math.PI/c,J=Math.PI/2/d,Z=.01,K=Math.min((1-h/100)*l,l-Z),W=l-K,ye=0,fe=2,se=d*fe+fe,_e=q*se/fe,xe=_e+q*k,Oe=Math.max(0,q*(k+se)),[Ie,Pe,Me]=[3,3,2].map(ke=>Array(Oe*ke).fill(0)),ze=[],Ue=s-l;function L(ke,Ne){let We=Math.PI/2;b=Ne*j,T=2*Math.PI*(b%H)/H+We,b+=X,M=Math.sin(T)*Ue,E=Math.cos(T)*Ue,t?ke.set(E,M,b):ke.set(E,b,M)}L(m,-1e-10),L(g,0),C.copy(m),L(m,1);let O=m.distanceTo(g),re=f?0:W+K,ue=O*Y+2*re,me=K,De=ue-re;for(let ke=0;ke<=Y;ke++){L(y,ke),V.subVectors(y,C).normalize(),C.copy(y),U.copy(y).setComponent(+t+1,0).normalize(),F.crossVectors(V,U).normalize();let Ne=ke===0,We=ke===Y,$e=Ne?3*Math.PI/2:J,_t=Ne?me:De,ir=Ne?q:xe,Gr=Ne?0:Oe-q,Q=V.clone().multiplyScalar(Ne?-W:W).add(y),ce=V.clone().multiplyScalar(Ne?-1:1).normalize();for(let ve=0;ve{Ie[ye*3+Fe]=Q.getComponent(Fe),Pe[ye*3+Fe]=ce.getComponent(Fe)}),Me[ye*2]=+We,Me[ye*2+1]=ve/c),g.copy(D).multiplyScalar(K),v.addVectors(y,g);for(let Fe=0;Fe{Ie[ye*3+Pr]=g.getComponent(Pr),Pe[ye*3+Pr]=R.getComponent(Pr)});let Hr=+Ne+Math.sin(Et);Me[ye*2]=(_t+W*Hr)/ue,Me[ye*2+1]=ve/c}}g.addVectors(y,P),ye=_e+ke*q+ve,[0,1,2].forEach(Fe=>{Ie[ye*3+Fe]=g.getComponent(Fe),Pe[ye*3+Fe]=D.getComponent(Fe)}),Me[ye*2]=(re+ke*O)/ue,Me[ye*2+1]=ve/c}}let Te=k+2*d+fe,Ee=1,[le,Ke]=[+f,Te-1];for(let ke=le;ke<=Ke-1;ke++){let Ne=f&&ke===Ke-1;for(let We=0;We{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new Wo;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new du(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var ao=new ie,XS=new gt,_v=new _,hl=class extends Yt{constructor(){super(),this.uuid=Se.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new Gt().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r0)for(let d=0;d0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c0,w=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,A=m.vertexColors.length>0,E=0;if(E=c(E,0,0),E=c(E,1,g),E=c(E,2,y),E=c(E,3,v),E=c(E,4,x),E=c(E,5,w),E=c(E,6,S),E=c(E,7,A),r.push(E),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let b=this.faceVertexUvs[0][p];r.push(f(b[0]),f(b[1]),f(b[2]))}if(x&&r.push(h(m.normal)),w){let b=m.vertexNormals;r.push(h(b[0]),h(b[1]),h(b[2]))}if(S&&r.push(d(m.color)),A){let b=m.vertexColors;r.push(d(b[0]),d(b[1]),d(b[2]))}}function c(p,m,g){return g?p|1<0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new hl().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ev.call(new Ge(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",ED.call(new Ge(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",MD.call(new Ge(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",MD.call(new Ge(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a0){let n=new be(t.skinIndices.length*4,4);e.setAttribute("skinIndex",TD.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new be(t.skinWeights.length*4,4);e.setAttribute("skinWeight",TD.call(n,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ae,r=t.geometry;if(t.isPoints||t.isLine){let n=new be(r.vertices.length*3,3),s=new be(r.colors.length*3,3);if(e.setAttribute("position",Ev.call(n,r.vertices)),e.setAttribute("color",ED.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new be(r.lineDistances.length,1);e.setAttribute("lineDistance",q8.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};hl.prototype.isGeometry=!0;var QS=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,n,s,o=t.faces;for(n=0;n0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,u;if(l>0){u=[];for(let y=0;y0){d=[];for(let y=0;y0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let y=0;y0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new _,r,n,s,o,a,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;Q8(l,u,d,f);let p=[],m,g,y,v,x,w,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),y=new _,x=3/8,w=1/8,S=g.faces.length,S!=2&&(x=.5,w=0,S!=1),y.addVectors(g.a,g.b).multiplyScalar(x),e.set(0,0,0),o=0;o3&&(A=3/(8*r)),E=1-r*Number(A),b=A,r<=2&&(r==2?(E=3/4,b=1/8):r==1||r==0),P=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new Cv(n).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Eu(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(ln);let o=100/ln.x;Object.assign(s.parameters,{width:100,height:ln.y*o,depth:ln.z*o}),t(this.build(s))})}};var Pv=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Ot?i.shape:new Ot,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,u=t*.5,c=e*.5,h=0,d=0,f=2*Math.PI/r;for(let m=0;m0){{let Pe=Y.clone().add(k).multiplyScalar(.5),Me=w.clone().sub(Pe).normalize(),Ue=x.clone().sub(Pe).normalize().add(Me).normalize().multiplyScalar(-1),L=q.clone().sub(X);V(Pe,L,Ue,E.angle())}let Oe,Ie;{let Pe=new _;Rp(T,fe,Pe);let Me=q.clone().add(j).multiplyScalar(.5);Me=K8(Me,k,w);let ze=q.clone().sub(j);[Oe,Ie]=V(Me,ze,Pe,D,j.y)}{let Pe=Oe,Me=Pe.clone().setY(0).normalize(),ze=new _(0,-1,0),Ue=Me.clone().cross(ze);G(Pe,Me,ze,Ue)}F.concat(Ie);{let Pe=E.angle(),Me=Math.PI-Pe,ze=w.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let Ue=new _,L=[];for(let re=0;ree&&A>r?Math.min(w*e/S,w*r/A):S>e?w*e/S:A>r?w*r/A:w}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=c.x,m=h.x,g=h.y,y=c.y;t.addPoint(t.createPoint(p,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(p,y)),t.isClosed=!0;let v=!0;for(let w=0,S=t.points.length;w0&&f[w]!==f[w-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=yi.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var DD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Se.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=i.parameters,c;return u===0?(c=new Ae,c.setAttribute("position",new be([],3))):c=new Kl(.5*t,n,s,o,a,l,u*Se.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...i,type:"SphereGeometry"}})}};var ID=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new jo(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var OD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new eA(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},eA=class extends Ae{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-c,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(Z=0,K=0,W=0)=>new _(Z,K,W),p=f(),m=f(),[g,y,v]=[e/2,t/2,r/2],x=-y,w=+y,[S,A,E]=[f(x,-g,+v),f(x,-g,-v),f(x,+g,-v)],b=(Z,K=!1)=>Math.sin(Z-Math.PI/(1+ +K)),M=(Z,K=!1)=>Math.cos(Z-Math.PI/(1+ +K));E.y=Math.sin(n)*e-g;let T=Math.cos(n)*e-v,C=S.z-c;n<=d?(E.z=Math.min(T,C),E.z==C&&(E.y-=(T-C)/Math.tan(d-n))):A.z=Math.min(A.z-T-v,S.z-c),p.subVectors(S,A),m.subVectors(E,A);let P=Math.min(p.length(),m.length())*s/100,D=P*Math.tan(n/2),I=P/Math.cos(n/2),R=p.clone().normalize().add(m.normalize()).setLength(I).add(A);p.set(0,b(n,!0),M(n,!0)),h.push([E,p.clone()]);let U=(Math.PI-n)/o;for(let Z=0;Z<=o;Z++){let K=d+n+Z*U;p.set(0,Math.sin(K)*D,Math.cos(K)*D),p.add(R),m.set(0,b(K),M(K)),h.push([p.clone(),m.clone()])}h.push([S,f(0,1,0)]);let F=Math.sin(U/2)*D*2,V=h.length-1,G=h[0][0].distanceTo(h[1][0]),H=h[V-1][0].distanceTo(h[V][0]),Y=G+F*o+H;h[0].push(1);for(let Z=0;Z<=o;Z++)h[Z+1].push(1-(G+Z*F)/Y);h[V].push(0);let[k,j,X]=h[0],q,z,J;for(let Z=1;Z{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ae=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ae.version}static addUnaryOp(t){return ae.max_unop_len=Math.max(t.length,ae.max_unop_len),ae.unary_ops[t]=1,ae}static addBinaryOp(t,e,r){return ae.max_binop_len=Math.max(t.length,ae.max_binop_len),ae.binary_ops[t]=e,r?ae.right_associative.add(t):ae.right_associative.delete(t),ae}static addIdentifierChar(t){return ae.additional_identifier_chars.add(t),ae}static addLiteral(t,e){return ae.literals[t]=e,ae}static removeUnaryOp(t){return delete ae.unary_ops[t],t.length===ae.max_unop_len&&(ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops)),ae}static removeAllUnaryOps(){return ae.unary_ops={},ae.max_unop_len=0,ae}static removeIdentifierChar(t){return ae.additional_identifier_chars.delete(t),ae}static removeBinaryOp(t){return delete ae.binary_ops[t],t.length===ae.max_binop_len&&(ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops)),ae.right_associative.delete(t),ae}static removeAllBinaryOps(){return ae.binary_ops={},ae.max_binop_len=0,ae}static removeLiteral(t){return delete ae.literals[t],ae}static removeAllLiterals(){return ae.literals={},ae}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ae(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ae.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ae.binary_ops[String.fromCharCode(t)]||ae.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ae.isIdentifierStart(t)||ae.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ae.hooks[t]){let r={context:this,node:e};return ae.hooks.run(t,r),r.node}return e}searchHook(t){if(ae.hooks[t]){let e={context:this};return ae.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ae.SPACE_CODE||t===ae.TAB_CODE||t===ae.LF_CODE||t===ae.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ae.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index0;){if(ae.binary_ops.hasOwnProperty(t)&&(!ae.isIdentifierStart(this.code)||this.index+t.lengths.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&c(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ae.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ae.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ae.isDecimalDigit(t)||t===ae.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ae.SQUOTE_CODE||t===ae.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ae.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ae.max_unop_len),r=e.length;r>0;){if(ae.unary_ops.hasOwnProperty(e)&&(!ae.isIdentifierStart(this.code)||this.index+e.length=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ae.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===ae.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ae.CBRACK_CODE)for(let o=e.length;o":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});ae.max_unop_len=ae.getMaxKeyLen(ae.unary_ops);ae.max_binop_len=ae.getMaxKeyLen(ae.binary_ops);var mc=i=>new ae(i).parse(),$8=Object.getOwnPropertyNames(ae);$8.forEach(i=>{mc[i]===void 0&&i!=="prototype"&&(mc[i]=ae[i])});mc.Jsep=ae;var eq="ConditionalExpression",tq={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:eq,test:r,consequent:n,alternate:s},r.operator&&i.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&i.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};mc.plugins.register(tq);var rq=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],nq=["0","1","2","3","4","5","6","7","8","9","."],iq=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function sq(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}mc.addBinaryOp("^",11,!0);function Ov(i,t,e="number"){let r="";for(let o=0;o0&&"id"in l){console.error("Two variables in a row",i);return}let u=t.getVariable(a.id),c=En.getDisplayedValue(u);e==="number"&&En.isTextValue(u)&&Array.isArray(u.textValue)&&u.textValue.length===1?c=parseFloat(c).toString():e==="boolean"&&En.isBoolean(u)?c=u?"true":"false":e==="boolean"&&En.isTextValue(u)&&!Array.isArray(u.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(r+=a.name),a.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!sq(a.name)&&!nq.includes(a.name)&&!rq.includes(a.name)&&!iq.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=mc(r)}catch(o){console.error(r,o);return}let s;try{s=Dt(n)}catch(o){console.error(r,n,o)}return s}function Dt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(Dt(i.left)===Dt(i.right));case"!=":return Number(Dt(i.left)!==Dt(i.right));case">":return Number(Dt(i.left)>Dt(i.right));case">=":return Number(Dt(i.left)>=Dt(i.right));case"<":return Number(Dt(i.left)=1)try{t=Dt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=Dt(i.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(Dt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var oq=new ie,aq=new ie;function lq(i,t,e){let r=[new _,new _,new _],n=[new _,new _,new _];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((s,o)=>{let a=n[o],l=Se.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ie().makeBasis(r[0],r[1],r[2])}var kD=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??Jh.create({parameters:Jw}).userData.shape;return{path:i.path??gh.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:s,extrusion:{...Xy,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new nA(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ae,{userData:{...i,type:"PathGeometry"}})}},nA=class extends Ae{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!FD(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:n,offset:s}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((n+s)*o):Math.ceil(Math.min(1,n+s)*o),u=Math.min(Math.max(2,l-a+1),o+2),c=[],h=[];for(let G=0;G{c[G]=c[G].clone().lerp(c[H],Y),h[G]=lq(h[G],h[H],Y)},f=0,p=s*o%1;(!this.inputs.path.isClosed||n<=1)&&(p||s===0)&&(f=p,d(0,1,f));let m=0,g=(s+n)*o%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&s+n<1)&&g&&(m=g,d(c.length-1,c.length-2,1-m)),n===0){let G=c.length-1;c[G].copy(c[0]),h[G].copy(h[0])}this._applyPathModifiers(h,f,m);let{bevel:y,bevelSides:v}=this.inputs.parameters.extrusion,x=y>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:A,vertices:E}=this._computeShapePoints(w),b=0,M;x==="round"&&(M=new ul(this.inputs.shapeData,2*y,y,w,v,void 0,!0),b=M.getAttribute("position").count);let T=0,C=0;A.sort((G,H)=>G.start-H.start),A.forEach(G=>{G.verticesStart=T,G.verticesCount=G.continuous.reduce((H,Y,k)=>H+(k===0||!Y?2:1),0),C+=G.verticesCount,T=C});let P=C*u,D,I=0;if(this._isOpenEnded()&&x==="flat"){try{D=Es({windingRule:St.ODD,elementType:br.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{D=qS}I=D.vertexCount}let R=P+2*I+b*2,U=P+2*I,F={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},V=[];if(A.forEach(G=>{this._extrudeRegion(G,E,h,c,F,V,this._isGeometryClosed()&&!this._isOpenEnded())}),D&&(this._closeEnd(D,P,V,F,h[0],c[0],!1),this._closeEnd(D,P+I,V,F,h[h.length-1],c[c.length-1],!0)),M){F.positions.set(M.getAttribute("position").array,U*3),F.normals.set(M.getAttribute("normal").array,U*3),F.uvs.set(M.getAttribute("uv").array,U*2);let G=V.length;V.push(...M.getIndex().array.map(k=>k+U)),U+=b,F.positions.set(M.getAttribute("position").array,U*3),F.normals.set(M.getAttribute("normal").array,U*3),F.uvs.set(M.getAttribute("uv").array,U*2);let H=V.length;V.push(...M.getIndex().array.map(k=>k+U)),this.setAttribute("position",new Ge(F.positions,3)),this.setAttribute("normal",new Ge(F.normals,3)),this.setAttribute("uv",new Ge(F.uvs,2)),this.setIndex(V);let Y=oq;Y.copy(h[h.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(Y,U,R),Y.copy(h[0]).setPosition(c[0]).multiply(aq.makeScale(1,1,-1)),this.applyMatrix4OnRange(Y,U-b,U),this.reverseIndicesOnRange(G,H)}else this.setAttribute("position",new Ge(F.positions,3)),this.setAttribute("normal",new Ge(F.normals,3)),this.setAttribute("uv",new Ge(F.uvs,2)),this.setIndex(V)}_extractPathPoints(){let r=yv(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let n=[r[0]];return r.forEach(o=>{n[n.length-1].distanceToSquared(o)>.001&&n.push(o)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],n=e.length,s=this.inputs.path.isClosed,o=new _,a=new _,l=new _,u=new _,c=new _(0,1,0);for(let g=0;g0&&(p*=-1);for(let g=1;g{let p=f===0?0:f===s-1?1:(f-r)/(s-(n===0?0:1)-(r+(1-n)));c.makeRotationZ(Se.lerp(o,o+a,p)*Se.DEG2RAD);let m=Se.lerp(l,u,p);h.makeScale(m,m,m),d.multiply(c).multiply(h)}),e}_computeShapePoints(e=12,r=St.ODD){let n=this.inputs.shapeData,s=n.extractShapePointsToFlatArray([],e),o=n.shapeHoles.map(m=>{let g=m.extractShapePointsToFlatArray([],e),y=[];for(let v=g.length-1;v>=1;v-=2){let x=g[v-1],w=g[v-0];y.push(x,w)}return y}),a;try{a=Es({windingRule:r,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=Dp}let l;try{l=Es({windingRule:St.ODD,elementType:br.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=WS}if(!a)throw new Error("error generating geometry");let u=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let m=0;mh&&(h=v),xf&&(f=x)}let p=[];for(let m=a.elementCount-1;m>=0;m--){let g=m>=u,y=m*2,v=a.elements[y+0],x=a.elements[y+1],w=v+x,S={start:v,count:x,normals:[],isHole:g,continuous:[],verticesStart:0,verticesCount:0};p.push(S);let A=v,E=w-1,b=v+1,M=n.roundedCurves.length;do{let T=A-v,C=a.vertices[E*2+0],P=a.vertices[E*2+1],D=a.vertices[A*2+0],I=a.vertices[A*2+1],R=a.vertices[b*2+0],U=a.vertices[b*2+1],F=D-C,V=I-P,G=Math.sqrt(F*F+V*V);F/=G,V/=G;let H=D-R,Y=I-U,k=Math.sqrt(H*H+Y*Y);H/=k,Y/=k,S.normals[T*2+0]=-Y,S.normals[T*2+1]=H;let j=a.vertexIndices[A];if(Array.isArray(j))S.continuous[T]=!1;else{let[X,q]=n.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)S.continuous[T]=!0;else{let z=q===1?X+1:X-1;z=(z+M)%M;let J=q===1?0:1,Z=n.roundedCurves[X].getTangent(q),K=n.roundedCurves[z].getTangent(J);S.continuous[T]=Z.dot(K)>.95}}g&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[E,A,b]=[A,b,b+1],b>=w&&(b-=x)}while(b!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,n,s,o){let a=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,n,s,o,a,l){let u=new _,c=new _,h=new _,d=new _,f=new N;n.forEach((m,g)=>{let y=s[g],v=e.verticesStart*n.length+e.verticesCount*g;for(let x=0;x{this.update(e),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c}=e,h=En.getDisplayedValue(u),d=c===2?h.toUpperCase():c===3?h.toLowerCase():h,f=dq(e,r,d),{shapes:p,charWidths:m,charCoords:g}=r.generateShapes(f,e),y=(typeof n=="number"?n:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(A=>new Ot().fromShape(A,!0));this.vectorShapes=x;let w=x.map(A=>yi.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?St.NONZERO:St.ODD,subdivisions:this.isLowResolution&&o>0?hq:uq}})),S=w.length?ws(w):VD();S.translate(-y,v,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([A,E])=>{this.setAttribute(A,E)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=ui(new Ae,td.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function dq(i,t,e){let r=[""],n="";for(let s of e)n+=s,s===" "||s===` +`?(r[r.length-1]+=n,n="",s===` +`&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var UD,rd=new Promise(i=>{UD=i}),zD=!1;var Rv;function GD(){if(zD)return;if(Rv)return Rv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.521/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});UD(l),zD=!0}return Rv=i(),Rv}function gc(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let u of o){let c=s;for(let h of u)c=c[h];for(n in c){let h=c[n];Hw(h)&&(c[n]=t.getVariable(h,[r.uuid,"geometry",...u,n]),Hw(c[n])&&(c[n]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let u=Ot.createFromState(s.shape,s.width,s.height);a.shape=u}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),a.geometry=new Eu().parse(s);else if(s.type==="SubdivGeometry"){let u=new Fr(s,e);return u.data=i,u}else if(s.type==="TextGeometry")return new td(s,t);let l;try{l=iA(a)}catch(u){console.error(u)}if(!l){let u=Ot.createFromState(mh.defaultData(),100,100);a.shape=u,l=iA(a)}return l}var fq=new ie;function Lp(i,t,e,r){let n=i.position.array,s=i.normal.array,o=fq.makeScale(t,e,r).invert().elements,a,l,u;for(var c=0,h=n.length;c{tt=i});var HD=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),jD=new Uint32Array([0,1,2,3]),WD=new Uint8Array([4]),Fr=class extends Ae{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=$s.div(r,n);this.subdividedGeometry&&Lp(this.subdividedGeometry.attributes,...s),this.originalGeometry&&Lp(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(nd.fromArray(s));let a=nd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Fr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new yn(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Lv.setFromBufferAttribute(r),Lv.getCenter(n),e.boundingSphere.radius=n.distanceTo(Lv.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lv.getSize(nd);let s={width:nd.x,height:nd.y,depth:nd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,u=e?.phongAngle??35;n===!1&&(u=-1),r&&(tt.free_bvh(r),tt.free_subdivision_surface(r));try{o=Fr.allocate(e,s)}catch(c){console.error(c,e),o=Fr.allocate({positionWASM:HD,indexWASM:jD,verticesPerFaceWASM:WD},s)}if(tt.set_destination_refinement_level(o,0),a=Fr.buildLevel(o,!0,u),e.subdivisions>0)try{tt.set_destination_refinement_level(o,e.subdivisions),l=Fr.buildLevel(o,!1,u)}catch{try{tt.set_destination_refinement_level(o,e.subdivisions-1),l=Fr.buildLevel(o,!1,u)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?r.geometry:gc(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,u,c;({positions:a,triIndices:c}=yc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:u}=lA(a,c,s,h),{positions:a,indices:l,verticesPerFace:u}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=HD,s=jD,o=WD);let u=n.length,c=s.length,h=o.length,d=n.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,g=f*Uint32Array.BYTES_PER_ELEMENT,y=tt._malloc(p),v=new Float32Array(tt.HEAPF32.buffer,y,d),x=new Uint32Array(tt.HEAPU32.buffer,y+m,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let w;e?.scaleBaked?.some(A=>A!==1)&&(w=new ie().makeScale(...e.scaleBaked)),r&&(w?w.premultiply(r):w=r);let S=w?tt.alloc_subdivision_surface2(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h,w.elements):tt.alloc_subdivision_surface(y,u,y+m,c,y+m+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return tt._free(y),S}static buildLevel(e,r,n,s,o){let a=o?tt.get_mesh_data2(e,r?tt.Level.CONTROL:tt.Level.REFINED,n,o.elements):tt.get_mesh_data(e,r?tt.Level.CONTROL:tt.Level.REFINED,n),l=8,u=tt.HEAPU32.subarray(a>>2,(a>>2)+l),c=u.subarray(4,4+4),h=0,d=tt.HEAPU32[u[h]>>2],f=tt.HEAPF32.subarray(d>>2,(d>>2)+c[h]);h++;let p=tt.HEAPU32[u[h]>>2],m=tt.HEAPF32.subarray(p>>2,(p>>2)+c[h]);h++;let g=tt.HEAPU32[u[h]>>2],y=tt.HEAPU32.subarray(g>>2,(g>>2)+c[h]);h++;let v=tt.HEAPU32[u[h]>>2],x=tt.HEAPU32.subarray(v>>2,(v>>2)+c[h]);if(h++,s===void 0){let w=new Ae;if(w.setIndex(new Ws(x,1)),w.setAttribute("position",new be(f,3)),w.setAttribute("normal",new be(m,3)),r){w.setAttribute("faceMap",new Ws(y,1));let S=new Float32Array(m.length/3*4).fill(0);w.setAttribute("color",new Ge(S,4))}return tt.free_mesh_data(a),w.userData.type="SubdivGeometry",w}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(m),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,tt.free_mesh_data(a)}static freeSubdivPointer(e){tt.free_bvh(e),tt.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=tt.get_wireframe_data_for_base_level(e),o=4,a=tt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),u=0,c=tt.HEAPU32[a[u]>>2],h=tt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=tt.HEAPU32[a[u]>>2],f=tt.HEAPU32.subarray(d>>2,(d>>2)+l[u]);if(r===void 0){let p=new Ae;p.setAttribute("position",new be(h,3));let m=new Float32Array(h.length);for(let g=0,y=h.length;g>2,(o>>2)+a),u=l.subarray(3,3+3),c=0,h=tt.HEAPU32[l[c]>>2],d=new Float32Array(tt.HEAPF32.subarray(h>>2,(h>>2)+u[c]));c++;let f=tt.HEAPU32[l[c]>>2],p=new Uint32Array(tt.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=tt.HEAPU32[l[c]>>2],g=new Uint8Array(tt.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return tt.free_topological_data(o),{positions:d,indices:p,verticesPerFace:g}}};var qD=["getX","getY","getZ"];function yc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let u=0;u=360){let d=l.length/2/u;l=l.filter((f,p)=>Math.floor(p/2)%d===0)}let c=0;for(let d=0;d=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a.005||r&&r.some((u,c)=>c%2===1?!1:a>=r[c]&&agq,calcBooleanTopological:()=>mq,freeMeshSet:()=>bq,getMeshSet:()=>yq,hasOpenEdges:()=>vq,transformMeshSet:()=>xq});var YD,XD=new Promise(i=>{YD=i});var Bv;function QD(){if(Bv)return Bv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.521/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(u=>u.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});YD(l)}return Bv=i(),Bv}var ft,id;XD.then(i=>ft=i);function pq(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=yc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:u}=lA(s,o,i);a=u.length,r=[];for(let c=0,h=0;c>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=ft.HEAPU32[s[a]>>2],u=new Float32Array(ft.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=ft.HEAPU32[s[a]>>2],h=new Uint32Array(ft.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=ft.HEAPU32[s[a]>>2],f=new Uint8Array(ft.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ft.free_mesh_data(r),{positions:u,indices:h,verticesPerFace:f}}function gq(i,t,e,r){id===void 0&&(id=ft.init_csg());let n=KD(i),s=ft.csg_calc(id,n,i.length,r,ZD(t));ft._free(n);let o=5,a=ft.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=ft.HEAPU32[a[u]>>2],h=ft.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=ft.HEAPU32[a[u]>>2],f=ft.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let p=l[u];e.setAttribute("position",new be(h,3)),e.setAttribute("normal",new be(f,3));let m=ft.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new fr),e.boundingSphere.radius=-1,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},ft.free_mesh_data(s),p}function yq(i,t,e){if(ft===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let y=i.userData;s=y.verticesPerFace.length,r=y.positions,n=Array(y.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,w=0;vwq[i.type].create(i);function sd(i){return i!==null&&"booleanOp"in i}var od=class extends jh(_r){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ie}updateVisible(e){super.updateVisible(e),this.visible=!sd(this.parent)&&this.visible,sd(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Ji.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),sd(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof od&&(e.freeBooleanPointer(),sd(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&sd(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),sd(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Fv=new Pt;function Np(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h=t;hl&&(l=d),f>u&&(u=f),p>c&&(c=p)}Fv.min.set(s,o,a),Fv.max.set(l,u,c),Fv.getCenter(r),Fv.getSize(n).multiplyScalar(.5)}var Sq=new Ae,Aq=new Ho,$t=class extends od{constructor(t,e){super(Sq,Aq),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Np(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Bp=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Mn=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Se.generateUUID(),this.type=t,this.name=""}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Mn&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let n=0;n0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let u=this.getTemp(e,n);if(u)return e.format(u,l,r);{u=super.generate(e,r,n,a.output,s);let c=this.generate(e,l,n);return e.addNodeCode(u+" = "+c+";"),e.format(u,l,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var jt=class extends Ye{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var wr=class extends jt{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof N?e:new N(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var kn=class extends jt{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof _?e:new _(e,r,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var gr=class extends Re{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var vi=class extends jt{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof gr?e:new gr(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var _q=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,JD=/[a-z_0-9]+/gi,ge=class extends Ye{constructor(e,r,n,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,n,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,n,s,o){return e.format(this.name,this.getType(e),r)}},It=uA;It.PI="PI",It.PI2="PI2",It.RECIPROCAL_PI="RECIPROCAL_PI",It.RECIPROCAL_PI2="RECIPROCAL_PI2",It.LOG2="LOG2",It.EPSILON="EPSILON";var Mq=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.| +)*?)}`,"gim"),Tq=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ad=class extends Ye{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,n,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=Mq.exec(e);if(r){let n=r[2],s;for(;s=Tq.exec(n);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ld=class extends Ye{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(s,this.getType(e),r)}};cn.addKeyword("uv",function(){return new ld});cn.addKeyword("uv2",function(){return new ld(1)});var vc=class extends Ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??vc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Di:return["Linear"];case et:return["sRGB"];default:return[]}}generate(e,r){let n=this.input.build(e,"v4"),s=this.getType(e),o=vc.Nodes[this.method],a=e.include(o);if(a===vc.LINEAR_TO_LINEAR)return e.format(n,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+n+", "+l+" )",s,r)}else return e.format(a+"( "+n+" )",s,r)}fromEncoding(e){let r=vc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=vc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},ni=vc;ni.Nodes={LinearToLinear:new ge(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(` +`)),sRGBToLinear:new ge(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(` +`)),LinearTosRGB:new ge(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(` +`))},ni.LINEAR_TO_LINEAR="LinearToLinear",ni.SRGB_TO_LINEAR="sRGBToLinear",ni.LINEAR_TO_SRGB="LinearTosRGB";var Rt=class extends ge{constructor(e="",r,n,s,o){super(e,o,s,n,r);this.nodeType="Expression"}};var ii=class extends jt{constructor(e=new or,r,n,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new ld,this.bias=n,this.project=s!==void 0?s:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let n=this.getTexture(e,r),s=this.uv.build(e,this.project?"v4":"v2"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=o?"tex2DBias":"tex2D",o?l=a+"( "+n+", "+s+", "+o+" )":l=a+"( "+n+", "+s+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new ni(new Rt("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,c),e.removeContext(),e.format(l,c,r)}};var Ce=class extends jt{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,n,s,o,a){return e.format(this.value+(this.value%1?"":".0"),s,r)}};var Fp=class extends Ye{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,n,s,o){s=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",u=[];if(a.inputs){for(let c=0;ce.getTypeLength(r)?n:r}generate(e,r){let n=this.getType(e);this.type=n;let s=this.a.build(e,n),o=this.b.build(e,n);return e.format("( "+s+" "+this.op+" "+o+" )",n,r)}},Tn=hA;Tn.ADD="+",Tn.SUB="-",Tn.MUL="*",Tn.DIV="/";var Wt=class extends Ye{constructor(e,r=Wt.ABS,n,s){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:s=r,typeof n!="string"?this.c=n:s=n,this.method=s,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Wt.MIX:case Wt.CLAMP:case Wt.REFRACT:case Wt.SMOOTHSTEP:case Wt.FACEFORWARD:return 3;case Wt.MIN:case Wt.MAX:case Wt.MOD:case Wt.STEP:case Wt.REFLECT:case Wt.DISTANCE:case Wt.DOT:case Wt.CROSS:case Wt.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),n=this.b?e.getTypeLength(this.b.getType(e)):0,s=this.c?e.getTypeLength(this.c.getType(e)):0;return r>n&&r>s?this.a.getType(e):n>s?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Wt.LENGTH:case Wt.DISTANCE:case Wt.DOT:return"f";case Wt.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let n,s,o,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Wt.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,r);case Wt.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,r);case Wt.CROSS:n=this.a.build(e,"v3"),s=this.b.build(e,"v3");break;case Wt.STEP:n=this.a.build(e,a===1?"f":c),s=this.b.build(e,c);break;case Wt.MIN:case Wt.MAX:case Wt.MOD:n=this.a.build(e,c),s=this.b.build(e,l===1?"f":c);break;case Wt.REFRACT:n=this.a.build(e,c),s=this.b.build(e,c),o=this.c.build(e,"f");break;case Wt.MIX:n=this.a.build(e,c),s=this.b.build(e,c),o=this.c.build(e,u===1?"f":c);break;default:n=this.a.build(e,c),this.b&&(s=this.b.build(e,c)),this.c&&(o=this.c.build(e,c));break}let d=[];d.push(n),s&&d.push(s),o&&d.push(o);let f=this.getNumInputs(e);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",h,r)}},ot=Wt;ot.RAD="radians",ot.DEG="degrees",ot.EXP="exp",ot.EXP2="exp2",ot.LOG="log",ot.LOG2="log2",ot.SQRT="sqrt",ot.INV_SQRT="inversesqrt",ot.FLOOR="floor",ot.CEIL="ceil",ot.NORMALIZE="normalize",ot.FRACT="fract",ot.SATURATE="saturate",ot.SIN="sin",ot.COS="cos",ot.TAN="tan",ot.ASIN="asin",ot.ACOS="acos",ot.ARCTAN="atan",ot.ABS="abs",ot.SIGN="sign",ot.LENGTH="length",ot.NEGATE="negate",ot.INVERT="invert",ot.MIN="min",ot.MAX="max",ot.MOD="mod",ot.STEP="step",ot.REFLECT="reflect",ot.DISTANCE="distance",ot.DOT="dot",ot.CROSS="cross",ot.POW="pow",ot.MIX="mix",ot.CLAMP="clamp",ot.REFRACT="refract",ot.SMOOTHSTEP="smoothstep",ot.FACEFORWARD="faceforward";var cd=class extends Ye{constructor(e,r,n){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=n}bilinearCubeUV(e,r,n,s){let o=new Fp(cd.Nodes.bilinearCubeUV,[r,n,s]);this.colorSpaceTL=this.colorSpaceTL??new ni(new Rt("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(o.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new ni(new Rt("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(o.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new ni(new Rt("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(o.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new ni(new Rt("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(o.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new Rt(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Rt(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Rt(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Rt(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Rt("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=o,l}generate(e,r){if(e.isShader("fragment")){let n=this.uv,s=this.bias||e.context.roughness,o=new Fp(cd.Nodes.roughnessToMip,[s]),a=new ot(o,cd.Nodes.m0,cd.Nodes.cubeUV_maxMipLevel,ot.CLAMP),l=new ot(a,ot.FLOOR),u=new ot(a,ot.FRACT),c=this.bilinearCubeUV(e,this.value,n,l),h=this.bilinearCubeUV(e,this.value,n,new Tn(l,new Ce(1).setReadonly(!0),Tn.ADD)),d=new ot(c,h,u,ot.MIX);return e.format(d.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},ud=cd;ud.Nodes=function(){let e=new ad(`struct TextureCubeUVData { + vec4 tl; + vec4 tr; + vec4 br; + vec4 bl; + vec2 f; + }`),r=new It("float cubeUV_maxMipLevel 8.0",!0),n=new It("float cubeUV_minMipLevel 4.0",!0),s=new It("float cubeUV_maxTileSize 256.0",!0),o=new It("float cubeUV_minTileSize 16.0",!0),a=new ge(`float getFace(vec3 direction) { + vec3 absDirection = abs(direction); + float face = -1.0; + if (absDirection.x > absDirection.z) { + if (absDirection.x > absDirection.y) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if (absDirection.z > absDirection.y) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + }`);a.useKeywords=!1;let l=new ge(`vec2 getUV(vec3 direction, float face) { + vec2 uv; + if (face == 0.0) { + uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x + } else if (face == 1.0) { + uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y + } else if (face == 2.0) { + uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z + } else if (face == 3.0) { + uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x + } else if (face == 4.0) { + uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y + } else { + uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z + } + return 0.5 * (uv + 1.0); + }`);l.useKeywords=!1;let u=new ge(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) { + float face = getFace(direction); + float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0); + mipInt = max(mipInt, cubeUV_minMipLevel); + float faceSize = exp2(mipInt); + float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); + vec2 uv = getUV(direction, face) * (faceSize - 1.0); + vec2 f = fract(uv); + uv += 0.5 - f; + if (face > 2.0) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + if(mipInt < cubeUV_maxMipLevel){ + uv.y += 2.0 * cubeUV_maxTileSize; + } + uv.y += filterInt * 2.0 * cubeUV_minTileSize; + uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); + uv *= texelSize; + vec4 tl = texture2D(envMap, uv); + uv.x += texelSize; + vec4 tr = texture2D(envMap, uv); + uv.y += texelSize; + vec4 br = texture2D(envMap, uv); + uv.x -= texelSize; + vec4 bl = texture2D(envMap, uv); + return TextureCubeUVData( tl, tr, br, bl, f ); + }`,[e,a,l,r,n,s,o]);u.useKeywords=!1;let c=new It("float r0 1.0",!0),h=new It("float v0 0.339",!0),d=new It("float m0 -2.0",!0),f=new It("float r1 0.8",!0),p=new It("float v1 0.276",!0),m=new It("float m1 -1.0",!0),g=new It("float r4 0.4",!0),y=new It("float v4 0.046",!0),v=new It("float m4 2.0",!0),x=new It("float r5 0.305",!0),w=new It("float v5 0.016",!0),S=new It("float m5 3.0",!0),A=new It("float r6 0.21",!0),E=new It("float v6 0.0038",!0),b=new It("float m6 4.0",!0),M=[c,h,d,f,p,m,g,y,v,x,w,S,A,E,b],T=new ge(`float roughnessToMip(float roughness) { + 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:u,roughnessToMip:T,m0:d,cubeUV_maxMipLevel:r}}();var xc=class extends Ye{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??xc.VIEW}getShared(){return this.scope===xc.WORLD}build(e,r,n,s){let o=e.context[this.scope+"Normal"];return o?o.build(e,r,n,s):super.build(e,r,n)}generate(e,r,n,s,o){let a;switch(this.scope){case xc.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case xc.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case xc.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}},Cn=xc;Cn.LOCAL="local",Cn.WORLD="world",Cn.VIEW="view",Cn.NORMAL="normal";cn.addKeyword("viewNormal",function(){return new Cn(Cn.VIEW)});cn.addKeyword("localNormal",function(){return new Cn(Cn.NORMAL)});cn.addKeyword("worldNormal",function(){return new Cn(Cn.WORLD)});var lo=class extends Ye{constructor(e){super("v3");this.nodeType="Position";this.scope=e??lo.LOCAL}getType(){switch(this.scope){case lo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case lo.LOCAL:case lo.WORLD:return!1}return!0}generate(e,r,n,s,o){let a;switch(this.scope){case lo.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case lo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case lo.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case lo.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}},xi=lo;xi.LOCAL="local",xi.WORLD="world",xi.VIEW="view",xi.PROJECTION="projection";cn.addKeyword("position",function(){return new xi});cn.addKeyword("worldPosition",function(){return new xi(xi.WORLD)});cn.addKeyword("viewPosition",function(){return new xi(xi.VIEW)});var Ms=class extends Ye{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??Ms.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case Ms.SPHERE:return"v2"}return this.type}generate(e,r){let n=this.getUnique(e);if(e.isShader("fragment")){let s;switch(this.scope){case Ms.VECTOR:{let o=new Cn(Cn.VIEW),a=e.context.roughness,l=o.build(e,"v3"),u=new xi(xi.VIEW).build(e,"v3"),c=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${u} ), ${l} )`;c&&(h=`normalize( mix( ${h}, ${l}, ${c} * ${c} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;n?(e.addNodeCode(`vec3 reflectVec = ${d};`),s="reflectVec"):s=d;break}case Ms.CUBE:{let o=new Ms(Ms.VECTOR).build(e,"v3"),a="vec3( -"+o+".x, "+o+".yz )";n?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),s="reflectCubeVec"):s=a;break}case Ms.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new Ms(Ms.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";n?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),s="reflectSphereVec"):s=a;break}}return e.format(s,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},co=Ms;co.CUBE="cube",co.SPHERE="sphere",co.VECTOR="vector";var kv=class extends Ye{constructor(e=new ii,r,n){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new ud(this.value,r??new co(co.VECTOR),n),this.irradianceNode=new ud(this.value,new Cn(Cn.WORLD),new Ce(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var Vv=class extends jt{constructor(e=new au,r,n){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new co,this.bias=n}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let n=this.getTexture(e,r),s=this.uv?.build(e,"v3"),o=this.bias?this.bias.build(e,"f"):void 0;o===void 0&&e.context.bias&&(o=e.context.bias.setTexture(this).build(e,"f"));let a;o?a="texCubeBias( "+n+", "+s+", "+o+" )":a="texCube( "+n+", "+s+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new ni(new Rt("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,u),e.removeContext(),e.format(a,u,r)}};var $D=` +uniform int frameIndex; +uniform vec2 resolution; +uniform mat4 previousModelViewMatrix; +uniform mat4 previousProjectionMatrix; + +varying vec4 vCurrentPosition; +varying vec4 vPreviousPosition; +`,eI=` +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))); +} + +`,tI=` +// 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; + +`,rI=` +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); +`;var nI=["x","y","z","w"],Cq=["float","vec2","vec3","vec4"],Pq={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},Dq={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},zv=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,n){let s=this.getIncludes(r,n);if(!s)return"";let o="";s=s.sort(t);for(let a=0;a","#include "].join(` +`),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(` +`),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) { + accumAlpha += (1.0 - accumAlpha) * alpha; + }`,""].join(` +`)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode($D),this.addFragmentParsCode(eI),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r0?r+1:"";this.addVaryCode("varying vec2 vUv"+n+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+n+";"),this.addVertexFinalCode("vUv"+n+" = uv"+n+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(tI),this.addFragmentFinalCode(rI)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+` +`}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+` +`}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+` +`}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+` +`}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,n="varying",s="V",o=""){let a=this.getVars(n),l=a[t];if(!l){let u=a.length;l={name:r||"node"+s+u+(o?"_"+o:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,n){return this.getVar(t,e,r,this.shader,"T",n)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(` +`)}getVarListCode(t,e){e=e??"";let r="";for(let n=0,s=t.length;n 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + }`);s=e.include(u);break;case 4:s=e.include(pd.Nodes.triplanar);break;default:s=e.include(pd.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let o=[];if(o.push("normal"),o.push(this.texture.generate(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.blending.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.projection.value===4){let a=`${n}_writeUvs`,l=a+"0",u=a+"1",c=a+"2",h=`${n}_triplanarWeights`;e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(h,"vec3"),o.push(l),o.push(u),o.push(c),o.push(h)}else{let a=`${n}_writeUvs`;e.addFragmentVariable(a,"vec2"),o.push(a)}return e.format(s+"("+o.join(",")+")",this.getType(e),r)}},fl=pd;fl.Nodes=function(){let e=new ge(` +vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { + vec3 posN = normalize(position); + float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); + float scaledHeight = position.y / (size.y * 0.5); + float v = (scaledHeight / 2.) + .5; + + vec2 calculatedUv = vec2(u,v); + vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; + writeUv = uvs; + + vec2 df = fwidth(uvs); + if(df.x > 0.5) df.x = 0.; + + #ifdef GL_EXT_shader_texture_lod + vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #else + vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); + #endif + + vec3 col = tmp.rgb; + float lalpha = alpha * tmp.a; + if ( crop > 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + } +`),r=new ge(` +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; + } +`),n=new ge(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) { + vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; + writeUv = uvs; + + vec4 tmp = texture2D( tex, uvs ); + + vec3 col = tmp.rgb; + + float lalpha = alpha * tmp.a; + if ( crop > 0.5 ) { + if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col; + }`),s=new ge(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) { + vec3 p = position; + vec2 uv0 = (1.0 + p.xy) / 2.0; + vec2 uv1 = (1.0 + p.zy) / 2.0; + vec2 uv2 = (1.0 + p.xz) / 2.0; + + uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy; + + // Range from 3 to 128 seems to be good + float exponent = (1.0 - blending) * 125.0 + 3.0; + + vec3 n = vObjectNormal; + vec3 weights = abs(normalize(n)); + weights = pow(weights, vec3(exponent)); + weights /= dot(weights, vec3(1.0)); + + // Write out all sets of UVs that we generated + writeUvs0 = uv0; + writeUvs1 = uv1; + writeUvs2 = uv2; + writeWeights = weights; + + // Derivatives for LOD + vec2 df0 = fwidth(uv0); + vec2 df1 = fwidth(uv1); + vec2 df2 = fwidth(uv2); + if (df0.x > 0.5) df0.x = 0.0; + if (df1.x > 0.5) df1.x = 0.0; + if (df2.x > 0.5) df2.x = 0.0; + + #ifdef GL_EXT_shader_texture_lod + vec4 tmp = + texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + + texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + + texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; + #else + vec4 tmp = + textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z + + textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x + + textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y; + #endif + + vec3 col = tmp.rgb; + float lalpha = alpha * tmp.a; + + // Apply cropping across all 3 planes + if ( crop > 0.5 ) { + if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) { + lalpha = 0.0; + } + if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) { + lalpha = 0.0; + } + if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) { + lalpha = 0.0; + } + } + + lalpha *= mask; + calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return col;//n * 0.5 + 0.5; + } + `);return{cylindrical:e,spherical:r,uv:n,triplanar:s}}();var md=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=r,this.near=n,this.far=s,this.isVector=o,this.isWorldSpace=a,this.origin=l,this.direction=u,this.colors=c,this.steps=h,this.isMask=f,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let n=`g${this.uuid.toString().replace(/-/g,"")}`,s=new ge(`vec3 ${n}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${n}_MAX_COLORS], float steps[${n}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) { + vec4 color = colors[0]; + #ifdef ${n}_IS_VECTOR + #ifdef ${n}_LINEAR + #ifdef ${n}_WORLDSPACE + float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far); + #else + float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far); + #endif + #else + #ifdef ${n}_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 ${n}_SMOOTH + for ( int i = 1; i < ${n}_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 < ${n}_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; + }`,[md.Nodes.vectorLinearWorldSpaceDepth,md.Nodes.vectorLinearObjectSpaceDepth,md.Nodes.vectorSphericalObjectSpaceDepth,md.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${n}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${n}_SMOOTH`),this.isVector.value>.5&&e.define(`${n}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${n}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${n}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let o=e.include(s),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(o+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},gd=md;gd.Nodes=function(){let e=new ge(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) { + vec3 n = normalize(direction); + float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z)); + return ( dist - near ) / ( far - near ); + }`),r=new ge(`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 ); + }`),n=new ge(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) { + float dist = length(vWPosition - origin); + return ( dist - near ) / ( far - near ); + }`),s=new ge(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) { + float dist = length(position - origin); + return ( dist - near ) / ( far - near ); + }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:r,vectorSphericalWorldSpaceDepth:n,vectorSphericalObjectSpaceDepth:s}}();var kp=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=r,this.scale=n,this.intensity=s,this.factor=o,this.isMask=u,this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=new ge(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) { + float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity ); + + float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return color; + }`),s=e.include(n),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.isMask.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(s+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var pA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=n,this.steps=s,this.offset=o,this.morph=a,this.angle=l,this.isMask=c,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(pA.Nodes.gradient),s=[];return s.push(this.gradientType.build(e,"i")),s.push(this.smooth.build(e,"b")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.offset.build(e,"v2")),s.push(this.morph.build(e,"v2")),s.push(this.angle.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},yd=pA;yd.Nodes=function(){return{gradient:new ge(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) { + 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 mA=class extends Ye{constructor(e,r,n,s){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=s,this.alpha=r,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let n=e.include(mA.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let s=[];return s.push(this.texture.generate(e,"t")),s.push("normal"),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},vd=mA;vd.Nodes=function(){return{matcap:new ge(`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 Vp=(o=>(o.SIMPLEX="simplex3d",o.SIMPLEX_FRACTAL="simplex3dFractal",o.ASHIMA="simplexAshima",o.FBM="fbm",o.PERLIN="perlin",o.VORONOI="voronoi",o))(Vp||{}),Pn=function(){let t=new ge(`vec3 random3(vec3 c) { + float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); + vec3 r; + r.z = fract(512.0*j); + j *= .125; + r.x = fract(512.0*j); + j *= .125; + r.y = fract(512.0*j); + return r-0.5; + }`),e=new ge(`float simplex3d(vec3 p) { + vec3 s = floor(p + dot(p, vec3(F3))); + vec3 x = p - s + dot(s, vec3(G3)); + + vec3 e = step(vec3(0.0), x - x.yzx); + vec3 i1 = e*(1.0 - e.zxy); + vec3 i2 = 1.0 - e.zxy*(1.0 - e); + + vec3 x1 = x - i1 + G3; + vec3 x2 = x - i2 + 2.0*G3; + vec3 x3 = x - 1.0 + 3.0*G3; + + vec4 w, d; + + w.x = dot(x, x); + w.y = dot(x1, x1); + w.z = dot(x2, x2); + w.w = dot(x3, x3); + + w = max(0.6 - w, 0.0); + + d.x = dot(random3(s), x); + d.y = dot(random3(s + i1), x1); + d.z = dot(random3(s + i2), x2); + d.w = dot(random3(s + 1.0), x3); + + w *= w; + w *= w; + d *= w; + + return dot(d, vec4(52.0)); + }`,[t]);e.keywords.F3=new It("float F3 0.3333333"),e.keywords.G3=new It("float G3 0.1666667");let r=new ge(`float simplex3dFractal(vec3 m) { + mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4); + mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63); + mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56); + return 0.5333333 * simplex3d(m * rot1) + + 0.2666667 * simplex3d(2.0 * m * rot2) + + 0.1333333 * simplex3d(4.0 * m * rot3) + + 0.0666667 * simplex3d(8.0 * m); + }`,[e]),n=new ge("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new ge("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),o=new ge(`float simplexAshima(vec3 v) { + 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) ) ); + }`,[n,s]),a=new ge("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new ge("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),u=new ge(`float noise(vec3 p){ + vec3 a = floor(p); + vec3 d = p - a; + d = d * d * (3.0 - 2.0 * d); + vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); + vec4 k1 = perm(b.xyxy); + vec4 k2 = perm(k1.xyxy + b.zzww); + vec4 c = k2 + a.zzzz; + vec4 k3 = perm(c); + vec4 k4 = perm(c + 1.0); + vec4 o1 = fract(k3 * (1.0 / 41.0)); + vec4 o2 = fract(k4 * (1.0 / 41.0)); + vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); + vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); + return o4.y * d.y + o4.x * (1.0 - d.y); + }`,[l]),c=new ge(`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; + }`,[u]);c.keywords.NUM_OCTAVES=new It(`int NUM_OCTAVES ${5}`);let h=new ge("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),d=new ge(`float perlin(vec3 P){ + 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; + }`,[n,s,h]),f=new ge(`float hashwithoutsine13(vec3 p3) + { + p3 = fract(p3 * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),p=new ge(`vec3 hashwithoutsine33(vec3 p3) + { + p3 = fract(p3 * vec3(.1031, .1030, .0973)); + p3 += dot(p3, p3.yxz+33.33); + return fract((p3.xxy + p3.yxx)*p3.zyx); + }`),m=new ge(`float metric(in vec3 p) + { + // L2 + return length(p); + + // Chebyshev + // vec3 a = abs(p); + // return max(a.x, max(a.y, a.z)); + }`),g=new ge(`float smin( float a, float b, float k ) + { + float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k); + float correction = k * h * (1.0 - h); + return mix(b, a, h) - correction; + }`),y=new ge(`float smax( float a, float b, float k ) + { + float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k); + float correction = k * h * (1.0 - h); + return mix(a, b, h) + correction; + }`),v=new ge(`float remap(float value, float input_min, float input_max, float output_min, float output_max) { + // Compute width of each interval + float input_width = input_max - input_min; + float output_width = output_max - output_min; + + // Convert input range into a 0-1 range + float scaled = (value - input_min) / input_width; + + // Convert the 0-1 range into a value in output range + return output_min + (scaled * output_width); + }`),x=new ge(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality) + { + // Integer and fractional parts of this point's coordinates + ivec3 p = ivec3(floor(x)); + vec3 f = fract(x); + + // Different variables that we will use to construct noise: + // + // f1: distance to the closest feature point + // f2: distance to the second closest feature point + // e: distance to the closest edge (cell boundary) + // + // We also compute "smooth" versions of all of the above quantites, essentially + // replacing "hard" minimums with "smooth" minimums (described by IQ) + float f1_smooth = 8.0; + float f1 = 8.0; + float f2_smooth = 8.0; + float f2 = 8.0; + float e_smooth = 8.0; + float e = 8.0; + + // Variables stored from closest cell + ivec3 mb; + vec3 mr; + + int steps = quality; + + for (int x = -steps; x <= steps; x++) + for (int y = -steps; y <= steps; y++) + for (int z = -steps; z <= steps; z++) + { + ivec3 b = ivec3(x, y, z); + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d = length(r); + + f1_smooth = smin(d, f1_smooth, smoothness); + + // Store un-smoothed distances too + if (d < f1) + { + f2 = f1; + f1 = d; + + mb = ivec3(x, y, z); + mr = r; + } + else if (d < f2) + { + f2 = d; + } + } + + float id = hashwithoutsine13(vec3(p + mb) + seed); + + // Second pass for edge distance + for (int x = -steps; x <= steps; x++) + for (int y = -steps; y <= steps; y++) + for (int z = -steps; z <= steps; z++) + { + // Start search at the cell that contains the closest point to "x" (found in 1st pass) + ivec3 b = mb + ivec3(x, y, z); + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version? + float d2 = dot(0.5 * (mr + r), normalize(r - mr)); + + e_smooth = smin(d1, e_smooth, smoothness); + + e = min(e, d2); + + // Also compute a smooth version of F2 in this pass + { + ivec3 b = ivec3(x, y, z); + if (b != mb) + { + vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f; + float d = length(r); + + f2_smooth = smin(d, f2_smooth, smoothness); + } + } + } + + // Different visualization modes + if (style == 0) + { + return f1_smooth; + } + if (style == 1) + { + return f2_smooth; + } + if (style == 2) + { + return f2_smooth - f1_smooth; + + // "Pebbles" also cool + //return step(0.2, f2_smooth - f1_smooth); + } + if (style == 3) + { + // This one is really good for rock / stone effects + float a = f1; + float b = f2; + float k = 3.0; + float h = max(k - abs(a - b), 0.0) / k; + float final = min(a, b) - h * h * k * (1.0 / 4.0); + return final; + } + if (style == 4) + { + // Some random adjustments to make this style stand out more + return exp(5.0 * e_smooth); + } + if (style == 5) + { + return pow(f1_smooth, 3.0); + } + if (style == 6) + { + const float eps = 0.0125; + + // Thicker lines as the user increases the smoothness slider + float thickness = smoothness * 0.25 + eps; + + // Blurrier lines as the user increases the smoothness slider + float blur = pow(smoothness, 3.0) * 0.25 + eps; + + return smoothstep( + thickness - thickness * blur, + thickness + thickness * blur, + e + ); + } + if (style == 7) + { + return hashwithoutsine13(vec3(p + mb) + seed); + } + } + `,[f,p,m,g,y,v]);return{simplex:e,simplexFractal:r,simplexAshima:o,fbm:c,perlin:d,voronoi:x}}();var xd=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=r,this.move=n,this.fA=s,this.fB=o,this.distortion=a,this.colorA=l,this.colorB=u,this.colorC=c,this.colorD=h,this.noiseType=f,this.voronoiStyle=m,this.highCut=g,this.lowCut=y,this.smoothness=v,this.seed=x,this.quality=w,this.isMask=p,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r,n,s,o){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(Vp)[this.noiseType.value],l=a=="voronoi"?` + float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality); + + // Apply clipping to colors + v = remap(v, lowCut, highCut, 0.0, 1.0); + v = smax(v, 0.0, smoothness * 0.25); + v = smin(v, 1.0, smoothness * 0.25); + + // Note that the voronoi mode only uses colors "A" and "C" from the UI + vec4 color = mix(colorA, colorC, v); + `:` + vec3 q = vec3(${a}(st), + ${a}(st + vec3(1.0)), + ${a}(st + vec3(1.0))); + vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move), + ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), + ${a}(st * q)); + float f = ${a}(st + r); + vec4 color; + color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0)); + color = mix(color, colorC, clamp(length(q), 0.0, 1.0)); + color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0)); + `,u=new ge(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha) + { + // Prevent scale of zero + scale = max(abs(scale), 0.001); + + vec3 st = position / size; + st /= scale; + + ${l} + + float lalpha = alpha * color.a * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return clamp(color, 0.0, 1.0).rgb; + }`,[Pn.simplex,Pn.simplexFractal,Pn.simplexAshima,Pn.fbm,Pn.perlin,Pn.voronoi]),c=e.include(u),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.voronoiStyle.build(e,"i")),h.push(this.highCut.build(e,"f")),h.push(this.lowCut.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.seed.build(e,"f")),h.push(this.quality.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(c+"("+h.join(",")+")",this.getType(e),r)}};xd.numOctaves=5;var gA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=n,this.contourWidth=s,this.contourThreshold=o,this.outlineThreshold=a,this.contourFrequency=l,this.outlineSmoothing=u,this.contourDirection=c,this.positionalLines=h,this.compensation=d,this.resolution=f,this.normalMap=p,this.depthMap=m,this.pixelRatio=g,this.alpha=y,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let n=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${n}_offset`),this.firstTime){let s=this.outlineWidth.build(e,"f"),o=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(s,"uniform float"),e.addVertexParsVariable(o,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(` + vID = randomColor.r; + vec2 ${n}_offset = vec2(0.0); + if (${a}) { + vec4 ${n}_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 ${n}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001; + ${n}_offset = normalize(${n}_clipNormal.xy) / ${o} * (${s} / 2.0) * ${n}_clipPosition.w * 2.0 * ${l}; + ${n}_clipPosition.xy += ${n}_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 = ${n}_clipPosition; + } + `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=e.include(gA.Nodes.outline),o=[];return o.push(this.outlineColor.build(e,"c")),o.push(this.contourColor.build(e,"c")),o.push(this.outlineWidth.build(e,"f")),o.push(this.contourWidth.build(e,"f")),o.push(this.contourThreshold.build(e,"f")),o.push(this.outlineThreshold.build(e,"f")),o.push(this.contourFrequency.build(e,"f")),o.push(this.outlineSmoothing.build(e,"f")),o.push(this.contourDirection.build(e,"v3")),o.push(this.positionalLines.build(e,"b")),o.push(this.resolution.build(e,"v2")),o.push(this.normalMap.getTexture(e,"t")),o.push(this.depthMap.getTexture(e,"t")),o.push(this.pixelRatio.build(e,"f")),o.push(this.compensation.build(e,"b")),o.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(s+"("+o.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},bd=gA;bd.Nodes=function(){let e=new ge(` +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 ge(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) { + vec3 result = outlineColor; + float resultAlpha = 0.0; + + vec3 N = normalize(vWNormal); + vec2 nuv = (gl_FragCoord.xy / resolution); + float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio); + resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample); + + //resultAlpha = 1.0; + //result = vec3(sobelSample); + + float t = 1.0 - contourThreshold; + if(positionalLines) { + vec3 NDir = position * contourDirection; + float NT = NDir.x + NDir.y + NDir.z; + float f = fract(NT * contourFrequency * 0.01); + float df = fwidth(NT * contourFrequency); + + float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f); + if (g < 1.0 && resultAlpha == 0.0) { + result = contourColor; + resultAlpha = 1.0; + } + } + else { + vec3 NDir = N * contourDirection; + float NT = NDir.x + NDir.y + NDir.z; + float df = fwidth(NT * contourThreshold); + float f = sin(NT * 1.0 * contourFrequency); + float g = smoothstep(0.0, df * contourWidth, 1.0 - f); + + if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) { + result = contourColor; + resultAlpha = 1.0 - g; + } + } + + float lalpha = alpha * resultAlpha * mask; + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * lalpha; + + return result; + }`,[e])}}();var uo=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d,f,p,m,g,y,v,x){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=n,this.blending=s,this.offset=o,this.colorA=a,this.colorB=l,this.frequency=u,this.size=c,this.variation=h,this.smoothness=d,this.zigzag=f,this.rotation=p,this.vertical=m,this.horizontal=g,this.sides=y,this.isMask=x,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let n;switch(this.style.value){case 0:n="circle";break;case 1:n="ring";break;case 2:n="polygon";break;case 3:n="xcross";break;case 4:n="diamond";break;case 5:n="checkerboard";break;case 6:n="line";break;case 7:n="wave";break;default:n="circle";break}let s=`g${this.uuid.toString().replace(/-/g,"")}`,o=new ge(`float hashwithoutsine12(vec2 p) + { + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),a=new ge(`vec2 rotate_uv(in vec2 uv, float a, bool repeat) + { + const float mid = 0.5; + float radians = a * (PI / 180.0); + vec2 rotated = vec2( + cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid, + cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid + ); + return repeat ? fract(rotated): rotated; + }`),l="";if(this.projection.value===4){let d=this.style.value===2?`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f=this.style.value===2?`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,p=this.style.value===2?`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;l=` + vec3 p = position; + float factor = 0.0125; + vec2 uv0 = fract(p.xy * factor); + vec2 uv1 = fract(p.zy * factor); + vec2 uv2 = fract(p.xz * factor); + + uv0 = rotate_uv(uv0 + offset, rotation, true); + uv1 = rotate_uv(uv1 + offset, rotation, true); + uv2 = rotate_uv(uv2 + offset, rotation, true); + + float d0 = ${d}; + float d1 = ${f}; + float d2 = ${p}; + + // Range from 3 to 128 seems to be good + float exponent = (1.0 - blending) * 125.0 + 3.0; + + vec3 n = vObjectNormal; + vec3 weights = abs(normalize(n)); + weights = pow(weights, vec3(exponent)); + weights /= dot(weights, vec3(1.0)); + d0 *= weights.z; + d1 *= weights.x; + d2 *= weights.y; + float draw = d0 + d1 + d2; + + vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y; + `}else{let d=this.style.value===2?`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${n}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,f="";this.axis.value===0?f=`float radius = length(p); + float theta = atan(p.y, p.z); + float phi = acos(p.x / radius);`:this.axis.value===1?f=`float radius = length(p); + float theta = atan(p.x, p.z); + float phi = acos(p.y / radius);`:(this.axis.value,f=`float radius = length(p); + float theta = atan(p.y, p.x); + float phi = acos(p.z / radius);`);let p="";switch(this.projection.value){case 0:p="custom_uv = vUv.st;";break;case 1:break;case 2:p=` + vec3 p = position; + ${f} + custom_uv = vec2(theta, phi); + custom_uv /= PI; + `;break;case 3:break;default:break}l=` + vec2 custom_uv; + ${p} + + custom_uv += offset; + custom_uv = fract(custom_uv); + custom_uv = rotate_uv(custom_uv, rotation, true); + + float draw = ${d}; + `}let u=new ge(`vec3 ${s}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) { + const float TWO_PI = PI * 2.0; + float smoothness_remapped = pow(smoothness, 5.0); + + ${l} + + // Construct final output color + vec4 color = mix(colorA, colorB, draw); + color.a = clamp(color.a, 0.0, 1.0); + + // Apply cuts + color.a *= + step(vertical.x, custom_uv.y) * + step(custom_uv.y, vertical.y); + color.a *= + step(horizontal.x, abs(custom_uv.x)) * + step(abs(custom_uv.x), horizontal.y); + + // Accumulate alpha + float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return clamp(color, 0.0, 1.0).rgb; + }`,[a,o,uo.DrawFunctions.circle,uo.DrawFunctions.ring,uo.DrawFunctions.polygon,uo.DrawFunctions.cross,uo.DrawFunctions.diamond,uo.DrawFunctions.checkerboard,uo.DrawFunctions.line,uo.DrawFunctions.wave]),c=e.include(u),h=[];return h.push("normal"),h.push(this.blending.build(e,"f")),h.push(this.style.build(e,"i")),h.push(this.offset.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.frequency.build(e,"v2")),h.push(this.size.build(e,"f")),h.push(this.variation.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.zigzag.build(e,"f")),h.push(this.rotation.build(e,"f")),h.push(this.vertical.build(e,"v2")),h.push(this.horizontal.build(e,"v2")),h.push(this.sides.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(c+"("+h.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},wd=uo;wd.DrawFunctions=function(){let e=new ge(`float hashwithoutsine12(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * 0.1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); + }`),r=new ge(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) { + // Create tiles in UV-space + uv *= frequency; + + // Integer coords + vec2 i = floor(uv); + + // Offset every other row based on zigzag param, then compute fractional coords + float row_offset = mod(i.y, 2.0); + uv.x += row_offset * zigzag; + vec2 f = fract(uv); + + // Rotate the tile itself: + // const float mid = 0.5; + // f = vec2( + // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid, + // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid + // ); + // f = fract(f); + + f = f * 2.0 - 1.0; + + // Recompute integer coords after shifting - then, random value per tile + i = floor(uv); + float rand = (hashwithoutsine12(i) * 5.0 + 1.0); + float jitter = mix(1.0, rand, variation); + f *= jitter; + + return f; + }`,[e]),n=new ge(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep( + -smoothness, + smoothness, + length(f) - size + ); + }`,[r]),s=new ge(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + + float d = length(f); + const float inner_width = 0.5; + + float outer = smoothstep(-smoothness, smoothness, d - size); + float inner = smoothstep(-smoothness, smoothness, d - size * inner_width); + return outer + (1.0 - inner); + }`,[r]),o=new ge(`float sdf_ngon(in vec2 p, in float r, in int n) { + float an = (PI * 2.0) / float(n); + float he = r * tan(0.5 * an); + + // Rotate to first sector + p = -p.yx; + float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an); + vec2 cs = vec2(cos(bn), sin(bn)); + p = mat2(cs.x, -cs.y, cs.y, cs.x)*p; + + // Side of polygon + return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r); + } + + float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides)); + }`,[r]),a=new ge(`float sdf_cross(in vec2 p, in vec2 b, float r ) { + p = abs(p); + p = (p.y > p.x) ? p.yx : p.xy; + vec2 q = p - b; + float k = max(q.y, q.x); + vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k); + return sign(k) * length(max(w, 0.0)) + r; + } + + // Avoid namespace conflicts + float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness)); + }`,[r]),l=new ge(`float ndot(vec2 a, vec2 b) { + return a.x*b.x - a.y*b.y; + } + + float sdf_diamond(in vec2 p, in vec2 b) { + p = abs(p); + float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0); + float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h)); + return d * sign(p.x * b.y + p.y * b.x - b.x * b.y); + } + + float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation); + return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size))); + }`,[r]),u=new ge(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + 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); + }`),c=new ge(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation); + + // Different approach for variation param here + float row = floor(uv * frequency).y; + float rand = hashwithoutsine12(vec2(row)); + float s = mix(size, size * rand, variation); + + return smoothstep( + s - smoothness, + s + smoothness, + abs(f.y) + ); + }`,[r]),h=new ge(`// Uses bisection + float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) { + // Convert all data to a primitive cosine wave + p = c * (p - vec2(d, a)); + + const float TWO_PI = PI * 2.0; + + // Reduce to principal half cycle + p.x = mod(p.x, TWO_PI); + if (p.x > PI) { + p.x = TWO_PI - p.x; + } + + // Find zero of derivative (minimize distance) + float xa = 0.0; + float xb = TWO_PI; + + // 24 bit precision + for (int i = 0; i < 24; i++) { + float x = 0.5 * (xa + xb); + float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x)); + if (y < 0.0) xa = x; + else xb = x; + } + float x = 0.5 * (xa + xb); + + // Compute distance + vec2 q = vec2(x, b * c * cos(x)); + return length(p - q) / c; + } + + float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) { + float repeat = frequency.x; + uv *= repeat; + vec2 i = floor(uv); + float row_offset = mod(i.y, 2.0); + uv.x += row_offset * zigzag; + vec2 f = vec2(uv.x, fract(uv.y)); + + // Generalized cosine: y(x) = a + b * cos(cx + d) + const float amplitude = 0.125; + float wave_frequency = frequency.y * 0.1; + float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0); + + // Different approach for variation param here + float rand = hashwithoutsine12(vec2(i.y)); + float s = mix(size, size * rand, variation); + + return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5); + }`);return{tileAndCenter:r,circle:n,ring:s,polygon:o,cross:a,diamond:l,checkerboard:u,line:c,wave:h}}();var yA=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=n,this.noiseStrength=s,this.noiseScale=o,this.offset=a,this.isMask=u,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(yA.Nodes.rainbow),s=[];return s.push(this.filmThickness.build(e,"f")),s.push(this.movement.build(e,"f")),s.push(this.wavelengths.build(e,"v3")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.offset.build(e,"v3")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Sd=yA;Sd.Nodes=function(){let e=new ge(`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); + }`,[Pn.simplex]);return{rainbow:new ge(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) { + vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0); + + float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0); + + float lalpha = alpha * rainbowContribution * mask; + calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask)); + accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask)); + + return res; + }`,[e])}}();var vA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=n,this.source=s,this.isWorldSpace=o,this.noiseStrength=a,this.noiseScale=l,this.shadowColor=u,this.offset=c,this.alpha=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let n=e.include(vA.Nodes.toon),s=[];return s.push(this.positioning.build(e,"i")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.source.build(e,"v3")),s.push(this.isWorldSpace.build(e,"b")),s.push(this.noiseStrength.build(e,"f")),s.push(this.noiseScale.build(e,"f")),s.push(this.shadowColor.build(e,"v4")),s.push(this.offset.build(e,"v3")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ad=vA;Ad.Nodes=function(){let e=new ge(`float rand(float n) { + return fract(sin(n) * 43758.5453123); + }`),r=new ge(`float hash1(float p) { + p = fract(p * 0.011); + p *= p + 7.5; + p *= p + p; + return fract(p); + }`),n=new ge(`float valueNoise(vec3 x) { + const vec3 step = vec3(110, 241, 171); + + vec3 i = floor(x); + vec3 f = fract(x); + + // For performance, compute the base input to a 1D hash from the integer part of the argument and the + // incremental change to the 1D based on the 3D -> 1D wrapping + float n = dot(i, step); + + vec3 u = f * f * (3.0 - 2.0 * f); + return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x), + mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y), + mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x), + mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z); + }`,[r]),s=new ge(`vec3 hash3(vec3 x) { + x = vec3(dot(x,vec3(127.1, 311.7, 74.7)), + dot(x,vec3(269.5, 183.3, 246.1)), + dot(x,vec3(113.5, 271.9, 124.6))); + + return fract(sin(x)*43758.5453123); + }`),o=new ge(`vec3 voronoiNoise(in vec3 x) + { + vec3 p = floor(x); + vec3 f = fract(x); + + float id = 0.0; + vec2 res = vec2(100.0); + + for(int k=-1; k<=1; k++) + for(int j=-1; j<=1; j++) + for(int i=-1; i<=1; i++) + { + vec3 b = vec3(float(i), float(j), float(k)); + + // Comment out the "+ hash(p + b);" part below to get "square" cells + vec3 r = vec3(b) - f + hash3(p + b); + float d = dot(r, r); + + if (d < res.x) + { + id = dot(p + b, vec3(1.0, 57.0, 113.0)); + res = vec2(d, res.x); + } + else if (d < res.y) + { + res.y = d; + } + } + + return vec3(sqrt(res), abs(id)); + } + `,[s]);return{toon:new ge(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) { + 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; + + }`,[Pn.simplex,e,n,o])}}();var sI=function(){return{textureBicubic:new ge(`float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + + // g0 and g1 are the two amplitude functions + float g0( float a ) { + return w0( a ) + w1( a ); + } + + float g1( float a ) { + return w2( a ) + w3( a ); + } + + // h0 and h1 are the two offset functions + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + }`)}}();function oI(i,t){return i>=t?new N(t/i,1):new N(1,i/t)}var xA=class extends Ye{constructor(e,r,n,s,o,a,l,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=n,this.transmissionSamplerSize=s,this.transmissionSamplerMap=o,this.transmissionDepthMap=a,this.aspectRatio=l,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,je.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let n=e.include(xA.Nodes.transmission),s=[];return s.push(this.thickness.build(e,"f")),s.push(this.ior.build(e,"f")),s.push(this.roughness.build(e,"f")),s.push(this.transmissionSamplerSize.build(e,"v2")),s.push(this.transmissionSamplerMap.getTexture(e,"t")),s.push(this.transmissionDepthMap.getTexture(e,"t")),s.push(this.aspectRatio.build(e,"v2")),s.push("normal"),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},_d=xA;_d.Nodes=function(){let e=new ge(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) { + // Slightly modified version of this: + // https://www.shadertoy.com/view/ltScRG + + // Special case for blur == 0.0 + if (lod == 0.0) { + #ifdef TEXTURE_LOD_EXT + return texture2DLodEXT( sp, U, 0.0).rgb; + #else + return textureLod( sp, U, 0.0).rgb; + #endif + } + + vec2 texelSize = vec2(1.0) / resolution; + vec2 halton = haltonSequence[frameIndex]; + float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton); + float temporalAngle = temporalOffset * PI2; + vec3 res = vec3(0.0); + vec2 uv = vec2(0.0); + vec2 offset = vec2(0.0); + vec2 vogelSample = vec2(0.0); + for (int i = 0; i < NUM_SAMPLES; i++) { + vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize; + offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20 + uv = U + offset; + float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod)); + if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) { + uv = unrefractedU; + lod = lod > 4.0 ? lod : lod / 2.0; + } + res += textureLod(sp, uv, lod).rgb; + } + return res / float(NUM_SAMPLES); + }`),r=new ge(`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; + }`),n=new ge(`float applyIorToRoughness( float roughness, float ior ) { + // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and + // an IOR of 1.5 results in the default amount of microfacet refraction. + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + }`),s=new ge(`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 + }`,[sI.textureBicubic,n,e]),o=new ge(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 ); + vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w; + unrefractedCoords += 1.0; + unrefractedCoords /= 2.0; + + // Sample framebuffer to get pixel the refracted ray hits. + return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio ); + }`,[s,r]);return{transmission:new ge(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) { + vec3 v = vec3(0.); + if (isOrthographic) { + v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + v = normalize(vWPosition - cameraPosition); + } + vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio ); + + float lalpha = alpha * mask; + calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * alpha; + + return transmission; + }`,[o])}}();var bA=(e=>(e.NOISE="noise",e.MAP="map",e))(bA||{}),wA=class extends Ye{constructor(e,r,n,s,o,a,l,u,c,h,d){super("v3");this.displacementTypeIndex=new yt(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(bA)[this.displacementTypeIndex.value]==="map"&&(this.mat=new hd(this.movementOrTexture.value.matrix)),this.cropOrOffset=n,this.scale=h,this.noiseFunctionIndex=d,this.voronoiStyle=s,this.smoothness=o,this.seed=a,this.highCut=l,this.lowCut=u,this.quality=c}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let n,s=[];switch(s.push("displaced_position"),s.push("displaced_normal"),Object.values(bA)[this.displacementTypeIndex.value]){case"map":{n=e.include(wA.Nodes.map),s.push(this.movementOrTexture.getTexture(e,"t")),s.push("uv"),s.push(this.cropOrOffset.build(e,"f")),this.mat&&s.push(this.mat.build(e,"mat3"));break}case"noise":{let a=Object.values(Vp)[this.noiseFunctionIndex.value],l=new ge(`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)); + }`),u=a=="voronoi"?` + float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality); + v = remap(v, lowCut, highCut, 0.0, 1.0); + v = smax(v, 0.0, smoothness * 0.25); + v = smin(v, 1.0, smoothness * 0.25); + + return p + n * v * intensity; + `:` + return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity; + `,c=new ge(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) { + ${u} + }`,[Pn.simplex,Pn.simplexFractal,Pn.simplexAshima,Pn.fbm,Pn.perlin,Pn.voronoi]),h=new ge(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) { + 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; + }`,[c,l]);n=e.include(h),s.push(this.scale.build(e,"f")),s.push(this.cropOrOffset.build(e,"v3")),s.push(this.movementOrTexture.build(e,"f")),s.push(this.voronoiStyle.build(e,"i")),s.push(this.smoothness.build(e,"f")),s.push(this.seed.build(e,"f")),s.push(this.highCut.build(e,"f")),s.push(this.lowCut.build(e,"f")),s.push(this.quality.build(e,"i"));break}}return s.push(this.intensity.build(e,"f")),s.push("displaced_normal"),e.format(n+"("+s.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ed=wA;Ed.Nodes=function(){let e=new ge(`vec3 orthogonal(vec3 v) { + return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); + }`),r=new ge(`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 ge(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) { + vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity; + vec3 tangent1 = normalize(orthogonal(normal)); + vec3 tangent2 = normalize(cross(normal, tangent1)); + vec3 nearby1 = position + tangent1 * 0.1; + vec3 nearby2 = position + tangent2 * 0.1; + vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; + vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; + displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); + return displaced_position; + }`,[e,r])}}();var je={normalRenderTarget:new ii,normalRenderTargetDepth:new ii,transmissionRenderTarget:new ii,aspectRatio:new wr,transmissionSize:new wr(2048,2048),transmissionRenderTargetDepth:new ii,aoRenderTarget:new ii,aoEnabled:new Tr,pixelRatioNode:new Ce(1),resolution:new wr,penumbraSize:new Ts(5,.5),frameIndex:new yt(0),transmissionLod:new yt(2)};for(let i of Object.values(je))i.isRenderGlobal=!0;var Ac=class extends Mn{constructor(){super("basic");this.nodeType="Basic";this.color=new zt(an),this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(vs.merge([we.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include "].join(` +`));let s=["#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #if defined( USE_LAYER_DISPLACE ) + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif /* !USE_LAYER_DISPLACE */ + `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` +`)}else{this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let n=this.color.flow(e,"c",{slot:"color"}),s=this.alpha?this.alpha.flow(e,"f"):void 0,o=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=s!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include ","#include ","varying vec3 vViewPosition;","#include "].join(` +`));let l=["#include ",n.code];s&&l.push(s.code,"#ifdef ALPHATEST"," if ( "+s.result+" <= ALPHATEST ) discard;","#endif"),a?l.push(a.code,`vec3 outgoingLight = ${n.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${n.result};`);let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),s?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${s.result} * ${u} );`):l.push("gl_FragColor = vec4("+n.result+", 1.0 );"),o&&l.push(`gl_FragColor.a *= ${o.result};`),l.push("#include ","#include "),r=l.join(` +`)}return r}};var zp=class extends Mn{constructor(){super("lambert");this.nodeType="Lambert";this.color=new zt(an),this.emissive=new zt(0),this.emissiveIntensity=new Ce(1),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(vs.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let s=["#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 + `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include ",` + vec3 diffuse = vec3( 1.0 ); + GeometricContext geometry; + geometry.position = mvPosition.xyz; + geometry.normal = normalize( transformedNormal ); + geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); + `),s.push(` + GeometricContext backGeometry; + backGeometry.position = geometry.position; + backGeometry.normal = -geometry.normal; + backGeometry.viewDir = geometry.viewDir; + vLightFront = vec3( 0.0 ); + vIndirectFront = vec3( 0.0 ); + #ifdef DOUBLE_SIDED + vLightBack = vec3( 0.0 ); + vIndirectBack = vec3( 0.0 ); + #endif + IncidentLight directLight; + float dotNL; + vec3 directLightColor_Diffuse; + vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); + vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); + #ifdef DOUBLE_SIDED + vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); + vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); + #endif + #if NUM_POINT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + getPointLightInfo( pointLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + getSpotLightInfo( spotLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_DIR_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + #ifdef DOUBLE_SIDED + vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; + #endif + } + #pragma unroll_loop_end + #endif + #if NUM_HEMI_LIGHTS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + #ifdef DOUBLE_SIDED + vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); + #endif + } + #pragma unroll_loop_end + #endif + `," #include "," #include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` +`)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),s=this.emissive.flow(e,"c",{slot:"emissive"}),o=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include ","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let f=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx, viewdy)); + bool isFrontFacing = (dot(normal, faceNormal) >= 0.0); + `,"#include "];f.push(n.code,"vec3 diffuseColor = "+n.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include ","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),s&&f.push(s.code,"reflectedLight.directDiffuse += "+s.result+" * "+o.result+";"),f.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),f.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${u.result} ); + + outgoingLight *= ao; + } + `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include ","#include ","#include "),r=f.join(` +`)}return r}};var aa=function(){let i=new ge(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) { + + // Gradient of UVs w.r.t. X coordinate (in screen-space) + vec2 dSTdx = dFdx(bumpMapUv); + + // Gradient of UVs w.r.t. Y coordinate (in screen-space) + vec2 dSTdy = dFdy(bumpMapUv); + + // Forward differencing + float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb); + float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll; + float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll; + + return vec2( dBx, dBy ); + }`),t=new ge(`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:i,perturbNormalArb:t}}();var Up=class extends Mn{constructor(){super("phong");this.nodeType="Phong";this.color=new zt(an),this.specular=new zt(1118481),this.shininess=new Ce(30),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(vs.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include "].join(` +`));let s=["#include ",` + #include + #include + #ifndef USE_LAYER_DISPLACE + #include + #endif + + + vec3 displaced_position = position; + vec3 displaced_normal = objectNormal; + + #ifdef USE_LAYER_DISPLACE + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #ifndef USE_LAYER_DISPLACE + #include + #endif + `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","#include ","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` +`)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let n=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let s=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),l=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let f=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(aa.dHdxy),e.include(aa.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),g=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",v="";this.bumpMap.projection.value===4?v=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${m.result}, uv0, ${y}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${m.result}, uv1, ${y}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${m.result}, uv2, ${y}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:v=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${m.result}, bumpMapCachedUv, ${y}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,f.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${g.result}; + ${v} + `)}f.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),h&&f.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),f.push("material.diffuseColor = diffuseColor;"),f.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),f.push("vec3 ao = aoEnabled && "+n.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),f.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${u.result} ); + + outgoingLight *= ao; + } + `),c&&f.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),h?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include ","#include ","#include "),r=f.join(` +`)}return r}};var Gp=class extends Mn{constructor(){super("standard");this.nodeType="Standard";this.color=new zt(an),this.roughness=new Ce(.3),this.metalness=new Ce(0),this.reflectivity=new Ce(.5),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0),this.occlusion=new Tr(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(vs.merge([we.fog,we.lights])),we.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include "].join(` +`));let s=["#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif + + vec3 displaced_position = position; + vec3 displaced_normal = normal; + + #if defined( USE_LAYER_DISPLACE ) + vec3 transformed; + vec3 transformedNormal; + #endif + `,"#include ",` + #if !defined( USE_LAYER_DISPLACE ) + #include + #endif /* !USE_LAYER_DISPLACE */ + `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push("#include ","#include ","#include "," vViewPosition = - mvPosition.xyz;","#include ","#include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` +`)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled});let n={gamma:!0};this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color",context:n}),this.roughness.analyze(e),this.metalness.analyze(e);let s=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:n}),a=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include ","#include ","#include ","#include ","#include ","#include ","#include "].join(` +`));let m=["#include "," #include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(aa.dHdxy),e.include(aa.perturbNormalArb);let y=this.bumpMap.texture.flow(e,"t"),v=this.bumpMap.flow(e,"v3"),x=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",w="";this.bumpMap.projection.value===4?w=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${y.result}, uv0, ${x}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${y.result}, uv1, ${x}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${y.result}, uv2, ${x}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:w=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${y.result}, bumpMapCachedUv, ${x}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${v.result}; + ${w} + `)}if(m.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float metalnessFactor = "+l.result+";"),this.roughnessMap){let y=this.roughnessMap.texture.flow(e,"t"),v=this.roughnessMap.flow(e,"v3"),x="";this.roughnessMap.projection.value===4?x=` + float roughnessChange = 1.0; + { + vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + float r0 = luminance(texture(${y.result}, uv0).rgb) * roughnessScale; + float r1 = luminance(texture(${y.result}, uv1).rgb) * roughnessScale; + float r2 = luminance(texture(${y.result}, uv2).rgb) * roughnessScale; + + roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y); + } + float roughnessFactor = roughnessChange * ${a.result}; + `:x=` + vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs; + + vec4 vals = texture(${y.result}, roughnessMapCachedUv); + float roughnessFactor = luminance(vals.rgb) * ${a.result}; + `,m.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${v.result}; + + const float roughnessScale = 1.0; + + ${x} + `)}else m.push(a.code," float roughnessFactor = "+a.result+";");d&&m.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),p?m.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include "),m.push("#include "),m.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let g="1.0";this.mask&&(this.mask.analyze(e),g=`luminance(${this.mask.flow(e,"v3").result})`),m.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${u.result} * ${g} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${g}, ${c.result} ); + + outgoingLight *= ao; + } + `),h&&m.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),d?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&m.push(`gl_FragColor.a *= ${f.result};`),m.push("#include ","#include ","#include "),r=m.join(` +`)}return r}};var Hp=class extends Mn{constructor(){super("toon");this.nodeType="Toon";this.color=new zt(an),this.specular=new zt(1118481),this.shininess=new Ce(30),this.previousModelViewMatrix=new Vn,this.previouseProjectionMatrix=new Vn,this.shadingAlpha=new Ce(1),this.shadingBlend=new yt(0)}get category(){return"toon"}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({resolution:je.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(vs.merge([we.fog,we.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include ","#include ","#include ","#include "].join(` +`));let s=["#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 + `];n&&s.push(n.code,n.result?"displaced_position = "+n.result+";":""),s.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),s.push(" #include "," #include "," #include "," vViewPosition = - mvPosition.xyz;"," #include "," #include "," #include "),s.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=s.join(` +`)}else{e.mergeUniform({penumbraSize:je.penumbraSize}),e.mergeUniform({frameIndex:je.frameIndex}),e.mergeUniform({aoMap:je.aoRenderTarget}),e.mergeUniform({aoEnabled:je.aoEnabled}),this.color===void 0&&(this.color=new zt(an)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let n=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),o=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include ","#include ","#include ","#include ","#include ","#include ",` + varying vec3 vViewPosition; + struct ToonMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; + }; + void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; + } + void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + } + #define RE_Direct RE_Direct_Toon + #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon + #define Material_LightProbeLOD( material ) (0) + `,"#include ","#include ","#include "].join(` +`));let d=["#include ",` + // NOTE: gl_FrontFacing alternative using face normal estimation. + vec3 viewdx = dFdx(vViewPosition); + vec3 viewdy = dFdy(vViewPosition); + vec3 faceNormal = normalize(cross(viewdx,viewdy)); + if (dot(normal, faceNormal) < 0.0) { + normal *= -1.0; + } + `," ToonMaterial material;"];if(this.bumpMap){e.include(aa.dHdxy),e.include(aa.perturbNormalArb);let p=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",y="";this.bumpMap.projection.value===4?y=` + vec3 bumpNormal = vec3(0.0); + { + vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0; + vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1; + vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2; + vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights; + + vec2 grad0 = dHdxy(${p.result}, uv0, ${g}); + vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection); + + vec2 grad1 = dHdxy(${p.result}, uv1, ${g}); + vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection); + + vec2 grad2 = dHdxy(${p.result}, uv2, ${g}); + vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection); + + bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y; + bumpNormal = normalize(bumpNormal); + } + + normal = bumpNormal; + `:y=` + vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs; + vec2 grad = dHdxy(${p.result}, bumpMapCachedUv, ${g}); + normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection ); + `,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates + ${m.result}; + ${y} + `)}d.push(n.code," vec3 diffuseColor = "+n.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," vec3 specular = "+s.result+";",o.code," float shininess = max( 0.0001, "+o.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include ","#include "),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),d.push(` + if (outgoingLight != diffuseColor) { + float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); + accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${f} * lightAccu; + outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${f}, ${l.result} ); + } + `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&d.push(`gl_FragColor.a *= ${h.result};`),d.push("#include ","#include ","#include "),r=d.join(` +`)}return r}};var Hv=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;let s=[1e3,1001,1002];for(let o of s){let a=this[o];a&&(a.image=this.img,a.needsUpdate=!0)}this.shared.requestRender()};if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"}));let s;await new Promise(o=>{n.onloadend=a=>{s=a.target?.result,o(null)}}),this.img.src=s}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=aI(e),this.img.onload=r}getTexture(e){let r=this[e];if(r)return r;{let n;return this.isVideo?n=new Sg(this.img,void 0,e,e):n=new or(this.img,void 0,e,e),this.loaded&&(n.needsUpdate=!0),this[e]=n,n}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var $i=class extends Md{};function EA(i,t){var e=Lq(t);return e.formatToParts?Oq(e,i):Rq(e,i)}var Iq={year:0,month:1,day:2,hour:3,minute:4,second:5};function Oq(i,t){try{for(var e=i.formatToParts(t),r=[],n=0;n=0&&(r[s]=parseInt(e[n].value,10))}return r}catch(o){if(o instanceof RangeError)return[NaN];throw o}}function Rq(i,t){var e=i.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(e);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var _A={};function Lq(i){if(!_A[i]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),e=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";_A[i]=e?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:i,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return _A[i]}function qv(i,t,e,r,n,s,o){var a=new Date(0);return a.setUTCFullYear(i,t,e),a.setUTCHours(r,n,s,o),a}var lI=36e5,Nq=6e4,MA={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function jp(i,t,e){var r,n;if(!i||(r=MA.timezoneZ.exec(i),r))return 0;var s;if(r=MA.timezoneHH.exec(i),r)return s=parseInt(r[1],10),cI(s)?-(s*lI):NaN;if(r=MA.timezoneHHMM.exec(i),r){s=parseInt(r[1],10);var o=parseInt(r[2],10);return cI(s,o)?(n=Math.abs(s)*lI+o*Nq,s>0?-n:n):NaN}if(kq(i)){t=new Date(t||Date.now());var a=e?t:Bq(t),l=TA(a,i),u=e?l:Fq(t,l,i);return-u}return NaN}function Bq(i){return qv(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds())}function TA(i,t){var e=EA(i,t),r=qv(e[0],e[1]-1,e[2],e[3]%24,e[4],e[5],0).getTime(),n=i.getTime(),s=n%1e3;return n-=s>=0?s:1e3+s,r-n}function Fq(i,t,e){var r=i.getTime(),n=r-t,s=TA(new Date(n),e);if(t===s)return t;n-=s-t;var o=TA(new Date(n),e);return s===o?s:Math.max(s,o)}function cI(i,t){return-23<=i&&i<=23&&(t==null||0<=t&&t<=59)}var uI={};function kq(i){if(uI[i])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:i}),uI[i]=!0,!0}catch{return!1}}var bI=pn(dI(),1),DA=pn(pI(),1);var Uq=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,mI=Uq;var CA=36e5,gI=6e4,Gq=2,si={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:mI};function IA(i,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(i===null)return new Date(NaN);var e=t||{},r=e.additionalDigits==null?Gq:(0,bI.default)(e.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]")return new Date(i.getTime());if(typeof i=="number"||Object.prototype.toString.call(i)==="[object Number]")return new Date(i);if(!(typeof i=="string"||Object.prototype.toString.call(i)==="[object String]"))return new Date(NaN);var n=Hq(i),s=jq(n.date,r),o=s.year,a=s.restDateString,l=Wq(a,o);if(isNaN(l))return new Date(NaN);if(l){var u=l.getTime(),c=0,h;if(n.time&&(c=qq(n.time),isNaN(c)))return new Date(NaN);if(n.timeZone||e.timeZone){if(h=jp(n.timeZone||e.timeZone,new Date(u+c)),isNaN(h))return new Date(NaN)}else h=(0,DA.default)(new Date(u+c)),h=(0,DA.default)(new Date(u+c+h));return new Date(u+c+h)}else return new Date(NaN)}function Hq(i){var t={},e=si.dateTimePattern.exec(i),r;if(e?(t.date=e[1],r=e[3]):(e=si.datePattern.exec(i),e?(t.date=e[1],r=e[2]):(t.date=null,r=i)),r){var n=si.timeZone.exec(r);n?(t.time=r.replace(n[1],""),t.timeZone=n[1].trim()):t.time=r}return t}function jq(i,t){var e=si.YYY[t],r=si.YYYYY[t],n;if(n=si.YYYY.exec(i)||r.exec(i),n){var s=n[1];return{year:parseInt(s,10),restDateString:i.slice(s.length)}}if(n=si.YY.exec(i)||e.exec(i),n){var o=n[1];return{year:parseInt(o,10)*100,restDateString:i.slice(o.length)}}return{year:null}}function Wq(i,t){if(t===null)return null;var e,r,n,s;if(i.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(e=si.MM.exec(i),e)return r=new Date(0),n=parseInt(e[1],10)-1,vI(t,n)?(r.setUTCFullYear(t,n),r):new Date(NaN);if(e=si.DDD.exec(i),e){r=new Date(0);var o=parseInt(e[1],10);return Qq(t,o)?(r.setUTCFullYear(t,0,o),r):new Date(NaN)}if(e=si.MMDD.exec(i),e){r=new Date(0),n=parseInt(e[1],10)-1;var a=parseInt(e[2],10);return vI(t,n,a)?(r.setUTCFullYear(t,n,a),r):new Date(NaN)}if(e=si.Www.exec(i),e)return s=parseInt(e[1],10)-1,xI(t,s)?yI(t,s):new Date(NaN);if(e=si.WwwD.exec(i),e){s=parseInt(e[1],10)-1;var l=parseInt(e[2],10)-1;return xI(t,s,l)?yI(t,s,l):new Date(NaN)}return null}function qq(i){var t,e,r;if(t=si.HH.exec(i),t)return e=parseFloat(t[1].replace(",",".")),PA(e)?e%24*CA:NaN;if(t=si.HHMM.exec(i),t)return e=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),PA(e,r)?e%24*CA+r*gI:NaN;if(t=si.HHMMSS.exec(i),t){e=parseInt(t[1],10),r=parseInt(t[2],10);var n=parseFloat(t[3].replace(",","."));return PA(e,r,n)?e%24*CA+r*gI+n*1e3:NaN}return null}function yI(i,t,e){t=t||0,e=e||0;var r=new Date(0);r.setUTCFullYear(i,0,4);var n=r.getUTCDay()||7,s=t*7+e+1-n;return r.setUTCDate(r.getUTCDate()+s),r}var Yq=[31,28,31,30,31,30,31,31,30,31,30,31],Xq=[31,29,31,30,31,30,31,31,30,31,30,31];function wI(i){return i%400===0||i%4===0&&i%100!==0}function vI(i,t,e){if(t<0||t>11)return!1;if(e!=null){if(e<1)return!1;var r=wI(i);if(r&&e>Xq[t]||!r&&e>Yq[t])return!1}return!0}function Qq(i,t){if(t<1)return!1;var e=wI(i);return!(e&&t>366||!e&&t>365)}function xI(i,t,e){return!(t<0||t>52||e!=null&&(e<0||e>6))}function PA(i,t,e){return!(i!=null&&(i<0||i>=25)||t!=null&&(t<0||t>=60)||e!=null&&(e<0||e>=60))}function Qv(i,t,e){var r=IA(i,e),n=jp(t,r,!0),s=new Date(r.getTime()-n),o=new Date(0);return o.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),o.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),o}function zn(i,t){return t.color(i)}function OA(i=new Date,t){let e=t.format,r=i.getSeconds(),n=i;t&&t.timeZone!==null&&(n=Qv(new Date,t.timeZone));let s=n.getHours(),o=n.getMinutes(),a;t.format12h24h==="12ampm"&&(a=s>=12?"PM":"AM");let l=s;t.format12h24h!=="24"&&(l=s%12,l===0&&(l=12));let u,c;switch(e){case"HH:mm:ss":u=[l,o,r];break;case"HH:mm":u=[l,o];break;case"HH":u=[l],a=void 0;break;case"mm":u=[o],a=void 0;break;case"ss":u=[r],a=void 0;break;case"year":c=n.getFullYear();break;case"month":c=n.getMonth()+1;break;case"dayOfYear":c=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=n.getDate();break;case"secondOfDay":c=s*60*60+o*60+r;break;default:console.error("Unknown time format",e),c=0;break}return u!==void 0?{textValue:u,suffix:a}:c}function SI(i,t){switch(i.type){case"fresnel":return Jq(i,t);case"gradient":return $q(i,t);case"depth":return e9(i,t);case"normal":return t9(i,t);case"noise":return r9(i,t);case"rainbow":return n9(i,t);case"toon":return i9(i,t);case"outline":return s9(i,t);case"transmission":return o9(i,t);case"color":return Zq(i,t);case"pattern":return a9(i,t)}}function Kq(i){return{type:i.type}}function Ps(i,t){let{alpha:e,mode:r,isMask:n}=i,s=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...Kq(i),alpha:s,mode:r,isMask:n}}function Zq(i,t){return{...Ps(i,t),color:zn(i.color,t)}}function Jq(i,t){let{bias:e,scale:r,intensity:n,factor:s,color:o}=i;return{...Ps(i,t),color:zn(o,t),bias:e,scale:r,intensity:n,factor:s}}function $q(i,t){let{gradientType:e,smooth:r,colors:n,steps:s,angle:o,offset:a,morph:l}=i;return{...Ps(i,t),gradientType:e,smooth:r,colors:n.map(u=>new Xe(u[0],u[1],u[2],u[3])),num:n.length,steps:s,offset:new N(...a),morph:new N(...l),angle:o}}function e9(i,t){let{gradientType:e,near:r,far:n,isVector:s,isWorldSpace:o,origin:a,direction:l,colors:u,steps:c,smooth:h}=i;return{...Ps(i,t),gradientType:e,near:r,far:n,isVector:s,isWorldSpace:o,origin:new _(...a),direction:l?new _(...l):new _(1,0,0),colors:u.map(d=>d!==void 0?new Xe(d[0],d[1],d[2],d[3]):new Xe(0,0,0,0)),steps:c.slice(0,u.length),smooth:h}}function t9(i,t){let{cnormal:e}=i;return{...Ps(i,t),cnormal:new _(e[0],e[1],e[2])}}function r9(i,t){return{...Ps(i,t),scale:i.scale,move:i.move,fA:new N(...i.fA),fB:new N(...i.fB),size:new _(...i.size),distortion:new N(...i.distortion),colorA:zn(i.colorA,t),colorB:zn(i.colorB,t),colorC:zn(i.colorC,t),colorD:zn(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function n9(i,t){return{...Ps(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new _(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new _(...i.offset)}}function i9(i,t){return{...Ps(i,t),positioning:i.positioning,colors:i.colors.map(e=>new Xe(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new _(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:zn(i.shadowColor,t),offset:new _(...i.offset)}}function s9(i,t){return{...Ps(i,t),outlineColor:zn(i.outlineColor,t),contourColor:zn(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new _(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function o9(i,t){return{...Ps(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function a9(i,t){return{...Ps(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new N(...i.offset),colorA:zn(i.colorA,t),colorB:zn(i.colorB,t),frequency:new N(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new N(...i.vertical),horizontal:new N(...i.horizontal),sides:i.sides}}var pl=class extends gr{};var RA={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},LA={depth:["colors"]};function l9(i,t,e){if(t==="isMask")return!0;let r=RA[i.type],n=LA[i.type];if(n!==void 0){let s=i.color;if(n.includes(t)){let o=s[t]?.value?.length;if(o!==void 0&&o!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function NA(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let n=!1,s=i;if("image"in s){let o=s.image,a=t.image(o),l=r;l.image instanceof $i||l.image.deref(),l.image=a}if("video"in s){let o=s.video,a=t.video(o),l=r;l.image instanceof $i||l.image.deref(),l.image=a}if("wrapping"in s){let o=r;o.wrap=s.wrapping}if("repeat"in s||"offset"in s){let o="mat",a=e.uniforms[`f${e.id}_${o}`];"repeat"in s&&(a.repeat=s.repeat),"offset"in s&&(a.offset=s.offset),a.updateMatrix()}return n}function AI(i,t,e,r){let n=!1;for(let[s,o]of Object.entries(i)){if(s==="bumpMap"||s==="roughnessMap"){n=!0;continue}if(!s||o===void 0)continue;if(BA(s,e,r,t)){s==="visible"&&e.type==="light"&&(n=!0);continue}e.visible=r.visible;let a=e.uniforms[`f${e.id}_${s}`];if(!!a&&!(a instanceof dl))switch(n=n||l9(e,s,o),a.constructor){case zt:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof pl?a.value=new gr(l.r,l.g,l.b,l.a):a.setRGBA(l);break}case vi:if(typeof o=="string"){let l=t.getColor(o);l&&(a.value=l);break}else{let l=o;a.value instanceof pl?a.value=new gr(l.r,l.g,l.b,l.a):a.value.setRGBA(l.r,l.g,l.b,l.a);break}case wr:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]);break}case kn:{let l=o;a.value.setX(l[0]),a.value.setY(l[1]),a.value.setZ(l[2]);break}case ii:{NA(o,t,e);break}case Cs:{a.value=o.map(l=>new Xe(...l));break}default:{a.value=o;break}}}return n}var ml=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,ho=class{constructor(t,e,r,n,s){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let o in n)this.uniforms[`f${this.id}_${o}`]=n[o];for(let o in r)BA(o,this,r,s)}get type(){return this.data.type}static create(t,e,r,n){if(r.type==="light")return Fi.createLigherLayer(t,e,r,n);if(r.type==="texture"||r.type==="video"){let s=r.type==="texture"?n.image(r.texture.image):n.video(r.texture.video),o=new bc(s,r.texture.wrapping),a=new Uv(s),l=new Gv(r.texture.repeat,r.texture.offset),u=new Ce(r.crop?1:0),c=new yt(r.projection??0),h=new yt(["x","y","z"].indexOf(r.axis)??0),d=new yt(r.side??0),f=new wr(r.size?new N(r.size[0],r.size[1]):new N(100,100)),p=new Ce(r.blending??0),m=new Ce(ml(r.alpha,n)),g=new yt(r.mode??0),y=new Tr(r.isMask??!1),v=new fl(o,a,u,c,h,d,f,p,l,m,g,y),x=new Rt(v.calpha,"f");return new ur(t,e,r,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,blending:p,mat:l,alpha:m,mode:g,isMask:y},v,g,x,y,n)}else if(r.type==="matcap"){let s=n.image(r.texture.image),o=new bc(s,r.texture.wrapping),a=new Ce(ml(r.alpha,n)),l=new yt(r.mode??0),u=new Tr(r.isMask??!1),c=new vd(o,a,l,u),h=new Rt(c.calpha,"f");return new ur(t,e,r,{texture:o,alpha:a,mode:l,isMask:u},c,l,h,u,n)}else if(r.type==="displace")if(r.displacementType==="noise"){let s=new kn(new _(...r.offset)),o=new Ce(r.scale??10),a=new Ce(r.intensity??8),l=new Ce(r.movement??1),u=new yt(r.noiseType??0),c=new yt(r.voronoiStyle??0),h=new Ce(r.smoothness??.5),d=new Ce(r.seed??0),f=new Ce(r.highCut??1),p=new Ce(r.lowCut??0),m=new yt(r.quality??1),g=new Ed(a,l,s,c,h,d,f,p,m,o,u);return new Wp(t,e,r,{offset:s,scale:o,intensity:a,movement:l,noiseType:u,voronoiStyle:c,smoothness:h,seed:d,highCut:f,lowCut:p,quality:m},g,n)}else throw new Error;else return h9(t,e,r,n)}updateByOp(t,e,r){let n=t;if(n.path[0]===void 0){if(n.type===0)return"type"in n.props||"category"in n.props||"visible"in n.props?(r.scene.markNeedsUpdateRendererDirty(),!0):AI(n.props,r.shared,this,e)}else if(n.path[0]==="texture")return"texture"in e||"video"in e?NA(n.props,r.shared,this):!0;return!1}dispose(){if(c9(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof $i||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},ur=class extends ho{constructor(e,r,n,s,o,a,l,u,c){super(e,r,n,s,c);this.params=s;this.color=o;this.mode=a;this.alpha=l;this.isMask=u}},Wp=class extends ho{constructor(e,r,n,s,o,a){super(e,r,n,s,a);this.position=o}},Fi=class extends ho{constructor(e,r,n,s,o,a){super(e,r,n,o,a);this.node=s}static createLigherLayer(e,r,n,s){let o,a=new Ce(ml(n.alpha,s)),l=new yt(n.mode),u=new Ce(n.bumpMapIntensity),c=new Ce(ml(n.alphaOverride,s)),h;if(!n.visible)o=new Ac,h={};else if(n.category==="lambert"){o=new zp;let d=new zt(s.color(n.emissive)??0),f=new Tr(n.occlusion??!0);h={emissive:d,occlusion:f},o.emissive=d,o.occlusion=f}else if(n.category==="toon"){o=new Hp;let d=new Ce(n.shininess??30),f=new zt(s.color(n.specular)??1118481);h={shininess:d,specular:f},o.shininess=d,o.specular=f}else if(n.category==="physical"){o=new Gp;let d=new Ce(n.roughness??.3),f=new Ce(n.metalness??0),p=new Ce(n.reflectivity??.5),m=new Tr(n.occlusion??!0);h={roughness:d,metalness:f,reflectivity:p,occlusion:m},o.roughness=d,o.metalness=f,o.reflectivity=p,o.occlusion=m}else{o=new Up;let d=new Ce(n.shininess??30),f=new zt(n.specular!==void 0?s.color(n.specular)??1118481:1118481),p=new Tr(n.occlusion??!0);h={shininess:d,specular:f,occlusion:p},o.shininess=d,o.specular=f,o.occlusion=p}return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,o.bumpMapIntensity=u,o.alphaOverride=c,h.alpha=o.shadingAlpha,h.mode=o.shadingBlend,h.bumpMapIntensity=o.bumpMapIntensity,h.alphaOverride=o.alphaOverride,new Fi(e,r,n,o,h,s)}get category(){return this.node.category}};function c9(i){let t=i instanceof ho?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function es(i){return{alpha:new Ce(i.alpha??1),mode:new yt(i.mode??0),isMask:new Tr(i.isMask??!1)}}function u9(i,t,e,r,n){switch(i.type){case"color":{let s=new zt(r.color??an),o=es(r),a=new wc(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,n)}case"fresnel":{let s=new zt(r.color??16777215),o=new Ce(r.bias??.1),a=new Ce(r.scale??1),l=new Ce(r.intensity??2),u=new Ce(r.factor??1),c=es(r),h=new kp(s,o,a,l,u,c.alpha,c.mode,c.isMask),d=new Rt(h.calpha,"f");return new ur(t,e,i,{color:s,bias:o,scale:a,intensity:l,factor:u,...c},h,c.mode,d,c.isMask,n)}case"rainbow":{let s=new Ce(r.filmThickness??30),o=new Ce(r.movement??0),a=new kn(r.wavelengths??new _(0,0,0)),l=new Ce(r.noiseStrength??0),u=new Ce(r.noiseScale??1),c=new kn(r.offset??new _(0,0,0)),h=es(r),d=new Sd(s,o,a,l,u,c,h.alpha,h.isMask),f=new Rt(d.calpha,"f");return new ur(t,e,i,{filmThickness:s,movement:o,wavelengths:a,noiseStrength:l,noiseScale:u,offset:c,...h},d,h.mode,f,h.isMask,n)}case"transmission":{let s=new Ce(r.thickness??10),o=new Ce(r.ior??1.5),a=new Ce(r.roughness??.5),l=je.transmissionSize,u=je.transmissionRenderTarget,c=je.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new wr(d/h,1):new wr(1,h/d),p=es(r),m=new _d(s,o,a,l,u,c,f,p.alpha),g=new Rt(m.calpha,"f");return new ur(t,e,i,{thickness:s,ior:o,roughness:a,aspectRatio:f,...p},m,p.mode,g,p.isMask,n)}case"toon":{let s=new yt(r.positioning??0),o;r.colors?o=new Cs(r.colors.length,r.colors):(o=new Cs(10,new Xe(0,0,0,1)),o.value[1]=new Xe(1,1,1,1));let a;r.steps?a=new Ts(r.steps.length,r.steps):(a=new Ts(10,1),a.value[0]=0);let l=new kn(r.source??new _(0,0,0)),u=new Tr(r.isWorldSpace??!0),c=new Ce(r.noiseStrength??0),h=new Ce(r.noiseScale??1),d=new vi(r.shadowColor),f=new kn(r.offset??new _(0,0,0)),p=es(r),m=new Ad(s,o,a,l,u,c,h,d,f,p.alpha),g=new Rt(m.calpha,"f");return new ur(t,e,i,{positioning:s,colors:o,steps:a,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:h,shadowColor:d,offset:f,...p},m,p.mode,g,p.isMask,n)}case"outline":{let s=new zt(r.outlineColor??16777215),o=new zt(r.contourColor??16777215),a=new Ce(r.outlineWidth??.1),l=new Ce(r.contourWidth??.1),u=new Ce(r.outlineThreshold??.1),c=new Ce(r.contourThreshold??.1),h=new Ce(r.outlineSmoothing??.1),d=new Ce(r.contourFrequency??.1),f=new kn(r.contourDirection??new _(0,1,0)),p=new Tr(r.positionalLines??!1),m=new Tr(r.compensation??!0),g=je.normalRenderTarget,y=je.normalRenderTargetDepth,v=je.pixelRatioNode,x=je.resolution,w=es(r),S=new bd(s,o,a,l,u,c,h,d,f,p,m,x,g,y,v,w.alpha),A=new Rt(S.calpha,"f");return new ur(t,e,i,{outlineColor:s,contourColor:o,outlineWidth:a,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:p,compensation:m,...w},S,w.mode,A,w.isMask,n)}case"depth":{let s=new yt(r.gradientType??0),o=new Tr(r.smooth??!1),a=new Ce(r.near??50),l=new Ce(r.far??200),u=new Ce(r.isVector??1),c=new Ce(r.isWorldSpace??0),h=new kn(r.origin??new _),d=new kn(r.direction??new _),f;r.colors?f=new Cs(r.colors.length,r.colors):(f=new Cs(2,new Xe(0,0,0,1)),f.value[1]=new Xe(1,1,1,1));let p;r.steps?p=new Ts(r.steps.length,r.steps):(p=new Ts(2,1),p.value[0]=0);let m=es(r),g=new gd(s,o,a,l,u,c,h,d,f,p,m.alpha,m.isMask),y=new Rt(g.calpha,"f");return new ur(t,e,i,{gradientType:s,smooth:o,near:a,far:l,isVector:u,isWorldSpace:c,origin:h,direction:d,colors:f,steps:p,...m},g,m.mode,y,m.isMask,n)}case"noise":{let s=new Ce(r.scale??1),o=new kn(r.size??new _(100,100,100)),a=new Ce(r.move??1),l=new wr(r.fA??new N(1.7,9.2)),u=new wr(r.fB??new N(8.3,2.8)),c=new wr(r.distortion??new N(1,1)),h=new vi(r.colorA),d=new vi(r.colorB),f=new vi(r.colorC),p=new vi(r.colorD),m=new yt(r.noiseType??0),g=new yt(r.voronoiStyle??0),y=new Ce(r.highCut??1),v=new Ce(r.lowCut??0),x=new Ce(r.smoothness??.5),w=new Ce(r.seed??.5),S=new yt(r.quality??1),A=es(r),E=new xd(s,o,a,l,u,c,h,d,f,p,A.alpha,m,A.isMask,g,y,v,x,w,S),b=new Rt(E.calpha,"f");return new ur(t,e,i,{scale:s,size:o,move:a,fA:l,fB:u,distortion:c,colorA:h,colorB:d,colorC:f,colorD:p,noiseType:m,...A,voronoiStyle:g,highCut:y,lowCut:v,smoothness:x,seed:w,quality:S},E,A.mode,b,A.isMask,n)}case"normal":{let s=new kn(r.cnormal??new _(1,1,1)),o=es(r),a=new fd(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{cnormal:s,...o},a,o.mode,l,o.isMask,n)}case"gradient":{let s=new yt(r.gradientType??0),o=new Tr(r.smooth??!1),a;r.colors?a=new Cs(r.colors.length,r.colors):(a=new Cs(10,new Xe(0,0,0,1)),a.value[1]=new Xe(1,1,1,1));let l;r.steps?l=new Ts(r.steps.length,r.steps):(l=new Ts(10,1),l.value[0]=0);let u=new wr(r.offset??new N(0,0)),c=new wr(r.morph??new N(0,0)),h=new Ce(r.angle??0),d=es(r),f=new yd(s,o,a,l,u,c,h,d.alpha,d.isMask),p=new Rt(f.calpha,"f");return new ur(t,e,i,{gradientType:s,smooth:o,colors:a,steps:l,offset:u,morph:c,angle:h,...d},f,d.mode,p,d.isMask,n)}case"pattern":{let s=new yt(r.style??0),o=new yt(r.projection??0),a=new yt(["x","y","z"].indexOf(r.axis)??0),l=new Ce(r.blending??0),u=new wr(r.offset??new N(0,0)),c=new vi(r.colorA),h=new vi(r.colorB),d=new wr(r.frequency??new N(10,10)),f=new Ce(r.size??.5),p=new Ce(r.variation??0),m=new Ce(r.smoothness??.5),g=new Ce(r.zigzag??0),y=new Ce(r.rotation??0),v=new wr(r.vertical??new N(0,1)),x=new wr(r.horizontal??new N(0,1)),w=new yt(r.sides??6),S=es(r),A=new wd(s,o,a,l,u,c,h,d,f,p,m,g,y,v,x,w,S.alpha,S.isMask),E=new Rt(A.calpha,"f");return new ur(t,e,i,{style:s,projection:o,axis:a,blending:l,offset:u,colorA:c,colorB:h,frequency:d,size:f,variation:p,smoothness:m,zigzag:g,rotation:y,vertical:v,horizontal:x,sides:w,...S},A,S.mode,E,S.isMask,n)}default:{let s=new zt(1,0,0,1),o=es(r),a=new wc(s,o.alpha),l=new Rt(a.calpha,"f");return new ur(t,e,i,{color:s,...o},a,o.mode,l,o.isMask,n)}}}function h9(i,t,e,r){let n=SI(e,r);return u9(e,i,t,n,r)}function BA(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=e.intensity*(e.visible?1:0),n):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=ml(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let s=t.uniforms[`f${t.id}_compensation`];s&&(s.value=e.compensation&&e.visible)}return n}}function _c(i,t){let e=0,r=i.layers.find(n=>n.data.type==="light");if(r){let n=r.data,s=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?s/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let s=n.data.visible?n.data.alpha:0;if(typeof s=="string"&&(s=Math.max(0,Math.min(1,Number(t.getVariable(s)??100)/100))),s===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let o of n.data.colors)if(o[3]<1){s=o[3];break}}else if(s===1&&n.data.type==="noise"){let o=t.color(n.data.colorA).a,a=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,u=t.color(n.data.colorD).a,c=Math.min(o,Math.min(a,Math.min(l,u)));c<1&&(s=c)}e+=(1-e)*s}}return e<1}var bi=class extends at{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Kv=class extends bi{constructor(e,r,n,s){super();this.flatShading=e;this.side=r;this.wireframe=n;this.root=s}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,n){return this.root.getFlavor(e,r,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,n){this.root.updateByOp(e,r,n)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},la=class extends bi{constructor(e,r,n=!0){super();this.data=e;this.allowVariableSaves=n;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,n){let s=n?6:(e?3:0)+r;if(s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let o=this.flavors[s];return o===void 0&&(o=new Kv(e,r,n,this),this.flavors[s]=o,o.flatShading=e,o.side=r,o.updateAfterBuild()),o}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r){this.data!==e&&this.reset0(e,r)}reset0(e,r){this.data=e;let n=e.layers??Br.defaultTwoLayerData("phong").layers;try{this.layers=n.map(s=>ho.create(this.layerIdGen++,s.id,s.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=_c(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,n){if(e[0]==="alphaOverride")this.transparent=_c(this.data,n.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let s=e[1],o=e[2];if(s&&o){let a=this.layers.find(l=>l.uuid===s);a?.hasValue(o)&&(o==="alpha"?(this.transparent=_c(this.data,n.shared),a.setValue(o,Math.max(0,Math.min(Number(r)/100,1)))):a.setValue(o,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(n=>n.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(n=>{"alpha"in n.data&&typeof n.data.alpha=="string"&&e.shared.getVariable(n.data.alpha,["material",this.uuid,"layer",n.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof Fi),this.lightLayer===void 0&&(this.lightLayer=new Fi(0,"",{..._n.defaultData("light","phong"),visible:!1},new Ac,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(o=>o instanceof Fi);if(!e)return;let r=e.data,n=r.bumpMap,s=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let o=0;ou.uuid===e.id),l=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,l),n.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(n.shared)}else{e.type===0&&e.props.occlusion!==void 0&&n.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(l=>l.uuid===o);if(a){let l=r.layers.data(o),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:ml(e.props.alpha,s,["material",this.uuid,"layer",o,"alpha"])}:u={...e.props,alphaOverride:ml(e.props.alphaOverride,s,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,n)){let h=ho.create(this.layerIdGen++,o,l,s);this.layers.splice(this.layers.findIndex(d=>d.uuid===o),1,h),this.onUpdate(n.shared)}}}}else this.reset(r,n)}applyMasks(){for(let e=0;e0){let n=e-1,s=this.layers[n];s instanceof Fi?s.node.mask=new Tn(r.color,r.alpha,Tn.MUL):s instanceof ur&&(s.isMask.value||(s.color.mask=new Tn(r.color,r.alpha,Tn.MUL)))}}}blendColors(){let e=this.layers.findIndex(n=>n instanceof ur),r=this.layers.findIndex(n=>n instanceof Fi);if(e!==-1&&en instanceof Fi);if(this.layers.length>r+1){for(let n=r+1;nr instanceof Wp);if(e.length>0){let r=e[0].position;for(let n=1;nMath.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){let o=n(s.uniforms[`f${s.id}_intensity`].value,e,r);s.uniforms[`f${s.id}_intensity`].value=o}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let n=(RA[r.type]??[]).map(u=>r[u]),s=(LA[r.type]??[]).map(u=>r[u]?.length??0),o=[...n,...s],a="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${a}"`;o.length?e+=`[${l}, "${o.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;re.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ur){let r=e.params.texture;if(r instanceof bc&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(bi.prototype,{properties:{get:function(){return this.fragment.properties}}});var Ec=class extends la{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var TI=pn(_I());var EI=new Map;function MI(i){if(typeof i=="string")return i;let t=EI.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},EI.set(i,t)),t.url}var ca=class{constructor({src:t,volume:e,delay:r,loop:n}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof t=="string"?s={src:t}:s={src:MI(t),format:"wav"},this.sound=new TI.Howl(s),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),n!==void 0&&(this.loop=n)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Jv=class{constructor(){this.type="ShapePath";this.color=new Re;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Yl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,n){return this.currentPath?.quadraticCurveTo(t,e,r,n),this}bezierCurveTo(t,e,r,n,s,o){return this.currentPath?.bezierCurveTo(t,e,r,n,s,o),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function n(m,g,y,v){let x=m.x,w=g.x,S=y.x,A=v.x,E=m.y,b=g.y,M=y.y,T=v.y,C=(A-S)*(E-M)-(T-M)*(x-S),P=(w-x)*(E-M)-(b-E)*(x-S),D=(T-M)*(w-x)-(A-S)*(b-E),I=C/D,R=P/D;if(D===0&&C!==0||I<=0||I>=1||R<0||R>1)return null;if(C===0&&D===0){for(let U=0;U<2;U++)if(s(U===0?y:v,m,g),r.loc===e.ORIGIN){let F=U===0?y:v;return{x:F.x,y:F.y,t:r.t}}else if(r.loc===e.BETWEEN){let F=+(x+r.t*(w-x)).toPrecision(10),V=+(E+r.t*(b-E)).toPrecision(10);return{x:F,y:V,t:r.t}}return null}else{for(let V=0;V<2;V++)if(s(V===0?y:v,m,g),r.loc===e.ORIGIN){let G=V===0?y:v;return{x:G.x,y:G.y,t:r.t}}let U=+(x+I*(w-x)).toPrecision(10),F=+(E+I*(b-E)).toPrecision(10);return{x:U,y:F,t:I}}}function s(m,g,y){let v=y.x-g.x,x=y.y-g.y,w=m.x-g.x,S=m.y-g.y,A=v*S-w*x;if(m.x===g.x&&m.y===g.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===y.x&&m.y===y.y){r.loc=e.DESTINATION,r.t=1;return}if(A<-Number.EPSILON){r.loc=e.LEFT;return}if(A>Number.EPSILON){r.loc=e.RIGHT;return}if(v*w<0||x*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+x*x)T.t<=M.t+Number.EPSILON&&T.t>=M.t-Number.EPSILON)===void 0&&(y.push(M),v.push(new N(M.x,M.y)))}}return v}function a(m,g,y){let v=new N;g.getCenter(v);let x=[];return y.forEach(w=>{w.boundingBox.containsPoint(v)&&o(m,w.points).forEach(A=>{x.push({identifier:w.identifier,isCW:w.isCW,point:A})})}),x.sort((w,S)=>w.point.x-S.point.x),x}function l(m,g,y,v,x){(x==null||x==="")&&(x="nonzero");let w=new N;m.boundingBox.getCenter(w);let S=[new N(y,w.y),new N(v,w.y)],A=a(S,m.boundingBox,g);A.sort((P,D)=>P.point.x-D.point.x);let E=[],b=[];A.forEach(P=>{P.identifier===m.identifier?E.push(P):b.push(P)});let M=E[0].point.x,T=[],C=0;for(;C0&&T[T.length-1]===b[C].identifier?T.pop():T.push(b[C].identifier),C++;if(T.push(m.identifier),x==="evenodd"){let P=T.length%2===0,D=T[T.length-2];return{identifier:m.identifier,isHole:P,for:D}}else if(x==="nonzero"){let P=!0,D=null,I=null;for(let R=0;R{let g=m.getPoints(),y=-999999999,v=999999999,x=-999999999,w=999999999;for(let S=0;Sy&&(y=A.y),A.yx&&(x=A.x),A.x=w&&(c=w-1),g.length&&d.push({curves:m.curves,points:g,isCW:gu.isClockWise(g),identifier:u++,boundingBox:new Tu(new N(w,v),new N(x,y))})});let f=d.map(m=>l(m,d,c,h,this.userData?.style.fillRule)),p=[];return d.forEach(m=>{let g=f[m.identifier];if(g&&!g.isHole){let y=new Wo;y.curves=m.curves,f.filter(x=>x?.isHole&&x.for===m.identifier).forEach(x=>{if(x){let w=d[x.identifier],S=new Yl;S.curves=w.curves,y.holes.push(S)}}),p.push(y)}}),p}};var PI,FA=new Promise(i=>{PI=i}),CI=!1;var $v;function DI(){if(CI)return;if($v)return $v;async function i(){let e=await import("./opentype.js");PI(e),CI=!0}return $v=i(),$v}var qp=class{async load(t,e,r=()=>{}){let{load:n}=await FA;n(t,(s,o)=>{s||!o?r(s??"Something went wrong"):e(o)})}async parse(t){let{parse:e,Bidi:r}=await FA;try{let n=e(t),s=new r,o=a=>n.charToGlyphIndex(a.char);return s.registerModifier("glyphIndex",null,o),s.applyFeatures(n,n.defaultRenderOptions.features),{font:n,bidi:s}}catch(n){console.error(n)}}};async function d9(i){return await(await fetch(i)).arrayBuffer()}var f9=new qp;async function kA(i){let t,e,r=!1;if(i.url?(t=await d9(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t){let n=await f9.parse(t);if(n)return{font:n.font,url:e,intercepted:r,arr:t,bidi:n.bidi}}}function p9(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var e0=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=kA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=kA(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let n=this._bidi;n.getTextGlyphs(e);let s=n.tokenizer.tokens,o=[],a=0,l=r.length===s.length;for(let u=0;ue.length&&(y=!0);o.push({char:h,index:c,replacements:m,replacementChars:Array.from(f)}),a++}}return o}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,n=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(v=>this.getTextWidth(v,e)),a=e.width,l=this.getCharWidth(` +`,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),h=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),d=this.getLineInitialOffsetY(s,t.length,e.height,n,e.verticalAlign),f=[],p=t.map(v=>[]),m=t.map(v=>[]),g;for(let v=0;v(r.glyphs.get(V).advanceWidth??0)*n),R=I.reduce((V,G)=>V+=G,0),U=I.map(V=>V/R),F=h;for(let V=0;V=0&&(t-=s),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,s){let o=e*t,a=Math.abs(this.ascender-this.descender)*n,l=t-a,u=-this.ascender*n-l/2;return s===3?-(r-o-u):s===2?-(r*.5-o*.5-u):u}createPath(t,e,r,n,s){let o=t.getPath(r,-n,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let a=new Jv,l=(t.advanceWidth??1)*e;if(t)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=m9(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r){let n=this.getCharWidth(" ",r),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(r.horizontalAlign===4&&e{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Yp=class extends VA{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let s=gc(e,r,this.flatShading,n);return s.computeBoundingSphere(),s}};var II={markNeedsUpdateRendererDirty:()=>{}};var zA=class extends Wv{constructor(e){super();this.shared=e}create(e){return new Md(e,this.shared)}},Mc=class{constructor(t,e={}){this.data=t;this.geometryCache=new Yp(!0);this.geometryCache2=new Yp(!1);this.imageHolderCache=new zA(this);this.thisContext={scene:II,shared:this};this.deletedMaterial=new Ec(Br.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new $i(_h.emptyImage,this);this.deletedVideo=new $i(ph.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.variables={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[r,n]of Object.entries(e.images))this.addImage(r,n);if(e.videos)for(let[r,n]of Object.entries(e.videos))this.addVideo(r,n);if(e.audios)for(let[r,n]of Object.entries(e.audios))this.addAudio(r,n);this.reset(t)}setRequestRender(t){this._requestRender=t}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1){this.resetLib(t.lib);for(let{id:r,data:n}of t.variables)this.addVariableHolder(r,n),e&&this.updateVariableHolder(r,n);for(let[r,n]of Object.entries(t.images))this.addImage(r,n);for(let[r,n]of Object.entries(t.videos))this.addVideo(r,n);for(let[r,n]of Object.entries(t.colors))this.addColor(r,n);for(let[r,n]of Object.entries(t.materials))this.addMaterial(r,n);for(let[r,n]of Object.entries(t.audios))this.addAudio(r,n);for(let[r,n]of Object.entries(t.fonts))this.addFont(r,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Ec(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new la(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new $i(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new $i(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new pl(e.r,e.g,e.b,e.a):this.colors[t]=new pl(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new gr(0,0,0,0))}else return"a"in t?new gr(t.r,t.g,t.b,t.a):new gr(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof ca)return e;{let r=new ca({src:e.data});return this.audios[t]=r,r}}deleteAudio(t){let e=this.audios[t];e&&(e instanceof ca&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new e0(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof ca&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){return this.variables[t]===void 0?(this.variables[t]={value:e.value,locations:[]},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0):(this.variables[t].value=e.value,!1)}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e;let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene;for(let s=this.variables[t].locations.length-1;s>=0;s--){let o=this.variables[t].locations[s];if(o[0]==="material"){let a=o[1],l=r,u={scene:n,shared:this},c=o.slice(2);n.traverseMaterial(d=>{let f=d.root??d;f.uuid===a&&f.onVariableUpdate(c,l,u)});let h=this.materials[a];h&&h.onVariableUpdate(c,l,u)}else{let a=n.find(o[0]);if(a===void 0){this.variables[t].locations.splice(s,1);continue}if(o[1]!=="geometry"){for(let l=1;l{let h=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(h.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0)})}}}}return!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let n=1;nRr.equal(o,e));s!==void 0&&s!==-1&&n.locations.splice(s,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;r=this.variables[r].value}while(typeof r=="string");return e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r}else return t}getVariables(){return this.variables}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){this.data=e,t.path[0]==="images"?t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="colors"?t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(Lr.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r}):t.path[0]==="fonts"?t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===2&&t.type===0&&"value"in t.props?this.updateVariable(t.path[1],t.props.value):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id):t.path[0]==="lib"&&this.updateLibByOp(Lr.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),s={...this.data.fonts[t],url:e.props.url};n.update(s),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}},b_e=new Mc(fi.emptyData());var ts=class extends $t{updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),yP(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[s,o]of Object.entries(e.props)){let a=n.shared.material(o);this.material[Number(s)]=a}else if(qn(e.path,["material"])&&this.material instanceof bi)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(Lr.drop(e,1),r.material,n);else if(qn(e.path,["materials","*"])&&Array.isArray(this.material)){let s=e.path[1];if("materials"in r&&sr.shared.material(s).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let s=0;s{e instanceof bi&&(e instanceof Ec||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var OI=new _,RI=new Xe,LI=new Xe,y9=new _,NI=new ie,Qt=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new ie().fromArray(r.bindMatrix),this.bindMatrixInverse=new ie)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ae&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Mc){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return mp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return mp.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),qn(e.path,["geometry"])&&this.updateByPatchedOpGeometry(Lr.drop(e,1),r.geometry,n)}removeInteractionGeometry(){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let c={...this.data.geometry,...s};this.localGeometry=gc(c,r,this.data.flatShading,this)}let o,a,l;s.scaleBaked?[o,a,l]=s.scaleBaked:{width:o,height:a,depth:l}=s;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Lp(this.localGeometry.attributes,o/u.sxPrev,a/u.syPrev,l/u.szPrev),u.sxPrev=o,u.syPrev=a,u.szPrev=l}else{let s={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=gc(s,r,this.data.flatShading,this)}}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let s=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Fr&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(s=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),s||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r),super.updateState(e,r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;this.is2DType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):e.setScalar(0),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Xe,n=this.geometry.attributes.skinWeight;for(let s=0,o=n.count;s{for(let l of o.normals)o.result.add(l);o.result.divideScalar(o.normals.length)});for(let o=0;o{b9=i});var fo=new Pt,Xp=new _;function BI(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Ds=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new ie;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:s,subdivPointer:o}=Fr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=o,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Td(this),Cd(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Fr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Fr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,$t.prototype.raycast.call(this,e,r),this.localGeometry=n}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;fo.setFromBufferAttribute(r),fo.getCenter(n),e.boundingSphere.radius=n.distanceTo(fo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),fo.getSize(Xp),this.hasNonUniformScale&&Xp.divide(this.scale);let s={width:Xp.x,height:Xp.y,depth:Xp.z};return this.geometry.userData.parameters=s,s}updateBoundingSphere(e){let r=this.originalGeometry;fo.min.set(e[0],e[2],e[4]),fo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(fo.min.applyMatrix4(this.shearScaleInv),fo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new fr);let n=r.boundingSphere.center;fo.getCenter(n),r.boundingSphere.radius=n.distanceTo(fo.max)}freeSubdivPointer(){this.subdivPointer&&(Fr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&this.createGeometryByControls(r)}};var FI=-1,w9=1,kI={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},VI={polygon_center:0,edge:1,vertex:2},Qp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ct=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-FI)*(e-r)/(w9-FI)+r};function zI(i){let t=[],e={};for(var r=0,n=i.length;rMath.round(o*1e4)/1e4));e[s]||(t.push(i[r]),e[s]=!0)}return t}var S9=new _,t0=new _,A9=new _,_9=new _;function Pd(i,t){let e=A9.fromArray(i),r=_9.fromArray(t);t0.copy(r).sub(e);let n=t0.length();return t0.normalize().multiplyScalar(n*.5),S9.copy(e).add(t0).toArray()}var rs=new dr,r0=new _,n0=new _,Tc=new _;function UI(i){let t=[];for(let e=0;e<=i.index.count;e++)if(r0.fromArray(i.index.array,e*3),rs.setFromAttributeAndIndices(i.attributes.position,r0.x,r0.y,r0.z),rs.getNormal(n0),rs.getMidpoint(Tc),!(isNaN(Tc.x)||isNaN(Tc.y)||isNaN(Tc.z))){let{a:r,b:n,c:s}=rs,o=r.toArray(),a=n.toArray(),l=s.toArray(),u=r.distanceTo(n),c=n.distanceTo(s),h=s.distanceTo(r),d=Pd(o,a),f=Pd(a,l),p=Pd(l,o),m=[u,c,h],g=Math.max(...m),y=m.filter(w=>Math.round(w)===Math.round(g)).length>1,v=[],x=rs.getMidpoint(Tc).toArray();g===u&&!y&&(v=[f,p,p],x=d),g===c&&!y&&(v=[d,p,p],x=f),g===h&&!y&&(v=[d,f,f],x=p),y&&(v=[d,f,p]),t.push({vertices:[o,a,l],faceCenters:v,midpoint:x,norm:rs.getNormal(n0).toArray()})}return t}function GI(i){let t=[],{position:e}=i.attributes;for(let r=0;r.5*(1-Math.cos(i*Math.PI)),GA=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let y=0;y<4095+1;y++)this.perlin[y]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),s=Math.floor(e),o=Math.floor(r),a=t-n,l=e-s,u=r-o,c,h,d=0,f=.5,p,m,g;for(let y=0;y=1&&(n++,a--),l>=1&&(s++,l--),u>=1&&(o++,u--)}return d}noiseSeed(t){let e=(()=>{let o,a;return{setSeed(l){a=o=(l??Math.random()*4294967296)>>>0},getSeed(){return o},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},HI=GA;var jI=new _,WI=new ie,qI=new gs;function HA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="TextGeometry"&&(t=!0)}),t}var Dd=class extends Qt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(WI.copy(n).invert(),qI.copy(e.ray).applyMatrix4(WI),qI.intersectBox(this.singleBBox,jI))){let s=jI.applyMatrix4(n),o=e.ray.origin.distanceTo(s);r.push({distance:o,point:s.clone(),object:this})}}};var oi=1e-4,po,QI,KI,ZI,YI=new _,XI=new _;rd.then(i=>{po=i,QI=[po.get_face_center,po.get_edge_midpoint,po.get_vertex_position],KI=[po.get_face_normal,po.get_edge_normal,po.get_vertex_normal],ZI=[po.face_count,po.edge_count,po.vertex_count]});var T9=new ie,C9=new ie,gl=new _,Cc=new _,Kp=new _,jA=new _,P9=new _,D9=new _;var ua=new HI,Dn=class extends Gh(gt){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof mr&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof mr&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let r;if(e!==void 0?r=e:r=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(r=0),this.parameters.type==="toObject"&&this.objectForSample){for(let s=0,o=this.children.length;s{let v=y.length,x=y.map(A=>A[0]).reduce((A,E)=>A+E,0),w=y.map(A=>A[1]).reduce((A,E)=>A+E,0),S=y.map(A=>A[2]).reduce((A,E)=>A+E,0);return[x/v,w/v,S/v]},d=y=>Math.round(y*1e6)/1e6;u.forEach(y=>{let v=u.filter(x=>d(y.pos[0])===d(x.pos[0])&&d(y.pos[1])===d(x.pos[1])&&d(y.pos[2])===d(x.pos[2]));v.length>1?c.push({pos:y.pos,norm:h(v.map(x=>x.norm))}):c.push(y)});let f=zI(c);if(f.length>0){let y=Math.round(f.length*r.count/100);this._updateCount(y)}else{let y=this.objectForSample.geometry.getAttribute("position");if(!y||isNaN(y.count)||y.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let p=new mv(this.objectForSample).build(),m=kI[r.axis],g=this.children;p.setRandomGenerator((0,Id.default)(this.object.uuid+r.seed));for(let[y,v]of g.entries()){let x=y*(s.freqScale/10)+s.movement,w=o?ua.noise(x):a(x,x),S=y+1,A=l(S,ct(w,s.rotation[0])),E=l(S,ct(w,s.rotation[1])),b=l(S,ct(w,s.rotation[2]));r.spreadType==="random"?p.sample(Kp,jA):(f.length&&(Kp.fromArray(f[y].pos),jA.fromArray(f[y].norm)),this.objectForSample instanceof Ds&&Kp.applyMatrix4(T9.copy(this.objectForSample.matrixWorld).invert())),Kp.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Kp),gl.fromArray(m);let M=r.align==="normal"?jA:this.object.getWorldDirection(D9),T=Cc.fromArray(r.position);Cc.x+=Cc.x+l(S,ct(w,s.position[0])),Cc.y+=Cc.y+l(S,ct(w,s.position[1])),Cc.z+=Cc.z+l(S,ct(w,s.position[2]));let C=Math.acos(M.dot(gl)),P=P9.crossVectors(gl,M).normalize(),D=C9.makeRotationAxis(P,C),I=M.clone().cross(this.object.up).normalize(),R=I.clone().cross(M).normalize(),U=new ie().makeBasis(I,M,R),F=new _(gl.y,gl.z,gl.x).normalize(),V=F.clone().cross(gl).normalize(),G=new ie().makeBasis(F,gl,V).invert(),H=new ie().multiplyMatrices(U,G);v.rotation.setFromRotationMatrix(H),T.applyMatrix4(D),v.position.add(T),v.rotation.x=v.rotation.x+n.x+A,v.rotation.y=v.rotation.y+n.y+E,v.rotation.z=v.rotation.z+n.z+b,v.scale.setScalar(1),v.scale.x=v.scale.x+r.scale[0]+l(S,ct(w,s.scale[0]))||oi,v.scale.y=v.scale.y+r.scale[1]+l(S,ct(w,s.scale[1]))||oi,v.scale.z=v.scale.z+r.scale[2]+l(S,ct(w,s.scale[2]))||oi,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof Ds){let r=this.objectForSample,n=VI[e],s=ZI[n],o=QI[n],a=KI[n],l=[],u=s(r.subdivPointerNew);for(let c=0;c<=u-1;c++){let h=o(r.subdivPointerNew,c),d=a(r.subdivPointerNew,c);YI.fromArray(h).applyMatrix4(r.matrixWorld),XI.fromArray(d),l.push({pos:YI.toArray(),norm:XI.toArray()})}return l}else return(this.objectForSample.geometry.index?UI(this.objectForSample.geometry):GI(this.objectForSample.geometry)).map((n,s)=>e==="polygon_center"?{pos:n.midpoint,norm:n.norm}:e==="vertex"?[{pos:n.vertices[0],norm:n.norm},{pos:n.vertices[1],norm:n.norm},{pos:n.vertices[2],norm:n.norm}]:e==="edge"?[{pos:n.faceCenters[0],norm:n.norm},{pos:n.faceCenters[1],norm:n.norm},{pos:n.faceCenters[2],norm:n.norm}]:[]).flat()}updateState(e,r){if(this.parameters=Zo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let n=r.find(this.parameters.toObject.object);n instanceof $t?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new ie,this.hiddenMatrix=new ie,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=i=>{var t;return t=class extends i{},t.geometryHelper=new yn(30,30,30),t};var i0=new gs,WA=new fr,JI=new ie,go=(i,t,e,r,n=!1)=>{let s=t,o=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),WA.copy(s.boundingSphere),WA.applyMatrix4(o),e.ray.intersectsSphere(WA)===!1||(JI.copy(o).invert(),i0.copy(e.ray).applyMatrix4(JI),s.boundingBox!==null&&i0.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,p,m;if(n===!1){let y=Math.max(0,f.start),v=Math.min(h.count,f.start+f.count);for(p=y,m=v;pT)continue;A.applyMatrix4(i.matrixWorld);let U=e.ray.origin.distanceTo(A);Ue.far||r.push({distance:U,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function g(y,v,x,w,S,A,E){let b=new _,M=new _,T=new _,C=new _,P=new _;if(b.fromBufferAttribute(w,S),M.fromBufferAttribute(w,A),T.fromBufferAttribute(w,E),x.intersectTriangle(b,M,T,!1,C)===null)return null;P.copy(C),P.applyMatrix4(y.matrixWorld);let I=v.ray.origin.distanceTo(P);return Iv.far?null:{faceIndex:1,distance:I,point:P.clone(),object:y}}};var s0=new _,ns=new ys,qA=class extends Da{constructor(e){let r=new Ae,n=new Hi({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Re(15711266),u=new Re(15711266),c=new Re(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,p,m){d(f,m),d(p,m)}function d(f,p){s.push(0,0,0),o.push(p.r,p.g,p.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}r.setAttribute("position",new be(s,3)),r.setAttribute("color",new be(o,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;ns.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=n?.8:1e-4;Is("n1",r,e,ns,-s,-o,a),Is("n2",r,e,ns,s,-o,a),Is("n3",r,e,ns,-s,o,a),Is("n4",r,e,ns,s,o,a);let l=a;Is("f1",r,e,ns,-s,-o,l),Is("f2",r,e,ns,s,-o,l),Is("f3",r,e,ns,-s,o,l),Is("f4",r,e,ns,s,o,l);let u=l,c=.5;Is("u1",r,e,ns,s*.7*c,o*1.1,u),Is("u2",r,e,ns,-s*.7*c,o*1.1,u),Is("u3",r,e,ns,0,o*(1.1+.9*c),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Is(i,t,e,r,n,s,o){s0.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let u=0,c=a.length;ut.is=e=>"objectHelper"in e)(a0||(a0={}));var yo=(i,t)=>class extends jh(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,s){this.objectHelper.raycast(n,s)}showGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!0)}}updateEntityBoxSize(n,s){this.objectHelper.visible&&this.geometryHelper instanceof yn?(n.setScalar(0),s.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,s)}hideGizmos(){for(let n in this.gizmos){let s=this.gizmos[n];s instanceof Na&&(s.visible=!1)}}};var l0=790,Od=new _,YA=new _,XA=new He,QA=new _,Zp=new _,KA=new _,er=class extends yo(ys,o0){constructor(e="",r={...cc.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Qa.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new ie,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,s=this.height;this.orthoCamera=new lu(n*-.5,n*.5,s*.5,s*-.5,-5e4,1e4),this.perspCamera=new Ir(45,n/s,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new _(e,r,n)),super.lookAt(e),this.getWorldPosition(Od),this.targetOffset=Od.distanceTo(e)}getTarget(e=new _){return this.getWorldDirection(YA),this.getWorldPosition(Od),YA.multiplyScalar(this.targetOffset),e.copy(Od).add(YA),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Od),Od.distanceTo(e)}updateUp(){this.getWorldQuaternion(XA),QA.set(0,0,1).applyQuaternion(XA),Zp.copy(gt.DEFAULT_UP),this.isUpVectorFlipped&&Zp.negate(),Zp.applyQuaternion(XA),KA.copy(gt.DEFAULT_UP).projectOnPlane(QA),this.angleOffsetFromUp=KA.angleTo(Zp),this.angleOffsetFromUp*=KA.cross(Zp).dot(QA)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new _),s=e.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:r.clone().add(s),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new _).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new _,n=e.getWorldPosition(r);return this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let s=e>r?this.aspect:1,o=e>r?1:this.aspect;this.left=-l0*.5*s,this.right=l0*.5*s,this.top=l0*.5*(1/o),this.bottom=-l0*.5*(1/o)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,s,o,a):this.orthoCamera.setViewOffset(e,r,n,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ih(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var Rd=new ie,O9=new ie,c0=new ie,$I=new _,eO=new _;function ZA(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.geometry?.type==="BooleanGeometry"&&(t=!0)}),t}var is=class extends ts{constructor(e,r,n){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Ae;this.onAfterRender=(e,r,n,s,o,a)=>{super.onAfterRender(e,r,n,s,o,a),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s0&&o.geometry.drawRange.count>0&&o.booleanMeshSetAddress!==0){Rd.multiplyMatrices(o.hiddenMatrix,o.matrix);try{if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=Ji.getMeshSet(o.geometry,e===!0,r)),o.booleanMeshSetAddress===-1)return;Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1}else o instanceof is&&o.needsTransformForDownstream===!0?(Ji.transformMeshSet(o.booleanMeshSetAddress,Rd),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(Ji.transformMeshSet(o.booleanMeshSetAddress,O9.multiplyMatrices(Rd,o.booleanMatrixInvOld)),o.booleanMatrixInvOld.copy(Rd).invert(),o.booleanWasTransformed=!1)}catch(a){console.error(a),o.booleanMeshSetAddress=0,o.geometry.userData.booleanOperationDidFail=!0;continue}Ji.hasOpenEdges(o.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(o.booleanMeshSetAddress),o.geometry.userData.booleanOperationDidFail=!1):o.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new be([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Ji.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Ae,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Ji.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Td(this),Cd(this)}dispose(){super.dispose(),this.geometry.dispose()}get recursiveBBox(){let e=super.recursiveBBox;return this.geometry.boundingSphere?.radius===-1&&(e.getCenter(this.geometry.boundingSphere.center),c0.copy(this.matrixWorld).invert(),this.geometry.boundingSphere.center.applyMatrix4(c0),$I.copy(e.max).applyMatrix4(c0),eO.copy(e.min).applyMatrix4(c0),this.geometry.boundingSphere.radius=$I.distanceTo(eO)/2),e}};var u0;(t=>{function i(e){return lt.is(e)&&e instanceof Ra}t.is=i})(u0||(u0={}));var Ld=(i,t)=>class extends yo(i,t){updateState_Light(r,n){this.updateState_Entity(r,n),r.color!==void 0&&(this.color=n.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var Yn=i=>i instanceof $t,Xn=i=>i!==null&&i instanceof is,tO=i=>i instanceof er,rO=i=>u0.is(i),Jp=i=>a0.is(i);var vo=class extends mo(Lg){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){go(this.object,vo.geometryHelper,e,r)}update(){}};var ss=class extends yo(js,vo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var cO={RED:0,GREEN:1,BLUE:2,ALPHA:3};var $p="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var R9=`#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 +}}`,h0=class extends at{constructor(i=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:i?"2":"1"},uniforms:{kernel64:new oe(null),kernel16:new oe(null),inputBuffer:new oe(null),cocBuffer:new oe(null),texelSize:new oe(new N),scale:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:R9,vertexShader:$p}),this.toneMapped=!1,t&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}set cocBuffer(i){this.uniforms.cocBuffer.value=i}setCoCBuffer(i){this.uniforms.cocBuffer.value=i}get scale(){return this.uniforms.scale.value}set scale(i){this.uniforms.scale.value=i}getScale(i){return this.uniforms.scale.value=i}setScale(i){this.uniforms.scale.value=i}generateKernel(){let i=2.39996323,t=new Float32Array(128),e=new Float32Array(32),r=0,n=0;for(let a=0;a<80;++a){let l=a*i,u=Math.sqrt(a)/Math.sqrt(80),c=u*Math.cos(l),h=u*Math.sin(l);a%5===0?(e[n++]=c,e[n++]=h):(t[r++]=c,t[r++]=h)}let s=[],o=[];for(let a=0;a<128;)s.push(new Xe(t[a++],t[a++],t[a++],t[a++]));for(let a=0;a<32;)o.push(new Xe(e[a++],e[a++],e[a++],e[a++]));this.uniforms.kernel64.value=s,this.uniforms.kernel16.value=o}setTexelSize(i,t){this.uniforms.texelSize.value.set(i,t)}setSize(i,t){this.uniforms.texelSize.value.set(1/i,1/t)}};function nO(i,t,e){return i*(t-e)-t}function r1(i,t,e){return Math.min(Math.max((i+t)/(t-e),0),1)}var L9=`#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));}`,N9=class extends at{constructor(i){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new oe(null),focusDistance:new oe(0),focusRange:new oe(0),cameraNear:new oe(.3),cameraFar:new oe(1e3)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:L9,vertexShader:$p}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(i)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(i){this.uniforms.depthBuffer.value=i}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(i){this.uniforms.focusDistance.value=i}get worldFocusDistance(){return-nO(this.focusDistance,this.near,this.far)}set worldFocusDistance(i){this.focusDistance=r1(-i,this.near,this.far)}getFocusDistance(i){this.uniforms.focusDistance.value=i}setFocusDistance(i){this.uniforms.focusDistance.value=i}get focalLength(){return this.focusRange}set focalLength(i){this.focusRange=i}get focusRange(){return this.uniforms.focusRange.value}set focusRange(i){this.uniforms.focusRange.value=i}get worldFocusRange(){return-nO(this.focusRange,this.near,this.far)}set worldFocusRange(i){this.focusRange=r1(-i,this.near,this.far)}getFocalLength(i){return this.focusRange}setFocalLength(i){this.focusRange=i}adoptCameraSettings(i){i&&(this.uniforms.cameraNear.value=i.near,this.uniforms.cameraFar.value=i.far,i instanceof Ir?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},B9=`#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 +}`,F9="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);}",iO=class extends at{constructor(i=new N){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new oe(null),texelSize:new oe(new N),halfTexelSize:new oe(new N),kernel:new oe(0),scale:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:B9,vertexShader:F9}),this.toneMapped=!1,this.setTexelSize(i.x,i.y)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.inputBuffer=i}get scale(){return this.uniforms.scale.value}set scale(i){this.uniforms.scale.value=i}getScale(){return this.uniforms.scale.value}setScale(i){this.uniforms.scale.value=i}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(i){this.uniforms.kernel.value=i}setKernel(i){this.kernel=i}setTexelSize(i,t){this.uniforms.texelSize.value.set(i,t),this.uniforms.halfTexelSize.value.set(i,t).multiplyScalar(.5)}setSize(i,t){let e=this.uniforms;e.texelSize.value.set(1/i,1/t),e.halfTexelSize.value.copy(e.texelSize.value).multiplyScalar(.5)}},k9=`#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 +}`,V9=class extends at{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new oe(null),opacity:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:k9,vertexShader:$p}),this.toneMapped=!1}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}getOpacity(i){return this.uniforms.opacity.value}setOpacity(i){this.uniforms.opacity.value=i}};var z9=`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 +}`,U9=`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);}`,Nd={DEPTH:0,LUMA:1,COLOR:2},G9={DISABLED:0,DEPTH:1,CUSTOM:2},H9=class extends at{constructor(i=new N,t=Nd.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:qo.replace(/\D+/g,""),LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new oe(null),depthBuffer:new oe(null),predicationBuffer:new oe(null),texelSize:new oe(i)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:z9,vertexShader:U9}),this.toneMapped=!1,this.edgeDetectionMode=t}set depthBuffer(i){this.uniforms.depthBuffer.value=i}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(i){this.defines.EDGE_DETECTION_MODE=i.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(i){this.edgeDetectionMode=i}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(i){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=i.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(i){this.localContrastAdaptationFactor=i}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(i){this.defines.EDGE_THRESHOLD=i.toFixed("6"),this.defines.DEPTH_THRESHOLD=(i*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(i){this.edgeDetectionThreshold=i}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(i){this.defines.PREDICATION_MODE=i.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(i){this.predicationMode=i}set predicationBuffer(i){this.uniforms.predicationBuffer.value=i}setPredicationBuffer(i){this.uniforms.predicationBuffer.value=i}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(i){this.defines.PREDICATION_THRESHOLD=i.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(i){this.predicationThreshold=i}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(i){this.defines.PREDICATION_SCALE=i.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(i){this.predicationScale=i}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(i){this.defines.PREDICATION_STRENGTH=i.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(i){this.predicationStrength=i}setSize(i,t){this.uniforms.texelSize.value.set(1/i,1/t)}},j9=`#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 +}`,W9="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);}",Os={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"},n1=class extends at{constructor(i,t,e,r,n=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:qo.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new oe(null),depthBuffer:new oe(null),resolution:new oe(new N),texelSize:new oe(new N),cameraNear:new oe(.3),cameraFar:new oe(1e3),aspect:new oe(1),time:new oe(0)},blending:Vt,depthWrite:!1,depthTest:!1,dithering:n}),this.toneMapped=!1,i&&this.setShaderParts(i),t&&this.setDefines(t),e&&this.setUniforms(e),this.adoptCameraSettings(r)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(i){this.uniforms.depthBuffer.value=i}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(i){this.defines.DEPTH_PACKING=i.toFixed(0),this.needsUpdate=!0}setDepthBuffer(i,t=vn){this.depthBuffer=i,this.depthPacking=t}setShaderParts(i){return this.fragmentShader=j9.replace(Os.FRAGMENT_HEAD,i.get(Os.FRAGMENT_HEAD)).replace(Os.FRAGMENT_MAIN_UV,i.get(Os.FRAGMENT_MAIN_UV)).replace(Os.FRAGMENT_MAIN_IMAGE,i.get(Os.FRAGMENT_MAIN_IMAGE)),this.vertexShader=W9.replace(Os.VERTEX_HEAD,i.get(Os.VERTEX_HEAD)).replace(Os.VERTEX_MAIN_SUPPORT,i.get(Os.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(i){for(let t of i.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(i){for(let t of i.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(i){this.extensions={};for(let t of i)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(i){this.encodeOutput!==i&&(i?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(i){return this.encodeOutput}setOutputEncodingEnabled(i){this.encodeOutput=i}get time(){return this.uniforms.time.value}set time(i){this.uniforms.time.value=i}setDeltaTime(i){this.uniforms.time.value+=i}adoptCameraSettings(i){i&&(this.uniforms.cameraNear.value=i.near,this.uniforms.cameraFar.value=i.far,i instanceof Ir?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(i,t){let e=this.uniforms;e.resolution.value.set(i,t),e.texelSize.value.set(1/i,1/t),e.aspect.value=i/t}static get Section(){return Os}};var q9=`#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 +}`,Y9=class extends at{constructor(i=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:qo.replace(/\D+/g,"")},uniforms:{inputBuffer:new oe(null),threshold:new oe(0),smoothing:new oe(1),range:new oe(null)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:q9,vertexShader:$p}),this.toneMapped=!1,this.colorOutput=i,this.luminanceRange=t}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get threshold(){return this.uniforms.threshold.value}set threshold(i){this.smoothing>0||i>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=i}getThreshold(){return this.threshold}setThreshold(i){this.threshold=i}get smoothing(){return this.uniforms.smoothing.value}set smoothing(i){this.threshold>0||i>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=i}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(i){this.smoothing=i}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(i){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(i){i?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(i){return this.colorOutput}setColorOutputEnabled(i){this.colorOutput=i}get useRange(){return this.luminanceRange!==null}set useRange(i){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(i){i!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=i,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(i){this.luminanceRange=i}},X9=`#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 +}`,uO={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},Q9=class extends at{constructor(i=null){super({name:"MaskMaterial",uniforms:{maskTexture:new oe(i),inputBuffer:new oe(null),strength:new oe(1)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:X9,vertexShader:$p}),this.toneMapped=!1,this.setColorChannel(cO.RED),this.setMaskFunction(uO.DISCARD)}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}set maskTexture(i){this.uniforms.maskTexture.value=i,delete this.defines.MASK_PRECISION_HIGH,i.type!==lr&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(i){this.maskTexture=i}set colorChannel(i){this.defines.COLOR_CHANNEL=i.toFixed(0),this.needsUpdate=!0}setColorChannel(i){this.colorChannel=i}set maskFunction(i){this.defines.MASK_FUNCTION=i.toFixed(0),this.needsUpdate=!0}setMaskFunction(i){this.maskFunction=i}get inverted(){return this.defines.INVERTED!==void 0}set inverted(i){this.inverted&&!i?delete this.defines.INVERTED:i&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(i){this.inverted=i}get strength(){return this.uniforms.strength.value}set strength(i){this.uniforms.strength.value=i}getStrength(){return this.strength}setStrength(i){this.strength=i}};var K9=`#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;}`,Z9="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);}",J9=class extends at{constructor(i=new N,t=new N){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new oe(null),searchTexture:new oe(null),areaTexture:new oe(null),resolution:new oe(t),texelSize:new oe(i)},blending:Vt,depthWrite:!1,depthTest:!1,fragmentShader:K9,vertexShader:Z9}),this.toneMapped=!1}set inputBuffer(i){this.uniforms.inputBuffer.value=i}setInputBuffer(i){this.uniforms.inputBuffer.value=i}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(i){this.uniforms.searchTexture.value=i}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(i){this.uniforms.areaTexture.value=i}setLookupTextures(i,t){this.searchTexture=i,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(i){let t=Math.min(Math.max(i,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(i){this.orthogonalSearchSteps=i}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(i){let t=Math.min(Math.max(i,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(i){this.diagonalSearchSteps=i}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(i){i?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(i){this.diagonalDetection=i}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(i){let t=Math.min(Math.max(i,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(i){this.cornerRounding=i}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(i){i?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(i){this.cornerDetection=i}setSize(i,t){let e=this.uniforms;e.texelSize.value.set(1/i,1/t),e.resolution.value.set(i,t)}};var $9=new ys,yl=null;function eY(){if(yl===null){let i=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);yl=new Ae,yl.setAttribute!==void 0?(yl.setAttribute("position",new Ge(i,3)),yl.setAttribute("uv",new Ge(t,2))):(yl.addAttribute("position",new Ge(i,3)),yl.addAttribute("uv",new Ge(t,2)))}return yl}var Zr=class{constructor(i="Pass",t=new Nn,e=$9){this.name=i,this.renderer=null,this.scene=t,this.camera=e,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(i){if(this.rtt===i){let t=this.getFullscreenMaterial();t!==null&&(t.needsUpdate=!0),this.rtt=!i}}setRenderer(i){this.renderer=i}isEnabled(){return this.enabled}setEnabled(i){this.enabled=i}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(i){let t=this.screen;t!==null?t.material=i:(t=new _r(eY(),i),t.frustumCulled=!1,this.scene===null&&(this.scene=new Nn),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(i){this.fullscreenMaterial=i}getDepthTexture(){return null}setDepthTexture(i,t=vn){}render(i,t,e,r,n){throw new Error("Render method not implemented!")}setSize(i,t){}initialize(i,t,e){}dispose(){for(let i of Object.keys(this)){let t=this[i];if(t!==null&&typeof t.dispose=="function"){if(t instanceof Nn||t===this.renderer)continue;this[i].dispose()}}}},em=class extends Zr{constructor(i,t=!0){super("CopyPass"),this.fullscreenMaterial=new V9,this.needsSwap=!1,this.renderTarget=i,i===void 0&&(this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=t}get resize(){return this.autoResize}set resize(i){this.autoResize=i}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(i){this.autoResize=i}render(i,t,e,r,n){this.fullscreenMaterial.inputBuffer=t.texture,i.setRenderTarget(this.renderToScreen?null:this.renderTarget),i.render(this.scene,this.camera)}setSize(i,t){this.autoResize&&this.renderTarget.setSize(i,t)}initialize(i,t,e){e!==void 0&&(this.renderTarget.texture.type=e,e!==lr?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":i.outputEncoding===et&&(this.renderTarget.texture.encoding=et))}};var hO=class extends Zr{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(i,t,e,r,n){let s=i.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},JA=new Re,i1=class extends Zr{constructor(i=!0,t=!0,e=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=i,this.depth=t,this.stencil=e,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(i,t,e){this.color=i,this.depth=t,this.stencil=e}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(i){this.overrideClearColor=i}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(i){this.overrideClearAlpha=i}render(i,t,e,r,n){let s=this.overrideClearColor,o=this.overrideClearAlpha,a=i.getClearAlpha(),l=s!==null,u=o>=0;l?(JA.copy(i.getClearColor(JA)),i.setClearColor(s,u?o:a)):u&&i.setClearAlpha(o),i.setRenderTarget(this.renderToScreen?null:t),i.clear(this.color,this.depth,this.stencil),l?i.setClearColor(JA,a):u&&i.setClearAlpha(a)}},vl=-1,wi=class extends Yt{constructor(i,t=vl,e=vl,r=1){super(),this.resizable=i,this.base=new N(1,1),this.preferred=new N(t,e),this.target=this.preferred,this.s=r}get width(){let{base:i,preferred:t,scale:e}=this,r;return t.width!==vl?r=t.width:t.height!==vl?r=Math.round(t.height*(i.width/Math.max(i.height,1))):r=Math.round(i.width*e),r}set width(i){this.preferredWidth=i}get height(){let{base:i,preferred:t,scale:e}=this,r;return t.height!==vl?r=t.height:t.width!==vl?r=Math.round(t.width/Math.max(i.width/Math.max(i.height,1),1)):r=Math.round(i.height*e),r}set height(i){this.preferredHeight=i}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(i){this.s!==i&&(this.s=i,this.preferred.setScalar(vl),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(i){this.scale=i}get baseWidth(){return this.base.width}set baseWidth(i){this.base.width!==i&&(this.base.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(i){this.base.width!==i&&(this.base.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(i){this.base.height!==i&&(this.base.height=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(i){this.baseHeight=i}setBaseSize(i,t){(this.base.width!==i||this.base.height!==t)&&(this.base.set(i,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(i){this.preferred.width!==i&&(this.preferred.width=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(i){this.preferredWidth=i}get preferredHeight(){return this.preferred.height}set preferredHeight(i){this.preferred.height!==i&&(this.preferred.height=i,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(i){this.preferredHeight=i}setPreferredSize(i,t){(this.preferred.width!==i||this.preferred.height!==t)&&(this.preferred.set(i,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(i){this.base.set(i.getBaseWidth(),i.getBaseHeight()),this.preferred.set(i.getPreferredWidth(),i.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return vl}},$A=!1,sO=class{constructor(i=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(i),this.meshCount=0,this.replaceMaterial=t=>{if(t.isMesh){let e;if(t.material.flatShading)switch(t.material.side){case Ln:e=this.materialsFlatShadedDoubleSide;break;case Qr:e=this.materialsFlatShadedBackSide;break;default:e=this.materialsFlatShaded;break}else switch(t.material.side){case Ln:e=this.materialsDoubleSide;break;case Qr:e=this.materialsBackSide;break;default:e=this.materials;break}this.originalMaterials.set(t,t.material),t.isSkinnedMesh?t.material=e[2]:t.isInstancedMesh?t.material=e[1]:t.material=e[0],++this.meshCount}}}setMaterial(i){if(this.disposeMaterials(),this.material=i,i!==null){let t=this.materials=[i.clone(),i.clone(),i.clone()];for(let e of t)e.uniforms=Object.assign({},i.uniforms),e.side=Pi;t[2].skinning=!0,this.materialsBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.side=Qr,r}),this.materialsDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.side=Ln,r}),this.materialsFlatShaded=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r}),this.materialsFlatShadedBackSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r.side=Qr,r}),this.materialsFlatShadedDoubleSide=t.map(e=>{let r=e.clone();return r.uniforms=Object.assign({},i.uniforms),r.flatShading=!0,r.side=Ln,r})}}render(i,t,e){let r=i.shadowMap.enabled;if(i.shadowMap.enabled=!1,$A){let n=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),i.render(t,e);for(let s of n)s[0].material=s[1];this.meshCount!==n.size&&n.clear()}else{let n=t.overrideMaterial;t.overrideMaterial=this.material,i.render(t,e),t.overrideMaterial=n}i.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let i=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of i)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return $A}static set workaroundEnabled(i){$A=i}},tY=class extends Zr{constructor(i,t,e=null){super("RenderPass",i,t),this.needsSwap=!1,this.clearPass=new i1,this.overrideMaterialManager=e===null?null:new sO(e),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(i){super.renderToScreen=i,this.clearPass.renderToScreen=i}get overrideMaterial(){let i=this.overrideMaterialManager;return i!==null?i.material:null}set overrideMaterial(i){let t=this.overrideMaterialManager;i!==null?t!==null?t.setMaterial(i):this.overrideMaterialManager=new sO(i):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(i){this.overrideMaterial=i}get clear(){return this.clearPass.enabled}set clear(i){this.clearPass.enabled=i}getSelection(){return this.selection}setSelection(i){this.selection=i}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(i){this.ignoreBackground=i}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(i){this.skipShadowMapUpdate=i}getClearPass(){return this.clearPass}render(i,t,e,r,n){let s=this.scene,o=this.camera,a=this.selection,l=o.layers.mask,u=s.background,c=i.shadowMap.autoUpdate,h=this.renderToScreen?null:t;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(i.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(i,t),i.setRenderTarget(h),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(i,s,o):i.render(s,o),o.layers.mask=l,s.background=u,i.shadowMap.autoUpdate=c}},s1=class extends Zr{constructor(i,t,{resolutionScale:e=1,width:r=wi.AUTO_SIZE,height:n=wi.AUTO_SIZE,renderTarget:s}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new tY(i,t,new Bf({depthPacking:Jb}));let o=this.renderPass;o.skipShadowMapUpdate=!0,o.ignoreBackground=!0;let a=o.getClearPass();a.overrideClearColor=new Re(16777215),a.overrideClearAlpha=1,this.renderTarget=s,this.renderTarget===void 0&&(this.renderTarget=new ht(1,1,{minFilter:kt,magFilter:kt,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new wi(this,r,n,e);l.addEventListener("change",u=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}render(i,t,e,r,n){let s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(i,s)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height)}};var _Te=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var pt={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},rY="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);}",nY="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));}",iY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",sY="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);}",oY="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);}",aY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",lY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",cY="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);}",uY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",hY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",dY="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);}",fY="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);}",pY="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",mY="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);}",gY="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);}",yY="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);}",vY="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);}",xY="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);}",bY=new Map([[pt.SKIP,null],[pt.ADD,rY],[pt.ALPHA,nY],[pt.AVERAGE,iY],[pt.COLOR_BURN,sY],[pt.COLOR_DODGE,oY],[pt.DARKEN,aY],[pt.DIFFERENCE,lY],[pt.EXCLUSION,cY],[pt.LIGHTEN,uY],[pt.MULTIPLY,hY],[pt.DIVIDE,dY],[pt.NEGATION,fY],[pt.NORMAL,pY],[pt.OVERLAY,mY],[pt.REFLECT,gY],[pt.SCREEN,yY],[pt.SOFT_LIGHT,vY],[pt.SUBTRACT,xY]]),wY=class extends Yt{constructor(i,t=1){super(),this.f=i,this.opacity=new oe(t)}getOpacity(){return this.opacity.value}setOpacity(i){this.opacity.value=i}get blendFunction(){return this.f}set blendFunction(i){this.f=i,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(i){this.blendFunction=i}getShaderCode(){return bY.get(this.blendFunction)}},xo={NONE:0,DEPTH:1,CONVOLUTION:2};var bo=class extends Yt{constructor(i,t,{attributes:e=xo.NONE,blendFunction:r=pt.SCREEN,defines:n=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=i,this.renderer=null,this.attributes=e,this.fragmentShader=t,this.vertexShader=a,this.defines=n,this.uniforms=s,this.extensions=o,this.blendMode=new wY(r),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(i){this.renderer=i}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(i){this.attributes=i,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(i){this.fragmentShader=i,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(i){this.vertexShader=i,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(i,t=vn){}update(i,t,e){}setSize(i,t){}initialize(i,t,e){}dispose(){for(let i of Object.keys(this)){let t=this[i];if(t!==null&&typeof t.dispose=="function"){if(t instanceof Nn||t===this.renderer)continue;this[i].dispose()}}}};function oO(i,t,e){for(let r of t){let n="$1"+i+r.charAt(0).toUpperCase()+r.slice(1),s=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let o of e.entries())o[1]!==null&&e.set(o[0],o[1].replace(s,n))}}function SY(i,t,e,r,n,s,o){let a=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=a.get("fragment")!==void 0&&/mainImage/.test(a.get("fragment")),u=a.get("fragment")!==void 0&&/mainUv/.test(a.get("fragment")),c=[],h=[],d=!1,f=!1;if(a.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(u&&(o&xo.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(!l&&!u)console.error("The fragment shader contains neither a mainImage nor a mainUv function",t);else{let p=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,m=n1.Section;if(u){let y=` ${i}MainUv(UV); +`;e.set(m.FRAGMENT_MAIN_UV,e.get(m.FRAGMENT_MAIN_UV)+y),d=!0}if(a.get("vertex")!==null&&/mainSupport/.test(a.get("vertex"))){let y=` ${i}MainSupport(`;y+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a.get("vertex"))?`vUv); +`:`); +`,e.set(m.VERTEX_MAIN_SUPPORT,e.get(m.VERTEX_MAIN_SUPPORT)+y),c=c.concat([...a.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(v=>v[1])),h=h.concat(c).concat([...a.get("vertex").matchAll(p)].map(v=>v[1]))}h=h.concat([...a.get("fragment").matchAll(p)].map(y=>y[1])),h=h.concat([...t.defines.keys()].map(y=>y.replace(/\([\w\s,]*\)/g,""))),h=h.concat([...t.uniforms.keys()]),t.uniforms.forEach((y,v)=>s.set(i+v.charAt(0).toUpperCase()+v.slice(1),y)),t.defines.forEach((y,v)=>n.set(i+v.charAt(0).toUpperCase()+v.slice(1),y)),oO(i,h,n),oO(i,h,a);let g=t.blendMode;if(r.set(g.blendFunction,g),l){let y=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,v=`${i}MainImage(color0, UV, `;(o&xo.DEPTH)!==0&&y.test(a.get("fragment"))&&(v+="depth, ",f=!0),v+=`color1); + `;let x=i+"BlendOpacity";s.set(x,g.opacity),v+=`color0 = blend${g.blendFunction}(color0, color1, ${x}); + + `,e.set(m.FRAGMENT_MAIN_IMAGE,e.get(m.FRAGMENT_MAIN_IMAGE)+v),v=`uniform float ${x}; + +`,e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+v)}e.set(m.FRAGMENT_HEAD,e.get(m.FRAGMENT_HEAD)+a.get("fragment")+` +`),a.get("vertex")!==null&&e.set(m.VERTEX_HEAD,e.get(m.VERTEX_HEAD)+a.get("vertex")+` +`)}return{varyings:c,transformedUv:d,readDepth:f}}var Pc=class extends Zr{constructor(i,...t){super("EffectPass"),this.fullscreenMaterial=new n1(null,null,null,i),this.effects=t.sort((e,r)=>r.attributes-e.attributes),this.skipRendering=!1,this.uniformCount=0,this.varyingCount=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(i){this.fullscreenMaterial.encodeOutput=i}get dithering(){return this.fullscreenMaterial.dithering}set dithering(i){let t=this.fullscreenMaterial;t.dithering=i,t.needsUpdate=!0}verifyResources(){let i=this.renderer.capabilities,t=Math.min(i.maxFragmentUniforms,i.maxVertexUniforms);this.uniformCount>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniformCount+" were defined"),t=i.maxVaryings,this.varyingCount>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let i=n1.Section,t=new Map([[i.FRAGMENT_HEAD,""],[i.FRAGMENT_MAIN_UV,""],[i.FRAGMENT_MAIN_IMAGE,""],[i.VERTEX_HEAD,""],[i.VERTEX_MAIN_SUPPORT,""]]),e=new Map,r=new Map,n=new Map,s=new Set,o=0,a=0,l=0,u=!1,c=!1;for(let d of this.effects)if(d.blendMode.blendFunction===pt.SKIP)l|=d.getAttributes()&xo.DEPTH;else if((l&d.getAttributes()&xo.CONVOLUTION)!==0)console.error("Convolution effects cannot be merged",d);else{l|=d.getAttributes();let f="e"+o++,p=SY(f,d,t,e,r,n,l);if(a+=p.varyings.length,u=u||p.transformedUv,c=c||p.readDepth,d.extensions!==null)for(let m of d.extensions)s.add(m)}let h=/\bblend\b/g;for(let d of e.values()){let f=d.getShaderCode().replace(h,`blend${d.blendFunction}`);t.set(i.FRAGMENT_HEAD,t.get(i.FRAGMENT_HEAD)+f+` +`)}if((l&xo.DEPTH)!==0){if(c){let d=`float depth = readDepth(UV); + + `;t.set(i.FRAGMENT_MAIN_IMAGE,d+t.get(i.FRAGMENT_MAIN_IMAGE))}this.needsDepthTexture=this.getDepthTexture()===null}else this.needsDepthTexture=!1;if(u){let d=`vec2 transformedUv = vUv; +`;t.set(i.FRAGMENT_MAIN_UV,d+t.get(i.FRAGMENT_MAIN_UV)),r.set("UV","transformedUv")}else r.set("UV","vUv");t.forEach((d,f,p)=>p.set(f,d.trim().replace(/^#/,` +#`))),this.uniformCount=n.size,this.varyingCount=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(t).setExtensions(s).setUniforms(n).setDefines(r)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(i,t=vn){this.fullscreenMaterial.depthBuffer=i,this.fullscreenMaterial.depthPacking=t;for(let e of this.effects)e.setDepthTexture(i,t)}render(i,t,e,r,n){for(let s of this.effects)s.update(i,t,r);if(!this.skipRendering||this.renderToScreen){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,s.time+=r,i.setRenderTarget(this.renderToScreen?null:e),i.render(this.scene,this.camera)}}setSize(i,t){this.fullscreenMaterial.setSize(i,t);for(let e of this.effects)e.setSize(i,t)}initialize(i,t,e){this.renderer=i;for(let r of this.effects)r.initialize(i,t,e),r.addEventListener("change",n=>this.handleEvent(n));this.updateMaterial(),this.verifyResources(),e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let i of this.effects)i.dispose()}handleEvent(i){switch(i.type){case"change":this.recompile();break}}},AY=[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])],dO=class extends Zr{constructor({resolutionScale:i=.5,width:t=wi.AUTO_SIZE,height:e=wi.AUTO_SIZE,kernelSize:r=o1.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let n=this.resolution=new wi(this,t,e,i);n.addEventListener("change",s=>this.setSize(n.baseWidth,n.baseHeight)),this.blurMaterial=new iO,this.ditheredBlurMaterial=new iO,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=r}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(i){this.resolution.preferredWidth=i}get height(){return this.resolution.height}set height(i){this.resolution.preferredHeight=i}get scale(){return this.blurMaterial.scale}set scale(i){this.blurMaterial.scale=i}getScale(){return this.blurMaterial.scale}setScale(i){this.blurMaterial.scale=i}getKernelSize(){return this.kernelSize}setKernelSize(i){this.kernelSize=i}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}render(i,t,e,r,n){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,u=AY[this.kernelSize],c=this.blurMaterial,h=t,d,f;for(this.fullscreenMaterial=c,d=0,f=u.length-1;dthis.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(i,t,e,r,n){let s=this.fullscreenMaterial;s.inputBuffer=t.texture,i.setRenderTarget(this.renderToScreen?null:this.renderTarget),i.render(this.scene,this.camera)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height)}initialize(i,t,e){e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},fO=class extends Zr{constructor(i,t){super("MaskPass",i,t),this.needsSwap=!1,this.clearPass=new i1(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(i){this.inverse=i}get clear(){return this.clearPass.enabled}set clear(i){this.clearPass.enabled=i}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(i){this.inverted=i}render(i,t,e,r,n){let s=i.getContext(),o=i.state.buffers,a=this.scene,l=this.camera,u=this.clearPass,c=this.inverted?0:1,h=1-c;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,c,4294967295),o.stencil.setClear(h),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?u.render(i,null):(u.render(i,t),u.render(i,e))),this.renderToScreen?(i.setRenderTarget(null),i.render(a,l)):(i.setRenderTarget(t),i.render(a,l),i.setRenderTarget(e),i.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}};var os=class extends Zr{constructor(i,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=i,this.inputBufferUniform=null,this.setInput(t)}setInput(i){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let t=this.fullscreenMaterial.uniforms;t!==void 0&&t[i]!==void 0&&(this.inputBufferUniform=t[i])}}render(i,t,e,r,n){this.inputBufferUniform!==null&&t!==null&&(this.inputBufferUniform.value=t.texture),i.setRenderTarget(this.renderToScreen?null:e),i.render(this.scene,this.camera)}initialize(i,t,e){e!==void 0&&e!==lr&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},e1=1/1e3,EY=1e3,pO=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(i){return this.fixedDeltaEnabled=i,this}isAutoResetEnabled(i){return this.autoReset}setAutoResetEnabled(i){return typeof document<"u"&&document.hidden!==void 0&&(i?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=i),this}getDelta(){return this.delta*e1}getFixedDelta(){return this.fixedDelta*e1}setFixedDelta(i){return this.fixedDelta=i*EY,this}getElapsed(){return this.elapsed*e1}getTimescale(){return this.timescale}setTimescale(i){return this.timescale=i,this}update(i){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=i!==void 0?i:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(i){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}};var o1={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var MY=`#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);}`,mO=class extends bo{constructor({blendFunction:i=pt.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:e=.025,resolutionScale:r=.5,intensity:n=1,width:s=wi.AUTO_SIZE,height:o=wi.AUTO_SIZE,kernelSize:a=o1.LARGE}={}){super("BloomEffect",MY,{blendFunction:i,uniforms:new Map([["map",new oe(null)],["intensity",new oe(n)]])}),this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.luminancePass=new _Y({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=e,this.blurPass=new dO({resolutionScale:r,width:s,height:o,kernelSize:a});let l=this.blurPass.getResolution();l.addEventListener("change",u=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(i){this.resolution.preferredWidth=i}get height(){return this.resolution.height}set height(i){this.resolution.preferredHeight=i}get dithering(){return this.blurPass.dithering}set dithering(i){this.blurPass.dithering=i}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(i){this.blurPass.kernelSize=i}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(i){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(i){this.uniforms.get("intensity").value=i}getIntensity(){return this.intensity}setIntensity(i){this.intensity=i}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}update(i,t,e){let r=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(i,t,r),this.blurPass.render(i,r,r)):this.blurPass.render(i,t,r)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t),this.renderTarget.setSize(e.width,e.height),this.luminancePass.resolution.copy(e)}initialize(i,t,e){this.blurPass.initialize(i,t,e),e!==void 0&&(this.renderTarget.texture.type=e,i.outputEncoding===et&&(this.renderTarget.texture.encoding=et))}};var TY="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);}",gO=class extends bo{constructor({blendFunction:i=pt.NORMAL,brightness:t=0,contrast:e=0}={}){super("BrightnessContrastEffect",TY,{blendFunction:i,uniforms:new Map([["brightness",new oe(t)],["contrast",new oe(e)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(i){this.uniforms.get("brightness").value=i}getBrightness(i){return this.brightness}setBrightness(i){this.brightness=i}get contrast(){return this.uniforms.get("contrast").value}set contrast(i){this.uniforms.get("contrast").value=i}getContrast(i){return this.contrast}setContrast(i){this.contrast=i}},CY="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",yO=class extends bo{constructor(i=pt.NORMAL){super("ColorAverageEffect",CY,{blendFunction:i})}};var PY="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));}",DY="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;}",vO=class extends bo{constructor({blendFunction:i=pt.NORMAL,offset:t=new N(.001,5e-4)}={}){super("ChromaticAberrationEffect",PY,{vertexShader:DY,blendFunction:i,attributes:xo.CONVOLUTION,uniforms:new Map([["offset",new oe(t)]])})}get offset(){return this.uniforms.get("offset").value}set offset(i){this.uniforms.get("offset").value=i}getOffset(){return this.offset}setOffset(i){this.offset=i}};var IY=`#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;}`,xO=class extends bo{constructor(i,{blendFunction:t=pt.NORMAL,worldFocusDistance:e,worldFocusRange:r,focusDistance:n=0,focalLength:s=.1,focusRange:o=s,bokehScale:a=1,width:l=wi.AUTO_SIZE,height:u=wi.AUTO_SIZE}={}){super("DepthOfFieldEffect",IY,{blendFunction:t,attributes:xo.DEPTH,uniforms:new Map([["nearColorBuffer",new oe(null)],["farColorBuffer",new oe(null)],["nearCoCBuffer",new oe(null)],["scale",new oe(1)]])}),this.camera=i,this.renderTarget=new ht(1,1,{minFilter:Je,magFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new os(new N9(i));let c=this.cocMaterial;c.focusDistance=n,c.focusRange=o,e!==void 0&&(c.worldFocusDistance=e),r!==void 0&&(c.worldFocusRange=r),this.blurPass=new dO({kernelSize:o1.MEDIUM,width:l,height:u});let h=this.blurPass.getResolution();h.addEventListener("change",f=>this.setSize(h.getBaseWidth(),h.getBaseHeight())),this.maskPass=new os(new Q9(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=uO.MULTIPLY,d.colorChannel=cO.GREEN,this.bokehNearBasePass=new os(new h0(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new os(new h0(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new os(new h0(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new os(new h0(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=a}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(i){let t=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let e of t)e.fullscreenMaterial.setScale(i);this.maskPass.fullscreenMaterial.setStrength(i),this.uniforms.get("scale").value=i}getBokehScale(){return this.bokehScale}setBokehScale(i){this.bokehScale=i}getTarget(){return this.target}setTarget(i){this.target=i}calculateFocusDistance(i){let t=this.camera,e=t.position.distanceTo(i);return r1(-e,t.near,t.far)}setDepthTexture(i,t=vn){this.circleOfConfusionMaterial.depthBuffer=i,this.circleOfConfusionMaterial.depthPacking=t}update(i,t,e){let r=this.renderTarget,n=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let a=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=a}this.cocPass.render(i,null,n),this.blurPass.render(i,n,s),this.maskPass.render(i,t,o),this.bokehFarBasePass.render(i,o,r),this.bokehFarFillPass.render(i,r,this.renderTargetFar),this.bokehNearBasePass.render(i,t,r),this.bokehNearFillPass.render(i,r,this.renderTargetNear)}setSize(i,t){let e=this.resolution;e.setBaseSize(i,t);let r=e.width,n=e.height,s=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];s.push(this.renderTargetCoC,this.renderTargetMasked),s.forEach(a=>a.setSize(i,t)),s=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],s.forEach(a=>a.setSize(r,n)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.fullscreenMaterial.setSize(r,n))}initialize(i,t,e){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(n=>n.initialize(i,t,e)),this.blurPass.initialize(i,t,lr),e!==void 0&&(this.renderTarget.texture.type=e,this.renderTargetNear.texture.type=e,this.renderTargetFar.texture.type=e,this.renderTargetMasked.texture.type=e,i.outputEncoding===et&&(this.renderTarget.texture.encoding=et,this.renderTargetNear.texture.encoding=et,this.renderTargetFar.texture.encoding=et,this.renderTargetMasked.texture.encoding=et))}};var BTe=new _,FTe=new ie;var OY="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);}",bO=class extends bo{constructor({blendFunction:i=pt.NORMAL,hue:t=0,saturation:e=0}={}){super("HueSaturationEffect",OY,{blendFunction:i,uniforms:new Map([["hue",new oe(new _)],["saturation",new oe(e)]])}),this.hue=t}get saturation(){return this.uniforms.get("saturation").value}set saturation(i){this.uniforms.get("saturation").value=i}getSaturation(){return this.saturation}setSaturation(i){this.saturation=i}get hue(){let i=this.uniforms.get("hue").value;return Math.acos((i.x*3-1)/2)}set hue(i){let t=Math.sin(i),e=Math.cos(i);this.uniforms.get("hue").value.set((2*e+1)/3,(-Math.sqrt(3)*t-e+1)/3,(Math.sqrt(3)*t-e+1)/3)}getHue(){return this.hue}setHue(i){this.hue=i}};var zTe=new Re;var RY=`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 +}`,wO=class extends bo{constructor({blendFunction:i=pt.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",RY,{blendFunction:i}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(i){this.premultiply!==i&&(i?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(i){this.premultiply=i}};var LY="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));}}",SO=class extends bo{constructor(i=30){super("PixelationEffect",LY,{uniforms:new Map([["active",new oe(!1)],["d",new oe(new N)]])}),this.resolution=new N,this.d=0,this.granularity=i}get granularity(){return this.d}set granularity(i){let t=Math.floor(i);t%2>0&&(t+=1),this.d=t,this.uniforms.get("active").value=t>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(i){this.granularity=i}setSize(i,t){this.resolution.set(i,t),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};var HTe=Math.PI*.5,jTe=new _,WTe=new _;var aO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",lO="data:image/png;base64,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",NY="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;}",BY="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);}",ha={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},f0=class extends bo{constructor({preset:i=ha.MEDIUM,edgeDetectionMode:t=Nd.COLOR,predicationMode:e=G9.DISABLED}={}){super("SMAAEffect",NY,{vertexShader:BY,blendFunction:pt.NORMAL,attributes:xo.CONVOLUTION|xo.DEPTH,uniforms:new Map([["weightMap",new oe(null)]])});let r,n;arguments.length>1&&(r=arguments[0],n=arguments[1],arguments.length>2&&(i=arguments[2]),arguments.length>3&&(t=arguments[3])),this.renderTargetEdges=new ht(1,1,{minFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new i1(!0,!1,!1),this.clearPass.overrideClearColor=new Re(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new os(new H9),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=e,this.weightsPass=new os(new J9);let s=new Hf;s.onLoad=()=>{let o=new or(r);o.name="SMAA.Search",o.magFilter=kt,o.minFilter=kt,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!0,this.weightsMaterial.searchTexture=o;let a=new or(n);a.name="SMAA.Area",a.magFilter=Je,a.minFilter=Je,a.generateMipmaps=!1,a.needsUpdate=!0,a.flipY=!1,this.weightsMaterial.areaTexture=a,this.dispatchEvent({type:"load"})},s.itemStart("search"),s.itemStart("area"),r!==void 0&&n!==void 0?(s.itemEnd("search"),s.itemEnd("area")):typeof Image<"u"&&(r=new Image,n=new Image,r.addEventListener("load",()=>s.itemEnd("search")),n.addEventListener("load",()=>s.itemEnd("area")),r.src=aO,n.src=lO),this.applyPreset(i)}get edgesTexture(){return this.renderTargetEdges.texture}getEdgesTexture(){return this.edgesTexture}get weightsTexture(){return this.renderTargetWeights.texture}getWeightsTexture(){return this.weightsTexture}get edgeDetectionMaterial(){return this.edgeDetectionPass.fullscreenMaterial}get colorEdgesMaterial(){return this.edgeDetectionMaterial}getEdgeDetectionMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.fullscreenMaterial}getWeightsMaterial(){return this.weightsMaterial}setEdgeDetectionThreshold(i){this.edgeDetectionMaterial.edgeDetectionThreshold=i}setOrthogonalSearchSteps(i){this.weightsMaterial.orthogonalSearchSteps=i}applyPreset(i){let t=this.edgeDetectionMaterial,e=this.weightsMaterial;switch(i){case ha.LOW:t.edgeDetectionThreshold=.15,e.orthogonalSearchSteps=4,e.diagonalDetection=!1,e.cornerDetection=!1;break;case ha.MEDIUM:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=8,e.diagonalDetection=!1,e.cornerDetection=!1;break;case ha.HIGH:t.edgeDetectionThreshold=.1,e.orthogonalSearchSteps=16,e.diagonalSearchSteps=8,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break;case ha.ULTRA:t.edgeDetectionThreshold=.05,e.orthogonalSearchSteps=32,e.diagonalSearchSteps=16,e.cornerRounding=25,e.diagonalDetection=!0,e.cornerDetection=!0;break}}setDepthTexture(i,t=vn){this.edgeDetectionMaterial.depthBuffer=i,this.edgeDetectionMaterial.depthPacking=t}update(i,t,e){this.clearPass.render(i,this.renderTargetEdges),this.edgeDetectionPass.render(i,t,this.renderTargetEdges),this.weightsPass.render(i,this.renderTargetEdges,this.renderTargetWeights)}setSize(i,t){this.edgeDetectionMaterial.setSize(i,t),this.weightsMaterial.setSize(i,t),this.renderTargetEdges.setSize(i,t),this.renderTargetWeights.setSize(i,t)}dispose(){let{searchTexture:i,areaTexture:t}=this.weightsMaterial;i!==null&&t!==null&&(i.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return aO}static get areaImageDataURL(){return lO}};var FY=`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);}`,d0={DEFAULT:0,ESKIL:1},AO=class extends bo{constructor({blendFunction:i=pt.NORMAL,technique:t=d0.DEFAULT,eskil:e=!1,offset:r=.5,darkness:n=.5}={}){super("VignetteEffect",FY,{blendFunction:i,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new oe(r)],["darkness",new oe(n)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(i){this.technique!==i&&(this.defines.set("VIGNETTE_TECHNIQUE",i.toFixed(0)),this.setChanged())}get eskil(){return this.technique===d0.ESKIL}set eskil(i){this.technique=i?d0.ESKIL:d0.DEFAULT}getTechnique(){return this.technique}setTechnique(i){this.technique=i}get offset(){return this.uniforms.get("offset").value}set offset(i){this.uniforms.get("offset").value=i}getOffset(){return this.offset}setOffset(i){this.offset=i}get darkness(){return this.uniforms.get("darkness").value}set darkness(i){this.uniforms.get("darkness").value=i}getDarkness(){return this.darkness}setDarkness(i){this.darkness=i}},XTe=[new Float32Array(3),new Float32Array(3)],QTe=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],KTe=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var ZTe=[new Float32Array(2),new Float32Array(2)];var JTe=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),$Te=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],eCe=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],tCe=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var rCe=new Map([[Qn(0,0,0,0),new Float32Array([0,0,0,0])],[Qn(0,0,0,1),new Float32Array([0,0,0,1])],[Qn(0,0,1,0),new Float32Array([0,0,1,0])],[Qn(0,0,1,1),new Float32Array([0,0,1,1])],[Qn(0,1,0,0),new Float32Array([0,1,0,0])],[Qn(0,1,0,1),new Float32Array([0,1,0,1])],[Qn(0,1,1,0),new Float32Array([0,1,1,0])],[Qn(0,1,1,1),new Float32Array([0,1,1,1])],[Qn(1,0,0,0),new Float32Array([1,0,0,0])],[Qn(1,0,0,1),new Float32Array([1,0,0,1])],[Qn(1,0,1,0),new Float32Array([1,0,1,0])],[Qn(1,0,1,1),new Float32Array([1,0,1,1])],[Qn(1,1,0,0),new Float32Array([1,1,0,0])],[Qn(1,1,0,1),new Float32Array([1,1,0,1])],[Qn(1,1,1,0),new Float32Array([1,1,1,0])],[Qn(1,1,1,1),new Float32Array([1,1,1,1])]]);function t1(i,t,e){return i+(t-i)*e}function Qn(i,t,e,r){let n=t1(i,t,.75),s=t1(e,r,1-.25);return t1(n,s,1-.125)}var kr=class{constructor(t,e){this.enabled=!1;this.effect=new t(e),Object.defineProperty(this,"opacity",{enumerable:!0,set(r){this.effect.blendMode.opacity.value=r},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(r){this.effect.blendMode.setBlendFunction(Number(r))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=pt.NORMAL}};var Bd=class extends kr{constructor(){super(mO),this.blendFunction=pt.SCREEN}set intensity(t){this.effect.intensity=t}get intensity(){return this.effect.intensity}set luminanceThreshold(t){this.effect.luminanceMaterial.threshold=t}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(t){this.effect.luminanceMaterial.smoothing=t}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(t){this.effect.blurPass.scale=t}get blurScale(){return this.effect.blurPass.scale}set kernelSize(t){this.effect.blurPass.kernelSize=t}get kernelSize(){return this.effect.blurPass.kernelSize}};var Fd=class extends kr{constructor(){super(gO)}set contrast(t){this.effect.uniforms.get("contrast").value=t}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(t){this.effect.uniforms.get("brightness").value=t}get brightness(){return this.effect.uniforms.get("brightness").value}};var kd=class extends kr{constructor(){super(vO),this.effect.offset=new N(.01,.01)}set offset(t){this.effect.offset.set(t[0]/1e3,t[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var Vd=class extends kr{constructor(){super(yO)}};var zd=class extends kr{constructor(){super(bO);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};var Ud=class extends kr{constructor(){super(wO),this.blendFunction=pt.OVERLAY}};var Gd=class extends kr{constructor(){super(AO)}get eskil(){return this.effect.eskil}set eskil(t){this.effect.eskil=t}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(t){this.effect.uniforms.get("darkness").value=t}get offset(){return this.effect.uniforms.get("offset").value}set offset(t){this.effect.uniforms.get("offset").value=t}};var Hd=class extends kr{constructor(t){super(xO,t)}set focalLength(t){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=t}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(t){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=t}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(t){this.effect.bokehScale=t}};var jd=class extends kr{constructor(){super(SO)}get granularity(){return this.effect.getGranularity()}set granularity(t){this.effect.setGranularity(t)}};var _O=`#define GLSLIFY 1 +varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`;var EO=`#define GLSLIFY 1 +#include +varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution; +#define USE_YCOCG +#define USE_CATMULL_ROM +const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){ +#ifdef USE_YCOCG +vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a); +#else +return texture(tex,uv); +#endif +}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){ +#ifdef CHOOSE_LONGEST_MOTION_VECTOR +float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose; +#else +float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv); +#ifdef USE_CATMULL_ROM +vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution); +#else +vec4 previousColor=sample_color(historyBuffer,previousPixelPos); +#endif +#ifdef USE_YCOCG +previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a); +#endif +vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5); +#ifdef USE_YCOCG +vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center; +#endif +vec4 previousColorClipped=clamp(previousColor,cmin,cmax); +#ifdef LUMINANCE_DIFFERENCES +#ifdef USE_YCOCG +float lum0=currentColor.r;float lum1=previousColorClipped.r; +#else +float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb); +#endif +float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback)); +#else +const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha); +#endif +#ifdef USE_YCOCG +gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a); +#else +gl_FragColor=result; +#endif +}`;var MO=`#define GLSLIFY 1 +varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`;var TO=`#define GLSLIFY 1 +layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`;var Wd=class extends at{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new oe(null)},blending:Vt,depthWrite:!1,depthTest:!1,vertexShader:MO,fragmentShader:TO})}set inputBuffer(t){this.uniforms.inputBuffer.value=t}},p0=class extends Zr{constructor(){super("TAAResolvePass");this.MRTCompatible=!0;this.needsSwap=!1,this.passThroughMaterial=new Wd,this.resolutionVector=new N,this.resolveMaterial=new at({name:"TAAResolveMaterial",uniforms:{inputBuffer:new oe(null),historyBuffer:new oe(null),velocityBuffer:new oe(null),depthBuffer:new oe(null),resolution:new oe(new N)},blending:Vt,depthWrite:!1,depthTest:!1,vertexShader:_O,fragmentShader:EO}),this.historyRenderTarget=new ht(1024,1024,{minFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new ht(1024,1024,{minFilter:Je,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,r){this.historyRenderTarget.setSize(e,r),this.resultRenderTarget.setSize(e,r)}render(e,r){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=r.texture[0],this.resolveMaterial.uniforms.velocityBuffer.value=r.texture[1],this.resolveMaterial.uniforms.depthBuffer.value=r.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(r.width,r.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let n=this.renderToScreen?null:r;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(n),e.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}};var m0=class extends Zr{constructor(e,r,n){super("TransmissionPass",void 0,r);this.MRTCompatible=!0;this.depthPass=new s1(e,r,{renderTarget:n.transmissionDepthTarget}),this.passThroughMaterial=new Wd,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new Wd,this.depthPass=new s1(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,r,n){let s=this.camera.layers.mask,o=e;o.setRenderTarget(o.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=r.texture[0],o.clear(),o.render(this.scene,this.camera),this.camera.layers.disable(3),this.depthPass.render(e,r,n),o.shadowMap.needsUpdate=!1,o.shadowMap.autoUpdate=!1;let a=this.renderToScreen?null:r;this.camera.layers.set(3),e.setRenderTarget(a),e.render(this.splineScene,this.camera),this.camera.layers.mask=s}};var CO=new Nn,HY=new at({transparent:!0,vertexShader:` + void main() { + gl_Position = vec4(0.0); + } + `,fragmentShader:` + layout(location = 1) out vec4 gVelocity; + + void main() { + gl_FragColor = vec4(0.0); + gVelocity = vec4(0.0); + } + `}),Dc=class extends Zr{constructor(e,r,n){super("OpaquePass",r??CO,n);this.MRTCompatible=!0;this.hasTransmissionPass=!1;this.clear=!0;this.clearColorOnly=!1;this.clearDepth=!1;this.needsSwap=!1,this.originalMaterials=new Map,this.MRTCompatible=e}set splatViewer(e){this._splatViewer=e}get splatViewer(){return this._splatViewer}setCamera(e){this.camera=e}setScene(e){this.scene=e??CO}getScene(){return this.scene}render(e,r){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.clear(),this.scene.traverse(s=>{s.layers.isEnabled(3)&&s instanceof $t&&(this.originalMaterials.set(s.id,s.material),s.material=HY)}),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let n=this.renderToScreen?null:r;if(e.setRenderTarget(n),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),this._splatViewer?.splatRenderingInitialized===!0){let s=e.autoClear;e.autoClear=!1,e.render(this.scene,this.camera),this._splatViewer.update(),e.render(this._splatViewer.splatMesh,this.camera),e.autoClear=s}else e.render(this.scene,this.camera);this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach((s,o)=>{let a=this.scene.getObjectById(o);a&&(a.material=s)})}};var g0=class{constructor(t,{depthBuffer:e=!0,stencilBuffer:r=!1,multisampling:n=0,frameBufferType:s=0}={}){this.renderer=t;this.helperStartIndex=0;this.copyPass=new em;this.depthTexture=null;this.timer=new pO;this._width=1;this._height=1;this.passes=[];this.helperPasses=[];this.autoRenderToScreen=!0;this.inputBuffer=this.createBuffer(e,r,s,n,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(e,r,s,n,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.texture[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(e,r,s,n,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.texture[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(t)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(t){let e=this.inputBuffer,r=this.multisampling;r>0&&t>0?(this.inputBuffer.samples=t,this.outputBuffer.samples=t,this.inputBuffer.dispose(),this.outputBuffer.dispose()):r!==t&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,t,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(t){if(this.renderer=t,t!==null){let e=t.getSize(new N),r=t.getContext().getContextAttributes()?.alpha??!1,n=this.inputBuffer.texture[0].type;n===lr&&t.outputEncoding===et&&(this.inputBuffer.texture[0].encoding=et,this.outputBuffer.texture[0].encoding=et,this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("doing some kinda dispose??")),t.autoClear=!1,this.setSize(e.width,e.height,!1);for(let s of this.passes)s.initialize(t,r,n)}}replaceRenderer(t,e=!0){let r=this.renderer,n=r.domElement.parentNode;return this.setRenderer(t),e&&n!==null&&(n.removeChild(r.domElement),n.appendChild(t.domElement)),r}createDepthTexture(){let t=this.depthTexture=new Gi(this._width,this._height);return this.inputBuffer.depthTexture=t,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(t.format=Ca,t.type=Ea):t.type=ps,t}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let t of this.passes)t.setDepthTexture(null)}}createBuffer(t,e,r,n,s,o){let a=this.renderer,l=a===null?new N:a.getDrawingBufferSize(new N),u={minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,stencilBuffer:e,depthBuffer:t},c;return n>0?(c=new ht(l.width,l.height,u),c.samples=n):(s?(c=new vg(l.width,l.height,2,u),c.texture[1].type=Go):c=new ht(l.width,l.height,u),c.depthTexture=new Gi(2048,2048),c.depthTexture.type=Xr),r===lr&&a!==null&&a.outputEncoding===et&&(Array.isArray(c.texture)?c.texture.forEach(h=>h.encoding=et):c.texture.encoding=et),Array.isArray(c.texture)?c.texture.forEach((h,d)=>{h.name=`EffectComposer.Buffer ${s} ${d}`,h.generateMipmaps=!1}):(c.texture.name=`EffectComposer.Buffer ${s}`,c.texture.generateMipmaps=!1),c.name=o,c}addPass(t,e){let r=this.passes,n=this.renderer,s=n.getDrawingBufferSize(new N),o=n.getContext().getContextAttributes()?.alpha??!1,a;if(t.MRTCompatible&&(a=this.inputBuffer.texture[0].type),t.MRTCompatible||(a=this.inputBuffer.texture.type),t.setRenderer(n),t.setSize(s.width,s.height),t.initialize(n,o,a),this.autoRenderToScreen&&(r.length>0&&(r[r.length-1].renderToScreen=!1),t.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?r.splice(e,0,t):r.push(t),this.autoRenderToScreen&&(r[r.length-1].renderToScreen=!0),t.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let l=this.createDepthTexture();for(t of r)t.setDepthTexture(l)}else t.setDepthTexture(this.depthTexture)}setHelperStartIndex(t){this.helperStartIndex=t}removePass(t){let e=this.passes,r=e.indexOf(t);if(r!==-1&&e.splice(r,1).length>0){if(this.depthTexture!==null){let o=(l,u)=>l||u.needsDepthTexture;e.reduce(o,!1)||(t.getDepthTexture()===this.depthTexture&&t.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&r===e.length&&(t.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let t=this.passes;this.deleteDepthTexture(),t.length>0&&(this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!1),this.passes=[])}render(t){let e=this.renderer,r=this.copyPass,n=this.inputBuffer,s=this.outputBuffer,o=this.inputBufferSingle,a=this.outputBufferSingle,l=!1,u,c,h,d;t===void 0&&(t=this.timer.update().getDelta());for(let f of this.passes)f.enabled&&(f.MRTCompatible?f.render(e,n,s,t,l):f.render(e,o,a,t,l),f.needsSwap&&(l&&(r.renderToScreen=f.renderToScreen,u=e.getContext(),c=e.state.buffers.stencil,c.setFunc(u.NOTEQUAL,1,4294967295),r.render(e,n,s,t,l),c.setFunc(u.EQUAL,1,4294967295)),h=n,d=o,n=s,o=a,s=h,a=d),f instanceof fO?l=!0:f instanceof hO&&(l=!1))}setSize(t,e,r){let n=this.renderer;if(this._width=t,this._height=e,t===void 0||e===void 0){let o=n.getSize(new N);t=o.width,e=o.height}n.setSize(t,e,r);let s=n.getDrawingBufferSize(new N);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height),this.inputBufferSingle.setSize(s.width,s.height),this.outputBufferSingle.setSize(s.width,s.height);for(let o of this.passes)o.setSize(s.width,s.height)}reset(){let t=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(t)}dispose(){for(let t of this.passes)t.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.inputBufferSingle!==null&&this.inputBufferSingle.dispose(),this.outputBufferSingle!==null&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}};var jY=new at({name:"CombineMaterial",uniforms:{inputBufferA:new oe(null),inputBufferB:new oe(null)},blending:Vt,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); + } +`}),y0=class extends Zr{constructor(e){super("HelperPass",void 0,e);this.MRTCompatible=!1;this.fullscreenMaterial=jY,this.helperPass=new Dc(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new Dc(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let r=new f0({preset:ha.LOW,edgeDetectionMode:Nd.COLOR});this.effectPass=new Pc(this.camera,r),this.rt=new ht(10,10,{minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,depthBuffer:!0})}setSize(e,r){this.rt.setSize(e,r),this.effectPass.setSize(e,r)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,r,n){super.initialize(e,r,n),this.effectPass.initialize(e,r,n)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(e,r,n){this.rt.depthTexture=r.depthTexture;let s=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.rt,n),this.fullscreenMaterial.uniforms.inputBufferA.value=n.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=r.texture,e.setClearAlpha(s),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}};var PO=`#define GLSLIFY 1 +#include +out vec3 n;void main(){ +#include +#include +#include +#include +#include +#include +vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`;var DO=`#define GLSLIFY 1 +in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`;var IO=`#define GLSLIFY 1 +out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`;var OO=`#define GLSLIFY 1 +in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`;var RO=`#define GLSLIFY 1 +out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`;var LO=`#define GLSLIFY 1 +in vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){ +#ifdef DEBUG +float d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0); +#else +vec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao; +#endif +}`;var qd=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]];var ZY=new at({vertexShader:PO,fragmentShader:DO}),v0=new at({vertexShader:RO,fragmentShader:LO,uniforms:{texture_ao_lrez:new oe(null),texture_depth_lrez:new oe(null),texture_depth_hrez:new oe(null),near:new oe(null),far:new oe(null)}}),x0=class extends Zr{constructor(e,r){super("AmbientOcclusionPass",void 0,r);this.fogEnabled=!1;this.fogNear=1;this.fogFar=1e3;this.frameIndex=0;this._runHalfRes=!0;this._width=1;this._height=1;let n=1024,s=1024;this.gBuffer=new ht(n,s,{type:Xr,depthTexture:new Gi(n,s),minFilter:Je,magFilter:Je}),this.depthBufferHighRes=new ht(n,s,{depthTexture:new Gi(n,s)}),this.aoBuffer=new ht(n,s,{minFilter:Je,magFilter:Je}),this.splineScene=e,this.splineCamera=r;let o=new Float32Array(qd.length*2);for(let l=0;l with size +float rectangle(vec2 st, vec2 size) { + size = vec2(0.5) - size * 0.5; + vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y)); + uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y)); + + return uv.x * uv.y; +} + +uniform vec2 uSize; +uniform float uScale; +uniform float uDPR; +uniform float uCurrent; +uniform vec3 uSceneColor; + +void main() { + vec2 screenUv = gl_FragCoord.xy / uResolution.xy; + screenUv *= 1.0 / uDPR; + + vec2 center = vec2(0.5, -0.5); + vec2 outsideUv = screenUv; + outsideUv += center; + outsideUv -= uCoords.xy / uResolution.xy; + outsideUv = (outsideUv - 0.5) + 0.5; + outsideUv -= center; + vec2 s = (uSize / uResolution) * uScale; + float isOutside = 1.0 - rectangle(outsideUv, s); + + vec2 mid = vec2(0.5); + vec2 insideUv = (screenUv - mid + s * mid) / s; + vec4 background = texture2D(tInput, screenUv); + vec4 image = texture2D(tMap, insideUv); + gl_FragColor = mix(image, background, isOutside); +} +`,b0=class extends os{constructor(){super(new at({vertexShader:JY,fragmentShader:$Y,uniforms:{tInput:new oe(null),tMap:new oe(null),uResolution:new oe(new N),uSize:new oe(new N),uCoords:new oe(new N),uScale:new oe(1),uSceneColor:new oe(new Re(16711680)),uDPR:new oe(1),uCurrent:new oe(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(t){this.uniforms.tMap.value=t}};var e7=` +void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}`,t7=` +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 ); + + } +} +`,r7=[],w0=class extends os{constructor(){super(new at({vertexShader:e7,fragmentShader:t7,uniforms:{toScene:new oe(null),fromScene:new oe(null),uResolution:new oe(new N),uDPR:new oe(1),mixRatio:new oe(0),threshold:new oe(.1),useTexture:new oe(0),tMixTexture:{value:r7[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(t){this.uniforms.fromScene.value=t}};function BO(i,t){return t&&t.enabled&&i.push(t.effect),i}var n7=i=>Object.values(pt).includes(i)?i:pt.NORMAL,tm=class extends Yt{constructor(e){super();this.postprocessingState=yh.defaultData;this._scene=new Nn;this._camera=new er;this.effects=new Map;this.blueNoiseTexture=new li;this._renderToScreen=!0;this.clock=new Pg,this.renderer=e,this.debug=!1,this.effects.set("bloom",new Bd),this.effects.set("chromaticAberration",new kd),this.effects.set("vignette",new Gd),this.effects.set("noise",new Ud),this.effects.set("colorAverage",new Vd),this.effects.set("hueSaturation",new zd),this.effects.set("brightnessContrast",new Fd),this.effects.set("depthOfField",new Hd),this.effects.set("pixelation",new jd),this.effectComposer=new g0(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new Dc(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new m0(this.scene,this.camera,this.renderer),this.aoPass=new x0(this.scene,this.camera),this.taaPass=new p0,this.taaPass.renderToScreen=!1,this.helperPass=new y0(this.camera),this.helperPass.renderToScreen=!1,this.overlayPass=new b0,this.overlayPass.enabled=!1,this.sceneTransitionPass=new w0,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.overlayPass.texture=e,this.overlayPass.enabled=!0):this.overlayPass.enabled=!1}get overlayTexture(){return this.overlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.aoPass.setCamera(e),this.helperPass.setCamera(e)}updateRenderToScreen(){let e=!1;for(let r=this.effectComposer.passes.length-1;r>=0;r--){let n=this.effectComposer.passes[r];if(n.enabled===!0&&!e&&this._renderToScreen){n.renderToScreen=!0,e=!0;continue}n.renderToScreen=!1}}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new li(e,128,128),this.blueNoiseTexture.wrapS=ms,this.blueNoiseTexture.wrapT=ms,this.blueNoiseTexture.minFilter=kt,this.blueNoiseTexture.magFilter=kt,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,r,n,s,o,a,l,u){this.aoPass.enabled=e,this.aoPass.radius=r,this.aoPass.bias=n,this.aoPass.aoColor=s,this.aoPass.fogEnabled=o,this.aoPass.fogNear=a,this.aoPass.fogFar=l,this.aoPass.runHalfRes!==!u&&(this.aoPass.runHalfRes=!u)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(BO,[]);e.length>0&&(this.uvEffectPass=new Pc(this.camera,...e),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let r=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(BO,[]);r.length>0&&(this.effectPass=new Pc(this.camera,...r),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.overlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass)}_initCopyPass(){if(this._savePass)return;let e=new N;this.renderer.getDrawingBufferSize(e),this._rt=new ht(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ms,wrapT:ms}),this._rt.samples=0,this._savePass=new em(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new em(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let r=this.effectComposer;!r||(e===!0?r.removePass(this._savePass):r.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:r,...n}=e,s=!1;r!==this.postprocessingState.enabled&&(s=!0);for(let o of Object.entries(n)){let a=o[1],l=this.effects.get(o[0]);if(l){l.enabled!==a.enabled&&(s=!0),l.enabled=a.enabled;for(let[u,c]of Object.entries(a))u==="blendFunction"?l.blendFunction=n7(c):l[u]=c}}this.postprocessingState=e,s&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,r,n,s){e instanceof Xe?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,r,n,s),this.effectComposer.outputBuffer.scissor.set(e,r,n,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(e,r,n,s)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,r,n,s){e instanceof Xe?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,r,n,s),this.effectComposer.outputBuffer.viewport.set(e,r,n,s))}resize(e,r,n){if(this.effectComposer.setSize(e,r,n),this._rt){let s=this.renderer.getPixelRatio();this._rt.setSize(e*s,r*s)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}};var i7=i=>` + +// 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 = ${i}; +const int gShadowSamples = ${i}; +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 +`,s7=ut.lights_fragment_begin,o7=ut.shadowmask_pars_fragment,FO=null,a7=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},kO=(i="medium")=>{if(FO===i)return!1;FO=i;let t=a7(i);ut.shadowmap_pars_fragment=i7(t);let e=s7.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ut.lights_fragment_begin=e;let r=o7.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ut.shadowmask_pars_fragment=r,!0};var l7=` +attribute vec3 randomColor; +varying vec3 vNormal; +flat out vec3 vColor; + +void main() +{ +vNormal = normal; +vColor = randomColor; +gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0)); +} +`,c7=` +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); +} +`,S0=new at({vertexShader:l7,fragmentShader:c7,uniforms:{depthContrast:{value:1}}});var VO=new or,A0=class extends tw{constructor(e){super(e);this._pixelRatio=this.getPixelRatio();this.viewportWidth=1;this.viewportHeight=1;this.resolution=new N;this.pipeline=new tm(this);this.dummyCamera=new er;this.sceneTransitionDuration=0;this.sceneTransitionTimeRemaining=-1;this.isXRCopyPassSet=!1;this.clear=(e=!0,r=!0,n=!0)=>{let s=this.getContext(),o=0;e&&(o|=s.COLOR_BUFFER_BIT),r&&(o|=s.DEPTH_BUFFER_BIT),n&&(o|=s.STENCIL_BUFFER_BIT),s.clear(o),s.clearBufferfv(s.COLOR,1,[0,0,0,1])};this.autoClear=!1;let r=this.setPixelRatio.bind(this),n=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Ng,this.dummyCamera.matrixAutoUpdate=!1;let s=this.getContext();if(s&&"drawingBufferColorSpace"in s)try{s.drawingBufferColorSpace="display-p3"}catch(o){console.warn(o)}this.setPixelRatio=o=>{this._pixelRatio!==o&&(this._pixelRatio=o,r(o))},this.setSize=(o,a,l=!0)=>{(this.viewportWidth!==o||this.viewportHeight!==a)&&(this.viewportWidth=o,this.viewportHeight=a,n(o,a,l),this.normalRenderTarget?.setSize(o*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(o,a),this.transmissionDepthTarget?.setSize(o*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(o,a,l))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new ht(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Je,magFilter:Je,wrapS:sr,wrapT:sr,depthBuffer:!1}))}_resizeTransmission(e,r){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),r*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,r*this._pixelRatio/1)}get hdTransmission(){return je.transmissionLod.value===1}set hdTransmission(e){je.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ht(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ul,magFilter:Je,wrapS:sr,wrapT:sr,depthBuffer:!1}),this.transmissionDepthTarget=new ht(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:kt,magFilter:kt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ht(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:kt,magFilter:kt,type:Xr,depthTexture:new Gi(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,r,n){this.normalRenderTarget&&(this.setClearColor(0),n.layers.enable(8),n.layers.disable(0),n.layers.disable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),n instanceof er?S0.uniforms.depthContrast.value=(n.far-n.near)/1e4:S0.uniforms.depthContrast.value=1,r.overrideMaterial=S0,this.render(r,n),this.setClearColor(r.bgColor,r.bgColor.a),this.setRenderTarget(null),r.overrideMaterial=e.wireframeState?_0:null,n.layers.enable(0),n.layers.enable(3),r.traverseEntity(s=>{s.layers.isEnabled(8)&&(s.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,r,n=1){this.dummyCamera.updateCameraState(r.dataPatched),this.dummyCamera.matrix.copy(r.matrixWorld);let s=r.height,o=r.width,a=this.viewportWidth/this.viewportHeight;o{je.penumbraSize.value[m]=p}),je.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?je.resolution.value.set(this.resolution.x,this.resolution.y):je.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(je.normalRenderTarget.value=a,je.normalRenderTargetDepth.value=VO):c.needsNormal()&&(this.createNormalRenderTarget(),je.normalRenderTarget.value=this.normalRenderTarget.texture,je.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(c,l,r));let h=l.data.ao,d=h.occlusion;d&&(this.createAORenderTarget(),je.aoRenderTarget.value=this.aoRenderTarget.texture),je.aoEnabled.value=d,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,l.aoColor,l.fog!==null,l.backupFog.near,l.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let f=!1;if(o!==void 0)je.transmissionRenderTarget.value=o,je.transmissionRenderTargetDepth.value=VO,this.pipeline.setTransmissionPassEnabled(!1);else{let p=c.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(f=!0),this.createTransmissionRenderTarget(),je.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,je.aspectRatio.value=oI(this.viewportWidth,this.viewportHeight),je.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}r.layers.enable(3),r.layers.enable(8),this.pipeline.sceneHelpers=n,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=l,this.pipeline.camera=r,f&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==l.postprocessing&&(this.pipeline.updatePostprocessing(l.postprocessing),!n&&!s&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.overrideMaterial=c.wireframeState?_0:null,this.pipeline.render(),je.frameIndex.value=(je.frameIndex.value+1)%16,r instanceof er&&r.copyHistory(),l.visible=u}renderFromSceneForSceneTransitionPass(e,r,n){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,r),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=n,this.sceneTransitionTimeRemaining=n,this.pipeline.renderToScreen=!0;let s=this.pipeline.sceneTransitionPass.uniforms;s.uDPR.value=window.devicePixelRatio,s.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}};var Yd=class extends mo(Rg){constructor(e,r=15,n=10066329){super(e,r,n);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){go(this.object,Yd.geometryHelper,e,r)}};var Xd=class extends mo(Og){constructor(e,r=15,n=6710886){super(e,r,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){go(this.object,Xd.geometryHelper,e,r)}};var E0=class extends mo(Ig){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){go(this.object,E0.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=E0._vector,r=this.object.distance?this.object.distance:1e3,n=r*Math.tan(this.object.angle);this.cone.scale.set(n,n,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o{if(e instanceof ts)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&kO(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let n=this.scene;n.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=zn(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=zn(e.aoColor,r))}updateByOp(e,r,n,s){super.updateByOp(e,r,n,s);let o=r;qn(e.path,["fog"])?this.updateFog(o.fog,n.shared):qn(e.path,["ao"])?this.updateAo(o.ao,n.shared):qn(e.path,["ambient"])?this.updateAmbientLight(o.ambient,n.shared):qn(e.path,["shadow"])&&this.updateShadow(o.shadow)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(zn(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(n=>{if(!n.visible)return!0;n instanceof Qd&&n.visible&&e<3&&(this.penumbraSizeArrayCache[e]=n.data.penumbraSize,e+=1),n instanceof Kd&&n.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=n.data.penumbraSize,r+=1)})}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Yn(o)||Jp(o)&&this.scene.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),nm(o,e,r,!0)),n(o))}};return n(this),r}};var M0=class extends Ld(Tg,Xd){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let s=this.shadow.camera;s.fov=90,s.aspect=1,s.near=100,s.far=2500;let o=new _(-s.far+this.position.x,-s.far+this.position.y,-s.far+this.position.z),a=new _(s.far+this.position.x,s.far+this.position.y,s.far+this.position.z),l=new Pt(o,a),u=new Na(l,new Re(16755200));u.visible=!1,this.gizmos.shadowmap=u,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof Na){let r=this.shadow.camera,n=new _(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new _(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(n,s),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var T0=class extends Qt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Np(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var bl=class extends Qt{constructor(e,r,n){super(e,r,n);this._shapeId=null;this._context=n}updateState(e,r){super.updateState(e,r),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let r;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let o=this._context.scene.find(s);o?.data&&(o.attachedPaths.add(this),r=o.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=Dv;break;case"Ellipse":s=Jh;break;case"Polygon":s=Pv;break;case"Star":s=Iv;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=s.create({parameters:e}).userData.shape}let n=this.geometry;r&&n.inputs&&(n.inputs.shapeData=r,n.build(),this.attachedSurfaceCloners.forEach(s=>s.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let n=this.geometry.getAttribute("position");n!==void 0?Np(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var Rs=class extends yo(js,vo){constructor(e,r,n){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let n=Sh.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let s,o;for(let a of to.rootOverrideProps)e[a]===void 0?(s===void 0&&(s={...e}),s[a]=n.data[a]):(o===void 0&&(o={}),o[a]=e[a],s===void 0&&(s={...e}),s[a]=Xs.apply(n.data[a],e[a]));return this.overrideData=o,s}else return{...Fn.defaultData,...e,...Ni(Fn.defaultData,to.rootOverrideProps)}}updateByOp(e,r,n,s){let o;if(this.isInstanceRoot&&!s){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let a of to.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(o===void 0&&(o={...e,props:{...e.props}}),o.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&to.rootOverrideProps.includes(e.path[0])){let a=e.path[0];o===void 0&&(o={...e,path:[],props:{[a]:r[a]}})}}super.updateByOp(o??e,r,n,s)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,s=!1;if(n!==this.oldComponent){if(this.oldComponent){let o=0;for(let a of this.children)if(lt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),C0(a),o+=1;else break;this.children.splice(0,o)}s=!0}if(n){let o={};jO(e,[this.uuid],r.overrides,this,n,n,0,s,o);for(let a of this.children)if(lt.is(a)){let l=a.data;l.type==="Empty"&&l.animations&&a.traverseEntity(u=>{if(u instanceof Qt&&u.isSkinnedMesh){let c=u.dataPatched;if(c.bones&&c.boneInverses){let h=c.bones.map(p=>e.scene.find(o[p])),d=c.boneInverses.map(p=>new ie().fromArray(p)),f=new Pa(h,d);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function C0(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)lt.is(e)&&C0(e)}}function HO(i,t,e,r){return i.component===t&&np(i.identity,r)?i.overrideData===e?2:1:0}function jO(i,t,e,r,n,s,o,a,l){if(o>50)return!1;if(r.component!==n){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}n.instances.push(r),r.component=n}n instanceof Rs&&n.isInstanceRoot&&n.expandInstanceChildren(i);let u=0;for(let c of n.children)if(lt.is(c)){let h=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],d=xh.resolve(e,h,1);if(d!=null&&!(d instanceof Jt)){if(!1)debugger;Object.setPrototypeOf(d,Jt.prototype),console.error("wrong prototype")}let f=null,p;if(!a){let m=r.children[u];if(f=lt.is(m)?m:null,f!==null){let g=HO(f,c,d,h);p=g>=1?f.stateSelection:void 0,g!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(h)??null,f!==null)){let g=HO(f,c,d,h);if(p=g>=1?f.stateSelection:void 0,g!==2)f=null;else{let y=f.parent.children.indexOf(f);f.parent.children.splice(y,1),r.children.splice(u,0,f),f.parent===r?(y<=u&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=d?Xs.apply(c.data,d):c.data;bs.is(m.type)&&(m={...m,type:"Empty"}),f=As.createEntity(h,m,i),f.overrideData=d,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(u,0,f),f.updateState(f.data,i),p&&f.changeSelectedState(p,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}u+=1,jO(i,t,e,f,c,s,o+1,a,l)}if(!a){let c=u;for(;;){let h=r.children[u];if(lt.is(h))i.pendingDeletes.add(h);else break;u+=1}r.children.splice(c,u-c)}return!0}var P0=class extends yo(Ff,vo){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};function h7(i,t,e){let r;return t.geometry.type==="TextGeometry"?new Dd(i,t,e):(t.geometry.type==="SubdivGeometry"?r=new Ds(i,t,e):t.geometry.type==="PathGeometry"?r=new bl(i,t,e):t.geometry.type==="VectorGeometry"?r=new T0(i,t,e):t.geometry.type==="BooleanGeometry"?r=new is(i,t,e):r=new Qt(i,t,e),r)}function D0(i,t,e){return t.type==="Mesh"?h7(i,t,e):t.type==="Empty"?new ss(i,t):t.type==="Splat"?new ss(i,t):t.type==="Bone"?new P0(i,t):t.type==="Page"?new Si(i,t):t.type==="PointLight"?new M0(i,t,e):t.type==="SpotLight"?new Kd(i,t,e):t.type==="DirectionalLight"?new Qd(i,t,e):t.type==="Component"||t.type==="Instance"?new Rs(i,t,e):bs.is(t.type)?new er(i,t):(console.error(t),new ss(i,t))}As.createEntity=D0;function d7(i,t,e){let r=D0(i.identity,t,e),n=i.children,s=i.attachedPaths,o=i.parent,a=i.component,l=i.instances,u=i.overrideData,c=i.uuid,h=i.stateSelection;i.dispose();for(let d of Object.keys(i))delete i[d];Object.setPrototypeOf(i,Object.getPrototypeOf(r));for(let d of Object.keys(r))i[d]=r[d];i.children=[...i.children,...n],i.attachedPaths=s,i.parent=o,i.component=a,i.instances=l,i.uuid=c,i.overrideData=u,i.updateState(i.data,e),h&&i.changeSelectedState(h,e),i.resetBBoxNeedsUpdate()}As.changeEntityProptotype=d7;As.Cloner=Dn;function WO(i,t,e,r){i.updateByOp(t,e,r,!1)}function qO(i,t){let e=!1,r=t.getLayersOfType("transmission"),n=t.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),r.length>0&&i.layers.enable(3),e=!0,Cd(i),Td(i)),r.length===0&&n.length===0&&i.layers.set(0),i instanceof ts&&i.needsAO&&i.layers.enable(5),e}function YO(i,t){if(!t.layers)return!1;let e=!1,r=t.getLayersOfType("transmission").filter(s=>s.data.visible),n=t.getLayersOfType("outline").filter(s=>s.data.visible);return r.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),e=!0),r.length===0&&n.length===0&&i.layers.set(0),i.needsAO&&i.layers.enable(5),e}function XO(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof ts)if(Array.isArray(e.material))for(let r=0;r{if(e instanceof ts)if(Array.isArray(e.material))for(let r=0;r0&&e.push({...c[0],object:r?s:i})}}var I0=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,n)=>{let s=[n,r],o=r;for(;this._constraints.has(o);)o=this._constraints.get(o),e.has(o)||s.push(o);for(let a=s.length-2;a>=0;a--)if(!e.has(s[a])){let l=t.find(s[a]);l?l.applyPathSnapping(t):console.warn(`missing entity ${s[a]}`),e.add(s[a])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var Ls=pn(Zd()),wo=pn(Jd());var Cr=pn(Zd()),Qe=pn(Jd()),wl=class{constructor(t,e,r){this._dataNormalized=t,this._minD=e,this._maxD=r}static createFromUnnormalized(t){let e=Qe.sup(t),r=Qe.inf(t),n=(0,Cr.default)(new Float32Array(t.size),t.shape),s=e-r;return s<1e-4?Qe.assigns(n,0):(Qe.subs(n,t,r),Qe.divs(n,n,s)),new wl(n,r,e)}get data(){return this._dataNormalized}get minD(){return this._minD}get maxD(){return this._maxD}denormalize(){let t=(0,Cr.default)(new Float32Array(this._dataNormalized.size),this._dataNormalized.shape);return Qe.muls(t,this._dataNormalized,this._maxD-this._minD),Qe.adds(t,t,this._minD),t}},tr=class{constructor(t,e){this._quantized=t,this._method=e}get quantized(){return this._quantized}static maxIntBits(t){return 2**t-1}static fromNormalized(t,e){let r=t.data,n;if(e==="norm8x"){let s=tr.maxIntBits(8),o=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.muls(o,r,s),Qe.roundeq(o),n=(0,Cr.default)(new Uint8Array(o.data),r.shape)}else if(e==="norm565"){let s=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.assign(s,r),Qe.mulseq(s.pick(null,0),tr.maxIntBits(5)),Qe.mulseq(s.pick(null,1),tr.maxIntBits(6)),Qe.mulseq(s.pick(null,2),tr.maxIntBits(5)),Qe.roundeq(s);let o=(0,Cr.default)(new Uint16Array(s.data),r.shape),a=(0,Cr.default)(new Uint16Array(r.shape[0]),[r.shape[0]]),l=(0,Cr.default)(new Uint16Array(r.shape[0]),[r.shape[0]]);Qe.lshifts(a,o.pick(null,0),11),Qe.lshifts(l,o.pick(null,1),5),Qe.boreq(a,l),Qe.boreq(a,o.pick(null,2)),n=a}else{let s=(0,Cr.default)(new Float32Array(r.size),r.shape);Qe.assign(s,r),Qe.mulseq(s.pick(null,0),tr.maxIntBits(11)),Qe.mulseq(s.pick(null,1),tr.maxIntBits(10)),Qe.mulseq(s.pick(null,2),tr.maxIntBits(11)),Qe.roundeq(s);let o=(0,Cr.default)(new Uint32Array(s.data),r.shape),a=(0,Cr.default)(new Uint32Array(r.shape[0]),[r.shape[0]]),l=(0,Cr.default)(new Uint32Array(r.shape[0]),[r.shape[0]]);Qe.lshifts(a,o.pick(null,0),21),Qe.lshifts(l,o.pick(null,1),11),Qe.boreq(a,l),Qe.boreq(a,o.pick(null,2)),n=a}return new tr(n,e)}dequantize(t,e){let r=this._method,n,s=this._quantized;if(r==="norm8x"){let o=tr.maxIntBits(8);n=(0,Cr.default)(new Float32Array(s.size),s.shape),Qe.muls(n,s,1/o)}else if(r==="norm565"){let o=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]),a=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]),l=(0,Cr.default)(new Uint8Array(s.shape[0]),[s.shape[0]]);Qe.rrshifts(o,s,11),Qe.rrshifts(a,s,5),Qe.bandseq(a,tr.maxIntBits(6)),Qe.bands(l,s,tr.maxIntBits(5)),n=(0,Cr.default)(new Float32Array(s.shape[0]*3),[s.shape[0],3]),Qe.muls(n.pick(null,0),o,1/tr.maxIntBits(5)),Qe.muls(n.pick(null,1),a,1/tr.maxIntBits(6)),Qe.muls(n.pick(null,2),l,1/tr.maxIntBits(5))}else{let o=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]),a=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]),l=(0,Cr.default)(new Uint16Array(s.shape[0]),[s.shape[0]]);Qe.rrshifts(o,s,21),Qe.rrshifts(a,s,11),Qe.bandseq(a,tr.maxIntBits(10)),Qe.bands(l,s,tr.maxIntBits(11)),n=(0,Cr.default)(new Float32Array(s.shape[0]*3),[s.shape[0],3]),Qe.muls(n.pick(null,0),o,1/tr.maxIntBits(11)),Qe.muls(n.pick(null,1),a,1/tr.maxIntBits(10)),Qe.muls(n.pick(null,2),l,1/tr.maxIntBits(11))}return new wl(n,t,e)}};var rr=class{constructor(t,e,r,n,s,o=!1){this._quantized=t,this._minMaxMatrix=e,this._chunkSize=r,this._quantizationMethod=n,this._variableChunkSize=s,this._isDynamicChunks=o}get length(){return this._quantized.shape[0]}get nchunks(){return this._minMaxMatrix.shape[0]}get quantized(){return this._quantized}get method(){return this._quantizationMethod}get minmaxMatrix(){return this._minMaxMatrix}_createPrunedMinMax(t){let e=t.length,r=this.minmaxMatrix.shape[0]-e,n=(0,Ls.default)(new Float32Array(r*2),[r,2]),s=0,o=r,a=0,l=this.minmaxMatrix.shape[0];for(let u=0;us&&wo.assign(n.hi(o,2).lo(s,0),this.minmaxMatrix.hi(l,2).lo(a,0)),s=o,a=l+1;return sa&&(o?wo.assign(s.hi(l,o).lo(a,0),this._quantized.hi(c,o).lo(u,0)):wo.assign(s.hi(l).lo(a),this._quantized.hi(c).lo(u))),a=l,u=c+1;return a1?h=wl.createFromUnnormalized(t.hi(c,t.shape[1]).lo(u,0)):h=wl.createFromUnnormalized(t.hi(c).lo(u)),o.set(l,0,h.minD),o.set(l,1,h.maxD),a.shape.length>1?wo.assign(a.hi(c,a.shape[1]).lo(u,0),tr.fromNormalized(h,e).quantized):wo.assign(a.hi(c).lo(u),tr.fromNormalized(h,e).quantized)}return new rr(a,o,r,e)}denormDequant(){let t=this._minMaxMatrix.shape[0],e=this._quantized,r=e.shape[0],n=this._quantizationMethod,s=this._chunkSize,o;if(this._isDynamicChunks){if(!this._variableChunkSize)throw new Error("variable chunk must exists if chunkSize isDynamic");o=this._variableChunkSize}let a;n==="norm8x"?a=(0,Ls.default)(new Float32Array(e.size),e.shape):a=(0,Ls.default)(new Float32Array(r*3),[r,3]);let l=0,u=s;for(let c=0;c1?p=new tr(e.hi(f,e.shape[1]).lo(l,0),n):p=new tr(e.hi(f).lo(l),n),wo.assign(a.hi(f,a.shape[1]).lo(l,0),p.dequantize(h,d).denormalize()),l=f}return a}static async fetchArrayBuffer(t){return await(await fetch(t,{mode:"cors"})).arrayBuffer()}};var da=pn(Zd()),wt=pn(Jd());var yR="http://127.0.0.1:8000";var Oc=pn(Zd()),Xt=pn(Jd());var vR=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9];function xR(i){return i<1e5?i<100?i<10?0:1:i<1e4?i<1e3?2:3:4:i<1e7?i<1e6?5:6:i<1e9?i<1e8?7:8:9}function bR(i,t){if(i===t)return 0;if(~~i===i&&~~t===t){if(i===0||t===0)return i=0)return-1;if(i>=0)return 1;i=-i,t=-t}let n=xR(i),s=xR(t),o=0;return ns&&(t*=vR[n-s-1],i/=10,o=1),i===t?o:i=32;)t|=i&1,i>>=1;return i+t}function wR(i,t,e,r){let n=t+1;if(n===e)return 1;if(r(i[n++],i[t])<0){for(;n=0;)n++;return n-t}function U7(i,t,e){for(e--;t>>1;n(s,i[u])<0?a=u:o=u+1}let l=r-o;switch(l){case 3:i[o+3]=i[o+2];case 2:i[o+2]=i[o+1];case 1:i[o+1]=i[o];break;default:for(;l>0;)i[o+l]=i[o+l-1],l--}i[o]=s}}function u1(i,t,e,r,n,s){let o=0,a=0,l=1;if(s(i,t[e+n])>0){for(a=r-n;l0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a),o+=n,l+=n}else{for(a=n+1;la&&(l=a);let u=o;o=n-l,l=n-u}for(o++;o>>1);s(i,t[e+u])>0?o=u+1:l=u}return l}function h1(i,t,e,r,n,s){let o=0,a=0,l=1;if(s(i,t[e+n])<0){for(a=n+1;la&&(l=a);let u=o;o=n-l,l=n-u}else{for(a=r-n;l=0;)o=l,l=(l<<1)+1,l<=0&&(l=a);l>a&&(l=a),o+=n,l+=n}for(o++;o>>1);s(i,t[e+u])<0?l=u:o=u+1}return l}var d1=class{constructor(t,e){mn(this,"array",null);mn(this,"compare",null);mn(this,"minGallop",7);mn(this,"length",0);mn(this,"tmpStorageLength",256);mn(this,"stackLength",0);mn(this,"runStart",null);mn(this,"runLength",null);mn(this,"stackSize",0);this.array=t,this.compare=e,this.length=t.length,this.length<2*256&&(this.tmpStorageLength=this.length>>>1),this.tmp=new Array(this.tmpStorageLength),this.stackLength=this.length<120?5:this.length<1542?10:this.length<119151?19:40,this.runStart=new Array(this.stackLength),this.runLength=new Array(this.stackLength)}pushRun(t,e){this.runStart[this.stackSize]=t,this.runLength[this.stackSize]=e,this.stackSize+=1}mergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;if(t>=1&&this.runLength[t-1]<=this.runLength[t]+this.runLength[t+1]||t>=2&&this.runLength[t-2]<=this.runLength[t]+this.runLength[t-1])this.runLength[t-1]this.runLength[t+1])break;this.mergeAt(t)}}forceMergeRuns(){for(;this.stackSize>1;){let t=this.stackSize-2;t>0&&this.runLength[t-1]=7||p>=7);if(m)break;d<0&&(d=0),d+=2}if(this.minGallop=d,d<1&&(this.minGallop=1),e===1){for(l=0;l=0;l--)o[f+l]=o[d+l];o[h]=a[c];return}let p=this.minGallop;for(;;){let m=0,g=0,y=!1;do if(s(a[c],o[u])<0){if(o[h--]=o[u--],m++,g=0,--e===0){y=!0;break}}else if(o[h--]=a[c--],g++,m=0,--n===1){y=!0;break}while((m|g)=0;l--)o[f+l]=o[d+l];if(e===0){y=!0;break}}if(o[h--]=a[c--],--n===1){y=!0;break}if(g=n-u1(o[u],a,0,n,n-1,s),g!==0){for(h-=g,c-=g,n-=g,f=h+1,d=c+1,l=0;l=7||g>=7);if(y)break;p<0&&(p=0),p+=2}if(this.minGallop=p,p<1&&(this.minGallop=1),n===1){for(h-=e,u-=e,f=h+1,d=u+1,l=e-1;l>=0;l--)o[f+l]=o[d+l];o[h]=a[c]}else{if(n===0)throw new Error("mergeHigh preconditions were not respected");for(d=h-(n-1),l=0;la&&(l=a),SR(i,e,e+l,e+s,t),s=l}o.pushRun(e,s),o.mergeRuns(),n-=s,e+=s}while(n!==0);o.forceMergeRuns()}function f1(i){let t=(0,Oc.default)(new Int32Array(i.shape[0]),[i.shape[0]]),e=(0,Oc.default)(new Int32Array(i.shape[0]),[i.shape[0]]);return Xt.bands(t,i,1023),Xt.lshifts(e,t,16),Xt.bxoreq(t,e),Xt.bandseq(t,4278190335),Xt.lshifts(e,t,8),Xt.bxoreq(t,e),Xt.bandseq(t,50393103),Xt.lshifts(e,t,4),Xt.bxoreq(t,e),Xt.bandseq(t,51130563),Xt.lshifts(e,t,2),Xt.bxoreq(t,e),Xt.bandseq(t,153391689),t}function G7(i){let t=f1(i.pick(null,0)),e=f1(i.pick(null,1));Xt.lshiftseq(e,1);let r=f1(i.pick(null,2));return Xt.lshiftseq(r,2),Xt.boreq(t,e),Xt.boreq(t,r),t}function Sl(i,t){if(i.shape[0]!==t.shape[0])throw new Error("wrong length");let e=(0,Oc.default)(new Float32Array(i.size),i.shape,i.stride,i.offset);for(let r=0;r1)for(let s=0;s[h,d]);AR(l,(h,d)=>h[0]-d[0]);let u=l.map(([h,d])=>d);return(0,Oc.default)(Uint32Array.from(u))}var as=class{constructor(t,e,r,n,s,o,a,l,u,c){this.propertyDescs=t,this.format=e,this.nsplats=r,this.xyz=n,this.colors=s,this.harmonics=o,this.opacity=a,this.scaling=l,this.rotation=u,this.maxSHDegree=c}getPlyBinary(){let t=as._generateHeaderString(this.propertyDescs,this.format,this.nsplats),e=new TextEncoder().encode(t),r=Object.keys(this.propertyDescs).length,n=(0,da.default)(new Float32Array(this.nsplats*r),[this.nsplats,r]);if(wt.assign(n.pick(null,this.propertyDescs.x.index),this.xyz.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.y.index),this.xyz.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.z.index),this.xyz.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.f_dc_0.index),this.colors.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.f_dc_1.index),this.colors.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.f_dc_2.index),this.colors.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.opacity.index),this.opacity.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.scale_0.index),this.scaling.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.scale_1.index),this.scaling.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.scale_2.index),this.scaling.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.rot_0.index),this.rotation.pick(null,0)),wt.assign(n.pick(null,this.propertyDescs.rot_1.index),this.rotation.pick(null,1)),wt.assign(n.pick(null,this.propertyDescs.rot_2.index),this.rotation.pick(null,2)),wt.assign(n.pick(null,this.propertyDescs.rot_3.index),this.rotation.pick(null,3)),this.harmonics&&this.harmonics.length>0)for(let a=0;a=t.byteLength)throw new Error("End of file reached while searching for end of header");let p=new Uint8Array(t,r,s);n+=e.decode(p),r+=s;let m=r-s*2,g=new Uint8Array(t,Math.max(0,m),m>0?s*2:s);if(e.decode(g).includes("end_header"))break}let o=n.split(` +`),a=0,l={},u={},c=0,h;for(let p=0;p0}get nchunks(){return this.xyz.nchunks}get nsplats(){return this.xyz.length}get chunkSize(){return this.config.chunkSize}static compressFromGaussianData(t,e){let r=rr.fromArray(t.xyz,e.xyz,e.chunkSize),n=rr.fromArray(t.scaling,e.scaling,e.chunkSize),s=rr.fromArray(t.colors,e.color,e.chunkSize),o=rr.fromArray(t.opacity,e.opacity,e.chunkSize),a=rr.fromArray(t.rotation,e.quaternion,e.chunkSize),l=t.harmonics,u=[];if(e.harmonics)for(let c=0;c=l[d]+a[d];)d++;d in e?e[d].push(h):e[d]=[h]}}return e}pruneSplats(t){let e=this._countIndexesInChunks(t),r,n=[];return e.length>0&&(r=this.variableChunkSize?[...this.variableChunkSize]:Array(this.nchunks).fill(this.chunkSize),e.forEach((s,o)=>{r[o]-=s.length,r[o]<=0&&n.push(o)}),r=r.filter(s=>s>0)),new Rc(this.config,this.xyz.pruneFeature(t,n,r),this.scaling.pruneFeature(t,n,r),this.color.pruneFeature(t,n,r),this.opacity.pruneFeature(t,n,r),this.quaternion.pruneFeature(t,n,r),this.harmonics?this.harmonics.map(s=>s.pruneFeature(t,n,this.variableChunkSize)):void 0,r)}static async loadConfig(t){return await(await fetch(t,{method:"GET",mode:"cors",headers:{Accept:"application/json"}})).json()}toGaussians(){let t={format:"binary_little_endian",version:"1.0"},e={},r=0;if(e.x={dtype:"float",index:r},r++,e.y={dtype:"float",index:r},r++,e.z={dtype:"float",index:r},r++,e.f_dc_0={dtype:"float",index:r},r++,e.f_dc_1={dtype:"float",index:r},r++,e.f_dc_2={dtype:"float",index:r},r++,this.harmonics&&this.harmonics.length>0)for(let o=0;oo.denormDequant());return new as(e,t,this.xyz.length,this.xyz.denormDequant(),this.color.denormDequant(),n||[],this.opacity.denormDequant(),this.scaling.denormDequant(),this.quaternion.denormDequant(),3)}};var Lc=pn(Zd()),Jr=pn(Jd());var _R={xyz:3,color:3,opacity:1,scaling:3,quaternion:4,harmonics:3},Al=class{constructor(t){this._buffer=t}get buffer(){return this._buffer}get decoded(){return this._decoded||(this._decoded=this.decodeBuffer()),this._decoded}get colorsA(){let t=.28209479177387814,e=this.decoded.color.denormDequant(),r=this.decoded.opacity.denormDequant(),n=(0,Lc.default)(new Float32Array(e.shape[0]*4),[e.shape[0],4]);return Jr.mulseq(e,t),Jr.addseq(e,.5),Jr.mulseq(e,255),Jr.maxseq(e,0),Jr.minseq(e,255),Jr.negeq(r),Jr.expeq(r),Jr.addseq(r,1),Jr.recipeq(r),Jr.mulseq(r,255),Jr.assign(n.hi(e.shape[0],3).lo(0,0),e),Jr.assign(n.hi(e.shape[0],4).lo(0,3),r),(0,Lc.default)(new Uint8Array(n.data),[e.shape[0],4]).data}get nsplats(){return this.decoded.nsplats}getSplatCount(){return this.decoded.nsplats}get precomputedCovarianceBufferData(){return this._precomputedCovarianceBufferData}decodeBuffer(){let{splatCount:t,chunkCount:e,chunkSize:r,typeChunks:n,vertexData:s,propertiesDesc:o}=this.decodeHeader(),a={xyz:o.xyz.compressionMethod,color:o.color.compressionMethod,opacity:o.opacity.compressionMethod,scaling:o.scaling.compressionMethod,quaternion:o.quaternion.compressionMethod,chunkSize:r};o.harmonics_0&&(a.harmonics=o.harmonics_0.compressionMethod);let l=s.byteOffset,u=Array(Object.keys(o).length);for(let y in o)u[o[y].index]={name:y,method:o[y].compressionMethod};let c=e*2*4,h=l,d=n==="dynamic"?e*2:0,f,p=!1;if(d>0){let y=new Uint16Array(s.buffer.slice(h,h+d));h+=d,f=Array.from(y),p=!0}let m={};for(let y of u){let v=0,x=!0;if(y.method==="norm8x")v=t*1*_R[y.name];else if(y.method==="norm11")v=t*4;else if(y.method==="norm565")v=t*2;else throw x=!1,new Error(`Not Implemented format: ${y.method}`);let w;if(x){let E=s.buffer.slice(h,h+c);w=(0,Lc.default)(new Float32Array(E),[e,2]),h+=c}else throw new Error("loading chunk byt hasnot minmax!");let S=s.buffer.slice(h,h+v);h+=v;let A;if(y.method==="norm8x")A=(0,Lc.default)(new Uint8Array(S),[t,_R[y.name]]);else if(y.method==="norm11")A=(0,Lc.default)(new Uint32Array(S));else if(y.method==="norm565")A=(0,Lc.default)(new Uint16Array(S));else throw new Error(`Not Implemented format: ${y.method}`);m[y.name]=new rr(A,w,r,y.method,f,p)}let g=[];for(let y=0;y<15;y++){let v=m[`harmonics_${y}`];v&&(g.push(v),delete m[`harmonics_${y}`])}return g.length>0&&(m.harmonics=g),new Rc(a,m.xyz,m.scaling,m.color,m.opacity,m.quaternion,m.harmonics,f)}buildPreComputedBuffers(){let r=this.decoded,n=r.nsplats,s=new ArrayBuffer(24*n),o=new Float32Array(s),a=r.scaling.denormDequant(),l=r.quaternion.denormDequant(),u=new He,c=new Gt,h=new Gt,d=new Gt,f=new ie;for(let p=0;p=t.byteLength)throw new Error("End of file reached while searching for end of header");let m=new Uint8Array(t,r,s);n+=e.decode(m),r+=s;let g=r-s*2,y=new Uint8Array(t,Math.max(0,g),g>=0?s*2:s);if(e.decode(y).includes("end_header"))break}let o=n.split(` +`),a=0,l=0,u=0,c=0,h="",d={};for(let m=0;m0)for(let M=0;M0)for(let M=0;M0&&(E.set(new Uint8Array(v.buffer),b),b+=x),t.xyz instanceof rr&&(E.set(new Uint8Array(t.xyz.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.xyz.quantized.data.buffer),b),b+=l,t.color instanceof rr&&(E.set(new Uint8Array(t.color.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.color.quantized.data.buffer),b),b+=c,t.opacity instanceof rr&&(E.set(new Uint8Array(t.opacity.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.opacity.quantized.data.buffer),b),b+=d,t.scaling instanceof rr&&(E.set(new Uint8Array(t.scaling.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.scaling.quantized.data.buffer),b),b+=p,t.quaternion instanceof rr&&(E.set(new Uint8Array(t.quaternion.minmaxMatrix.data.buffer),b),b+=a),E.set(new Uint8Array(t.quaternion.quantized.data.buffer),b),b+=g,S>0&&t.harmonics&&t.harmonics.length>0)for(let M=0;M1){t.exports.sortIndexes(n,s,u,o,a,l,d.DepthMapRange,r);let I=new Uint32Array(r);D=I.buffer,I.set(new Uint32Array(c,l,r))}else if(r===1){let I=new Uint32Array(r);I[0]=new Uint32Array(c,n,e)[0],D=I.buffer}else D=new ArrayBuffer(0);i.postMessage({sortDone:!0,indexesBuffer:D},[D])}function v(C,P,D){let I=new Float32Array(c,s,e*3);r=0;let R=new Uint32Array(c,n,e);for(let U=0;UY.enabled&&Y.mode==="Include").map(Y=>Y.type==="Box"?A(Y):M(Y)),H=F.filter(Y=>Y.enabled&&Y.mode==="Exclude").map(Y=>Y.type==="Box"?A(Y):M(Y));for(let Y=D[U];YF.enabled&&F.mode==="Include").map(F=>F.type==="Box"?A(F):M(F)),R=P.filter(F=>F.enabled&&F.mode==="Exclude").map(F=>F.type==="Box"?A(F):M(F)),U=C.length;for(let F=0;F{let F=S(C,P,D,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?b(F.x,F.y,F.z,U):T(F.x,F.y,F.z,U)})}function S(C,P,D,I,R){let U=C-R[0],F=P-R[1],V=D-R[2],G=1/(I[3]*U+I[7]*F+I[11]*V+I[15]);return{x:(I[0]*U+I[4]*F+I[8]*V+I[12])*G+R[0],y:(I[1]*U+I[5]*F+I[9]*V+I[13])*G+R[1],z:(I[2]*U+I[6]*F+I[10]*V+I[14])*G+R[2]}}function A(C){let P=C.cropSize[0]/2,D=C.cropSize[1]/2,I=C.cropSize[2]/2,R=[C.cropCenter[0]-P,C.cropCenter[1]-D,C.cropCenter[2]-I,C.cropCenter[0]+P,C.cropCenter[1]+D,C.cropCenter[2]+I],U=E(C.cropRotation);return Object.assign(R,{invRotationMatrix:U,cropCenter:C.cropCenter})}function E(C){let P=[],D=C[0]*Math.PI/180,I=C[1]*Math.PI/180,R=C[2]*Math.PI/180,U=Math.cos(D),F=Math.sin(D),V=Math.cos(I),G=Math.sin(I),H=Math.cos(R),Y=Math.sin(R),k=U*H,j=U*Y,X=F*H,q=F*Y;return P[0]=V*H,P[1]=-V*Y,P[2]=G,P[4]=j+X*G,P[5]=k-q*G,P[6]=-F*V,P[8]=q-k*G,P[9]=X+j*G,P[10]=U*V,P[12]=0,P[13]=0,P[14]=0,P[3]=0,P[7]=0,P[11]=0,P[15]=1,P}function b(C,P,D,I){return C>=I[0]&&C<=I[3]&&P>=I[1]&&P<=I[4]&&D>=I[2]&&D<=I[5]}function M(C){let P=2/C.cropSize[0],D=2/C.cropSize[1],I=2/C.cropSize[2],R=E(C.cropRotation);return{invRadiusX:P,invRadiusY:D,invRadiusZ:I,cropCenter:C.cropCenter,invRotationMatrix:R}}function T(C,P,D,I){let R=(C-I.cropCenter[0])*I.invRadiusX,U=(P-I.cropCenter[1])*I.invRadiusY,F=(D-I.cropCenter[2])*I.invRadiusZ;return R*R+U*U+F*F<=1}i.onmessage=C=>{if(C.data.getCroppedIndexes){let P=new Uint32Array(x(new Float32Array(C.data.positions),C.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:P},[P])}else if(C.data.positions)h=C.data.positions,f=new Float32Array(h),m=C.data.meshMatrixWorlds,g=C.data.cropsArray,p=C.data.meshIndexIntervals,v(m,g,p),i.postMessage({sortSetupComplete:!0});else if(C.data.sort||C.data.newMatrixWorlds||C.data.newCropsArray)(C.data.newMatrixWorlds||C.data.newCropsArray)&&(g=C.data.newCropsArray||g,m=C.data.newMatrixWorlds||m,v(m,g,p)),y(C.data.sort.view,C.data.sort.cameraPosition);else if(C.data.init){d=C.data.init.Constants,e=C.data.init.splatCount;let P=d.BytesPerInt,D=d.BytesPerFloat*3,I=new Uint8Array(C.data.init.sorterWasmBytes),R=P+D,U=e*R,F=e*d.BytesPerInt*2+d.DepthMapRange*d.BytesPerInt*2,V=d.MemoryPageSize*32,G=U+F+V,H=Math.floor(G/d.MemoryPageSize)+1,Y={module:{},env:{memory:new WebAssembly.Memory({initial:H*2,maximum:H*3,shared:!0})}};WebAssembly.compile(I).then(k=>WebAssembly.instantiate(k,Y)).then(k=>{t=k,n=0,s=e*P,o=s+e*D,u=o+16*d.BytesPerFloat*2,a=u+e*d.BytesPerInt,l=a+d.DepthMapRange*d.BytesPerInt,c=Y.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function MR(i){let t=new Worker(URL.createObjectURL(new Blob(["(",H7.toString(),")(self)"],{type:"application/javascript"}))),e=atob(ER),r=new Uint8Array(e.length);for(let n=0;n + + attribute uint splatIndex; + + uniform highp sampler2D covariancesTexture; + uniform highp usampler2D centersColorsTexture; + uniform vec2 focal; + uniform vec2 viewport; + uniform vec2 basisViewport; + uniform vec2 covariancesTextureSize; + uniform vec2 centersColorsTextureSize; + uniform highp sampler2D meshMatrixWorldsTexture; + uniform uint meshIndexIntervals[257]; + uniform float orthoZoom; + + varying vec4 vColor; + varying vec2 vUv; + + varying vec2 vPosition; + + const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); + const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000)); + const uvec4 shift4 = uvec4(0, 8, 16, 24); + vec4 uintToRGBAVec (uint u) { + uvec4 urgba = mask4 & u; + urgba = urgba >> shift4; + vec4 rgba = vec4(urgba) * encodeNorm4; + return rgba; + } + + vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) { + vec2 samplerUV = vec2(0.0, 0.0); + float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x; + samplerUV.y = float(floor(d)) / dimensions.y; + samplerUV.x = fract(d); + return samplerUV; + } + + void main () { + uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize)); + vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba)); + vColor = uintToRGBAVec(sampledCenterColor.r); + + vPosition = position.xy * 2.0; + + uint meshIndex; + for (int i = 1; i < 257; i++) { + if (splatIndex < meshIndexIntervals[i]) { + meshIndex = uint(i - 1); + break; + } + } + + float strideMulmeshIndex = float(4u*meshIndex); + float meshMatrixWorldsTextureLength = float(256*4); + + mat4 modelMat = mat4( + texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)), + texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)), + texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)), + texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0)) + ); + mat4 modelViewMat = viewMatrix * modelMat; + vec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0); + vec4 clipCenter = projectionMatrix * viewCenter; + + vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg; + vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg; + vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg; + + vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r); + vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg); + + // Compute the 2D covariance matrix from the upper-right portion of the 3D covariance matrix + mat3 Vrk = mat3( + cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z, + cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y, + cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z + ); + float s = 1.0 / (viewCenter.z * viewCenter.z); + + mat3 W = transpose(mat3(modelViewMat)); + mat3 T = orthoZoom > 0.0 ? W : W * mat3( + focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s, + 0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s, + 0., 0., 0. + ); + mat3 cov2Dm = transpose(T) * Vrk * T; + cov2Dm[0][0] += 0.3; + cov2Dm[1][1] += 0.3; + + // We are interested in the upper-left 2x2 portion of the projected 3D covariance matrix because + // we only care about the X and Y values. We want the X-diagonal, cov2Dm[0][0], + // the Y-diagonal, cov2Dm[1][1], and the correlation between the two cov2Dm[0][1]. We don't + // need cov2Dm[1][0] because it is a symetric matrix. + vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]); + + vec3 ndcCenter = clipCenter.xyz / clipCenter.w; + + // We now need to solve for the eigen-values and eigen vectors of the 2D covariance matrix + // so that we can determine the 2D basis for the splat. This is done using the method described + // here: https://people.math.harvard.edu/~knill/teaching/math21b2004/exhibits/2dmatrices/index.html + // + // This is a different approach than in the original work at INRIA. In that work they compute the + // max extents of the 2D covariance matrix in screen space to form an axis aligned bounding rectangle + // which forms the geometry that is actually rasterized. They then use the inverse 2D covariance + // matrix (called 'conic') to determine fragment opacity. + float a = cov2Dv.x; + float d = cov2Dv.z; + float b = cov2Dv.y; + float D = a * d - b * b; + float trace = a + d; + float traceOver2 = 0.5 * trace; + float term2 = sqrt(trace * trace / 4.0 - D); + float eigenValue1 = traceOver2 + term2; + float eigenValue2 = max(traceOver2 - term2, 0.00); // prevent negative eigen value + + const float maxSplatSize = 1024.0; + vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a)); + // since the eigen vectors are orthogonal, we derive the second one from the first + vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x); + vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize); + vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize); + + vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport; + + if (orthoZoom > 0.0) { + ndcOffset *= orthoZoom; + } + + gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0); + }`,n=` + precision highp float; + #include + + uniform vec3 debugColor; + + varying vec4 vColor; + varying vec2 vUv; + + varying vec2 vPosition; + layout(location = 1) out vec4 gVelocity; + + void main () { + // compute the negative squared distance from the center of the splat to the + // current fragment in the splat's local space. + float A = -dot(vPosition, vPosition); + if (A < -4.0) discard; + vec3 color = vColor.rgb; + A = exp(A) * vColor.a; + gl_FragColor = vec4(color.rgb, A); + gVelocity = vec4(0.0); // so it is ignored by TAA + }`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new N},viewport:{type:"v2",value:new N},basisViewport:{type:"v2",value:new N},debugColor:{type:"v3",value:new Re},covariancesTextureSize:{type:"v2",value:new N(1024,1024)},centersColorsTextureSize:{type:"v2",value:new N(1024,1024)},orthoZoom:{type:"f",value:-1}};return new at({uniforms:s,vertexShader:r,fragmentShader:n,transparent:!0,alphaTest:1,blending:_a,depthTest:!0,depthWrite:!1,side:Ln})}static buildGeomtery(e){let r=new Ae;r.setIndex([0,1,2,0,2,3]);let n=new Float32Array(4*3),s=new Ge(n,3);r.setAttribute("position",s),s.setXYZ(0,-1,-1,0),s.setXYZ(1,-1,1,0),s.setXYZ(2,1,1,0),s.setXYZ(3,1,-1,0),s.needsUpdate=!0;let o=new Wf().copy(r),a=new Uint32Array(e),l=new uu(a,1,!1);return l.setUsage(rM),o.setAttribute("splatIndex",l),o.instanceCount=e,o}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(s=>s.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,n=0;for(let s of this.splatBuffers){let o=s.nsplats;this.colors.subarray(e,e+o*4).set(s.colorsA),e+=o*4,this.centers.subarray(r,r+o*3).set(s.decoded.xyz.denormDequant().data),r+=o*3,this.covariances.subarray(n,n+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),n+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let n=this.splatCount,s=new N(4096,1024);for(;s.x*s.y*20&&(N0.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(N0),this.material.uniforms.basisViewport.value.set(2/N0.x,2/N0.y),this.material.uniforms.focal.value.set(r,n),this.material.uniforms.orthoZoom.value=s,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose())}};var im=class{constructor(t={}){mn(this,"updateSplatMeshUniforms",function(){let t=new N;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());mn(this,"updateView",function(){let t=new ie,e=[],r=new _(0,0,-1),n=new _(0,0,-1),s=new _,o=new _;return function(a=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!a){n.set(0,0,-1).applyQuaternion(this.camera.quaternion);let h=!1,d=!1;if(n.dot(r)<=.95&&(h=!0),o.copy(this.camera.position).sub(s).length()>=1&&(d=!0),!h&&!d&&!l&&!u)return}s.copy(this.camera.position),r.copy(n),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new _().fromArray(t.position)),t.orientation&&(t.orientation=new He().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(o=>{if(o.data.type==="Splat"){let a=o.visible;o.traverseAncestors(l=>{a&&(a=l.visible)}),a&&e.push(o)}}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(o=>o.matrixWorld),this.meshMatrixWorldsOld=e.map(o=>o.matrixWorld.clone()),this.cropsArray=e.map(o=>o.data.crops.map(a=>a.data));let r=e.map(o=>new Al(new Uint8Array(o.data.buffer).buffer)),n=0,s=[0];for(let o of r)n+=o.getSplatCount(),s.push(n);return this.setupSplatMesh(r,n,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(n),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;ee.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((n,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=n.data):Object.entries(n.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,u)=>l!==this.cropsArray[r][s][o][u])?(t=!0,this.cropsArray[r][s][o]=a):a!==this.cropsArray[r][s]?.[o]&&(t=!0,this.cropsArray[r][s][o]=a)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new _,n=new He,s=!1,o=1,a,l){this.splatMesh=_l.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(n),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=MR(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var _0=new Ho;_0.wireframe=!0;var CR=new _,xl=class extends Nn{constructor(e,r){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new I0;this.errorPage=new Si("fdasfa",{...ea.defaultData,name:""});this.invisibleObjects=new ss("jflkdsafjasdifjaslk",{...Jy.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=QO(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=XO(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),n=this.entityIdentityToEntity[r];n&&(e.uuid=n.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Si&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let n=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);n.splice(0,0,a)}return{entity:r,sortKey:n}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push(s)}return r.sort((n,s)=>KC(n.sortKey,s.sortKey)),r.map(n=>n.entity)}nonExistOrDescendantOf(e,r){let n=this.find(e);if(n===void 0)return!0;for(;n;){if(n.uuid===r)return!0;n=n.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Qi)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,n,e.localIndex,r);s.updateVisible(),s.resetBBoxNeedsUpdate(),Yn(s)&&Xn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markToExpandCloner(n),n.resetBBoxNeedsUpdate(),this.unregisterObject(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(n),this.markPenumbraSizeDirty(),n.parent.remove(n),Xn(n.parent)&&(n.parent.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Yn(n)&&(n.freeBooleanPointer(),s instanceof is&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n instanceof bl&&n.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),this.pathConstraints.removeDependencies(n.uuid),n.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),n.cloner?.resetOnMove(),this.markToExpandCloner(n);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(n),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(n),n.invalidateClonerTransform(n),n.updateVisible(),n.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),Yn(n)&&(n.invalidateUpstreamBooleanData(),Xn(n.parent)?n.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof is&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Si&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,n,s){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:a}=r.props;r={...r,props:a},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let o=this.find(e);if(o)try{WO(o,r,n,{scene:this,shared:s}),o instanceof Qt&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let n=Object.entries(r.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(n,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{Xn(s)&&s.recomputeBoolean(),s instanceof er&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){lt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{lt.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,n,s,o,a,l){if(e){let u=s.find(e);u&&u!==s&&o.forInstancesRec(c=>{c.data=Ha(c.data,h=>{let d=h.events.data(l.id),f=c.goUp(a);if(f){let p=[...hy(f.identity),e].join("-"),m=this.entityIdentityToEntity[p];if(m){let g=m.uuid,y=Rr.zoom(d,r);y[n]=g}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,n,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Rs&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,n)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=Ha(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of Eh.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,n,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,n,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,n,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,n,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,n,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,n,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,n,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,n,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,n,s)})}),!0})}expandInstances(e,r,n){let s=new Set;this.traverseEntity(o=>{if(o instanceof Rs&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),n&&o.traverseEntity(a=>{n.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),C0(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Rs&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let n=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[n]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[n]),r.dispose()})}clearScene(){for(let e of this.children)lt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let n=[],s=o=>{for(let a of o.children){let l=a.cloner;if(lt.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let u=[];if(e.intersectObject(a,!0,u),u.length){let c=u[0];c.object=a,c.point.applyMatrix4(c.object.matrixWorld);let h=a.matrixWorld.clone().invert();c.point.applyMatrix4(h),n.push(c)}}else(Yn(a)||Jp(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,n),nm(a,e,n)),s(a)}};return s(this),n}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;lt.is(o)&&(o.visible||a?.object.data.visible)&&((Yn(o)||Jp(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),nm(o,e,r,!0)),n(o))}};return n(this),r}forEachEntity(e){for(let r of this.children)lt.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)lt.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)lt.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(n=>{if(n instanceof Qt&&n.data.type==="Mesh"&&n.data.geometry.type==="TextGeometry"&&n.data.geometry.font===e){let s=n.geometry,o=n.data.geometry;s.updateFont(e,r).then(()=>{s.update(o);let a=n.invalidateDownstreamBooleanData();Xn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)Uh.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)lt.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,n){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,n),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,n,s,o,a){let l={scene:this,shared:a},u=D0(e,r,l);return u&&(this.entityByUuid[e]=u,s.add(u),s.children.splice(o,0,s.children.pop()),n.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(n,u,a)),u.updateState(r,l),u instanceof Qt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let h=c.dataPatched;if(c instanceof Qt&&h.bones&&h.boneInverses){let d=h.bones.map(m=>this.find(m)),f=h.boneInverses.map(m=>new ie().fromArray(m)),p=new Pa(d,f);c.bind(p,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let s=0,o=e.length;s{if(r instanceof $t)if(Array.isArray(r.material))for(let n=0;n{s instanceof er&&s.setViewplaneSize(e,r,n)})}initializeSplatViewer(e){this.splatViewer=new im({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};var sm=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},PR=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return j7(Math.atan2(r,e))},DR=(i,t,e)=>{let r={x:0,y:0};return e=B0(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},B0=i=>i*(Math.PI/180),j7=i=>i*(180/Math.PI),IR=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,m1=new Map,g1=i=>{m1.has(i)&&clearTimeout(m1.get(i)),m1.set(i,setTimeout(i,100))},$d=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s{let r=t.split(/[ ,]+/g),n;for(let s=0;s(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),v1=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},k0=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},V0=(i,t,e)=>{let r=RR(i);for(let n in r)if(r.hasOwnProperty(n))if(typeof t=="string")r[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o{let e=RR(i);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},RR=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},z0=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},LR=(i,t)=>{let e={};for(let r in i)i.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:i.hasOwnProperty(r)&&(e[r]=i[r]);return e},om=(i,t)=>{if(i.length)for(let e=0,r=i.length;e({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(BR="ontouchstart"in window,FR=!!window.PointerEvent,kR=!!window.MSPointerEvent);var BR,FR,kR,am={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"}},ef,lm={};FR?ef=am.pointer:kR?ef=am.MSPointer:BR?(ef=am.touch,lm=am.mouse):ef=am.mouse;function Nc(){}Nc.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Nc.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;se&&t-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:n},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return i;(!u.x||!u.y)&&this.trigger("plain",i),u.x||this.trigger("plain:"+s,i),u.y||this.trigger("plain:"+o,i),u.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var VR=un;function Vr(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Vr.id,Vr.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Vr.prototype=new tf;Vr.constructor=Vr;Vr.id=0;Vr.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r