\n\n',t.children[0].style.cssText="\n width: 80%;\n height: 80%;\n stroke: #FFFFFF;\n backdrop-filter: drop-shadow(0 0 2px black);\n}\n ",this.divInteractive.appendChild(t),this.editBlock.push(t)})()}removeEditBlock(t){try{this.textContent&&this.divInteractive?.removeChild(this.textContent)}catch(A){}try{this.textContent&&this.divBlock?.appendChild(this.textContent)}catch(A){}this.edit&&(this.edit=!1,this.interactive.style.pointerEvents="",this.divInteractive.style.outline="",this.divInteractive.style.pointerEvents="none",this.divBlock.style.pointerEvents="auto",0!==this.editBlock.length&&(this.editBlock.forEach((t=>{try{this.divInteractive.removeChild(t)}catch(A){}this.editBlockListeners.length>0&&this.editBlockListeners.forEach((A=>{t.removeEventListener("mousedown",A),t.removeEventListener("mousemove",A)}))})),this.editBlock=[]))}setPointerEvents(t){this.divBlock.style.pointerEvents=t?"auto":"none"}onDelete(){this.ui.removeChild(this.divBlock),this.interactive.removeChild(this.divInteractive),this.removeCb&&this.removeCb(this.divBlock)}}class c{constructor(){__publicField(this,"listeners",[])}addDelegate(t){const A=new h(t);return this.listeners.push(A),A}addListener(t){this.listeners.push(t)}removeListeners(t){for(let A=0;A=t.tapToRedirect&&S.openGameStorePage(),k.isStart&&(t.mouseOrTouchActive=!1)}static mouseOrTouchMove(A){this.onTouchMove.Invoke(A),k.isStart&&t.mouseOrTouchActive}static generateClick(){this.mouseOrTouchDown(new MouseEvent("mousedown"))}};__publicField(C,"touchUpCount",0),__publicField(C,"firstClicked",!1),__publicField(C,"mouseOrTouchActive",!1),__publicField(C,"tapToRedirect",null),__publicField(C,"touchDevice"),__publicField(C,"onTouchDown",new c),__publicField(C,"onTouchMove",new c),__publicField(C,"onTouchUp",new c);let u=C;var m,E,p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},B={},Q=(m||(m=1,E=B,function(){var t=function(){this.init()};t.prototype={init:function(){var t=this||A;return t._counter=1e3,t._html5AudioPool=[],t.html5PoolSize=10,t._codecs={},t._howls=[],t._muted=!1,t._volume=1,t._canPlayEvent="canplaythrough",t._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,t.masterGain=null,t.noAudio=!1,t.usingWebAudio=!0,t.autoSuspend=!0,t.ctx=null,t.autoUnlock=!0,t._setup(),t},volume:function(t){var e=this||A;if(t=parseFloat(t),e.ctx||I(),void 0!==t&&t>=0&&t<=1){if(e._volume=t,e._muted)return e;e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t,A.ctx.currentTime);for(var i=0;i=0;e--)t._howls[e].unload();return t.usingWebAudio&&t.ctx&&void 0!==t.ctx.close&&(t.ctx.close(),t.ctx=null,I()),t},codecs:function(t){return(this||A)._codecs[t.replace(/^x-/,"")]},_setup:function(){var t=this||A;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(e){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||A,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(l){return t}if(!e||"function"!=typeof e.canPlayType)return t;var i=e.canPlayType("audio/mpeg;").replace(/^no$/,""),n=t._navigator?t._navigator.userAgent:"",s=n.match(/OPR\/(\d+)/g),o=s&&parseInt(s[0].split("/")[1],10)<33,r=-1!==n.indexOf("Safari")&&-1===n.indexOf("Chrome"),a=n.match(/Version\/(.*?) /),I=r&&a&&parseInt(a[1],10)<15;return t._codecs={mp3:!(o||!i&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!i,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(I||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(I||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var t=this||A;if(!t._audioUnlocked&&t.ctx){t._audioUnlocked=!1,t.autoUnlock=!1,t._mobileUnloaded||44100===t.ctx.sampleRate||(t._mobileUnloaded=!0,t.unload()),t._scratchBuffer=t.ctx.createBuffer(1,1,22050);var e=function(A){for(;t._html5AudioPool.length0?r._seek:i._sprite[t][0]/1e3),l=Math.max(0,(i._sprite[t][0]+i._sprite[t][1])/1e3-I),g=1e3*l/Math.abs(r._rate),c=i._sprite[t][0]/1e3,d=(i._sprite[t][0]+i._sprite[t][1])/1e3;r._sprite=t,r._ended=!1;var h=function(){r._paused=!1,r._seek=I,r._start=c,r._stop=d,r._loop=!(!r._loop&&!i._sprite[t][2])};if(!(I>=d)){var C=r._node;if(i._webAudio){var u=function(){i._playLock=!1,h(),i._refreshBuffer(r);var t=r._muted||i._muted?0:r._volume;C.gain.setValueAtTime(t,A.ctx.currentTime),r._playStart=A.ctx.currentTime,void 0===C.bufferSource.start?r._loop?C.bufferSource.noteGrainOn(0,I,86400):C.bufferSource.noteGrainOn(0,I,l):r._loop?C.bufferSource.start(0,I,86400):C.bufferSource.start(0,I,l),g!==1/0&&(i._endTimers[r._id]=setTimeout(i._ended.bind(i,r),g)),e||setTimeout((function(){i._emit("play",r._id),i._loadQueue()}),0)};"running"===A.state&&"interrupted"!==A.ctx.state?u():(i._playLock=!0,i.once("resume",u),i._clearTimer(r._id))}else{var m=function(){C.currentTime=I,C.muted=r._muted||i._muted||A._muted||C.muted,C.volume=r._volume*A.volume(),C.playbackRate=r._rate;try{var n=C.play();if(n&&"undefined"!=typeof Promise&&(n instanceof Promise||"function"==typeof n.then)?(i._playLock=!0,h(),n.then((function(){i._playLock=!1,C._unlocked=!0,e?i._loadQueue():i._emit("play",r._id)})).catch((function(){i._playLock=!1,i._emit("playerror",r._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."),r._ended=!0,r._paused=!0}))):e||(i._playLock=!1,h(),i._emit("play",r._id)),C.playbackRate=r._rate,C.paused)return void i._emit("playerror",r._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.");"__default"!==t||r._loop?i._endTimers[r._id]=setTimeout(i._ended.bind(i,r),g):(i._endTimers[r._id]=function(){i._ended(r),C.removeEventListener("ended",i._endTimers[r._id],!1)},C.addEventListener("ended",i._endTimers[r._id],!1))}catch(s){i._emit("playerror",r._id,s)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===C.src&&(C.src=i._src,C.load());var E=window&&window.ejecta||!C.readyState&&A._navigator.isCocoonJS;if(C.readyState>=3||E)m();else{i._playLock=!0,i._state="loading";var p=function(){i._state="loaded",m(),C.removeEventListener(A._canPlayEvent,p,!1)};C.addEventListener(A._canPlayEvent,p,!1),i._clearTimer(r._id)}}return r._id}i._ended(r)},pause:function(t){var A=this;if("loaded"!==A._state||A._playLock)return A._queue.push({event:"pause",action:function(){A.pause(t)}}),A;for(var e=A._getSoundIds(t),i=0;i=0?e=parseInt(s[0],10):t=parseFloat(s[0]):s.length>=2&&(t=parseFloat(s[0]),e=parseInt(s[1],10)),!(void 0!==t&&t>=0&&t<=1))return(i=e?n._soundById(e):n._sounds[0])?i._volume:0;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"volume",action:function(){n.volume.apply(n,s)}}),n;void 0===e&&(n._volume=t),e=n._getSoundIds(e);for(var o=0;o0?i/I:i),g=Date.now();t._fadeTo=e,t._interval=setInterval((function(){var n=(Date.now()-g)/i;g=Date.now(),r+=a*n,r=Math.round(100*r)/100,r=a<0?Math.max(e,r):Math.min(e,r),o._webAudio?t._volume=r:o.volume(r,t._id,!0),s&&(o._volume=r),(eA&&r>=e)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,o.volume(e,t._id),o._emit("fade",t._id))}),l)},_stopFade:function(t){var e=this,i=e._soundById(t);return i&&i._interval&&(e._webAudio&&i._node.gain.cancelScheduledValues(A.ctx.currentTime),clearInterval(i._interval),i._interval=null,e.volume(i._fadeTo,t),i._fadeTo=null,e._emit("fade",t)),e},loop:function(){var t,A,e,i=this,n=arguments;if(0===n.length)return i._loop;if(1===n.length){if("boolean"!=typeof n[0])return!!(e=i._soundById(parseInt(n[0],10)))&&e._loop;t=n[0],i._loop=t}else 2===n.length&&(t=n[0],A=parseInt(n[1],10));for(var s=i._getSoundIds(A),o=0;o=0?e=parseInt(s[0],10):t=parseFloat(s[0]):2===s.length&&(t=parseFloat(s[0]),e=parseInt(s[1],10)),"number"!=typeof t)return(i=n._soundById(e))?i._rate:n._rate;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"rate",action:function(){n.rate.apply(n,s)}}),n;void 0===e&&(n._rate=t),e=n._getSoundIds(e);for(var o=0;o=0?e=parseInt(n[0],10):i._sounds.length&&(e=i._sounds[0]._id,t=parseFloat(n[0])):2===n.length&&(t=parseFloat(n[0]),e=parseInt(n[1],10)),void 0===e)return 0;if("number"==typeof t&&("loaded"!==i._state||i._playLock))return i._queue.push({event:"seek",action:function(){i.seek.apply(i,n)}}),i;var s=i._soundById(e);if(s){if(!("number"==typeof t&&t>=0)){if(i._webAudio){var o=i.playing(e)?A.ctx.currentTime-s._playStart:0,r=s._rateSeek?s._rateSeek-s._seek:0;return s._seek+(r+o*Math.abs(s._rate))}return s._node.currentTime}var a=i.playing(e);a&&i.pause(e,!0),s._seek=t,s._ended=!1,i._clearTimer(e),i._webAudio||!s._node||isNaN(s._node.duration)||(s._node.currentTime=t);var I=function(){a&&i.play(e,!0),i._emit("seek",e)};if(a&&!i._webAudio){var l=function(){i._playLock?setTimeout(l,0):I()};setTimeout(l,0)}else I()}return i},playing:function(t){var A=this;if("number"==typeof t){var e=A._soundById(t);return!!e&&!e._paused}for(var i=0;i=0&&A._howls.splice(s,1);var o=!0;for(i=0;i=0){o=!1;break}return n&&o&&delete n[t._src],A.noAudio=!1,t._state="unloaded",t._sounds=[],t=null,null},on:function(t,A,e,i){var n=this["_on"+t];return"function"==typeof A&&n.push(i?{id:e,fn:A,once:i}:{id:e,fn:A}),this},off:function(t,A,e){var i=this,n=i["_on"+t],s=0;if("number"==typeof A&&(e=A,A=null),A||e)for(s=0;s=0;s--)n[s].id&&n[s].id!==A&&"load"!==t||(setTimeout(function(t){t.call(this,A,e)}.bind(i,n[s].fn),0),n[s].once&&i.off(t,n[s].fn,n[s].id));return i._loadQueue(t),i},_loadQueue:function(t){var A=this;if(A._queue.length>0){var e=A._queue[0];e.event===t&&(A._queue.shift(),A._loadQueue()),t||e.action()}return A},_ended:function(t){var e=this,i=t._sprite;if(!e._webAudio&&t._node&&!t._node.paused&&!t._node.ended&&t._node.currentTime=0;i--){if(e<=A)return;t._sounds[i]._ended&&(t._webAudio&&t._sounds[i]._node&&t._sounds[i]._node.disconnect(0),t._sounds.splice(i,1),e--)}}},_getSoundIds:function(t){if(void 0===t){for(var A=[],e=0;e=0;if(!t.bufferSource)return this;if(A._scratchBuffer&&t.bufferSource&&(t.bufferSource.onended=null,t.bufferSource.disconnect(0),e))try{t.bufferSource.buffer=A._scratchBuffer}catch(i){}return t.bufferSource=null,this},_clearSound:function(t){/MSIE |Trident\//.test(A._navigator&&A._navigator.userAgent)||(t.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var i=function(t){this._parent=t,this.init()};i.prototype={init:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++A._counter,e._sounds.push(t),t.create(),t},create:function(){var t=this,e=t._parent,i=A._muted||t._muted||t._parent._muted?0:t._volume;return e._webAudio?(t._node=void 0===A.ctx.createGain?A.ctx.createGainNode():A.ctx.createGain(),t._node.gain.setValueAtTime(i,A.ctx.currentTime),t._node.paused=!0,t._node.connect(A.masterGain)):A.noAudio||(t._node=A._obtainHtml5Audio(),t._errorFn=t._errorListener.bind(t),t._node.addEventListener("error",t._errorFn,!1),t._loadFn=t._loadListener.bind(t),t._node.addEventListener(A._canPlayEvent,t._loadFn,!1),t._endFn=t._endListener.bind(t),t._node.addEventListener("ended",t._endFn,!1),t._node.src=e._src,t._node.preload=!0===e._preload?"auto":e._preload,t._node.volume=i*A.volume(),t._node.load()),t},reset:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._rateSeek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++A._counter,t},_errorListener:function(){var t=this;t._parent._emit("loaderror",t._id,t._node.error?t._node.error.code:0),t._node.removeEventListener("error",t._errorFn,!1)},_loadListener:function(){var t=this,e=t._parent;e._duration=Math.ceil(10*t._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),t._node.removeEventListener(A._canPlayEvent,t._loadFn,!1)},_endListener:function(){var t=this,A=t._parent;A._duration===1/0&&(A._duration=Math.ceil(10*t._node.duration)/10,A._sprite.__default[1]===1/0&&(A._sprite.__default[1]=1e3*A._duration),A._ended(t)),t._node.removeEventListener("ended",t._endFn,!1)}};var n={},s=function(t){var A=t._src;if(n[A])return t._duration=n[A].duration,void a(t);if(/^data:[^;]+;base64,/.test(A)){for(var e=atob(A.split(",")[1]),i=new Uint8Array(e.length),s=0;s0?(n[e._src]=t,a(e,t)):i()};"undefined"!=typeof Promise&&1===A.ctx.decodeAudioData.length?A.ctx.decodeAudioData(t).then(s).catch(i):A.ctx.decodeAudioData(t,s,i)},a=function(t,A){A&&!t._duration&&(t._duration=A.duration),0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue())},I=function(){if(A.usingWebAudio){try{"undefined"!=typeof AudioContext?A.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?A.ctx=new webkitAudioContext:A.usingWebAudio=!1}catch(s){A.usingWebAudio=!1}A.ctx||(A.usingWebAudio=!1);var t=/iP(hone|od|ad)/.test(A._navigator&&A._navigator.platform),e=A._navigator&&A._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),i=e?parseInt(e[1],10):null;if(t&&i&&i<9){var n=/safari/.test(A._navigator&&A._navigator.userAgent.toLowerCase());A._navigator&&!n&&(A.usingWebAudio=!1)}A.usingWebAudio&&(A.masterGain=void 0===A.ctx.createGain?A.ctx.createGainNode():A.ctx.createGain(),A.masterGain.gain.setValueAtTime(A._muted?0:A._volume,A.ctx.currentTime),A.masterGain.connect(A.ctx.destination)),A._setup()}};E.Howler=A,E.Howl=e,void 0!==p?(p.HowlerGlobal=t,p.Howler=A,p.Howl=e,p.Sound=i):"undefined"!=typeof window&&(window.HowlerGlobal=t,window.Howler=A,window.Howl=e,window.Sound=i)}(),
/*!
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
*
* howler.js v2.2.4
* howlerjs.com
*
* (c) 2013-2020, James Simpson of GoldFire Studios
* goldfirestudios.com
*
* MIT License
*/
function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var A=this;if(!A.ctx||!A.ctx.listener)return A;for(var e=A._howls.length-1;e>=0;e--)A._howls[e].stereo(t);return A},HowlerGlobal.prototype.pos=function(t,A,e){var i=this;return i.ctx&&i.ctx.listener?(A="number"!=typeof A?i._pos[1]:A,e="number"!=typeof e?i._pos[2]:e,"number"!=typeof t?i._pos:(i._pos=[t,A,e],void 0!==i.ctx.listener.positionX?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]),i)):i},HowlerGlobal.prototype.orientation=function(t,A,e,i,n,s){var o=this;if(!o.ctx||!o.ctx.listener)return o;var r=o._orientation;return A="number"!=typeof A?r[1]:A,e="number"!=typeof e?r[2]:e,i="number"!=typeof i?r[3]:i,n="number"!=typeof n?r[4]:n,s="number"!=typeof s?r[5]:s,"number"!=typeof t?r:(o._orientation=[t,A,e,i,n,s],void 0!==o.ctx.listener.forwardX?(o.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),o.ctx.listener.forwardY.setTargetAtTime(A,Howler.ctx.currentTime,.1),o.ctx.listener.forwardZ.setTargetAtTime(e,Howler.ctx.currentTime,.1),o.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),o.ctx.listener.upY.setTargetAtTime(n,Howler.ctx.currentTime,.1),o.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):o.ctx.listener.setOrientation(t,A,e,i,n,s),o)},Howl.prototype.init=function(t){return function(A){var e=this;return e._orientation=A.orientation||[1,0,0],e._stereo=A.stereo||null,e._pos=A.pos||null,e._pannerAttr={coneInnerAngle:void 0!==A.coneInnerAngle?A.coneInnerAngle:360,coneOuterAngle:void 0!==A.coneOuterAngle?A.coneOuterAngle:360,coneOuterGain:void 0!==A.coneOuterGain?A.coneOuterGain:0,distanceModel:void 0!==A.distanceModel?A.distanceModel:"inverse",maxDistance:void 0!==A.maxDistance?A.maxDistance:1e4,panningModel:void 0!==A.panningModel?A.panningModel:"HRTF",refDistance:void 0!==A.refDistance?A.refDistance:1,rolloffFactor:void 0!==A.rolloffFactor?A.rolloffFactor:1},e._onstereo=A.onstereo?[{fn:A.onstereo}]:[],e._onpos=A.onpos?[{fn:A.onpos}]:[],e._onorientation=A.onorientation?[{fn:A.onorientation}]:[],t.call(this,A)}}(Howl.prototype.init),Howl.prototype.stereo=function(A,e){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"stereo",action:function(){i.stereo(A,e)}}),i;var n=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===e){if("number"!=typeof A)return i._stereo;i._stereo=A,i._pos=[A,0,0]}for(var s=i._getSoundIds(e),o=0;othis._setLoadRandom()),2e3)}static _setStyle(){}static update(){this.setNewIcon()}static _setLoadRandom(){const t=this.previewPercent>100?1:this.previewPercent+10*(Math.random()+1);this.previewPercent=t,this.setLoader(t)}static setNewIcon(){const t=k.getValue("loader","icon");this.loaderIcon&&(this.defImg||(this.defImg=this.loaderIcon.src),this.loaderIcon.src=t||this.defImg||"")}}__publicField(M,"loader"),__publicField(M,"loaderBox"),__publicField(M,"loaderIcon"),__publicField(M,"intervalLoader"),__publicField(M,"previewPercent"),__publicField(M,"defImg",null);class V{static handleRequestComplete(){this.completedRequests++,this.percentLoaded=100*Math.floor((this.numDownloadFiles+1)/this.completedRequests),M.setLoader(this.percentLoaded),(this.completedRequests===this.numDownloadFiles&&!window.isStarted||0===this.numDownloadFiles)&&(this.onloadCb(),this.isLoaded=!0,window.isStarted=!0)}static loadResources({resources:t},A){!0!==this.isLoaded?(this.convertResources=t,this.onloadCb=A,this.numDownloadFiles=this.convertResources.reduce(((t,A)=>A?.resources?.length?(t+=A?.resources?.length,t):t),0),this.percentLoaded=Math.floor(100/(this.numDownloadFiles+1)),M.setLoader(this.percentLoaded),this.resolveResources(),0===this.numDownloadFiles&&this.handleRequestComplete()):console.error("Resources are already loaded!")}static async resolveResources(){this.convertResources.forEach((({type:t,resources:A,loader:e})=>{t in this.resources||(this.resources[t]={}),A.forEach((A=>{if("value"in A)this.loadResource(t,A.name,A.value,e);else if("values"in A&&"category"in A&&A.category&&Array.isArray(A.values)){const i=A.values[k.config?.[A.category][A.name]];this.loadResource(t,A.name,i,e)}}))}))}static loadResource(t,A,e,i){if(i){const n="string"==typeof e?e:e[0];let s=[void 0];Array.isArray(e)&&e.length>1&&(s=[...e],s.shift()),i(n,...s).then((e=>{this.setResource(t,A,e)})).catch((t=>{console.error(t)}))}else this.setResource(t,A,e)}static setResource(t,A,e){this.resources?.[t]||(this.resources[t]={}),this.resources[t][A]=e,this.isLoaded||this.handleRequestComplete()}static getResource(t,A){if(this.resources){if(this.resources[t])return this.resources[t][A];console.error('No "name" resource:',A)}else console.error('No "type" resource:',t)}static deleteResource(t,A){t in this.resources?A in this.resources[t]?delete this.resources[t][A]:console.error("This resource name does not exist:",A):console.error("This resource type does not exist:",t)}}__publicField(V,"convertResources",[]),__publicField(V,"isLoaded",!1),__publicField(V,"resources",{}),__publicField(V,"percentLoaded",0),__publicField(V,"completedRequests",0),__publicField(V,"onloadCb",(()=>{})),__publicField(V,"numDownloadFiles",0);const y=class t{constructor(){__publicField(this,"onUpdate",new c)}static get Instance(){return t.instance||(t.instance=new t),this.instance}update(t){this.onUpdate.Invoke(t)}};__publicField(y,"instance");let w=y;class f{constructor({element:t,category:A,variable:e={}}){__publicField(this,"element"),__publicField(this,"category"),__publicField(this,"variable"),this.element=t,this.category=A,this.variable=e,this._setStyleToComponent()}_setStyleToComponent(){const t=k.getCategory(this.category),{variable:A,element:e}=this;Object.entries(A).forEach((([A,i])=>{switch(A){case"backgroundColor":(!this.variable?.backgroundColorAlpha||Number(t[this.variable.backgroundColorAlpha])>0)&&(e.style.backgroundColor=o(t[i],this.variable?.backgroundColorAlpha?Number(t[this.variable.backgroundColorAlpha]):100));break;case"bounceSize":if(this.variable.bounceSize&&1!==Number(t[this.variable.bounceSize])){let A=-1;for(let t=0;t-1&&document.styleSheets[0].deleteRule(A),document.styleSheets[0].insertRule(`\n @keyframes bounceAnimation_${this.variable.bounceSize} {\n 0% {transform: scale(1); }\n 50% { transform: scale(${Number(t[this.variable.bounceSize])}); }\n 100% {transform: scale(1); }\n }\n`,0),e.style.animation=`${this.variable.bounceTime?Number(t[this.variable.bounceTime]):800}ms bounceAnimation_${this.variable.bounceSize} infinite ease-in-out`}else{let t=-1;for(let A=0;A-1&&document.styleSheets[0].deleteRule(t)}break;case"backgroundGradientColors":const A=this.variable.backgroundGradientAngle?Number(t[this.variable.backgroundGradientAngle]):0;let n="";t[this.variable.backgroundGradientColors].forEach(((t,A)=>{n+=`, ${t.replace("0x","#")}`})),e.style.background=`linear-gradient(${A}deg ${n})`}}))}update(){this._setStyleToComponent()}}class R{static ticker(){const t=performance.now(),A=(t-this.lastTime)/1e3;return this.lastTime=t,A}static resize(){const{portrait:t,width:A,height:e}=window.screenSize,{type:i,scale:n,offsetX:s,offsetY:o}=k.getValue("video_options","videoScale")[t?"portrait":"landscape"],r=document.querySelector("#videoPlayable"),a=document.querySelector("#ui"),I=document.querySelector("#editor");if(!r)return;const{clientWidth:l,clientHeight:g}=r;let c=n||1,d=l,h=g;switch(i){case"minFit":break;case"contain":c*=A/e>l/g?e/g:A/l;break;case"cover":c*=A/e>l/g?A/l:e/g}d=l*c,h=g*c,r.style.transform=`scale(${c}) translate(${s}%, ${o}%)`,a.style.width=`${d}px`,a.style.height=`${h}px`,I.style.width=`${d}px`,I.style.height=`${h}px`}}__publicField(R,"lastTime",performance.now());const N=class t{static setUpdateStateVideoCb(t){this.updateStateVideoCb||(this.updateStateVideoCb=t)}static setUpdateCurrentStepCb(t){this.updateCurrentStepCb||(this.updateCurrentStepCb=t)}static init(){console.log("!!!!!!!!!VideoC INIT");const A=k.getVideoOptions();window.setVideoFile=this.setVideoFile,this.steps=A?A.steps:[],this.state="pause";const e=document.querySelector("#interactive");this.interactive=e;const i=document.querySelector("#ui");if(!i)throw new Error("No ui!");this.ui=i;const n=document.querySelector("#constructor");if(!n)throw new Error("No constructor!");this.constr=n,this.customStyleBackdrop=new f({element:this.constr,category:"backdrop",variable:{backgroundColor:"backdrop_color"}}),this.playable=document.createElement("video"),this.playable.id="videoPlayable",this.playable.setAttribute("muted","true"),this.playable.setAttribute("playsinline","true"),this.playable.setAttribute("crossorigin","anonymous"),this.playable.setAttribute("preload","auto"),this.source=document.createElement("source"),this.playable.appendChild(this.source);const s=V.getResource("video","main");this.source.setAttribute("type","video/mp4"),s&&(this.source.src=s,this.playable.load(),setTimeout((()=>{R.resize(),M.disableLoader()}),300)),this.constr.insertAdjacentElement("afterbegin",this.playable);const o=document.querySelector(".bannerHolder");o&&document.body.removeChild(o),u.onTouchDown.addDelegate((()=>{console.log("onTouchDown"),this.nextStep()})),this.playable.addEventListener("ended",this.ended.bind(this)),this.delegateId=w.Instance.onUpdate.addDelegate((()=>{this.tickerUpdate()}));const r=k.getValue("videoOptions","playbackRate");void 0!==r?this.setPlaybackRate(r):this.setPlaybackRate(1);const a=k.getCategory("sounds");a.upload_background_music&&"upload"===a?.music_source&&(V.setResource("sounds","newBackground",a.upload_background_music),v.playBackground("newBackground",Number(a.background_volume)/100)),v.updateGlobalute(),this.start(),setTimeout((()=>{this.disableVideoBackdrop(),this.disableImageBackdrop(),this.updateBackdropStyle(),v.updateGlobalute()}),200),k.updateVariableConfig.addDelegate((([A,e,i])=>{switch(console.log("VideoC updateConfig"),A){case"videoOptions":"playbackRate"===e&&"number"==typeof i&&this.setPlaybackRate(i);break;case"backdrop":switch(e){case"backdrop_color":t.customStyleBackdrop.update();break;case"backdrop_type":case"backdrop_image":t.updateBackdropStyle()}break;case"sounds":switch(e){case"global_volume":v.setVolume(i/100);break;case"music_source":"upload"!==i&&v.destroyBackground(),v.updateGlobalute()}}}))}static updateBackdropStyle(){const{backdrop_type:t,backdrop_image:A}=k.getCategory("backdrop");"video"===t?(this.backdrop="video",this.enableVideoBackdrop(),this.disableImageBackdrop()):"image"===t&&A?(this.backdrop=A,this.disableImageBackdrop(),this.disableVideoBackdrop(),this.enableImageBackdrop()):(this.backdrop=null,this.disableVideoBackdrop(),this.disableImageBackdrop())}static enableVideoBackdrop(){if(!this.backdropVideoPlayer)if(this.filter=document.createElement("div"),this.filter.style.cssText="\n position: fixed;\n inset: -10px;\n z-index: -1;\n -webkit-backdrop-filter: blur(30px) brightness(50%);\n backdrop-filter: blur(30px) brightness(50%);\n pointer-events: none;\n ",this.constr.appendChild(this.filter),this.backdropVideoPlayer=this.playable.cloneNode(!0),this.backdropVideoPlayer.style.cssText="\n position: fixed;\n inset: 0px;\n z-index: -2;\n object-fit: cover;\n width: 100%;\n height: 100%;\n pointer-events: none;\n}\n \n ",this.constr.appendChild(this.backdropVideoPlayer),this.backdropVideoPlayer.playbackRate=this.playable.playbackRate,this.backdropVideoPlayer.id="backdropVideo","play"===this.state){console.log("play",this.state);const t=this.backdropVideoPlayer.play();void 0!==t&&t.then((()=>{this.backdropVideoPlayer&&(this.backdropVideoPlayer.currentTime=this.playable.currentTime)})).catch((t=>{console.error("error play"),console.log("errorPlayPromise: "+t)}))}else this.backdropVideoPlayer?.pause()}static disableVideoBackdrop(){this.backdropVideoPlayer&&this.constr.removeChild(this.backdropVideoPlayer),this.backdropVideoPlayer=null,this.filter&&this.constr.removeChild(this.filter),this.filter=null}static enableImageBackdrop(){!this.backdropImage&&"video"!==this.backdrop&&this.backdrop&&(this.backdropImage=document.createElement("img"),this.backdropImage.style.cssText="\n position: fixed;\n inset: 0px;\n width: 100%;\n height: 100%;\n z-index: -1;\n pointer-events: none;\n object-fit: cover;\n\n ",this.backdropImage.src=this.backdrop,this.constr.appendChild(this.backdropImage))}static disableImageBackdrop(){this.backdropImage&&this.constr.removeChild(this.backdropImage),this.backdropImage=null}static ended(){null!==this.delegateId&&w.Instance.onUpdate.removeListeners(this.delegateId);try{this.updateStateVideoCb&&this.updateStateVideoCb("pause")}catch(t){}this.endGame=!0,this.showEndCard(),k.end()}static start(){console.log("start meow");const t=setInterval((()=>{if(this.playable.readyState>0)if(this.editMode)clearInterval(t);else{this.playable.muted=!0;const A=this.playable.play();void 0!==A&&A.then((()=>{this.editMode,clearInterval(t),this.state="play"})).catch((t=>{console.error("error play"),console.log("errorPlayPromise: "+t)}))}}),50)}static setCurrentTime(t){this.playable.currentTime=t,this.backdropVideoPlayer&&(this.backdropVideoPlayer.currentTime=t),this.pause(),this.loopPlay=!1,clearInterval(this.intervalRewind),this.backplay=!1,this.currentStep=null,this.endGame=!1;let A=0;this.steps.length>0&&this.steps.map((t=>t.time[0])).forEach(((e,i)=>{et.time[0])).indexOf(t.time[0]);this.currentStepNum=A,this.showCurrentStep()}}static play(){return this.playable.play().then((()=>{this.state="play",this.backdropVideoPlayer&&(this.backdropVideoPlayer.muted=!0),this.backdropVideoPlayer&&this.backdropVideoPlayer.play();try{this.updateStateVideoCb&&this.updateStateVideoCb("play")}catch(t){}}))}static pause(){this.playable.pause(),this.backdropVideoPlayer&&this.backdropVideoPlayer.pause(),this.state="pause";try{this.updateStateVideoCb&&this.updateStateVideoCb("pause")}catch(t){}}static updateSteps(t){k.setValue("video_options","steps",t),this.steps=t}static setPlaybackRate(t){t&&"number"==typeof t&&(this.playable.playbackRate=t,this.backdropVideoPlayer&&(this.backdropVideoPlayer.playbackRate=t))}static nextStep(){if(!this.editMode){if("video"===k.getValue("sounds","music_source")&&this.playable.muted&&(this.playable.muted=!1),this.loopPlay=!1,this.endGame)this.showEndCard(),k.end();else{if(!this.currentStep)return;this.currentStep.options.redirect&&k.end();const t=this.currentStep&&"type"in this.currentStep?this.currentStep.type:null;this.stepObjects.forEach((t=>{t.destroy()})),this.stepObjects=[],this.currentStepNum++,"loop"===t?(this.loopPlay=!1,clearInterval(this.intervalRewind),this.backplay=!1):"freeze"===t&&this.play()}this.currentStep=null}}static showEndCard(){console.log("endgame")}static mute(){this.playable&&(this.playable.muted=!0)}static unMute(){this.playable&&(this.playable.muted=!1)}static changeVolume(t){this.playable&&(isNaN(t)&&(t=1),this.playable.volume=t)}static showCurrentStep(){if(this.editMode||this.currentStep)return;const t=k.getCategory("video_options");t&&0!==t.steps.length&&(console.log("video_options",t),this.currentStep=t.steps[this.currentStepNum],console.log("this.currentStep",this.currentStep),0!==this.currentStep?.components.length&&this.currentStep.components.forEach(((t,A)=>{t&&this.stepObjects.push(new g(t,this.ui,{zIndex:A}))})))}static tickerUpdate(){if(!this.playable.paused)if(this.endGame)this.showEndCard();else{const A=k.getCategory("video_options");if(A?.components&&A.components.length>0&&!this.editMode&&A.components.forEach(((t,A)=>{t&&0!==t.length&&t.forEach((t=>{const e=this.activeBlocks.map((t=>t.uiBlock)).includes(t.block);if(this.playable.currentTime>=t.time[0]&&this.playable.currentTime<=t.time[1]){if(!e){const e=new g(t.block,this.ui,{zIndex:A});this.activeBlocks.push(e)}}else if(e){const A=this.activeBlocks.map((t=>t.uiBlock)).indexOf(t.block);this.activeBlocks[A].destroy(),this.activeBlocks.splice(A,1)}}))})),!this.steps[this.currentStepNum])return;const{type:e,time:i,options:n}=this.steps[this.currentStepNum];if("freeze"===e&&1===i.length&&i[0]){if(this.playable.currentTime>=i[0]){this.pause(),this.showCurrentStep(),console.log("this.currentStepNum",this.currentStepNum),console.log("this.steps[this.currentStepNum]",this.steps[this.currentStepNum]);try{this.updateCurrentStepCb&&this.updateCurrentStepCb(this.currentStepNum)}catch(t){}}}else if("loop"===e&&2===i.length&&i[0]&&i[1]&&this.playable.currentTime>=i[0]){const A=30;if(!this.loopPlay){this.showCurrentStep();try{this.updateCurrentStepCb&&this.updateCurrentStepCb(this.currentStepNum)}catch(t){}}!this.loopPlay&&(this.loopPlay=!0),n?.cyclic?this.playable.currentTime>=i[1]&&(this.playable.currentTime=i[0],this.backdropVideoPlayer&&(this.backdropVideoPlayer.currentTime=i[0])):this.playable.currentTime>=i[1]&&(this.backplay=!0,this.playable.pause(),this.intervalRewind=setInterval((()=>{this.playable.currentTime<=i[0]?(clearInterval(this.intervalRewind),this.backplay=!1,this.playable.play()):"play"===this.state&&this.backplay&&(this.playable.currentTime-=1/A,this.backdropVideoPlayer&&(this.backdropVideoPlayer.currentTime=this.playable.currentTime))}),1e3/A))}}}static setEditMode(t){this.editMode=t}static setVideoFile(A){console.log("setVideoFile",A.slice(0,200)),A&&0!==A.trim().length&&t.source&&(console.log("!!!!!!!ssssssssssssssssssssssssssssssssssssssssssss"),V.setResource("video","main",A),t.source.src=V.getResource("video","main"),t.playable.load(),setTimeout((()=>{R.resize(),M.disableLoader(),t.disableImageBackdrop(),t.disableVideoBackdrop(),t.updateBackdropStyle()}),200))}static updateScreenScale(){R.resize()}};__publicField(N,"playable"),__publicField(N,"interactive",null),__publicField(N,"constr"),__publicField(N,"steps"),__publicField(N,"currentStep",null),__publicField(N,"currentStepNum",0),__publicField(N,"endGame",!1),__publicField(N,"editMode",!1),__publicField(N,"stepObjects",[]),__publicField(N,"backplay",!1),__publicField(N,"state"),__publicField(N,"loopPlay",!1),__publicField(N,"intervalRewind"),__publicField(N,"backdrop",null),__publicField(N,"backdropVideoPlayer",null),__publicField(N,"filter",null),__publicField(N,"backdropImage",null),__publicField(N,"activeBlocks",[]),__publicField(N,"ui"),__publicField(N,"source"),__publicField(N,"customStyleBackdrop"),__publicField(N,"delegateId"),__publicField(N,"updateStateVideoCb",null),__publicField(N,"updateCurrentStepCb",null);let b=N;const U=class t{static init(){if(this.initialized)return void console.error("Sound is already inited!");this.volume=1,this.backgroundMusic=null;const t=k.getCategory("sounds");if(!t)throw new Error("No sounds in config");this.setVolume(Number(t.global_volume)/100),this.mute&&this.setMute(!0),t.upload_background_music?(V.setResource("sounds","newBackground",t.upload_background_music),this.playBackground("newBackground",Number(t.background_volume)/100)):V.getResource("sounds","background")&&this.playBackground("background",Number(t.background_volume)/100),this.initialized=!0}static playBackground(t,A=1){this.backgroundMusic=this.playSound(t,{loop:!0,volume:A})}static destroyBackground(){this.backgroundMusic&&(this.backgroundMusic.stop(),this.backgroundMusic.unload(),this.backgroundMusic=null)}static playSound(t,A={}){const{loop:e=!1,volume:i=1,onEnd:n}=A;let s=new Q.Howl({src:V.getResource("sounds",t),volume:this.volume*i,loop:e,onplayerror:function(){s.once("unlock",(function(){s.play()}))},onend:n});return s.play(),s}static setVolume(t){return this.volume=t,Q.Howler.volume(t),b.changeVolume(t),this.getVolume()}static getVolume(){return this.volume}static setMute(t){return console.log("setMute",t),this.mute=t,Q.Howler.mute(this.mute),window.onMuteCallback&&window.onMuteCallback(this.mute),t?b.mute():b.unMute(),this.mute}static getMute(){return window.onMuteCallback&&window.onMuteCallback(this.mute),this.mute}static updateGlobalute(){"none"===k.getValue("sounds","music_source")?this.setMute(!0):"upload"===k.getValue("sounds","music_source")?(Q.Howler.mute(!1),b.mute()):"upload"===k.getValue("sounds","music_source")&&(Q.Howler.mute(!0),b.unMute())}static updateConfig(A,e){switch(console.log("SoundC updateConfig"),A){case"global_volume":"number"==typeof e&&this.setVolume(e/100);break;case"background_volume":"number"==typeof e&&this.backgroundMusic?.volume(e/100);break;case"upload_background_music":e?(this.destroyBackground(),V.setResource("sounds","newBackground",e),t.playBackground("newBackground",Number(k.getValue("sounds","background_volume"))/100)):(this.destroyBackground(),V.deleteResource("sounds","newBackground"),V.getResource("sounds","background")&&this.playBackground("background",Number(k.getValue("sounds","background_volume"))/100))}}};__publicField(U,"volume"),__publicField(U,"initialized",!1),__publicField(U,"backgroundMusic"),__publicField(U,"mute",!1);let v=U;class S{static init({redirect:t,network:e},i){this.isAndroid=!!/android/i.test(navigator.userAgent||navigator.vendor);const n={android:"",ios:""};t?("string"==typeof t.android&&(n.android=t.android),"string"==typeof t.ios&&(n.ios=t.ios),""!==n.android.trim()&&""!==n.ios.trim()||console.warn("BAD CONFIG: urls are empty")):console.error("BAD CONFIG: 'redirect' parameter not found."),this.gameStoreLink=n,this.network=e,window.addEventListener("resize",this.rotate.bind(this)),this.initScreenSize((()=>{if((this.network&&this.network.added_api)===A.mraid){const t=window.mraid.getState();console.log("mraid.getState first:",t),"loading"===t?window.mraid.addEventListener("ready",Z):Z()}!1===this.gameInit&&(i(),this.gameInit=!0),this.network?.added_api||k.start(),this.updateScreenScale()}))}static setTimeoutToRedirect(){null!==this.timeToRedirect&&setTimeout(this.redirectClick,1e3*this.timeToRedirect)}static initScreenSize(t){const A=setInterval((()=>{this.setScreenSize(),console.log("window.screenSize",window.screenSize),window.screenSize&&0!==window.screenSize.width&&0!==window.screenSize.height?(console.log("API_SetScreensSize, success interval"),clearInterval(A),this.validScreenSizeIsSet=!0,t()):console.log("API_SetScreensSize, skip interval")}),50)}static setScreenSize(t){let e={};this.network?.added_api===A.mraid?window.mraid&&window.mraid.getMaxSize&&(e=window.mraid.getMaxSize()):(this.network,A.dapi);const i=e.width||window.innerWidth,n=e.height||window.innerHeight;window.screenSize={width:i,height:n,resolution:window.devicePixelRatio,portrait:n>i},t&&t(),this.currentOrientation=window.screenSize.portrait}static rotate(){!1!==this.validScreenSizeIsSet&&this.network?.added_api!=A.dapi&&this.network?.added_api!=A.mraid&&this.setScreenSize(this.updateScreenScale)}static updateScreenScale(){const{portrait:t,width:A,height:e}=window.screenSize,i=t?A:e,n=t?e:A;let s=1;s*=A/e>i/n?e/n:A/i,document.querySelector("html").style.fontSize=n*s*.1+"px",k.resizeScreen()}static gameIsReady(){this.network?.added_api===A.mobvista&&window.gameReady&&window.gameReady()}static gameIsEnded(){this.network?.added_api===A.mobvista&&window.gameEnd&&window.gameEnd()}static redirectClick(){u.tapToRedirect=u.touchUpCount,window.dispatchEvent(new Event("mouseup"))}static openGameStorePage(){console.log("!!!redirect!!!");const t=this.isAndroid;window.openStorePage(t?this.gameStoreLink.android:this.gameStoreLink.ios)}}function T(t){t.hasOwnProperty("volume")?S.isAudioEnabled=!!t.volume:S.isAudioEnabled=!!t,v.setMute(!S.isAudioEnabled)}function D(t,A){t?(t.hasOwnProperty("width")?(window.screenSize.width=t.width,window.screenSize.height=t.height,window.screenSize.portrait=t.height>t.width):(window.screenSize.width=t,window.screenSize.height=A,window.screenSize.portrait=A>t),S.updateScreenScale()):S.setScreenSize(S.updateScreenScale)}function x(t){t&&k.start(),v.setMute(!t)}function Z(){window.mraid.addEventListener("viewableChange",x),window.mraid.addEventListener("sizeChange",D),window.mraid.addEventListener("audioVolumeChange",T);const t=setInterval((()=>{window.mraid.isViewable()&&(clearInterval(t),k.start())}),50)}__publicField(S,"timeToRedirect",null),__publicField(S,"gameInit",!1),__publicField(S,"gameStoreLink"),__publicField(S,"isAndroid"),__publicField(S,"validScreenSizeIsSet",!1),__publicField(S,"network"),__publicField(S,"isAudioEnabled",!0),__publicField(S,"currentOrientation",null),window.switchMute=t=>{v.setMute(t)};class J{constructor(t,A,e,i,n){this.name=t,this.foreground=A,this.background=e,this.msRefresh=i,this.refreshCallback=n,this.data=[],this._min=1/0,this._max=0,this.lastTime=0,this.pixelRatio=Math.round(devicePixelRatio||1),this.width=100*this.pixelRatio,this.height=60*this.pixelRatio,this.text={position:{x:3*this.pixelRatio,y:2*this.pixelRatio}},this.graph={position:{x:3*this.pixelRatio,y:18*this.pixelRatio},size:{width:94*this.pixelRatio,height:40*this.pixelRatio}},this.canvas=document.createElement("canvas"),this.canvas.width=this.width,this.canvas.height=this.height,this.canvas.style.width="100px",this.canvas.style.height="60px",this.canvas.style.borderRadius="5px",this.context=this.canvas.getContext("2d"),this.init(),this.dom=this.canvas}get min(){return this._min}get max(){return this._max}init(){if(!this.context)return;const t=12*this.pixelRatio;this.context.font=`400 ${t}px "Avenir Next", Helvetica, "Helvetica Neue", Arial, sans-serif`,this.context.textBaseline="top",this.context.fillStyle=this.background,this.context.fillRect(0,0,this.width,this.height),this.context.fillStyle=this.foreground,this.context.fillText(this.name,this.text.position.x,this.text.position.y)}update(t){const A=t-this.lastTime;if(Athis.graph.size.width&&this.data.splice(0,this.data.length-this.graph.size.width),this.context){this.context.fillStyle=this.background,this.context.globalAlpha=1,this.context.fillRect(0,0,this.width,this.height),this.context.fillStyle=this.foreground,this.context.fillText(`${Math.round(i)} ${this.name} (${Math.round(this._min)}-${Math.round(this._max)})`,this.text.position.x,this.text.position.y),this.context.beginPath(),this.context.moveTo(this.data.length+this.graph.position.x,(1-this.data[this.data.length-1]/s)*this.graph.size.height+this.graph.position.y);for(let t=this.data.length-1;t>0;t--){const A=t-.5+this.graph.position.x,e=t=>(1-t/s)*this.graph.size.height+this.graph.position.y,i=e(this.data[t]),n=e(this.data[t-1]);this.context.bezierCurveTo(A,i,A,n,t-1+this.graph.position.x,n)}this.context.strokeStyle=this.foreground,this.context.stroke()}}}class F{constructor(){this.mode=0,this.dom=document.createElement("div"),this.panels=[],this.background="#ffffff",this.initStyle(),this.dom.addEventListener("click",(t=>{t.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)}),!1),this.beginTime=(performance||Date).now(),this.frames=0,this.panels.push(this.addPanel("FPS","#4080f0",100,((t,A)=>{const e={value:1e3*this.frames/A,maxValue:100};return this.frames=0,e}))),this.panels.push(this.addPanel("MS","#33A033",0,(t=>({value:t-this.beginTime,maxValue:200})))),performance&&performance.memory&&this.panels.push(this.addPanel("MB","#ff0088",100,(()=>{if(!performance||!performance.memory)return;const t=performance.memory,A=1048576;return{value:t.usedJSHeapSize/A,maxValue:t.jsHeapSizeLimit/A}}))),this.showPanel(0)}addPanel(t,A,e,i){const n=new J(t,A,this.background,e,i);return this.addPanelObject(n),n}showPanel(t){for(let A=0;A{this.updateStyle()};(null==t?void 0:t.addEventListener)?null==t||t.addEventListener("change",A):(null==t?void 0:t.addListener)&&(null==t||t.addListener(A)),this.updateStyle()}updateStyle(){var t;const A="undefined"!=typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):void 0,e=null!==(t=null==A?void 0:A.matches)&&void 0!==t&&t;this.dom.style.position="fixed",this.dom.style.top="5px",this.dom.style.left="5px",this.dom.style.cursor="pointer",this.dom.style.opacity="0.9",this.dom.style.zIndex="10000",this.dom.style.borderRadius="5px",e?(this.background="#000000",this.dom.style.boxShadow="-4px -4px 10px 0 rgb(255, 255, 255, 0.7)"):(this.background="#ffffff",this.dom.style.boxShadow="-4px -4px 10px 0 rgb(0, 0, 0, 0.7)");for(const i of this.panels)i.background=this.background}}var G,j={exports:{}},L=j.exports,Y=(G||(G=1,function(t,A){function e(){const t=["endCurrentSession","function","baseURL","newCustomEvent","string","getBaseEventObject","set","newCustomEventWithNumber","getFullEventObject","DNS","getCountryCode","newCustomEventWithString","true","appKey","parse","toString","getStringFromJSONDictionary","getTime","getRandomValues","next","ByteBrew: Initialization Failed. Please provide all the required parameters.","ByteBrew: Stopping Tracking","onBeforeUnload","status","create","platform","object","unsafeStringify","5680nGxFLt","ByteBrewWebRequestor","ByteBrew: Remote configurations retrieved","No Response","remoteConfigURL","user","number","Invalid UUID","RemoteConfigHandler","randomUUID","ByteBrew: Custom Event Sent Successfully","3541604RdYkGx","0123456789abcdef","ByteBrewSDK","expires","ByteBrew Exception: Failed to retrieve remote configs","getScreenResolution","language","loadRemoteConfigs","sendUserEvent","error","createNewUserEvent","newCustomEventWithJSONDictionary","trunc","push","application/json;charset=UTF-8","ByteBrew","URL","setRemoteConfigs","hasSuccessfullyInitialized","ByteBrew: Custom Event Failed to Send: Status ","cookie","setUserHasInitializedSuccessfullyCookie","beforeunload","sendRequest","crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported","sdkVersion","startNewSession","length","hasBeenInitializedWhilePageOpen","application/json","version","ByteBrew: Reinitalizing ByteBrew","initializeByteBrew","userID","new_user","validate","get","charCodeAt","ByteBrewCore","getTrackingSettingsCookie","freeze","nsecs","toLowerCase","sessionID","NIL","replace","Stringified UUID is invalid","ByteBrew Exception: ","join","clockseq","360eAqeXK","userHasInitializedSuccessfullyCookieKey","msecs","189559PwkjcO","__importDefault","getAndCompareUserHasInitializedSuccessfullyCookie","sessionStartTime","tryGetUserIDFromCookie","stringify","default","split","appVersion","exports","isArray","isByteBrewInitialized","prototype","ByteBrew: Starting New Session","__awaiter","sendRemoteConfigRequest","createUserEvent","137568aCjVoI","test","random","2372nsuKXw","write","ByteBrew: Ending Current Session","toUTCString","ByteBrew: Creating New User Event","ByteBrew: Creating User Event","session_key","rng","isTrackingEnabled","bb_tr_on","cors","converter","setTrackingSettingsCookie","bb_u_id","ByteBrew: Tracking is disabled. Not initializing.","undefined","has","floor","read","false","sendCustomEvent","hasRemoteConfigsBeenSet","entries","text","canSendData",'{"name":"bytebrew-web-sdk","version":"1.0.1","description":"Official ByteBrew Web SDK","main":"./dist/ByteBrewSDK.js","types":"./dist/types/ByteBrew.d.ts","files":["dist"],"keywords":["bytebrew","analytics"],"scripts":{"build":"node distPreBuild.js && tsc -p tsconfig.dist.json && webpack --config webpack.dist.config.js && node distPostBuild.js && npm pack"},"author":"ByteBrew (https://github.com/ByteBrewIO)","license":"MIT","homepage":"https://github.com/ByteBrewIO/bytebrew-web-sdk","bugs":{"url":"https://github.com/ByteBrewIO/bytebrew-web-sdk/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"@babel/preset-env":"^7.22.14","@types/js-cookie":"^3.0.3","@types/uuid":"^9.0.2","babel-loader":"^9.1.3","webpack":"^5.88.2","webpack-cli":"^5.1.4","webpack-obfuscator":"^3.5.1"},"dependencies":{"js-cookie":"^3.0.5","ts-loader":"^9.5.1","uuid":"^9.0.0"}}',"ByteBrew: Sending Custom Event: ","ceil","charAt","call","then","33014AgVMdy","sendBasicRequest","ByteBrew: Initialization Failed! No session key was included in the response","BrowserEventListeners","36LmFMDh","stopTracking","country","ByteBrew: Initialization Complete","onInitializationSuccessful","ByteBrew Exception: Failed to parse remote configs","https://web-platform.bytebrew.io/api/game/configurations/remote/","https://web-platform.bytebrew.io/api/game/logs/add","restartTracking","GET","isInitialized","hasUserInitialized","log","slice","ByteBrewCookieManager","attributes","appID","amd","game_close","ByteBrew: Initializing event listeners","getUserID","sessionKey","1865020DDsLvl","remoteConfigs","reinitializeByteBrew","initializeEventListeners","assign","__esModule","trackingEnabled","apply","7GgjDKo","2628012VEOcOU","trackingSettingsIDCookieKey","27oGCOzI","innerWidth","defineProperty","bind","createNewUserCookieAndReturnID","userIDCookieKey","ByteBrew: Initialization Failed! Couldn't get session key from ByteBrew: Status ","retreiveRemoteConfigValue","value","now"];return(e=function(){return t})()}function i(t,A){const n=e();return(i=function(t,A){return n[t-=212]})(t,A)}(function(t){const A=i,e=t();for(;;)try{if(368192==parseInt(A(328))/1+parseInt(A(379))/2*(-parseInt(A(226))/3)+parseInt(A(348))/4*(parseInt(A(264))/5)+parseInt(A(224))/6*(-parseInt(A(223))/7)+-parseInt(A(345))/8*(parseInt(A(325))/9)+-parseInt(A(215))/10+-parseInt(A(275))/11*(-parseInt(A(383))/12))break;e.push(e.shift())}catch(n){e.push(e.shift())}})(e),function(e,n){const s=i;"object"==s(262)&&"object"==s(262)?t[s(337)]=n():"undefined"==s(237)&&(void 0)[s(400)]?(void 0)("ByteBrewSDK",[],n):"object"==s(262)?A[s(277)]=n():e[s(277)]=n()}(L,(()=>(()=>{var t={646:function(t){t[i(337)]=function(){function t(t){const A=i;for(var e=1;e{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(382)]=void 0;const s=e(284);class o{static[n(218)](){const t=n;console[t(395)](t(212)),window.addEventListener(t(297),o[t(258)])}static onBeforeUnload(){const t=n;s[t(313)][t(236)]()}}A[n(382)]=o},719:(t,A,e)=>{const n=i;Object.defineProperty(A,"__esModule",{value:!0}),A[n(290)]=void 0;const s=e(284),o=e(878);A[n(290)]=class{static[n(307)](t,A,e){const i=n;s.ByteBrewCore[i(307)](t,A,e)}static[n(339)](){const t=n;return s[t(313)][t(393)]}static[n(239)](t,A){const e=n;void 0===A?s.ByteBrewCore[e(239)](t):e(240)==typeof A?s.ByteBrewCore[e(247)](t,A):e(270)==typeof A?s[e(313)][e(243)](t,A):e(262)==typeof A&&s[e(313)][e(286)](t,A)}static loadRemoteConfigs(t){const A=n;o.RemoteConfigHandler[A(282)](t)}static[n(233)](t,A){const e=n;return o[e(272)][e(233)](t,A)}static[n(369)](){const t=n;return o[t(272)][t(369)]()}static[n(391)](){const t=n;s[t(313)][t(391)]()}static[n(384)](){const t=n;s[t(313)][t(384)]()}static[n(213)](){return s.ByteBrewCore.userID}}},441:function(t,A,e){const n=i;var s=this&&this[n(329)]||function(t){return t&&t[n(220)]?t:{default:t}};Object[n(228)](A,n(220),{value:!0}),A[n(397)]=void 0;const o=s(e(646)),r=e(429);class a{static[n(332)](){const t=n,A=o[t(334)][t(311)](a[t(231)]);return A?{userID:A,isNewUser:!1,hasSuccessfullyInitialized:a[t(394)]()}:{userID:a.createNewUserCookieAndReturnID(),isNewUser:!0,hasSuccessfullyInitialized:!1}}static[n(230)](){const t=n,A=(0,r.v4)();return o.default[t(242)](a[t(231)],A,{expires:365}),A}static setTrackingSettingsCookie(t){const A=n,e=A(t?248:367);o[A(334)].set(a[A(225)],e,{expires:365})}static[n(314)](){const t=n,A=o[t(334)][t(311)](a.trackingSettingsIDCookieKey);return!A||"true"===A}static[n(356)](){return a.getTrackingSettingsCookie()}static setUserHasInitializedSuccessfullyCookie(){const t=n,A=o.default[t(311)](a[t(231)]);A&&o.default[t(242)](a.userHasInitializedSuccessfullyCookieKey,A,{expires:365})}static[n(330)](){const t=n,A=o[t(334)][t(311)](a[t(326)]),e=o[t(334)][t(311)](a[t(231)]);return!(!A||!e)&&A===e}static hasUserInitialized(){return a[n(330)]()}}A.ByteBrewCookieManager=a,a.userIDCookieKey=n(361),a.trackingSettingsIDCookieKey=n(357),a[n(326)]="bb_u_h_init"},284:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(313)]=void 0;const s=e(441),o=e(797),r=e(334),a=e(429),I=e(147);class l{static[n(246)](){const t=n;let A=navigator[t(281)][t(335)]("-");return A.length<2?"??":A[A.length-1]||"??"}static[n(307)](t,A,e){const i=n;if(l[i(393)])return;if(console[i(395)]("ByteBrew: Starting Initialization"),!t||!A)return void console.log(i(256));if(l[i(221)]=s[i(397)][i(356)](),!l.trackingEnabled)return void console[i(395)](i(362));l[i(399)]=t,l[i(249)]=A,l[i(336)]=e,l.sessionID=(0,a.v4)(),l.sessionKey="",l[i(300)]=I[i(305)],l.language=navigator[i(281)],l[i(385)]=l[i(246)]();const o=s[i(397)][i(332)]();l[i(308)]=o[i(308)],o.isNewUser||!o[i(293)]?l.createNewUserEvent():l[i(344)](),l[i(331)]=new Date,r[i(382)][i(218)]()}static reinitializeByteBrew(){const t=n;console[t(395)](t(306)),l.initializeByteBrew(l[t(399)],l[t(249)],l[t(336)])}static[n(387)](t){const A=n;l[A(214)]=t,l[A(393)]=!0,l.hasBeenInitializedWhilePageOpen=!0,s[A(397)][A(296)](),console[A(395)](A(386))}static[n(301)](){const t=n;l[t(303)]&&(console.log(t(341)),this[t(217)]())}static[n(372)](){return l[n(393)]&&l.trackingEnabled}static getScreenResolution(){return window[n(227)]+"x"+window.innerHeight}static[n(241)](){const t=n;return{game_id:l[t(399)],user_id:l[t(308)],session_id:l[t(318)],session_key:l.sessionKey,platform:l.platform}}static[n(244)](){const t=n;return Object[t(219)](Object[t(219)]({},l[t(241)]()),{version_number:l[t(336)],sdk_version:l[t(300)],deviceScreenSize:l[t(280)](),tracking_enabled:l[t(221)]})}static[n(283)](t,A){const e=n;o.ByteBrewWebRequestor[e(380)](t,A).then((t=>{const A=e;if(t&&t.ok){const e=t.headers.get(A(354));e?l.onInitializationSuccessful(e):console[A(395)](A(381))}else console[A(395)](A(232)+(t?t[A(259)]:"No Response"))}))}static createUserEvent(){const t=n;if(!l[t(221)])return;console.log(t(353));let A={eventType:"game_open",userLocale:l[t(281)]};const e=Object[t(219)](Object[t(219)]({},l[t(244)]()),{category:t(269),geo:l[t(385)],externalData:A});l[t(283)](o.ByteBrewWebRequestor[t(238)],e)}static[n(285)](){const t=n;if(!l[t(221)])return;console[t(395)](t(352));let A={eventType:t(309),userLocale:l[t(281)]};const e=Object.assign(Object.assign({},l.getFullEventObject()),{category:t(269),geo:l[t(385)],externalData:A});l[t(283)](o[t(265)][t(238)],e)}static endCurrentSession(){const t=n;if(!l[t(372)]())return;l[t(393)]=!1,console.log(t(350));const A=new Date;let e={sessionLength:Math[t(287)]((A[t(253)]()-l[t(331)].getTime())/1e3)[t(251)]()};const i=Object[t(219)](Object[t(219)]({},l[t(244)]()),{category:t(401),externalData:e});o.ByteBrewWebRequestor[t(380)](o[t(265)][t(238)],i)}static[n(252)](t){const A=n;let e="";if(!t)return e;for(const[i,n]of Object.entries(t))e+=i+"="+n+";";return e[A(302)]>0&&(e=e[A(396)](0,-1)),e}static[n(368)](t,A){const e=n;if(!l.canSendData())return;console[e(395)](e(374)+t);let i={eventType:t};A&&(i=Object.assign(Object[e(219)]({},i),{value:"object"==typeof A?l[e(252)](A):A[e(251)]()}));const s=Object[e(219)](Object[e(219)]({},l[e(244)]()),{category:"custom",externalData:i});o.ByteBrewWebRequestor[e(380)](o[e(265)][e(238)],s)[e(378)]((t=>{const A=e;t&&t.ok?console.log(A(274)):console[A(395)](A(294)+(t?t.status:A(267)))}))}static[n(239)](t){l[n(368)](t,null)}static[n(247)](t,A){l.sendCustomEvent(t,A)}static newCustomEventWithNumber(t,A){l.sendCustomEvent(t,A)}static[n(286)](t,A){l[n(368)](t,A)}static[n(391)](){const t=n;console[t(395)]("ByteBrew: Restarting Tracking"),l[t(221)]=!0,s[t(397)][t(360)](!0),l[t(217)]()}static[n(384)](){const t=n;console[t(395)](t(257)),l[t(221)]=!1,s.ByteBrewCookieManager[t(360)](!1)}}A[n(313)]=l,l[n(393)]=!1,l[n(303)]=!1,l[n(261)]="Web"},797:function(t,A,e){const n=i;var s=this&&this[n(342)]||function(t,A,e,n){return new(e||(e=Promise))((function(s,o){const r=i;function a(t){try{l(n.next(t))}catch(A){o(A)}}function I(t){try{l(n.throw(t))}catch(A){o(A)}}function l(t){const A=i;var n;t.done?s(t.value):(n=t[A(234)],n instanceof e?n:new e((function(t){t(n)})))[A(378)](a,I)}l((n=n[r(222)](t,A||[]))[r(255)]())}))};Object[n(228)](A,n(220),{value:!0}),A[n(265)]=void 0;const o=e(284);class r{static sendBasicRequest(t,A){return s(this,void 0,void 0,(function*(){const e=i;try{const i={method:"POST",mode:e(358),headers:{Accept:e(304),"Content-Type":e(289),"sdk-key":o[e(313)][e(249)]},body:JSON.stringify(A),keepalive:!0};return yield r[e(298)](t,i)}catch(n){console[e(284)](n)}}))}static[n(343)](t){return s(this,void 0,void 0,(function*(){const A=i;try{const e={method:A(392),mode:"cors",headers:{Accept:A(304),"Content-Type":"application/json;charset=UTF-8","sdk-key":o[A(313)][A(249)],user_id:o[A(313)][A(308)]}};return yield r[A(298)](t,e)}catch(e){console[A(284)](e)}}))}static[n(298)](t,A){return s(this,void 0,void 0,(function*(){const e=i;try{const i=yield fetch(t,A);return i.ok||console[e(284)]("Request failed with status "+i[e(259)]),i}catch(n){console[e(284)](n)}}))}}A.ByteBrewWebRequestor=r,r[n(238)]=n(390),r[n(268)]=n(389)},878:(t,A,e)=>{const n=i;Object.defineProperty(A,n(220),{value:!0}),A[n(272)]=void 0;const s=e(284),o=e(797);class r{static[n(292)](t){r.remoteConfigs=t}static hasRemoteConfigsBeenSet(){return!!r[n(216)]}static loadRemoteConfigs(t){const A=n;o[A(265)][A(343)](o[A(265)][A(268)]+s[A(313)].appID)[A(378)]((e=>{const i=A;e&&e.ok?e[i(371)]()[i(378)]((A=>{const e=i;let n=null;try{n=new Map(Object[e(370)](JSON[e(250)](A))),console[e(395)](e(266))}catch(s){n=null,console[e(284)](e(388))}finally{r[e(292)](n),n&&t(n)}})):e?console.error(i(322)+(e?e[i(259)]:i(267))+" "+(e?e.statusText:"")):console[i(284)](i(279))}))}static[n(233)](t,A){const e=n;return r[e(369)]()&&r.remoteConfigs[e(364)](t)?r[e(216)][e(311)](t):A}}A[n(272)]=r,r[n(216)]=null},429:(t,A,e)=>{const n=i;Object.defineProperty(A,n(220),{value:!0}),Object[n(228)](A,n(319),{enumerable:!0,get:function(){return I[n(334)]}}),Object[n(228)](A,n(250),{enumerable:!0,get:function(){return d.default}}),Object[n(228)](A,n(333),{enumerable:!0,get:function(){return c[n(334)]}}),Object.defineProperty(A,"v1",{enumerable:!0,get:function(){return s[n(334)]}}),Object[n(228)](A,"v3",{enumerable:!0,get:function(){return o[n(334)]}}),Object[n(228)](A,"v4",{enumerable:!0,get:function(){return r[n(334)]}}),Object[n(228)](A,"v5",{enumerable:!0,get:function(){return a[n(334)]}}),Object.defineProperty(A,n(310),{enumerable:!0,get:function(){return g[n(334)]}}),Object[n(228)](A,"version",{enumerable:!0,get:function(){return l[n(334)]}});var s=h(e(990)),o=h(e(237)),r=h(e(355)),a=h(e(764)),I=h(e(314)),l=h(e(464)),g=h(e(435)),c=h(e(8)),d=h(e(222));function h(t){return t&&t[n(220)]?t:{default:t}}},163:(t,A)=>{const e=i;function n(t){return 14+(t+64>>>9<<4)+1}function s(t,A){const e=(65535&t)+(65535&A);return(t>>16)+(A>>16)+(e>>16)<<16|65535&e}function o(t,A,e,i,n,o){return s((r=s(s(A,t),s(i,o)))<<(a=n)|r>>>32-a,e);var r,a}function r(t,A,e,i,n,s,r){return o(A&e|~A&i,t,A,n,s,r)}function a(t,A,e,i,n,s,r){return o(A&i|e&~i,t,A,n,s,r)}function I(t,A,e,i,n,s,r){return o(A^e^i,t,A,n,s,r)}function l(t,A,e,i,n,s,r){return o(e^(A|~i),t,A,n,s,r)}Object.defineProperty(A,e(220),{value:!0}),A[e(334)]=void 0,A.default=function(t){const A=e;if(A(240)==typeof t){const e=unescape(encodeURIComponent(t));t=new Uint8Array(e[A(302)]);for(let i=0;i>5]>>>A%32&255,o=parseInt(s[e(376)](n>>>4&15)+s[e(376)](15&n),16);i[e(288)](o)}return i}(function(t,e){const i=A;t[e>>5]|=128<>5]|=(255&t[A/8])<{const e=i;Object[e(228)](A,e(220),{value:!0}),A[e(334)]=void 0;var n={randomUUID:e(363)!=typeof crypto&&crypto[e(273)]&&crypto[e(273)][e(229)](crypto)};A.default=n},314:(t,A)=>{const e=i;Object[e(228)](A,"__esModule",{value:!0}),A.default=void 0,A[e(334)]="00000000-0000-0000-0000-000000000000"},222:(t,A,e)=>{const n=i;Object.defineProperty(A,n(220),{value:!0}),A[n(334)]=void 0;var s,o=(s=e(435))&&s.__esModule?s:{default:s};A[n(334)]=function(t){const A=n;if(!(0,o.default)(t))throw TypeError(A(271));let e;const i=new Uint8Array(16);return i[0]=(e=parseInt(t[A(396)](0,8),16))>>>24,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i[4]=(e=parseInt(t[A(396)](9,13),16))>>>8,i[5]=255&e,i[6]=(e=parseInt(t[A(396)](14,18),16))>>>8,i[7]=255&e,i[8]=(e=parseInt(t[A(396)](19,23),16))>>>8,i[9]=255&e,i[10]=(e=parseInt(t[A(396)](24,36),16))/1099511627776&255,i[11]=e/4294967296&255,i[12]=e>>>24&255,i[13]=e>>>16&255,i[14]=e>>>8&255,i[15]=255&e,i}},58:(t,A)=>{const e=i;Object[e(228)](A,"__esModule",{value:!0}),A[e(334)]=void 0,A[e(334)]=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},319:(t,A)=>{const e=i;let n;Object[e(228)](A,"__esModule",{value:!0}),A[e(334)]=function(){const t=e;if(!n&&(n="undefined"!=typeof crypto&&crypto[t(254)]&&crypto.getRandomValues.bind(crypto),!n))throw new Error(t(299));return n(s)};const s=new Uint8Array(16)},757:(t,A)=>{const e=i;function n(t,A,e,i){switch(t){case 0:return A&e^~A&i;case 1:case 3:return A^e^i;case 2:return A&e^A&i^e&i}}function s(t,A){return t<>>32-A}Object.defineProperty(A,e(220),{value:!0}),A[e(334)]=void 0,A[e(334)]=function(t){const A=e,i=[1518500249,1859775393,2400959708,3395469782],o=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){const e=unescape(encodeURIComponent(t));t=[];for(let i=0;i>>0;c=g,g=l,l=s(a,30)>>>0,a=r,r=I}o[0]=o[0]+r>>>0,o[1]=o[1]+a>>>0,o[2]=o[2]+l>>>0,o[3]=o[3]+g>>>0,o[4]=o[4]+c>>>0}return[o[0]>>24&255,o[0]>>16&255,o[0]>>8&255,255&o[0],o[1]>>24&255,o[1]>>16&255,o[1]>>8&255,255&o[1],o[2]>>24&255,o[2]>>16&255,o[2]>>8&255,255&o[2],o[3]>>24&255,o[3]>>16&255,o[3]>>8&255,255&o[3],o[4]>>24&255,o[4]>>16&255,o[4]>>8&255,255&o[4]]}},8:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(334)]=void 0,A[n(263)]=a;var s,o=(s=e(435))&&s[n(220)]?s:{default:s};const r=[];for(let i=0;i<256;++i)r[n(288)]((i+256)[n(251)](16)[n(396)](1));function a(t,A=0){const e=n;return(r[t[A+0]]+r[t[A+1]]+r[t[A+2]]+r[t[A+3]]+"-"+r[t[A+4]]+r[t[A+5]]+"-"+r[t[A+6]]+r[t[A+7]]+"-"+r[t[A+8]]+r[t[A+9]]+"-"+r[t[A+10]]+r[t[A+11]]+r[t[A+12]]+r[t[A+13]]+r[t[A+14]]+r[t[A+15]])[e(317)]()}A[n(334)]=function(t,A=0){const e=n,i=a(t,A);if(!(0,o.default)(i))throw TypeError(e(321));return i}},990:(t,A,e)=>{const n=i;Object.defineProperty(A,"__esModule",{value:!0}),A[n(334)]=void 0;var s,o=(s=e(319))&&s[n(220)]?s:{default:s},r=e(8);let a,I,l=0,g=0;A[n(334)]=function(t,A,e){const i=n;let s=A&&e||0;const c=A||new Array(16);let d=(t=t||{}).node||a,h=void 0!==t[i(324)]?t[i(324)]:I;if(null==d||null==h){const A=t[i(347)]||(t[i(355)]||o[i(334)])();null==d&&(d=a=[1|A[0],A[1],A[2],A[3],A[4],A[5]]),null==h&&(h=I=16383&(A[6]<<8|A[7]))}let C=void 0!==t[i(327)]?t.msecs:Date.now(),u=void 0!==t[i(316)]?t.nsecs:g+1;const m=C-l+(u-g)/1e4;if(m<0&&void 0===t[i(324)]&&(h=h+1&16383),(m<0||C>l)&&void 0===t[i(316)]&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=C,g=u,I=h,C+=122192928e5;const E=(1e4*(268435455&C)+u)%4294967296;c[s++]=E>>>24&255,c[s++]=E>>>16&255,c[s++]=E>>>8&255,c[s++]=255&E;const p=C/4294967296*1e4&268435455;c[s++]=p>>>8&255,c[s++]=255&p,c[s++]=p>>>24&15|16,c[s++]=p>>>16&255,c[s++]=h>>>8|128,c[s++]=255&h;for(let n=0;n<6;++n)c[s+n]=d[n];return A||(0,r[i(263)])(c)}},237:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(334)]=void 0;var s=r(e(925)),o=r(e(163));function r(t){return t&&t[n(220)]?t:{default:t}}var a=(0,s.default)("v3",48,o[n(334)]);A[n(334)]=a},925:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(291)]=A.DNS=void 0,A[n(334)]=function(t,A,e){const s=n;function l(t,n,s,a){const I=i;var l;if(I(240)==typeof t&&(t=function(t){const A=I;t=unescape(encodeURIComponent(t));const e=[];for(let i=0;i{const n=i;Object.defineProperty(A,"__esModule",{value:!0}),A[n(334)]=void 0;var s=a(e(790)),o=a(e(319)),r=e(8);function a(t){return t&&t.__esModule?t:{default:t}}A[n(334)]=function(t,A,e){const i=n;if(s[i(334)][i(273)]&&!A&&!t)return s.default[i(273)]();const a=(t=t||{}).random||(t[i(355)]||o.default)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,A){e=e||0;for(let t=0;t<16;++t)A[e+t]=a[t];return A}return(0,r.unsafeStringify)(a)}},764:(t,A,e)=>{const n=i;Object[n(228)](A,"__esModule",{value:!0}),A[n(334)]=void 0;var s=r(e(925)),o=r(e(757));function r(t){return t&&t[n(220)]?t:{default:t}}var a=(0,s[n(334)])("v5",80,o.default);A.default=a},435:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(334)]=void 0;var s,o=(s=e(58))&&s.__esModule?s:{default:s};A[n(334)]=function(t){const A=n;return A(240)==typeof t&&o[A(334)][A(346)](t)}},464:(t,A,e)=>{const n=i;Object[n(228)](A,n(220),{value:!0}),A[n(334)]=void 0;var s,o=(s=e(435))&&s[n(220)]?s:{default:s};A[n(334)]=function(t){const A=n;if(!(0,o[A(334)])(t))throw TypeError(A(271));return parseInt(t[A(396)](14,15),16)}},147:t=>{const A=i;t[A(337)]=JSON[A(250)](A(373))}},A={};function e(n){const s=i;var o=A[n];if(void 0!==o)return o[s(337)];var r=A[n]={exports:{}};return t[n][s(377)](r[s(337)],r,r[s(337)],e),r.exports}var n={};return(()=>{const t=i;var A=n;Object[t(228)](A,"__esModule",{value:!0}),A.ByteBrew=void 0;var s=e(719);Object[t(228)](A,t(290),{enumerable:!0,get:function(){return s[t(290)]}})})(),n})()))}(j,j.exports)),j.exports);class P{static init(t){if(!Y.ByteBrew||Y.ByteBrew.isByteBrewInitialized()||!k.release)return;if(!t||!t?.isAnalyticsBB_Enabled)return;const A=[t?.AnalyticsBB_AppID,t?.AnalyticsBB_Key,t?.AppVersion];A.every((t=>"string"==typeof t&&t.trim().length>0))?(Y.ByteBrew.initializeByteBrew(...A),Y.ByteBrew.loadRemoteConfigs((t=>{this.config=t}))):console.error("Params is empty")}static sendCustomEvent(t,A){if(!Y.ByteBrew)return;if("string"!=typeof t)return void console.error("Type of eventName must be string");if(!Object.values(A).every((t=>["string","boolean","number"].includes(typeof t))))return void console.error("Type of object values must be boolean, string or number");if(console.log(">>>",t,A),!k.release||!Y.ByteBrew.isByteBrewInitialized())return;const e=k.getValue("analytics_params","AppVersion"),i=S.network?.name||"local";Y.ByteBrew.newCustomEvent(t,{...A,version:e,network:i})}static isRemoteConfigReady(){return!!(Y.ByteBrew&&Y.ByteBrew.initializeByteBrew&&this.config)&&Y.ByteBrew.hasRemoteConfigsBeenSet()}static getRemoteConfigValue(t){if(this.config){if(this.config.has(t))return this.config.get(t);console.error(t," not includes in remote config")}else console.error("Remote config empty")}}__publicField(P,"config",null);const W=class t{static initConfig({templateType:t,redirectOptions:A,ticker:e,release:i,debug:n,network:s,language:o="en"}){return this.debug=n||{},this.network=s,this.templateType=t,this.language=o,this.release=!!i,this.setWindowControls(),A&&(A||(S.timeToRedirect=null,u.tapToRedirect=null),A?.tapRedirect&&(u.tapToRedirect=A.tapRedirect),A?.timeRedirect&&(S.timeToRedirect=A.timeRedirect)),this.ticker=e,this}static setFpsCounter(){!this.stats&&"fps_counter"in this.debug&&this.debug.fps_counter&&(this.stats=new F,this.stats.showPanel(0),document.body.appendChild(this.stats.dom))}static init({config:A,resizeCb:e,afterResourcesLoadedCb:n,beforeResourcesLoadedCb:s,playableIsVisibleCb:o,gameRedirectedCb:r,resources:a,firstClickCb:I}){!0!==this.isInit?(this.resizeCb=e,this.playableIsVisibleCb=o,this.gameRedirectedCb=r,this.firstClickCb=I,this.config=A,P.init(A.analytics_params),S.init({redirect:this.config?.redirect,network:this.network},(()=>{M.init(),u.init(),s&&s(),V.loadResources({resources:a},(()=>{this.update(),n&&n(),this.isInit=!0,this.resourcesIsLoaded=!0,this.setFpsCounter(),t.templateType!==i.video&&M.disableLoader(),S.gameIsReady()}))})),!this.release&&this.setUpFont()):console.error("Game is initialized!")}static start(){!0!==this.isStart?(this.playableIsVisibleCb&&this.playableIsVisibleCb(),this.isStart=!0):console.error("Game is started!")}static firstClick(){this.firstClickCb()}static end(){S.openGameStorePage(),!0!==this.isEnd?(this.gameRedirectedCb&&this.gameRedirectedCb(),S.gameIsEnded(),this.isEnd=!0):console.error("Game is ended!")}static loadResources(){!0!==this.isLoaded?this.isLoaded=!0:console.error("Game is ended!")}static resizeScreen(){this.resizeCb&&this.resizeCb()}static update(){this.stats&&this.stats.begin();const t="fps_limitter"in this.debug&&void 0!==this.debug.fps_limitter?this.debug.fps_limitter:-1;if(t>-1?setTimeout((()=>{requestAnimationFrame(this.update.bind(this))}),1e3/t):requestAnimationFrame(this.update.bind(this)),this.ticker){const t=this.ticker();w.Instance.update(t)}this.stats&&this.stats.end()}static getValue(t,A){if(this.config)if(t in this.config||!this.config[t]){if(!this.config[t]||A in this.config[t])return this.config[t][A];console.error("variable in config is not defined:",A)}else console.error("category in config is not defined:",t);else console.error("config object is undefined")}static getCategory(t){if(this.config){if(t in this.config||!this.config[t])return this.config[t];console.error("category in config is not defined:",t)}else console.error("config object is undefined")}static openGameStorePage(){S.openGameStorePage(),this.end()}static mouseOrTouchDown(){u.generateClick()}static setValue(t,A,e){t in this.config||!this.config[t]?!this.config[t]||A in this.config[t]?this.config[t][A]=e:console.error("variable in config is not defined:",A):console.error("category in config is not defined:",t)}static set24ADSControls(){window.CustomizationRedirectCallback=null,window.onMuteCallback=null,window.isStarted=!1,window.localRedirect=function(t){(window.top?window.top:document).location.href=t},window.registerRedirectCallback=function(t){window.CustomizationRedirectCallback=t},window.onChangeMute=function(t){window.onMuteCallback=t},window.soundConfig=function(t,A){switch(t){case"setMute":return v.setMute(A);case"getMute":return v.getMute();case"setVolume":return v.setVolume(A);case"getVolume":return v.getVolume()}},window.VideoC=b}static setWindowControls(){window.setRedirectOptions=function(t){t||(S.timeToRedirect=null,u.tapToRedirect=null),t?.tapRedirect&&(u.tapToRedirect=t.tapRedirect),t?.timeRedirect&&(S.timeToRedirect=t.timeRedirect)},window.showLoader=function(t){t?M.showLoader():M.disableLoader()},window.updateVariableConfig=(...t)=>{this.setValue(...t),t[0]&&t[1]&&!["fonts","text_options","video_options"].includes(t[0])&&("loader"===t[0]?M.update():"sounds"===t[0]&&v.updateConfig(t[1],t[2]),this.updateVariableConfig.Invoke(t))},window.Template=this}static setUpFont(){if(!this.release&&"fonts"in this.config&&this.config.fonts&&this.config.fonts.length>0){const t=this.config.fonts.find((t=>t.id===this.config.text_options.en.fontFamily)),A=`@font-face { font-family: gameFont;src: url(${t?.url?t.url.replace("./","./fonts/"):this.config.fonts[this.config.fonts.length-1].file[0]})}`,e=document.createElement("style");e.innerHTML=A,document.head.appendChild(e)}}static getVideoOptions(){return"video_options"in this.config&&this.config.video_options?this.config.video_options:(console.error("No video optinos!"),{})}};__publicField(W,"config"),__publicField(W,"resizeCb"),__publicField(W,"playableIsVisibleCb",(()=>{})),__publicField(W,"gameRedirectedCb"),__publicField(W,"firstClickCb"),__publicField(W,"stats"),__publicField(W,"debug"),__publicField(W,"updateVariableConfig",new c),__publicField(W,"release",!1),__publicField(W,"ticker",null),__publicField(W,"templateType"),__publicField(W,"isStart",!1),__publicField(W,"isEnd",!1),__publicField(W,"isInit",!1),__publicField(W,"isLoaded",!1),__publicField(W,"resourcesIsLoaded",!1),__publicField(W,"network"),__publicField(W,"language");let k=W;var z=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return t},Out:function(t){return t},InOut:function(t){return t}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(t){var A=1.70158;return 1===t?1:t*t*((A+1)*t-A)},Out:function(t){var A=1.70158;return 0===t?0:--t*t*((A+1)*t+A)+1},InOut:function(t){var A=2.5949095;return(t*=2)<1?t*t*((A+1)*t-A)*.5:.5*((t-=2)*t*((A+1)*t+A)+2)}}),Bounce:Object.freeze({In:function(t){return 1-z.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*z.Bounce.In(2*t):.5*z.Bounce.Out(2*t-1)+.5}}),generatePow:function(t){return void 0===t&&(t=4),t=(t=t1e4?1e4:t,{In:function(A){return Math.pow(A,t)},Out:function(A){return 1-Math.pow(1-A,t)},InOut:function(A){return A<.5?Math.pow(2*A,t)/2:(1-Math.pow(2-2*A,t))/2+.5}}}}),O=function(){return performance.now()},X=function(){function t(){for(var t=[],A=0;A0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?s(t[e],t[e-1],e-i):s(t[n],t[n+1>e?e:n+1],i-n)},Utils:{Linear:function(t,A,e){return(A-t)*e+t}}},K=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),q=new X,_=function(){function t(t,A){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=z.Linear.None,this._interpolationFunction=H.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=K.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=t,"object"==typeof A?(this._group=A,A.add(this)):!0===A&&(this._group=q,q.add(this))}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(t,A){if(void 0===A&&(A=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=A<0?0:A,this},t.prototype.duration=function(t){return void 0===t&&(t=1e3),this._duration=t<0?0:t,this},t.prototype.dynamic=function(t){return void 0===t&&(t=!1),this._isDynamic=t,this},t.prototype.start=function(t,A){if(void 0===t&&(t=O()),void 0===A&&(A=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||A){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var n in this._valuesEnd)i[n]=this._valuesEnd[n];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,A)}return this},t.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},t.prototype._setupProperties=function(t,A,e,i,n){for(var s in e){var o=t[s],r=Array.isArray(o),a=r?"array":typeof o,I=!r&&Array.isArray(e[s]);if("undefined"!==a&&"function"!==a){if(I){if(0===(u=e[s]).length)continue;for(var l=[o],g=0,c=u.length;ga)return 1;var t=Math.trunc(o/r),A=o-t*r,e=Math.min(A/s._duration,1);return 0===e&&o===s._duration?1:e}(),l=this._easingFunction(I);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,I),0===this._duration||o>=this._duration){if(this._repeat>0){var g=Math.min(Math.trunc((o-this._duration)/r)+1,this._repeat);for(n in isFinite(this._repeat)&&(this._repeat-=g),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=r*g,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var c=0,d=this._chainedTweens.length;c{this.group.update()}))}static createOpacityAnimation(t,A){const e=A?t:t.children.find((t=>!!t.name.toLowerCase().includes("outline"))),i=e.material.clone();i.transparent=!0;const n=new _({opacity:e.material.opacity}).to({opacity:0},1e3).onUpdate((t=>{i.opacity=t.opacity,e.material=i})).yoyo(!0).repeat(1/0).start();return this.add(n),n}static add(t){this.group.add(t)}static create(t,A,e){const i=new _(t).to(A,e);return this.group.add(i),i}static end(){null!==this.delegateId&&w.Instance.onUpdate.removeListeners(this.delegateId)}static createBounceAnimation(t){const A=new _({x:t.scale.x,y:t.scale.y,z:t.scale.z}).to({x:1.2*t.scale.x,y:1.2*t.scale.y,z:1.2*t.scale.z},400).onUpdate((function(A){t.scale.set(A.x,A.y,A.z)})).delay(100).yoyo(!0).repeat(1/0).start();return this.add(A),A}static createScaleAnimation(t,A){const e=new _({x:t.scale.x,y:t.scale.y,z:t.scale.z}).to({x:A,y:A,z:A},250).onUpdate((function(A){t.scale.set(A.x,A.y,A.z)})).onComplete((()=>{0===A&&(t.visible=!1)})).start();return this.add(e),e}static appearObjectAnimation(t){const A=new _({scale:0}).to({scale:1.1},200).onUpdate((A=>{t.scale.set(A.scale,A.scale,A.scale)})),e=new _({scale:1.1}).to({scale:.9},200).onUpdate((A=>{t.scale.set(A.scale,A.scale,A.scale)})).yoyo(!0).repeat(1);A.chain(e),A.start(),this.add(A)}static moveUpDownAnimation(t,A,e,i=500){const n=new _({y:A}).to({y:e},i).onUpdate((function(A){t.position.setY(A.y)})).yoyo(!0).repeat(1/0).easing(z.Quadratic.InOut).start();return this.add(n),n}static rotateInfinity(t){const A=new _({t:0}).to({t:360},3e3).onUpdate((function(A){t.rotation.y=a(A.t)})).repeat(1/0).start();return this.add(A),A}}__publicField(tt,"group"),__publicField(tt,"delegateId");const At=(t,A)=>{const e=A.x-t.x,i=A.y-t.y;return Math.sqrt(e*e+i*i)},et=t=>t*(Math.PI/180),it=new Map,nt=t=>{it.has(t)&&clearTimeout(it.get(t)),it.set(t,setTimeout(t,100))},st=(t,A,e)=>{const i=A.split(/[ ,]+/g);let n;for(let s=0;s{const i=A.split(/[ ,]+/g);let n;for(let s=0;s(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),at=()=>({x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}),It=(t,A)=>{A.top||A.right||A.bottom||A.left?(t.style.top=A.top,t.style.right=A.right,t.style.bottom=A.bottom,t.style.left=A.left):(t.style.left=A.x+"px",t.style.top=A.y+"px")},lt=(t,A,e)=>{const i=gt(t);for(let n in i)if(i.hasOwnProperty(n))if("string"==typeof A)i[n]=A+" "+e;else{let t="";for(let i=0,n=A.length;i{const A={};return A[t]="",["webkit","Moz","o"].forEach((function(e){A[e+t.charAt(0).toUpperCase()+t.slice(1)]=""})),A},ct=(t,A)=>{for(let e in A)A.hasOwnProperty(e)&&(t[e]=A[e]);return t},dt=(t,A)=>{if(t.length)for(let e=0,i=t.length;e=0&&e._handlers_[t].splice(e._handlers_[t].indexOf(A),1),e},Bt.prototype.trigger=function(t,A){var e,i=this,n=t.split(/[ ,]+/g);i._handlers_=i._handlers_||{};for(var s=0;s{const e={};for(let i in t)t.hasOwnProperty(i)&&A.hasOwnProperty(i)?e[i]=A[i]:t.hasOwnProperty(i)&&(e[i]=t[i]);return e})(A.options,t))},Bt.prototype.bindEvt=function(t,A){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[A]=function(){"function"==typeof e["on"+A]?e["on"+A].apply(e,arguments):console.warn('[WARNING] : Missing "on'+A+'" handler.')},st(t,ht[A],e._domHandlers_[A]),pt[A]&&st(t,pt[A],e._domHandlers_[A]),e},Bt.prototype.unbindEvt=function(t,A){var e=this;return e._domHandlers_=e._domHandlers_||{},ot(t,ht[A],e._domHandlers_[A]),pt[A]&&ot(t,pt[A],e._domHandlers_[A]),delete e._domHandlers_[A],this},Qt.prototype=new Bt,Qt.constructor=Qt,Qt.id=0,Qt.prototype.buildEl=function(t){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},Qt.prototype.stylize=function(){if(this.options.dataOnly)return this;var t=this.options.fadeTime+"ms",A=(()=>{const t=gt("borderRadius");for(let A in t)t.hasOwnProperty(A)&&(t[A]="50%");return t})(),e=lt("transition","opacity",t),i={};return i.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},i.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},i.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},ct(i.el,e),"circle"===this.options.shape&&ct(i.back,A),ct(i.front,A),this.applyStyles(i),this},Qt.prototype.applyStyles=function(t){for(var A in this.ui)if(this.ui.hasOwnProperty(A))for(var e in t[A])this.ui[A].style[e]=t[A][e];return this},Qt.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},Qt.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},Qt.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},Qt.prototype.show=function(t){var A=this;return A.options.dataOnly||(clearTimeout(A.removeTimeout),clearTimeout(A.showTimeout),clearTimeout(A.restTimeout),A.addToDom(),A.restCallback(),setTimeout((function(){A.ui.el.style.opacity=1}),0),A.showTimeout=setTimeout((function(){A.trigger("shown",A.instance),"function"==typeof t&&t.call(this)}),A.options.fadeTime)),A},Qt.prototype.hide=function(t){var A=this;if(A.options.dataOnly)return A;if(A.ui.el.style.opacity=A.options.restOpacity,clearTimeout(A.removeTimeout),clearTimeout(A.showTimeout),clearTimeout(A.restTimeout),A.removeTimeout=setTimeout((function(){var e="dynamic"===A.options.mode?"none":"block";A.ui.el.style.display=e,"function"==typeof t&&t.call(A),A.trigger("hidden",A.instance)}),A.options.fadeTime),A.options.restJoystick){const e=A.options.restJoystick,i={};i.x=!0===e||!1!==e.x?0:A.instance.frontPosition.x,i.y=!0===e||!1!==e.y?0:A.instance.frontPosition.y,A.setPosition(t,i)}return A},Qt.prototype.setPosition=function(t,A){var e=this;e.frontPosition={x:A.x,y:A.y};var i=e.options.fadeTime+"ms",n={};n.front=lt("transition",["transform"],i);var s={front:{}};s.front={transform:"translate("+e.frontPosition.x+"px,"+e.frontPosition.y+"px)"},e.applyStyles(n),e.applyStyles(s),e.restTimeout=setTimeout((function(){"function"==typeof t&&t.call(e),e.restCallback()}),e.options.fadeTime)},Qt.prototype.restCallback=function(){var t=this,A={};A.front=lt("transition","none",""),t.applyStyles(A),t.trigger("rested",t.instance)},Qt.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},Qt.prototype.computeDirection=function(t){var A,e,i,n=t.angle.radian,s=Math.PI/4,o=Math.PI/2;if(n>s&&n<3*s&&!t.lockX?A="up":n>-s&&n<=s&&!t.lockY?A="left":n>3*-s&&n<=-s&&!t.lockX?A="down":t.lockY||(A="right"),t.lockY||(e=n>-o&&n0?"up":"down"),t.force>this.options.threshold){var r,a={};for(r in this.direction)this.direction.hasOwnProperty(r)&&(a[r]=this.direction[r]);var I={};for(r in this.direction={x:e,y:i,angle:A},t.direction=this.direction,a)a[r]===this.direction[r]&&(I[r]=!0);if(I.x&&I.y&&I.angle)return t;I.x&&I.y||this.trigger("plain",t),I.x||this.trigger("plain:"+e,t),I.y||this.trigger("plain:"+i,t),I.angle||this.trigger("dir dir:"+A,t)}else this.resetDirection();return t},Mt.prototype=new Bt,Mt.constructor=Mt,Mt.id=0,Mt.prototype.prepareNipples=function(){var t=this,A=t.nipples;A.on=t.on.bind(t),A.off=t.off.bind(t),A.options=t.options,A.destroy=t.destroy.bind(t),A.ids=t.ids,A.id=t.id,A.processOnMove=t.processOnMove.bind(t),A.processOnEnd=t.processOnEnd.bind(t),A.get=function(t){if(void 0===t)return A[0];for(var e=0,i=A.length;e0&&e.pressureFn(t,A,A.identifier),e.processOnMove(t)};if((A=e.idles.indexOf(r))>=0&&e.idles.splice(A,1),e.actives.push(r),e.ids.push(r.identifier),"semi"!==i.mode)a(r);else{if(!(At(o,r.position)<=i.catchDistance))return r.destroy(),void e.processOnStart(t);a(r)}return r},Mt.prototype.getOrCreate=function(t,A){var e,i=this,n=i.options;return/(semi|static)/.test(n.mode)?(e=i.idles[0])?(i.idles.splice(0,1),e):"semi"===n.mode?i.createNipple(A,t):(console.warn("Coudln't find the needed nipple."),!1):e=i.createNipple(A,t)},Mt.prototype.processOnMove=function(t){var A=this,e=A.options,i=A.manager.getIdentifier(t),n=A.nipples.get(i),s=A.manager.scroll;if((t=>isNaN(t.buttons)?0!==t.pressure:0!==t.buttons)(t)){if(!n)return console.error("Found zombie joystick with ID "+i),void A.manager.removeIdentifier(i);if(e.dynamicPage){var o=n.el.getBoundingClientRect();n.position={x:s.x+o.left,y:s.y+o.top}}n.identifier=i;var r=n.options.size/2,a={x:t.pageX,y:t.pageY};e.lockX&&(a.y=n.position.y),e.lockY&&(a.x=n.position.x);var I,l,g=At(a,n.position),c=((t,A)=>{const e=A.x-t.x,i=A.y-t.y;return Math.atan2(i,e)*(180/Math.PI)})(a,n.position),d=et(c),h=g/r,C={distance:g,position:a};if("circle"===n.options.shape?(I=Math.min(g,r),l=((t,A,e)=>{const i={x:0,y:0};return e=et(e),i.x=t.x-A*Math.cos(e),i.y=t.y-A*Math.sin(e),i})(n.position,I,c)):(l=((t,A,e)=>({x:Math.min(Math.max(t.x,A.x-e),A.x+e),y:Math.min(Math.max(t.y,A.y-e),A.y+e)}))(a,n.position,r),I=At(l,n.position)),e.follow){if(g>r){let t=a.x-l.x,e=a.y-l.y;n.position.x+=t,n.position.y+=e,n.el.style.top=n.position.y-(A.box.top+s.y)+"px",n.el.style.left=n.position.x-(A.box.left+s.x)+"px",g=At(a,n.position)}}else a=l,g=I;var u=a.x-n.position.x,m=a.y-n.position.y;n.frontPosition={x:u,y:m},e.dataOnly||(n.ui.front.style.transform="translate("+u+"px,"+m+"px)");var E={identifier:n.identifier,position:a,force:h,pressure:t.force||t.pressure||t.webkitForce||0,distance:g,angle:{radian:d,degree:c},vector:{x:u/r,y:-m/r},raw:C,instance:n,lockX:e.lockX,lockY:e.lockY};(E=n.computeDirection(E)).angle={radian:et(180-c),degree:180-c},n.trigger("move",E),A.trigger("move "+n.id+":move",E)}else this.processOnEnd(t)},Mt.prototype.processOnEnd=function(t){var A=this,e=A.options,i=A.manager.getIdentifier(t),n=A.nipples.get(i),s=A.manager.removeIdentifier(n.identifier);n&&(e.dataOnly||n.hide((function(){"dynamic"===e.mode&&(n.trigger("removed",n),A.trigger("removed "+n.id+":removed",n),A.manager.trigger("removed "+n.id+":removed",n),n.destroy())})),clearInterval(A.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),A.trigger("end "+n.id+":end",n),A.ids.indexOf(n.identifier)>=0&&A.ids.splice(A.ids.indexOf(n.identifier),1),A.actives.indexOf(n)>=0&&A.actives.splice(A.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?A.idles.push(n):A.nipples.indexOf(n)>=0&&A.nipples.splice(A.nipples.indexOf(n),1),A.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(A.manager.ids[s.id]=s.identifier))},Mt.prototype.onDestroyed=function(t,A){var e=this;e.nipples.indexOf(A)>=0&&e.nipples.splice(e.nipples.indexOf(A),1),e.actives.indexOf(A)>=0&&e.actives.splice(e.actives.indexOf(A),1),e.idles.indexOf(A)>=0&&e.idles.splice(e.idles.indexOf(A),1),e.ids.indexOf(A.identifier)>=0&&e.ids.splice(e.ids.indexOf(A.identifier),1),e.manager.removeIdentifier(A.identifier),e.manager.unbindDocument()},Mt.prototype.destroy=function(){var t=this;for(var A in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach((function(t){t.destroy()})),t.pressureIntervals)t.pressureIntervals.hasOwnProperty(A)&&clearInterval(t.pressureIntervals[A]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off()},Vt.prototype=new Bt,Vt.constructor=Vt,Vt.prototype.prepareCollections=function(){var t=this;t.collections.create=t.create.bind(t),t.collections.on=t.on.bind(t),t.collections.off=t.off.bind(t),t.collections.destroy=t.destroy.bind(t),t.collections.get=function(A){var e;return t.collections.every((function(t){return!(e=t.get(A))})),e}},Vt.prototype.create=function(t){return this.createCollection(t)},Vt.prototype.createCollection=function(t){var A=this,e=new Mt(A,t);return A.bindCollection(e),A.collections.push(e),e},Vt.prototype.bindCollection=function(t){var A,e=this,i=function(t,i){A=t.type+" "+i.id+":"+t.type,e.trigger(A,i)};t.on("destroyed",e.onDestroyed.bind(e)),t.on("shown hidden rested dir plain",i),t.on("dir:up dir:right dir:down dir:left",i),t.on("plain:up plain:right plain:down plain:left",i)},Vt.prototype.bindDocument=function(){var t=this;t.binded||(t.bindEvt(document,"move").bindEvt(document,"end"),t.binded=!0)},Vt.prototype.unbindDocument=function(t){var A=this;Object.keys(A.ids).length&&!0!==t||(A.unbindEvt(document,"move").unbindEvt(document,"end"),A.binded=!1)},Vt.prototype.getIdentifier=function(t){var A;return t?void 0===(A=void 0===t.identifier?t.pointerId:t.identifier)&&(A=this.latest||0):A=this.index,void 0===this.ids[A]&&(this.ids[A]=this.index,this.index+=1),this.latest=A,this.ids[A]},Vt.prototype.removeIdentifier=function(t){var A={};for(var e in this.ids)if(this.ids[e]===t){A.id=e,A.identifier=this.ids[e],delete this.ids[e];break}return A},Vt.prototype.onmove=function(t){return this.onAny("move",t),!1},Vt.prototype.onend=function(t){return this.onAny("end",t),!1},Vt.prototype.oncancel=function(t){return this.onAny("end",t),!1},Vt.prototype.onAny=function(t,A){var e,i=this,n="processOn"+t.charAt(0).toUpperCase()+t.slice(1);A=rt(A);var s=function(t,A,e){e.ids.indexOf(A)>=0&&(e[n](t),t._found_=!0)};return dt(A,(function(t){e=i.getIdentifier(t),dt(i.collections,s.bind(null,t,e)),t._found_||i.removeIdentifier(e)})),!1},Vt.prototype.destroy=function(){var t=this;t.unbindDocument(!0),t.ids={},t.index=0,t.collections.forEach((function(t){t.destroy()})),t.off()},Vt.prototype.onDestroyed=function(t,A){var e=this;if(e.collections.indexOf(A)<0)return!1;e.collections.splice(e.collections.indexOf(A),1)};const yt=new Vt;let wt=(__publicField(t=class{static init(t){this.manager=function(t){return yt.create(t)}(t),this.manager.on("start",(t=>{u.mouseOrTouchDown(t),this.active=!0,this.onJoysticStart.Invoke(t)})),this.manager.on("move",((t,A)=>{this.active&&this.onJoysticDown.Invoke({event:t,data:A}),u.mouseOrTouchMove(t),this.onJoysticMove.Invoke({event:t,data:A})})),this.manager.on("end",(t=>{this.onJoysticEnd.Invoke(t),this.active=!1,u.mouseOrTouchUp(t)}))}},"onJoysticStart",new c),__publicField(t,"onJoysticDown",new c),__publicField(t,"onJoysticMove",new c),__publicField(t,"onJoysticEnd",new c),__publicField(t,"active",!1),__publicField(t,"manager"),__publicField(t,"isClicked"),t);
/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/const ft="175",Rt=0,Nt=1,bt=2,Ut=100,vt=101,St=102,Tt=200,Dt=201,xt=202,Zt=203,Jt=204,Ft=205,Gt=206,jt=207,Lt=208,Yt=209,Pt=210,Wt=211,kt=212,zt=213,Ot=214,Xt=0,Ht=1,Kt=2,qt=3,_t=4,$t=5,tA=6,AA=7,eA="attached",iA=301,nA=302,sA=303,oA=304,rA=306,aA=1e3,IA=1001,lA=1002,gA=1003,cA=1004,dA=1005,hA=1006,CA=1007,uA=1008,mA=1009,EA=1012,pA=1013,BA=1014,QA=1015,MA=1016,VA=1017,yA=1018,wA=1020,fA=1023,RA=1026,NA=1027,bA=1028,UA=1029,vA=1031,SA=1033,TA=33776,DA=33777,xA=33778,ZA=33779,JA=35840,FA=35841,GA=35842,jA=35843,LA=36196,YA=37492,PA=37496,WA=37808,kA=37809,zA=37810,OA=37811,XA=37812,HA=37813,KA=37814,qA=37815,_A=37816,$A=37817,te=37818,Ae=37819,ee=37820,ie=37821,ne=36492,se=36494,oe=36495,re=36284,ae=36285,Ie=36286,le=2200,ge=2300,ce=2301,de=2302,he=2400,Ce=2401,ue=2402,me="",Ee="srgb",pe="srgb-linear",Be="linear",Qe="srgb",Me=7680,Ve=512,ye=513,we=514,fe=515,Re=516,Ne=517,be=518,Ue=519,ve=35044,Se=35048,Te="300 es",De=2e3,xe=2001;let Ze=class{addEventListener(t,A){void 0===this._listeners&&(this._listeners={});const e=this._listeners;void 0===e[t]&&(e[t]=[]),-1===e[t].indexOf(A)&&e[t].push(A)}hasEventListener(t,A){const e=this._listeners;return void 0!==e&&void 0!==e[t]&&-1!==e[t].indexOf(A)}removeEventListener(t,A){const e=this._listeners;if(void 0===e)return;const i=e[t];if(void 0!==i){const t=i.indexOf(A);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const A=this._listeners;if(void 0===A)return;const e=A[t.type];if(void 0!==e){t.target=this;const A=e.slice(0);for(let e=0,i=A.length;e>8&255]+Je[t>>16&255]+Je[t>>24&255]+"-"+Je[255&A]+Je[A>>8&255]+"-"+Je[A>>16&15|64]+Je[A>>24&255]+"-"+Je[63&e|128]+Je[e>>8&255]+"-"+Je[e>>16&255]+Je[e>>24&255]+Je[255&i]+Je[i>>8&255]+Je[i>>16&255]+Je[i>>24&255]).toLowerCase()}function Le(t,A,e){return Math.max(A,Math.min(e,t))}function Ye(t,A,e){return(1-e)*t+e*A}function Pe(t,A){switch(A.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function We(t,A){switch(A.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}let ke=class t{constructor(A=0,e=0){t.prototype.isVector2=!0,this.x=A,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,A){return this.x=t,this.y=A,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,A){switch(t){case 0:this.x=A;break;case 1:this.y=A;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,A){return this.x=t.x+A.x,this.y=t.y+A.y,this}addScaledVector(t,A){return this.x+=t.x*A,this.y+=t.y*A,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,A){return this.x=t.x-A.x,this.y=t.y-A.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){const A=this.x,e=this.y,i=t.elements;return this.x=i[0]*A+i[3]*e+i[6],this.y=i[1]*A+i[4]*e+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,A){return this.x=Le(this.x,t.x,A.x),this.y=Le(this.y,t.y,A.y),this}clampScalar(t,A){return this.x=Le(this.x,t,A),this.y=Le(this.y,t,A),this}clampLength(t,A){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Le(e,t,A))}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=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(t){const A=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===A)return Math.PI/2;const e=this.dot(t)/A;return Math.acos(Le(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const A=this.x-t.x,e=this.y-t.y;return A*A+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,A){return this.x+=(t.x-this.x)*A,this.y+=(t.y-this.y)*A,this}lerpVectors(t,A,e){return this.x=t.x+(A.x-t.x)*e,this.y=t.y+(A.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,A=0){return this.x=t[A],this.y=t[A+1],this}toArray(t=[],A=0){return t[A]=this.x,t[A+1]=this.y,t}fromBufferAttribute(t,A){return this.x=t.getX(A),this.y=t.getY(A),this}rotateAround(t,A){const e=Math.cos(A),i=Math.sin(A),n=this.x-t.x,s=this.y-t.y;return this.x=n*e-s*i+t.x,this.y=n*i+s*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ze=class t{constructor(A,e,i,n,s,o,r,a,I){t.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==A&&this.set(A,e,i,n,s,o,r,a,I)}set(t,A,e,i,n,s,o,r,a){const I=this.elements;return I[0]=t,I[1]=i,I[2]=o,I[3]=A,I[4]=n,I[5]=r,I[6]=e,I[7]=s,I[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const A=this.elements,e=t.elements;return A[0]=e[0],A[1]=e[1],A[2]=e[2],A[3]=e[3],A[4]=e[4],A[5]=e[5],A[6]=e[6],A[7]=e[7],A[8]=e[8],this}extractBasis(t,A,e){return t.setFromMatrix3Column(this,0),A.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const A=t.elements;return this.set(A[0],A[4],A[8],A[1],A[5],A[9],A[2],A[6],A[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,A){const e=t.elements,i=A.elements,n=this.elements,s=e[0],o=e[3],r=e[6],a=e[1],I=e[4],l=e[7],g=e[2],c=e[5],d=e[8],h=i[0],C=i[3],u=i[6],m=i[1],E=i[4],p=i[7],B=i[2],Q=i[5],M=i[8];return n[0]=s*h+o*m+r*B,n[3]=s*C+o*E+r*Q,n[6]=s*u+o*p+r*M,n[1]=a*h+I*m+l*B,n[4]=a*C+I*E+l*Q,n[7]=a*u+I*p+l*M,n[2]=g*h+c*m+d*B,n[5]=g*C+c*E+d*Q,n[8]=g*u+c*p+d*M,this}multiplyScalar(t){const A=this.elements;return A[0]*=t,A[3]*=t,A[6]*=t,A[1]*=t,A[4]*=t,A[7]*=t,A[2]*=t,A[5]*=t,A[8]*=t,this}determinant(){const t=this.elements,A=t[0],e=t[1],i=t[2],n=t[3],s=t[4],o=t[5],r=t[6],a=t[7],I=t[8];return A*s*I-A*o*a-e*n*I+e*o*r+i*n*a-i*s*r}invert(){const t=this.elements,A=t[0],e=t[1],i=t[2],n=t[3],s=t[4],o=t[5],r=t[6],a=t[7],I=t[8],l=I*s-o*a,g=o*r-I*n,c=a*n-s*r,d=A*l+e*g+i*c;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const h=1/d;return t[0]=l*h,t[1]=(i*a-I*e)*h,t[2]=(o*e-i*s)*h,t[3]=g*h,t[4]=(I*A-i*r)*h,t[5]=(i*n-o*A)*h,t[6]=c*h,t[7]=(e*r-a*A)*h,t[8]=(s*A-e*n)*h,this}transpose(){let t;const A=this.elements;return t=A[1],A[1]=A[3],A[3]=t,t=A[2],A[2]=A[6],A[6]=t,t=A[5],A[5]=A[7],A[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const A=this.elements;return t[0]=A[0],t[1]=A[3],t[2]=A[6],t[3]=A[1],t[4]=A[4],t[5]=A[7],t[6]=A[2],t[7]=A[5],t[8]=A[8],this}setUvTransform(t,A,e,i,n,s,o){const r=Math.cos(n),a=Math.sin(n);return this.set(e*r,e*a,-e*(r*s+a*o)+s+t,-i*a,i*r,-i*(-a*s+r*o)+o+A,0,0,1),this}scale(t,A){return this.premultiply(Oe.makeScale(t,A)),this}rotate(t){return this.premultiply(Oe.makeRotation(-t)),this}translate(t,A){return this.premultiply(Oe.makeTranslation(t,A)),this}makeTranslation(t,A){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,A,0,0,1),this}makeRotation(t){const A=Math.cos(t),e=Math.sin(t);return this.set(A,-e,0,e,A,0,0,0,1),this}makeScale(t,A){return this.set(t,0,0,0,A,0,0,0,1),this}equals(t){const A=this.elements,e=t.elements;for(let i=0;i<9;i++)if(A[i]!==e[i])return!1;return!0}fromArray(t,A=0){for(let e=0;e<9;e++)this.elements[e]=t[e+A];return this}toArray(t=[],A=0){const e=this.elements;return t[A]=e[0],t[A+1]=e[1],t[A+2]=e[2],t[A+3]=e[3],t[A+4]=e[4],t[A+5]=e[5],t[A+6]=e[6],t[A+7]=e[7],t[A+8]=e[8],t}clone(){return(new this.constructor).fromArray(this.elements)}};const Oe=new ze;function Xe(t){for(let A=t.length-1;A>=0;--A)if(t[A]>=65535)return!0;return!1}const He={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Ke(t,A){return new He[t](A)}function qe(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function _e(){const t=qe("canvas");return t.style.display="block",t}const $e={};function ti(t){t in $e||($e[t]=!0,console.warn(t))}const Ai=(new ze).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ei=(new ze).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ii(){const t={enabled:!0,workingColorSpace:pe,spaces:{},convert:function(t,A,e){return!1!==this.enabled&&A!==e&&A&&e?(this.spaces[A].transfer===Qe&&(t.r=si(t.r),t.g=si(t.g),t.b=si(t.b)),this.spaces[A].primaries!==this.spaces[e].primaries&&(t.applyMatrix3(this.spaces[A].toXYZ),t.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===Qe&&(t.r=oi(t.r),t.g=oi(t.g),t.b=oi(t.b)),t):t},fromWorkingColorSpace:function(t,A){return this.convert(t,this.workingColorSpace,A)},toWorkingColorSpace:function(t,A){return this.convert(t,A,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return t===me?Be:this.spaces[t].transfer},getLuminanceCoefficients:function(t,A=this.workingColorSpace){return t.fromArray(this.spaces[A].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,A,e){return t.copy(this.spaces[A].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace}},A=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[pe]:{primaries:A,whitePoint:i,transfer:Be,toXYZ:Ai,fromXYZ:ei,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ee},outputColorSpaceConfig:{drawingBufferColorSpace:Ee}},[Ee]:{primaries:A,whitePoint:i,transfer:Qe,toXYZ:Ai,fromXYZ:ei,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ee}}}),t}const ni=ii();function si(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function oi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let ri;class ai{static getDataURL(t,A="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===ri&&(ri=qe("canvas")),ri.width=t.width,ri.height=t.height;const A=ri.getContext("2d");t instanceof ImageData?A.putImageData(t,0,0):A.drawImage(t,0,0,t.width,t.height),e=ri}return e.toDataURL(A)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const A=qe("canvas");A.width=t.width,A.height=t.height;const e=A.getContext("2d");e.drawImage(t,0,0,t.width,t.height);const i=e.getImageData(0,0,t.width,t.height),n=i.data;for(let t=0;t0&&(e.userData=this.userData),A||(t.textures[this.uuid]=e),e}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case aA:t.x=t.x-Math.floor(t.x);break;case IA:t.x=t.x<0?0:1;break;case lA:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case aA:t.y=t.y-Math.floor(t.y);break;case IA:t.y=t.y<0?0:1;break;case lA:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}di.DEFAULT_IMAGE=null,di.DEFAULT_MAPPING=300,di.DEFAULT_ANISOTROPY=1;let hi=class t{constructor(A=0,e=0,i=0,n=1){t.prototype.isVector4=!0,this.x=A,this.y=e,this.z=i,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,A,e,i){return this.x=t,this.y=A,this.z=e,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,A){switch(t){case 0:this.x=A;break;case 1:this.y=A;break;case 2:this.z=A;break;case 3:this.w=A;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=void 0!==t.w?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,A){return this.x=t.x+A.x,this.y=t.y+A.y,this.z=t.z+A.z,this.w=t.w+A.w,this}addScaledVector(t,A){return this.x+=t.x*A,this.y+=t.y*A,this.z+=t.z*A,this.w+=t.w*A,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,A){return this.x=t.x-A.x,this.y=t.y-A.y,this.z=t.z-A.z,this.w=t.w-A.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){const A=this.x,e=this.y,i=this.z,n=this.w,s=t.elements;return this.x=s[0]*A+s[4]*e+s[8]*i+s[12]*n,this.y=s[1]*A+s[5]*e+s[9]*i+s[13]*n,this.z=s[2]*A+s[6]*e+s[10]*i+s[14]*n,this.w=s[3]*A+s[7]*e+s[11]*i+s[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const A=Math.sqrt(1-t.w*t.w);return A<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/A,this.y=t.y/A,this.z=t.z/A),this}setAxisAngleFromRotationMatrix(t){let A,e,i,n;const s=.01,o=.1,r=t.elements,a=r[0],I=r[4],l=r[8],g=r[1],c=r[5],d=r[9],h=r[2],C=r[6],u=r[10];if(Math.abs(I-g)r&&t>m?tm?r=0?1:-1,i=1-A*A;if(i>Number.EPSILON){const n=Math.sqrt(i),s=Math.atan2(n,A*e);t=Math.sin(t*s)/n,o=Math.sin(o*s)/n}const n=o*e;if(r=r*t+g*n,a=a*t+c*n,I=I*t+d*n,l=l*t+h*n,t===1-o){const t=1/Math.sqrt(r*r+a*a+I*I+l*l);r*=t,a*=t,I*=t,l*=t}}t[A]=r,t[A+1]=a,t[A+2]=I,t[A+3]=l}static multiplyQuaternionsFlat(t,A,e,i,n,s){const o=e[i],r=e[i+1],a=e[i+2],I=e[i+3],l=n[s],g=n[s+1],c=n[s+2],d=n[s+3];return t[A]=o*d+I*l+r*c-a*g,t[A+1]=r*d+I*g+a*l-o*c,t[A+2]=a*d+I*c+o*g-r*l,t[A+3]=I*d-o*l-r*g-a*c,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,A,e,i){return this._x=t,this._y=A,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,A=!0){const e=t._x,i=t._y,n=t._z,s=t._order,o=Math.cos,r=Math.sin,a=o(e/2),I=o(i/2),l=o(n/2),g=r(e/2),c=r(i/2),d=r(n/2);switch(s){case"XYZ":this._x=g*I*l+a*c*d,this._y=a*c*l-g*I*d,this._z=a*I*d+g*c*l,this._w=a*I*l-g*c*d;break;case"YXZ":this._x=g*I*l+a*c*d,this._y=a*c*l-g*I*d,this._z=a*I*d-g*c*l,this._w=a*I*l+g*c*d;break;case"ZXY":this._x=g*I*l-a*c*d,this._y=a*c*l+g*I*d,this._z=a*I*d+g*c*l,this._w=a*I*l-g*c*d;break;case"ZYX":this._x=g*I*l-a*c*d,this._y=a*c*l+g*I*d,this._z=a*I*d-g*c*l,this._w=a*I*l+g*c*d;break;case"YZX":this._x=g*I*l+a*c*d,this._y=a*c*l+g*I*d,this._z=a*I*d-g*c*l,this._w=a*I*l-g*c*d;break;case"XZY":this._x=g*I*l-a*c*d,this._y=a*c*l-g*I*d,this._z=a*I*d+g*c*l,this._w=a*I*l+g*c*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===A&&this._onChangeCallback(),this}setFromAxisAngle(t,A){const e=A/2,i=Math.sin(e);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const A=t.elements,e=A[0],i=A[4],n=A[8],s=A[1],o=A[5],r=A[9],a=A[2],I=A[6],l=A[10],g=e+o+l;if(g>0){const t=.5/Math.sqrt(g+1);this._w=.25/t,this._x=(I-r)*t,this._y=(n-a)*t,this._z=(s-i)*t}else if(e>o&&e>l){const t=2*Math.sqrt(1+e-o-l);this._w=(I-r)/t,this._x=.25*t,this._y=(i+s)/t,this._z=(n+a)/t}else if(o>l){const t=2*Math.sqrt(1+o-e-l);this._w=(n-a)/t,this._x=(i+s)/t,this._y=.25*t,this._z=(r+I)/t}else{const t=2*Math.sqrt(1+l-e-o);this._w=(s-i)/t,this._x=(n+a)/t,this._y=(r+I)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,A){let e=t.dot(A)+1;return eMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*A.z-t.z*A.y,this._y=t.z*A.x-t.x*A.z,this._z=t.x*A.y-t.y*A.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Le(this.dot(t),-1,1)))}rotateTowards(t,A){const e=this.angleTo(t);if(0===e)return this;const i=Math.min(1,A/e);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(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,A){const e=t._x,i=t._y,n=t._z,s=t._w,o=A._x,r=A._y,a=A._z,I=A._w;return this._x=e*I+s*o+i*a-n*r,this._y=i*I+s*r+n*o-e*a,this._z=n*I+s*a+e*r-i*o,this._w=s*I-e*o-i*r-n*a,this._onChangeCallback(),this}slerp(t,A){if(0===A)return this;if(1===A)return this.copy(t);const e=this._x,i=this._y,n=this._z,s=this._w;let o=s*t._w+e*t._x+i*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=e,this._y=i,this._z=n,this;const r=1-o*o;if(r<=Number.EPSILON){const t=1-A;return this._w=t*s+A*this._w,this._x=t*e+A*this._x,this._y=t*i+A*this._y,this._z=t*n+A*this._z,this.normalize(),this}const a=Math.sqrt(r),I=Math.atan2(a,o),l=Math.sin((1-A)*I)/a,g=Math.sin(A*I)/a;return this._w=s*l+this._w*g,this._x=e*l+this._x*g,this._y=i*l+this._y*g,this._z=n*l+this._z*g,this._onChangeCallback(),this}slerpQuaternions(t,A,e){return this.copy(t).slerp(A,e)}random(){const t=2*Math.PI*Math.random(),A=2*Math.PI*Math.random(),e=Math.random(),i=Math.sqrt(1-e),n=Math.sqrt(e);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(A),n*Math.cos(A))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,A=0){return this._x=t[A],this._y=t[A+1],this._z=t[A+2],this._w=t[A+3],this._onChangeCallback(),this}toArray(t=[],A=0){return t[A]=this._x,t[A+1]=this._y,t[A+2]=this._z,t[A+3]=this._w,t}fromBufferAttribute(t,A){return this._x=t.getX(A),this._y=t.getY(A),this._z=t.getZ(A),this._w=t.getW(A),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Bi=class t{constructor(A=0,e=0,i=0){t.prototype.isVector3=!0,this.x=A,this.y=e,this.z=i}set(t,A,e){return void 0===e&&(e=this.z),this.x=t,this.y=A,this.z=e,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,A){switch(t){case 0:this.x=A;break;case 1:this.y=A;break;case 2:this.z=A;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,A){return this.x=t.x+A.x,this.y=t.y+A.y,this.z=t.z+A.z,this}addScaledVector(t,A){return this.x+=t.x*A,this.y+=t.y*A,this.z+=t.z*A,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,A){return this.x=t.x-A.x,this.y=t.y-A.y,this.z=t.z-A.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,A){return this.x=t.x*A.x,this.y=t.y*A.y,this.z=t.z*A.z,this}applyEuler(t){return this.applyQuaternion(Mi.setFromEuler(t))}applyAxisAngle(t,A){return this.applyQuaternion(Mi.setFromAxisAngle(t,A))}applyMatrix3(t){const A=this.x,e=this.y,i=this.z,n=t.elements;return this.x=n[0]*A+n[3]*e+n[6]*i,this.y=n[1]*A+n[4]*e+n[7]*i,this.z=n[2]*A+n[5]*e+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const A=this.x,e=this.y,i=this.z,n=t.elements,s=1/(n[3]*A+n[7]*e+n[11]*i+n[15]);return this.x=(n[0]*A+n[4]*e+n[8]*i+n[12])*s,this.y=(n[1]*A+n[5]*e+n[9]*i+n[13])*s,this.z=(n[2]*A+n[6]*e+n[10]*i+n[14])*s,this}applyQuaternion(t){const A=this.x,e=this.y,i=this.z,n=t.x,s=t.y,o=t.z,r=t.w,a=2*(s*i-o*e),I=2*(o*A-n*i),l=2*(n*e-s*A);return this.x=A+r*a+s*l-o*I,this.y=e+r*I+o*a-n*l,this.z=i+r*l+n*I-s*a,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const A=this.x,e=this.y,i=this.z,n=t.elements;return this.x=n[0]*A+n[4]*e+n[8]*i,this.y=n[1]*A+n[5]*e+n[9]*i,this.z=n[2]*A+n[6]*e+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,A){return this.x=Le(this.x,t.x,A.x),this.y=Le(this.y,t.y,A.y),this.z=Le(this.z,t.z,A.z),this}clampScalar(t,A){return this.x=Le(this.x,t,A),this.y=Le(this.y,t,A),this.z=Le(this.z,t,A),this}clampLength(t,A){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Le(e,t,A))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(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,A){return this.x+=(t.x-this.x)*A,this.y+=(t.y-this.y)*A,this.z+=(t.z-this.z)*A,this}lerpVectors(t,A,e){return this.x=t.x+(A.x-t.x)*e,this.y=t.y+(A.y-t.y)*e,this.z=t.z+(A.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,A){const e=t.x,i=t.y,n=t.z,s=A.x,o=A.y,r=A.z;return this.x=i*r-n*o,this.y=n*s-e*r,this.z=e*o-i*s,this}projectOnVector(t){const A=t.lengthSq();if(0===A)return this.set(0,0,0);const e=t.dot(this)/A;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return Qi.copy(this).projectOnVector(t),this.sub(Qi)}reflect(t){return this.sub(Qi.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const A=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===A)return Math.PI/2;const e=this.dot(t)/A;return Math.acos(Le(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const A=this.x-t.x,e=this.y-t.y,i=this.z-t.z;return A*A+e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,A,e){const i=Math.sin(A)*t;return this.x=i*Math.sin(e),this.y=Math.cos(A)*t,this.z=i*Math.cos(e),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,A,e){return this.x=t*Math.sin(A),this.y=e,this.z=t*Math.cos(A),this}setFromMatrixPosition(t){const A=t.elements;return this.x=A[12],this.y=A[13],this.z=A[14],this}setFromMatrixScale(t){const A=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=A,this.y=e,this.z=i,this}setFromMatrixColumn(t,A){return this.fromArray(t.elements,4*A)}setFromMatrix3Column(t,A){return this.fromArray(t.elements,3*A)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,A=0){return this.x=t[A],this.y=t[A+1],this.z=t[A+2],this}toArray(t=[],A=0){return t[A]=this.x,t[A+1]=this.y,t[A+2]=this.z,t}fromBufferAttribute(t,A){return this.x=t.getX(A),this.y=t.getY(A),this.z=t.getZ(A),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,A=2*Math.random()-1,e=Math.sqrt(1-A*A);return this.x=e*Math.cos(t),this.y=A,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Qi=new Bi,Mi=new pi;class Vi{constructor(t=new Bi(1/0,1/0,1/0),A=new Bi(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=A}set(t,A){return this.min.copy(t),this.max.copy(A),this}setFromArray(t){this.makeEmpty();for(let A=0,e=t.length;A=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,A){return A.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,wi),wi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let A,e;return t.normal.x>0?(A=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(A=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(A+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(A+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(A+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(A+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),A<=-t.constant&&e>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ti),Di.subVectors(this.max,Ti),Ri.subVectors(t.a,Ti),Ni.subVectors(t.b,Ti),bi.subVectors(t.c,Ti),Ui.subVectors(Ni,Ri),vi.subVectors(bi,Ni),Si.subVectors(Ri,bi);let A=[0,-Ui.z,Ui.y,0,-vi.z,vi.y,0,-Si.z,Si.y,Ui.z,0,-Ui.x,vi.z,0,-vi.x,Si.z,0,-Si.x,-Ui.y,Ui.x,0,-vi.y,vi.x,0,-Si.y,Si.x,0];return!!Ji(A,Ri,Ni,bi,Di)&&(A=[1,0,0,0,1,0,0,0,1],!!Ji(A,Ri,Ni,bi,Di)&&(xi.crossVectors(Ui,vi),A=[xi.x,xi.y,xi.z],Ji(A,Ri,Ni,bi,Di)))}clampPoint(t,A){return A.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,wi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(wi).length()),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()||(yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yi)),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)}}const yi=[new Bi,new Bi,new Bi,new Bi,new Bi,new Bi,new Bi,new Bi],wi=new Bi,fi=new Vi,Ri=new Bi,Ni=new Bi,bi=new Bi,Ui=new Bi,vi=new Bi,Si=new Bi,Ti=new Bi,Di=new Bi,xi=new Bi,Zi=new Bi;function Ji(t,A,e,i,n){for(let s=0,o=t.length-3;s<=o;s+=3){Zi.fromArray(t,s);const o=n.x*Math.abs(Zi.x)+n.y*Math.abs(Zi.y)+n.z*Math.abs(Zi.z),r=A.dot(Zi),a=e.dot(Zi),I=i.dot(Zi);if(Math.max(-Math.max(r,a,I),Math.min(r,a,I))>o)return!1}return!0}const Fi=new Vi,Gi=new Bi,ji=new Bi;let Li=class{constructor(t=new Bi,A=-1){this.isSphere=!0,this.center=t,this.radius=A}set(t,A){return this.center.copy(t),this.radius=A,this}setFromPoints(t,A){const e=this.center;void 0!==A?e.copy(A):Fi.setFromPoints(t).getCenter(e);let i=0;for(let n=0,s=t.length;nthis.radius*this.radius&&(A.sub(this.center).normalize(),A.multiplyScalar(this.radius).add(this.center)),A}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;Gi.subVectors(t,this.center);const A=Gi.lengthSq();if(A>this.radius*this.radius){const t=Math.sqrt(A),e=.5*(t-this.radius);this.center.addScaledVector(Gi,e/t),this.radius+=e}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(ji.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Gi.copy(t.center).add(ji)),this.expandByPoint(Gi.copy(t.center).sub(ji))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}};const Yi=new Bi,Pi=new Bi,Wi=new Bi,ki=new Bi,zi=new Bi,Oi=new Bi,Xi=new Bi;let Hi=class{constructor(t=new Bi,A=new Bi(0,0,-1)){this.origin=t,this.direction=A}set(t,A){return this.origin.copy(t),this.direction.copy(A),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,A){return A.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Yi)),this}closestPointToPoint(t,A){A.subVectors(t,this.origin);const e=A.dot(this.direction);return e<0?A.copy(this.origin):A.copy(this.origin).addScaledVector(this.direction,e)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const A=Yi.subVectors(t,this.origin).dot(this.direction);return A<0?this.origin.distanceToSquared(t):(Yi.copy(this.origin).addScaledVector(this.direction,A),Yi.distanceToSquared(t))}distanceSqToSegment(t,A,e,i){Pi.copy(t).add(A).multiplyScalar(.5),Wi.copy(A).sub(t).normalize(),ki.copy(this.origin).sub(Pi);const n=.5*t.distanceTo(A),s=-this.direction.dot(Wi),o=ki.dot(this.direction),r=-ki.dot(Wi),a=ki.lengthSq(),I=Math.abs(1-s*s);let l,g,c,d;if(I>0)if(l=s*r-o,g=s*o-r,d=n*I,l>=0)if(g>=-d)if(g<=d){const t=1/I;l*=t,g*=t,c=l*(l+s*g+2*o)+g*(s*l+g+2*r)+a}else g=n,l=Math.max(0,-(s*g+o)),c=-l*l+g*(g+2*r)+a;else g=-n,l=Math.max(0,-(s*g+o)),c=-l*l+g*(g+2*r)+a;else g<=-d?(l=Math.max(0,-(-s*n+o)),g=l>0?-n:Math.min(Math.max(-n,-r),n),c=-l*l+g*(g+2*r)+a):g<=d?(l=0,g=Math.min(Math.max(-n,-r),n),c=g*(g+2*r)+a):(l=Math.max(0,-(s*n+o)),g=l>0?n:Math.min(Math.max(-n,-r),n),c=-l*l+g*(g+2*r)+a);else g=s>0?-n:n,l=Math.max(0,-(s*g+o)),c=-l*l+g*(g+2*r)+a;return e&&e.copy(this.origin).addScaledVector(this.direction,l),i&&i.copy(Pi).addScaledVector(Wi,g),c}intersectSphere(t,A){Yi.subVectors(t.center,this.origin);const e=Yi.dot(this.direction),i=Yi.dot(Yi)-e*e,n=t.radius*t.radius;if(i>n)return null;const s=Math.sqrt(n-i),o=e-s,r=e+s;return r<0?null:o<0?this.at(r,A):this.at(o,A)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const A=t.normal.dot(this.direction);if(0===A)return 0===t.distanceToPoint(this.origin)?0:null;const e=-(this.origin.dot(t.normal)+t.constant)/A;return e>=0?e:null}intersectPlane(t,A){const e=this.distanceToPlane(t);return null===e?null:this.at(e,A)}intersectsPlane(t){const A=t.distanceToPoint(this.origin);return 0===A||t.normal.dot(this.direction)*A<0}intersectBox(t,A){let e,i,n,s,o,r;const a=1/this.direction.x,I=1/this.direction.y,l=1/this.direction.z,g=this.origin;return a>=0?(e=(t.min.x-g.x)*a,i=(t.max.x-g.x)*a):(e=(t.max.x-g.x)*a,i=(t.min.x-g.x)*a),I>=0?(n=(t.min.y-g.y)*I,s=(t.max.y-g.y)*I):(n=(t.max.y-g.y)*I,s=(t.min.y-g.y)*I),e>s||n>i?null:((n>e||isNaN(e))&&(e=n),(s=0?(o=(t.min.z-g.z)*l,r=(t.max.z-g.z)*l):(o=(t.max.z-g.z)*l,r=(t.min.z-g.z)*l),e>r||o>i?null:((o>e||e!=e)&&(e=o),(r=0?e:i,A)))}intersectsBox(t){return null!==this.intersectBox(t,Yi)}intersectTriangle(t,A,e,i,n){zi.subVectors(A,t),Oi.subVectors(e,t),Xi.crossVectors(zi,Oi);let s,o=this.direction.dot(Xi);if(o>0){if(i)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}ki.subVectors(this.origin,t);const r=s*this.direction.dot(Oi.crossVectors(ki,Oi));if(r<0)return null;const a=s*this.direction.dot(zi.cross(ki));if(a<0)return null;if(r+a>o)return null;const I=-s*ki.dot(Xi);return I<0?null:this.at(I/o,n)}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)}},Ki=class t{constructor(A,e,i,n,s,o,r,a,I,l,g,c,d,h,C,u){t.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==A&&this.set(A,e,i,n,s,o,r,a,I,l,g,c,d,h,C,u)}set(t,A,e,i,n,s,o,r,a,I,l,g,c,d,h,C){const u=this.elements;return u[0]=t,u[4]=A,u[8]=e,u[12]=i,u[1]=n,u[5]=s,u[9]=o,u[13]=r,u[2]=a,u[6]=I,u[10]=l,u[14]=g,u[3]=c,u[7]=d,u[11]=h,u[15]=C,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 t).fromArray(this.elements)}copy(t){const A=this.elements,e=t.elements;return A[0]=e[0],A[1]=e[1],A[2]=e[2],A[3]=e[3],A[4]=e[4],A[5]=e[5],A[6]=e[6],A[7]=e[7],A[8]=e[8],A[9]=e[9],A[10]=e[10],A[11]=e[11],A[12]=e[12],A[13]=e[13],A[14]=e[14],A[15]=e[15],this}copyPosition(t){const A=this.elements,e=t.elements;return A[12]=e[12],A[13]=e[13],A[14]=e[14],this}setFromMatrix3(t){const A=t.elements;return this.set(A[0],A[3],A[6],0,A[1],A[4],A[7],0,A[2],A[5],A[8],0,0,0,0,1),this}extractBasis(t,A,e){return t.setFromMatrixColumn(this,0),A.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,A,e){return this.set(t.x,A.x,e.x,0,t.y,A.y,e.y,0,t.z,A.z,e.z,0,0,0,0,1),this}extractRotation(t){const A=this.elements,e=t.elements,i=1/qi.setFromMatrixColumn(t,0).length(),n=1/qi.setFromMatrixColumn(t,1).length(),s=1/qi.setFromMatrixColumn(t,2).length();return A[0]=e[0]*i,A[1]=e[1]*i,A[2]=e[2]*i,A[3]=0,A[4]=e[4]*n,A[5]=e[5]*n,A[6]=e[6]*n,A[7]=0,A[8]=e[8]*s,A[9]=e[9]*s,A[10]=e[10]*s,A[11]=0,A[12]=0,A[13]=0,A[14]=0,A[15]=1,this}makeRotationFromEuler(t){const A=this.elements,e=t.x,i=t.y,n=t.z,s=Math.cos(e),o=Math.sin(e),r=Math.cos(i),a=Math.sin(i),I=Math.cos(n),l=Math.sin(n);if("XYZ"===t.order){const t=s*I,e=s*l,i=o*I,n=o*l;A[0]=r*I,A[4]=-r*l,A[8]=a,A[1]=e+i*a,A[5]=t-n*a,A[9]=-o*r,A[2]=n-t*a,A[6]=i+e*a,A[10]=s*r}else if("YXZ"===t.order){const t=r*I,e=r*l,i=a*I,n=a*l;A[0]=t+n*o,A[4]=i*o-e,A[8]=s*a,A[1]=s*l,A[5]=s*I,A[9]=-o,A[2]=e*o-i,A[6]=n+t*o,A[10]=s*r}else if("ZXY"===t.order){const t=r*I,e=r*l,i=a*I,n=a*l;A[0]=t-n*o,A[4]=-s*l,A[8]=i+e*o,A[1]=e+i*o,A[5]=s*I,A[9]=n-t*o,A[2]=-s*a,A[6]=o,A[10]=s*r}else if("ZYX"===t.order){const t=s*I,e=s*l,i=o*I,n=o*l;A[0]=r*I,A[4]=i*a-e,A[8]=t*a+n,A[1]=r*l,A[5]=n*a+t,A[9]=e*a-i,A[2]=-a,A[6]=o*r,A[10]=s*r}else if("YZX"===t.order){const t=s*r,e=s*a,i=o*r,n=o*a;A[0]=r*I,A[4]=n-t*l,A[8]=i*l+e,A[1]=l,A[5]=s*I,A[9]=-o*I,A[2]=-a*I,A[6]=e*l+i,A[10]=t-n*l}else if("XZY"===t.order){const t=s*r,e=s*a,i=o*r,n=o*a;A[0]=r*I,A[4]=-l,A[8]=a*I,A[1]=t*l+n,A[5]=s*I,A[9]=e*l-i,A[2]=i*l-e,A[6]=o*I,A[10]=n*l+t}return A[3]=0,A[7]=0,A[11]=0,A[12]=0,A[13]=0,A[14]=0,A[15]=1,this}makeRotationFromQuaternion(t){return this.compose($i,t,tn)}lookAt(t,A,e){const i=this.elements;return nn.subVectors(t,A),0===nn.lengthSq()&&(nn.z=1),nn.normalize(),An.crossVectors(e,nn),0===An.lengthSq()&&(1===Math.abs(e.z)?nn.x+=1e-4:nn.z+=1e-4,nn.normalize(),An.crossVectors(e,nn)),An.normalize(),en.crossVectors(nn,An),i[0]=An.x,i[4]=en.x,i[8]=nn.x,i[1]=An.y,i[5]=en.y,i[9]=nn.y,i[2]=An.z,i[6]=en.z,i[10]=nn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,A){const e=t.elements,i=A.elements,n=this.elements,s=e[0],o=e[4],r=e[8],a=e[12],I=e[1],l=e[5],g=e[9],c=e[13],d=e[2],h=e[6],C=e[10],u=e[14],m=e[3],E=e[7],p=e[11],B=e[15],Q=i[0],M=i[4],V=i[8],y=i[12],w=i[1],f=i[5],R=i[9],N=i[13],b=i[2],U=i[6],v=i[10],S=i[14],T=i[3],D=i[7],x=i[11],Z=i[15];return n[0]=s*Q+o*w+r*b+a*T,n[4]=s*M+o*f+r*U+a*D,n[8]=s*V+o*R+r*v+a*x,n[12]=s*y+o*N+r*S+a*Z,n[1]=I*Q+l*w+g*b+c*T,n[5]=I*M+l*f+g*U+c*D,n[9]=I*V+l*R+g*v+c*x,n[13]=I*y+l*N+g*S+c*Z,n[2]=d*Q+h*w+C*b+u*T,n[6]=d*M+h*f+C*U+u*D,n[10]=d*V+h*R+C*v+u*x,n[14]=d*y+h*N+C*S+u*Z,n[3]=m*Q+E*w+p*b+B*T,n[7]=m*M+E*f+p*U+B*D,n[11]=m*V+E*R+p*v+B*x,n[15]=m*y+E*N+p*S+B*Z,this}multiplyScalar(t){const A=this.elements;return A[0]*=t,A[4]*=t,A[8]*=t,A[12]*=t,A[1]*=t,A[5]*=t,A[9]*=t,A[13]*=t,A[2]*=t,A[6]*=t,A[10]*=t,A[14]*=t,A[3]*=t,A[7]*=t,A[11]*=t,A[15]*=t,this}determinant(){const t=this.elements,A=t[0],e=t[4],i=t[8],n=t[12],s=t[1],o=t[5],r=t[9],a=t[13],I=t[2],l=t[6],g=t[10],c=t[14];return t[3]*(+n*r*l-i*a*l-n*o*g+e*a*g+i*o*c-e*r*c)+t[7]*(+A*r*c-A*a*g+n*s*g-i*s*c+i*a*I-n*r*I)+t[11]*(+A*a*l-A*o*c-n*s*l+e*s*c+n*o*I-e*a*I)+t[15]*(-i*o*I-A*r*l+A*o*g+i*s*l-e*s*g+e*r*I)}transpose(){const t=this.elements;let A;return A=t[1],t[1]=t[4],t[4]=A,A=t[2],t[2]=t[8],t[8]=A,A=t[6],t[6]=t[9],t[9]=A,A=t[3],t[3]=t[12],t[12]=A,A=t[7],t[7]=t[13],t[13]=A,A=t[11],t[11]=t[14],t[14]=A,this}setPosition(t,A,e){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=A,i[14]=e),this}invert(){const t=this.elements,A=t[0],e=t[1],i=t[2],n=t[3],s=t[4],o=t[5],r=t[6],a=t[7],I=t[8],l=t[9],g=t[10],c=t[11],d=t[12],h=t[13],C=t[14],u=t[15],m=l*C*a-h*g*a+h*r*c-o*C*c-l*r*u+o*g*u,E=d*g*a-I*C*a-d*r*c+s*C*c+I*r*u-s*g*u,p=I*h*a-d*l*a+d*o*c-s*h*c-I*o*u+s*l*u,B=d*l*r-I*h*r-d*o*g+s*h*g+I*o*C-s*l*C,Q=A*m+e*E+i*p+n*B;if(0===Q)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/Q;return t[0]=m*M,t[1]=(h*g*n-l*C*n-h*i*c+e*C*c+l*i*u-e*g*u)*M,t[2]=(o*C*n-h*r*n+h*i*a-e*C*a-o*i*u+e*r*u)*M,t[3]=(l*r*n-o*g*n-l*i*a+e*g*a+o*i*c-e*r*c)*M,t[4]=E*M,t[5]=(I*C*n-d*g*n+d*i*c-A*C*c-I*i*u+A*g*u)*M,t[6]=(d*r*n-s*C*n-d*i*a+A*C*a+s*i*u-A*r*u)*M,t[7]=(s*g*n-I*r*n+I*i*a-A*g*a-s*i*c+A*r*c)*M,t[8]=p*M,t[9]=(d*l*n-I*h*n-d*e*c+A*h*c+I*e*u-A*l*u)*M,t[10]=(s*h*n-d*o*n+d*e*a-A*h*a-s*e*u+A*o*u)*M,t[11]=(I*o*n-s*l*n-I*e*a+A*l*a+s*e*c-A*o*c)*M,t[12]=B*M,t[13]=(I*h*i-d*l*i+d*e*g-A*h*g-I*e*C+A*l*C)*M,t[14]=(d*o*i-s*h*i-d*e*r+A*h*r+s*e*C-A*o*C)*M,t[15]=(s*l*i-I*o*i+I*e*r-A*l*r-s*e*g+A*o*g)*M,this}scale(t){const A=this.elements,e=t.x,i=t.y,n=t.z;return A[0]*=e,A[4]*=i,A[8]*=n,A[1]*=e,A[5]*=i,A[9]*=n,A[2]*=e,A[6]*=i,A[10]*=n,A[3]*=e,A[7]*=i,A[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,A=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(A,e,i))}makeTranslation(t,A,e){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,A,0,0,1,e,0,0,0,1),this}makeRotationX(t){const A=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,A,-e,0,0,e,A,0,0,0,0,1),this}makeRotationY(t){const A=Math.cos(t),e=Math.sin(t);return this.set(A,0,e,0,0,1,0,0,-e,0,A,0,0,0,0,1),this}makeRotationZ(t){const A=Math.cos(t),e=Math.sin(t);return this.set(A,-e,0,0,e,A,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,A){const e=Math.cos(A),i=Math.sin(A),n=1-e,s=t.x,o=t.y,r=t.z,a=n*s,I=n*o;return this.set(a*s+e,a*o-i*r,a*r+i*o,0,a*o+i*r,I*o+e,I*r-i*s,0,a*r-i*o,I*r+i*s,n*r*r+e,0,0,0,0,1),this}makeScale(t,A,e){return this.set(t,0,0,0,0,A,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,A,e,i,n,s){return this.set(1,e,n,0,t,1,s,0,A,i,1,0,0,0,0,1),this}compose(t,A,e){const i=this.elements,n=A._x,s=A._y,o=A._z,r=A._w,a=n+n,I=s+s,l=o+o,g=n*a,c=n*I,d=n*l,h=s*I,C=s*l,u=o*l,m=r*a,E=r*I,p=r*l,B=e.x,Q=e.y,M=e.z;return i[0]=(1-(h+u))*B,i[1]=(c+p)*B,i[2]=(d-E)*B,i[3]=0,i[4]=(c-p)*Q,i[5]=(1-(g+u))*Q,i[6]=(C+m)*Q,i[7]=0,i[8]=(d+E)*M,i[9]=(C-m)*M,i[10]=(1-(g+h))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,A,e){const i=this.elements;let n=qi.set(i[0],i[1],i[2]).length();const s=qi.set(i[4],i[5],i[6]).length(),o=qi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],_i.copy(this);const r=1/n,a=1/s,I=1/o;return _i.elements[0]*=r,_i.elements[1]*=r,_i.elements[2]*=r,_i.elements[4]*=a,_i.elements[5]*=a,_i.elements[6]*=a,_i.elements[8]*=I,_i.elements[9]*=I,_i.elements[10]*=I,A.setFromRotationMatrix(_i),e.x=n,e.y=s,e.z=o,this}makePerspective(t,A,e,i,n,s,o=2e3){const r=this.elements,a=2*n/(A-t),I=2*n/(e-i),l=(A+t)/(A-t),g=(e+i)/(e-i);let c,d;if(o===De)c=-(s+n)/(s-n),d=-2*s*n/(s-n);else{if(o!==xe)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);c=-s/(s-n),d=-s*n/(s-n)}return r[0]=a,r[4]=0,r[8]=l,r[12]=0,r[1]=0,r[5]=I,r[9]=g,r[13]=0,r[2]=0,r[6]=0,r[10]=c,r[14]=d,r[3]=0,r[7]=0,r[11]=-1,r[15]=0,this}makeOrthographic(t,A,e,i,n,s,o=2e3){const r=this.elements,a=1/(A-t),I=1/(e-i),l=1/(s-n),g=(A+t)*a,c=(e+i)*I;let d,h;if(o===De)d=(s+n)*l,h=-2*l;else{if(o!==xe)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);d=n*l,h=-1*l}return r[0]=2*a,r[4]=0,r[8]=0,r[12]=-g,r[1]=0,r[5]=2*I,r[9]=0,r[13]=-c,r[2]=0,r[6]=0,r[10]=h,r[14]=-d,r[3]=0,r[7]=0,r[11]=0,r[15]=1,this}equals(t){const A=this.elements,e=t.elements;for(let i=0;i<16;i++)if(A[i]!==e[i])return!1;return!0}fromArray(t,A=0){for(let e=0;e<16;e++)this.elements[e]=t[e+A];return this}toArray(t=[],A=0){const e=this.elements;return t[A]=e[0],t[A+1]=e[1],t[A+2]=e[2],t[A+3]=e[3],t[A+4]=e[4],t[A+5]=e[5],t[A+6]=e[6],t[A+7]=e[7],t[A+8]=e[8],t[A+9]=e[9],t[A+10]=e[10],t[A+11]=e[11],t[A+12]=e[12],t[A+13]=e[13],t[A+14]=e[14],t[A+15]=e[15],t}};const qi=new Bi,_i=new Ki,$i=new Bi(0,0,0),tn=new Bi(1,1,1),An=new Bi,en=new Bi,nn=new Bi,sn=new Ki,on=new pi;let rn=class t{constructor(A=0,e=0,i=0,n=t.DEFAULT_ORDER){this.isEuler=!0,this._x=A,this._y=e,this._z=i,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,A,e,i=this._order){return this._x=t,this._y=A,this._z=e,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,A=this._order,e=!0){const i=t.elements,n=i[0],s=i[4],o=i[8],r=i[1],a=i[5],I=i[9],l=i[2],g=i[6],c=i[10];switch(A){case"XYZ":this._y=Math.asin(Le(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-I,c),this._z=Math.atan2(-s,n)):(this._x=Math.atan2(g,a),this._z=0);break;case"YXZ":this._x=Math.asin(-Le(I,-1,1)),Math.abs(I)<.9999999?(this._y=Math.atan2(o,c),this._z=Math.atan2(r,a)):(this._y=Math.atan2(-l,n),this._z=0);break;case"ZXY":this._x=Math.asin(Le(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-l,c),this._z=Math.atan2(-s,a)):(this._y=0,this._z=Math.atan2(r,n));break;case"ZYX":this._y=Math.asin(-Le(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(g,c),this._z=Math.atan2(r,n)):(this._x=0,this._z=Math.atan2(-s,a));break;case"YZX":this._z=Math.asin(Le(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-I,a),this._y=Math.atan2(-l,n)):(this._x=0,this._y=Math.atan2(o,c));break;case"XZY":this._z=Math.asin(-Le(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,a),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-I,c),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+A)}return this._order=A,!0===e&&this._onChangeCallback(),this}setFromQuaternion(t,A,e){return sn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(sn,A,e)}setFromVector3(t,A=this._order){return this.set(t.x,t.y,t.z,A)}reorder(t){return on.setFromEuler(this),this.setFromQuaternion(on,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],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],A=0){return t[A]=this._x,t[A+1]=this._y,t[A+2]=this._z,t[A+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}};rn.DEFAULT_ORDER="XYZ";let an=class{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const A=this.geometry.parameters;if(void 0!==A&&void 0!==A.shapes){const e=A.shapes;if(Array.isArray(e))for(let A=0,i=e.length;A0){i.children=[];for(let A=0;A0){i.animations=[];for(let A=0;A0&&(e.geometries=A),i.length>0&&(e.materials=i),n.length>0&&(e.textures=n),o.length>0&&(e.images=o),r.length>0&&(e.shapes=r),a.length>0&&(e.skeletons=a),I.length>0&&(e.animations=I),l.length>0&&(e.nodes=l)}return e.object=i,e;function s(t){const A=[];for(const e in t){const i=t[e];delete i.metadata,A.push(i)}return A}}clone(t){return(new this.constructor).copy(this,t)}copy(t,A=!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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===A)for(let e=0;e0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,A,e,i,n){wn.subVectors(i,A),fn.subVectors(e,A),Rn.subVectors(t,A);const s=wn.dot(wn),o=wn.dot(fn),r=wn.dot(Rn),a=fn.dot(fn),I=fn.dot(Rn),l=s*a-o*o;if(0===l)return n.set(0,0,0),null;const g=1/l,c=(a*r-o*I)*g,d=(s*I-o*r)*g;return n.set(1-c-d,d,c)}static containsPoint(t,A,e,i){return null!==this.getBarycoord(t,A,e,i,Nn)&&Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(t,A,e,i,n,s,o,r){return null===this.getBarycoord(t,A,e,i,Nn)?(r.x=0,r.y=0,"z"in r&&(r.z=0),"w"in r&&(r.w=0),null):(r.setScalar(0),r.addScaledVector(n,Nn.x),r.addScaledVector(s,Nn.y),r.addScaledVector(o,Nn.z),r)}static getInterpolatedAttribute(t,A,e,i,n,s){return xn.setScalar(0),Zn.setScalar(0),Jn.setScalar(0),xn.fromBufferAttribute(t,A),Zn.fromBufferAttribute(t,e),Jn.fromBufferAttribute(t,i),s.setScalar(0),s.addScaledVector(xn,n.x),s.addScaledVector(Zn,n.y),s.addScaledVector(Jn,n.z),s}static isFrontFacing(t,A,e,i){return wn.subVectors(e,A),fn.subVectors(t,A),wn.cross(fn).dot(i)<0}set(t,A,e){return this.a.copy(t),this.b.copy(A),this.c.copy(e),this}setFromPointsAndIndices(t,A,e,i){return this.a.copy(t[A]),this.b.copy(t[e]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,A,e,i){return this.a.fromBufferAttribute(t,A),this.b.fromBufferAttribute(t,e),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return wn.subVectors(this.c,this.b),fn.subVectors(this.a,this.b),.5*wn.cross(fn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Fn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,A){return Fn.getBarycoord(t,this.a,this.b,this.c,A)}getInterpolation(t,A,e,i,n){return Fn.getInterpolation(t,this.a,this.b,this.c,A,e,i,n)}containsPoint(t){return Fn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Fn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,A){const e=this.a,i=this.b,n=this.c;let s,o;bn.subVectors(i,e),Un.subVectors(n,e),Sn.subVectors(t,e);const r=bn.dot(Sn),a=Un.dot(Sn);if(r<=0&&a<=0)return A.copy(e);Tn.subVectors(t,i);const I=bn.dot(Tn),l=Un.dot(Tn);if(I>=0&&l<=I)return A.copy(i);const g=r*l-I*a;if(g<=0&&r>=0&&I<=0)return s=r/(r-I),A.copy(e).addScaledVector(bn,s);Dn.subVectors(t,n);const c=bn.dot(Dn),d=Un.dot(Dn);if(d>=0&&c<=d)return A.copy(n);const h=c*a-r*d;if(h<=0&&a>=0&&d<=0)return o=a/(a-d),A.copy(e).addScaledVector(Un,o);const C=I*d-c*l;if(C<=0&&l-I>=0&&c-d>=0)return vn.subVectors(n,i),o=(l-I)/(l-I+(c-d)),A.copy(i).addScaledVector(vn,o);const u=1/(C+h+g);return s=h*u,o=g*u,A.copy(e).addScaledVector(bn,s).addScaledVector(Un,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Gn={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},jn={h:0,s:0,l:0},Ln={h:0,s:0,l:0};function Yn(t,A,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+6*(A-t)*e:e<.5?A:e<2/3?t+6*(A-t)*(2/3-e):t}let Pn=class{constructor(t,A,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,A,e)}set(t,A,e){if(void 0===A&&void 0===e){const A=t;A&&A.isColor?this.copy(A):"number"==typeof A?this.setHex(A):"string"==typeof A&&this.setStyle(A)}else this.setRGB(t,A,e);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,A=Ee){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ni.toWorkingColorSpace(this,A),this}setRGB(t,A,e,i=ni.workingColorSpace){return this.r=t,this.g=A,this.b=e,ni.toWorkingColorSpace(this,i),this}setHSL(t,A,e,i=ni.workingColorSpace){if(t=(t%(n=1)+n)%n,A=Le(A,0,1),e=Le(e,0,1),0===A)this.r=this.g=this.b=e;else{const i=e<=.5?e*(1+A):e+A-e*A,n=2*e-i;this.r=Yn(n,i,t+1/3),this.g=Yn(n,i,t),this.b=Yn(n,i,t-1/3)}var n;return ni.toWorkingColorSpace(this,i),this}setStyle(t,A=Ee){function e(A){void 0!==A&&parseFloat(A)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return e(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,A);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return e(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,A);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return e(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,A);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const e=i[1],n=e.length;if(3===n)return this.setRGB(parseInt(e.charAt(0),16)/15,parseInt(e.charAt(1),16)/15,parseInt(e.charAt(2),16)/15,A);if(6===n)return this.setHex(parseInt(e,16),A);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,A);return this}setColorName(t,A=Ee){const e=Gn[t.toLowerCase()];return void 0!==e?this.setHex(e,A):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=si(t.r),this.g=si(t.g),this.b=si(t.b),this}copyLinearToSRGB(t){return this.r=oi(t.r),this.g=oi(t.g),this.b=oi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ee){return ni.fromWorkingColorSpace(Wn.copy(this),t),65536*Math.round(Le(255*Wn.r,0,255))+256*Math.round(Le(255*Wn.g,0,255))+Math.round(Le(255*Wn.b,0,255))}getHexString(t=Ee){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,A=ni.workingColorSpace){ni.fromWorkingColorSpace(Wn.copy(this),A);const e=Wn.r,i=Wn.g,n=Wn.b,s=Math.max(e,i,n),o=Math.min(e,i,n);let r,a;const I=(o+s)/2;if(o===s)r=0,a=0;else{const t=s-o;switch(a=I<=.5?t/(s+o):t/(2-s-o),s){case e:r=(i-n)/t+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const A in t){const e=t[A];if(void 0===e){console.warn(`THREE.Material: parameter '${A}' has value of undefined.`);continue}const i=this[A];void 0!==i?i&&i.isColor?i.set(e):i&&i.isVector3&&e&&e.isVector3?i.copy(e):this[A]=e:console.warn(`THREE.Material: '${A}' is not a property of THREE.${this.type}.`)}}toJSON(t){const A=void 0===t||"string"==typeof t;A&&(t={textures:{},images:{}});const e={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(t){const A=[];for(const e in t){const i=t[e];delete i.metadata,A.push(i)}return A}if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),this.color&&this.color.isColor&&(e.color=this.color.getHex()),void 0!==this.roughness&&(e.roughness=this.roughness),void 0!==this.metalness&&(e.metalness=this.metalness),void 0!==this.sheen&&(e.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(e.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(e.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(e.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(e.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(e.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(e.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(e.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(e.shininess=this.shininess),void 0!==this.clearcoat&&(e.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(e.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(e.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(e.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(e.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,e.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(e.dispersion=this.dispersion),void 0!==this.iridescence&&(e.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(e.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(e.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(e.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(e.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(e.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(e.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(e.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(e.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(e.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(e.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(e.lightMap=this.lightMap.toJSON(t).uuid,e.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(e.aoMap=this.aoMap.toJSON(t).uuid,e.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(e.bumpMap=this.bumpMap.toJSON(t).uuid,e.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(e.normalMap=this.normalMap.toJSON(t).uuid,e.normalMapType=this.normalMapType,e.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(e.displacementMap=this.displacementMap.toJSON(t).uuid,e.displacementScale=this.displacementScale,e.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(e.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(e.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(e.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(e.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(e.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(e.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(e.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(e.combine=this.combine)),void 0!==this.envMapRotation&&(e.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(e.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(e.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(e.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(e.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(e.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(e.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(e.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(e.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(e.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(e.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(e.size=this.size),null!==this.shadowSide&&(e.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(e.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(e.blending=this.blending),0!==this.side&&(e.side=this.side),!0===this.vertexColors&&(e.vertexColors=!0),this.opacity<1&&(e.opacity=this.opacity),!0===this.transparent&&(e.transparent=!0),204!==this.blendSrc&&(e.blendSrc=this.blendSrc),205!==this.blendDst&&(e.blendDst=this.blendDst),this.blendEquation!==Ut&&(e.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(e.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(e.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(e.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(e.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(e.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(e.depthFunc=this.depthFunc),!1===this.depthTest&&(e.depthTest=this.depthTest),!1===this.depthWrite&&(e.depthWrite=this.depthWrite),!1===this.colorWrite&&(e.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(e.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(e.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(e.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(e.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Me&&(e.stencilFail=this.stencilFail),this.stencilZFail!==Me&&(e.stencilZFail=this.stencilZFail),this.stencilZPass!==Me&&(e.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(e.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(e.rotation=this.rotation),!0===this.polygonOffset&&(e.polygonOffset=!0),0!==this.polygonOffsetFactor&&(e.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(e.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(e.linewidth=this.linewidth),void 0!==this.dashSize&&(e.dashSize=this.dashSize),void 0!==this.gapSize&&(e.gapSize=this.gapSize),void 0!==this.scale&&(e.scale=this.scale),!0===this.dithering&&(e.dithering=!0),this.alphaTest>0&&(e.alphaTest=this.alphaTest),!0===this.alphaHash&&(e.alphaHash=!0),!0===this.alphaToCoverage&&(e.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(e.premultipliedAlpha=!0),!0===this.forceSinglePass&&(e.forceSinglePass=!0),!0===this.wireframe&&(e.wireframe=!0),this.wireframeLinewidth>1&&(e.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(e.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(e.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(e.flatShading=!0),!1===this.visible&&(e.visible=!1),!1===this.toneMapped&&(e.toneMapped=!1),!1===this.fog&&(e.fog=!1),Object.keys(this.userData).length>0&&(e.userData=this.userData),A){const A=i(t.textures),n=i(t.images);A.length>0&&(e.textures=A),n.length>0&&(e.images=n)}return e}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.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,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;const A=t.clippingPlanes;let e=null;if(null!==A){const t=A.length;e=new Array(t);for(let i=0;i!==t;++i)e[i]=A[i].clone()}return this.clippingPlanes=e,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.alphaHash=t.alphaHash,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){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}};class On extends zn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Pn(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.envMapRotation=new rn,this.combine=0,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.envMapRotation.copy(t.envMapRotation),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}}const Xn=new Bi,Hn=new ke;let Kn=0;class qn{constructor(t,A,e=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Kn++}),this.name="",this.array=t,this.itemSize=A,this.count=void 0!==t?t.length/A:0,this.normalized=e,this.usage=ve,this.updateRanges=[],this.gpuType=QA,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,A){this.updateRanges.push({start:t,count:A})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=t.gpuType,this}copyAt(t,A,e){t*=this.itemSize,e*=A.itemSize;for(let i=0,n=this.itemSize;iA.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),A.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Vi);const t=this.attributes.position,A=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Bi(-1/0,-1/0,-1/0),new Bi(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),A)for(let e=0,i=A.length;e0&&(t.userData=this.userData),void 0!==this.parameters){const A=this.parameters;for(const e in A)void 0!==A[e]&&(t[e]=A[e]);return t}t.data={attributes:{}};const A=this.index;null!==A&&(t.data.index={type:A.array.constructor.name,array:Array.prototype.slice.call(A.array)});const e=this.attributes;for(const r in e){const A=e[r];t.data.attributes[r]=A.toJSON(t.data)}const i={};let n=!1;for(const r in this.morphAttributes){const A=this.morphAttributes[r],e=[];for(let i=0,n=A.length;i0&&(i[r]=e,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.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;const A={};this.name=t.name;const e=t.index;null!==e&&this.setIndex(e.clone());const i=t.attributes;for(const a in i){const t=i[a];this.setAttribute(a,t.clone(A))}const n=t.morphAttributes;for(const a in n){const t=[],e=n[a];for(let i=0,n=e.length;i0){const e=t[A[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,A=e.length;t(t.far-t.near)**2)return}Is.copy(n).invert(),ls.copy(t.ray).applyMatrix4(Is),null!==e.boundingBox&&!1===ls.intersectsBox(e.boundingBox)||this._computeIntersections(t,A,ls)}}_computeIntersections(t,A,e){let i;const n=this.geometry,s=this.material,o=n.index,r=n.attributes.position,a=n.attributes.uv,I=n.attributes.uv1,l=n.attributes.normal,g=n.groups,c=n.drawRange;if(null!==o)if(Array.isArray(s))for(let d=0,h=g.length;de.far?null:{distance:I,point:ps.clone(),object:t}}(t,A,e,i,ds,hs,Cs,Es);if(l){const t=new Bi;Fn.getBarycoord(Es,ds,hs,Cs,t),n&&(l.uv=Fn.getInterpolatedAttribute(n,r,a,I,t,new ke)),s&&(l.uv1=Fn.getInterpolatedAttribute(s,r,a,I,t,new ke)),o&&(l.normal=Fn.getInterpolatedAttribute(o,r,a,I,t,new Bi),l.normal.dot(i.direction)>0&&l.normal.multiplyScalar(-1));const A={a:r,b:a,c:I,normal:new Bi,materialIndex:0};Fn.getNormal(ds,hs,Cs,A.normal),l.face=A,l.barycoord=t}return l}class Ms extends as{constructor(t=1,A=1,e=1,i=1,n=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:A,depth:e,widthSegments:i,heightSegments:n,depthSegments:s};const o=this;i=Math.floor(i),n=Math.floor(n),s=Math.floor(s);const r=[],a=[],I=[],l=[];let g=0,c=0;function d(t,A,e,i,n,s,d,h,C,u,m){const E=s/C,p=d/u,B=s/2,Q=d/2,M=h/2,V=C+1,y=u+1;let w=0,f=0;const R=new Bi;for(let o=0;o0?1:-1,I.push(R.x,R.y,R.z),l.push(r/C),l.push(1-o/u),w+=1}}for(let o=0;o0&&(A.defines=this.defines),A.vertexShader=this.vertexShader,A.fragmentShader=this.fragmentShader,A.lights=this.lights,A.clipping=this.clipping;const e={};for(const i in this.extensions)!0===this.extensions[i]&&(e[i]=!0);return Object.keys(e).length>0&&(A.extensions=e),A}}class Ns extends yn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ki,this.projectionMatrix=new Ki,this.projectionMatrixInverse=new Ki,this.coordinateSystem=De}copy(t,A){return super.copy(t,A),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,A){super.updateWorldMatrix(t,A),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const bs=new Bi,Us=new ke,vs=new ke;class Ss extends Ns{constructor(t=50,A=1,e=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=e,this.far=i,this.focus=10,this.aspect=A,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,A){return super.copy(t,A),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=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const A=.5*this.getFilmHeight()/t;this.fov=2*Ge*Math.atan(A),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Fe*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ge*Math.atan(Math.tan(.5*Fe*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,A,e){bs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),A.set(bs.x,bs.y).multiplyScalar(-t/bs.z),bs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(bs.x,bs.y).multiplyScalar(-t/bs.z)}getViewSize(t,A){return this.getViewBounds(t,Us,vs),A.subVectors(vs,Us)}setViewOffset(t,A,e,i,n,s){this.aspect=t/A,null===this.view&&(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=A,this.view.offsetX=e,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let A=t*Math.tan(.5*Fe*this.fov)/this.zoom,e=2*A,i=this.aspect*e,n=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,o=s.fullHeight;n+=s.offsetX*i/t,A-=s.offsetY*e/o,i*=s.width/t,e*=s.height/o}const o=this.filmOffset;0!==o&&(n+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,A,A-e,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const A=super.toJSON(t);return A.object.fov=this.fov,A.object.zoom=this.zoom,A.object.near=this.near,A.object.far=this.far,A.object.focus=this.focus,A.object.aspect=this.aspect,null!==this.view&&(A.object.view=Object.assign({},this.view)),A.object.filmGauge=this.filmGauge,A.object.filmOffset=this.filmOffset,A}}const Ts=-90;class Ds extends yn{constructor(t,A,e){super(),this.type="CubeCamera",this.renderTarget=e,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ss(Ts,1,t,A);i.layers=this.layers,this.add(i);const n=new Ss(Ts,1,t,A);n.layers=this.layers,this.add(n);const s=new Ss(Ts,1,t,A);s.layers=this.layers,this.add(s);const o=new Ss(Ts,1,t,A);o.layers=this.layers,this.add(o);const r=new Ss(Ts,1,t,A);r.layers=this.layers,this.add(r);const a=new Ss(Ts,1,t,A);a.layers=this.layers,this.add(a)}updateCoordinateSystem(){const t=this.coordinateSystem,A=this.children.concat(),[e,i,n,s,o,r]=A;for(const a of A)this.remove(a);if(t===De)e.up.set(0,1,0),e.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),r.up.set(0,1,0),r.lookAt(0,0,-1);else{if(t!==xe)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);e.up.set(0,-1,0),e.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),r.up.set(0,-1,0),r.lookAt(0,0,-1)}for(const a of A)this.add(a),a.updateMatrixWorld()}update(t,A){null===this.parent&&this.updateMatrixWorld();const{renderTarget:e,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[n,s,o,r,a,I]=this.children,l=t.getRenderTarget(),g=t.getActiveCubeFace(),c=t.getActiveMipmapLevel(),d=t.xr.enabled;t.xr.enabled=!1;const h=e.texture.generateMipmaps;e.texture.generateMipmaps=!1,t.setRenderTarget(e,0,i),t.render(A,n),t.setRenderTarget(e,1,i),t.render(A,s),t.setRenderTarget(e,2,i),t.render(A,o),t.setRenderTarget(e,3,i),t.render(A,r),t.setRenderTarget(e,4,i),t.render(A,a),e.texture.generateMipmaps=h,t.setRenderTarget(e,5,i),t.render(A,I),t.setRenderTarget(l,g,c),t.xr.enabled=d,e.texture.needsPMREMUpdate=!0}}class xs extends di{constructor(t=[],A=301,e,i,n,s,o,r,a,I){super(t,A,e,i,n,s,o,r,a,I),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Zs extends ui{constructor(t=1,A={}){super(t,t,A),this.isWebGLCubeRenderTarget=!0;const e={width:t,height:t,depth:1},i=[e,e,e,e,e,e];this.texture=new xs(i,A.mapping,A.wrapS,A.wrapT,A.magFilter,A.minFilter,A.format,A.type,A.anisotropy,A.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==A.generateMipmaps&&A.generateMipmaps,this.texture.minFilter=void 0!==A.minFilter?A.minFilter:hA}fromEquirectangularTexture(t,A){this.texture.type=A.type,this.texture.colorSpace=A.colorSpace,this.texture.generateMipmaps=A.generateMipmaps,this.texture.minFilter=A.minFilter,this.texture.magFilter=A.magFilter;const e=new Ms(5,5,5),i=new Rs({name:"CubemapFromEquirect",uniforms:Vs({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});i.uniforms.tEquirect.value=A;const n=new Bs(e,i),s=A.minFilter;return A.minFilter===uA&&(A.minFilter=hA),new Ds(1,10,this).update(t,n),A.minFilter=s,n.geometry.dispose(),n.material.dispose(),this}clear(t,A=!0,e=!0,i=!0){const n=t.getRenderTarget();for(let s=0;s<6;s++)t.setRenderTarget(this,s),t.clear(A,e,i);t.setRenderTarget(n)}}class Js extends yn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Fs={type:"move"};class Gs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Js,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Bi,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Bi),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Bi,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Bi),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const A=this._hand;if(A)for(const e of t.hand.values())this._getHandJoint(A,e)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,A,e){let i=null,n=null,s=null;const o=this._targetRay,r=this._grip,a=this._hand;if(t&&"visible-blurred"!==A.session.visibilityState){if(a&&t.hand){s=!0;for(const s of t.hand.values()){const t=A.getJointPose(s,e),i=this._getHandJoint(a,s);null!==t&&(i.matrix.fromArray(t.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=t.radius),i.visible=null!==t}const i=a.joints["index-finger-tip"],n=a.joints["thumb-tip"],o=i.position.distanceTo(n.position),r=.02,I=.005;a.inputState.pinching&&o>r+I?(a.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!a.inputState.pinching&&o<=r-I&&(a.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==r&&t.gripSpace&&(n=A.getPose(t.gripSpace,e),null!==n&&(r.matrix.fromArray(n.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,n.linearVelocity?(r.hasLinearVelocity=!0,r.linearVelocity.copy(n.linearVelocity)):r.hasLinearVelocity=!1,n.angularVelocity?(r.hasAngularVelocity=!0,r.angularVelocity.copy(n.angularVelocity)):r.hasAngularVelocity=!1));null!==o&&(i=A.getPose(t.targetRaySpace,e),null===i&&null!==n&&(i=n),null!==i&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Fs)))}return null!==o&&(o.visible=null!==i),null!==r&&(r.visible=null!==n),null!==a&&(a.visible=null!==s),this}_getHandJoint(t,A){if(void 0===t.joints[A.jointName]){const e=new Js;e.matrixAutoUpdate=!1,e.visible=!1,t.joints[A.jointName]=e,t.add(e)}return t.joints[A.jointName]}}class js{constructor(t,A=25e-5){this.isFogExp2=!0,this.name="",this.color=new Pn(t),this.density=A}clone(){return new js(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Ls{constructor(t,A=1,e=1e3){this.isFog=!0,this.name="",this.color=new Pn(t),this.near=A,this.far=e}clone(){return new Ls(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Ys extends yn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new rn,this.environmentIntensity=1,this.environmentRotation=new rn,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,A){return super.copy(t,A),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const A=super.toJSON(t);return null!==this.fog&&(A.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(A.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(A.object.backgroundIntensity=this.backgroundIntensity),A.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(A.object.environmentIntensity=this.environmentIntensity),A.object.environmentRotation=this.environmentRotation.toArray(),A}}class Ps{constructor(t,A){this.isInterleavedBuffer=!0,this.array=t,this.stride=A,this.count=void 0!==t?t.length/A:0,this.usage=ve,this.updateRanges=[],this.version=0,this.uuid=je()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,A){this.updateRanges.push({start:t,count:A})}clearUpdateRanges(){this.updateRanges.length=0}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,A,e){t*=this.stride,e*=A.stride;for(let i=0,n=this.stride;it.far||A.push({distance:r,point:Xs.clone(),uv:Fn.getInterpolation(Xs,to,Ao,eo,io,no,so,new ke),face:null,object:this})}copy(t,A){return super.copy(t,A),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function ro(t,A,e,i,n,s){qs.subVectors(t,e).addScalar(.5).multiply(i),void 0!==n?(_s.x=s*qs.x-n*qs.y,_s.y=n*qs.x+s*qs.y):_s.copy(qs),t.copy(A),t.x+=_s.x,t.y+=_s.y,t.applyMatrix4($s)}const ao=new Bi,Io=new Bi;class lo extends yn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const A=t.levels;for(let e=0,i=A.length;e0){let e,i;for(e=1,i=A.length;e0){ao.setFromMatrixPosition(this.matrixWorld);const e=t.ray.origin.distanceTo(ao);this.getObjectForDistance(e).raycast(t,A)}}update(t){const A=this.levels;if(A.length>1){ao.setFromMatrixPosition(t.matrixWorld),Io.setFromMatrixPosition(this.matrixWorld);const e=ao.distanceTo(Io)/t.zoom;let i,n;for(A[0].object.visible=!0,i=1,n=A.length;i=t))break;A[i-1].object.visible=!1,A[i].object.visible=!0}for(this._currentLevel=i-1;i1?null:A.copy(t.start).addScaledVector(e,n)}intersectsLine(t){const A=this.distanceToPoint(t.start),e=this.distanceToPoint(t.end);return A<0&&e>0||e<0&&A>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,A){const e=A||Fo.getNormalMatrix(t),i=this.coplanarPoint(Zo).applyMatrix4(t),n=this.normal.applyMatrix3(e).normalize();return this.constant=-i.dot(n),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)}}const jo=new Li,Lo=new Bi;class Yo{constructor(t=new Go,A=new Go,e=new Go,i=new Go,n=new Go,s=new Go){this.planes=[t,A,e,i,n,s]}set(t,A,e,i,n,s){const o=this.planes;return o[0].copy(t),o[1].copy(A),o[2].copy(e),o[3].copy(i),o[4].copy(n),o[5].copy(s),this}copy(t){const A=this.planes;for(let e=0;e<6;e++)A[e].copy(t.planes[e]);return this}setFromProjectionMatrix(t,A=2e3){const e=this.planes,i=t.elements,n=i[0],s=i[1],o=i[2],r=i[3],a=i[4],I=i[5],l=i[6],g=i[7],c=i[8],d=i[9],h=i[10],C=i[11],u=i[12],m=i[13],E=i[14],p=i[15];if(e[0].setComponents(r-n,g-a,C-c,p-u).normalize(),e[1].setComponents(r+n,g+a,C+c,p+u).normalize(),e[2].setComponents(r+s,g+I,C+d,p+m).normalize(),e[3].setComponents(r-s,g-I,C-d,p-m).normalize(),e[4].setComponents(r-o,g-l,C-h,p-E).normalize(),A===De)e[5].setComponents(r+o,g+l,C+h,p+E).normalize();else{if(A!==xe)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+A);e[5].setComponents(o,l,h,E).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),jo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const A=t.geometry;null===A.boundingSphere&&A.computeBoundingSphere(),jo.copy(A.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(jo)}intersectsSprite(t){return jo.center.set(0,0,0),jo.radius=.7071067811865476,jo.applyMatrix4(t.matrixWorld),this.intersectsSphere(jo)}intersectsSphere(t){const A=this.planes,e=t.center,i=-t.radius;for(let n=0;n<6;n++)if(A[n].distanceToPoint(e)0?t.max.x:t.min.x,Lo.y=i.normal.y>0?t.max.y:t.min.y,Lo.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Lo)<0)return!1}return!0}containsPoint(t){const A=this.planes;for(let e=0;e<6;e++)if(A[e].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Po(t,A){return t-A}function Wo(t,A){return t.z-A.z}function ko(t,A){return A.z-t.z}class zo{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,A,e,i){const n=this.pool,s=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1,index:-1});const o=n[this.index];s.push(o),this.index++,o.start=t,o.count=A,o.z=e,o.index=i}reset(){this.list.length=0,this.index=0}}const Oo=new Ki,Xo=new Pn(1,1,1),Ho=new Yo,Ko=new Vi,qo=new Li,_o=new Bi,$o=new Bi,tr=new Bi,Ar=new zo,er=new Bs,ir=[];function nr(t,A,e=0){const i=A.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==A.array.constructor){const n=t.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);A.setIndex(new qn(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const A=this.geometry;if(Boolean(t.getIndex())!==Boolean(A.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const e in A.attributes){if(!t.hasAttribute(e))throw new Error(`THREE.BatchedMesh: Added geometry missing "${e}". All geometries must have consistent attributes.`);const i=t.getAttribute(e),n=A.getAttribute(e);if(i.itemSize!==n.itemSize||i.normalized!==n.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const A=this._instanceInfo;if(t<0||t>=A.length||!1===A[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const A=this._geometryInfo;if(t<0||t>=A.length||!1===A[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Vi);const t=this.boundingBox,A=this._instanceInfo;t.makeEmpty();for(let e=0,i=A.length;e=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const A={visible:!0,active:!0,geometryIndex:t};let e=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Po),e=this._availableInstanceIds.shift(),this._instanceInfo[e]=A):(e=this._instanceInfo.length,this._instanceInfo.push(A));const i=this._matricesTexture;Oo.identity().toArray(i.image.data,16*e),i.needsUpdate=!0;const n=this._colorsTexture;return n&&(Xo.toArray(n.image.data,4*e),n.needsUpdate=!0),this._visibilityChanged=!0,e}addGeometry(t,A=-1,e=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===A?t.getAttribute("position").count:A;const s=t.getIndex();if(null!==s&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===e?s.count:e),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Po),o=this._availableGeometryIds.shift(),n[o]=i):(o=this._geometryCount,this._geometryCount++,n.push(i)),this.setGeometryAt(o,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,o}setGeometryAt(t,A){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(A);const e=this.geometry,i=null!==e.getIndex(),n=e.getIndex(),s=A.getIndex(),o=this._geometryInfo[t];if(i&&s.count>o.reservedIndexCount||A.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const r=o.vertexStart,a=o.reservedVertexCount;o.vertexCount=A.getAttribute("position").count;for(const I in e.attributes){const t=A.getAttribute(I),i=e.getAttribute(I);nr(t,i,r);const n=t.itemSize;for(let A=t.count,e=a;A=A.length||!1===A[t].active)return this;const e=this._instanceInfo;for(let i=0,n=e.length;iA)).sort(((t,A)=>e[t].vertexStart-e[A].vertexStart)),n=this.geometry;for(let s=0,o=e.length;s=this._geometryCount)return null;const e=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Vi,A=e.index,n=e.attributes.position;for(let e=i.start,s=i.start+i.count;e=this._geometryCount)return null;const e=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const A=new Li;this.getBoundingBoxAt(t,Ko),Ko.getCenter(A.center);const n=e.index,s=e.attributes.position;let o=0;for(let t=i.start,e=i.start+i.count;tt.active));if(Math.max(...e.map((t=>t.vertexStart+t.reservedVertexCount)))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${A}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...e.map((t=>t.indexStart+t.reservedIndexCount)))>A)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${A}. Cannot shrink further.`);const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=A,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new as,this._initializeGeometry(i));const n=this.geometry;i.index&&sr(i.index.array,n.index.array);for(const s in i.attributes)sr(i.attributes[s].array,n.attributes[s].array)}raycast(t,A){const e=this._instanceInfo,i=this._geometryInfo,n=this.matrixWorld,s=this.geometry;er.material=this.material,er.geometry.index=s.index,er.geometry.attributes=s.attributes,null===er.geometry.boundingBox&&(er.geometry.boundingBox=new Vi),null===er.geometry.boundingSphere&&(er.geometry.boundingSphere=new Li);for(let o=0,r=e.length;o({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null}))),this._instanceInfo=t._instanceInfo.map((t=>({...t}))),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,A,e,i,n){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),o=null===s?1:s.array.BYTES_PER_ELEMENT,r=this._instanceInfo,a=this._multiDrawStarts,I=this._multiDrawCounts,l=this._geometryInfo,g=this.perObjectFrustumCulled,c=this._indirectTexture,d=c.image.data;g&&(Oo.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse).multiply(this.matrixWorld),Ho.setFromProjectionMatrix(Oo,t.coordinateSystem));let h=0;if(this.sortObjects){Oo.copy(this.matrixWorld).invert(),_o.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Oo),$o.set(0,0,-1).transformDirection(e.matrixWorld).transformDirection(Oo);for(let e=0,i=r.length;e0){const e=t[A[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,A=e.length;ti)return;dr.applyMatrix4(t.matrixWorld);const a=A.ray.origin.distanceTo(dr);return aA.far?void 0:{distance:a,point:hr.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const mr=new Bi,Er=new Bi;class pr extends Cr{constructor(t,A){super(t,A),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const A=t.attributes.position,e=[];for(let t=0,i=A.count;t0){const e=t[A[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,A=e.length;tn.far)return;s.push({distance:a,distanceToRay:Math.sqrt(r),point:e,index:A,face:null,faceIndex:null,barycoord:null,object:o})}}class Nr extends di{constructor(t,A,e,i,n,s,o,r,a){super(t,A,e,i,n,s,o,r,a),this.isCanvasTexture=!0,this.needsUpdate=!0}}class br extends di{constructor(t,A,e=1014,i,n,s,o=1003,r=1003,a,I=1026){if(I!==RA&&I!==NA)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,i,n,s,o,r,I,e,a),this.isDepthTexture=!0,this.image={width:t,height:A},this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new li(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const A=super.toJSON(t);return null!==this.compareFunction&&(A.compareFunction=this.compareFunction),A}}class Ur{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,A){const e=this.getUtoTmapping(t);return this.getPoint(e,A)}getPoints(t=5){const A=[];for(let e=0;e<=t;e++)A.push(this.getPoint(e/t));return A}getSpacedPoints(t=5){const A=[];for(let e=0;e<=t;e++)A.push(this.getPointAt(e/t));return A}getLength(){const 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;const A=[];let e,i=this.getPoint(0),n=0;A.push(0);for(let s=1;s<=t;s++)e=this.getPoint(s/t),n+=e.distanceTo(i),A.push(n),i=e;return this.cacheArcLengths=A,A}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,A=null){const e=this.getLengths();let i=0;const n=e.length;let s;s=A||t*e[n-1];let o,r=0,a=n-1;for(;r<=a;)if(i=Math.floor(r+(a-r)/2),o=e[i]-s,o<0)r=i+1;else{if(!(o>0)){a=i;break}a=i-1}if(i=a,e[i]===s)return i/(n-1);const I=e[i];return(i+(s-I)/(e[i+1]-I))/(n-1)}getTangent(t,A){const e=1e-4;let i=t-e,n=t+e;i<0&&(i=0),n>1&&(n=1);const s=this.getPoint(i),o=this.getPoint(n),r=A||(s.isVector2?new ke:new Bi);return r.copy(o).sub(s).normalize(),r}getTangentAt(t,A){const e=this.getUtoTmapping(t);return this.getTangent(e,A)}computeFrenetFrames(t,A=!1){const e=new Bi,i=[],n=[],s=[],o=new Bi,r=new Ki;for(let c=0;c<=t;c++){const A=c/t;i[c]=this.getTangentAt(A,new Bi)}n[0]=new Bi,s[0]=new Bi;let a=Number.MAX_VALUE;const I=Math.abs(i[0].x),l=Math.abs(i[0].y),g=Math.abs(i[0].z);I<=a&&(a=I,e.set(1,0,0)),l<=a&&(a=l,e.set(0,1,0)),g<=a&&e.set(0,0,1),o.crossVectors(i[0],e).normalize(),n[0].crossVectors(i[0],o),s[0].crossVectors(i[0],n[0]);for(let c=1;c<=t;c++){if(n[c]=n[c-1].clone(),s[c]=s[c-1].clone(),o.crossVectors(i[c-1],i[c]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(Le(i[c-1].dot(i[c]),-1,1));n[c].applyMatrix4(r.makeRotationAxis(o,t))}s[c].crossVectors(i[c],n[c])}if(!0===A){let A=Math.acos(Le(n[0].dot(n[t]),-1,1));A/=t,i[0].dot(o.crossVectors(n[0],n[t]))>0&&(A=-A);for(let e=1;e<=t;e++)n[e].applyMatrix4(r.makeRotationAxis(i[e],A*e)),s[e].crossVectors(i[e],n[e])}return{tangents:i,normals:n,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class vr extends Ur{constructor(t=0,A=0,e=1,i=1,n=0,s=2*Math.PI,o=!1,r=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=A,this.xRadius=e,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=s,this.aClockwise=o,this.aRotation=r}getPoint(t,A=new ke){const e=A,i=2*Math.PI;let n=this.aEndAngle-this.aStartAngle;const s=Math.abs(n)i;)n-=i;ni.length-2?i.length-1:s+1],l=i[s>i.length-3?i.length-1:s+2];return e.set(Jr(o,r.x,a.x,I.x,l.x),Jr(o,r.y,a.y,I.y,l.y)),e}copy(t){super.copy(t),this.points=[];for(let A=0,e=t.points.length;A0?0:(Math.floor(Math.abs(a)/n)+1)*n:0===I&&a===n-1&&(a=n-2,I=1),this.closed||a>0?o=i[(a-1)%n]:(Tr.subVectors(i[0],i[1]).add(i[0]),o=Tr);const l=i[a%n],g=i[(a+1)%n];if(this.closed||a+2=e){const t=i[n]-e,s=this.curves[n],o=s.getLength(),r=0===o?0:1-t/o;return s.getPointAt(r,A)}n++}return null}getLength(){const 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;const t=[];let A=0;for(let e=0,i=this.curves.length;e1&&!A[A.length-1].equals(A[0])&&A.push(A[0]),A}copy(t){super.copy(t),this.curves=[];for(let A=0,e=t.curves.length;A0){const t=a.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(a);const I=a.getPoint(1);return this.currentPoint.copy(I),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Xr extends as{constructor(t=[new ke(0,-.5),new ke(.5,0),new ke(0,.5)],A=12,e=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:A,phiStart:e,phiLength:i},A=Math.floor(A),i=Le(i,0,2*Math.PI);const n=[],s=[],o=[],r=[],a=[],I=1/A,l=new Bi,g=new ke,c=new Bi,d=new Bi,h=new Bi;let C=0,u=0;for(let m=0;m<=t.length-1;m++)switch(m){case 0:C=t[m+1].x-t[m].x,u=t[m+1].y-t[m].y,c.x=1*u,c.y=-C,c.z=0*u,h.copy(c),c.normalize(),r.push(c.x,c.y,c.z);break;case t.length-1:r.push(h.x,h.y,h.z);break;default:C=t[m+1].x-t[m].x,u=t[m+1].y-t[m].y,c.x=1*u,c.y=-C,c.z=0*u,d.copy(c),c.x+=h.x,c.y+=h.y,c.z+=h.z,c.normalize(),r.push(c.x,c.y,c.z),h.copy(d)}for(let m=0;m<=A;m++){const n=e+m*I*i,c=Math.sin(n),d=Math.cos(n);for(let e=0;e<=t.length-1;e++){l.x=t[e].x*c,l.y=t[e].y,l.z=t[e].x*d,s.push(l.x,l.y,l.z),g.x=m/A,g.y=e/(t.length-1),o.push(g.x,g.y);const i=r[3*e+0]*c,n=r[3*e+1],I=r[3*e+0]*d;a.push(i,n,I)}}for(let m=0;m0||0!==i)&&(I.push(s,o,a),E+=3),(A>0||i!==n-1)&&(I.push(o,r,a),E+=3)}a.addGroup(u,E,0),u+=E}(),!1===s&&(t>0&&m(!0),A>0&&m(!1)),this.setIndex(I),this.setAttribute("position",new ts(l,3)),this.setAttribute("normal",new ts(g,3)),this.setAttribute("uv",new ts(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qr(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class _r extends qr{constructor(t=1,A=1,e=32,i=1,n=!1,s=0,o=2*Math.PI){super(0,t,A,e,i,n,s,o),this.type="ConeGeometry",this.parameters={radius:t,height:A,radialSegments:e,heightSegments:i,openEnded:n,thetaStart:s,thetaLength:o}}static fromJSON(t){return new _r(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class $r extends as{constructor(t=[],A=[],e=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:A,radius:e,detail:i};const n=[],s=[];function o(t,A,e,i){const n=i+1,s=[];for(let o=0;o<=n;o++){s[o]=[];const i=t.clone().lerp(e,o/n),r=A.clone().lerp(e,o/n),a=n-o;for(let t=0;t<=a;t++)s[o][t]=0===t&&o===n?i:i.clone().lerp(r,t/a)}for(let o=0;o.9&&o<.1&&(A<.2&&(s[t+0]+=1),e<.2&&(s[t+2]+=1),i<.2&&(s[t+4]+=1))}}()}(),this.setAttribute("position",new ts(n,3)),this.setAttribute("normal",new ts(n.slice(),3)),this.setAttribute("uv",new ts(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $r(t.vertices,t.indices,t.radius,t.details)}}class ta extends $r{constructor(t=1,A=0){const e=(1+Math.sqrt(5))/2,i=1/e;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-e,0,-i,e,0,i,-e,0,i,e,-i,-e,0,-i,e,0,i,-e,0,i,e,0,-e,0,-i,e,0,-i,-e,0,i,e,0,i],[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],t,A),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:A}}static fromJSON(t){return new ta(t.radius,t.detail)}}const Aa=new Bi,ea=new Bi,ia=new Bi,na=new Fn;let sa=class extends Or{constructor(t){super(t),this.uuid=je(),this.type="Shape",this.holes=[]}getPointsHoles(t){const A=[];for(let e=0,i=this.holes.length;e0)for(let o=A;o=A;o-=i)s=Na(o/i|0,t[o],t[o+1],s);return s&&Ma(s,s.next)&&(ba(s),s=s.next),s}function ra(t,A){if(!t)return t;A||(A=t);let e,i=t;do{if(e=!1,i.steiner||!Ma(i,i.next)&&0!==Qa(i.prev,i,i.next))i=i.next;else{if(ba(i),i=A=i.prev,i===i.next)break;e=!0}}while(e||i!==A);return A}function aa(t,A,e,i,n,s,o){if(!t)return;!o&&s&&function(t,A,e,i){let n=t;do{0===n.z&&(n.z=ua(n.x,n.y,A,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let A,e=1;do{let i,n=t;t=null;let s=null;for(A=0;n;){A++;let o=n,r=0;for(let t=0;t0||a>0&&o;)0!==r&&(0===a||!o||n.z<=o.z)?(i=n,n=n.nextZ,r--):(i=o,o=o.nextZ,a--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;n=o}s.nextZ=null,e*=2}while(A>1)}(n)}(t,i,n,s);let r=t;for(;t.prev!==t.next;){const a=t.prev,I=t.next;if(s?la(t,i,n,s):Ia(t))A.push(a.i,t.i,I.i),ba(t),t=I.next,r=I.next;else if((t=I)===r){o?1===o?aa(t=ga(ra(t),A),A,e,i,n,s,2):2===o&&ca(t,A,e,i,n,s):aa(ra(t),A,e,i,n,s,1);break}}}function Ia(t){const A=t.prev,e=t,i=t.next;if(Qa(A,e,i)>=0)return!1;const n=A.x,s=e.x,o=i.x,r=A.y,a=e.y,I=i.y,l=Math.min(n,s,o),g=Math.min(r,a,I),c=Math.max(n,s,o),d=Math.max(r,a,I);let h=i.next;for(;h!==A;){if(h.x>=l&&h.x<=c&&h.y>=g&&h.y<=d&&pa(n,r,s,a,o,I,h.x,h.y)&&Qa(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function la(t,A,e,i){const n=t.prev,s=t,o=t.next;if(Qa(n,s,o)>=0)return!1;const r=n.x,a=s.x,I=o.x,l=n.y,g=s.y,c=o.y,d=Math.min(r,a,I),h=Math.min(l,g,c),C=Math.max(r,a,I),u=Math.max(l,g,c),m=ua(d,h,A,e,i),E=ua(C,u,A,e,i);let p=t.prevZ,B=t.nextZ;for(;p&&p.z>=m&&B&&B.z<=E;){if(p.x>=d&&p.x<=C&&p.y>=h&&p.y<=u&&p!==n&&p!==o&&pa(r,l,a,g,I,c,p.x,p.y)&&Qa(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,B.x>=d&&B.x<=C&&B.y>=h&&B.y<=u&&B!==n&&B!==o&&pa(r,l,a,g,I,c,B.x,B.y)&&Qa(B.prev,B,B.next)>=0)return!1;B=B.nextZ}for(;p&&p.z>=m;){if(p.x>=d&&p.x<=C&&p.y>=h&&p.y<=u&&p!==n&&p!==o&&pa(r,l,a,g,I,c,p.x,p.y)&&Qa(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;B&&B.z<=E;){if(B.x>=d&&B.x<=C&&B.y>=h&&B.y<=u&&B!==n&&B!==o&&pa(r,l,a,g,I,c,B.x,B.y)&&Qa(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function ga(t,A){let e=t;do{const i=e.prev,n=e.next.next;!Ma(i,n)&&Va(i,e,e.next,n)&&fa(i,n)&&fa(n,i)&&(A.push(i.i,e.i,n.i),ba(e),ba(e.next),e=t=n),e=e.next}while(e!==t);return ra(e)}function ca(t,A,e,i,n,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Ba(o,t)){let r=Ra(o,t);return o=ra(o,o.next),r=ra(r,r.next),aa(o,A,e,i,n,s,0),void aa(r,A,e,i,n,s,0)}t=t.next}o=o.next}while(o!==t)}function da(t,A){let e=t.x-A.x;return 0===e&&(e=t.y-A.y,0===e)&&(e=(t.next.y-t.y)/(t.next.x-t.x)-(A.next.y-A.y)/(A.next.x-A.x)),e}function ha(t,A){const e=function(t,A){let e=A;const i=t.x,n=t.y;let s,o=-1/0;if(Ma(t,e))return e;do{if(Ma(t,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const t=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(t<=i&&t>o&&(o=t,s=e.x=e.x&&e.x>=a&&i!==e.x&&Ea(ns.x||e.x===s.x&&Ca(s,e)))&&(s=e,l=A)}e=e.next}while(e!==r);return s}(t,A);if(!e)return A;const i=Ra(e,t);return ra(i,i.next),ra(e,e.next)}function Ca(t,A){return Qa(t.prev,t,A.prev)<0&&Qa(A.next,t,t.next)<0}function ua(t,A,e,i,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(A=1431655765&((A=858993459&((A=252645135&((A=16711935&((A=(A-i)*n|0)|A<<8))|A<<4))|A<<2))|A<<1))<<1}function ma(t){let A=t,e=t;do{(A.x=(t-o)*(s-r)&&(t-o)*(i-r)>=(e-o)*(A-r)&&(e-o)*(s-r)>=(n-o)*(i-r)}function pa(t,A,e,i,n,s,o,r){return!(t===o&&A===r)&&Ea(t,A,e,i,n,s,o,r)}function Ba(t,A){return t.next.i!==A.i&&t.prev.i!==A.i&&!function(t,A){let e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==A.i&&e.next.i!==A.i&&Va(e,e.next,t,A))return!0;e=e.next}while(e!==t);return!1}(t,A)&&(fa(t,A)&&fa(A,t)&&function(t,A){let e=t,i=!1;const n=(t.x+A.x)/2,s=(t.y+A.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&&(i=!i),e=e.next}while(e!==t);return i}(t,A)&&(Qa(t.prev,t,A.prev)||Qa(t,A.prev,A))||Ma(t,A)&&Qa(t.prev,t,t.next)>0&&Qa(A.prev,A,A.next)>0)}function Qa(t,A,e){return(A.y-t.y)*(e.x-A.x)-(A.x-t.x)*(e.y-A.y)}function Ma(t,A){return t.x===A.x&&t.y===A.y}function Va(t,A,e,i){const n=wa(Qa(t,A,e)),s=wa(Qa(t,A,i)),o=wa(Qa(e,i,t)),r=wa(Qa(e,i,A));return n!==s&&o!==r||!(0!==n||!ya(t,e,A))||!(0!==s||!ya(t,i,A))||!(0!==o||!ya(e,t,i))||!(0!==r||!ya(e,A,i))}function ya(t,A,e){return A.x<=Math.max(t.x,e.x)&&A.x>=Math.min(t.x,e.x)&&A.y<=Math.max(t.y,e.y)&&A.y>=Math.min(t.y,e.y)}function wa(t){return t>0?1:t<0?-1:0}function fa(t,A){return Qa(t.prev,t,t.next)<0?Qa(t,A,t.next)>=0&&Qa(t,t.prev,A)>=0:Qa(t,A,t.prev)<0||Qa(t,t.next,A)<0}function Ra(t,A){const e=Ua(t.i,t.x,t.y),i=Ua(A.i,A.x,A.y),n=t.next,s=A.prev;return t.next=A,A.prev=t,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function Na(t,A,e,i){const n=Ua(t,A,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function ba(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ua(t,A,e){return{i:t,x:A,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class va{static triangulate(t,A,e=2){return function(t,A,e=2){const i=A&&A.length,n=i?A[0]*e:t.length;let s=oa(t,0,n,e,!0);const o=[];if(!s||s.next===s.prev)return o;let r,a,I;if(i&&(s=function(t,A,e,i){const n=[];for(let s=0,o=A.length;s80*e){r=1/0,a=1/0;let A=-1/0,i=-1/0;for(let s=e;sA&&(A=e),n>i&&(i=n)}I=Math.max(A-r,i-a),I=0!==I?32767/I:0}return aa(s,o,e,r,a,I,0),o}(t,A,e)}}class Sa{static area(t){const A=t.length;let e=0;for(let i=A-1,n=0;n2&&t[A-1].equals(t[0])&&t.pop()}function Da(t,A){for(let e=0;eNumber.EPSILON){const g=Math.sqrt(l),c=Math.sqrt(a*a+I*I),d=A.x-r/g,h=A.y+o/g,C=((e.x-I/c-d)*I-(e.y+a/c-h)*a)/(o*I-r*a);i=d+o*C-t.x,n=h+r*C-t.y;const u=i*i+n*n;if(u<=2)return new ke(i,n);s=Math.sqrt(u/2)}else{let t=!1;o>Number.EPSILON?a>Number.EPSILON&&(t=!0):o<-Number.EPSILON?a<-Number.EPSILON&&(t=!0):Math.sign(r)===Math.sign(I)&&(t=!0),t?(i=-r,n=o,s=Math.sqrt(l)):(i=o,n=r,s=Math.sqrt(l/2))}return new ke(i/s,n/s)}const v=[];for(let A=0,e=R.length,i=e-1,n=A+1;A=0;A--){const t=A/d,e=l*Math.cos(t*Math.PI/2),i=g*Math.sin(t*Math.PI/2)+c;for(let A=0,n=R.length;A=0;){const i=e;let n=e-1;n<0&&(n=t.length-1);for(let t=0,e=r+2*d;t0)&&c.push(A,i,o),(u!==e-1||r0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class $a extends zn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Pn(16777215),this.specular=new Pn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rn,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),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.flatShading=t.flatShading,this.fog=t.fog,this}}class tI extends zn{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Pn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class AI extends zn{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class eI extends zn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Pn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rn,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),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.flatShading=t.flatShading,this.fog=t.fog,this}}class iI extends zn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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}}class nI extends zn{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",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.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class sI extends zn{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Pn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class oI extends rr{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function rI(t,A){return t&&t.constructor!==A?"number"==typeof A.BYTES_PER_ELEMENT?new A(t):Array.prototype.slice.call(t):t}function aI(t){const A=t.length,e=new Array(A);for(let i=0;i!==A;++i)e[i]=i;return e.sort((function(A,e){return t[A]-t[e]})),e}function II(t,A,e){const i=t.length,n=new t.constructor(i);for(let s=0,o=0;o!==i;++s){const i=e[s]*A;for(let e=0;e!==A;++e)n[o++]=t[i+e]}return n}function lI(t,A,e,i){let n=1,s=t[0];for(;void 0!==s&&void 0===s[i];)s=t[n++];if(void 0===s)return;let o=s[i];if(void 0!==o)if(Array.isArray(o))do{o=s[i],void 0!==o&&(A.push(s.time),e.push(...o)),s=t[n++]}while(void 0!==s);else if(void 0!==o.toArray)do{o=s[i],void 0!==o&&(A.push(s.time),o.toArray(e,e.length)),s=t[n++]}while(void 0!==s);else do{o=s[i],void 0!==o&&(A.push(s.time),e.push(o)),s=t[n++]}while(void 0!==s)}class gI{constructor(t,A,e,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new A.constructor(e),this.sampleValues=A,this.valueSize=e,this.settings=null,this.DefaultSettings_={}}evaluate(t){const A=this.parameterPositions;let e=this._cachedIndex,i=A[e],n=A[e-1];t:{A:{let s;e:{i:if(!(t=n)break t;{const o=A[1];t=n)break A}s=e,e=0}}for(;e>>1;tA;)--s;if(++s,0!==n||s!==i){n>=s&&(s=Math.max(s,1),n=s-1);const t=this.getValueSize();this.times=e.slice(n,s),this.values=this.values.slice(n*t,s*t)}return this}validate(){let t=!0;const A=this.getValueSize();A-Math.floor(A)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const e=this.times,i=this.values,n=e.length;0===n&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let r=0;r!==n;r++){const A=e[r];if("number"==typeof A&&isNaN(A)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,r,A),t=!1;break}if(null!==s&&s>A){console.error("THREE.KeyframeTrack: Out of order keys.",this,r,A,s),t=!1;break}s=A}if(void 0!==i&&(o=i,ArrayBuffer.isView(o)&&!(o instanceof DataView)))for(let r=0,a=i.length;r!==a;++r){const A=i[r];if(isNaN(A)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,r,A),t=!1;break}}var o;return t}optimize(){const t=this.times.slice(),A=this.values.slice(),e=this.getValueSize(),i=this.getInterpolation()===de,n=t.length-1;let s=1;for(let o=1;o0){t[s]=t[n];for(let t=n*e,i=s*e,o=0;o!==e;++o)A[i+o]=A[t+o];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=A.slice(0,s*e)):(this.times=t,this.values=A),this}clone(){const t=this.times.slice(),A=this.values.slice(),e=new(0,this.constructor)(this.name,t,A);return e.createInterpolant=this.createInterpolant,e}}CI.prototype.ValueTypeName="",CI.prototype.TimeBufferType=Float32Array,CI.prototype.ValueBufferType=Float32Array,CI.prototype.DefaultInterpolation=ce;class uI extends CI{constructor(t,A,e){super(t,A,e)}}uI.prototype.ValueTypeName="bool",uI.prototype.ValueBufferType=Array,uI.prototype.DefaultInterpolation=ge,uI.prototype.InterpolantFactoryMethodLinear=void 0,uI.prototype.InterpolantFactoryMethodSmooth=void 0;class mI extends CI{constructor(t,A,e,i){super(t,A,e,i)}}mI.prototype.ValueTypeName="color";class EI extends CI{constructor(t,A,e,i){super(t,A,e,i)}}EI.prototype.ValueTypeName="number";class pI extends gI{constructor(t,A,e,i){super(t,A,e,i)}interpolate_(t,A,e,i){const n=this.resultBuffer,s=this.sampleValues,o=this.valueSize,r=(e-A)/(i-A);let a=t*o;for(let I=a+o;a!==I;a+=4)pi.slerpFlat(n,0,s,a-o,s,a,r);return n}}class BI extends CI{constructor(t,A,e,i){super(t,A,e,i)}InterpolantFactoryMethodLinear(t){return new pI(this.times,this.values,this.getValueSize(),t)}}BI.prototype.ValueTypeName="quaternion",BI.prototype.InterpolantFactoryMethodSmooth=void 0;class QI extends CI{constructor(t,A,e){super(t,A,e)}}QI.prototype.ValueTypeName="string",QI.prototype.ValueBufferType=Array,QI.prototype.DefaultInterpolation=ge,QI.prototype.InterpolantFactoryMethodLinear=void 0,QI.prototype.InterpolantFactoryMethodSmooth=void 0;class MI extends CI{constructor(t,A,e,i){super(t,A,e,i)}}MI.prototype.ValueTypeName="vector";class VI{constructor(t="",A=-1,e=[],i=2500){this.name=t,this.tracks=e,this.duration=A,this.blendMode=i,this.uuid=je(),this.duration<0&&this.resetDuration()}static parse(t){const A=[],e=t.tracks,i=1/(t.fps||1);for(let s=0,o=e.length;s!==o;++s)A.push(yI(e[s]).scale(i));const n=new this(t.name,t.duration,A,t.blendMode);return n.uuid=t.uuid,n}static toJSON(t){const A=[],e=t.tracks,i={name:t.name,duration:t.duration,tracks:A,uuid:t.uuid,blendMode:t.blendMode};for(let n=0,s=e.length;n!==s;++n)A.push(CI.toJSON(e[n]));return i}static CreateFromMorphTargetSequence(t,A,e,i){const n=A.length,s=[];for(let o=0;o1){const t=e[1];let n=i[t];n||(i[t]=n=[]),n.push(A)}}const s=[];for(const o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],A,e));return s}static parseAnimation(t,A){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const e=function(t,A,e,i,n){if(0!==e.length){const s=[],o=[];lI(e,s,o,i),0!==s.length&&n.push(new t(A,s,o))}},i=[],n=t.name||"default",s=t.fps||30,o=t.blendMode;let r=t.length||-1;const a=t.hierarchy||[];for(let I=0;I{A&&A(n),this.manager.itemEnd(t)}),0),n;if(void 0!==bI[t])return void bI[t].push({onLoad:A,onProgress:e,onError:i});bI[t]=[],bI[t].push({onLoad:A,onProgress:e,onError:i});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,r=this.responseType;fetch(s).then((A=>{if(200===A.status||0===A.status){if(0===A.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===A.body||void 0===A.body.getReader)return A;const e=bI[t],i=A.body.getReader(),n=A.headers.get("X-File-Size")||A.headers.get("Content-Length"),s=n?parseInt(n):0,o=0!==s;let r=0;const a=new ReadableStream({start(t){!function A(){i.read().then((({done:i,value:n})=>{if(i)t.close();else{r+=n.byteLength;const i=new ProgressEvent("progress",{lengthComputable:o,loaded:r,total:s});for(let t=0,A=e.length;t{t.error(A)}))}()}});return new Response(a)}throw new UI(`fetch for "${A.url}" responded with ${A.status}: ${A.statusText}`,A)})).then((t=>{switch(r){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,o)));case"json":return t.json();default:if(""===o)return t.text();{const A=/charset="?([^;"\s]*)"?/i.exec(o),e=A&&A[1]?A[1].toLowerCase():void 0,i=new TextDecoder(e);return t.arrayBuffer().then((t=>i.decode(t)))}}})).then((A=>{wI.add(t,A);const e=bI[t];delete bI[t];for(let t=0,i=e.length;t{const e=bI[t];if(void 0===e)throw this.manager.itemError(t),A;delete bI[t];for(let t=0,i=e.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class SI extends NI{constructor(t){super(t)}load(t,A,e,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,s=wI.get(t);if(void 0!==s)return n.manager.itemStart(t),setTimeout((function(){A&&A(s),n.manager.itemEnd(t)}),0),s;const o=qe("img");function r(){I(),wI.add(t,this),A&&A(this),n.manager.itemEnd(t)}function a(A){I(),i&&i(A),n.manager.itemError(t),n.manager.itemEnd(t)}function I(){o.removeEventListener("load",r,!1),o.removeEventListener("error",a,!1)}return o.addEventListener("load",r,!1),o.addEventListener("error",a,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),n.manager.itemStart(t),o.src=t,o}}class TI extends NI{constructor(t){super(t)}load(t,A,e,i){const n=new di,s=new SI(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(t){n.image=t,n.needsUpdate=!0,void 0!==A&&A(n)}),e,i),n}}class DI extends yn{constructor(t,A=1){super(),this.isLight=!0,this.type="Light",this.color=new Pn(t),this.intensity=A}dispose(){}copy(t,A){return super.copy(t,A),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const A=super.toJSON(t);return A.object.color=this.color.getHex(),A.object.intensity=this.intensity,void 0!==this.groundColor&&(A.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(A.object.distance=this.distance),void 0!==this.angle&&(A.object.angle=this.angle),void 0!==this.decay&&(A.object.decay=this.decay),void 0!==this.penumbra&&(A.object.penumbra=this.penumbra),void 0!==this.shadow&&(A.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(A.object.target=this.target.uuid),A}}class xI extends DI{constructor(t,A,e){super(t,e),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(yn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Pn(A)}copy(t,A){return super.copy(t,A),this.groundColor.copy(t.groundColor),this}}const ZI=new Ki,JI=new Bi,FI=new Bi;class GI{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.map=null,this.mapPass=null,this.matrix=new Ki,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Yo,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new hi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const A=this.camera,e=this.matrix;JI.setFromMatrixPosition(t.matrixWorld),A.position.copy(JI),FI.setFromMatrixPosition(t.target.matrixWorld),A.lookAt(FI),A.updateMatrixWorld(),ZI.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ZI),e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(ZI)}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.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class jI extends GI{constructor(){super(new Ss(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const A=this.camera,e=2*Ge*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,n=t.distance||A.far;e===A.fov&&i===A.aspect&&n===A.far||(A.fov=e,A.aspect=i,A.far=n,A.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class LI extends DI{constructor(t,A,e=0,i=Math.PI/3,n=0,s=2){super(t,A),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(yn.DEFAULT_UP),this.updateMatrix(),this.target=new yn,this.distance=e,this.angle=i,this.penumbra=n,this.decay=s,this.map=null,this.shadow=new jI}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,A){return super.copy(t,A),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}}const YI=new Ki,PI=new Bi,WI=new Bi;class kI extends GI{constructor(){super(new Ss(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ke(4,2),this._viewportCount=6,this._viewports=[new hi(2,1,1,1),new hi(0,1,1,1),new hi(3,1,1,1),new hi(1,1,1,1),new hi(3,0,1,1),new hi(1,0,1,1)],this._cubeDirections=[new Bi(1,0,0),new Bi(-1,0,0),new Bi(0,0,1),new Bi(0,0,-1),new Bi(0,1,0),new Bi(0,-1,0)],this._cubeUps=[new Bi(0,1,0),new Bi(0,1,0),new Bi(0,1,0),new Bi(0,1,0),new Bi(0,0,1),new Bi(0,0,-1)]}updateMatrices(t,A=0){const e=this.camera,i=this.matrix,n=t.distance||e.far;n!==e.far&&(e.far=n,e.updateProjectionMatrix()),PI.setFromMatrixPosition(t.matrixWorld),e.position.copy(PI),WI.copy(e.position),WI.add(this._cubeDirections[A]),e.up.copy(this._cubeUps[A]),e.lookAt(WI),e.updateMatrixWorld(),i.makeTranslation(-PI.x,-PI.y,-PI.z),YI.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(YI)}}class zI extends DI{constructor(t,A,e=0,i=2){super(t,A),this.isPointLight=!0,this.type="PointLight",this.distance=e,this.decay=i,this.shadow=new kI}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,A){return super.copy(t,A),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class OI extends Ns{constructor(t=-1,A=1,e=1,i=-1,n=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=A,this.top=e,this.bottom=i,this.near=n,this.far=s,this.updateProjectionMatrix()}copy(t,A){return super.copy(t,A),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=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,A,e,i,n,s){null===this.view&&(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=A,this.view.offsetX=e,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),A=(this.top-this.bottom)/(2*this.zoom),e=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=e-t,s=e+t,o=i+A,r=i-A;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,A=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=t*this.view.offsetX,s=n+t*this.view.width,o-=A*this.view.offsetY,r=o-A*this.view.height}this.projectionMatrix.makeOrthographic(n,s,o,r,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const A=super.toJSON(t);return A.object.zoom=this.zoom,A.object.left=this.left,A.object.right=this.right,A.object.top=this.top,A.object.bottom=this.bottom,A.object.near=this.near,A.object.far=this.far,null!==this.view&&(A.object.view=Object.assign({},this.view)),A}}class XI extends GI{constructor(){super(new OI(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class HI extends DI{constructor(t,A){super(t,A),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(yn.DEFAULT_UP),this.updateMatrix(),this.target=new yn,this.shadow=new XI}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class KI extends DI{constructor(t,A){super(t,A),this.isAmbientLight=!0,this.type="AmbientLight"}}class qI extends DI{constructor(t,A,e=10,i=10){super(t,A),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=e,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const A=super.toJSON(t);return A.object.width=this.width,A.object.height=this.height,A}}class _I{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Bi)}set(t){for(let A=0;A<9;A++)this.coefficients[A].copy(t[A]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,A){const e=t.x,i=t.y,n=t.z,s=this.coefficients;return A.copy(s[0]).multiplyScalar(.282095),A.addScaledVector(s[1],.488603*i),A.addScaledVector(s[2],.488603*n),A.addScaledVector(s[3],.488603*e),A.addScaledVector(s[4],e*i*1.092548),A.addScaledVector(s[5],i*n*1.092548),A.addScaledVector(s[6],.315392*(3*n*n-1)),A.addScaledVector(s[7],e*n*1.092548),A.addScaledVector(s[8],.546274*(e*e-i*i)),A}getIrradianceAt(t,A){const e=t.x,i=t.y,n=t.z,s=this.coefficients;return A.copy(s[0]).multiplyScalar(.886227),A.addScaledVector(s[1],1.023328*i),A.addScaledVector(s[2],1.023328*n),A.addScaledVector(s[3],1.023328*e),A.addScaledVector(s[4],.858086*e*i),A.addScaledVector(s[5],.858086*i*n),A.addScaledVector(s[6],.743125*n*n-.247708),A.addScaledVector(s[7],.858086*e*n),A.addScaledVector(s[8],.429043*(e*e-i*i)),A}add(t){for(let A=0;A<9;A++)this.coefficients[A].add(t.coefficients[A]);return this}addScaledSH(t,A){for(let e=0;e<9;e++)this.coefficients[e].addScaledVector(t.coefficients[e],A);return this}scale(t){for(let A=0;A<9;A++)this.coefficients[A].multiplyScalar(t);return this}lerp(t,A){for(let e=0;e<9;e++)this.coefficients[e].lerp(t.coefficients[e],A);return this}equals(t){for(let A=0;A<9;A++)if(!this.coefficients[A].equals(t.coefficients[A]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,A=0){const e=this.coefficients;for(let i=0;i<9;i++)e[i].fromArray(t,A+3*i);return this}toArray(t=[],A=0){const e=this.coefficients;for(let i=0;i<9;i++)e[i].toArray(t,A+3*i);return t}static getBasisAt(t,A){const e=t.x,i=t.y,n=t.z;A[0]=.282095,A[1]=.488603*i,A[2]=.488603*n,A[3]=.488603*e,A[4]=1.092548*e*i,A[5]=1.092548*i*n,A[6]=.315392*(3*n*n-1),A[7]=1.092548*e*n,A[8]=.546274*(e*e-i*i)}}class $I extends DI{constructor(t=new _I,A=1){super(void 0,A),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const A=super.toJSON(t);return A.object.sh=this.sh.toArray(),A}}class tl extends NI{constructor(t){super(t),this.textures={}}load(t,A,e,i){const n=this,s=new vI(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,(function(e){try{A(n.parse(JSON.parse(e)))}catch(s){i?i(s):console.error(s),n.manager.itemError(t)}}),e,i)}parse(t){const A=this.textures;function e(t){return void 0===A[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),A[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new Pn).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const n in t.uniforms){const A=t.uniforms[n];switch(i.uniforms[n]={},A.type){case"t":i.uniforms[n].value=e(A.value);break;case"c":i.uniforms[n].value=(new Pn).setHex(A.value);break;case"v2":i.uniforms[n].value=(new ke).fromArray(A.value);break;case"v3":i.uniforms[n].value=(new Bi).fromArray(A.value);break;case"v4":i.uniforms[n].value=(new hi).fromArray(A.value);break;case"m3":i.uniforms[n].value=(new ze).fromArray(A.value);break;case"m4":i.uniforms[n].value=(new Ki).fromArray(A.value);break;default:i.uniforms[n].value=A.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const n in t.extensions)i.extensions[n]=t.extensions[n];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=e(t.map)),void 0!==t.matcap&&(i.matcap=e(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=e(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=e(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let A=t.normalScale;!1===Array.isArray(A)&&(A=[A,A]),i.normalScale=(new ke).fromArray(A)}return void 0!==t.displacementMap&&(i.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=e(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=e(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=e(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=e(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=e(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=e(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=e(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=e(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new ke).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=e(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=e(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=e(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=e(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=e(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=e(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=e(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return tl.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Ha,SpriteMaterial:zs,RawShaderMaterial:Ka,ShaderMaterial:Rs,PointsMaterial:Qr,MeshPhysicalMaterial:_a,MeshStandardMaterial:qa,MeshPhongMaterial:$a,MeshToonMaterial:tI,MeshNormalMaterial:AI,MeshLambertMaterial:eI,MeshDepthMaterial:iI,MeshDistanceMaterial:nI,MeshBasicMaterial:On,MeshMatcapMaterial:sI,LineDashedMaterial:oI,LineBasicMaterial:rr,Material:zn}[t]}}class Al{static extractUrlBase(t){const A=t.lastIndexOf("/");return-1===A?"./":t.slice(0,A+1)}static resolveURL(t,A){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(A)&&/^\//.test(t)&&(A=A.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:A+t)}}class el extends as{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class il extends NI{constructor(t){super(t)}load(t,A,e,i){const n=this,s=new vI(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,(function(e){try{A(n.parse(JSON.parse(e)))}catch(s){i?i(s):console.error(s),n.manager.itemError(t)}}),e,i)}parse(t){const A={},e={};function i(t,i){if(void 0!==A[i])return A[i];const n=t.interleavedBuffers[i],s=function(t,A){if(void 0!==e[A])return e[A];const i=t.arrayBuffers[A],n=new Uint32Array(i).buffer;return e[A]=n,n}(t,n.buffer),o=Ke(n.type,s),r=new Ps(o,n.stride);return r.uuid=n.uuid,A[i]=r,r}const n=t.isInstancedBufferGeometry?new el:new as,s=t.data.index;if(void 0!==s){const t=Ke(s.type,s.array);n.setIndex(new qn(t,1))}const o=t.data.attributes;for(const l in o){const A=o[l];let e;if(A.isInterleavedBufferAttribute){const n=i(t.data,A.data);e=new ks(n,A.itemSize,A.offset,A.normalized)}else{const t=Ke(A.type,A.array);e=new(A.isInstancedBufferAttribute?Ro:qn)(t,A.itemSize,A.normalized)}void 0!==A.name&&(e.name=A.name),void 0!==A.usage&&e.setUsage(A.usage),n.setAttribute(l,e)}const r=t.data.morphAttributes;if(r)for(const l in r){const A=r[l],e=[];for(let n=0,s=A.length;n0){const e=new fI(A);n=new SI(e),n.setCrossOrigin(this.crossOrigin);for(let A=0,n=t.length;A0){i=new SI(this.manager),i.setCrossOrigin(this.crossOrigin);for(let A=0,i=t.length;A{const A=new Vi;A.min.fromArray(t.boxMin),A.max.fromArray(t.boxMax);const e=new Li;return e.radius=t.sphereRadius,e.center.fromArray(t.sphereCenter),{boxInitialized:t.boxInitialized,box:A,sphereInitialized:t.sphereInitialized,sphere:e}})),s._maxInstanceCount=t.maxInstanceCount,s._maxVertexCount=t.maxVertexCount,s._maxIndexCount=t.maxIndexCount,s._geometryInitialized=t.geometryInitialized,s._geometryCount=t.geometryCount,s._matricesTexture=l(t.matricesTexture.uuid),void 0!==t.colorsTexture&&(s._colorsTexture=l(t.colorsTexture.uuid));break;case"LOD":s=new lo;break;case"Line":s=new Cr(a(t.geometry),I(t.material));break;case"LineLoop":s=new Br(a(t.geometry),I(t.material));break;case"LineSegments":s=new pr(a(t.geometry),I(t.material));break;case"PointCloud":case"Points":s=new fr(a(t.geometry),I(t.material));break;case"Sprite":s=new oo(I(t.material));break;case"Group":s=new Js;break;case"Bone":s=new Mo;break;default:s=new yn}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(s.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(s.matrixAutoUpdate=t.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.quaternion&&s.quaternion.fromArray(t.quaternion),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.up&&s.up.fromArray(t.up),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(s.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(s.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(s.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(s.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&s.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(s.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.frustumCulled&&(s.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(s.renderOrder=t.renderOrder),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.layers&&(s.layers.mask=t.layers),void 0!==t.children){const o=t.children;for(let t=0;t{A&&A(e),n.manager.itemEnd(t)})).catch((t=>{i&&i(t)})):(setTimeout((function(){A&&A(s),n.manager.itemEnd(t)}),0),s);const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader;const r=fetch(t,o).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(n.options,{colorSpaceConversion:"none"}))})).then((function(e){return wI.add(t,e),A&&A(e),n.manager.itemEnd(t),e})).catch((function(A){i&&i(A),wI.remove(t),n.manager.itemError(t),n.manager.itemEnd(t)}));wI.add(t,r),n.manager.itemStart(t)}}class Il extends Ss{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t,this.index=0}}class ll{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gl(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const A=gl();t=(A-this.oldTime)/1e3,this.oldTime=A,this.elapsedTime+=t}return t}}function gl(){return performance.now()}class cl{constructor(t,A,e){let i,n,s;switch(this.binding=t,this.valueSize=e,A){case"quaternion":i=this._slerp,n=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*e),this._workIndex=5;break;case"string":case"bool":i=this._select,n=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*e);break;default:i=this._lerp,n=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*e)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=n,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,A){const e=this.buffer,i=this.valueSize,n=t*i+i;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==i;++t)e[n+t]=e[t];s=A}else{s+=A;const t=A/s;this._mixBufferRegion(e,n,0,t,i)}this.cumulativeWeight=s}accumulateAdditive(t){const A=this.buffer,e=this.valueSize,i=e*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(A,i,0,t,e),this.cumulativeWeightAdditive+=t}apply(t){const A=this.valueSize,e=this.buffer,i=t*A+A,n=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,n<1){const t=A*this._origIndex;this._mixBufferRegion(e,i,t,1-n,A)}s>0&&this._mixBufferRegionAdditive(e,i,this._addIndex*A,1,A);for(let r=A,a=A+A;r!==a;++r)if(e[r]!==e[r+A]){o.setValue(e,i);break}}saveOriginalState(){const t=this.binding,A=this.buffer,e=this.valueSize,i=e*this._origIndex;t.getValue(A,i);for(let n=e,s=i;n!==s;++n)A[n]=A[i+n%e];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,A=t+this.valueSize;for(let e=t;e=.5)for(let s=0;s!==n;++s)t[A+s]=t[e+s]}_slerp(t,A,e,i){pi.slerpFlat(t,A,t,A,t,e,i)}_slerpAdditive(t,A,e,i,n){const s=this._workIndex*n;pi.multiplyQuaternionsFlat(t,s,t,A,t,e),pi.slerpFlat(t,A,t,A,t,s,i)}_lerp(t,A,e,i,n){const s=1-i;for(let o=0;o!==n;++o){const n=A+o;t[n]=t[n]*s+t[e+o]*i}}_lerpAdditive(t,A,e,i,n){for(let s=0;s!==n;++s){const n=A+s;t[n]=t[n]+t[e+s]*i}}}const dl="\\[\\]\\.:\\/",hl=new RegExp("["+dl+"]","g"),Cl="[^"+dl+"]",ul="[^"+dl.replace("\\.","")+"]",ml=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Cl)+/(WCOD+)?/.source.replace("WCOD",ul)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cl)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cl)+"$"),El=["material","materials","bones","map"];class pl{constructor(t,A,e){this.path=A,this.parsedPath=e||pl.parseTrackName(A),this.node=pl.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,A,e){return t&&t.isAnimationObjectGroup?new pl.Composite(t,A,e):new pl(t,A,e)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(hl,"")}static parseTrackName(t){const A=ml.exec(t);if(null===A)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const e={nodeName:A[2],objectName:A[3],objectIndex:A[4],propertyName:A[5],propertyIndex:A[6]},i=e.nodeName&&e.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=e.nodeName.substring(i+1);-1!==El.indexOf(t)&&(e.nodeName=e.nodeName.substring(0,i),e.objectName=t)}if(null===e.propertyName||0===e.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return e}static findNode(t,A){if(void 0===A||""===A||"."===A||-1===A||A===t.name||A===t.uuid)return t;if(t.skeleton){const e=t.skeleton.getBoneByName(A);if(void 0!==e)return e}if(t.children){const e=function(t){for(let i=0;i0){const t=this._interpolants,A=this._propertyBindings;if(2501===this.blendMode)for(let e=0,i=t.length;e!==i;++e)t[e].evaluate(s),A[e].accumulateAdditive(o);else for(let e=0,n=t.length;e!==n;++e)t[e].evaluate(s),A[e].accumulate(i,o)}}_updateWeight(t){let A=0;if(this.enabled){A=this.weight;const e=this._weightInterpolant;if(null!==e){const i=e.evaluate(t)[0];A*=i,t>e.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=A,A}_updateTimeScale(t){let A=0;if(!this.paused){A=this.timeScale;const e=this._timeScaleInterpolant;null!==e&&(A*=e.evaluate(t)[0],t>e.parameterPositions[1]&&(this.stopWarping(),0===A?this.paused=!0:this.timeScale=A))}return this._effectiveTimeScale=A,A}_updateTime(t){const A=this._clip.duration,e=this.loop;let i=this.time+t,n=this._loopCount;const s=2202===e;if(0===t)return-1===n||!s||1&~n?i:A-i;if(e===le){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=A)i=A;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===n&&(t>=0?(n=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=A||i<0){const e=Math.floor(i/A);i-=A*e,n+=Math.abs(e);const o=this.repetitions-n;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?A:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const A=t<0;this._setEndings(A,!A,s)}else this._setEndings(!1,!1,s);this._loopCount=n,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:e})}}else this.time=i;if(s&&!(1&~n))return A-i}return i}_setEndings(t,A,e){const i=this._interpolantSettings;e?(i.endingStart=Ce,i.endingEnd=Ce):(i.endingStart=t?this.zeroSlopeAtStart?Ce:he:ue,i.endingEnd=A?this.zeroSlopeAtEnd?Ce:he:ue)}_scheduleFading(t,A,e){const i=this._mixer,n=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,r=s.sampleValues;return o[0]=n,r[0]=A,o[1]=n+t,r[1]=e,this}}const Ql=new Float32Array(1);class Ml extends Ze{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,A){const e=t._localRoot||this._root,i=t._clip.tracks,n=i.length,s=t._propertyBindings,o=t._interpolants,r=e.uuid,a=this._bindingsByRootAndName;let I=a[r];void 0===I&&(I={},a[r]=I);for(let l=0;l!==n;++l){const t=i[l],n=t.name;let a=I[n];if(void 0!==a)++a.referenceCount,s[l]=a;else{if(a=s[l],void 0!==a){null===a._cacheIndex&&(++a.referenceCount,this._addInactiveBinding(a,r,n));continue}const i=A&&A._propertyBindings[l].binding.parsedPath;a=new cl(pl.create(e,n,i),t.ValueTypeName,t.getValueSize()),++a.referenceCount,this._addInactiveBinding(a,r,n),s[l]=a}o[l].resultBuffer=a.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const A=(t._localRoot||this._root).uuid,e=t._clip.uuid,i=this._actionsByClip[e];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,e,A)}const A=t._propertyBindings;for(let t=0,e=A.length;t!==e;++t){const e=A[t];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const A=t._propertyBindings;for(let t=0,e=A.length;t!==e;++t){const e=A[t];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){const A=t._cacheIndex;return null!==A&&A=0;--A)t[A].stop();return this}update(t){t*=this.timeScale;const A=this._actions,e=this._nActiveActions,i=this.time+=t,n=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==e;++a)A[a]._update(i,t,n,s);const o=this._bindings,r=this._nActiveBindings;for(let a=0;a!==r;++a)o[a].apply(s);return this}setTime(t){this.time=0;for(let A=0;At.start-A.start));let A=0;for(let t=1;t 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include