var z2 = Object.defineProperty; var N2 = Object.getOwnPropertyDescriptor; var Pr = (e, t, i, r) => { for (var s = r > 1 ? void 0 : r ? N2(t, i) : t, n = e.length - 1, a; n >= 0; n--) (a = e[n]) && (s = (r ? a(t, i, s) : a(s)) || s); return r && s && z2(t, i, s), s; }; var U2 = Object.create, ag = Object.defineProperty, F2 = Object.getOwnPropertyDescriptor, k2 = Object.getOwnPropertyNames, j2 = Object.getPrototypeOf, G2 = Object.prototype.hasOwnProperty, au = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), V2 = (e, t) => { for (var i in t) ag(e, i, { get: t[i], enumerable: !0 }); }, H2 = (e, t, i, r) => { if ((t && typeof t == 'object') || typeof t == 'function') for (let s of k2(t)) !G2.call(e, s) && s !== i && ag(e, s, { get: () => t[s], enumerable: !(r = F2(t, s)) || r.enumerable }); return e; }, Eh = (e, t, i) => ( (i = e != null ? U2(j2(e)) : {}), H2(t || !e || !e.__esModule ? ag(i, 'default', { value: e, enumerable: !0 }) : i, e) ), W2 = au((e, t) => { (function (i, r) { typeof e == 'object' ? (t.exports = r()) : typeof define == 'function' && define.amd ? define(r) : (i.Alea = r()); })(e, function () { 'use strict'; return ( (i.importState = function (s) { var n = new i(); return n.importState(s), n; }), i ); function i() { return (function (s) { var n = 0, a = 0, o = 0, l = 1; s.length == 0 && (s = [+new Date()]); var h = r(); (n = h(' ')), (a = h(' ')), (o = h(' ')); for (var u = 0; u < s.length; u++) (n -= h(s[u])), n < 0 && (n += 1), (a -= h(s[u])), a < 0 && (a += 1), (o -= h(s[u])), o < 0 && (o += 1); h = null; var c = function () { var d = 2091639 * n + l * 2.3283064365386963e-10; return (n = a), (a = o), (o = d - (l = d | 0)); }; return ( (c.next = c), (c.uint32 = function () { return c() * 4294967296; }), (c.fract53 = function () { return c() + ((c() * 2097152) | 0) * 11102230246251565e-32; }), (c.version = 'Alea 0.9'), (c.args = s), (c.exportState = function () { return [n, a, o, l]; }), (c.importState = function (d) { (n = +d[0] || 0), (a = +d[1] || 0), (o = +d[2] || 0), (l = +d[3] || 0); }), c ); })(Array.prototype.slice.call(arguments)); } function r() { var s = 4022871197, n = function (a) { a = a.toString(); for (var o = 0; o < a.length; o++) { s += a.charCodeAt(o); var l = 0.02519603282416938 * s; (s = l >>> 0), (l -= s), (l *= s), (s = l >>> 0), (l -= s), (s += l * 4294967296); } return (s >>> 0) * 2.3283064365386963e-10; }; return (n.version = 'Mash 0.9'), n; } }); }), rw = au((e, t) => { (function (i, r) { typeof e == 'object' && typeof t < 'u' ? r(e) : typeof define == 'function' && define.amd ? define(['exports'], r) : r(((i = typeof globalThis < 'u' ? globalThis : i || self).SVDJS = {})); })(e, function (i) { 'use strict'; (i.SVD = function (r, s, n, a, o) { if (((s = s === void 0 || s), (n = n === void 0 || n), (o = 1e-64 / (a = a || Math.pow(2, -52))), !r)) throw new TypeError('Matrix a is not defined'); var l, h, u, c, d, p, f, g, m, v, y, b, x = r[0].length, w = r.length; if (w < x) throw new TypeError('Invalid matrix: m < n'); for (var A = [], S = [], _ = [], M = s === 'f' ? w : x, C = (v = f = 0); C < w; C++) S[C] = new Array(M).fill(0); for (C = 0; C < x; C++) _[C] = new Array(x).fill(0); var T, P = new Array(x).fill(0); for (C = 0; C < w; C++) for (l = 0; l < x; l++) S[C][l] = r[C][l]; for (C = 0; C < x; C++) { for (A[C] = f, m = 0, u = C + 1, l = C; l < w; l++) m += Math.pow(S[l][C], 2); if (m < o) f = 0; else for (g = (p = S[C][C]) * (f = p < 0 ? Math.sqrt(m) : -Math.sqrt(m)) - m, S[C][C] = p - f, l = u; l < x; l++) { for (m = 0, h = C; h < w; h++) m += S[h][C] * S[h][l]; for (p = m / g, h = C; h < w; h++) S[h][l] = S[h][l] + p * S[h][C]; } for (P[C] = f, m = 0, l = u; l < x; l++) m += Math.pow(S[C][l], 2); if (m < o) f = 0; else { for (g = (p = S[C][C + 1]) * (f = p < 0 ? Math.sqrt(m) : -Math.sqrt(m)) - m, S[C][C + 1] = p - f, l = u; l < x; l++) A[l] = S[C][l] / g; for (l = u; l < w; l++) { for (m = 0, h = u; h < x; h++) m += S[l][h] * S[C][h]; for (h = u; h < x; h++) S[l][h] = S[l][h] + m * A[h]; } } v < (y = Math.abs(P[C]) + Math.abs(A[C])) && (v = y); } if (n) for (C = x - 1; 0 <= C; C--) { if (f !== 0) { for (g = S[C][C + 1] * f, l = u; l < x; l++) _[l][C] = S[C][l] / g; for (l = u; l < x; l++) { for (m = 0, h = u; h < x; h++) m += S[C][h] * _[h][l]; for (h = u; h < x; h++) _[h][l] = _[h][l] + m * _[h][C]; } } for (l = u; l < x; l++) (_[C][l] = 0), (_[l][C] = 0); (_[C][C] = 1), (f = A[C]), (u = C); } if (s) { if (s === 'f') for (C = x; C < w; C++) { for (l = x; l < w; l++) S[C][l] = 0; S[C][C] = 1; } for (C = x - 1; 0 <= C; C--) { for (u = C + 1, f = P[C], l = u; l < M; l++) S[C][l] = 0; if (f !== 0) { for (g = S[C][C] * f, l = u; l < M; l++) { for (m = 0, h = u; h < w; h++) m += S[h][C] * S[h][l]; for (p = m / g, h = C; h < w; h++) S[h][l] = S[h][l] + p * S[h][C]; } for (l = C; l < w; l++) S[l][C] = S[l][C] / f; } else for (l = C; l < w; l++) S[l][C] = 0; S[C][C] = S[C][C] + 1; } } for (a *= v, h = x - 1; 0 <= h; h--) for (var L = 0; L < 50; L++) { for (T = !1, u = h; 0 <= u; u--) { if (Math.abs(A[u]) <= a) { T = !0; break; } if (Math.abs(P[u - 1]) <= a) break; } if (!T) { for (d = 0, c = u - (m = 1), C = u; C < h + 1 && ((p = m * A[C]), (A[C] = d * A[C]), !(Math.abs(p) <= a)); C++) if (((f = P[C]), (P[C] = Math.sqrt(p * p + f * f)), (d = f / (g = P[C])), (m = -p / g), s)) for (l = 0; l < w; l++) (y = S[l][c]), (b = S[l][C]), (S[l][c] = y * d + b * m), (S[l][C] = -y * m + b * d); } if (((b = P[h]), u === h)) { if (b < 0 && ((P[h] = -b), n)) for (l = 0; l < x; l++) _[l][h] = -_[l][h]; break; } for ( v = P[u], p = (((y = P[h - 1]) - b) * (y + b) + ((f = A[h - 1]) - (g = A[h])) * (f + g)) / (2 * g * y), f = Math.sqrt(p * p + 1), p = ((v - b) * (v + b) + g * (y / (p < 0 ? p - f : p + f) - g)) / v, C = u + (m = d = 1); C < h + 1; C++ ) { if ( ((f = A[C]), (y = P[C]), (g = m * f), (f *= d), (b = Math.sqrt(p * p + g * g)), (p = v * (d = p / (A[C - 1] = b)) + f * (m = g / b)), (f = -v * m + f * d), (g = y * m), (y *= d), n) ) for (l = 0; l < x; l++) (v = _[l][C - 1]), (b = _[l][C]), (_[l][C - 1] = v * d + b * m), (_[l][C] = -v * m + b * d); if (((b = Math.sqrt(p * p + g * g)), (p = (d = p / (P[C - 1] = b)) * f + (m = g / b) * y), (v = -m * f + d * y), s)) for (l = 0; l < w; l++) (y = S[l][C - 1]), (b = S[l][C]), (S[l][C - 1] = y * d + b * m), (S[l][C] = -y * m + b * d); } (A[u] = 0), (A[h] = p), (P[h] = v); } for (C = 0; C < x; C++) P[C] < a && (P[C] = 0); return { u: S, q: P, v: _ }; }), (i.VERSION = '1.1.1'), Object.defineProperty(i, '__esModule', { value: !0 }); }); }), X2 = au((e) => { (function () { 'use strict'; var t = function () { this.init(); }; t.prototype = { init: function () { var c = this || i; return ( (c._counter = 1e3), (c._html5AudioPool = []), (c.html5PoolSize = 10), (c._codecs = {}), (c._howls = []), (c._muted = !1), (c._volume = 1), (c._canPlayEvent = 'canplaythrough'), (c._navigator = typeof window < 'u' && window.navigator ? window.navigator : null), (c.masterGain = null), (c.noAudio = !1), (c.usingWebAudio = !0), (c.autoSuspend = !0), (c.ctx = null), (c.autoUnlock = !0), c._setup(), c ); }, volume: function (c) { var d = this || i; if (((c = parseFloat(c)), d.ctx || u(), typeof c < 'u' && c >= 0 && c <= 1)) { if (((d._volume = c), d._muted)) return d; d.usingWebAudio && d.masterGain.gain.setValueAtTime(c, i.ctx.currentTime); for (var p = 0; p < d._howls.length; p++) if (!d._howls[p]._webAudio) for (var f = d._howls[p]._getSoundIds(), g = 0; g < f.length; g++) { var m = d._howls[p]._soundById(f[g]); m && m._node && (m._node.volume = m._volume * c); } return d; } return d._volume; }, mute: function (c) { var d = this || i; d.ctx || u(), (d._muted = c), d.usingWebAudio && d.masterGain.gain.setValueAtTime(c ? 0 : d._volume, i.ctx.currentTime); for (var p = 0; p < d._howls.length; p++) if (!d._howls[p]._webAudio) for (var f = d._howls[p]._getSoundIds(), g = 0; g < f.length; g++) { var m = d._howls[p]._soundById(f[g]); m && m._node && (m._node.muted = c ? !0 : m._muted); } return d; }, stop: function () { for (var c = this || i, d = 0; d < c._howls.length; d++) c._howls[d].stop(); return c; }, unload: function () { for (var c = this || i, d = c._howls.length - 1; d >= 0; d--) c._howls[d].unload(); return c.usingWebAudio && c.ctx && typeof c.ctx.close < 'u' && (c.ctx.close(), (c.ctx = null), u()), c; }, codecs: function (c) { return (this || i)._codecs[c.replace(/^x-/, '')]; }, _setup: function () { var c = this || i; if (((c.state = (c.ctx && c.ctx.state) || 'suspended'), c._autoSuspend(), !c.usingWebAudio)) if (typeof Audio < 'u') try { var d = new Audio(); typeof d.oncanplaythrough > 'u' && (c._canPlayEvent = 'canplay'); } catch { c.noAudio = !0; } else c.noAudio = !0; try { var d = new Audio(); d.muted && (c.noAudio = !0); } catch {} return c.noAudio || c._setupCodecs(), c; }, _setupCodecs: function () { var c = this || i, d = null; try { d = typeof Audio < 'u' ? new Audio() : null; } catch { return c; } if (!d || typeof d.canPlayType != 'function') return c; var p = d.canPlayType('audio/mpeg;').replace(/^no$/, ''), f = c._navigator ? c._navigator.userAgent : '', g = f.match(/OPR\/([0-6].)/g), m = g && parseInt(g[0].split('/')[1], 10) < 33, v = f.indexOf('Safari') !== -1 && f.indexOf('Chrome') === -1, y = f.match(/Version\/(.*?) /), b = v && y && parseInt(y[1], 10) < 15; return ( (c._codecs = { mp3: !!(!m && (p || d.canPlayType('audio/mp3;').replace(/^no$/, ''))), mpeg: !!p, opus: !!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''), ogg: !!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''), oga: !!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''), wav: !!(d.canPlayType('audio/wav; codecs="1"') || d.canPlayType('audio/wav')).replace(/^no$/, ''), aac: !!d.canPlayType('audio/aac;').replace(/^no$/, ''), caf: !!d.canPlayType('audio/x-caf;').replace(/^no$/, ''), m4a: !!(d.canPlayType('audio/x-m4a;') || d.canPlayType('audio/m4a;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''), m4b: !!(d.canPlayType('audio/x-m4b;') || d.canPlayType('audio/m4b;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''), mp4: !!(d.canPlayType('audio/x-mp4;') || d.canPlayType('audio/mp4;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''), weba: !!(!b && d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')), webm: !!(!b && d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')), dolby: !!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ''), flac: !!(d.canPlayType('audio/x-flac;') || d.canPlayType('audio/flac;')).replace(/^no$/, '') }), c ); }, _unlockAudio: function () { var c = this || i; if (!(c._audioUnlocked || !c.ctx)) { (c._audioUnlocked = !1), (c.autoUnlock = !1), !c._mobileUnloaded && c.ctx.sampleRate !== 44100 && ((c._mobileUnloaded = !0), c.unload()), (c._scratchBuffer = c.ctx.createBuffer(1, 1, 22050)); var d = function (p) { for (; c._html5AudioPool.length < c.html5PoolSize; ) try { var f = new Audio(); (f._unlocked = !0), c._releaseHtml5Audio(f); } catch { c.noAudio = !0; break; } for (var g = 0; g < c._howls.length; g++) if (!c._howls[g]._webAudio) for (var m = c._howls[g]._getSoundIds(), v = 0; v < m.length; v++) { var y = c._howls[g]._soundById(m[v]); y && y._node && !y._node._unlocked && ((y._node._unlocked = !0), y._node.load()); } c._autoResume(); var b = c.ctx.createBufferSource(); (b.buffer = c._scratchBuffer), b.connect(c.ctx.destination), typeof b.start > 'u' ? b.noteOn(0) : b.start(0), typeof c.ctx.resume == 'function' && c.ctx.resume(), (b.onended = function () { b.disconnect(0), (c._audioUnlocked = !0), document.removeEventListener('touchstart', d, !0), document.removeEventListener('touchend', d, !0), document.removeEventListener('click', d, !0), document.removeEventListener('keydown', d, !0); for (var x = 0; x < c._howls.length; x++) c._howls[x]._emit('unlock'); }); }; return ( document.addEventListener('touchstart', d, !0), document.addEventListener('touchend', d, !0), document.addEventListener('click', d, !0), document.addEventListener('keydown', d, !0), c ); } }, _obtainHtml5Audio: function () { var c = this || i; if (c._html5AudioPool.length) return c._html5AudioPool.pop(); var d = new Audio().play(); return ( d && typeof Promise < 'u' && (d instanceof Promise || typeof d.then == 'function') && d.catch(function () { console.warn('HTML5 Audio pool exhausted, returning potentially locked audio object.'); }), new Audio() ); }, _releaseHtml5Audio: function (c) { var d = this || i; return c._unlocked && d._html5AudioPool.push(c), d; }, _autoSuspend: function () { var c = this; if (!(!c.autoSuspend || !c.ctx || typeof c.ctx.suspend > 'u' || !i.usingWebAudio)) { for (var d = 0; d < c._howls.length; d++) if (c._howls[d]._webAudio) { for (var p = 0; p < c._howls[d]._sounds.length; p++) if (!c._howls[d]._sounds[p]._paused) return c; } return ( c._suspendTimer && clearTimeout(c._suspendTimer), (c._suspendTimer = setTimeout(function () { if (c.autoSuspend) { (c._suspendTimer = null), (c.state = 'suspending'); var f = function () { (c.state = 'suspended'), c._resumeAfterSuspend && (delete c._resumeAfterSuspend, c._autoResume()); }; c.ctx.suspend().then(f, f); } }, 3e4)), c ); } }, _autoResume: function () { var c = this; if (!(!c.ctx || typeof c.ctx.resume > 'u' || !i.usingWebAudio)) return ( c.state === 'running' && c.ctx.state !== 'interrupted' && c._suspendTimer ? (clearTimeout(c._suspendTimer), (c._suspendTimer = null)) : c.state === 'suspended' || (c.state === 'running' && c.ctx.state === 'interrupted') ? (c.ctx.resume().then(function () { c.state = 'running'; for (var d = 0; d < c._howls.length; d++) c._howls[d]._emit('resume'); }), c._suspendTimer && (clearTimeout(c._suspendTimer), (c._suspendTimer = null))) : c.state === 'suspending' && (c._resumeAfterSuspend = !0), c ); } }; var i = new t(), r = function (c) { var d = this; if (!c.src || c.src.length === 0) { console.error('An array of source files must be passed with any new Howl.'); return; } d.init(c); }; r.prototype = { init: function (c) { var d = this; return ( i.ctx || u(), (d._autoplay = c.autoplay || !1), (d._format = typeof c.format != 'string' ? c.format : [c.format]), (d._html5 = c.html5 || !1), (d._muted = c.mute || !1), (d._loop = c.loop || !1), (d._pool = c.pool || 5), (d._preload = typeof c.preload == 'boolean' || c.preload === 'metadata' ? c.preload : !0), (d._rate = c.rate || 1), (d._sprite = c.sprite || {}), (d._src = typeof c.src != 'string' ? c.src : [c.src]), (d._volume = c.volume !== void 0 ? c.volume : 1), (d._xhr = { method: c.xhr && c.xhr.method ? c.xhr.method : 'GET', headers: c.xhr && c.xhr.headers ? c.xhr.headers : null, withCredentials: c.xhr && c.xhr.withCredentials ? c.xhr.withCredentials : !1 }), (d._duration = 0), (d._state = 'unloaded'), (d._sounds = []), (d._endTimers = {}), (d._queue = []), (d._playLock = !1), (d._onend = c.onend ? [{ fn: c.onend }] : []), (d._onfade = c.onfade ? [{ fn: c.onfade }] : []), (d._onload = c.onload ? [{ fn: c.onload }] : []), (d._onloaderror = c.onloaderror ? [{ fn: c.onloaderror }] : []), (d._onplayerror = c.onplayerror ? [{ fn: c.onplayerror }] : []), (d._onpause = c.onpause ? [{ fn: c.onpause }] : []), (d._onplay = c.onplay ? [{ fn: c.onplay }] : []), (d._onstop = c.onstop ? [{ fn: c.onstop }] : []), (d._onmute = c.onmute ? [{ fn: c.onmute }] : []), (d._onvolume = c.onvolume ? [{ fn: c.onvolume }] : []), (d._onrate = c.onrate ? [{ fn: c.onrate }] : []), (d._onseek = c.onseek ? [{ fn: c.onseek }] : []), (d._onunlock = c.onunlock ? [{ fn: c.onunlock }] : []), (d._onresume = []), (d._webAudio = i.usingWebAudio && !d._html5), typeof i.ctx < 'u' && i.ctx && i.autoUnlock && i._unlockAudio(), i._howls.push(d), d._autoplay && d._queue.push({ event: 'play', action: function () { d.play(); } }), d._preload && d._preload !== 'none' && d.load(), d ); }, load: function () { var c = this, d = null; if (i.noAudio) { c._emit('loaderror', null, 'No audio support.'); return; } typeof c._src == 'string' && (c._src = [c._src]); for (var p = 0; p < c._src.length; p++) { var f, g; if (c._format && c._format[p]) f = c._format[p]; else { if (((g = c._src[p]), typeof g != 'string')) { c._emit('loaderror', null, 'Non-string found in selected audio sources - ignoring.'); continue; } (f = /^data:audio\/([^;,]+);/i.exec(g)), f || (f = /\.([^.]+)$/.exec(g.split('?', 1)[0])), f && (f = f[1].toLowerCase()); } if ( (f || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'), f && i.codecs(f)) ) { d = c._src[p]; break; } } if (!d) { c._emit('loaderror', null, 'No codec support for selected audio sources.'); return; } return ( (c._src = d), (c._state = 'loading'), window.location.protocol === 'https:' && d.slice(0, 5) === 'http:' && ((c._html5 = !0), (c._webAudio = !1)), new s(c), c._webAudio && a(c), c ); }, play: function (c, d) { var p = this, f = null; if (typeof c == 'number') (f = c), (c = null); else { if (typeof c == 'string' && p._state === 'loaded' && !p._sprite[c]) return null; if (typeof c > 'u' && ((c = '__default'), !p._playLock)) { for (var g = 0, m = 0; m < p._sounds.length; m++) p._sounds[m]._paused && !p._sounds[m]._ended && (g++, (f = p._sounds[m]._id)); g === 1 ? (c = null) : (f = null); } } var v = f ? p._soundById(f) : p._inactiveSound(); if (!v) return null; if ((f && !c && (c = v._sprite || '__default'), p._state !== 'loaded')) { (v._sprite = c), (v._ended = !1); var y = v._id; return ( p._queue.push({ event: 'play', action: function () { p.play(y); } }), y ); } if (f && !v._paused) return d || p._loadQueue('play'), v._id; p._webAudio && i._autoResume(); var b = Math.max(0, v._seek > 0 ? v._seek : p._sprite[c][0] / 1e3), x = Math.max(0, (p._sprite[c][0] + p._sprite[c][1]) / 1e3 - b), w = (x * 1e3) / Math.abs(v._rate), A = p._sprite[c][0] / 1e3, S = (p._sprite[c][0] + p._sprite[c][1]) / 1e3; (v._sprite = c), (v._ended = !1); var _ = function () { (v._paused = !1), (v._seek = b), (v._start = A), (v._stop = S), (v._loop = !!(v._loop || p._sprite[c][2])); }; if (b >= S) { p._ended(v); return; } var M = v._node; if (p._webAudio) { var C = function () { (p._playLock = !1), _(), p._refreshBuffer(v); var D = v._muted || p._muted ? 0 : v._volume; M.gain.setValueAtTime(D, i.ctx.currentTime), (v._playStart = i.ctx.currentTime), typeof M.bufferSource.start > 'u' ? v._loop ? M.bufferSource.noteGrainOn(0, b, 86400) : M.bufferSource.noteGrainOn(0, b, x) : v._loop ? M.bufferSource.start(0, b, 86400) : M.bufferSource.start(0, b, x), w !== 1 / 0 && (p._endTimers[v._id] = setTimeout(p._ended.bind(p, v), w)), d || setTimeout(function () { p._emit('play', v._id), p._loadQueue(); }, 0); }; i.state === 'running' && i.ctx.state !== 'interrupted' ? C() : ((p._playLock = !0), p.once('resume', C), p._clearTimer(v._id)); } else { var T = function () { (M.currentTime = b), (M.muted = v._muted || p._muted || i._muted || M.muted), (M.volume = v._volume * i.volume()), (M.playbackRate = v._rate); try { var D = M.play(); if ( (D && typeof Promise < 'u' && (D instanceof Promise || typeof D.then == 'function') ? ((p._playLock = !0), _(), D.then(function () { (p._playLock = !1), (M._unlocked = !0), d ? p._loadQueue() : p._emit('play', v._id); }).catch(function () { (p._playLock = !1), p._emit( 'playerror', v._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.' ), (v._ended = !0), (v._paused = !0); })) : d || ((p._playLock = !1), _(), p._emit('play', v._id)), (M.playbackRate = v._rate), M.paused) ) { p._emit( 'playerror', v._id, 'Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.' ); return; } c !== '__default' || v._loop ? (p._endTimers[v._id] = setTimeout(p._ended.bind(p, v), w)) : ((p._endTimers[v._id] = function () { p._ended(v), M.removeEventListener('ended', p._endTimers[v._id], !1); }), M.addEventListener('ended', p._endTimers[v._id], !1)); } catch (k) { p._emit('playerror', v._id, k); } }; M.src === 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA' && ((M.src = p._src), M.load()); var P = (window && window.ejecta) || (!M.readyState && i._navigator.isCocoonJS); if (M.readyState >= 3 || P) T(); else { (p._playLock = !0), (p._state = 'loading'); var L = function () { (p._state = 'loaded'), T(), M.removeEventListener(i._canPlayEvent, L, !1); }; M.addEventListener(i._canPlayEvent, L, !1), p._clearTimer(v._id); } } return v._id; }, pause: function (c) { var d = this; if (d._state !== 'loaded' || d._playLock) return ( d._queue.push({ event: 'pause', action: function () { d.pause(c); } }), d ); for (var p = d._getSoundIds(c), f = 0; f < p.length; f++) { d._clearTimer(p[f]); var g = d._soundById(p[f]); if (g && !g._paused && ((g._seek = d.seek(p[f])), (g._rateSeek = 0), (g._paused = !0), d._stopFade(p[f]), g._node)) if (d._webAudio) { if (!g._node.bufferSource) continue; typeof g._node.bufferSource.stop > 'u' ? g._node.bufferSource.noteOff(0) : g._node.bufferSource.stop(0), d._cleanBuffer(g._node); } else (!isNaN(g._node.duration) || g._node.duration === 1 / 0) && g._node.pause(); arguments[1] || d._emit('pause', g ? g._id : null); } return d; }, stop: function (c, d) { var p = this; if (p._state !== 'loaded' || p._playLock) return ( p._queue.push({ event: 'stop', action: function () { p.stop(c); } }), p ); for (var f = p._getSoundIds(c), g = 0; g < f.length; g++) { p._clearTimer(f[g]); var m = p._soundById(f[g]); m && ((m._seek = m._start || 0), (m._rateSeek = 0), (m._paused = !0), (m._ended = !0), p._stopFade(f[g]), m._node && (p._webAudio ? m._node.bufferSource && (typeof m._node.bufferSource.stop > 'u' ? m._node.bufferSource.noteOff(0) : m._node.bufferSource.stop(0), p._cleanBuffer(m._node)) : (!isNaN(m._node.duration) || m._node.duration === 1 / 0) && ((m._node.currentTime = m._start || 0), m._node.pause(), m._node.duration === 1 / 0 && p._clearSound(m._node))), d || p._emit('stop', m._id)); } return p; }, mute: function (c, d) { var p = this; if (p._state !== 'loaded' || p._playLock) return ( p._queue.push({ event: 'mute', action: function () { p.mute(c, d); } }), p ); if (typeof d > 'u') if (typeof c == 'boolean') p._muted = c; else return p._muted; for (var f = p._getSoundIds(d), g = 0; g < f.length; g++) { var m = p._soundById(f[g]); m && ((m._muted = c), m._interval && p._stopFade(m._id), p._webAudio && m._node ? m._node.gain.setValueAtTime(c ? 0 : m._volume, i.ctx.currentTime) : m._node && (m._node.muted = i._muted ? !0 : c), p._emit('mute', m._id)); } return p; }, volume: function () { var c = this, d = arguments, p, f; if (d.length === 0) return c._volume; if (d.length === 1 || (d.length === 2 && typeof d[1] > 'u')) { var g = c._getSoundIds(), m = g.indexOf(d[0]); m >= 0 ? (f = parseInt(d[0], 10)) : (p = parseFloat(d[0])); } else d.length >= 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10))); var v; if (typeof p < 'u' && p >= 0 && p <= 1) { if (c._state !== 'loaded' || c._playLock) return ( c._queue.push({ event: 'volume', action: function () { c.volume.apply(c, d); } }), c ); typeof f > 'u' && (c._volume = p), (f = c._getSoundIds(f)); for (var y = 0; y < f.length; y++) (v = c._soundById(f[y])), v && ((v._volume = p), d[2] || c._stopFade(f[y]), c._webAudio && v._node && !v._muted ? v._node.gain.setValueAtTime(p, i.ctx.currentTime) : v._node && !v._muted && (v._node.volume = p * i.volume()), c._emit('volume', v._id)); } else return (v = f ? c._soundById(f) : c._sounds[0]), v ? v._volume : 0; return c; }, fade: function (c, d, p, f) { var g = this; if (g._state !== 'loaded' || g._playLock) return ( g._queue.push({ event: 'fade', action: function () { g.fade(c, d, p, f); } }), g ); (c = Math.min(Math.max(0, parseFloat(c)), 1)), (d = Math.min(Math.max(0, parseFloat(d)), 1)), (p = parseFloat(p)), g.volume(c, f); for (var m = g._getSoundIds(f), v = 0; v < m.length; v++) { var y = g._soundById(m[v]); if (y) { if ((f || g._stopFade(m[v]), g._webAudio && !y._muted)) { var b = i.ctx.currentTime, x = b + p / 1e3; (y._volume = c), y._node.gain.setValueAtTime(c, b), y._node.gain.linearRampToValueAtTime(d, x); } g._startFadeInterval(y, c, d, p, m[v], typeof f > 'u'); } } return g; }, _startFadeInterval: function (c, d, p, f, g, m) { var v = this, y = d, b = p - d, x = Math.abs(b / 0.01), w = Math.max(4, x > 0 ? f / x : f), A = Date.now(); (c._fadeTo = p), (c._interval = setInterval(function () { var S = (Date.now() - A) / f; (A = Date.now()), (y += b * S), (y = Math.round(y * 100) / 100), b < 0 ? (y = Math.max(p, y)) : (y = Math.min(p, y)), v._webAudio ? (c._volume = y) : v.volume(y, c._id, !0), m && (v._volume = y), ((p < d && y <= p) || (p > d && y >= p)) && (clearInterval(c._interval), (c._interval = null), (c._fadeTo = null), v.volume(p, c._id), v._emit('fade', c._id)); }, w)); }, _stopFade: function (c) { var d = this, p = d._soundById(c); return ( p && p._interval && (d._webAudio && p._node.gain.cancelScheduledValues(i.ctx.currentTime), clearInterval(p._interval), (p._interval = null), d.volume(p._fadeTo, c), (p._fadeTo = null), d._emit('fade', c)), d ); }, loop: function () { var c = this, d = arguments, p, f, g; if (d.length === 0) return c._loop; if (d.length === 1) if (typeof d[0] == 'boolean') (p = d[0]), (c._loop = p); else return (g = c._soundById(parseInt(d[0], 10))), g ? g._loop : !1; else d.length === 2 && ((p = d[0]), (f = parseInt(d[1], 10))); for (var m = c._getSoundIds(f), v = 0; v < m.length; v++) (g = c._soundById(m[v])), g && ((g._loop = p), c._webAudio && g._node && g._node.bufferSource && ((g._node.bufferSource.loop = p), p && ((g._node.bufferSource.loopStart = g._start || 0), (g._node.bufferSource.loopEnd = g._stop), c.playing(m[v]) && (c.pause(m[v], !0), c.play(m[v], !0))))); return c; }, rate: function () { var c = this, d = arguments, p, f; if (d.length === 0) f = c._sounds[0]._id; else if (d.length === 1) { var g = c._getSoundIds(), m = g.indexOf(d[0]); m >= 0 ? (f = parseInt(d[0], 10)) : (p = parseFloat(d[0])); } else d.length === 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10))); var v; if (typeof p == 'number') { if (c._state !== 'loaded' || c._playLock) return ( c._queue.push({ event: 'rate', action: function () { c.rate.apply(c, d); } }), c ); typeof f > 'u' && (c._rate = p), (f = c._getSoundIds(f)); for (var y = 0; y < f.length; y++) if (((v = c._soundById(f[y])), v)) { c.playing(f[y]) && ((v._rateSeek = c.seek(f[y])), (v._playStart = c._webAudio ? i.ctx.currentTime : v._playStart)), (v._rate = p), c._webAudio && v._node && v._node.bufferSource ? v._node.bufferSource.playbackRate.setValueAtTime(p, i.ctx.currentTime) : v._node && (v._node.playbackRate = p); var b = c.seek(f[y]), x = (c._sprite[v._sprite][0] + c._sprite[v._sprite][1]) / 1e3 - b, w = (x * 1e3) / Math.abs(v._rate); (c._endTimers[f[y]] || !v._paused) && (c._clearTimer(f[y]), (c._endTimers[f[y]] = setTimeout(c._ended.bind(c, v), w))), c._emit('rate', v._id); } } else return (v = c._soundById(f)), v ? v._rate : c._rate; return c; }, seek: function () { var c = this, d = arguments, p, f; if (d.length === 0) c._sounds.length && (f = c._sounds[0]._id); else if (d.length === 1) { var g = c._getSoundIds(), m = g.indexOf(d[0]); m >= 0 ? (f = parseInt(d[0], 10)) : c._sounds.length && ((f = c._sounds[0]._id), (p = parseFloat(d[0]))); } else d.length === 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10))); if (typeof f > 'u') return 0; if (typeof p == 'number' && (c._state !== 'loaded' || c._playLock)) return ( c._queue.push({ event: 'seek', action: function () { c.seek.apply(c, d); } }), c ); var v = c._soundById(f); if (v) if (typeof p == 'number' && p >= 0) { var y = c.playing(f); y && c.pause(f, !0), (v._seek = p), (v._ended = !1), c._clearTimer(f), !c._webAudio && v._node && !isNaN(v._node.duration) && (v._node.currentTime = p); var b = function () { y && c.play(f, !0), c._emit('seek', f); }; if (y && !c._webAudio) { var x = function () { c._playLock ? setTimeout(x, 0) : b(); }; setTimeout(x, 0); } else b(); } else if (c._webAudio) { var w = c.playing(f) ? i.ctx.currentTime - v._playStart : 0, A = v._rateSeek ? v._rateSeek - v._seek : 0; return v._seek + (A + w * Math.abs(v._rate)); } else return v._node.currentTime; return c; }, playing: function (c) { var d = this; if (typeof c == 'number') { var p = d._soundById(c); return p ? !p._paused : !1; } for (var f = 0; f < d._sounds.length; f++) if (!d._sounds[f]._paused) return !0; return !1; }, duration: function (c) { var d = this, p = d._duration, f = d._soundById(c); return f && (p = d._sprite[f._sprite][1] / 1e3), p; }, state: function () { return this._state; }, unload: function () { for (var c = this, d = c._sounds, p = 0; p < d.length; p++) d[p]._paused || c.stop(d[p]._id), c._webAudio || (c._clearSound(d[p]._node), d[p]._node.removeEventListener('error', d[p]._errorFn, !1), d[p]._node.removeEventListener(i._canPlayEvent, d[p]._loadFn, !1), d[p]._node.removeEventListener('ended', d[p]._endFn, !1), i._releaseHtml5Audio(d[p]._node)), delete d[p]._node, c._clearTimer(d[p]._id); var f = i._howls.indexOf(c); f >= 0 && i._howls.splice(f, 1); var g = !0; for (p = 0; p < i._howls.length; p++) if (i._howls[p]._src === c._src || c._src.indexOf(i._howls[p]._src) >= 0) { g = !1; break; } return n && g && delete n[c._src], (i.noAudio = !1), (c._state = 'unloaded'), (c._sounds = []), (c = null), null; }, on: function (c, d, p, f) { var g = this, m = g['_on' + c]; return typeof d == 'function' && m.push(f ? { id: p, fn: d, once: f } : { id: p, fn: d }), g; }, off: function (c, d, p) { var f = this, g = f['_on' + c], m = 0; if ((typeof d == 'number' && ((p = d), (d = null)), d || p)) for (m = 0; m < g.length; m++) { var v = p === g[m].id; if ((d === g[m].fn && v) || (!d && v)) { g.splice(m, 1); break; } } else if (c) f['_on' + c] = []; else { var y = Object.keys(f); for (m = 0; m < y.length; m++) y[m].indexOf('_on') === 0 && Array.isArray(f[y[m]]) && (f[y[m]] = []); } return f; }, once: function (c, d, p) { var f = this; return f.on(c, d, p, 1), f; }, _emit: function (c, d, p) { for (var f = this, g = f['_on' + c], m = g.length - 1; m >= 0; m--) (!g[m].id || g[m].id === d || c === 'load') && (setTimeout( function (v) { v.call(this, d, p); }.bind(f, g[m].fn), 0 ), g[m].once && f.off(c, g[m].fn, g[m].id)); return f._loadQueue(c), f; }, _loadQueue: function (c) { var d = this; if (d._queue.length > 0) { var p = d._queue[0]; p.event === c && (d._queue.shift(), d._loadQueue()), c || p.action(); } return d; }, _ended: function (c) { var d = this, p = c._sprite; if (!d._webAudio && c._node && !c._node.paused && !c._node.ended && c._node.currentTime < c._stop) return setTimeout(d._ended.bind(d, c), 100), d; var f = !!(c._loop || d._sprite[p][2]); if ((d._emit('end', c._id), !d._webAudio && f && d.stop(c._id, !0).play(c._id), d._webAudio && f)) { d._emit('play', c._id), (c._seek = c._start || 0), (c._rateSeek = 0), (c._playStart = i.ctx.currentTime); var g = ((c._stop - c._start) * 1e3) / Math.abs(c._rate); d._endTimers[c._id] = setTimeout(d._ended.bind(d, c), g); } return ( d._webAudio && !f && ((c._paused = !0), (c._ended = !0), (c._seek = c._start || 0), (c._rateSeek = 0), d._clearTimer(c._id), d._cleanBuffer(c._node), i._autoSuspend()), !d._webAudio && !f && d.stop(c._id, !0), d ); }, _clearTimer: function (c) { var d = this; if (d._endTimers[c]) { if (typeof d._endTimers[c] != 'function') clearTimeout(d._endTimers[c]); else { var p = d._soundById(c); p && p._node && p._node.removeEventListener('ended', d._endTimers[c], !1); } delete d._endTimers[c]; } return d; }, _soundById: function (c) { for (var d = this, p = 0; p < d._sounds.length; p++) if (c === d._sounds[p]._id) return d._sounds[p]; return null; }, _inactiveSound: function () { var c = this; c._drain(); for (var d = 0; d < c._sounds.length; d++) if (c._sounds[d]._ended) return c._sounds[d].reset(); return new s(c); }, _drain: function () { var c = this, d = c._pool, p = 0, f = 0; if (!(c._sounds.length < d)) { for (f = 0; f < c._sounds.length; f++) c._sounds[f]._ended && p++; for (f = c._sounds.length - 1; f >= 0; f--) { if (p <= d) return; c._sounds[f]._ended && (c._webAudio && c._sounds[f]._node && c._sounds[f]._node.disconnect(0), c._sounds.splice(f, 1), p--); } } }, _getSoundIds: function (c) { var d = this; if (typeof c > 'u') { for (var p = [], f = 0; f < d._sounds.length; f++) p.push(d._sounds[f]._id); return p; } else return [c]; }, _refreshBuffer: function (c) { var d = this; return ( (c._node.bufferSource = i.ctx.createBufferSource()), (c._node.bufferSource.buffer = n[d._src]), c._panner ? c._node.bufferSource.connect(c._panner) : c._node.bufferSource.connect(c._node), (c._node.bufferSource.loop = c._loop), c._loop && ((c._node.bufferSource.loopStart = c._start || 0), (c._node.bufferSource.loopEnd = c._stop || 0)), c._node.bufferSource.playbackRate.setValueAtTime(c._rate, i.ctx.currentTime), d ); }, _cleanBuffer: function (c) { var d = this, p = i._navigator && i._navigator.vendor.indexOf('Apple') >= 0; if (i._scratchBuffer && c.bufferSource && ((c.bufferSource.onended = null), c.bufferSource.disconnect(0), p)) try { c.bufferSource.buffer = i._scratchBuffer; } catch {} return (c.bufferSource = null), d; }, _clearSound: function (c) { var d = /MSIE |Trident\//.test(i._navigator && i._navigator.userAgent); d || (c.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA'); } }; var s = function (c) { (this._parent = c), this.init(); }; s.prototype = { init: function () { var c = this, d = c._parent; return ( (c._muted = d._muted), (c._loop = d._loop), (c._volume = d._volume), (c._rate = d._rate), (c._seek = 0), (c._paused = !0), (c._ended = !0), (c._sprite = '__default'), (c._id = ++i._counter), d._sounds.push(c), c.create(), c ); }, create: function () { var c = this, d = c._parent, p = i._muted || c._muted || c._parent._muted ? 0 : c._volume; return ( d._webAudio ? ((c._node = typeof i.ctx.createGain > 'u' ? i.ctx.createGainNode() : i.ctx.createGain()), c._node.gain.setValueAtTime(p, i.ctx.currentTime), (c._node.paused = !0), c._node.connect(i.masterGain)) : i.noAudio || ((c._node = i._obtainHtml5Audio()), (c._errorFn = c._errorListener.bind(c)), c._node.addEventListener('error', c._errorFn, !1), (c._loadFn = c._loadListener.bind(c)), c._node.addEventListener(i._canPlayEvent, c._loadFn, !1), (c._endFn = c._endListener.bind(c)), c._node.addEventListener('ended', c._endFn, !1), (c._node.src = d._src), (c._node.preload = d._preload === !0 ? 'auto' : d._preload), (c._node.volume = p * i.volume()), c._node.load()), c ); }, reset: function () { var c = this, d = c._parent; return ( (c._muted = d._muted), (c._loop = d._loop), (c._volume = d._volume), (c._rate = d._rate), (c._seek = 0), (c._rateSeek = 0), (c._paused = !0), (c._ended = !0), (c._sprite = '__default'), (c._id = ++i._counter), c ); }, _errorListener: function () { var c = this; c._parent._emit('loaderror', c._id, c._node.error ? c._node.error.code : 0), c._node.removeEventListener('error', c._errorFn, !1); }, _loadListener: function () { var c = this, d = c._parent; (d._duration = Math.ceil(c._node.duration * 10) / 10), Object.keys(d._sprite).length === 0 && (d._sprite = { __default: [0, d._duration * 1e3] }), d._state !== 'loaded' && ((d._state = 'loaded'), d._emit('load'), d._loadQueue()), c._node.removeEventListener(i._canPlayEvent, c._loadFn, !1); }, _endListener: function () { var c = this, d = c._parent; d._duration === 1 / 0 && ((d._duration = Math.ceil(c._node.duration * 10) / 10), d._sprite.__default[1] === 1 / 0 && (d._sprite.__default[1] = d._duration * 1e3), d._ended(c)), c._node.removeEventListener('ended', c._endFn, !1); } }; var n = {}, a = function (c) { var d = c._src; if (n[d]) { (c._duration = n[d].duration), h(c); return; } if (/^data:[^;]+;base64,/.test(d)) { for (var p = atob(d.split(',')[1]), f = new Uint8Array(p.length), g = 0; g < p.length; ++g) f[g] = p.charCodeAt(g); l(f.buffer, c); } else { var m = new XMLHttpRequest(); m.open(c._xhr.method, d, !0), (m.withCredentials = c._xhr.withCredentials), (m.responseType = 'arraybuffer'), c._xhr.headers && Object.keys(c._xhr.headers).forEach(function (v) { m.setRequestHeader(v, c._xhr.headers[v]); }), (m.onload = function () { var v = (m.status + '')[0]; if (v !== '0' && v !== '2' && v !== '3') { c._emit('loaderror', null, 'Failed loading audio file with status: ' + m.status + '.'); return; } l(m.response, c); }), (m.onerror = function () { c._webAudio && ((c._html5 = !0), (c._webAudio = !1), (c._sounds = []), delete n[d], c.load()); }), o(m); } }, o = function (c) { try { c.send(); } catch { c.onerror(); } }, l = function (c, d) { var p = function () { d._emit('loaderror', null, 'Decoding audio data failed.'); }, f = function (g) { g && d._sounds.length > 0 ? ((n[d._src] = g), h(d, g)) : p(); }; typeof Promise < 'u' && i.ctx.decodeAudioData.length === 1 ? i.ctx.decodeAudioData(c).then(f).catch(p) : i.ctx.decodeAudioData(c, f, p); }, h = function (c, d) { d && !c._duration && (c._duration = d.duration), Object.keys(c._sprite).length === 0 && (c._sprite = { __default: [0, c._duration * 1e3] }), c._state !== 'loaded' && ((c._state = 'loaded'), c._emit('load'), c._loadQueue()); }, u = function () { if (i.usingWebAudio) { try { typeof AudioContext < 'u' ? (i.ctx = new AudioContext()) : typeof webkitAudioContext < 'u' ? (i.ctx = new webkitAudioContext()) : (i.usingWebAudio = !1); } catch { i.usingWebAudio = !1; } i.ctx || (i.usingWebAudio = !1); var c = /iP(hone|od|ad)/.test(i._navigator && i._navigator.platform), d = i._navigator && i._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), p = d ? parseInt(d[1], 10) : null; if (c && p && p < 9) { var f = /safari/.test(i._navigator && i._navigator.userAgent.toLowerCase()); i._navigator && !f && (i.usingWebAudio = !1); } i.usingWebAudio && ((i.masterGain = typeof i.ctx.createGain > 'u' ? i.ctx.createGainNode() : i.ctx.createGain()), i.masterGain.gain.setValueAtTime(i._muted ? 0 : i._volume, i.ctx.currentTime), i.masterGain.connect(i.ctx.destination)), i._setup(); } }; typeof define == 'function' && define.amd && define([], function () { return { Howler: i, Howl: r }; }), typeof e < 'u' && ((e.Howler = i), (e.Howl = r)), typeof global < 'u' ? ((global.HowlerGlobal = t), (global.Howler = i), (global.Howl = r), (global.Sound = s)) : typeof window < 'u' && ((window.HowlerGlobal = t), (window.Howler = i), (window.Howl = r), (window.Sound = s)); })(), (function () { 'use strict'; (HowlerGlobal.prototype._pos = [0, 0, 0]), (HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0]), (HowlerGlobal.prototype.stereo = function (i) { var r = this; if (!r.ctx || !r.ctx.listener) return r; for (var s = r._howls.length - 1; s >= 0; s--) r._howls[s].stereo(i); return r; }), (HowlerGlobal.prototype.pos = function (i, r, s) { var n = this; if (!n.ctx || !n.ctx.listener) return n; if (((r = typeof r != 'number' ? n._pos[1] : r), (s = typeof s != 'number' ? n._pos[2] : s), typeof i == 'number')) (n._pos = [i, r, s]), typeof n.ctx.listener.positionX < 'u' ? (n.ctx.listener.positionX.setTargetAtTime(n._pos[0], Howler.ctx.currentTime, 0.1), n.ctx.listener.positionY.setTargetAtTime(n._pos[1], Howler.ctx.currentTime, 0.1), n.ctx.listener.positionZ.setTargetAtTime(n._pos[2], Howler.ctx.currentTime, 0.1)) : n.ctx.listener.setPosition(n._pos[0], n._pos[1], n._pos[2]); else return n._pos; return n; }), (HowlerGlobal.prototype.orientation = function (i, r, s, n, a, o) { var l = this; if (!l.ctx || !l.ctx.listener) return l; var h = l._orientation; if ( ((r = typeof r != 'number' ? h[1] : r), (s = typeof s != 'number' ? h[2] : s), (n = typeof n != 'number' ? h[3] : n), (a = typeof a != 'number' ? h[4] : a), (o = typeof o != 'number' ? h[5] : o), typeof i == 'number') ) (l._orientation = [i, r, s, n, a, o]), typeof l.ctx.listener.forwardX < 'u' ? (l.ctx.listener.forwardX.setTargetAtTime(i, Howler.ctx.currentTime, 0.1), l.ctx.listener.forwardY.setTargetAtTime(r, Howler.ctx.currentTime, 0.1), l.ctx.listener.forwardZ.setTargetAtTime(s, Howler.ctx.currentTime, 0.1), l.ctx.listener.upX.setTargetAtTime(n, Howler.ctx.currentTime, 0.1), l.ctx.listener.upY.setTargetAtTime(a, Howler.ctx.currentTime, 0.1), l.ctx.listener.upZ.setTargetAtTime(o, Howler.ctx.currentTime, 0.1)) : l.ctx.listener.setOrientation(i, r, s, n, a, o); else return h; return l; }), (Howl.prototype.init = (function (i) { return function (r) { var s = this; return ( (s._orientation = r.orientation || [1, 0, 0]), (s._stereo = r.stereo || null), (s._pos = r.pos || null), (s._pannerAttr = { coneInnerAngle: typeof r.coneInnerAngle < 'u' ? r.coneInnerAngle : 360, coneOuterAngle: typeof r.coneOuterAngle < 'u' ? r.coneOuterAngle : 360, coneOuterGain: typeof r.coneOuterGain < 'u' ? r.coneOuterGain : 0, distanceModel: typeof r.distanceModel < 'u' ? r.distanceModel : 'inverse', maxDistance: typeof r.maxDistance < 'u' ? r.maxDistance : 1e4, panningModel: typeof r.panningModel < 'u' ? r.panningModel : 'HRTF', refDistance: typeof r.refDistance < 'u' ? r.refDistance : 1, rolloffFactor: typeof r.rolloffFactor < 'u' ? r.rolloffFactor : 1 }), (s._onstereo = r.onstereo ? [{ fn: r.onstereo }] : []), (s._onpos = r.onpos ? [{ fn: r.onpos }] : []), (s._onorientation = r.onorientation ? [{ fn: r.onorientation }] : []), i.call(this, r) ); }; })(Howl.prototype.init)), (Howl.prototype.stereo = function (i, r) { var s = this; if (!s._webAudio) return s; if (s._state !== 'loaded') return ( s._queue.push({ event: 'stereo', action: function () { s.stereo(i, r); } }), s ); var n = typeof Howler.ctx.createStereoPanner > 'u' ? 'spatial' : 'stereo'; if (typeof r > 'u') if (typeof i == 'number') (s._stereo = i), (s._pos = [i, 0, 0]); else return s._stereo; for (var a = s._getSoundIds(r), o = 0; o < a.length; o++) { var l = s._soundById(a[o]); if (l) if (typeof i == 'number') (l._stereo = i), (l._pos = [i, 0, 0]), l._node && ((l._pannerAttr.panningModel = 'equalpower'), (!l._panner || !l._panner.pan) && t(l, n), n === 'spatial' ? typeof l._panner.positionX < 'u' ? (l._panner.positionX.setValueAtTime(i, Howler.ctx.currentTime), l._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime), l._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime)) : l._panner.setPosition(i, 0, 0) : l._panner.pan.setValueAtTime(i, Howler.ctx.currentTime)), s._emit('stereo', l._id); else return l._stereo; } return s; }), (Howl.prototype.pos = function (i, r, s, n) { var a = this; if (!a._webAudio) return a; if (a._state !== 'loaded') return ( a._queue.push({ event: 'pos', action: function () { a.pos(i, r, s, n); } }), a ); if (((r = typeof r != 'number' ? 0 : r), (s = typeof s != 'number' ? -0.5 : s), typeof n > 'u')) if (typeof i == 'number') a._pos = [i, r, s]; else return a._pos; for (var o = a._getSoundIds(n), l = 0; l < o.length; l++) { var h = a._soundById(o[l]); if (h) if (typeof i == 'number') (h._pos = [i, r, s]), h._node && ((!h._panner || h._panner.pan) && t(h, 'spatial'), typeof h._panner.positionX < 'u' ? (h._panner.positionX.setValueAtTime(i, Howler.ctx.currentTime), h._panner.positionY.setValueAtTime(r, Howler.ctx.currentTime), h._panner.positionZ.setValueAtTime(s, Howler.ctx.currentTime)) : h._panner.setPosition(i, r, s)), a._emit('pos', h._id); else return h._pos; } return a; }), (Howl.prototype.orientation = function (i, r, s, n) { var a = this; if (!a._webAudio) return a; if (a._state !== 'loaded') return ( a._queue.push({ event: 'orientation', action: function () { a.orientation(i, r, s, n); } }), a ); if (((r = typeof r != 'number' ? a._orientation[1] : r), (s = typeof s != 'number' ? a._orientation[2] : s), typeof n > 'u')) if (typeof i == 'number') a._orientation = [i, r, s]; else return a._orientation; for (var o = a._getSoundIds(n), l = 0; l < o.length; l++) { var h = a._soundById(o[l]); if (h) if (typeof i == 'number') (h._orientation = [i, r, s]), h._node && (h._panner || (h._pos || (h._pos = a._pos || [0, 0, -0.5]), t(h, 'spatial')), typeof h._panner.orientationX < 'u' ? (h._panner.orientationX.setValueAtTime(i, Howler.ctx.currentTime), h._panner.orientationY.setValueAtTime(r, Howler.ctx.currentTime), h._panner.orientationZ.setValueAtTime(s, Howler.ctx.currentTime)) : h._panner.setOrientation(i, r, s)), a._emit('orientation', h._id); else return h._orientation; } return a; }), (Howl.prototype.pannerAttr = function () { var i = this, r = arguments, s, n, a; if (!i._webAudio) return i; if (r.length === 0) return i._pannerAttr; if (r.length === 1) if (typeof r[0] == 'object') (s = r[0]), typeof n > 'u' && (s.pannerAttr || (s.pannerAttr = { coneInnerAngle: s.coneInnerAngle, coneOuterAngle: s.coneOuterAngle, coneOuterGain: s.coneOuterGain, distanceModel: s.distanceModel, maxDistance: s.maxDistance, refDistance: s.refDistance, rolloffFactor: s.rolloffFactor, panningModel: s.panningModel }), (i._pannerAttr = { coneInnerAngle: typeof s.pannerAttr.coneInnerAngle < 'u' ? s.pannerAttr.coneInnerAngle : i._coneInnerAngle, coneOuterAngle: typeof s.pannerAttr.coneOuterAngle < 'u' ? s.pannerAttr.coneOuterAngle : i._coneOuterAngle, coneOuterGain: typeof s.pannerAttr.coneOuterGain < 'u' ? s.pannerAttr.coneOuterGain : i._coneOuterGain, distanceModel: typeof s.pannerAttr.distanceModel < 'u' ? s.pannerAttr.distanceModel : i._distanceModel, maxDistance: typeof s.pannerAttr.maxDistance < 'u' ? s.pannerAttr.maxDistance : i._maxDistance, refDistance: typeof s.pannerAttr.refDistance < 'u' ? s.pannerAttr.refDistance : i._refDistance, rolloffFactor: typeof s.pannerAttr.rolloffFactor < 'u' ? s.pannerAttr.rolloffFactor : i._rolloffFactor, panningModel: typeof s.pannerAttr.panningModel < 'u' ? s.pannerAttr.panningModel : i._panningModel })); else return (a = i._soundById(parseInt(r[0], 10))), a ? a._pannerAttr : i._pannerAttr; else r.length === 2 && ((s = r[0]), (n = parseInt(r[1], 10))); for (var o = i._getSoundIds(n), l = 0; l < o.length; l++) if (((a = i._soundById(o[l])), a)) { var h = a._pannerAttr; h = { coneInnerAngle: typeof s.coneInnerAngle < 'u' ? s.coneInnerAngle : h.coneInnerAngle, coneOuterAngle: typeof s.coneOuterAngle < 'u' ? s.coneOuterAngle : h.coneOuterAngle, coneOuterGain: typeof s.coneOuterGain < 'u' ? s.coneOuterGain : h.coneOuterGain, distanceModel: typeof s.distanceModel < 'u' ? s.distanceModel : h.distanceModel, maxDistance: typeof s.maxDistance < 'u' ? s.maxDistance : h.maxDistance, refDistance: typeof s.refDistance < 'u' ? s.refDistance : h.refDistance, rolloffFactor: typeof s.rolloffFactor < 'u' ? s.rolloffFactor : h.rolloffFactor, panningModel: typeof s.panningModel < 'u' ? s.panningModel : h.panningModel }; var u = a._panner; u ? ((u.coneInnerAngle = h.coneInnerAngle), (u.coneOuterAngle = h.coneOuterAngle), (u.coneOuterGain = h.coneOuterGain), (u.distanceModel = h.distanceModel), (u.maxDistance = h.maxDistance), (u.refDistance = h.refDistance), (u.rolloffFactor = h.rolloffFactor), (u.panningModel = h.panningModel)) : (a._pos || (a._pos = i._pos || [0, 0, -0.5]), t(a, 'spatial')); } return i; }), (Sound.prototype.init = (function (i) { return function () { var r = this, s = r._parent; (r._orientation = s._orientation), (r._stereo = s._stereo), (r._pos = s._pos), (r._pannerAttr = s._pannerAttr), i.call(this), r._stereo ? s.stereo(r._stereo) : r._pos && s.pos(r._pos[0], r._pos[1], r._pos[2], r._id); }; })(Sound.prototype.init)), (Sound.prototype.reset = (function (i) { return function () { var r = this, s = r._parent; return ( (r._orientation = s._orientation), (r._stereo = s._stereo), (r._pos = s._pos), (r._pannerAttr = s._pannerAttr), r._stereo ? s.stereo(r._stereo) : r._pos ? s.pos(r._pos[0], r._pos[1], r._pos[2], r._id) : r._panner && (r._panner.disconnect(0), (r._panner = void 0), s._refreshBuffer(r)), i.call(this) ); }; })(Sound.prototype.reset)); var t = function (i, r) { (r = r || 'spatial'), r === 'spatial' ? ((i._panner = Howler.ctx.createPanner()), (i._panner.coneInnerAngle = i._pannerAttr.coneInnerAngle), (i._panner.coneOuterAngle = i._pannerAttr.coneOuterAngle), (i._panner.coneOuterGain = i._pannerAttr.coneOuterGain), (i._panner.distanceModel = i._pannerAttr.distanceModel), (i._panner.maxDistance = i._pannerAttr.maxDistance), (i._panner.refDistance = i._pannerAttr.refDistance), (i._panner.rolloffFactor = i._pannerAttr.rolloffFactor), (i._panner.panningModel = i._pannerAttr.panningModel), typeof i._panner.positionX < 'u' ? (i._panner.positionX.setValueAtTime(i._pos[0], Howler.ctx.currentTime), i._panner.positionY.setValueAtTime(i._pos[1], Howler.ctx.currentTime), i._panner.positionZ.setValueAtTime(i._pos[2], Howler.ctx.currentTime)) : i._panner.setPosition(i._pos[0], i._pos[1], i._pos[2]), typeof i._panner.orientationX < 'u' ? (i._panner.orientationX.setValueAtTime(i._orientation[0], Howler.ctx.currentTime), i._panner.orientationY.setValueAtTime(i._orientation[1], Howler.ctx.currentTime), i._panner.orientationZ.setValueAtTime(i._orientation[2], Howler.ctx.currentTime)) : i._panner.setOrientation(i._orientation[0], i._orientation[1], i._orientation[2])) : ((i._panner = Howler.ctx.createStereoPanner()), i._panner.pan.setValueAtTime(i._stereo, Howler.ctx.currentTime)), i._panner.connect(i._node), i._paused || i._parent.pause(i._id, !0).play(i._id, !0); }; })(); }), q2 = au((e, t) => { t.exports = function (i, r) { for (var s = i.split('.'), n = r.split('.'), a = 0; a < 3; a++) { var o = Number(s[a]), l = Number(n[a]); if (o > l) return 1; if (l > o) return -1; if (!isNaN(o) && isNaN(l)) return 1; if (isNaN(o) && !isNaN(l)) return -1; } return 0; }; }), Wo = '149', hr = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Y2 = 0, Jv = 1, Q2 = 2, og = 1, sw = 2, jl = 3, Vr = 0, hi = 1, er = 2, fi = 0, Ao = 1, $v = 2, e0 = 3, t0 = 4, Z2 = 5, no = 100, K2 = 101, J2 = 102, i0 = 103, r0 = 104, $2 = 200, eM = 201, tM = 202, iM = 203, nw = 204, aw = 205, rM = 206, sM = 207, nM = 208, aM = 209, oM = 210, lM = 0, hM = 1, cM = 2, Bf = 3, dM = 4, uM = 5, pM = 6, fM = 7, ow = 0, mM = 1, gM = 2, Gs = 0, vM = 1, yM = 2, xM = 3, bM = 4, wM = 5, lw = 300, ya = 301, xa = 302, zf = 303, Nf = 304, Ch = 306, oh = 1e3, Ji = 1001, Uf = 1002, Ot = 1003, s0 = 1004, Wu = 1005, mt = 1006, _M = 1007, Bo = 1008, Mi = 1009, AM = 1010, SM = 1011, hw = 1012, MM = 1013, gn = 1014, vn = 1015, lh = 1016, EM = 1017, CM = 1018, ca = 1020, TM = 1021, Ur = 1023, PM = 1024, DM = 1025, da = 1026, ba = 1027, LM = 1028, OM = 1029, IM = 1030, RM = 1031, BM = 1033, Xu = 33776, qu = 33777, Yu = 33778, Qu = 33779, n0 = 35840, a0 = 35841, o0 = 35842, l0 = 35843, zM = 36196, h0 = 37492, c0 = 37496, d0 = 37808, u0 = 37809, p0 = 37810, f0 = 37811, m0 = 37812, g0 = 37813, v0 = 37814, y0 = 37815, x0 = 37816, b0 = 37817, w0 = 37818, _0 = 37819, A0 = 37820, S0 = 37821, Zu = 36492, NM = 36283, M0 = 36284, E0 = 36285, C0 = 36286, dd = 2300, ud = 2301, Ku = 2302, T0 = 2400, P0 = 2401, D0 = 2402, gs = 3e3, Ke = 3001, qs = 3200, cw = 3201, UM = 0, FM = 1, rs = 'srgb', pd = 'srgb-linear', Ju = 7680, kM = 519, Ff = 35044, L0 = '300 es', kf = 1035, Vi = class { addEventListener(e, t) { this._listeners === void 0 && (this._listeners = {}); let i = this._listeners; i[e] === void 0 && (i[e] = []), i[e].indexOf(t) === -1 && i[e].push(t); } hasEventListener(e, t) { if (this._listeners === void 0) return !1; let i = this._listeners; return i[e] !== void 0 && i[e].indexOf(t) !== -1; } removeEventListener(e, t) { if (this._listeners === void 0) return; let i = this._listeners[e]; if (i !== void 0) { let r = i.indexOf(t); r !== -1 && i.splice(r, 1); } } dispatchEvent(e) { if (this._listeners === void 0) return; let t = this._listeners[e.type]; if (t !== void 0) { e.target = this; let i = t.slice(0); for (let r = 0, s = i.length; r < s; r++) i[r].call(this, e); e.target = null; } } }, yi = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ], O0 = 1234567, Ql = Math.PI / 180, hh = 180 / Math.PI; function ps() { let e = (Math.random() * 4294967295) | 0, t = (Math.random() * 4294967295) | 0, i = (Math.random() * 4294967295) | 0, r = (Math.random() * 4294967295) | 0; return ( yi[e & 255] + yi[(e >> 8) & 255] + yi[(e >> 16) & 255] + yi[(e >> 24) & 255] + '-' + yi[t & 255] + yi[(t >> 8) & 255] + '-' + yi[((t >> 16) & 15) | 64] + yi[(t >> 24) & 255] + '-' + yi[(i & 63) | 128] + yi[(i >> 8) & 255] + '-' + yi[(i >> 16) & 255] + yi[(i >> 24) & 255] + yi[r & 255] + yi[(r >> 8) & 255] + yi[(r >> 16) & 255] + yi[(r >> 24) & 255] ).toLowerCase(); } function ti(e, t, i) { return Math.max(t, Math.min(i, e)); } function lg(e, t) { return ((e % t) + t) % t; } function jM(e, t, i, r, s) { return r + ((e - t) * (s - r)) / (i - t); } function GM(e, t, i) { return e !== t ? (i - e) / (t - e) : 0; } function Zl(e, t, i) { return (1 - i) * e + i * t; } function VM(e, t, i, r) { return Zl(e, t, 1 - Math.exp(-i * r)); } function HM(e, t = 1) { return t - Math.abs(lg(e, t * 2) - t); } function WM(e, t, i) { return e <= t ? 0 : e >= i ? 1 : ((e = (e - t) / (i - t)), e * e * (3 - 2 * e)); } function XM(e, t, i) { return e <= t ? 0 : e >= i ? 1 : ((e = (e - t) / (i - t)), e * e * e * (e * (e * 6 - 15) + 10)); } function qM(e, t) { return e + Math.floor(Math.random() * (t - e + 1)); } function YM(e, t) { return e + Math.random() * (t - e); } function QM(e) { return e * (0.5 - Math.random()); } function ZM(e) { e !== void 0 && (O0 = e); let t = (O0 += 1831565813); return (t = Math.imul(t ^ (t >>> 15), t | 1)), (t ^= t + Math.imul(t ^ (t >>> 7), t | 61)), ((t ^ (t >>> 14)) >>> 0) / 4294967296; } function KM(e) { return e * Ql; } function JM(e) { return e * hh; } function jf(e) { return (e & (e - 1)) === 0 && e !== 0; } function $M(e) { return Math.pow(2, Math.ceil(Math.log(e) / Math.LN2)); } function fd(e) { return Math.pow(2, Math.floor(Math.log(e) / Math.LN2)); } function eE(e, t, i, r, s) { let n = Math.cos, a = Math.sin, o = n(i / 2), l = a(i / 2), h = n((t + r) / 2), u = a((t + r) / 2), c = n((t - r) / 2), d = a((t - r) / 2), p = n((r - t) / 2), f = a((r - t) / 2); switch (s) { case 'XYX': e.set(o * u, l * c, l * d, o * h); break; case 'YZY': e.set(l * d, o * u, l * c, o * h); break; case 'ZXZ': e.set(l * c, l * d, o * u, o * h); break; case 'XZX': e.set(o * u, l * f, l * p, o * h); break; case 'YXY': e.set(l * p, o * u, l * f, o * h); break; case 'ZYZ': e.set(l * f, l * p, o * u, o * h); break; default: console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + s); } } function ks(e, t) { switch (t.constructor) { case Float32Array: return e; case Uint16Array: return e / 65535; case Uint8Array: return e / 255; case Int16Array: return Math.max(e / 32767, -1); case Int8Array: return Math.max(e / 127, -1); default: throw new Error('Invalid component type.'); } } function _t(e, t) { switch (t.constructor) { case Float32Array: return e; case Uint16Array: return Math.round(e * 65535); case Uint8Array: return Math.round(e * 255); case Int16Array: return Math.round(e * 32767); case Int8Array: return Math.round(e * 127); default: throw new Error('Invalid component type.'); } } var it = Object.freeze({ __proto__: null, DEG2RAD: Ql, RAD2DEG: hh, ceilPowerOfTwo: $M, clamp: ti, damp: VM, degToRad: KM, denormalize: ks, euclideanModulo: lg, floorPowerOfTwo: fd, generateUUID: ps, inverseLerp: GM, isPowerOfTwo: jf, lerp: Zl, mapLinear: jM, normalize: _t, pingpong: HM, radToDeg: JM, randFloat: YM, randFloatSpread: QM, randInt: qM, seededRandom: ZM, setQuaternionFromProperEuler: eE, smootherstep: XM, smoothstep: WM }), G = class { constructor(e = 0, t = 0) { (G.prototype.isVector2 = !0), (this.x = e), (this.y = t); } get width() { return this.x; } set width(e) { this.x = e; } get height() { return this.y; } set height(e) { this.y = e; } set(e, t) { return (this.x = e), (this.y = t), this; } setScalar(e) { return (this.x = e), (this.y = e), this; } setX(e) { return (this.x = e), this; } setY(e) { return (this.y = e), this; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; default: throw new Error('index is out of range: ' + e); } return this; } getComponent(e) { switch (e) { case 0: return this.x; case 1: return this.y; default: throw new Error('index is out of range: ' + e); } } clone() { return new this.constructor(this.x, this.y); } copy(e) { return (this.x = e.x), (this.y = e.y), this; } add(e) { return (this.x += e.x), (this.y += e.y), this; } addScalar(e) { return (this.x += e), (this.y += e), this; } addVectors(e, t) { return (this.x = e.x + t.x), (this.y = e.y + t.y), this; } addScaledVector(e, t) { return (this.x += e.x * t), (this.y += e.y * t), this; } sub(e) { return (this.x -= e.x), (this.y -= e.y), this; } subScalar(e) { return (this.x -= e), (this.y -= e), this; } subVectors(e, t) { return (this.x = e.x - t.x), (this.y = e.y - t.y), this; } multiply(e) { return (this.x *= e.x), (this.y *= e.y), this; } multiplyScalar(e) { return (this.x *= e), (this.y *= e), this; } divide(e) { return (this.x /= e.x), (this.y /= e.y), this; } divideScalar(e) { return this.multiplyScalar(1 / e); } applyMatrix3(e) { let t = this.x, i = this.y, r = e.elements; return (this.x = r[0] * t + r[3] * i + r[6]), (this.y = r[1] * t + r[4] * i + r[7]), this; } min(e) { return (this.x = Math.min(this.x, e.x)), (this.y = Math.min(this.y, e.y)), this; } max(e) { return (this.x = Math.max(this.x, e.x)), (this.y = Math.max(this.y, e.y)), this; } clamp(e, t) { return (this.x = Math.max(e.x, Math.min(t.x, this.x))), (this.y = Math.max(e.y, Math.min(t.y, this.y))), this; } clampScalar(e, t) { return (this.x = Math.max(e, Math.min(t, this.x))), (this.y = Math.max(e, Math.min(t, this.y))), this; } clampLength(e, t) { let i = this.length(); return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i))); } floor() { return (this.x = Math.floor(this.x)), (this.y = Math.floor(this.y)), this; } ceil() { return (this.x = Math.ceil(this.x)), (this.y = Math.ceil(this.y)), this; } round() { return (this.x = Math.round(this.x)), (this.y = Math.round(this.y)), this; } roundToZero() { return ( (this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)), (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)), this ); } negate() { return (this.x = -this.x), (this.y = -this.y), this; } dot(e) { return this.x * e.x + this.y * e.y; } cross(e) { return this.x * e.y - this.y * e.x; } lengthSq() { return this.x * this.x + this.y * this.y; } length() { return Math.sqrt(this.x * this.x + this.y * this.y); } manhattanLength() { return Math.abs(this.x) + Math.abs(this.y); } normalize() { return this.divideScalar(this.length() || 1); } angle() { return Math.atan2(-this.y, -this.x) + Math.PI; } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { let t = this.x - e.x, i = this.y - e.y; return t * t + i * i; } manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); } setLength(e) { return this.normalize().multiplyScalar(e); } lerp(e, t) { return (this.x += (e.x - this.x) * t), (this.y += (e.y - this.y) * t), this; } lerpVectors(e, t, i) { return (this.x = e.x + (t.x - e.x) * i), (this.y = e.y + (t.y - e.y) * i), this; } equals(e) { return e.x === this.x && e.y === this.y; } fromArray(e, t = 0) { return (this.x = e[t]), (this.y = e[t + 1]), this; } toArray(e = [], t = 0) { return (e[t] = this.x), (e[t + 1] = this.y), e; } fromBufferAttribute(e, t) { return (this.x = e.getX(t)), (this.y = e.getY(t)), this; } rotateAround(e, t) { let i = Math.cos(t), r = Math.sin(t), s = this.x - e.x, n = this.y - e.y; return (this.x = s * i - n * r + e.x), (this.y = s * r + n * i + e.y), this; } random() { return (this.x = Math.random()), (this.y = Math.random()), this; } *[Symbol.iterator]() { yield this.x, yield this.y; } }, Ai = class { constructor() { (Ai.prototype.isMatrix3 = !0), (this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1]); } set(e, t, i, r, s, n, a, o, l) { let h = this.elements; return (h[0] = e), (h[1] = r), (h[2] = a), (h[3] = t), (h[4] = s), (h[5] = o), (h[6] = i), (h[7] = n), (h[8] = l), this; } identity() { return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; } copy(e) { let t = this.elements, i = e.elements; return ( (t[0] = i[0]), (t[1] = i[1]), (t[2] = i[2]), (t[3] = i[3]), (t[4] = i[4]), (t[5] = i[5]), (t[6] = i[6]), (t[7] = i[7]), (t[8] = i[8]), this ); } extractBasis(e, t, i) { return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this; } setFromMatrix4(e) { let t = e.elements; return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), this; } multiply(e) { return this.multiplyMatrices(this, e); } premultiply(e) { return this.multiplyMatrices(e, this); } multiplyMatrices(e, t) { let i = e.elements, r = t.elements, s = this.elements, n = i[0], a = i[3], o = i[6], l = i[1], h = i[4], u = i[7], c = i[2], d = i[5], p = i[8], f = r[0], g = r[3], m = r[6], v = r[1], y = r[4], b = r[7], x = r[2], w = r[5], A = r[8]; return ( (s[0] = n * f + a * v + o * x), (s[3] = n * g + a * y + o * w), (s[6] = n * m + a * b + o * A), (s[1] = l * f + h * v + u * x), (s[4] = l * g + h * y + u * w), (s[7] = l * m + h * b + u * A), (s[2] = c * f + d * v + p * x), (s[5] = c * g + d * y + p * w), (s[8] = c * m + d * b + p * A), this ); } multiplyScalar(e) { let t = this.elements; return (t[0] *= e), (t[3] *= e), (t[6] *= e), (t[1] *= e), (t[4] *= e), (t[7] *= e), (t[2] *= e), (t[5] *= e), (t[8] *= e), this; } determinant() { let e = this.elements, t = e[0], i = e[1], r = e[2], s = e[3], n = e[4], a = e[5], o = e[6], l = e[7], h = e[8]; return t * n * h - t * a * l - i * s * h + i * a * o + r * s * l - r * n * o; } invert() { let e = this.elements, t = e[0], i = e[1], r = e[2], s = e[3], n = e[4], a = e[5], o = e[6], l = e[7], h = e[8], u = h * n - a * l, c = a * o - h * s, d = l * s - n * o, p = t * u + i * c + r * d; if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); let f = 1 / p; return ( (e[0] = u * f), (e[1] = (r * l - h * i) * f), (e[2] = (a * i - r * n) * f), (e[3] = c * f), (e[4] = (h * t - r * o) * f), (e[5] = (r * s - a * t) * f), (e[6] = d * f), (e[7] = (i * o - l * t) * f), (e[8] = (n * t - i * s) * f), this ); } transpose() { let e, t = this.elements; return (e = t[1]), (t[1] = t[3]), (t[3] = e), (e = t[2]), (t[2] = t[6]), (t[6] = e), (e = t[5]), (t[5] = t[7]), (t[7] = e), this; } getNormalMatrix(e) { return this.setFromMatrix4(e).invert().transpose(); } transposeIntoArray(e) { let t = this.elements; return ( (e[0] = t[0]), (e[1] = t[3]), (e[2] = t[6]), (e[3] = t[1]), (e[4] = t[4]), (e[5] = t[7]), (e[6] = t[2]), (e[7] = t[5]), (e[8] = t[8]), this ); } setUvTransform(e, t, i, r, s, n, a) { let o = Math.cos(s), l = Math.sin(s); return this.set(i * o, i * l, -i * (o * n + l * a) + n + e, -r * l, r * o, -r * (-l * n + o * a) + a + t, 0, 0, 1), this; } scale(e, t) { return this.premultiply($u.makeScale(e, t)), this; } rotate(e) { return this.premultiply($u.makeRotation(-e)), this; } translate(e, t) { return this.premultiply($u.makeTranslation(e, t)), this; } makeTranslation(e, t) { return this.set(1, 0, e, 0, 1, t, 0, 0, 1), this; } makeRotation(e) { let t = Math.cos(e), i = Math.sin(e); return this.set(t, -i, 0, i, t, 0, 0, 0, 1), this; } makeScale(e, t) { return this.set(e, 0, 0, 0, t, 0, 0, 0, 1), this; } equals(e) { let t = this.elements, i = e.elements; for (let r = 0; r < 9; r++) if (t[r] !== i[r]) return !1; return !0; } fromArray(e, t = 0) { for (let i = 0; i < 9; i++) this.elements[i] = e[i + t]; return this; } toArray(e = [], t = 0) { let i = this.elements; return ( (e[t] = i[0]), (e[t + 1] = i[1]), (e[t + 2] = i[2]), (e[t + 3] = i[3]), (e[t + 4] = i[4]), (e[t + 5] = i[5]), (e[t + 6] = i[6]), (e[t + 7] = i[7]), (e[t + 8] = i[8]), e ); } clone() { return new this.constructor().fromArray(this.elements); } }, $u = new Ai(); function dw(e) { for (let t = e.length - 1; t >= 0; --t) if (e[t] >= 65535) return !0; return !1; } var tE = { Int8Array: Int8Array, Uint8Array: Uint8Array, Uint8ClampedArray: Uint8ClampedArray, Int16Array: Int16Array, Uint16Array: Uint16Array, Int32Array: Int32Array, Uint32Array: Uint32Array, Float32Array: Float32Array, Float64Array: Float64Array }; function Wh(e, t) { return new tE[e](t); } function md(e) { return document.createElementNS('http://www.w3.org/1999/xhtml', e); } function ua(e) { return e < 0.04045 ? e * 0.0773993808 : Math.pow(e * 0.9478672986 + 0.0521327014, 2.4); } function Kc(e) { return e < 0.0031308 ? e * 12.92 : 1.055 * Math.pow(e, 0.41666) - 0.055; } var ep = { [rs]: { [pd]: ua }, [pd]: { [rs]: Kc } }, Ci = { legacyMode: !0, get workingColorSpace() { return pd; }, set workingColorSpace(e) { console.warn('THREE.ColorManagement: .workingColorSpace is readonly.'); }, convert: function (e, t, i) { if (this.legacyMode || t === i || !t || !i) return e; if (ep[t] && ep[t][i] !== void 0) { let r = ep[t][i]; return (e.r = r(e.r)), (e.g = r(e.g)), (e.b = r(e.b)), e; } throw new Error('Unsupported color space conversion.'); }, fromWorkingColorSpace: function (e, t) { return this.convert(e, this.workingColorSpace, t); }, toWorkingColorSpace: function (e, t) { return this.convert(e, t, this.workingColorSpace); } }, uw = { 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 }, Jt = { r: 0, g: 0, b: 0 }, Dr = { h: 0, s: 0, l: 0 }, Xh = { h: 0, s: 0, l: 0 }; function tp(e, t, i) { return ( i < 0 && (i += 1), i > 1 && (i -= 1), i < 1 / 6 ? e + (t - e) * 6 * i : i < 1 / 2 ? t : i < 2 / 3 ? e + (t - e) * 6 * (2 / 3 - i) : e ); } function qh(e, t) { return (t.r = e.r), (t.g = e.g), (t.b = e.b), t; } var Ge = class { constructor(e, t, i) { return (this.isColor = !0), (this.r = 1), (this.g = 1), (this.b = 1), t === void 0 && i === void 0 ? this.set(e) : this.setRGB(e, t, i); } set(e) { return e && e.isColor ? this.copy(e) : typeof e == 'number' ? this.setHex(e) : typeof e == 'string' && this.setStyle(e), this; } setScalar(e) { return (this.r = e), (this.g = e), (this.b = e), this; } setHex(e, t = rs) { return ( (e = Math.floor(e)), (this.r = ((e >> 16) & 255) / 255), (this.g = ((e >> 8) & 255) / 255), (this.b = (e & 255) / 255), Ci.toWorkingColorSpace(this, t), this ); } setRGB(e, t, i, r = Ci.workingColorSpace) { return (this.r = e), (this.g = t), (this.b = i), Ci.toWorkingColorSpace(this, r), this; } setHSL(e, t, i, r = Ci.workingColorSpace) { if (((e = lg(e, 1)), (t = ti(t, 0, 1)), (i = ti(i, 0, 1)), t === 0)) this.r = this.g = this.b = i; else { let s = i <= 0.5 ? i * (1 + t) : i + t - i * t, n = 2 * i - s; (this.r = tp(n, s, e + 1 / 3)), (this.g = tp(n, s, e)), (this.b = tp(n, s, e - 1 / 3)); } return Ci.toWorkingColorSpace(this, r), this; } setStyle(e, t = rs) { function i(s) { s !== void 0 && parseFloat(s) < 1 && console.warn('THREE.Color: Alpha component of ' + e + ' will be ignored.'); } let r; if ((r = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e))) { let s, n = r[1], a = r[2]; switch (n) { case 'rgb': case 'rgba': if ((s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))) return ( (this.r = Math.min(255, parseInt(s[1], 10)) / 255), (this.g = Math.min(255, parseInt(s[2], 10)) / 255), (this.b = Math.min(255, parseInt(s[3], 10)) / 255), Ci.toWorkingColorSpace(this, t), i(s[4]), this ); if ((s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))) return ( (this.r = Math.min(100, parseInt(s[1], 10)) / 100), (this.g = Math.min(100, parseInt(s[2], 10)) / 100), (this.b = Math.min(100, parseInt(s[3], 10)) / 100), Ci.toWorkingColorSpace(this, t), i(s[4]), this ); break; case 'hsl': case 'hsla': if ((s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))) { let o = parseFloat(s[1]) / 360, l = parseFloat(s[2]) / 100, h = parseFloat(s[3]) / 100; return i(s[4]), this.setHSL(o, l, h, t); } break; } } else if ((r = /^\#([A-Fa-f\d]+)$/.exec(e))) { let s = r[1], n = s.length; if (n === 3) return ( (this.r = parseInt(s.charAt(0) + s.charAt(0), 16) / 255), (this.g = parseInt(s.charAt(1) + s.charAt(1), 16) / 255), (this.b = parseInt(s.charAt(2) + s.charAt(2), 16) / 255), Ci.toWorkingColorSpace(this, t), this ); if (n === 6) return ( (this.r = parseInt(s.charAt(0) + s.charAt(1), 16) / 255), (this.g = parseInt(s.charAt(2) + s.charAt(3), 16) / 255), (this.b = parseInt(s.charAt(4) + s.charAt(5), 16) / 255), Ci.toWorkingColorSpace(this, t), this ); } return e && e.length > 0 ? this.setColorName(e, t) : this; } setColorName(e, t = rs) { let i = uw[e.toLowerCase()]; return i !== void 0 ? this.setHex(i, t) : console.warn('THREE.Color: Unknown color ' + e), this; } clone() { return new this.constructor(this.r, this.g, this.b); } copy(e) { return (this.r = e.r), (this.g = e.g), (this.b = e.b), this; } copySRGBToLinear(e) { return (this.r = ua(e.r)), (this.g = ua(e.g)), (this.b = ua(e.b)), this; } copyLinearToSRGB(e) { return (this.r = Kc(e.r)), (this.g = Kc(e.g)), (this.b = Kc(e.b)), this; } convertSRGBToLinear() { return this.copySRGBToLinear(this), this; } convertLinearToSRGB() { return this.copyLinearToSRGB(this), this; } getHex(e = rs) { return ( Ci.fromWorkingColorSpace(qh(this, Jt), e), (ti(Jt.r * 255, 0, 255) << 16) ^ (ti(Jt.g * 255, 0, 255) << 8) ^ (ti(Jt.b * 255, 0, 255) << 0) ); } getHexString(e = rs) { return ('000000' + this.getHex(e).toString(16)).slice(-6); } getHSL(e, t = Ci.workingColorSpace) { Ci.fromWorkingColorSpace(qh(this, Jt), t); let i = Jt.r, r = Jt.g, s = Jt.b, n = Math.max(i, r, s), a = Math.min(i, r, s), o, l, h = (a + n) / 2; if (a === n) (o = 0), (l = 0); else { let u = n - a; switch (((l = h <= 0.5 ? u / (n + a) : u / (2 - n - a)), n)) { case i: o = (r - s) / u + (r < s ? 6 : 0); break; case r: o = (s - i) / u + 2; break; case s: o = (i - r) / u + 4; break; } o /= 6; } return (e.h = o), (e.s = l), (e.l = h), e; } getRGB(e, t = Ci.workingColorSpace) { return Ci.fromWorkingColorSpace(qh(this, Jt), t), (e.r = Jt.r), (e.g = Jt.g), (e.b = Jt.b), e; } getStyle(e = rs) { return ( Ci.fromWorkingColorSpace(qh(this, Jt), e), e !== rs ? `color(${e} ${Jt.r} ${Jt.g} ${Jt.b})` : `rgb(${(Jt.r * 255) | 0},${(Jt.g * 255) | 0},${(Jt.b * 255) | 0})` ); } offsetHSL(e, t, i) { return this.getHSL(Dr), (Dr.h += e), (Dr.s += t), (Dr.l += i), this.setHSL(Dr.h, Dr.s, Dr.l), this; } add(e) { return (this.r += e.r), (this.g += e.g), (this.b += e.b), this; } addColors(e, t) { return (this.r = e.r + t.r), (this.g = e.g + t.g), (this.b = e.b + t.b), this; } addScalar(e) { return (this.r += e), (this.g += e), (this.b += e), this; } sub(e) { return (this.r = Math.max(0, this.r - e.r)), (this.g = Math.max(0, this.g - e.g)), (this.b = Math.max(0, this.b - e.b)), this; } multiply(e) { return (this.r *= e.r), (this.g *= e.g), (this.b *= e.b), this; } multiplyScalar(e) { return (this.r *= e), (this.g *= e), (this.b *= e), this; } lerp(e, t) { return (this.r += (e.r - this.r) * t), (this.g += (e.g - this.g) * t), (this.b += (e.b - this.b) * t), this; } lerpColors(e, t, i) { return (this.r = e.r + (t.r - e.r) * i), (this.g = e.g + (t.g - e.g) * i), (this.b = e.b + (t.b - e.b) * i), this; } lerpHSL(e, t) { this.getHSL(Dr), e.getHSL(Xh); let i = Zl(Dr.h, Xh.h, t), r = Zl(Dr.s, Xh.s, t), s = Zl(Dr.l, Xh.l, t); return this.setHSL(i, r, s), this; } equals(e) { return e.r === this.r && e.g === this.g && e.b === this.b; } fromArray(e, t = 0) { return (this.r = e[t]), (this.g = e[t + 1]), (this.b = e[t + 2]), this; } toArray(e = [], t = 0) { return (e[t] = this.r), (e[t + 1] = this.g), (e[t + 2] = this.b), e; } fromBufferAttribute(e, t) { return (this.r = e.getX(t)), (this.g = e.getY(t)), (this.b = e.getZ(t)), this; } toJSON() { return this.getHex(); } *[Symbol.iterator]() { yield this.r, yield this.g, yield this.b; } }; Ge.NAMES = uw; var Ra, pw = class { static getDataURL(e) { if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > 'u') return e.src; let t; if (e instanceof HTMLCanvasElement) t = e; else { Ra === void 0 && (Ra = md('canvas')), (Ra.width = e.width), (Ra.height = e.height); let i = Ra.getContext('2d'); e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), (t = Ra); } return t.width > 2048 || t.height > 2048 ? (console.warn('THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', e), t.toDataURL('image/jpeg', 0.6)) : t.toDataURL('image/png'); } static sRGBToLinear(e) { if ( (typeof HTMLImageElement < 'u' && e instanceof HTMLImageElement) || (typeof HTMLCanvasElement < 'u' && e instanceof HTMLCanvasElement) || (typeof ImageBitmap < 'u' && e instanceof ImageBitmap) ) { let t = md('canvas'); (t.width = e.width), (t.height = e.height); let i = t.getContext('2d'); i.drawImage(e, 0, 0, e.width, e.height); let r = i.getImageData(0, 0, e.width, e.height), s = r.data; for (let n = 0; n < s.length; n++) s[n] = ua(s[n] / 255) * 255; return i.putImageData(r, 0, 0), t; } else if (e.data) { let t = e.data.slice(0); for (let i = 0; i < t.length; i++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? (t[i] = Math.floor(ua(t[i] / 255) * 255)) : (t[i] = ua(t[i])); return { data: t, width: e.width, height: e.height }; } else return console.warn('THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.'), e; } }, fw = class { constructor(e = null) { (this.isSource = !0), (this.uuid = ps()), (this.data = e), (this.version = 0); } set needsUpdate(e) { e === !0 && this.version++; } toJSON(e) { let t = e === void 0 || typeof e == 'string'; if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid]; let i = { uuid: this.uuid, url: '' }, r = this.data; if (r !== null) { let s; if (Array.isArray(r)) { s = []; for (let n = 0, a = r.length; n < a; n++) r[n].isDataTexture ? s.push(ip(r[n].image)) : s.push(ip(r[n])); } else s = ip(r); i.url = s; } return t || (e.images[this.uuid] = i), i; } }; function ip(e) { return (typeof HTMLImageElement < 'u' && e instanceof HTMLImageElement) || (typeof HTMLCanvasElement < 'u' && e instanceof HTMLCanvasElement) || (typeof ImageBitmap < 'u' && e instanceof ImageBitmap) ? pw.getDataURL(e) : e.data ? { data: Array.from(e.data), width: e.width, height: e.height, type: e.data.constructor.name } : (console.warn('THREE.Texture: Unable to serialize Texture.'), {}); } var iE = 0, ci = class extends Vi { constructor( e = ci.DEFAULT_IMAGE, t = ci.DEFAULT_MAPPING, i = Ji, r = Ji, s = mt, n = Bo, a = Ur, o = Mi, l = ci.DEFAULT_ANISOTROPY, h = gs ) { super(), (this.isTexture = !0), Object.defineProperty(this, 'id', { value: iE++ }), (this.uuid = ps()), (this.name = ''), (this.source = new fw(e)), (this.mipmaps = []), (this.mapping = t), (this.wrapS = i), (this.wrapT = r), (this.magFilter = s), (this.minFilter = n), (this.anisotropy = l), (this.format = a), (this.internalFormat = null), (this.type = o), (this.offset = new G(0, 0)), (this.repeat = new G(1, 1)), (this.center = new G(0, 0)), (this.rotation = 0), (this.matrixAutoUpdate = !0), (this.matrix = new Ai()), (this.generateMipmaps = !0), (this.premultiplyAlpha = !1), (this.flipY = !0), (this.unpackAlignment = 4), (this.encoding = h), (this.userData = {}), (this.version = 0), (this.onUpdate = null), (this.isRenderTargetTexture = !1), (this.needsPMREMUpdate = !1); } get image() { return this.source.data; } set image(e) { this.source.data = e; } updateMatrix() { this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); } clone() { return new this.constructor().copy(this); } copy(e) { return ( (this.name = e.name), (this.source = e.source), (this.mipmaps = e.mipmaps.slice(0)), (this.mapping = e.mapping), (this.wrapS = e.wrapS), (this.wrapT = e.wrapT), (this.magFilter = e.magFilter), (this.minFilter = e.minFilter), (this.anisotropy = e.anisotropy), (this.format = e.format), (this.internalFormat = e.internalFormat), (this.type = e.type), this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), (this.rotation = e.rotation), (this.matrixAutoUpdate = e.matrixAutoUpdate), this.matrix.copy(e.matrix), (this.generateMipmaps = e.generateMipmaps), (this.premultiplyAlpha = e.premultiplyAlpha), (this.flipY = e.flipY), (this.unpackAlignment = e.unpackAlignment), (this.encoding = e.encoding), (this.userData = JSON.parse(JSON.stringify(e.userData))), (this.needsUpdate = !0), this ); } toJSON(e) { let t = e === void 0 || typeof e == 'string'; if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; let i = { metadata: { version: 4.5, type: 'Texture', generator: 'Texture.toJSON' }, uuid: this.uuid, name: this.name, image: this.source.toJSON(e).uuid, mapping: this.mapping, repeat: [this.repeat.x, this.repeat.y], offset: [this.offset.x, this.offset.y], center: [this.center.x, this.center.y], rotation: this.rotation, wrap: [this.wrapS, this.wrapT], format: this.format, type: this.type, encoding: this.encoding, minFilter: this.minFilter, magFilter: this.magFilter, anisotropy: this.anisotropy, flipY: this.flipY, generateMipmaps: this.generateMipmaps, premultiplyAlpha: this.premultiplyAlpha, unpackAlignment: this.unpackAlignment }; return Object.keys(this.userData).length > 0 && (i.userData = this.userData), t || (e.textures[this.uuid] = i), i; } dispose() { this.dispatchEvent({ type: 'dispose' }); } transformUv(e) { if (this.mapping !== lw) return e; if ((e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)) switch (this.wrapS) { case oh: e.x = e.x - Math.floor(e.x); break; case Ji: e.x = e.x < 0 ? 0 : 1; break; case Uf: Math.abs(Math.floor(e.x) % 2) === 1 ? (e.x = Math.ceil(e.x) - e.x) : (e.x = e.x - Math.floor(e.x)); break; } if (e.y < 0 || e.y > 1) switch (this.wrapT) { case oh: e.y = e.y - Math.floor(e.y); break; case Ji: e.y = e.y < 0 ? 0 : 1; break; case Uf: Math.abs(Math.floor(e.y) % 2) === 1 ? (e.y = Math.ceil(e.y) - e.y) : (e.y = e.y - Math.floor(e.y)); break; } return this.flipY && (e.y = 1 - e.y), e; } set needsUpdate(e) { e === !0 && (this.version++, (this.source.needsUpdate = !0)); } }; ci.DEFAULT_IMAGE = null; ci.DEFAULT_MAPPING = lw; ci.DEFAULT_ANISOTROPY = 1; var $e = class { constructor(e = 0, t = 0, i = 0, r = 1) { ($e.prototype.isVector4 = !0), (this.x = e), (this.y = t), (this.z = i), (this.w = r); } get width() { return this.z; } set width(e) { this.z = e; } get height() { return this.w; } set height(e) { this.w = e; } set(e, t, i, r) { return (this.x = e), (this.y = t), (this.z = i), (this.w = r), this; } setScalar(e) { return (this.x = e), (this.y = e), (this.z = e), (this.w = e), this; } setX(e) { return (this.x = e), this; } setY(e) { return (this.y = e), this; } setZ(e) { return (this.z = e), this; } setW(e) { return (this.w = e), this; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; case 2: this.z = t; break; case 3: this.w = t; break; default: throw new Error('index is out of range: ' + e); } return this; } getComponent(e) { switch (e) { 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: ' + e); } } clone() { return new this.constructor(this.x, this.y, this.z, this.w); } copy(e) { return (this.x = e.x), (this.y = e.y), (this.z = e.z), (this.w = e.w !== void 0 ? e.w : 1), this; } add(e) { return (this.x += e.x), (this.y += e.y), (this.z += e.z), (this.w += e.w), this; } addScalar(e) { return (this.x += e), (this.y += e), (this.z += e), (this.w += e), this; } addVectors(e, t) { return (this.x = e.x + t.x), (this.y = e.y + t.y), (this.z = e.z + t.z), (this.w = e.w + t.w), this; } addScaledVector(e, t) { return (this.x += e.x * t), (this.y += e.y * t), (this.z += e.z * t), (this.w += e.w * t), this; } sub(e) { return (this.x -= e.x), (this.y -= e.y), (this.z -= e.z), (this.w -= e.w), this; } subScalar(e) { return (this.x -= e), (this.y -= e), (this.z -= e), (this.w -= e), this; } subVectors(e, t) { return (this.x = e.x - t.x), (this.y = e.y - t.y), (this.z = e.z - t.z), (this.w = e.w - t.w), this; } multiply(e) { return (this.x *= e.x), (this.y *= e.y), (this.z *= e.z), (this.w *= e.w), this; } multiplyScalar(e) { return (this.x *= e), (this.y *= e), (this.z *= e), (this.w *= e), this; } applyMatrix4(e) { let t = this.x, i = this.y, r = this.z, s = this.w, n = e.elements; return ( (this.x = n[0] * t + n[4] * i + n[8] * r + n[12] * s), (this.y = n[1] * t + n[5] * i + n[9] * r + n[13] * s), (this.z = n[2] * t + n[6] * i + n[10] * r + n[14] * s), (this.w = n[3] * t + n[7] * i + n[11] * r + n[15] * s), this ); } divideScalar(e) { return this.multiplyScalar(1 / e); } setAxisAngleFromQuaternion(e) { this.w = 2 * Math.acos(e.w); let t = Math.sqrt(1 - e.w * e.w); return t < 1e-4 ? ((this.x = 1), (this.y = 0), (this.z = 0)) : ((this.x = e.x / t), (this.y = e.y / t), (this.z = e.z / t)), this; } setAxisAngleFromRotationMatrix(e) { let t, i, r, s, n = e.elements, a = n[0], o = n[4], l = n[8], h = n[1], u = n[5], c = n[9], d = n[2], p = n[6], f = n[10]; if (Math.abs(o - h) < 0.01 && Math.abs(l - d) < 0.01 && Math.abs(c - p) < 0.01) { if (Math.abs(o + h) < 0.1 && Math.abs(l + d) < 0.1 && Math.abs(c + p) < 0.1 && Math.abs(a + u + f - 3) < 0.1) return this.set(1, 0, 0, 0), this; t = Math.PI; let m = (a + 1) / 2, v = (u + 1) / 2, y = (f + 1) / 2, b = (o + h) / 4, x = (l + d) / 4, w = (c + p) / 4; return ( m > v && m > y ? m < 0.01 ? ((i = 0), (r = 0.707106781), (s = 0.707106781)) : ((i = Math.sqrt(m)), (r = b / i), (s = x / i)) : v > y ? v < 0.01 ? ((i = 0.707106781), (r = 0), (s = 0.707106781)) : ((r = Math.sqrt(v)), (i = b / r), (s = w / r)) : y < 0.01 ? ((i = 0.707106781), (r = 0.707106781), (s = 0)) : ((s = Math.sqrt(y)), (i = x / s), (r = w / s)), this.set(i, r, s, t), this ); } let g = Math.sqrt((p - c) * (p - c) + (l - d) * (l - d) + (h - o) * (h - o)); return ( Math.abs(g) < 0.001 && (g = 1), (this.x = (p - c) / g), (this.y = (l - d) / g), (this.z = (h - o) / g), (this.w = Math.acos((a + u + f - 1) / 2)), this ); } min(e) { return ( (this.x = Math.min(this.x, e.x)), (this.y = Math.min(this.y, e.y)), (this.z = Math.min(this.z, e.z)), (this.w = Math.min(this.w, e.w)), this ); } max(e) { return ( (this.x = Math.max(this.x, e.x)), (this.y = Math.max(this.y, e.y)), (this.z = Math.max(this.z, e.z)), (this.w = Math.max(this.w, e.w)), this ); } clamp(e, t) { return ( (this.x = Math.max(e.x, Math.min(t.x, this.x))), (this.y = Math.max(e.y, Math.min(t.y, this.y))), (this.z = Math.max(e.z, Math.min(t.z, this.z))), (this.w = Math.max(e.w, Math.min(t.w, this.w))), this ); } clampScalar(e, t) { return ( (this.x = Math.max(e, Math.min(t, this.x))), (this.y = Math.max(e, Math.min(t, this.y))), (this.z = Math.max(e, Math.min(t, this.z))), (this.w = Math.max(e, Math.min(t, this.w))), this ); } clampLength(e, t) { let i = this.length(); return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i))); } floor() { return ( (this.x = Math.floor(this.x)), (this.y = Math.floor(this.y)), (this.z = Math.floor(this.z)), (this.w = Math.floor(this.w)), this ); } ceil() { return (this.x = Math.ceil(this.x)), (this.y = Math.ceil(this.y)), (this.z = Math.ceil(this.z)), (this.w = Math.ceil(this.w)), this; } round() { return ( (this.x = Math.round(this.x)), (this.y = Math.round(this.y)), (this.z = Math.round(this.z)), (this.w = Math.round(this.w)), this ); } roundToZero() { return ( (this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)), (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)), (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z)), (this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w)), this ); } negate() { return (this.x = -this.x), (this.y = -this.y), (this.z = -this.z), (this.w = -this.w), this; } dot(e) { return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; } lengthSq() { return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; } length() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } manhattanLength() { return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); } normalize() { return this.divideScalar(this.length() || 1); } setLength(e) { return this.normalize().multiplyScalar(e); } lerp(e, t) { return ( (this.x += (e.x - this.x) * t), (this.y += (e.y - this.y) * t), (this.z += (e.z - this.z) * t), (this.w += (e.w - this.w) * t), this ); } lerpVectors(e, t, i) { return ( (this.x = e.x + (t.x - e.x) * i), (this.y = e.y + (t.y - e.y) * i), (this.z = e.z + (t.z - e.z) * i), (this.w = e.w + (t.w - e.w) * i), this ); } equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; } fromArray(e, t = 0) { return (this.x = e[t]), (this.y = e[t + 1]), (this.z = e[t + 2]), (this.w = e[t + 3]), this; } toArray(e = [], t = 0) { return (e[t] = this.x), (e[t + 1] = this.y), (e[t + 2] = this.z), (e[t + 3] = this.w), e; } fromBufferAttribute(e, t) { return (this.x = e.getX(t)), (this.y = e.getY(t)), (this.z = e.getZ(t)), (this.w = e.getW(t)), this; } random() { return (this.x = Math.random()), (this.y = Math.random()), (this.z = Math.random()), (this.w = Math.random()), this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z, yield this.w; } }, ii = class extends Vi { constructor(e = 1, t = 1, i = {}) { super(), (this.isWebGLRenderTarget = !0), (this.width = e), (this.height = t), (this.depth = 1), (this.scissor = new $e(0, 0, e, t)), (this.scissorTest = !1), (this.viewport = new $e(0, 0, e, t)); let r = { width: e, height: t, depth: 1 }; (this.texture = new ci(r, i.mapping, i.wrapS, i.wrapT, i.magFilter, i.minFilter, i.format, i.type, i.anisotropy, i.encoding)), (this.texture.isRenderTargetTexture = !0), (this.texture.flipY = !1), (this.texture.generateMipmaps = i.generateMipmaps !== void 0 ? i.generateMipmaps : !1), (this.texture.internalFormat = i.internalFormat !== void 0 ? i.internalFormat : null), (this.texture.minFilter = i.minFilter !== void 0 ? i.minFilter : mt), (this.depthBuffer = i.depthBuffer !== void 0 ? i.depthBuffer : !0), (this.stencilBuffer = i.stencilBuffer !== void 0 ? i.stencilBuffer : !1), (this.depthTexture = i.depthTexture !== void 0 ? i.depthTexture : null), (this.samples = i.samples !== void 0 ? i.samples : 0); } setSize(e, t, i = 1) { (this.width !== e || this.height !== t || this.depth !== i) && ((this.width = e), (this.height = t), (this.depth = i), (this.texture.image.width = e), (this.texture.image.height = t), (this.texture.image.depth = i), this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); } clone() { return new this.constructor().copy(this); } copy(e) { (this.width = e.width), (this.height = e.height), (this.depth = e.depth), this.viewport.copy(e.viewport), (this.texture = e.texture.clone()), (this.texture.isRenderTargetTexture = !0); let t = Object.assign({}, e.texture.image); return ( (this.texture.source = new fw(t)), (this.depthBuffer = e.depthBuffer), (this.stencilBuffer = e.stencilBuffer), e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), (this.samples = e.samples), this ); } dispose() { this.dispatchEvent({ type: 'dispose' }); } }, mw = class extends ci { constructor(e = null, t = 1, i = 1, r = 1) { super(null), (this.isDataArrayTexture = !0), (this.image = { data: e, width: t, height: i, depth: r }), (this.magFilter = Ot), (this.minFilter = Ot), (this.wrapR = Ji), (this.generateMipmaps = !1), (this.flipY = !1), (this.unpackAlignment = 1); } }, rE = class extends ci { constructor(e = null, t = 1, i = 1, r = 1) { super(null), (this.isData3DTexture = !0), (this.image = { data: e, width: t, height: i, depth: r }), (this.magFilter = Ot), (this.minFilter = Ot), (this.wrapR = Ji), (this.generateMipmaps = !1), (this.flipY = !1), (this.unpackAlignment = 1); } }, ct = class { constructor(e = 0, t = 0, i = 0, r = 1) { (this.isQuaternion = !0), (this._x = e), (this._y = t), (this._z = i), (this._w = r); } static slerpFlat(e, t, i, r, s, n, a) { let o = i[r + 0], l = i[r + 1], h = i[r + 2], u = i[r + 3], c = s[n + 0], d = s[n + 1], p = s[n + 2], f = s[n + 3]; if (a === 0) { (e[t + 0] = o), (e[t + 1] = l), (e[t + 2] = h), (e[t + 3] = u); return; } if (a === 1) { (e[t + 0] = c), (e[t + 1] = d), (e[t + 2] = p), (e[t + 3] = f); return; } if (u !== f || o !== c || l !== d || h !== p) { let g = 1 - a, m = o * c + l * d + h * p + u * f, v = m >= 0 ? 1 : -1, y = 1 - m * m; if (y > Number.EPSILON) { let x = Math.sqrt(y), w = Math.atan2(x, m * v); (g = Math.sin(g * w) / x), (a = Math.sin(a * w) / x); } let b = a * v; if (((o = o * g + c * b), (l = l * g + d * b), (h = h * g + p * b), (u = u * g + f * b), g === 1 - a)) { let x = 1 / Math.sqrt(o * o + l * l + h * h + u * u); (o *= x), (l *= x), (h *= x), (u *= x); } } (e[t] = o), (e[t + 1] = l), (e[t + 2] = h), (e[t + 3] = u); } static multiplyQuaternionsFlat(e, t, i, r, s, n) { let a = i[r], o = i[r + 1], l = i[r + 2], h = i[r + 3], u = s[n], c = s[n + 1], d = s[n + 2], p = s[n + 3]; return ( (e[t] = a * p + h * u + o * d - l * c), (e[t + 1] = o * p + h * c + l * u - a * d), (e[t + 2] = l * p + h * d + a * c - o * u), (e[t + 3] = h * p - a * u - o * c - l * d), e ); } get x() { return this._x; } set x(e) { (this._x = e), this._onChangeCallback(); } get y() { return this._y; } set y(e) { (this._y = e), this._onChangeCallback(); } get z() { return this._z; } set z(e) { (this._z = e), this._onChangeCallback(); } get w() { return this._w; } set w(e) { (this._w = e), this._onChangeCallback(); } set(e, t, i, r) { return (this._x = e), (this._y = t), (this._z = i), (this._w = r), this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._w); } copy(e) { return (this._x = e.x), (this._y = e.y), (this._z = e.z), (this._w = e.w), this._onChangeCallback(), this; } setFromEuler(e, t) { let i = e._x, r = e._y, s = e._z, n = e._order, a = Math.cos, o = Math.sin, l = a(i / 2), h = a(r / 2), u = a(s / 2), c = o(i / 2), d = o(r / 2), p = o(s / 2); switch (n) { case 'XYZ': (this._x = c * h * u + l * d * p), (this._y = l * d * u - c * h * p), (this._z = l * h * p + c * d * u), (this._w = l * h * u - c * d * p); break; case 'YXZ': (this._x = c * h * u + l * d * p), (this._y = l * d * u - c * h * p), (this._z = l * h * p - c * d * u), (this._w = l * h * u + c * d * p); break; case 'ZXY': (this._x = c * h * u - l * d * p), (this._y = l * d * u + c * h * p), (this._z = l * h * p + c * d * u), (this._w = l * h * u - c * d * p); break; case 'ZYX': (this._x = c * h * u - l * d * p), (this._y = l * d * u + c * h * p), (this._z = l * h * p - c * d * u), (this._w = l * h * u + c * d * p); break; case 'YZX': (this._x = c * h * u + l * d * p), (this._y = l * d * u + c * h * p), (this._z = l * h * p - c * d * u), (this._w = l * h * u - c * d * p); break; case 'XZY': (this._x = c * h * u - l * d * p), (this._y = l * d * u - c * h * p), (this._z = l * h * p + c * d * u), (this._w = l * h * u + c * d * p); break; default: console.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + n); } return t !== !1 && this._onChangeCallback(), this; } setFromAxisAngle(e, t) { let i = t / 2, r = Math.sin(i); return (this._x = e.x * r), (this._y = e.y * r), (this._z = e.z * r), (this._w = Math.cos(i)), this._onChangeCallback(), this; } setFromRotationMatrix(e) { let t = e.elements, i = t[0], r = t[4], s = t[8], n = t[1], a = t[5], o = t[9], l = t[2], h = t[6], u = t[10], c = i + a + u; if (c > 0) { let d = 0.5 / Math.sqrt(c + 1); (this._w = 0.25 / d), (this._x = (h - o) * d), (this._y = (s - l) * d), (this._z = (n - r) * d); } else if (i > a && i > u) { let d = 2 * Math.sqrt(1 + i - a - u); (this._w = (h - o) / d), (this._x = 0.25 * d), (this._y = (r + n) / d), (this._z = (s + l) / d); } else if (a > u) { let d = 2 * Math.sqrt(1 + a - i - u); (this._w = (s - l) / d), (this._x = (r + n) / d), (this._y = 0.25 * d), (this._z = (o + h) / d); } else { let d = 2 * Math.sqrt(1 + u - i - a); (this._w = (n - r) / d), (this._x = (s + l) / d), (this._y = (o + h) / d), (this._z = 0.25 * d); } return this._onChangeCallback(), this; } setFromUnitVectors(e, t) { let i = e.dot(t) + 1; return ( i < Number.EPSILON ? ((i = 0), Math.abs(e.x) > Math.abs(e.z) ? ((this._x = -e.y), (this._y = e.x), (this._z = 0), (this._w = i)) : ((this._x = 0), (this._y = -e.z), (this._z = e.y), (this._w = i))) : ((this._x = e.y * t.z - e.z * t.y), (this._y = e.z * t.x - e.x * t.z), (this._z = e.x * t.y - e.y * t.x), (this._w = i)), this.normalize() ); } angleTo(e) { return 2 * Math.acos(Math.abs(ti(this.dot(e), -1, 1))); } rotateTowards(e, t) { let i = this.angleTo(e); if (i === 0) return this; let r = Math.min(1, t / i); return this.slerp(e, r), 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(e) { return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._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 e = this.length(); return ( e === 0 ? ((this._x = 0), (this._y = 0), (this._z = 0), (this._w = 1)) : ((e = 1 / e), (this._x = this._x * e), (this._y = this._y * e), (this._z = this._z * e), (this._w = this._w * e)), this._onChangeCallback(), this ); } multiply(e) { return this.multiplyQuaternions(this, e); } premultiply(e) { return this.multiplyQuaternions(e, this); } multiplyQuaternions(e, t) { let i = e._x, r = e._y, s = e._z, n = e._w, a = t._x, o = t._y, l = t._z, h = t._w; return ( (this._x = i * h + n * a + r * l - s * o), (this._y = r * h + n * o + s * a - i * l), (this._z = s * h + n * l + i * o - r * a), (this._w = n * h - i * a - r * o - s * l), this._onChangeCallback(), this ); } slerp(e, t) { if (t === 0) return this; if (t === 1) return this.copy(e); let i = this._x, r = this._y, s = this._z, n = this._w, a = n * e._w + i * e._x + r * e._y + s * e._z; if ((a < 0 ? ((this._w = -e._w), (this._x = -e._x), (this._y = -e._y), (this._z = -e._z), (a = -a)) : this.copy(e), a >= 1)) return (this._w = n), (this._x = i), (this._y = r), (this._z = s), this; let o = 1 - a * a; if (o <= Number.EPSILON) { let d = 1 - t; return ( (this._w = d * n + t * this._w), (this._x = d * i + t * this._x), (this._y = d * r + t * this._y), (this._z = d * s + t * this._z), this.normalize(), this._onChangeCallback(), this ); } let l = Math.sqrt(o), h = Math.atan2(l, a), u = Math.sin((1 - t) * h) / l, c = Math.sin(t * h) / l; return ( (this._w = n * u + this._w * c), (this._x = i * u + this._x * c), (this._y = r * u + this._y * c), (this._z = s * u + this._z * c), this._onChangeCallback(), this ); } slerpQuaternions(e, t, i) { return this.copy(e).slerp(t, i); } random() { let e = Math.random(), t = Math.sqrt(1 - e), i = Math.sqrt(e), r = 2 * Math.PI * Math.random(), s = 2 * Math.PI * Math.random(); return this.set(t * Math.cos(r), i * Math.sin(s), i * Math.cos(s), t * Math.sin(r)); } equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; } fromArray(e, t = 0) { return (this._x = e[t]), (this._y = e[t + 1]), (this._z = e[t + 2]), (this._w = e[t + 3]), this._onChangeCallback(), this; } toArray(e = [], t = 0) { return (e[t] = this._x), (e[t + 1] = this._y), (e[t + 2] = this._z), (e[t + 3] = this._w), e; } fromBufferAttribute(e, t) { return (this._x = e.getX(t)), (this._y = e.getY(t)), (this._z = e.getZ(t)), (this._w = e.getW(t)), this; } _onChange(e) { return (this._onChangeCallback = e), this; } _onChangeCallback() {} *[Symbol.iterator]() { yield this._x, yield this._y, yield this._z, yield this._w; } }, E = class { constructor(e = 0, t = 0, i = 0) { (E.prototype.isVector3 = !0), (this.x = e), (this.y = t), (this.z = i); } set(e, t, i) { return i === void 0 && (i = this.z), (this.x = e), (this.y = t), (this.z = i), this; } setScalar(e) { return (this.x = e), (this.y = e), (this.z = e), this; } setX(e) { return (this.x = e), this; } setY(e) { return (this.y = e), this; } setZ(e) { return (this.z = e), this; } setComponent(e, t) { switch (e) { case 0: this.x = t; break; case 1: this.y = t; break; case 2: this.z = t; break; default: throw new Error('index is out of range: ' + e); } return this; } getComponent(e) { switch (e) { case 0: return this.x; case 1: return this.y; case 2: return this.z; default: throw new Error('index is out of range: ' + e); } } clone() { return new this.constructor(this.x, this.y, this.z); } copy(e) { return (this.x = e.x), (this.y = e.y), (this.z = e.z), this; } add(e) { return (this.x += e.x), (this.y += e.y), (this.z += e.z), this; } addScalar(e) { return (this.x += e), (this.y += e), (this.z += e), this; } addVectors(e, t) { return (this.x = e.x + t.x), (this.y = e.y + t.y), (this.z = e.z + t.z), this; } addScaledVector(e, t) { return (this.x += e.x * t), (this.y += e.y * t), (this.z += e.z * t), this; } sub(e) { return (this.x -= e.x), (this.y -= e.y), (this.z -= e.z), this; } subScalar(e) { return (this.x -= e), (this.y -= e), (this.z -= e), this; } subVectors(e, t) { return (this.x = e.x - t.x), (this.y = e.y - t.y), (this.z = e.z - t.z), this; } multiply(e) { return (this.x *= e.x), (this.y *= e.y), (this.z *= e.z), this; } multiplyScalar(e) { return (this.x *= e), (this.y *= e), (this.z *= e), this; } multiplyVectors(e, t) { return (this.x = e.x * t.x), (this.y = e.y * t.y), (this.z = e.z * t.z), this; } applyEuler(e) { return this.applyQuaternion(I0.setFromEuler(e)); } applyAxisAngle(e, t) { return this.applyQuaternion(I0.setFromAxisAngle(e, t)); } applyMatrix3(e) { let t = this.x, i = this.y, r = this.z, s = e.elements; return ( (this.x = s[0] * t + s[3] * i + s[6] * r), (this.y = s[1] * t + s[4] * i + s[7] * r), (this.z = s[2] * t + s[5] * i + s[8] * r), this ); } applyNormalMatrix(e) { return this.applyMatrix3(e).normalize(); } applyMatrix4(e) { let t = this.x, i = this.y, r = this.z, s = e.elements, n = 1 / (s[3] * t + s[7] * i + s[11] * r + s[15]); return ( (this.x = (s[0] * t + s[4] * i + s[8] * r + s[12]) * n), (this.y = (s[1] * t + s[5] * i + s[9] * r + s[13]) * n), (this.z = (s[2] * t + s[6] * i + s[10] * r + s[14]) * n), this ); } applyQuaternion(e) { let t = this.x, i = this.y, r = this.z, s = e.x, n = e.y, a = e.z, o = e.w, l = o * t + n * r - a * i, h = o * i + a * t - s * r, u = o * r + s * i - n * t, c = -s * t - n * i - a * r; return ( (this.x = l * o + c * -s + h * -a - u * -n), (this.y = h * o + c * -n + u * -s - l * -a), (this.z = u * o + c * -a + l * -n - h * -s), this ); } project(e) { return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); } unproject(e) { return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); } transformDirection(e) { let t = this.x, i = this.y, r = this.z, s = e.elements; return ( (this.x = s[0] * t + s[4] * i + s[8] * r), (this.y = s[1] * t + s[5] * i + s[9] * r), (this.z = s[2] * t + s[6] * i + s[10] * r), this.normalize() ); } divide(e) { return (this.x /= e.x), (this.y /= e.y), (this.z /= e.z), this; } divideScalar(e) { return this.multiplyScalar(1 / e); } min(e) { return (this.x = Math.min(this.x, e.x)), (this.y = Math.min(this.y, e.y)), (this.z = Math.min(this.z, e.z)), this; } max(e) { return (this.x = Math.max(this.x, e.x)), (this.y = Math.max(this.y, e.y)), (this.z = Math.max(this.z, e.z)), this; } clamp(e, t) { return ( (this.x = Math.max(e.x, Math.min(t.x, this.x))), (this.y = Math.max(e.y, Math.min(t.y, this.y))), (this.z = Math.max(e.z, Math.min(t.z, this.z))), this ); } clampScalar(e, t) { return ( (this.x = Math.max(e, Math.min(t, this.x))), (this.y = Math.max(e, Math.min(t, this.y))), (this.z = Math.max(e, Math.min(t, this.z))), this ); } clampLength(e, t) { let i = this.length(); return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i))); } floor() { return (this.x = Math.floor(this.x)), (this.y = Math.floor(this.y)), (this.z = Math.floor(this.z)), this; } ceil() { return (this.x = Math.ceil(this.x)), (this.y = Math.ceil(this.y)), (this.z = Math.ceil(this.z)), this; } round() { return (this.x = Math.round(this.x)), (this.y = Math.round(this.y)), (this.z = Math.round(this.z)), this; } roundToZero() { return ( (this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)), (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)), (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z)), this ); } negate() { return (this.x = -this.x), (this.y = -this.y), (this.z = -this.z), this; } dot(e) { return this.x * e.x + this.y * e.y + this.z * e.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(e) { return this.normalize().multiplyScalar(e); } lerp(e, t) { return (this.x += (e.x - this.x) * t), (this.y += (e.y - this.y) * t), (this.z += (e.z - this.z) * t), this; } lerpVectors(e, t, i) { return (this.x = e.x + (t.x - e.x) * i), (this.y = e.y + (t.y - e.y) * i), (this.z = e.z + (t.z - e.z) * i), this; } cross(e) { return this.crossVectors(this, e); } crossVectors(e, t) { let i = e.x, r = e.y, s = e.z, n = t.x, a = t.y, o = t.z; return (this.x = r * o - s * a), (this.y = s * n - i * o), (this.z = i * a - r * n), this; } projectOnVector(e) { let t = e.lengthSq(); if (t === 0) return this.set(0, 0, 0); let i = e.dot(this) / t; return this.copy(e).multiplyScalar(i); } projectOnPlane(e) { return rp.copy(this).projectOnVector(e), this.sub(rp); } reflect(e) { return this.sub(rp.copy(e).multiplyScalar(2 * this.dot(e))); } angleTo(e) { let t = Math.sqrt(this.lengthSq() * e.lengthSq()); if (t === 0) return Math.PI / 2; let i = this.dot(e) / t; return Math.acos(ti(i, -1, 1)); } distanceTo(e) { return Math.sqrt(this.distanceToSquared(e)); } distanceToSquared(e) { let t = this.x - e.x, i = this.y - e.y, r = this.z - e.z; return t * t + i * i + r * r; } manhattanDistanceTo(e) { return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); } setFromSpherical(e) { return this.setFromSphericalCoords(e.radius, e.phi, e.theta); } setFromSphericalCoords(e, t, i) { let r = Math.sin(t) * e; return (this.x = r * Math.sin(i)), (this.y = Math.cos(t) * e), (this.z = r * Math.cos(i)), this; } setFromCylindrical(e) { return this.setFromCylindricalCoords(e.radius, e.theta, e.y); } setFromCylindricalCoords(e, t, i) { return (this.x = e * Math.sin(t)), (this.y = i), (this.z = e * Math.cos(t)), this; } setFromMatrixPosition(e) { let t = e.elements; return (this.x = t[12]), (this.y = t[13]), (this.z = t[14]), this; } setFromMatrixScale(e) { let t = this.setFromMatrixColumn(e, 0).length(), i = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length(); return (this.x = t), (this.y = i), (this.z = r), this; } setFromMatrixColumn(e, t) { return this.fromArray(e.elements, t * 4); } setFromMatrix3Column(e, t) { return this.fromArray(e.elements, t * 3); } setFromEuler(e) { return (this.x = e._x), (this.y = e._y), (this.z = e._z), this; } equals(e) { return e.x === this.x && e.y === this.y && e.z === this.z; } fromArray(e, t = 0) { return (this.x = e[t]), (this.y = e[t + 1]), (this.z = e[t + 2]), this; } toArray(e = [], t = 0) { return (e[t] = this.x), (e[t + 1] = this.y), (e[t + 2] = this.z), e; } fromBufferAttribute(e, t) { return (this.x = e.getX(t)), (this.y = e.getY(t)), (this.z = e.getZ(t)), this; } random() { return (this.x = Math.random()), (this.y = Math.random()), (this.z = Math.random()), this; } randomDirection() { let e = (Math.random() - 0.5) * 2, t = Math.random() * Math.PI * 2, i = Math.sqrt(1 - e ** 2); return (this.x = i * Math.cos(t)), (this.y = i * Math.sin(t)), (this.z = e), this; } *[Symbol.iterator]() { yield this.x, yield this.y, yield this.z; } }, rp = new E(), I0 = new ct(), Kt = class { constructor(e = new E(1 / 0, 1 / 0, 1 / 0), t = new E(-1 / 0, -1 / 0, -1 / 0)) { (this.isBox3 = !0), (this.min = e), (this.max = t); } set(e, t) { return this.min.copy(e), this.max.copy(t), this; } setFromArray(e) { let t = 1 / 0, i = 1 / 0, r = 1 / 0, s = -1 / 0, n = -1 / 0, a = -1 / 0; for (let o = 0, l = e.length; o < l; o += 3) { let h = e[o], u = e[o + 1], c = e[o + 2]; h < t && (t = h), u < i && (i = u), c < r && (r = c), h > s && (s = h), u > n && (n = u), c > a && (a = c); } return this.min.set(t, i, r), this.max.set(s, n, a), this; } setFromBufferAttribute(e) { let t = 1 / 0, i = 1 / 0, r = 1 / 0, s = -1 / 0, n = -1 / 0, a = -1 / 0; for (let o = 0, l = e.count; o < l; o++) { let h = e.getX(o), u = e.getY(o), c = e.getZ(o); h < t && (t = h), u < i && (i = u), c < r && (r = c), h > s && (s = h), u > n && (n = u), c > a && (a = c); } return this.min.set(t, i, r), this.max.set(s, n, a), this; } setFromPoints(e) { this.makeEmpty(); for (let t = 0, i = e.length; t < i; t++) this.expandByPoint(e[t]); return this; } setFromCenterAndSize(e, t) { let i = Hn.copy(t).multiplyScalar(0.5); return this.min.copy(e).sub(i), this.max.copy(e).add(i), this; } setFromObject(e, t = !1) { return this.makeEmpty(), this.expandByObject(e, t); } clone() { return new this.constructor().copy(this); } copy(e) { return this.min.copy(e.min), this.max.copy(e.max), this; } makeEmpty() { return (this.min.x = this.min.y = this.min.z = 1 / 0), (this.max.x = this.max.y = this.max.z = -1 / 0), this; } isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; } getCenter(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5); } getSize(e) { return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); } expandByPoint(e) { return this.min.min(e), this.max.max(e), this; } expandByVector(e) { return this.min.sub(e), this.max.add(e), this; } expandByScalar(e) { return this.min.addScalar(-e), this.max.addScalar(e), this; } expandByObject(e, t = !1) { e.updateWorldMatrix(!1, !1); let i = e.geometry; if (i !== void 0) if (t && i.attributes != null && i.attributes.position !== void 0) { let s = i.attributes.position; for (let n = 0, a = s.count; n < a; n++) Hn.fromBufferAttribute(s, n).applyMatrix4(e.matrixWorld), this.expandByPoint(Hn); } else i.boundingBox === null && i.computeBoundingBox(), sp.copy(i.boundingBox), sp.applyMatrix4(e.matrixWorld), this.union(sp); let r = e.children; for (let s = 0, n = r.length; s < n; s++) this.expandByObject(r[s], t); return this; } containsPoint(e) { return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z); } containsBox(e) { return ( this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z ); } getParameter(e, t) { return t.set( (e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y), (e.z - this.min.z) / (this.max.z - this.min.z) ); } intersectsBox(e) { return !( e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z ); } intersectsSphere(e) { return this.clampPoint(e.center, Hn), Hn.distanceToSquared(e.center) <= e.radius * e.radius; } intersectsPlane(e) { let t, i; return ( e.normal.x > 0 ? ((t = e.normal.x * this.min.x), (i = e.normal.x * this.max.x)) : ((t = e.normal.x * this.max.x), (i = e.normal.x * this.min.x)), e.normal.y > 0 ? ((t += e.normal.y * this.min.y), (i += e.normal.y * this.max.y)) : ((t += e.normal.y * this.max.y), (i += e.normal.y * this.min.y)), e.normal.z > 0 ? ((t += e.normal.z * this.min.z), (i += e.normal.z * this.max.z)) : ((t += e.normal.z * this.max.z), (i += e.normal.z * this.min.z)), t <= -e.constant && i >= -e.constant ); } intersectsTriangle(e) { if (this.isEmpty()) return !1; this.getCenter(dl), Yh.subVectors(this.max, dl), Ba.subVectors(e.a, dl), za.subVectors(e.b, dl), Na.subVectors(e.c, dl), Ks.subVectors(za, Ba), Js.subVectors(Na, za), Wn.subVectors(Ba, Na); let t = [ 0, -Ks.z, Ks.y, 0, -Js.z, Js.y, 0, -Wn.z, Wn.y, Ks.z, 0, -Ks.x, Js.z, 0, -Js.x, Wn.z, 0, -Wn.x, -Ks.y, Ks.x, 0, -Js.y, Js.x, 0, -Wn.y, Wn.x, 0 ]; return !np(t, Ba, za, Na, Yh) || ((t = [1, 0, 0, 0, 1, 0, 0, 0, 1]), !np(t, Ba, za, Na, Yh)) ? !1 : (Qh.crossVectors(Ks, Js), (t = [Qh.x, Qh.y, Qh.z]), np(t, Ba, za, Na, Yh)); } clampPoint(e, t) { return t.copy(e).clamp(this.min, this.max); } distanceToPoint(e) { return Hn.copy(e).clamp(this.min, this.max).sub(e).length(); } getBoundingSphere(e) { return this.getCenter(e.center), (e.radius = this.getSize(Hn).length() * 0.5), e; } intersect(e) { return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; } union(e) { return this.min.min(e.min), this.max.max(e.max), this; } applyMatrix4(e) { return this.isEmpty() ? this : (Cs[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), Cs[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), Cs[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), Cs[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), Cs[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), Cs[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), Cs[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), Cs[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(Cs), this); } translate(e) { return this.min.add(e), this.max.add(e), this; } equals(e) { return e.min.equals(this.min) && e.max.equals(this.max); } }, Cs = [new E(), new E(), new E(), new E(), new E(), new E(), new E(), new E()], Hn = new E(), sp = new Kt(), Ba = new E(), za = new E(), Na = new E(), Ks = new E(), Js = new E(), Wn = new E(), dl = new E(), Yh = new E(), Qh = new E(), Xn = new E(); function np(e, t, i, r, s) { for (let n = 0, a = e.length - 3; n <= a; n += 3) { Xn.fromArray(e, n); let o = s.x * Math.abs(Xn.x) + s.y * Math.abs(Xn.y) + s.z * Math.abs(Xn.z), l = t.dot(Xn), h = i.dot(Xn), u = r.dot(Xn); if (Math.max(-Math.max(l, h, u), Math.min(l, h, u)) > o) return !1; } return !0; } var sE = new Kt(), ul = new E(), ap = new E(), Mr = class { constructor(e = new E(), t = -1) { (this.center = e), (this.radius = t); } set(e, t) { return this.center.copy(e), (this.radius = t), this; } setFromPoints(e, t) { let i = this.center; t !== void 0 ? i.copy(t) : sE.setFromPoints(e).getCenter(i); let r = 0; for (let s = 0, n = e.length; s < n; s++) r = Math.max(r, i.distanceToSquared(e[s])); return (this.radius = Math.sqrt(r)), this; } copy(e) { return this.center.copy(e.center), (this.radius = e.radius), this; } isEmpty() { return this.radius < 0; } makeEmpty() { return this.center.set(0, 0, 0), (this.radius = -1), this; } containsPoint(e) { return e.distanceToSquared(this.center) <= this.radius * this.radius; } distanceToPoint(e) { return e.distanceTo(this.center) - this.radius; } intersectsSphere(e) { let t = this.radius + e.radius; return e.center.distanceToSquared(this.center) <= t * t; } intersectsBox(e) { return e.intersectsSphere(this); } intersectsPlane(e) { return Math.abs(e.distanceToPoint(this.center)) <= this.radius; } clampPoint(e, t) { let i = this.center.distanceToSquared(e); return ( t.copy(e), i > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t ); } getBoundingBox(e) { return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); } applyMatrix4(e) { return this.center.applyMatrix4(e), (this.radius = this.radius * e.getMaxScaleOnAxis()), this; } translate(e) { return this.center.add(e), this; } expandByPoint(e) { if (this.isEmpty()) return this.center.copy(e), (this.radius = 0), this; ul.subVectors(e, this.center); let t = ul.lengthSq(); if (t > this.radius * this.radius) { let i = Math.sqrt(t), r = (i - this.radius) * 0.5; this.center.addScaledVector(ul, r / i), (this.radius += r); } return this; } union(e) { return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? (this.radius = Math.max(this.radius, e.radius)) : (ap.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(ul.copy(e.center).add(ap)), this.expandByPoint(ul.copy(e.center).sub(ap))), this); } equals(e) { return e.center.equals(this.center) && e.radius === this.radius; } clone() { return new this.constructor().copy(this); } }, Ts = new E(), op = new E(), Zh = new E(), $s = new E(), lp = new E(), Kh = new E(), hp = new E(), Xo = class { constructor(e = new E(), t = new E(0, 0, -1)) { (this.origin = e), (this.direction = t); } set(e, t) { return this.origin.copy(e), this.direction.copy(t), this; } copy(e) { return this.origin.copy(e.origin), this.direction.copy(e.direction), this; } at(e, t) { return t.copy(this.direction).multiplyScalar(e).add(this.origin); } lookAt(e) { return this.direction.copy(e).sub(this.origin).normalize(), this; } recast(e) { return this.origin.copy(this.at(e, Ts)), this; } closestPointToPoint(e, t) { t.subVectors(e, this.origin); let i = t.dot(this.direction); return i < 0 ? t.copy(this.origin) : t.copy(this.direction).multiplyScalar(i).add(this.origin); } distanceToPoint(e) { return Math.sqrt(this.distanceSqToPoint(e)); } distanceSqToPoint(e) { let t = Ts.subVectors(e, this.origin).dot(this.direction); return t < 0 ? this.origin.distanceToSquared(e) : (Ts.copy(this.direction).multiplyScalar(t).add(this.origin), Ts.distanceToSquared(e)); } distanceSqToSegment(e, t, i, r) { op.copy(e).add(t).multiplyScalar(0.5), Zh.copy(t).sub(e).normalize(), $s.copy(this.origin).sub(op); let s = e.distanceTo(t) * 0.5, n = -this.direction.dot(Zh), a = $s.dot(this.direction), o = -$s.dot(Zh), l = $s.lengthSq(), h = Math.abs(1 - n * n), u, c, d, p; if (h > 0) if (((u = n * o - a), (c = n * a - o), (p = s * h), u >= 0)) if (c >= -p) if (c <= p) { let f = 1 / h; (u *= f), (c *= f), (d = u * (u + n * c + 2 * a) + c * (n * u + c + 2 * o) + l); } else (c = s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l); else (c = -s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l); else c <= -p ? ((u = Math.max(0, -(-n * s + a))), (c = u > 0 ? -s : Math.min(Math.max(-s, -o), s)), (d = -u * u + c * (c + 2 * o) + l)) : c <= p ? ((u = 0), (c = Math.min(Math.max(-s, -o), s)), (d = c * (c + 2 * o) + l)) : ((u = Math.max(0, -(n * s + a))), (c = u > 0 ? s : Math.min(Math.max(-s, -o), s)), (d = -u * u + c * (c + 2 * o) + l)); else (c = n > 0 ? -s : s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l); return i && i.copy(this.direction).multiplyScalar(u).add(this.origin), r && r.copy(Zh).multiplyScalar(c).add(op), d; } intersectSphere(e, t) { Ts.subVectors(e.center, this.origin); let i = Ts.dot(this.direction), r = Ts.dot(Ts) - i * i, s = e.radius * e.radius; if (r > s) return null; let n = Math.sqrt(s - r), a = i - n, o = i + n; return a < 0 && o < 0 ? null : a < 0 ? this.at(o, t) : this.at(a, t); } intersectsSphere(e) { return this.distanceSqToPoint(e.center) <= e.radius * e.radius; } distanceToPlane(e) { let t = e.normal.dot(this.direction); if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; let i = -(this.origin.dot(e.normal) + e.constant) / t; return i >= 0 ? i : null; } intersectPlane(e, t) { let i = this.distanceToPlane(e); return i === null ? null : this.at(i, t); } intersectsPlane(e) { let t = e.distanceToPoint(this.origin); return t === 0 || e.normal.dot(this.direction) * t < 0; } intersectBox(e, t) { let i, r, s, n, a, o, l = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, c = this.origin; return ( l >= 0 ? ((i = (e.min.x - c.x) * l), (r = (e.max.x - c.x) * l)) : ((i = (e.max.x - c.x) * l), (r = (e.min.x - c.x) * l)), h >= 0 ? ((s = (e.min.y - c.y) * h), (n = (e.max.y - c.y) * h)) : ((s = (e.max.y - c.y) * h), (n = (e.min.y - c.y) * h)), i > n || s > r || ((s > i || isNaN(i)) && (i = s), (n < r || isNaN(r)) && (r = n), u >= 0 ? ((a = (e.min.z - c.z) * u), (o = (e.max.z - c.z) * u)) : ((a = (e.max.z - c.z) * u), (o = (e.min.z - c.z) * u)), i > o || a > r) || ((a > i || i !== i) && (i = a), (o < r || r !== r) && (r = o), r < 0) ? null : this.at(i >= 0 ? i : r, t) ); } intersectsBox(e) { return this.intersectBox(e, Ts) !== null; } intersectTriangle(e, t, i, r, s) { lp.subVectors(t, e), Kh.subVectors(i, e), hp.crossVectors(lp, Kh); let n = this.direction.dot(hp), a; if (n > 0) { if (r) return null; a = 1; } else if (n < 0) (a = -1), (n = -n); else return null; $s.subVectors(this.origin, e); let o = a * this.direction.dot(Kh.crossVectors($s, Kh)); if (o < 0) return null; let l = a * this.direction.dot(lp.cross($s)); if (l < 0 || o + l > n) return null; let h = -a * $s.dot(hp); return h < 0 ? null : this.at(h / n, s); } applyMatrix4(e) { return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; } equals(e) { return e.origin.equals(this.origin) && e.direction.equals(this.direction); } clone() { return new this.constructor().copy(this); } }, ve = class { constructor() { (ve.prototype.isMatrix4 = !0), (this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); } set(e, t, i, r, s, n, a, o, l, h, u, c, d, p, f, g) { let m = this.elements; return ( (m[0] = e), (m[4] = t), (m[8] = i), (m[12] = r), (m[1] = s), (m[5] = n), (m[9] = a), (m[13] = o), (m[2] = l), (m[6] = h), (m[10] = u), (m[14] = c), (m[3] = d), (m[7] = p), (m[11] = f), (m[15] = g), this ); } identity() { return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; } clone() { return new ve().fromArray(this.elements); } copy(e) { let t = this.elements, i = e.elements; return ( (t[0] = i[0]), (t[1] = i[1]), (t[2] = i[2]), (t[3] = i[3]), (t[4] = i[4]), (t[5] = i[5]), (t[6] = i[6]), (t[7] = i[7]), (t[8] = i[8]), (t[9] = i[9]), (t[10] = i[10]), (t[11] = i[11]), (t[12] = i[12]), (t[13] = i[13]), (t[14] = i[14]), (t[15] = i[15]), this ); } copyPosition(e) { let t = this.elements, i = e.elements; return (t[12] = i[12]), (t[13] = i[13]), (t[14] = i[14]), this; } setFromMatrix3(e) { let t = e.elements; return this.set(t[0], t[3], t[6], 0, t[1], t[4], t[7], 0, t[2], t[5], t[8], 0, 0, 0, 0, 1), this; } extractBasis(e, t, i) { return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this; } makeBasis(e, t, i) { return this.set(e.x, t.x, i.x, 0, e.y, t.y, i.y, 0, e.z, t.z, i.z, 0, 0, 0, 0, 1), this; } extractRotation(e) { let t = this.elements, i = e.elements, r = 1 / Ua.setFromMatrixColumn(e, 0).length(), s = 1 / Ua.setFromMatrixColumn(e, 1).length(), n = 1 / Ua.setFromMatrixColumn(e, 2).length(); return ( (t[0] = i[0] * r), (t[1] = i[1] * r), (t[2] = i[2] * r), (t[3] = 0), (t[4] = i[4] * s), (t[5] = i[5] * s), (t[6] = i[6] * s), (t[7] = 0), (t[8] = i[8] * n), (t[9] = i[9] * n), (t[10] = i[10] * n), (t[11] = 0), (t[12] = 0), (t[13] = 0), (t[14] = 0), (t[15] = 1), this ); } makeRotationFromEuler(e) { let t = this.elements, i = e.x, r = e.y, s = e.z, n = Math.cos(i), a = Math.sin(i), o = Math.cos(r), l = Math.sin(r), h = Math.cos(s), u = Math.sin(s); if (e.order === 'XYZ') { let c = n * h, d = n * u, p = a * h, f = a * u; (t[0] = o * h), (t[4] = -o * u), (t[8] = l), (t[1] = d + p * l), (t[5] = c - f * l), (t[9] = -a * o), (t[2] = f - c * l), (t[6] = p + d * l), (t[10] = n * o); } else if (e.order === 'YXZ') { let c = o * h, d = o * u, p = l * h, f = l * u; (t[0] = c + f * a), (t[4] = p * a - d), (t[8] = n * l), (t[1] = n * u), (t[5] = n * h), (t[9] = -a), (t[2] = d * a - p), (t[6] = f + c * a), (t[10] = n * o); } else if (e.order === 'ZXY') { let c = o * h, d = o * u, p = l * h, f = l * u; (t[0] = c - f * a), (t[4] = -n * u), (t[8] = p + d * a), (t[1] = d + p * a), (t[5] = n * h), (t[9] = f - c * a), (t[2] = -n * l), (t[6] = a), (t[10] = n * o); } else if (e.order === 'ZYX') { let c = n * h, d = n * u, p = a * h, f = a * u; (t[0] = o * h), (t[4] = p * l - d), (t[8] = c * l + f), (t[1] = o * u), (t[5] = f * l + c), (t[9] = d * l - p), (t[2] = -l), (t[6] = a * o), (t[10] = n * o); } else if (e.order === 'YZX') { let c = n * o, d = n * l, p = a * o, f = a * l; (t[0] = o * h), (t[4] = f - c * u), (t[8] = p * u + d), (t[1] = u), (t[5] = n * h), (t[9] = -a * h), (t[2] = -l * h), (t[6] = d * u + p), (t[10] = c - f * u); } else if (e.order === 'XZY') { let c = n * o, d = n * l, p = a * o, f = a * l; (t[0] = o * h), (t[4] = -u), (t[8] = l * h), (t[1] = c * u + f), (t[5] = n * h), (t[9] = d * u - p), (t[2] = p * u - d), (t[6] = a * h), (t[10] = f * u + c); } return (t[3] = 0), (t[7] = 0), (t[11] = 0), (t[12] = 0), (t[13] = 0), (t[14] = 0), (t[15] = 1), this; } makeRotationFromQuaternion(e) { return this.compose(nE, e, aE); } lookAt(e, t, i) { let r = this.elements; return ( qi.subVectors(e, t), qi.lengthSq() === 0 && (qi.z = 1), qi.normalize(), en.crossVectors(i, qi), en.lengthSq() === 0 && (Math.abs(i.z) === 1 ? (qi.x += 1e-4) : (qi.z += 1e-4), qi.normalize(), en.crossVectors(i, qi)), en.normalize(), Jh.crossVectors(qi, en), (r[0] = en.x), (r[4] = Jh.x), (r[8] = qi.x), (r[1] = en.y), (r[5] = Jh.y), (r[9] = qi.y), (r[2] = en.z), (r[6] = Jh.z), (r[10] = qi.z), this ); } multiply(e) { return this.multiplyMatrices(this, e); } premultiply(e) { return this.multiplyMatrices(e, this); } multiplyMatrices(e, t) { let i = e.elements, r = t.elements, s = this.elements, n = i[0], a = i[4], o = i[8], l = i[12], h = i[1], u = i[5], c = i[9], d = i[13], p = i[2], f = i[6], g = i[10], m = i[14], v = i[3], y = i[7], b = i[11], x = i[15], w = r[0], A = r[4], S = r[8], _ = r[12], M = r[1], C = r[5], T = r[9], P = r[13], L = r[2], D = r[6], k = r[10], W = r[14], X = r[3], z = r[7], j = r[11], U = r[15]; return ( (s[0] = n * w + a * M + o * L + l * X), (s[4] = n * A + a * C + o * D + l * z), (s[8] = n * S + a * T + o * k + l * j), (s[12] = n * _ + a * P + o * W + l * U), (s[1] = h * w + u * M + c * L + d * X), (s[5] = h * A + u * C + c * D + d * z), (s[9] = h * S + u * T + c * k + d * j), (s[13] = h * _ + u * P + c * W + d * U), (s[2] = p * w + f * M + g * L + m * X), (s[6] = p * A + f * C + g * D + m * z), (s[10] = p * S + f * T + g * k + m * j), (s[14] = p * _ + f * P + g * W + m * U), (s[3] = v * w + y * M + b * L + x * X), (s[7] = v * A + y * C + b * D + x * z), (s[11] = v * S + y * T + b * k + x * j), (s[15] = v * _ + y * P + b * W + x * U), this ); } multiplyScalar(e) { let t = this.elements; return ( (t[0] *= e), (t[4] *= e), (t[8] *= e), (t[12] *= e), (t[1] *= e), (t[5] *= e), (t[9] *= e), (t[13] *= e), (t[2] *= e), (t[6] *= e), (t[10] *= e), (t[14] *= e), (t[3] *= e), (t[7] *= e), (t[11] *= e), (t[15] *= e), this ); } determinant() { let e = this.elements, t = e[0], i = e[4], r = e[8], s = e[12], n = e[1], a = e[5], o = e[9], l = e[13], h = e[2], u = e[6], c = e[10], d = e[14], p = e[3], f = e[7], g = e[11], m = e[15]; return ( p * (+s * o * u - r * l * u - s * a * c + i * l * c + r * a * d - i * o * d) + f * (+t * o * d - t * l * c + s * n * c - r * n * d + r * l * h - s * o * h) + g * (+t * l * u - t * a * d - s * n * u + i * n * d + s * a * h - i * l * h) + m * (-r * a * h - t * o * u + t * a * c + r * n * u - i * n * c + i * o * h) ); } transpose() { let e = this.elements, t; return ( (t = e[1]), (e[1] = e[4]), (e[4] = t), (t = e[2]), (e[2] = e[8]), (e[8] = t), (t = e[6]), (e[6] = e[9]), (e[9] = t), (t = e[3]), (e[3] = e[12]), (e[12] = t), (t = e[7]), (e[7] = e[13]), (e[13] = t), (t = e[11]), (e[11] = e[14]), (e[14] = t), this ); } setPosition(e, t, i) { let r = this.elements; return e.isVector3 ? ((r[12] = e.x), (r[13] = e.y), (r[14] = e.z)) : ((r[12] = e), (r[13] = t), (r[14] = i)), this; } invert() { let e = this.elements, t = e[0], i = e[1], r = e[2], s = e[3], n = e[4], a = e[5], o = e[6], l = e[7], h = e[8], u = e[9], c = e[10], d = e[11], p = e[12], f = e[13], g = e[14], m = e[15], v = u * g * l - f * c * l + f * o * d - a * g * d - u * o * m + a * c * m, y = p * c * l - h * g * l - p * o * d + n * g * d + h * o * m - n * c * m, b = h * f * l - p * u * l + p * a * d - n * f * d - h * a * m + n * u * m, x = p * u * o - h * f * o - p * a * c + n * f * c + h * a * g - n * u * g, w = t * v + i * y + r * b + s * x; if (w === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); let A = 1 / w; return ( (e[0] = v * A), (e[1] = (f * c * s - u * g * s - f * r * d + i * g * d + u * r * m - i * c * m) * A), (e[2] = (a * g * s - f * o * s + f * r * l - i * g * l - a * r * m + i * o * m) * A), (e[3] = (u * o * s - a * c * s - u * r * l + i * c * l + a * r * d - i * o * d) * A), (e[4] = y * A), (e[5] = (h * g * s - p * c * s + p * r * d - t * g * d - h * r * m + t * c * m) * A), (e[6] = (p * o * s - n * g * s - p * r * l + t * g * l + n * r * m - t * o * m) * A), (e[7] = (n * c * s - h * o * s + h * r * l - t * c * l - n * r * d + t * o * d) * A), (e[8] = b * A), (e[9] = (p * u * s - h * f * s - p * i * d + t * f * d + h * i * m - t * u * m) * A), (e[10] = (n * f * s - p * a * s + p * i * l - t * f * l - n * i * m + t * a * m) * A), (e[11] = (h * a * s - n * u * s - h * i * l + t * u * l + n * i * d - t * a * d) * A), (e[12] = x * A), (e[13] = (h * f * r - p * u * r + p * i * c - t * f * c - h * i * g + t * u * g) * A), (e[14] = (p * a * r - n * f * r - p * i * o + t * f * o + n * i * g - t * a * g) * A), (e[15] = (n * u * r - h * a * r + h * i * o - t * u * o - n * i * c + t * a * c) * A), this ); } scale(e) { let t = this.elements, i = e.x, r = e.y, s = e.z; return ( (t[0] *= i), (t[4] *= r), (t[8] *= s), (t[1] *= i), (t[5] *= r), (t[9] *= s), (t[2] *= i), (t[6] *= r), (t[10] *= s), (t[3] *= i), (t[7] *= r), (t[11] *= s), this ); } getMaxScaleOnAxis() { let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], i = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; return Math.sqrt(Math.max(t, i, r)); } makeTranslation(e, t, i) { return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, i, 0, 0, 0, 1), this; } makeRotationX(e) { let t = Math.cos(e), i = Math.sin(e); return this.set(1, 0, 0, 0, 0, t, -i, 0, 0, i, t, 0, 0, 0, 0, 1), this; } makeRotationY(e) { let t = Math.cos(e), i = Math.sin(e); return this.set(t, 0, i, 0, 0, 1, 0, 0, -i, 0, t, 0, 0, 0, 0, 1), this; } makeRotationZ(e) { let t = Math.cos(e), i = Math.sin(e); return this.set(t, -i, 0, 0, i, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; } makeRotationAxis(e, t) { let i = Math.cos(t), r = Math.sin(t), s = 1 - i, n = e.x, a = e.y, o = e.z, l = s * n, h = s * a; return ( this.set( l * n + i, l * a - r * o, l * o + r * a, 0, l * a + r * o, h * a + i, h * o - r * n, 0, l * o - r * a, h * o + r * n, s * o * o + i, 0, 0, 0, 0, 1 ), this ); } makeScale(e, t, i) { return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, i, 0, 0, 0, 0, 1), this; } makeShear(e, t, i, r, s, n) { return this.set(1, i, s, 0, e, 1, n, 0, t, r, 1, 0, 0, 0, 0, 1), this; } compose(e, t, i) { let r = this.elements, s = t._x, n = t._y, a = t._z, o = t._w, l = s + s, h = n + n, u = a + a, c = s * l, d = s * h, p = s * u, f = n * h, g = n * u, m = a * u, v = o * l, y = o * h, b = o * u, x = i.x, w = i.y, A = i.z; return ( (r[0] = (1 - (f + m)) * x), (r[1] = (d + b) * x), (r[2] = (p - y) * x), (r[3] = 0), (r[4] = (d - b) * w), (r[5] = (1 - (c + m)) * w), (r[6] = (g + v) * w), (r[7] = 0), (r[8] = (p + y) * A), (r[9] = (g - v) * A), (r[10] = (1 - (c + f)) * A), (r[11] = 0), (r[12] = e.x), (r[13] = e.y), (r[14] = e.z), (r[15] = 1), this ); } decompose(e, t, i) { let r = this.elements, s = Ua.set(r[0], r[1], r[2]).length(), n = Ua.set(r[4], r[5], r[6]).length(), a = Ua.set(r[8], r[9], r[10]).length(); this.determinant() < 0 && (s = -s), (e.x = r[12]), (e.y = r[13]), (e.z = r[14]), Lr.copy(this); let o = 1 / s, l = 1 / n, h = 1 / a; return ( (Lr.elements[0] *= o), (Lr.elements[1] *= o), (Lr.elements[2] *= o), (Lr.elements[4] *= l), (Lr.elements[5] *= l), (Lr.elements[6] *= l), (Lr.elements[8] *= h), (Lr.elements[9] *= h), (Lr.elements[10] *= h), t.setFromRotationMatrix(Lr), (i.x = s), (i.y = n), (i.z = a), this ); } makePerspective(e, t, i, r, s, n) { let a = this.elements, o = (2 * s) / (t - e), l = (2 * s) / (i - r), h = (t + e) / (t - e), u = (i + r) / (i - r), c = -(n + s) / (n - s), d = (-2 * n * s) / (n - s); return ( (a[0] = o), (a[4] = 0), (a[8] = h), (a[12] = 0), (a[1] = 0), (a[5] = l), (a[9] = u), (a[13] = 0), (a[2] = 0), (a[6] = 0), (a[10] = c), (a[14] = d), (a[3] = 0), (a[7] = 0), (a[11] = -1), (a[15] = 0), this ); } makeOrthographic(e, t, i, r, s, n) { let a = this.elements, o = 1 / (t - e), l = 1 / (i - r), h = 1 / (n - s), u = (t + e) * o, c = (i + r) * l, d = (n + s) * h; return ( (a[0] = 2 * o), (a[4] = 0), (a[8] = 0), (a[12] = -u), (a[1] = 0), (a[5] = 2 * l), (a[9] = 0), (a[13] = -c), (a[2] = 0), (a[6] = 0), (a[10] = -2 * h), (a[14] = -d), (a[3] = 0), (a[7] = 0), (a[11] = 0), (a[15] = 1), this ); } equals(e) { let t = this.elements, i = e.elements; for (let r = 0; r < 16; r++) if (t[r] !== i[r]) return !1; return !0; } fromArray(e, t = 0) { for (let i = 0; i < 16; i++) this.elements[i] = e[i + t]; return this; } toArray(e = [], t = 0) { let i = this.elements; return ( (e[t] = i[0]), (e[t + 1] = i[1]), (e[t + 2] = i[2]), (e[t + 3] = i[3]), (e[t + 4] = i[4]), (e[t + 5] = i[5]), (e[t + 6] = i[6]), (e[t + 7] = i[7]), (e[t + 8] = i[8]), (e[t + 9] = i[9]), (e[t + 10] = i[10]), (e[t + 11] = i[11]), (e[t + 12] = i[12]), (e[t + 13] = i[13]), (e[t + 14] = i[14]), (e[t + 15] = i[15]), e ); } }, Ua = new E(), Lr = new ve(), nE = new E(0, 0, 0), aE = new E(1, 1, 1), en = new E(), Jh = new E(), qi = new E(), R0 = new ve(), B0 = new ct(), _i = class { constructor(e = 0, t = 0, i = 0, r = _i.DEFAULT_ORDER) { (this.isEuler = !0), (this._x = e), (this._y = t), (this._z = i), (this._order = r); } get x() { return this._x; } set x(e) { (this._x = e), this._onChangeCallback(); } get y() { return this._y; } set y(e) { (this._y = e), this._onChangeCallback(); } get z() { return this._z; } set z(e) { (this._z = e), this._onChangeCallback(); } get order() { return this._order; } set order(e) { (this._order = e), this._onChangeCallback(); } set(e, t, i, r = this._order) { return (this._x = e), (this._y = t), (this._z = i), (this._order = r), this._onChangeCallback(), this; } clone() { return new this.constructor(this._x, this._y, this._z, this._order); } copy(e) { return (this._x = e._x), (this._y = e._y), (this._z = e._z), (this._order = e._order), this._onChangeCallback(), this; } setFromRotationMatrix(e, t = this._order, i = !0) { let r = e.elements, s = r[0], n = r[4], a = r[8], o = r[1], l = r[5], h = r[9], u = r[2], c = r[6], d = r[10]; switch (t) { case 'XYZ': (this._y = Math.asin(ti(a, -1, 1))), Math.abs(a) < 0.9999999 ? ((this._x = Math.atan2(-h, d)), (this._z = Math.atan2(-n, s))) : ((this._x = Math.atan2(c, l)), (this._z = 0)); break; case 'YXZ': (this._x = Math.asin(-ti(h, -1, 1))), Math.abs(h) < 0.9999999 ? ((this._y = Math.atan2(a, d)), (this._z = Math.atan2(o, l))) : ((this._y = Math.atan2(-u, s)), (this._z = 0)); break; case 'ZXY': (this._x = Math.asin(ti(c, -1, 1))), Math.abs(c) < 0.9999999 ? ((this._y = Math.atan2(-u, d)), (this._z = Math.atan2(-n, l))) : ((this._y = 0), (this._z = Math.atan2(o, s))); break; case 'ZYX': (this._y = Math.asin(-ti(u, -1, 1))), Math.abs(u) < 0.9999999 ? ((this._x = Math.atan2(c, d)), (this._z = Math.atan2(o, s))) : ((this._x = 0), (this._z = Math.atan2(-n, l))); break; case 'YZX': (this._z = Math.asin(ti(o, -1, 1))), Math.abs(o) < 0.9999999 ? ((this._x = Math.atan2(-h, l)), (this._y = Math.atan2(-u, s))) : ((this._x = 0), (this._y = Math.atan2(a, d))); break; case 'XZY': (this._z = Math.asin(-ti(n, -1, 1))), Math.abs(n) < 0.9999999 ? ((this._x = Math.atan2(c, l)), (this._y = Math.atan2(a, s))) : ((this._x = Math.atan2(-h, d)), (this._y = 0)); break; default: console.warn('THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + t); } return (this._order = t), i === !0 && this._onChangeCallback(), this; } setFromQuaternion(e, t, i) { return R0.makeRotationFromQuaternion(e), this.setFromRotationMatrix(R0, t, i); } setFromVector3(e, t = this._order) { return this.set(e.x, e.y, e.z, t); } reorder(e) { return B0.setFromEuler(this), this.setFromQuaternion(B0, e); } equals(e) { return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; } fromArray(e) { return (this._x = e[0]), (this._y = e[1]), (this._z = e[2]), e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; } toArray(e = [], t = 0) { return (e[t] = this._x), (e[t + 1] = this._y), (e[t + 2] = this._z), (e[t + 3] = this._order), e; } _onChange(e) { return (this._onChangeCallback = e), this; } _onChangeCallback() {} *[Symbol.iterator]() { yield this._x, yield this._y, yield this._z, yield this._order; } }; _i.DEFAULT_ORDER = 'XYZ'; var hg = class { constructor() { this.mask = 1; } set(e) { this.mask = ((1 << e) | 0) >>> 0; } enable(e) { this.mask |= (1 << e) | 0; } enableAll() { this.mask = -1; } toggle(e) { this.mask ^= (1 << e) | 0; } disable(e) { this.mask &= ~((1 << e) | 0); } disableAll() { this.mask = 0; } test(e) { return (this.mask & e.mask) !== 0; } isEnabled(e) { return (this.mask & ((1 << e) | 0)) !== 0; } }, oE = 0, z0 = new E(), Fa = new ct(), Ps = new ve(), $h = new E(), pl = new E(), lE = new E(), hE = new ct(), N0 = new E(1, 0, 0), U0 = new E(0, 1, 0), F0 = new E(0, 0, 1), cE = { type: 'added' }, k0 = { type: 'removed' }, bt = class extends Vi { constructor() { super(), (this.isObject3D = !0), Object.defineProperty(this, 'id', { value: oE++ }), (this.uuid = ps()), (this.name = ''), (this.type = 'Object3D'), (this.parent = null), (this.children = []), (this.up = bt.DEFAULT_UP.clone()); let e = new E(), t = new _i(), i = new ct(), r = new E(1, 1, 1); function s() { i.setFromEuler(t, !1); } function n() { t.setFromQuaternion(i, void 0, !1); } t._onChange(s), i._onChange(n), Object.defineProperties(this, { position: { configurable: !0, enumerable: !0, value: e }, rotation: { configurable: !0, enumerable: !0, value: t }, quaternion: { configurable: !0, enumerable: !0, value: i }, scale: { configurable: !0, enumerable: !0, value: r }, modelViewMatrix: { value: new ve() }, normalMatrix: { value: new Ai() } }), (this.matrix = new ve()), (this.matrixWorld = new ve()), (this.matrixAutoUpdate = bt.DEFAULT_MATRIX_AUTO_UPDATE), (this.matrixWorldNeedsUpdate = !1), (this.matrixWorldAutoUpdate = bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE), (this.layers = new hg()), (this.visible = !0), (this.castShadow = !1), (this.receiveShadow = !1), (this.frustumCulled = !0), (this.renderOrder = 0), (this.animations = []), (this.userData = {}); } onBeforeRender() {} onAfterRender() {} applyMatrix4(e) { this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); } applyQuaternion(e) { return this.quaternion.premultiply(e), this; } setRotationFromAxisAngle(e, t) { this.quaternion.setFromAxisAngle(e, t); } setRotationFromEuler(e) { this.quaternion.setFromEuler(e, !0); } setRotationFromMatrix(e) { this.quaternion.setFromRotationMatrix(e); } setRotationFromQuaternion(e) { this.quaternion.copy(e); } rotateOnAxis(e, t) { return Fa.setFromAxisAngle(e, t), this.quaternion.multiply(Fa), this; } rotateOnWorldAxis(e, t) { return Fa.setFromAxisAngle(e, t), this.quaternion.premultiply(Fa), this; } rotateX(e) { return this.rotateOnAxis(N0, e); } rotateY(e) { return this.rotateOnAxis(U0, e); } rotateZ(e) { return this.rotateOnAxis(F0, e); } translateOnAxis(e, t) { return z0.copy(e).applyQuaternion(this.quaternion), this.position.add(z0.multiplyScalar(t)), this; } translateX(e) { return this.translateOnAxis(N0, e); } translateY(e) { return this.translateOnAxis(U0, e); } translateZ(e) { return this.translateOnAxis(F0, e); } localToWorld(e) { return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld); } worldToLocal(e) { return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Ps.copy(this.matrixWorld).invert()); } lookAt(e, t, i) { e.isVector3 ? $h.copy(e) : $h.set(e, t, i); let r = this.parent; this.updateWorldMatrix(!0, !1), pl.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Ps.lookAt(pl, $h, this.up) : Ps.lookAt($h, pl, this.up), this.quaternion.setFromRotationMatrix(Ps), r && (Ps.extractRotation(r.matrixWorld), Fa.setFromRotationMatrix(Ps), this.quaternion.premultiply(Fa.invert())); } add(e) { if (arguments.length > 1) { for (let t = 0; t < arguments.length; t++) this.add(arguments[t]); return this; } return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), (e.parent = this), this.children.push(e), e.dispatchEvent(cE)) : console.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', e), this); } remove(e) { if (arguments.length > 1) { for (let i = 0; i < arguments.length; i++) this.remove(arguments[i]); return this; } let t = this.children.indexOf(e); return t !== -1 && ((e.parent = null), this.children.splice(t, 1), e.dispatchEvent(k0)), this; } removeFromParent() { let e = this.parent; return e !== null && e.remove(this), this; } clear() { for (let e = 0; e < this.children.length; e++) { let t = this.children[e]; (t.parent = null), t.dispatchEvent(k0); } return (this.children.length = 0), this; } attach(e) { return ( this.updateWorldMatrix(!0, !1), Ps.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Ps.multiply(e.parent.matrixWorld)), e.applyMatrix4(Ps), this.add(e), e.updateWorldMatrix(!1, !0), this ); } getObjectById(e) { return this.getObjectByProperty('id', e); } getObjectByName(e) { return this.getObjectByProperty('name', e); } getObjectByProperty(e, t) { if (this[e] === t) return this; for (let i = 0, r = this.children.length; i < r; i++) { let s = this.children[i].getObjectByProperty(e, t); if (s !== void 0) return s; } } getObjectsByProperty(e, t) { let i = []; this[e] === t && i.push(this); for (let r = 0, s = this.children.length; r < s; r++) { let n = this.children[r].getObjectsByProperty(e, t); n.length > 0 && (i = i.concat(n)); } return i; } getWorldPosition(e) { return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); } getWorldQuaternion(e) { return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(pl, e, lE), e; } getWorldScale(e) { return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(pl, hE, e), e; } getWorldDirection(e) { this.updateWorldMatrix(!0, !1); let t = this.matrixWorld.elements; return e.set(t[8], t[9], t[10]).normalize(); } raycast() {} traverse(e) { e(this); let t = this.children; for (let i = 0, r = t.length; i < r; i++) t[i].traverse(e); } traverseVisible(e) { if (this.visible === !1) return; e(this); let t = this.children; for (let i = 0, r = t.length; i < r; i++) t[i].traverseVisible(e); } traverseAncestors(e) { let t = this.parent; t !== null && (e(t), t.traverseAncestors(e)); } updateMatrix() { this.matrix.compose(this.position, this.quaternion, this.scale), (this.matrixWorldNeedsUpdate = !0); } updateMatrixWorld(e) { this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), (this.matrixWorldNeedsUpdate = !1), (e = !0)); let t = this.children; for (let i = 0, r = t.length; i < r; i++) { let s = t[i]; (s.matrixWorldAutoUpdate === !0 || e === !0) && s.updateMatrixWorld(e); } } updateWorldMatrix(e, t) { let i = this.parent; if ( (e === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) ) { let r = this.children; for (let s = 0, n = r.length; s < n; s++) { let a = r[s]; a.matrixWorldAutoUpdate === !0 && a.updateWorldMatrix(!1, !0); } } } toJSON(e) { let t = e === void 0 || typeof e == 'string', i = {}; t && ((e = { geometries: {}, materials: {}, textures: {}, images: {}, shapes: {}, skeletons: {}, animations: {}, nodes: {} }), (i.metadata = { version: 4.5, type: 'Object', generator: 'Object3D.toJSON' })); let r = {}; (r.uuid = this.uuid), (r.type = this.type), this.name !== '' && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (r.userData = this.userData), (r.layers = this.layers.mask), (r.matrix = this.matrix.toArray()), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.isInstancedMesh && ((r.type = 'InstancedMesh'), (r.count = this.count), (r.instanceMatrix = this.instanceMatrix.toJSON()), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())); function s(a, o) { return a[o.uuid] === void 0 && (a[o.uuid] = o.toJSON(e)), o.uuid; } if (this.isScene) this.background && (this.background.isColor ? (r.background = this.background.toJSON()) : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid); else if (this.isMesh || this.isLine || this.isPoints) { r.geometry = s(e.geometries, this.geometry); let a = this.geometry.parameters; if (a !== void 0 && a.shapes !== void 0) { let o = a.shapes; if (Array.isArray(o)) for (let l = 0, h = o.length; l < h; l++) { let u = o[l]; s(e.shapes, u); } else s(e.shapes, o); } } if ( (this.isSkinnedMesh && ((r.bindMode = this.bindMode), (r.bindMatrix = this.bindMatrix.toArray()), this.skeleton !== void 0 && (s(e.skeletons, this.skeleton), (r.skeleton = this.skeleton.uuid))), this.material !== void 0) ) if (Array.isArray(this.material)) { let a = []; for (let o = 0, l = this.material.length; o < l; o++) a.push(s(e.materials, this.material[o])); r.material = a; } else r.material = s(e.materials, this.material); if (this.children.length > 0) { r.children = []; for (let a = 0; a < this.children.length; a++) r.children.push(this.children[a].toJSON(e).object); } if (this.animations.length > 0) { r.animations = []; for (let a = 0; a < this.animations.length; a++) { let o = this.animations[a]; r.animations.push(s(e.animations, o)); } } if (t) { let a = n(e.geometries), o = n(e.materials), l = n(e.textures), h = n(e.images), u = n(e.shapes), c = n(e.skeletons), d = n(e.animations), p = n(e.nodes); a.length > 0 && (i.geometries = a), o.length > 0 && (i.materials = o), l.length > 0 && (i.textures = l), h.length > 0 && (i.images = h), u.length > 0 && (i.shapes = u), c.length > 0 && (i.skeletons = c), d.length > 0 && (i.animations = d), p.length > 0 && (i.nodes = p); } return (i.object = r), i; function n(a) { let o = []; for (let l in a) { let h = a[l]; delete h.metadata, o.push(h); } return o; } } clone(e) { return new this.constructor().copy(this, e); } copy(e, t = !0) { if ( ((this.name = e.name), this.up.copy(e.up), this.position.copy(e.position), (this.rotation.order = e.rotation.order), this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), (this.matrixAutoUpdate = e.matrixAutoUpdate), (this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate), (this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate), (this.layers.mask = e.layers.mask), (this.visible = e.visible), (this.castShadow = e.castShadow), (this.receiveShadow = e.receiveShadow), (this.frustumCulled = e.frustumCulled), (this.renderOrder = e.renderOrder), (this.userData = JSON.parse(JSON.stringify(e.userData))), t === !0) ) for (let i = 0; i < e.children.length; i++) { let r = e.children[i]; this.add(r.clone()); } return this; } }; bt.DEFAULT_UP = new E(0, 1, 0); bt.DEFAULT_MATRIX_AUTO_UPDATE = !0; bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; var Or = new E(), Ds = new E(), cp = new E(), Ls = new E(), ka = new E(), ja = new E(), j0 = new E(), dp = new E(), up = new E(), pp = new E(), Bi = class { constructor(e = new E(), t = new E(), i = new E()) { (this.a = e), (this.b = t), (this.c = i); } static getNormal(e, t, i, r) { r.subVectors(i, t), Or.subVectors(e, t), r.cross(Or); let s = r.lengthSq(); return s > 0 ? r.multiplyScalar(1 / Math.sqrt(s)) : r.set(0, 0, 0); } static getBarycoord(e, t, i, r, s) { Or.subVectors(r, t), Ds.subVectors(i, t), cp.subVectors(e, t); let n = Or.dot(Or), a = Or.dot(Ds), o = Or.dot(cp), l = Ds.dot(Ds), h = Ds.dot(cp), u = n * l - a * a; if (u === 0) return s.set(-2, -1, -1); let c = 1 / u, d = (l * o - a * h) * c, p = (n * h - a * o) * c; return s.set(1 - d - p, p, d); } static containsPoint(e, t, i, r) { return this.getBarycoord(e, t, i, r, Ls), Ls.x >= 0 && Ls.y >= 0 && Ls.x + Ls.y <= 1; } static getUV(e, t, i, r, s, n, a, o) { return ( this.getBarycoord(e, t, i, r, Ls), o.set(0, 0), o.addScaledVector(s, Ls.x), o.addScaledVector(n, Ls.y), o.addScaledVector(a, Ls.z), o ); } static isFrontFacing(e, t, i, r) { return Or.subVectors(i, t), Ds.subVectors(e, t), Or.cross(Ds).dot(r) < 0; } set(e, t, i) { return this.a.copy(e), this.b.copy(t), this.c.copy(i), this; } setFromPointsAndIndices(e, t, i, r) { return this.a.copy(e[t]), this.b.copy(e[i]), this.c.copy(e[r]), this; } setFromAttributeAndIndices(e, t, i, r) { return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, i), this.c.fromBufferAttribute(e, r), this; } clone() { return new this.constructor().copy(this); } copy(e) { return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; } getArea() { return Or.subVectors(this.c, this.b), Ds.subVectors(this.a, this.b), Or.cross(Ds).length() * 0.5; } getMidpoint(e) { return e .addVectors(this.a, this.b) .add(this.c) .multiplyScalar(1 / 3); } getNormal(e) { return Bi.getNormal(this.a, this.b, this.c, e); } getPlane(e) { return e.setFromCoplanarPoints(this.a, this.b, this.c); } getBarycoord(e, t) { return Bi.getBarycoord(e, this.a, this.b, this.c, t); } getUV(e, t, i, r, s) { return Bi.getUV(e, this.a, this.b, this.c, t, i, r, s); } containsPoint(e) { return Bi.containsPoint(e, this.a, this.b, this.c); } isFrontFacing(e) { return Bi.isFrontFacing(this.a, this.b, this.c, e); } intersectsBox(e) { return e.intersectsTriangle(this); } closestPointToPoint(e, t) { let i = this.a, r = this.b, s = this.c, n, a; ka.subVectors(r, i), ja.subVectors(s, i), dp.subVectors(e, i); let o = ka.dot(dp), l = ja.dot(dp); if (o <= 0 && l <= 0) return t.copy(i); up.subVectors(e, r); let h = ka.dot(up), u = ja.dot(up); if (h >= 0 && u <= h) return t.copy(r); let c = o * u - h * l; if (c <= 0 && o >= 0 && h <= 0) return (n = o / (o - h)), t.copy(i).addScaledVector(ka, n); pp.subVectors(e, s); let d = ka.dot(pp), p = ja.dot(pp); if (p >= 0 && d <= p) return t.copy(s); let f = d * l - o * p; if (f <= 0 && l >= 0 && p <= 0) return (a = l / (l - p)), t.copy(i).addScaledVector(ja, a); let g = h * p - d * u; if (g <= 0 && u - h >= 0 && d - p >= 0) return j0.subVectors(s, r), (a = (u - h) / (u - h + (d - p))), t.copy(r).addScaledVector(j0, a); let m = 1 / (g + f + c); return (n = f * m), (a = c * m), t.copy(i).addScaledVector(ka, n).addScaledVector(ja, a); } equals(e) { return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); } }, dE = 0, Th = class extends Vi { constructor() { super(), (this.isMaterial = !0), Object.defineProperty(this, 'id', { value: dE++ }), (this.uuid = ps()), (this.name = ''), (this.type = 'Material'), (this.blending = Ao), (this.side = Vr), (this.vertexColors = !1), (this.opacity = 1), (this.transparent = !1), (this.blendSrc = nw), (this.blendDst = aw), (this.blendEquation = no), (this.blendSrcAlpha = null), (this.blendDstAlpha = null), (this.blendEquationAlpha = null), (this.depthFunc = Bf), (this.depthTest = !0), (this.depthWrite = !0), (this.stencilWriteMask = 255), (this.stencilFunc = kM), (this.stencilRef = 0), (this.stencilFuncMask = 255), (this.stencilFail = Ju), (this.stencilZFail = Ju), (this.stencilZPass = Ju), (this.stencilWrite = !1), (this.clippingPlanes = null), (this.clipIntersection = !1), (this.clipShadows = !1), (this.shadowSide = null), (this.colorWrite = !0), (this.precision = null), (this.polygonOffset = !1), (this.polygonOffsetFactor = 0), (this.polygonOffsetUnits = 0), (this.dithering = !1), (this.alphaToCoverage = !1), (this.premultipliedAlpha = !1), (this.forceSinglePass = !1), (this.visible = !0), (this.toneMapped = !0), (this.userData = {}), (this.version = 0), (this._alphaTest = 0); } get alphaTest() { return this._alphaTest; } set alphaTest(e) { this._alphaTest > 0 != e > 0 && this.version++, (this._alphaTest = e); } onBuild() {} onBeforeRender() {} onBeforeCompile() {} customProgramCacheKey() { return this.onBeforeCompile.toString(); } setValues(e) { if (e !== void 0) for (let t in e) { let i = e[t]; if (i === void 0) { console.warn("THREE.Material: '" + t + "' parameter is undefined."); continue; } let r = this[t]; if (r === void 0) { console.warn('THREE.' + this.type + ": '" + t + "' is not a property of this material."); continue; } r && r.isColor ? r.set(i) : r && r.isVector3 && i && i.isVector3 ? r.copy(i) : (this[t] = i); } } toJSON(e) { let t = e === void 0 || typeof e == 'string'; t && (e = { textures: {}, images: {} }); let i = { metadata: { version: 4.5, type: 'Material', generator: 'Material.toJSON' } }; (i.uuid = this.uuid), (i.type = this.type), this.name !== '' && (i.name = this.name), this.color && this.color.isColor && (i.color = this.color.getHex()), this.roughness !== void 0 && (i.roughness = this.roughness), this.metalness !== void 0 && (i.metalness = this.metalness), this.sheen !== void 0 && (i.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (i.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (i.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (i.emissive = this.emissive.getHex()), this.emissiveIntensity && this.emissiveIntensity !== 1 && (i.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (i.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (i.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (i.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (i.shininess = this.shininess), this.clearcoat !== void 0 && (i.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (i.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (i.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && ((i.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid), (i.clearcoatNormalScale = this.clearcoatNormalScale.toArray())), this.iridescence !== void 0 && (i.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (i.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (i.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (i.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (i.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.map && this.map.isTexture && (i.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (i.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (i.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && ((i.lightMap = this.lightMap.toJSON(e).uuid), (i.lightMapIntensity = this.lightMapIntensity)), this.aoMap && this.aoMap.isTexture && ((i.aoMap = this.aoMap.toJSON(e).uuid), (i.aoMapIntensity = this.aoMapIntensity)), this.bumpMap && this.bumpMap.isTexture && ((i.bumpMap = this.bumpMap.toJSON(e).uuid), (i.bumpScale = this.bumpScale)), this.normalMap && this.normalMap.isTexture && ((i.normalMap = this.normalMap.toJSON(e).uuid), (i.normalMapType = this.normalMapType), (i.normalScale = this.normalScale.toArray())), this.displacementMap && this.displacementMap.isTexture && ((i.displacementMap = this.displacementMap.toJSON(e).uuid), (i.displacementScale = this.displacementScale), (i.displacementBias = this.displacementBias)), this.roughnessMap && this.roughnessMap.isTexture && (i.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (i.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (i.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (i.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (i.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (i.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && ((i.envMap = this.envMap.toJSON(e).uuid), this.combine !== void 0 && (i.combine = this.combine)), this.envMapIntensity !== void 0 && (i.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (i.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (i.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (i.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (i.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (i.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (i.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (i.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (i.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (i.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (i.size = this.size), this.shadowSide !== null && (i.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (i.sizeAttenuation = this.sizeAttenuation), this.blending !== Ao && (i.blending = this.blending), this.side !== Vr && (i.side = this.side), this.vertexColors && (i.vertexColors = !0), this.opacity < 1 && (i.opacity = this.opacity), this.transparent === !0 && (i.transparent = this.transparent), (i.depthFunc = this.depthFunc), (i.depthTest = this.depthTest), (i.depthWrite = this.depthWrite), (i.colorWrite = this.colorWrite), (i.stencilWrite = this.stencilWrite), (i.stencilWriteMask = this.stencilWriteMask), (i.stencilFunc = this.stencilFunc), (i.stencilRef = this.stencilRef), (i.stencilFuncMask = this.stencilFuncMask), (i.stencilFail = this.stencilFail), (i.stencilZFail = this.stencilZFail), (i.stencilZPass = this.stencilZPass), this.rotation !== void 0 && this.rotation !== 0 && (i.rotation = this.rotation), this.polygonOffset === !0 && (i.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (i.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (i.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (i.linewidth = this.linewidth), this.dashSize !== void 0 && (i.dashSize = this.dashSize), this.gapSize !== void 0 && (i.gapSize = this.gapSize), this.scale !== void 0 && (i.scale = this.scale), this.dithering === !0 && (i.dithering = !0), this.alphaTest > 0 && (i.alphaTest = this.alphaTest), this.alphaToCoverage === !0 && (i.alphaToCoverage = this.alphaToCoverage), this.premultipliedAlpha === !0 && (i.premultipliedAlpha = this.premultipliedAlpha), this.forceSinglePass === !0 && (i.forceSinglePass = this.forceSinglePass), this.wireframe === !0 && (i.wireframe = this.wireframe), this.wireframeLinewidth > 1 && (i.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== 'round' && (i.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== 'round' && (i.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (i.flatShading = this.flatShading), this.visible === !1 && (i.visible = !1), this.toneMapped === !1 && (i.toneMapped = !1), this.fog === !1 && (i.fog = !1), Object.keys(this.userData).length > 0 && (i.userData = this.userData); function r(s) { let n = []; for (let a in s) { let o = s[a]; delete o.metadata, n.push(o); } return n; } if (t) { let s = r(e.textures), n = r(e.images); s.length > 0 && (i.textures = s), n.length > 0 && (i.images = n); } return i; } clone() { return new this.constructor().copy(this); } copy(e) { (this.name = e.name), (this.blending = e.blending), (this.side = e.side), (this.vertexColors = e.vertexColors), (this.opacity = e.opacity), (this.transparent = e.transparent), (this.blendSrc = e.blendSrc), (this.blendDst = e.blendDst), (this.blendEquation = e.blendEquation), (this.blendSrcAlpha = e.blendSrcAlpha), (this.blendDstAlpha = e.blendDstAlpha), (this.blendEquationAlpha = e.blendEquationAlpha), (this.depthFunc = e.depthFunc), (this.depthTest = e.depthTest), (this.depthWrite = e.depthWrite), (this.stencilWriteMask = e.stencilWriteMask), (this.stencilFunc = e.stencilFunc), (this.stencilRef = e.stencilRef), (this.stencilFuncMask = e.stencilFuncMask), (this.stencilFail = e.stencilFail), (this.stencilZFail = e.stencilZFail), (this.stencilZPass = e.stencilZPass), (this.stencilWrite = e.stencilWrite); let t = e.clippingPlanes, i = null; if (t !== null) { let r = t.length; i = new Array(r); for (let s = 0; s !== r; ++s) i[s] = t[s].clone(); } return ( (this.clippingPlanes = i), (this.clipIntersection = e.clipIntersection), (this.clipShadows = e.clipShadows), (this.shadowSide = e.shadowSide), (this.colorWrite = e.colorWrite), (this.precision = e.precision), (this.polygonOffset = e.polygonOffset), (this.polygonOffsetFactor = e.polygonOffsetFactor), (this.polygonOffsetUnits = e.polygonOffsetUnits), (this.dithering = e.dithering), (this.alphaTest = e.alphaTest), (this.alphaToCoverage = e.alphaToCoverage), (this.premultipliedAlpha = e.premultipliedAlpha), (this.forceSinglePass = e.forceSinglePass), (this.visible = e.visible), (this.toneMapped = e.toneMapped), (this.userData = JSON.parse(JSON.stringify(e.userData))), this ); } dispose() { this.dispatchEvent({ type: 'dispose' }); } set needsUpdate(e) { e === !0 && this.version++; } }, Ph = class extends Th { constructor(e) { super(), (this.isMeshBasicMaterial = !0), (this.type = 'MeshBasicMaterial'), (this.color = new Ge(16777215)), (this.map = null), (this.lightMap = null), (this.lightMapIntensity = 1), (this.aoMap = null), (this.aoMapIntensity = 1), (this.specularMap = null), (this.alphaMap = null), (this.envMap = null), (this.combine = ow), (this.reflectivity = 1), (this.refractionRatio = 0.98), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.wireframeLinecap = 'round'), (this.wireframeLinejoin = 'round'), (this.fog = !0), this.setValues(e); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.map = e.map), (this.lightMap = e.lightMap), (this.lightMapIntensity = e.lightMapIntensity), (this.aoMap = e.aoMap), (this.aoMapIntensity = e.aoMapIntensity), (this.specularMap = e.specularMap), (this.alphaMap = e.alphaMap), (this.envMap = e.envMap), (this.combine = e.combine), (this.reflectivity = e.reflectivity), (this.refractionRatio = e.refractionRatio), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.wireframeLinecap = e.wireframeLinecap), (this.wireframeLinejoin = e.wireframeLinejoin), (this.fog = e.fog), this ); } }, Yt = new E(), ec = new G(), Xe = class { constructor(e, t, i = !1) { if (Array.isArray(e)) throw new TypeError('THREE.BufferAttribute: array should be a Typed Array.'); (this.isBufferAttribute = !0), (this.name = ''), (this.array = e), (this.itemSize = t), (this.count = e !== void 0 ? e.length / t : 0), (this.normalized = i), (this.usage = Ff), (this.updateRange = { offset: 0, count: -1 }), (this.version = 0); } onUploadCallback() {} set needsUpdate(e) { e === !0 && this.version++; } setUsage(e) { return (this.usage = e), this; } copy(e) { return ( (this.name = e.name), (this.array = new e.array.constructor(e.array)), (this.itemSize = e.itemSize), (this.count = e.count), (this.normalized = e.normalized), (this.usage = e.usage), this ); } copyAt(e, t, i) { (e *= this.itemSize), (i *= t.itemSize); for (let r = 0, s = this.itemSize; r < s; r++) this.array[e + r] = t.array[i + r]; return this; } copyArray(e) { return this.array.set(e), this; } applyMatrix3(e) { if (this.itemSize === 2) for (let t = 0, i = this.count; t < i; t++) ec.fromBufferAttribute(this, t), ec.applyMatrix3(e), this.setXY(t, ec.x, ec.y); else if (this.itemSize === 3) for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.applyMatrix3(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } applyMatrix4(e) { for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.applyMatrix4(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } applyNormalMatrix(e) { for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.applyNormalMatrix(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } transformDirection(e) { for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.transformDirection(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z); return this; } set(e, t = 0) { return this.array.set(e, t), this; } getX(e) { let t = this.array[e * this.itemSize]; return this.normalized && (t = ks(t, this.array)), t; } setX(e, t) { return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize] = t), this; } getY(e) { let t = this.array[e * this.itemSize + 1]; return this.normalized && (t = ks(t, this.array)), t; } setY(e, t) { return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 1] = t), this; } getZ(e) { let t = this.array[e * this.itemSize + 2]; return this.normalized && (t = ks(t, this.array)), t; } setZ(e, t) { return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 2] = t), this; } getW(e) { let t = this.array[e * this.itemSize + 3]; return this.normalized && (t = ks(t, this.array)), t; } setW(e, t) { return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 3] = t), this; } setXY(e, t, i) { return ( (e *= this.itemSize), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array))), (this.array[e + 0] = t), (this.array[e + 1] = i), this ); } setXYZ(e, t, i, r) { return ( (e *= this.itemSize), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array))), (this.array[e + 0] = t), (this.array[e + 1] = i), (this.array[e + 2] = r), this ); } setXYZW(e, t, i, r, s) { return ( (e *= this.itemSize), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array)), (s = _t(s, this.array))), (this.array[e + 0] = t), (this.array[e + 1] = i), (this.array[e + 2] = r), (this.array[e + 3] = s), this ); } onUpload(e) { return (this.onUploadCallback = e), this; } clone() { return new this.constructor(this.array, this.itemSize).copy(this); } toJSON() { let e = { itemSize: this.itemSize, type: this.array.constructor.name, array: Array.from(this.array), normalized: this.normalized }; return ( this.name !== '' && (e.name = this.name), this.usage !== Ff && (e.usage = this.usage), (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (e.updateRange = this.updateRange), e ); } copyColorsArray() { console.error('THREE.BufferAttribute: copyColorsArray() was removed in r144.'); } copyVector2sArray() { console.error('THREE.BufferAttribute: copyVector2sArray() was removed in r144.'); } copyVector3sArray() { console.error('THREE.BufferAttribute: copyVector3sArray() was removed in r144.'); } copyVector4sArray() { console.error('THREE.BufferAttribute: copyVector4sArray() was removed in r144.'); } }, gw = class extends Xe { constructor(e, t, i) { super(new Uint16Array(e), t, i); } }, Kl = class extends Xe { constructor(e, t, i) { super(new Uint32Array(e), t, i); } }, uE = class extends Xe { constructor(e, t, i) { super(new Uint16Array(e), t, i), (this.isFloat16BufferAttribute = !0); } }, Ce = class extends Xe { constructor(e, t, i) { super(new Float32Array(e), t, i); } }, pE = 0, cr = new ve(), fp = new bt(), Ga = new E(), Yi = new Kt(), fl = new Kt(), oi = new E(), Ve = class extends Vi { constructor() { super(), (this.isBufferGeometry = !0), Object.defineProperty(this, 'id', { value: pE++ }), (this.uuid = ps()), (this.name = ''), (this.type = 'BufferGeometry'), (this.index = null), (this.attributes = {}), (this.morphAttributes = {}), (this.morphTargetsRelative = !1), (this.groups = []), (this.boundingBox = null), (this.boundingSphere = null), (this.drawRange = { start: 0, count: 1 / 0 }), (this.userData = {}); } getIndex() { return this.index; } setIndex(e) { return Array.isArray(e) ? (this.index = new (dw(e) ? Kl : gw)(e, 1)) : (this.index = e), this; } getAttribute(e) { return this.attributes[e]; } setAttribute(e, t) { return (this.attributes[e] = t), this; } deleteAttribute(e) { return delete this.attributes[e], this; } hasAttribute(e) { return this.attributes[e] !== void 0; } addGroup(e, t, i = 0) { this.groups.push({ start: e, count: t, materialIndex: i }); } clearGroups() { this.groups = []; } setDrawRange(e, t) { (this.drawRange.start = e), (this.drawRange.count = t); } applyMatrix4(e) { let t = this.attributes.position; t !== void 0 && (t.applyMatrix4(e), (t.needsUpdate = !0)); let i = this.attributes.normal; if (i !== void 0) { let s = new Ai().getNormalMatrix(e); i.applyNormalMatrix(s), (i.needsUpdate = !0); } let r = this.attributes.tangent; return ( r !== void 0 && (r.transformDirection(e), (r.needsUpdate = !0)), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this ); } applyQuaternion(e) { return cr.makeRotationFromQuaternion(e), this.applyMatrix4(cr), this; } rotateX(e) { return cr.makeRotationX(e), this.applyMatrix4(cr), this; } rotateY(e) { return cr.makeRotationY(e), this.applyMatrix4(cr), this; } rotateZ(e) { return cr.makeRotationZ(e), this.applyMatrix4(cr), this; } translate(e, t, i) { return cr.makeTranslation(e, t, i), this.applyMatrix4(cr), this; } scale(e, t, i) { return cr.makeScale(e, t, i), this.applyMatrix4(cr), this; } lookAt(e) { return fp.lookAt(e), fp.updateMatrix(), this.applyMatrix4(fp.matrix), this; } center() { return this.computeBoundingBox(), this.boundingBox.getCenter(Ga).negate(), this.translate(Ga.x, Ga.y, Ga.z), this; } setFromPoints(e) { let t = []; for (let i = 0, r = e.length; i < r; i++) { let s = e[i]; t.push(s.x, s.y, s.z || 0); } return this.setAttribute('position', new Ce(t, 3)), this; } computeBoundingBox() { this.boundingBox === null && (this.boundingBox = new Kt()); let e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this ), this.boundingBox.set(new E(-1 / 0, -1 / 0, -1 / 0), new E(1 / 0, 1 / 0, 1 / 0)); return; } if (e !== void 0) { if ((this.boundingBox.setFromBufferAttribute(e), t)) for (let i = 0, r = t.length; i < r; i++) { let s = t[i]; Yi.setFromBufferAttribute(s), this.morphTargetsRelative ? (oi.addVectors(this.boundingBox.min, Yi.min), this.boundingBox.expandByPoint(oi), oi.addVectors(this.boundingBox.max, Yi.max), this.boundingBox.expandByPoint(oi)) : (this.boundingBox.expandByPoint(Yi.min), this.boundingBox.expandByPoint(Yi.max)); } } else this.boundingBox.makeEmpty(); (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); } computeBoundingSphere() { this.boundingSphere === null && (this.boundingSphere = new Mr()); let e = this.attributes.position, t = this.morphAttributes.position; if (e && e.isGLBufferAttribute) { console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this ), this.boundingSphere.set(new E(), 1 / 0); return; } if (e) { let i = this.boundingSphere.center; if ((Yi.setFromBufferAttribute(e), t)) for (let s = 0, n = t.length; s < n; s++) { let a = t[s]; fl.setFromBufferAttribute(a), this.morphTargetsRelative ? (oi.addVectors(Yi.min, fl.min), Yi.expandByPoint(oi), oi.addVectors(Yi.max, fl.max), Yi.expandByPoint(oi)) : (Yi.expandByPoint(fl.min), Yi.expandByPoint(fl.max)); } Yi.getCenter(i); let r = 0; for (let s = 0, n = e.count; s < n; s++) oi.fromBufferAttribute(e, s), (r = Math.max(r, i.distanceToSquared(oi))); if (t) for (let s = 0, n = t.length; s < n; s++) { let a = t[s], o = this.morphTargetsRelative; for (let l = 0, h = a.count; l < h; l++) oi.fromBufferAttribute(a, l), o && (Ga.fromBufferAttribute(e, l), oi.add(Ga)), (r = Math.max(r, i.distanceToSquared(oi))); } (this.boundingSphere.radius = Math.sqrt(r)), isNaN(this.boundingSphere.radius) && console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); } } computeTangents() { let e = this.index, t = this.attributes; if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { console.error('THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)'); return; } let i = e.array, r = t.position.array, s = t.normal.array, n = t.uv.array, a = r.length / 3; this.hasAttribute('tangent') === !1 && this.setAttribute('tangent', new Xe(new Float32Array(4 * a), 4)); let o = this.getAttribute('tangent').array, l = [], h = []; for (let M = 0; M < a; M++) (l[M] = new E()), (h[M] = new E()); let u = new E(), c = new E(), d = new E(), p = new G(), f = new G(), g = new G(), m = new E(), v = new E(); function y(M, C, T) { u.fromArray(r, M * 3), c.fromArray(r, C * 3), d.fromArray(r, T * 3), p.fromArray(n, M * 2), f.fromArray(n, C * 2), g.fromArray(n, T * 2), c.sub(u), d.sub(u), f.sub(p), g.sub(p); let P = 1 / (f.x * g.y - g.x * f.y); !isFinite(P) || (m.copy(c).multiplyScalar(g.y).addScaledVector(d, -f.y).multiplyScalar(P), v.copy(d).multiplyScalar(f.x).addScaledVector(c, -g.x).multiplyScalar(P), l[M].add(m), l[C].add(m), l[T].add(m), h[M].add(v), h[C].add(v), h[T].add(v)); } let b = this.groups; b.length === 0 && (b = [{ start: 0, count: i.length }]); for (let M = 0, C = b.length; M < C; ++M) { let T = b[M], P = T.start, L = T.count; for (let D = P, k = P + L; D < k; D += 3) y(i[D + 0], i[D + 1], i[D + 2]); } let x = new E(), w = new E(), A = new E(), S = new E(); function _(M) { A.fromArray(s, M * 3), S.copy(A); let C = l[M]; x.copy(C), x.sub(A.multiplyScalar(A.dot(C))).normalize(), w.crossVectors(S, C); let T = w.dot(h[M]) < 0 ? -1 : 1; (o[M * 4] = x.x), (o[M * 4 + 1] = x.y), (o[M * 4 + 2] = x.z), (o[M * 4 + 3] = T); } for (let M = 0, C = b.length; M < C; ++M) { let T = b[M], P = T.start, L = T.count; for (let D = P, k = P + L; D < k; D += 3) _(i[D + 0]), _(i[D + 1]), _(i[D + 2]); } } computeVertexNormals() { let e = this.index, t = this.getAttribute('position'); if (t !== void 0) { let i = this.getAttribute('normal'); if (i === void 0) (i = new Xe(new Float32Array(t.count * 3), 3)), this.setAttribute('normal', i); else for (let c = 0, d = i.count; c < d; c++) i.setXYZ(c, 0, 0, 0); let r = new E(), s = new E(), n = new E(), a = new E(), o = new E(), l = new E(), h = new E(), u = new E(); if (e) for (let c = 0, d = e.count; c < d; c += 3) { let p = e.getX(c + 0), f = e.getX(c + 1), g = e.getX(c + 2); r.fromBufferAttribute(t, p), s.fromBufferAttribute(t, f), n.fromBufferAttribute(t, g), h.subVectors(n, s), u.subVectors(r, s), h.cross(u), a.fromBufferAttribute(i, p), o.fromBufferAttribute(i, f), l.fromBufferAttribute(i, g), a.add(h), o.add(h), l.add(h), i.setXYZ(p, a.x, a.y, a.z), i.setXYZ(f, o.x, o.y, o.z), i.setXYZ(g, l.x, l.y, l.z); } else for (let c = 0, d = t.count; c < d; c += 3) r.fromBufferAttribute(t, c + 0), s.fromBufferAttribute(t, c + 1), n.fromBufferAttribute(t, c + 2), h.subVectors(n, s), u.subVectors(r, s), h.cross(u), i.setXYZ(c + 0, h.x, h.y, h.z), i.setXYZ(c + 1, h.x, h.y, h.z), i.setXYZ(c + 2, h.x, h.y, h.z); this.normalizeNormals(), (i.needsUpdate = !0); } } merge() { return ( console.error('THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead.'), this ); } normalizeNormals() { let e = this.attributes.normal; for (let t = 0, i = e.count; t < i; t++) oi.fromBufferAttribute(e, t), oi.normalize(), e.setXYZ(t, oi.x, oi.y, oi.z); } toNonIndexed() { function e(a, o) { let l = a.array, h = a.itemSize, u = a.normalized, c = new l.constructor(o.length * h), d = 0, p = 0; for (let f = 0, g = o.length; f < g; f++) { a.isInterleavedBufferAttribute ? (d = o[f] * a.data.stride + a.offset) : (d = o[f] * h); for (let m = 0; m < h; m++) c[p++] = l[d++]; } return new Xe(c, h, u); } if (this.index === null) return console.warn('THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.'), this; let t = new Ve(), i = this.index.array, r = this.attributes; for (let a in r) { let o = r[a], l = e(o, i); t.setAttribute(a, l); } let s = this.morphAttributes; for (let a in s) { let o = [], l = s[a]; for (let h = 0, u = l.length; h < u; h++) { let c = l[h], d = e(c, i); o.push(d); } t.morphAttributes[a] = o; } t.morphTargetsRelative = this.morphTargetsRelative; let n = this.groups; for (let a = 0, o = n.length; a < o; a++) { let l = n[a]; t.addGroup(l.start, l.count, l.materialIndex); } return t; } toJSON() { let e = { metadata: { version: 4.5, type: 'BufferGeometry', generator: 'BufferGeometry.toJSON' } }; if ( ((e.uuid = this.uuid), (e.type = this.type), this.name !== '' && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) ) { let o = this.parameters; for (let l in o) o[l] !== void 0 && (e[l] = o[l]); return e; } e.data = { attributes: {} }; let t = this.index; t !== null && (e.data.index = { type: t.array.constructor.name, array: Array.prototype.slice.call(t.array) }); let i = this.attributes; for (let o in i) { let l = i[o]; e.data.attributes[o] = l.toJSON(e.data); } let r = {}, s = !1; for (let o in this.morphAttributes) { let l = this.morphAttributes[o], h = []; for (let u = 0, c = l.length; u < c; u++) { let d = l[u]; h.push(d.toJSON(e.data)); } h.length > 0 && ((r[o] = h), (s = !0)); } s && ((e.data.morphAttributes = r), (e.data.morphTargetsRelative = this.morphTargetsRelative)); let n = this.groups; n.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(n))); let a = this.boundingSphere; return a !== null && (e.data.boundingSphere = { center: a.center.toArray(), radius: a.radius }), e; } clone() { return new this.constructor().copy(this); } copy(e) { (this.index = null), (this.attributes = {}), (this.morphAttributes = {}), (this.groups = []), (this.boundingBox = null), (this.boundingSphere = null); let t = {}; this.name = e.name; let i = e.index; i !== null && this.setIndex(i.clone(t)); let r = e.attributes; for (let l in r) { let h = r[l]; this.setAttribute(l, h.clone(t)); } let s = e.morphAttributes; for (let l in s) { let h = [], u = s[l]; for (let c = 0, d = u.length; c < d; c++) h.push(u[c].clone(t)); this.morphAttributes[l] = h; } this.morphTargetsRelative = e.morphTargetsRelative; let n = e.groups; for (let l = 0, h = n.length; l < h; l++) { let u = n[l]; this.addGroup(u.start, u.count, u.materialIndex); } let a = e.boundingBox; a !== null && (this.boundingBox = a.clone()); let o = e.boundingSphere; return ( o !== null && (this.boundingSphere = o.clone()), (this.drawRange.start = e.drawRange.start), (this.drawRange.count = e.drawRange.count), (this.userData = e.userData), e.parameters !== void 0 && (this.parameters = Object.assign({}, e.parameters)), this ); } dispose() { this.dispatchEvent({ type: 'dispose' }); } }, G0 = new ve(), Va = new Xo(), mp = new Mr(), ml = new E(), gl = new E(), vl = new E(), gp = new E(), tc = new E(), ic = new G(), rc = new G(), sc = new G(), vp = new E(), nc = new E(), tr = class extends bt { constructor(e = new Ve(), t = new Ph()) { super(), (this.isMesh = !0), (this.type = 'Mesh'), (this.geometry = e), (this.material = t), this.updateMorphTargets(); } copy(e, t) { return ( super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), (this.material = e.material), (this.geometry = e.geometry), this ); } updateMorphTargets() { let e = this.geometry.morphAttributes, t = Object.keys(e); if (t.length > 0) { let i = e[t[0]]; if (i !== void 0) { (this.morphTargetInfluences = []), (this.morphTargetDictionary = {}); for (let r = 0, s = i.length; r < s; r++) { let n = i[r].name || String(r); this.morphTargetInfluences.push(0), (this.morphTargetDictionary[n] = r); } } } } getVertexPosition(e, t) { let i = this.geometry, r = i.attributes.position, s = i.morphAttributes.position, n = i.morphTargetsRelative; t.fromBufferAttribute(r, e); let a = this.morphTargetInfluences; if (s && a) { tc.set(0, 0, 0); for (let o = 0, l = s.length; o < l; o++) { let h = a[o], u = s[o]; h !== 0 && (gp.fromBufferAttribute(u, e), n ? tc.addScaledVector(gp, h) : tc.addScaledVector(gp.sub(t), h)); } t.add(tc); } return this.isSkinnedMesh && this.boneTransform(e, t), t; } raycast(e, t) { let i = this.geometry, r = this.material, s = this.matrixWorld; if ( r === void 0 || (i.boundingSphere === null && i.computeBoundingSphere(), mp.copy(i.boundingSphere), mp.applyMatrix4(s), e.ray.intersectsSphere(mp) === !1) || (G0.copy(s).invert(), Va.copy(e.ray).applyMatrix4(G0), i.boundingBox !== null && Va.intersectsBox(i.boundingBox) === !1) ) return; let n, a = i.index, o = i.attributes.position, l = i.attributes.uv, h = i.attributes.uv2, u = i.groups, c = i.drawRange; if (a !== null) if (Array.isArray(r)) for (let d = 0, p = u.length; d < p; d++) { let f = u[d], g = r[f.materialIndex], m = Math.max(f.start, c.start), v = Math.min(a.count, Math.min(f.start + f.count, c.start + c.count)); for (let y = m, b = v; y < b; y += 3) { let x = a.getX(y), w = a.getX(y + 1), A = a.getX(y + 2); (n = ac(this, g, e, Va, l, h, x, w, A)), n && ((n.faceIndex = Math.floor(y / 3)), (n.face.materialIndex = f.materialIndex), t.push(n)); } } else { let d = Math.max(0, c.start), p = Math.min(a.count, c.start + c.count); for (let f = d, g = p; f < g; f += 3) { let m = a.getX(f), v = a.getX(f + 1), y = a.getX(f + 2); (n = ac(this, r, e, Va, l, h, m, v, y)), n && ((n.faceIndex = Math.floor(f / 3)), t.push(n)); } } else if (o !== void 0) if (Array.isArray(r)) for (let d = 0, p = u.length; d < p; d++) { let f = u[d], g = r[f.materialIndex], m = Math.max(f.start, c.start), v = Math.min(o.count, Math.min(f.start + f.count, c.start + c.count)); for (let y = m, b = v; y < b; y += 3) { let x = y, w = y + 1, A = y + 2; (n = ac(this, g, e, Va, l, h, x, w, A)), n && ((n.faceIndex = Math.floor(y / 3)), (n.face.materialIndex = f.materialIndex), t.push(n)); } } else { let d = Math.max(0, c.start), p = Math.min(o.count, c.start + c.count); for (let f = d, g = p; f < g; f += 3) { let m = f, v = f + 1, y = f + 2; (n = ac(this, r, e, Va, l, h, m, v, y)), n && ((n.faceIndex = Math.floor(f / 3)), t.push(n)); } } } }; function fE(e, t, i, r, s, n, a, o) { let l; if ((t.side === hi ? (l = r.intersectTriangle(a, n, s, !0, o)) : (l = r.intersectTriangle(s, n, a, t.side === Vr, o)), l === null)) return null; nc.copy(o), nc.applyMatrix4(e.matrixWorld); let h = i.ray.origin.distanceTo(nc); return h < i.near || h > i.far ? null : { distance: h, point: nc.clone(), object: e }; } function ac(e, t, i, r, s, n, a, o, l) { e.getVertexPosition(a, ml), e.getVertexPosition(o, gl), e.getVertexPosition(l, vl); let h = fE(e, t, i, r, ml, gl, vl, vp); if (h) { s && (ic.fromBufferAttribute(s, a), rc.fromBufferAttribute(s, o), sc.fromBufferAttribute(s, l), (h.uv = Bi.getUV(vp, ml, gl, vl, ic, rc, sc, new G()))), n && (ic.fromBufferAttribute(n, a), rc.fromBufferAttribute(n, o), sc.fromBufferAttribute(n, l), (h.uv2 = Bi.getUV(vp, ml, gl, vl, ic, rc, sc, new G()))); let u = { a: a, b: o, c: l, normal: new E(), materialIndex: 0 }; Bi.getNormal(ml, gl, vl, u.normal), (h.face = u); } return h; } var vs = class extends Ve { constructor(e = 1, t = 1, i = 1, r = 1, s = 1, n = 1) { super(), (this.type = 'BoxGeometry'), (this.parameters = { width: e, height: t, depth: i, widthSegments: r, heightSegments: s, depthSegments: n }); let a = this; (r = Math.floor(r)), (s = Math.floor(s)), (n = Math.floor(n)); let o = [], l = [], h = [], u = [], c = 0, d = 0; p('z', 'y', 'x', -1, -1, i, t, e, n, s, 0), p('z', 'y', 'x', 1, -1, i, t, -e, n, s, 1), p('x', 'z', 'y', 1, 1, e, i, t, r, n, 2), p('x', 'z', 'y', 1, -1, e, i, -t, r, n, 3), p('x', 'y', 'z', 1, -1, e, t, i, r, s, 4), p('x', 'y', 'z', -1, -1, e, t, -i, r, s, 5), this.setIndex(o), this.setAttribute('position', new Ce(l, 3)), this.setAttribute('normal', new Ce(h, 3)), this.setAttribute('uv', new Ce(u, 2)); function p(f, g, m, v, y, b, x, w, A, S, _) { let M = b / A, C = x / S, T = b / 2, P = x / 2, L = w / 2, D = A + 1, k = S + 1, W = 0, X = 0, z = new E(); for (let j = 0; j < k; j++) { let U = j * C - P; for (let N = 0; N < D; N++) { let B = N * M - T; (z[f] = B * v), (z[g] = U * y), (z[m] = L), l.push(z.x, z.y, z.z), (z[f] = 0), (z[g] = 0), (z[m] = w > 0 ? 1 : -1), h.push(z.x, z.y, z.z), u.push(N / A), u.push(1 - j / S), (W += 1); } } for (let j = 0; j < S; j++) for (let U = 0; U < A; U++) { let N = c + U + D * j, B = c + U + D * (j + 1), H = c + (U + 1) + D * (j + 1), Q = c + (U + 1) + D * j; o.push(N, B, Q), o.push(B, H, Q), (X += 6); } a.addGroup(d, X, _), (d += X), (c += W); } } static fromJSON(e) { return new vs(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments); } }; function zo(e) { let t = {}; for (let i in e) { t[i] = {}; for (let r in e[i]) { let s = e[i][r]; s && (s.isColor || s.isMatrix3 || s.isMatrix4 || s.isVector2 || s.isVector3 || s.isVector4 || s.isTexture || s.isQuaternion) ? (t[i][r] = s.clone()) : Array.isArray(s) ? (t[i][r] = s.slice()) : (t[i][r] = s); } } return t; } function Li(e) { let t = {}; for (let i = 0; i < e.length; i++) { let r = zo(e[i]); for (let s in r) t[s] = r[s]; } return t; } function mE(e) { let t = []; for (let i = 0; i < e.length; i++) t.push(e[i].clone()); return t; } function vw(e) { return e.getRenderTarget() === null && e.outputEncoding === Ke ? rs : pd; } var qo = { clone: zo, merge: Li }, gE = `void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, vE = `void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`, ri = class extends Th { constructor(e) { super(), (this.isShaderMaterial = !0), (this.type = 'ShaderMaterial'), (this.defines = {}), (this.uniforms = {}), (this.uniformsGroups = []), (this.vertexShader = gE), (this.fragmentShader = vE), (this.linewidth = 1), (this.wireframe = !1), (this.wireframeLinewidth = 1), (this.fog = !1), (this.lights = !1), (this.clipping = !1), (this.extensions = { derivatives: !1, fragDepth: !1, drawBuffers: !1, shaderTextureLOD: !1 }), (this.defaultAttributeValues = { color: [1, 1, 1], uv: [0, 0], uv2: [0, 0] }), (this.index0AttributeName = void 0), (this.uniformsNeedUpdate = !1), (this.glslVersion = null), e !== void 0 && this.setValues(e); } copy(e) { return ( super.copy(e), (this.fragmentShader = e.fragmentShader), (this.vertexShader = e.vertexShader), (this.uniforms = zo(e.uniforms)), (this.uniformsGroups = mE(e.uniformsGroups)), (this.defines = Object.assign({}, e.defines)), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), (this.fog = e.fog), (this.lights = e.lights), (this.clipping = e.clipping), (this.extensions = Object.assign({}, e.extensions)), (this.glslVersion = e.glslVersion), this ); } toJSON(e) { let t = super.toJSON(e); (t.glslVersion = this.glslVersion), (t.uniforms = {}); for (let r in this.uniforms) { let s = this.uniforms[r].value; s && s.isTexture ? (t.uniforms[r] = { type: 't', value: s.toJSON(e).uuid }) : s && s.isColor ? (t.uniforms[r] = { type: 'c', value: s.getHex() }) : s && s.isVector2 ? (t.uniforms[r] = { type: 'v2', value: s.toArray() }) : s && s.isVector3 ? (t.uniforms[r] = { type: 'v3', value: s.toArray() }) : s && s.isVector4 ? (t.uniforms[r] = { type: 'v4', value: s.toArray() }) : s && s.isMatrix3 ? (t.uniforms[r] = { type: 'm3', value: s.toArray() }) : s && s.isMatrix4 ? (t.uniforms[r] = { type: 'm4', value: s.toArray() }) : (t.uniforms[r] = { value: s }); } Object.keys(this.defines).length > 0 && (t.defines = this.defines), (t.vertexShader = this.vertexShader), (t.fragmentShader = this.fragmentShader); let i = {}; for (let r in this.extensions) this.extensions[r] === !0 && (i[r] = !0); return Object.keys(i).length > 0 && (t.extensions = i), t; } }, Yo = class extends bt { constructor() { super(), (this.isCamera = !0), (this.type = 'Camera'), (this.matrixWorldInverse = new ve()), (this.projectionMatrix = new ve()), (this.projectionMatrixInverse = new ve()); } copy(e, t) { return ( super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this ); } getWorldDirection(e) { this.updateWorldMatrix(!0, !1); let t = this.matrixWorld.elements; return e.set(-t[8], -t[9], -t[10]).normalize(); } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } updateWorldMatrix(e, t) { super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } clone() { return new this.constructor().copy(this); } }, wi = class extends Yo { constructor(e = 50, t = 1, i = 0.1, r = 2e3) { super(), (this.isPerspectiveCamera = !0), (this.type = 'PerspectiveCamera'), (this.fov = e), (this.zoom = 1), (this.near = i), (this.far = r), (this.focus = 10), (this.aspect = t), (this.view = null), (this.filmGauge = 35), (this.filmOffset = 0), this.updateProjectionMatrix(); } copy(e, t) { return ( super.copy(e, t), (this.fov = e.fov), (this.zoom = e.zoom), (this.near = e.near), (this.far = e.far), (this.focus = e.focus), (this.aspect = e.aspect), (this.view = e.view === null ? null : Object.assign({}, e.view)), (this.filmGauge = e.filmGauge), (this.filmOffset = e.filmOffset), this ); } setFocalLength(e) { let t = (0.5 * this.getFilmHeight()) / e; (this.fov = hh * 2 * Math.atan(t)), this.updateProjectionMatrix(); } getFocalLength() { let e = Math.tan(Ql * 0.5 * this.fov); return (0.5 * this.getFilmHeight()) / e; } getEffectiveFOV() { return hh * 2 * Math.atan(Math.tan(Ql * 0.5 * this.fov) / this.zoom); } getFilmWidth() { return this.filmGauge * Math.min(this.aspect, 1); } getFilmHeight() { return this.filmGauge / Math.max(this.aspect, 1); } setViewOffset(e, t, i, r, s, n) { (this.aspect = e / t), this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }), (this.view.enabled = !0), (this.view.fullWidth = e), (this.view.fullHeight = t), (this.view.offsetX = i), (this.view.offsetY = r), (this.view.width = s), (this.view.height = n), this.updateProjectionMatrix(); } clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } updateProjectionMatrix() { let e = this.near, t = (e * Math.tan(Ql * 0.5 * this.fov)) / this.zoom, i = 2 * t, r = this.aspect * i, s = -0.5 * r, n = this.view; if (this.view !== null && this.view.enabled) { let o = n.fullWidth, l = n.fullHeight; (s += (n.offsetX * r) / o), (t -= (n.offsetY * i) / l), (r *= n.width / o), (i *= n.height / l); } let a = this.filmOffset; a !== 0 && (s += (e * a) / this.getFilmWidth()), this.projectionMatrix.makePerspective(s, s + r, t, t - i, e, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); } toJSON(e) { let t = super.toJSON(e); return ( (t.object.fov = this.fov), (t.object.zoom = this.zoom), (t.object.near = this.near), (t.object.far = this.far), (t.object.focus = this.focus), (t.object.aspect = this.aspect), this.view !== null && (t.object.view = Object.assign({}, this.view)), (t.object.filmGauge = this.filmGauge), (t.object.filmOffset = this.filmOffset), t ); } }, Ha = -90, Wa = 1, yE = class extends bt { constructor(e, t, i) { super(), (this.type = 'CubeCamera'), (this.renderTarget = i); let r = new wi(Ha, Wa, e, t); (r.layers = this.layers), r.up.set(0, 1, 0), r.lookAt(1, 0, 0), this.add(r); let s = new wi(Ha, Wa, e, t); (s.layers = this.layers), s.up.set(0, 1, 0), s.lookAt(-1, 0, 0), this.add(s); let n = new wi(Ha, Wa, e, t); (n.layers = this.layers), n.up.set(0, 0, -1), n.lookAt(0, 1, 0), this.add(n); let a = new wi(Ha, Wa, e, t); (a.layers = this.layers), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), this.add(a); let o = new wi(Ha, Wa, e, t); (o.layers = this.layers), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), this.add(o); let l = new wi(Ha, Wa, e, t); (l.layers = this.layers), l.up.set(0, 1, 0), l.lookAt(0, 0, -1), this.add(l); } update(e, t) { this.parent === null && this.updateMatrixWorld(); let i = this.renderTarget, [r, s, n, a, o, l] = this.children, h = e.getRenderTarget(), u = e.toneMapping, c = e.xr.enabled; (e.toneMapping = Gs), (e.xr.enabled = !1); let d = i.texture.generateMipmaps; (i.texture.generateMipmaps = !1), e.setRenderTarget(i, 0), e.render(t, r), e.setRenderTarget(i, 1), e.render(t, s), e.setRenderTarget(i, 2), e.render(t, n), e.setRenderTarget(i, 3), e.render(t, a), e.setRenderTarget(i, 4), e.render(t, o), (i.texture.generateMipmaps = d), e.setRenderTarget(i, 5), e.render(t, l), e.setRenderTarget(h), (e.toneMapping = u), (e.xr.enabled = c), (i.texture.needsPMREMUpdate = !0); } }, cg = class extends ci { constructor(e, t, i, r, s, n, a, o, l, h) { (e = e !== void 0 ? e : []), (t = t !== void 0 ? t : ya), super(e, t, i, r, s, n, a, o, l, h), (this.isCubeTexture = !0), (this.flipY = !1); } get images() { return this.image; } set images(e) { this.image = e; } }, xE = class extends ii { constructor(e = 1, t = {}) { super(e, e, t), (this.isWebGLCubeRenderTarget = !0); let i = { width: e, height: e, depth: 1 }, r = [i, i, i, i, i, i]; (this.texture = new cg(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.encoding)), (this.texture.isRenderTargetTexture = !0), (this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1), (this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : mt); } fromEquirectangularTexture(e, t) { (this.texture.type = t.type), (this.texture.encoding = t.encoding), (this.texture.generateMipmaps = t.generateMipmaps), (this.texture.minFilter = t.minFilter), (this.texture.magFilter = t.magFilter); let i = { uniforms: { tEquirect: { value: null } }, vertexShader: ` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `, fragmentShader: ` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } ` }, r = new vs(5, 5, 5), s = new ri({ name: 'CubemapFromEquirect', uniforms: zo(i.uniforms), vertexShader: i.vertexShader, fragmentShader: i.fragmentShader, side: hi, blending: fi }); s.uniforms.tEquirect.value = t; let n = new tr(r, s), a = t.minFilter; return ( t.minFilter === Bo && (t.minFilter = mt), new yE(1, 10, this).update(e, n), (t.minFilter = a), n.geometry.dispose(), n.material.dispose(), this ); } clear(e, t, i, r) { let s = e.getRenderTarget(); for (let n = 0; n < 6; n++) e.setRenderTarget(this, n), e.clear(t, i, r); e.setRenderTarget(s); } }, yp = new E(), bE = new E(), wE = new Ai(), yr = class { constructor(e = new E(1, 0, 0), t = 0) { (this.isPlane = !0), (this.normal = e), (this.constant = t); } set(e, t) { return this.normal.copy(e), (this.constant = t), this; } setComponents(e, t, i, r) { return this.normal.set(e, t, i), (this.constant = r), this; } setFromNormalAndCoplanarPoint(e, t) { return this.normal.copy(e), (this.constant = -t.dot(this.normal)), this; } setFromCoplanarPoints(e, t, i) { let r = yp.subVectors(i, t).cross(bE.subVectors(e, t)).normalize(); return this.setFromNormalAndCoplanarPoint(r, e), this; } copy(e) { return this.normal.copy(e.normal), (this.constant = e.constant), this; } normalize() { let e = 1 / this.normal.length(); return this.normal.multiplyScalar(e), (this.constant *= e), this; } negate() { return (this.constant *= -1), this.normal.negate(), this; } distanceToPoint(e) { return this.normal.dot(e) + this.constant; } distanceToSphere(e) { return this.distanceToPoint(e.center) - e.radius; } projectPoint(e, t) { return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e); } intersectLine(e, t) { let i = e.delta(yp), r = this.normal.dot(i); if (r === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; let s = -(e.start.dot(this.normal) + this.constant) / r; return s < 0 || s > 1 ? null : t.copy(i).multiplyScalar(s).add(e.start); } intersectsLine(e) { let t = this.distanceToPoint(e.start), i = this.distanceToPoint(e.end); return (t < 0 && i > 0) || (i < 0 && t > 0); } intersectsBox(e) { return e.intersectsPlane(this); } intersectsSphere(e) { return e.intersectsPlane(this); } coplanarPoint(e) { return e.copy(this.normal).multiplyScalar(-this.constant); } applyMatrix4(e, t) { let i = t || wE.getNormalMatrix(e), r = this.coplanarPoint(yp).applyMatrix4(e), s = this.normal.applyMatrix3(i).normalize(); return (this.constant = -r.dot(s)), this; } translate(e) { return (this.constant -= e.dot(this.normal)), this; } equals(e) { return e.normal.equals(this.normal) && e.constant === this.constant; } clone() { return new this.constructor().copy(this); } }, Xa = new Mr(), oc = new E(), dg = class { constructor(e = new yr(), t = new yr(), i = new yr(), r = new yr(), s = new yr(), n = new yr()) { this.planes = [e, t, i, r, s, n]; } set(e, t, i, r, s, n) { let a = this.planes; return a[0].copy(e), a[1].copy(t), a[2].copy(i), a[3].copy(r), a[4].copy(s), a[5].copy(n), this; } copy(e) { let t = this.planes; for (let i = 0; i < 6; i++) t[i].copy(e.planes[i]); return this; } setFromProjectionMatrix(e) { let t = this.planes, i = e.elements, r = i[0], s = i[1], n = i[2], a = i[3], o = i[4], l = i[5], h = i[6], u = i[7], c = i[8], d = i[9], p = i[10], f = i[11], g = i[12], m = i[13], v = i[14], y = i[15]; return ( t[0].setComponents(a - r, u - o, f - c, y - g).normalize(), t[1].setComponents(a + r, u + o, f + c, y + g).normalize(), t[2].setComponents(a + s, u + l, f + d, y + m).normalize(), t[3].setComponents(a - s, u - l, f - d, y - m).normalize(), t[4].setComponents(a - n, u - h, f - p, y - v).normalize(), t[5].setComponents(a + n, u + h, f + p, y + v).normalize(), this ); } intersectsObject(e) { let t = e.geometry; return ( t.boundingSphere === null && t.computeBoundingSphere(), Xa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld), this.intersectsSphere(Xa) ); } intersectsSprite(e) { return Xa.center.set(0, 0, 0), (Xa.radius = 0.7071067811865476), Xa.applyMatrix4(e.matrixWorld), this.intersectsSphere(Xa); } intersectsSphere(e) { let t = this.planes, i = e.center, r = -e.radius; for (let s = 0; s < 6; s++) if (t[s].distanceToPoint(i) < r) return !1; return !0; } intersectsBox(e) { let t = this.planes; for (let i = 0; i < 6; i++) { let r = t[i]; if ( ((oc.x = r.normal.x > 0 ? e.max.x : e.min.x), (oc.y = r.normal.y > 0 ? e.max.y : e.min.y), (oc.z = r.normal.z > 0 ? e.max.z : e.min.z), r.distanceToPoint(oc) < 0) ) return !1; } return !0; } containsPoint(e) { let t = this.planes; for (let i = 0; i < 6; i++) if (t[i].distanceToPoint(e) < 0) return !1; return !0; } clone() { return new this.constructor().copy(this); } }; function yw() { let e = null, t = !1, i = null, r = null; function s(n, a) { i(n, a), (r = e.requestAnimationFrame(s)); } return { start: function () { t !== !0 && i !== null && ((r = e.requestAnimationFrame(s)), (t = !0)); }, stop: function () { e.cancelAnimationFrame(r), (t = !1); }, setAnimationLoop: function (n) { i = n; }, setContext: function (n) { e = n; } }; } function _E(e, t) { let i = t.isWebGL2, r = new WeakMap(); function s(h, u) { let c = h.array, d = h.usage, p = e.createBuffer(); e.bindBuffer(u, p), e.bufferData(u, c, d), h.onUploadCallback(); let f; if (c instanceof Float32Array) f = 5126; else if (c instanceof Uint16Array) if (h.isFloat16BufferAttribute) if (i) f = 5131; else throw new Error('THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.'); else f = 5123; else if (c instanceof Int16Array) f = 5122; else if (c instanceof Uint32Array) f = 5125; else if (c instanceof Int32Array) f = 5124; else if (c instanceof Int8Array) f = 5120; else if (c instanceof Uint8Array) f = 5121; else if (c instanceof Uint8ClampedArray) f = 5121; else throw new Error('THREE.WebGLAttributes: Unsupported buffer data format: ' + c); return { buffer: p, type: f, bytesPerElement: c.BYTES_PER_ELEMENT, version: h.version }; } function n(h, u, c) { let d = u.array, p = u.updateRange; e.bindBuffer(c, h), p.count === -1 ? e.bufferSubData(c, 0, d) : (i ? e.bufferSubData(c, p.offset * d.BYTES_PER_ELEMENT, d, p.offset, p.count) : e.bufferSubData(c, p.offset * d.BYTES_PER_ELEMENT, d.subarray(p.offset, p.offset + p.count)), (p.count = -1)), u.onUploadCallback(); } function a(h) { return h.isInterleavedBufferAttribute && (h = h.data), r.get(h); } function o(h) { h.isInterleavedBufferAttribute && (h = h.data); let u = r.get(h); u && (e.deleteBuffer(u.buffer), r.delete(h)); } function l(h, u) { if (h.isGLBufferAttribute) { let d = r.get(h); (!d || d.version < h.version) && r.set(h, { buffer: h.buffer, type: h.type, bytesPerElement: h.elementSize, version: h.version }); return; } h.isInterleavedBufferAttribute && (h = h.data); let c = r.get(h); c === void 0 ? r.set(h, s(h, u)) : c.version < h.version && (n(c.buffer, h, u), (c.version = h.version)); } return { get: a, remove: o, update: l }; } var ou = class extends Ve { constructor(e = 1, t = 1, i = 1, r = 1) { super(), (this.type = 'PlaneGeometry'), (this.parameters = { width: e, height: t, widthSegments: i, heightSegments: r }); let s = e / 2, n = t / 2, a = Math.floor(i), o = Math.floor(r), l = a + 1, h = o + 1, u = e / a, c = t / o, d = [], p = [], f = [], g = []; for (let m = 0; m < h; m++) { let v = m * c - n; for (let y = 0; y < l; y++) { let b = y * u - s; p.push(b, -v, 0), f.push(0, 0, 1), g.push(y / a), g.push(1 - m / o); } } for (let m = 0; m < o; m++) for (let v = 0; v < a; v++) { let y = v + l * m, b = v + l * (m + 1), x = v + 1 + l * (m + 1), w = v + 1 + l * m; d.push(y, b, w), d.push(b, x, w); } this.setIndex(d), this.setAttribute('position', new Ce(p, 3)), this.setAttribute('normal', new Ce(f, 3)), this.setAttribute('uv', new Ce(g, 2)); } static fromJSON(e) { return new ou(e.width, e.height, e.widthSegments, e.heightSegments); } }, AE = `#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vUv ).g; #endif`, SE = `#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`, ME = `#ifdef USE_ALPHATEST if ( diffuseColor.a < alphaTest ) discard; #endif`, EE = `#ifdef USE_ALPHATEST uniform float alphaTest; #endif`, CE = `#ifdef USE_AOMAP float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_ENVMAP ) && defined( STANDARD ) float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif #endif`, TE = `#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`, PE = 'vec3 transformed = vec3( position );', DE = `vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`, LE = `vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) { float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #ifdef USE_IRIDESCENCE vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) { float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif`, OE = `#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`, IE = `#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`, RE = `#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`, BE = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`, zE = `#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`, NE = `#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`, UE = `#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`, FE = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`, kE = `#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`, jE = `#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`, GE = `#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); }`, VE = `#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`, HE = `vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`, WE = `#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`, XE = `#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`, qE = `#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`, YE = `#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`, QE = 'gl_FragColor = linearToOutputTexel( gl_FragColor );', ZE = `vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`, KE = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`, JE = `#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`, $E = `#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`, eC = `#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`, tC = `#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`, iC = `#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`, rC = `#ifdef USE_FOG varying float vFogDepth; #endif`, sC = `#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`, nC = `#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`, aC = `#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`, oC = `#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`, lC = `#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`, hC = `LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`, cC = `varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`, dC = `uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( PHYSICALLY_CORRECT_LIGHTS ) float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`, uC = `#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`, pC = `ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`, fC = `varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`, mC = `BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`, gC = `varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`, vC = `PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`, yC = `struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`, xC = ` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`, bC = `#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`, wC = `#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`, _C = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`, AC = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`, SC = `#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`, MC = `#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`, EC = `#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`, CC = `#ifdef USE_MAP uniform sampler2D map; #endif`, TC = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`, PC = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`, DC = `float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`, LC = `#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`, OC = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`, IC = `#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`, RC = `#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`, BC = `#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`, zC = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`, NC = `#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`, UC = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, FC = `#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`, kC = `#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`, jC = `#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`, GC = `#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`, VC = `#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`, HC = `#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`, WC = `#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`, XC = `#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, qC = `vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`, YC = `#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`, QC = `vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`, ZC = `#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`, KC = `#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`, JC = `float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`, $C = `#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`, eT = `#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`, tT = `#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`, iT = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`, rT = `float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`, sT = `#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`, nT = `#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`, aT = `#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`, oT = `#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`, lT = `float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`, hT = `#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`, cT = `#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`, dT = `#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`, uT = `#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`, pT = `#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`, fT = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`, mT = `#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`, gT = `#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`, vT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`, yT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`, xT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`, bT = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`, wT = `varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`, _T = `uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`, AT = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, ST = `#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`, MT = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`, ET = `uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`, CT = `#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`, TT = `#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`, PT = `#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`, DT = `#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`, LT = `varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`, OT = `uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`, IT = `uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`, RT = `uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, BT = `#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`, zT = `uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`, NT = `#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`, UT = `#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, FT = `#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`, kT = `#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`, jT = `#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`, GT = `#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`, VT = `#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`, HT = `#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`, WT = `#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`, XT = `#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`, qT = `#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`, YT = `#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`, QT = `uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`, ZT = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`, KT = `#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`, JT = `uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`, $T = `uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`, e3 = `uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`, Ze = { alphamap_fragment: AE, alphamap_pars_fragment: SE, alphatest_fragment: ME, alphatest_pars_fragment: EE, aomap_fragment: CE, aomap_pars_fragment: TE, begin_vertex: PE, beginnormal_vertex: DE, bsdfs: LE, iridescence_fragment: OE, bumpmap_pars_fragment: IE, clipping_planes_fragment: RE, clipping_planes_pars_fragment: BE, clipping_planes_pars_vertex: zE, clipping_planes_vertex: NE, color_fragment: UE, color_pars_fragment: FE, color_pars_vertex: kE, color_vertex: jE, common: GE, cube_uv_reflection_fragment: VE, defaultnormal_vertex: HE, displacementmap_pars_vertex: WE, displacementmap_vertex: XE, emissivemap_fragment: qE, emissivemap_pars_fragment: YE, encodings_fragment: QE, encodings_pars_fragment: ZE, envmap_fragment: KE, envmap_common_pars_fragment: JE, envmap_pars_fragment: $E, envmap_pars_vertex: eC, envmap_physical_pars_fragment: uC, envmap_vertex: tC, fog_vertex: iC, fog_pars_vertex: rC, fog_fragment: sC, fog_pars_fragment: nC, gradientmap_pars_fragment: aC, lightmap_fragment: oC, lightmap_pars_fragment: lC, lights_lambert_fragment: hC, lights_lambert_pars_fragment: cC, lights_pars_begin: dC, lights_toon_fragment: pC, lights_toon_pars_fragment: fC, lights_phong_fragment: mC, lights_phong_pars_fragment: gC, lights_physical_fragment: vC, lights_physical_pars_fragment: yC, lights_fragment_begin: xC, lights_fragment_maps: bC, lights_fragment_end: wC, logdepthbuf_fragment: _C, logdepthbuf_pars_fragment: AC, logdepthbuf_pars_vertex: SC, logdepthbuf_vertex: MC, map_fragment: EC, map_pars_fragment: CC, map_particle_fragment: TC, map_particle_pars_fragment: PC, metalnessmap_fragment: DC, metalnessmap_pars_fragment: LC, morphcolor_vertex: OC, morphnormal_vertex: IC, morphtarget_pars_vertex: RC, morphtarget_vertex: BC, normal_fragment_begin: zC, normal_fragment_maps: NC, normal_pars_fragment: UC, normal_pars_vertex: FC, normal_vertex: kC, normalmap_pars_fragment: jC, clearcoat_normal_fragment_begin: GC, clearcoat_normal_fragment_maps: VC, clearcoat_pars_fragment: HC, iridescence_pars_fragment: WC, output_fragment: XC, packing: qC, premultiplied_alpha_fragment: YC, project_vertex: QC, dithering_fragment: ZC, dithering_pars_fragment: KC, roughnessmap_fragment: JC, roughnessmap_pars_fragment: $C, shadowmap_pars_fragment: eT, shadowmap_pars_vertex: tT, shadowmap_vertex: iT, shadowmask_pars_fragment: rT, skinbase_vertex: sT, skinning_pars_vertex: nT, skinning_vertex: aT, skinnormal_vertex: oT, specularmap_fragment: lT, specularmap_pars_fragment: hT, tonemapping_fragment: cT, tonemapping_pars_fragment: dT, transmission_fragment: uT, transmission_pars_fragment: pT, uv_pars_fragment: fT, uv_pars_vertex: mT, uv_vertex: gT, uv2_pars_fragment: vT, uv2_pars_vertex: yT, uv2_vertex: xT, worldpos_vertex: bT, background_vert: wT, background_frag: _T, backgroundCube_vert: AT, backgroundCube_frag: ST, cube_vert: MT, cube_frag: ET, depth_vert: CT, depth_frag: TT, distanceRGBA_vert: PT, distanceRGBA_frag: DT, equirect_vert: LT, equirect_frag: OT, linedashed_vert: IT, linedashed_frag: RT, meshbasic_vert: BT, meshbasic_frag: zT, meshlambert_vert: NT, meshlambert_frag: UT, meshmatcap_vert: FT, meshmatcap_frag: kT, meshnormal_vert: jT, meshnormal_frag: GT, meshphong_vert: VT, meshphong_frag: HT, meshphysical_vert: WT, meshphysical_frag: XT, meshtoon_vert: qT, meshtoon_frag: YT, points_vert: QT, points_frag: ZT, shadow_vert: KT, shadow_frag: JT, sprite_vert: $T, sprite_frag: e3 }, ge = { common: { diffuse: { value: new Ge(16777215) }, opacity: { value: 1 }, map: { value: null }, uvTransform: { value: new Ai() }, uv2Transform: { value: new Ai() }, alphaMap: { value: null }, alphaTest: { value: 0 } }, specularmap: { specularMap: { value: null } }, envmap: { envMap: { value: null }, flipEnvMap: { value: -1 }, reflectivity: { value: 1 }, ior: { value: 1.5 }, refractionRatio: { value: 0.98 } }, aomap: { aoMap: { value: null }, aoMapIntensity: { value: 1 } }, lightmap: { lightMap: { value: null }, lightMapIntensity: { value: 1 } }, emissivemap: { emissiveMap: { value: null } }, bumpmap: { bumpMap: { value: null }, bumpScale: { value: 1 } }, normalmap: { normalMap: { value: null }, normalScale: { value: new G(1, 1) } }, displacementmap: { displacementMap: { value: null }, displacementScale: { value: 1 }, displacementBias: { value: 0 } }, roughnessmap: { roughnessMap: { value: null } }, metalnessmap: { metalnessMap: { value: null } }, gradientmap: { gradientMap: { value: null } }, fog: { fogDensity: { value: 25e-5 }, fogNear: { value: 1 }, fogFar: { value: 2e3 }, fogColor: { value: new Ge(16777215) } }, lights: { ambientLightColor: { value: [] }, lightProbe: { value: [] }, directionalLights: { value: [], properties: { direction: {}, color: {} } }, directionalLightShadows: { value: [], properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } }, directionalShadowMap: { value: [] }, directionalShadowMatrix: { value: [] }, spotLights: { value: [], properties: { color: {}, position: {}, direction: {}, distance: {}, coneCos: {}, penumbraCos: {}, decay: {} } }, spotLightShadows: { value: [], properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } }, spotLightMap: { value: [] }, spotShadowMap: { value: [] }, spotLightMatrix: { value: [] }, pointLights: { value: [], properties: { color: {}, position: {}, decay: {}, distance: {} } }, pointLightShadows: { value: [], properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {}, shadowCameraNear: {}, shadowCameraFar: {} } }, pointShadowMap: { value: [] }, pointShadowMatrix: { value: [] }, hemisphereLights: { value: [], properties: { direction: {}, skyColor: {}, groundColor: {} } }, rectAreaLights: { value: [], properties: { color: {}, position: {}, width: {}, height: {} } }, ltc_1: { value: null }, ltc_2: { value: null } }, points: { diffuse: { value: new Ge(16777215) }, opacity: { value: 1 }, size: { value: 1 }, scale: { value: 1 }, map: { value: null }, alphaMap: { value: null }, alphaTest: { value: 0 }, uvTransform: { value: new Ai() } }, sprite: { diffuse: { value: new Ge(16777215) }, opacity: { value: 1 }, center: { value: new G(0.5, 0.5) }, rotation: { value: 0 }, map: { value: null }, alphaMap: { value: null }, alphaTest: { value: 0 }, uvTransform: { value: new Ai() } } }, ss = { basic: { uniforms: Li([ge.common, ge.specularmap, ge.envmap, ge.aomap, ge.lightmap, ge.fog]), vertexShader: Ze.meshbasic_vert, fragmentShader: Ze.meshbasic_frag }, lambert: { uniforms: Li([ ge.common, ge.specularmap, ge.envmap, ge.aomap, ge.lightmap, ge.emissivemap, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.fog, ge.lights, { emissive: { value: new Ge(0) } } ]), vertexShader: Ze.meshlambert_vert, fragmentShader: Ze.meshlambert_frag }, phong: { uniforms: Li([ ge.common, ge.specularmap, ge.envmap, ge.aomap, ge.lightmap, ge.emissivemap, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.fog, ge.lights, { emissive: { value: new Ge(0) }, specular: { value: new Ge(1118481) }, shininess: { value: 30 } } ]), vertexShader: Ze.meshphong_vert, fragmentShader: Ze.meshphong_frag }, standard: { uniforms: Li([ ge.common, ge.envmap, ge.aomap, ge.lightmap, ge.emissivemap, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.roughnessmap, ge.metalnessmap, ge.fog, ge.lights, { emissive: { value: new Ge(0) }, roughness: { value: 1 }, metalness: { value: 0 }, envMapIntensity: { value: 1 } } ]), vertexShader: Ze.meshphysical_vert, fragmentShader: Ze.meshphysical_frag }, toon: { uniforms: Li([ ge.common, ge.aomap, ge.lightmap, ge.emissivemap, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.gradientmap, ge.fog, ge.lights, { emissive: { value: new Ge(0) } } ]), vertexShader: Ze.meshtoon_vert, fragmentShader: Ze.meshtoon_frag }, matcap: { uniforms: Li([ge.common, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.fog, { matcap: { value: null } }]), vertexShader: Ze.meshmatcap_vert, fragmentShader: Ze.meshmatcap_frag }, points: { uniforms: Li([ge.points, ge.fog]), vertexShader: Ze.points_vert, fragmentShader: Ze.points_frag }, dashed: { uniforms: Li([ge.common, ge.fog, { scale: { value: 1 }, dashSize: { value: 1 }, totalSize: { value: 2 } }]), vertexShader: Ze.linedashed_vert, fragmentShader: Ze.linedashed_frag }, depth: { uniforms: Li([ge.common, ge.displacementmap]), vertexShader: Ze.depth_vert, fragmentShader: Ze.depth_frag }, normal: { uniforms: Li([ge.common, ge.bumpmap, ge.normalmap, ge.displacementmap, { opacity: { value: 1 } }]), vertexShader: Ze.meshnormal_vert, fragmentShader: Ze.meshnormal_frag }, sprite: { uniforms: Li([ge.sprite, ge.fog]), vertexShader: Ze.sprite_vert, fragmentShader: Ze.sprite_frag }, background: { uniforms: { uvTransform: { value: new Ai() }, t2D: { value: null }, backgroundIntensity: { value: 1 } }, vertexShader: Ze.background_vert, fragmentShader: Ze.background_frag }, backgroundCube: { uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 }, backgroundBlurriness: { value: 0 }, backgroundIntensity: { value: 1 } }, vertexShader: Ze.backgroundCube_vert, fragmentShader: Ze.backgroundCube_frag }, cube: { uniforms: { tCube: { value: null }, tFlip: { value: -1 }, opacity: { value: 1 } }, vertexShader: Ze.cube_vert, fragmentShader: Ze.cube_frag }, equirect: { uniforms: { tEquirect: { value: null } }, vertexShader: Ze.equirect_vert, fragmentShader: Ze.equirect_frag }, distanceRGBA: { uniforms: Li([ ge.common, ge.displacementmap, { referencePosition: { value: new E() }, nearDistance: { value: 1 }, farDistance: { value: 1e3 } } ]), vertexShader: Ze.distanceRGBA_vert, fragmentShader: Ze.distanceRGBA_frag }, shadow: { uniforms: Li([ge.lights, ge.fog, { color: { value: new Ge(0) }, opacity: { value: 1 } }]), vertexShader: Ze.shadow_vert, fragmentShader: Ze.shadow_frag } }; ss.physical = { uniforms: Li([ ss.standard.uniforms, { clearcoat: { value: 0 }, clearcoatMap: { value: null }, clearcoatRoughness: { value: 0 }, clearcoatRoughnessMap: { value: null }, clearcoatNormalScale: { value: new G(1, 1) }, clearcoatNormalMap: { value: null }, iridescence: { value: 0 }, iridescenceMap: { value: null }, iridescenceIOR: { value: 1.3 }, iridescenceThicknessMinimum: { value: 100 }, iridescenceThicknessMaximum: { value: 400 }, iridescenceThicknessMap: { value: null }, sheen: { value: 0 }, sheenColor: { value: new Ge(0) }, sheenColorMap: { value: null }, sheenRoughness: { value: 1 }, sheenRoughnessMap: { value: null }, transmission: { value: 0 }, transmissionMap: { value: null }, transmissionSamplerSize: { value: new G() }, transmissionSamplerMap: { value: null }, thickness: { value: 0 }, thicknessMap: { value: null }, attenuationDistance: { value: 0 }, attenuationColor: { value: new Ge(0) }, specularIntensity: { value: 1 }, specularIntensityMap: { value: null }, specularColor: { value: new Ge(1, 1, 1) }, specularColorMap: { value: null } } ]), vertexShader: Ze.meshphysical_vert, fragmentShader: Ze.meshphysical_frag }; var lc = { r: 0, b: 0, g: 0 }; function t3(e, t, i, r, s, n, a) { let o = new Ge(0), l = n === !0 ? 0 : 1, h, u, c = null, d = 0, p = null; function f(m, v) { let y = !1, b = v.isScene === !0 ? v.background : null; b && b.isTexture && (b = (v.backgroundBlurriness > 0 ? i : t).get(b)); let x = e.xr, w = x.getSession && x.getSession(); w && w.environmentBlendMode === 'additive' && (b = null), b === null ? g(o, l) : b && b.isColor && (g(b, 1), (y = !0)), (e.autoClear || y) && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), b && (b.isCubeTexture || b.mapping === Ch) ? (u === void 0 && ((u = new tr( new vs(1, 1, 1), new ri({ name: 'BackgroundCubeMaterial', uniforms: zo(ss.backgroundCube.uniforms), vertexShader: ss.backgroundCube.vertexShader, fragmentShader: ss.backgroundCube.fragmentShader, side: hi, depthTest: !1, depthWrite: !1, fog: !1 }) )), u.geometry.deleteAttribute('normal'), u.geometry.deleteAttribute('uv'), (u.onBeforeRender = function (A, S, _) { this.matrixWorld.copyPosition(_.matrixWorld); }), Object.defineProperty(u.material, 'envMap', { get: function () { return this.uniforms.envMap.value; } }), s.update(u)), (u.material.uniforms.envMap.value = b), (u.material.uniforms.flipEnvMap.value = b.isCubeTexture && b.isRenderTargetTexture === !1 ? -1 : 1), (u.material.uniforms.backgroundBlurriness.value = v.backgroundBlurriness), (u.material.uniforms.backgroundIntensity.value = v.backgroundIntensity), (u.material.toneMapped = b.encoding !== Ke), (c !== b || d !== b.version || p !== e.toneMapping) && ((u.material.needsUpdate = !0), (c = b), (d = b.version), (p = e.toneMapping)), u.layers.enableAll(), m.unshift(u, u.geometry, u.material, 0, 0, null)) : b && b.isTexture && (h === void 0 && ((h = new tr( new ou(2, 2), new ri({ name: 'BackgroundMaterial', uniforms: zo(ss.background.uniforms), vertexShader: ss.background.vertexShader, fragmentShader: ss.background.fragmentShader, side: Vr, depthTest: !1, depthWrite: !1, fog: !1 }) )), h.geometry.deleteAttribute('normal'), Object.defineProperty(h.material, 'map', { get: function () { return this.uniforms.t2D.value; } }), s.update(h)), (h.material.uniforms.t2D.value = b), (h.material.uniforms.backgroundIntensity.value = v.backgroundIntensity), (h.material.toneMapped = b.encoding !== Ke), b.matrixAutoUpdate === !0 && b.updateMatrix(), h.material.uniforms.uvTransform.value.copy(b.matrix), (c !== b || d !== b.version || p !== e.toneMapping) && ((h.material.needsUpdate = !0), (c = b), (d = b.version), (p = e.toneMapping)), h.layers.enableAll(), m.unshift(h, h.geometry, h.material, 0, 0, null)); } function g(m, v) { m.getRGB(lc, vw(e)), r.buffers.color.setClear(lc.r, lc.g, lc.b, v, a); } return { getClearColor: function () { return o; }, setClearColor: function (m, v = 1) { o.set(m), (l = v), g(o, l); }, getClearAlpha: function () { return l; }, setClearAlpha: function (m) { (l = m), g(o, l); }, render: f }; } function i3(e, t, i, r) { let s = e.getParameter(34921), n = r.isWebGL2 ? null : t.get('OES_vertex_array_object'), a = r.isWebGL2 || n !== null, o = {}, l = m(null), h = l, u = !1; function c(D, k, W, X, z) { let j = !1; if (a) { let U = g(X, W, k); h !== U && ((h = U), p(h.object)), (j = v(D, X, W, z)), j && y(D, X, W, z); } else { let U = k.wireframe === !0; (h.geometry !== X.id || h.program !== W.id || h.wireframe !== U) && ((h.geometry = X.id), (h.program = W.id), (h.wireframe = U), (j = !0)); } z !== null && i.update(z, 34963), (j || u) && ((u = !1), _(D, k, W, X), z !== null && e.bindBuffer(34963, i.get(z).buffer)); } function d() { return r.isWebGL2 ? e.createVertexArray() : n.createVertexArrayOES(); } function p(D) { return r.isWebGL2 ? e.bindVertexArray(D) : n.bindVertexArrayOES(D); } function f(D) { return r.isWebGL2 ? e.deleteVertexArray(D) : n.deleteVertexArrayOES(D); } function g(D, k, W) { let X = W.wireframe === !0, z = o[D.id]; z === void 0 && ((z = {}), (o[D.id] = z)); let j = z[k.id]; j === void 0 && ((j = {}), (z[k.id] = j)); let U = j[X]; return U === void 0 && ((U = m(d())), (j[X] = U)), U; } function m(D) { let k = [], W = [], X = []; for (let z = 0; z < s; z++) (k[z] = 0), (W[z] = 0), (X[z] = 0); return { geometry: null, program: null, wireframe: !1, newAttributes: k, enabledAttributes: W, attributeDivisors: X, object: D, attributes: {}, index: null }; } function v(D, k, W, X) { let z = h.attributes, j = k.attributes, U = 0, N = W.getAttributes(); for (let B in N) if (N[B].location >= 0) { let H = z[B], Q = j[B]; if ( (Q === void 0 && (B === 'instanceMatrix' && D.instanceMatrix && (Q = D.instanceMatrix), B === 'instanceColor' && D.instanceColor && (Q = D.instanceColor)), H === void 0 || H.attribute !== Q || (Q && H.data !== Q.data)) ) return !0; U++; } return h.attributesNum !== U || h.index !== X; } function y(D, k, W, X) { let z = {}, j = k.attributes, U = 0, N = W.getAttributes(); for (let B in N) if (N[B].location >= 0) { let H = j[B]; H === void 0 && (B === 'instanceMatrix' && D.instanceMatrix && (H = D.instanceMatrix), B === 'instanceColor' && D.instanceColor && (H = D.instanceColor)); let Q = {}; (Q.attribute = H), H && H.data && (Q.data = H.data), (z[B] = Q), U++; } (h.attributes = z), (h.attributesNum = U), (h.index = X); } function b() { let D = h.newAttributes; for (let k = 0, W = D.length; k < W; k++) D[k] = 0; } function x(D) { w(D, 0); } function w(D, k) { let W = h.newAttributes, X = h.enabledAttributes, z = h.attributeDivisors; (W[D] = 1), X[D] === 0 && (e.enableVertexAttribArray(D), (X[D] = 1)), z[D] !== k && ((r.isWebGL2 ? e : t.get('ANGLE_instanced_arrays'))[r.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE'](D, k), (z[D] = k)); } function A() { let D = h.newAttributes, k = h.enabledAttributes; for (let W = 0, X = k.length; W < X; W++) k[W] !== D[W] && (e.disableVertexAttribArray(W), (k[W] = 0)); } function S(D, k, W, X, z, j) { r.isWebGL2 === !0 && (W === 5124 || W === 5125) ? e.vertexAttribIPointer(D, k, W, z, j) : e.vertexAttribPointer(D, k, W, X, z, j); } function _(D, k, W, X) { if (r.isWebGL2 === !1 && (D.isInstancedMesh || X.isInstancedBufferGeometry) && t.get('ANGLE_instanced_arrays') === null) return; b(); let z = X.attributes, j = W.getAttributes(), U = k.defaultAttributeValues; for (let N in j) { let B = j[N]; if (B.location >= 0) { let H = z[N]; if ( (H === void 0 && (N === 'instanceMatrix' && D.instanceMatrix && (H = D.instanceMatrix), N === 'instanceColor' && D.instanceColor && (H = D.instanceColor)), H !== void 0) ) { let Q = H.normalized, Y = H.itemSize, F = i.get(H); if (F === void 0) continue; let se = F.buffer, V = F.type, ee = F.bytesPerElement; if (H.isInterleavedBufferAttribute) { let J = H.data, fe = J.stride, re = H.offset; if (J.isInstancedInterleavedBuffer) { for (let oe = 0; oe < B.locationSize; oe++) w(B.location + oe, J.meshPerAttribute); D.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = J.meshPerAttribute * J.count); } else for (let oe = 0; oe < B.locationSize; oe++) x(B.location + oe); e.bindBuffer(34962, se); for (let oe = 0; oe < B.locationSize; oe++) S(B.location + oe, Y / B.locationSize, V, Q, fe * ee, (re + (Y / B.locationSize) * oe) * ee); } else { if (H.isInstancedBufferAttribute) { for (let J = 0; J < B.locationSize; J++) w(B.location + J, H.meshPerAttribute); D.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = H.meshPerAttribute * H.count); } else for (let J = 0; J < B.locationSize; J++) x(B.location + J); e.bindBuffer(34962, se); for (let J = 0; J < B.locationSize; J++) S(B.location + J, Y / B.locationSize, V, Q, Y * ee, (Y / B.locationSize) * J * ee); } } else if (U !== void 0) { let Q = U[N]; if (Q !== void 0) switch (Q.length) { case 2: e.vertexAttrib2fv(B.location, Q); break; case 3: e.vertexAttrib3fv(B.location, Q); break; case 4: e.vertexAttrib4fv(B.location, Q); break; default: e.vertexAttrib1fv(B.location, Q); } } } } A(); } function M() { P(); for (let D in o) { let k = o[D]; for (let W in k) { let X = k[W]; for (let z in X) f(X[z].object), delete X[z]; delete k[W]; } delete o[D]; } } function C(D) { if (o[D.id] === void 0) return; let k = o[D.id]; for (let W in k) { let X = k[W]; for (let z in X) f(X[z].object), delete X[z]; delete k[W]; } delete o[D.id]; } function T(D) { for (let k in o) { let W = o[k]; if (W[D.id] === void 0) continue; let X = W[D.id]; for (let z in X) f(X[z].object), delete X[z]; delete W[D.id]; } } function P() { L(), (u = !0), h !== l && ((h = l), p(h.object)); } function L() { (l.geometry = null), (l.program = null), (l.wireframe = !1); } return { setup: c, reset: P, resetDefaultState: L, dispose: M, releaseStatesOfGeometry: C, releaseStatesOfProgram: T, initAttributes: b, enableAttribute: x, disableUnusedAttributes: A }; } function r3(e, t, i, r) { let s = r.isWebGL2, n; function a(h) { n = h; } function o(h, u) { e.drawArrays(n, h, u), i.update(u, n, 1); } function l(h, u, c) { if (c === 0) return; let d, p; if (s) (d = e), (p = 'drawArraysInstanced'); else if (((d = t.get('ANGLE_instanced_arrays')), (p = 'drawArraysInstancedANGLE'), d === null)) { console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); return; } d[p](n, h, u, c), i.update(u, n, c); } (this.setMode = a), (this.render = o), (this.renderInstances = l); } function s3(e, t, i) { let r; function s() { if (r !== void 0) return r; if (t.has('EXT_texture_filter_anisotropic') === !0) { let S = t.get('EXT_texture_filter_anisotropic'); r = e.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT); } else r = 0; return r; } function n(S) { if (S === 'highp') { if (e.getShaderPrecisionFormat(35633, 36338).precision > 0 && e.getShaderPrecisionFormat(35632, 36338).precision > 0) return 'highp'; S = 'mediump'; } return S === 'mediump' && e.getShaderPrecisionFormat(35633, 36337).precision > 0 && e.getShaderPrecisionFormat(35632, 36337).precision > 0 ? 'mediump' : 'lowp'; } let a = typeof WebGL2RenderingContext < 'u' && e instanceof WebGL2RenderingContext, o = i.precision !== void 0 ? i.precision : 'highp', l = n(o); l !== o && (console.warn('THREE.WebGLRenderer:', o, 'not supported, using', l, 'instead.'), (o = l)); let h = a || t.has('WEBGL_draw_buffers'), u = i.logarithmicDepthBuffer === !0, c = e.getParameter(34930), d = e.getParameter(35660), p = e.getParameter(3379), f = e.getParameter(34076), g = e.getParameter(34921), m = e.getParameter(36347), v = e.getParameter(36348), y = e.getParameter(36349), b = d > 0, x = a || t.has('OES_texture_float'), w = b && x, A = a ? e.getParameter(36183) : 0; return { isWebGL2: a, drawBuffers: h, getMaxAnisotropy: s, getMaxPrecision: n, precision: o, logarithmicDepthBuffer: u, maxTextures: c, maxVertexTextures: d, maxTextureSize: p, maxCubemapSize: f, maxAttributes: g, maxVertexUniforms: m, maxVaryings: v, maxFragmentUniforms: y, vertexTextures: b, floatFragmentTextures: x, floatVertexTextures: w, maxSamples: A }; } function n3(e) { let t = this, i = null, r = 0, s = !1, n = !1, a = new yr(), o = new Ai(), l = { value: null, needsUpdate: !1 }; (this.uniform = l), (this.numPlanes = 0), (this.numIntersection = 0), (this.init = function (c, d) { let p = c.length !== 0 || d || r !== 0 || s; return (s = d), (r = c.length), p; }), (this.beginShadows = function () { (n = !0), u(null); }), (this.endShadows = function () { n = !1; }), (this.setGlobalState = function (c, d) { i = u(c, d, 0); }), (this.setState = function (c, d, p) { let f = c.clippingPlanes, g = c.clipIntersection, m = c.clipShadows, v = e.get(c); if (!s || f === null || f.length === 0 || (n && !m)) n ? u(null) : h(); else { let y = n ? 0 : r, b = y * 4, x = v.clippingState || null; (l.value = x), (x = u(f, d, b, p)); for (let w = 0; w !== b; ++w) x[w] = i[w]; (v.clippingState = x), (this.numIntersection = g ? this.numPlanes : 0), (this.numPlanes += y); } }); function h() { l.value !== i && ((l.value = i), (l.needsUpdate = r > 0)), (t.numPlanes = r), (t.numIntersection = 0); } function u(c, d, p, f) { let g = c !== null ? c.length : 0, m = null; if (g !== 0) { if (((m = l.value), f !== !0 || m === null)) { let v = p + g * 4, y = d.matrixWorldInverse; o.getNormalMatrix(y), (m === null || m.length < v) && (m = new Float32Array(v)); for (let b = 0, x = p; b !== g; ++b, x += 4) a.copy(c[b]).applyMatrix4(y, o), a.normal.toArray(m, x), (m[x + 3] = a.constant); } (l.value = m), (l.needsUpdate = !0); } return (t.numPlanes = g), (t.numIntersection = 0), m; } } function a3(e) { let t = new WeakMap(); function i(a, o) { return o === zf ? (a.mapping = ya) : o === Nf && (a.mapping = xa), a; } function r(a) { if (a && a.isTexture && a.isRenderTargetTexture === !1) { let o = a.mapping; if (o === zf || o === Nf) if (t.has(a)) { let l = t.get(a).texture; return i(l, a.mapping); } else { let l = a.image; if (l && l.height > 0) { let h = new xE(l.height / 2); return h.fromEquirectangularTexture(e, a), t.set(a, h), a.addEventListener('dispose', s), i(h.texture, a.mapping); } else return null; } } return a; } function s(a) { let o = a.target; o.removeEventListener('dispose', s); let l = t.get(o); l !== void 0 && (t.delete(o), l.dispose()); } function n() { t = new WeakMap(); } return { get: r, dispose: n }; } var gd = class extends Yo { constructor(e = -1, t = 1, i = 1, r = -1, s = 0.1, n = 2e3) { super(), (this.isOrthographicCamera = !0), (this.type = 'OrthographicCamera'), (this.zoom = 1), (this.view = null), (this.left = e), (this.right = t), (this.top = i), (this.bottom = r), (this.near = s), (this.far = n), this.updateProjectionMatrix(); } copy(e, t) { return ( super.copy(e, t), (this.left = e.left), (this.right = e.right), (this.top = e.top), (this.bottom = e.bottom), (this.near = e.near), (this.far = e.far), (this.zoom = e.zoom), (this.view = e.view === null ? null : Object.assign({}, e.view)), this ); } setViewOffset(e, t, i, r, s, n) { this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }), (this.view.enabled = !0), (this.view.fullWidth = e), (this.view.fullHeight = t), (this.view.offsetX = i), (this.view.offsetY = r), (this.view.width = s), (this.view.height = n), this.updateProjectionMatrix(); } clearViewOffset() { this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); } updateProjectionMatrix() { let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), i = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2, s = i - e, n = i + e, a = r + t, o = r - t; if (this.view !== null && this.view.enabled) { let l = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom; (s += l * this.view.offsetX), (n = s + l * this.view.width), (a -= h * this.view.offsetY), (o = a - h * this.view.height); } this.projectionMatrix.makeOrthographic(s, n, a, o, this.near, this.far), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); } toJSON(e) { let t = super.toJSON(e); return ( (t.object.zoom = this.zoom), (t.object.left = this.left), (t.object.right = this.right), (t.object.top = this.top), (t.object.bottom = this.bottom), (t.object.near = this.near), (t.object.far = this.far), this.view !== null && (t.object.view = Object.assign({}, this.view)), t ); } }, uo = 4, V0 = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], ia = 20, xp = new gd(), H0 = new Ge(), bp = null, Jn = (1 + Math.sqrt(5)) / 2, qa = 1 / Jn, W0 = [ new E(1, 1, 1), new E(-1, 1, 1), new E(1, 1, -1), new E(-1, 1, -1), new E(0, Jn, qa), new E(0, Jn, -qa), new E(qa, 0, Jn), new E(-qa, 0, Jn), new E(Jn, qa, 0), new E(-Jn, qa, 0) ], X0 = class { constructor(e) { (this._renderer = e), (this._pingPongRenderTarget = null), (this._lodMax = 0), (this._cubeSize = 0), (this._lodPlanes = []), (this._sizeLods = []), (this._sigmas = []), (this._blurMaterial = null), (this._cubemapMaterial = null), (this._equirectMaterial = null), this._compileMaterial(this._blurMaterial); } fromScene(e, t = 0, i = 0.1, r = 100) { (bp = this._renderer.getRenderTarget()), this._setSize(256); let s = this._allocateTargets(); return ( (s.depthBuffer = !0), this._sceneToCubeUV(e, i, r, s), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s ); } fromEquirectangular(e, t = null) { return this._fromTexture(e, t); } fromCubemap(e, t = null) { return this._fromTexture(e, t); } compileCubemapShader() { this._cubemapMaterial === null && ((this._cubemapMaterial = Q0()), this._compileMaterial(this._cubemapMaterial)); } compileEquirectangularShader() { this._equirectMaterial === null && ((this._equirectMaterial = Y0()), this._compileMaterial(this._equirectMaterial)); } dispose() { this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(); } _setSize(e) { (this._lodMax = Math.floor(Math.log2(e))), (this._cubeSize = Math.pow(2, this._lodMax)); } _dispose() { this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose(); for (let e = 0; e < this._lodPlanes.length; e++) this._lodPlanes[e].dispose(); } _cleanup(e) { this._renderer.setRenderTarget(bp), (e.scissorTest = !1), hc(e, 0, 0, e.width, e.height); } _fromTexture(e, t) { e.mapping === ya || e.mapping === xa ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), (bp = this._renderer.getRenderTarget()); let i = t || this._allocateTargets(); return this._textureToCubeUV(e, i), this._applyPMREM(i), this._cleanup(i), i; } _allocateTargets() { let e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, i = { magFilter: mt, minFilter: mt, generateMipmaps: !1, type: lh, format: Ur, encoding: gs, depthBuffer: !1 }, r = q0(e, t, i); if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) { this._pingPongRenderTarget !== null && this._dispose(), (this._pingPongRenderTarget = q0(e, t, i)); let { _lodMax: s } = this; ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = o3(s)), (this._blurMaterial = l3(s, e, t)); } return r; } _compileMaterial(e) { let t = new tr(this._lodPlanes[0], e); this._renderer.compile(t, xp); } _sceneToCubeUV(e, t, i, r) { let s = new wi(90, 1, t, i), n = [1, -1, 1, 1, 1, 1], a = [1, 1, 1, -1, -1, -1], o = this._renderer, l = o.autoClear, h = o.toneMapping; o.getClearColor(H0), (o.toneMapping = Gs), (o.autoClear = !1); let u = new Ph({ name: 'PMREM.Background', side: hi, depthWrite: !1, depthTest: !1 }), c = new tr(new vs(), u), d = !1, p = e.background; p ? p.isColor && (u.color.copy(p), (e.background = null), (d = !0)) : (u.color.copy(H0), (d = !0)); for (let f = 0; f < 6; f++) { let g = f % 3; g === 0 ? (s.up.set(0, n[f], 0), s.lookAt(a[f], 0, 0)) : g === 1 ? (s.up.set(0, 0, n[f]), s.lookAt(0, a[f], 0)) : (s.up.set(0, n[f], 0), s.lookAt(0, 0, a[f])); let m = this._cubeSize; hc(r, g * m, f > 2 ? m : 0, m, m), o.setRenderTarget(r), d && o.render(c, s), o.render(e, s); } c.geometry.dispose(), c.material.dispose(), (o.toneMapping = h), (o.autoClear = l), (e.background = p); } _textureToCubeUV(e, t) { let i = this._renderer, r = e.mapping === ya || e.mapping === xa; r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Q0()), (this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1)) : this._equirectMaterial === null && (this._equirectMaterial = Y0()); let s = r ? this._cubemapMaterial : this._equirectMaterial, n = new tr(this._lodPlanes[0], s), a = s.uniforms; a.envMap.value = e; let o = this._cubeSize; hc(t, 0, 0, 3 * o, 2 * o), i.setRenderTarget(t), i.render(n, xp); } _applyPMREM(e) { let t = this._renderer, i = t.autoClear; t.autoClear = !1; for (let r = 1; r < this._lodPlanes.length; r++) { let s = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]), n = W0[(r - 1) % W0.length]; this._blur(e, r - 1, r, s, n); } t.autoClear = i; } _blur(e, t, i, r, s) { let n = this._pingPongRenderTarget; this._halfBlur(e, n, t, i, r, 'latitudinal', s), this._halfBlur(n, e, i, i, r, 'longitudinal', s); } _halfBlur(e, t, i, r, s, n, a) { let o = this._renderer, l = this._blurMaterial; n !== 'latitudinal' && n !== 'longitudinal' && console.error('blur direction must be either latitudinal or longitudinal!'); let h = 3, u = new tr(this._lodPlanes[r], l), c = l.uniforms, d = this._sizeLods[i] - 1, p = isFinite(s) ? Math.PI / (2 * d) : (2 * Math.PI) / (2 * ia - 1), f = s / p, g = isFinite(s) ? 1 + Math.floor(h * f) : ia; g > ia && console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ia}`); let m = [], v = 0; for (let A = 0; A < ia; ++A) { let S = A / f, _ = Math.exp((-S * S) / 2); m.push(_), A === 0 ? (v += _) : A < g && (v += 2 * _); } for (let A = 0; A < m.length; A++) m[A] = m[A] / v; (c.envMap.value = e.texture), (c.samples.value = g), (c.weights.value = m), (c.latitudinal.value = n === 'latitudinal'), a && (c.poleAxis.value = a); let { _lodMax: y } = this; (c.dTheta.value = p), (c.mipInt.value = y - i); let b = this._sizeLods[r], x = 3 * b * (r > y - uo ? r - y + uo : 0), w = 4 * (this._cubeSize - b); hc(t, x, w, 3 * b, 2 * b), o.setRenderTarget(t), o.render(u, xp); } }; function o3(e) { let t = [], i = [], r = [], s = e, n = e - uo + 1 + V0.length; for (let a = 0; a < n; a++) { let o = Math.pow(2, s); i.push(o); let l = 1 / o; a > e - uo ? (l = V0[a - e + uo - 1]) : a === 0 && (l = 0), r.push(l); let h = 1 / (o - 2), u = -h, c = 1 + h, d = [u, u, c, u, c, c, u, u, c, c, u, c], p = 6, f = 6, g = 3, m = 2, v = 1, y = new Float32Array(g * f * p), b = new Float32Array(m * f * p), x = new Float32Array(v * f * p); for (let A = 0; A < p; A++) { let S = ((A % 3) * 2) / 3 - 1, _ = A > 2 ? 0 : -1, M = [S, _, 0, S + 2 / 3, _, 0, S + 2 / 3, _ + 1, 0, S, _, 0, S + 2 / 3, _ + 1, 0, S, _ + 1, 0]; y.set(M, g * f * A), b.set(d, m * f * A); let C = [A, A, A, A, A, A]; x.set(C, v * f * A); } let w = new Ve(); w.setAttribute('position', new Xe(y, g)), w.setAttribute('uv', new Xe(b, m)), w.setAttribute('faceIndex', new Xe(x, v)), t.push(w), s > uo && s--; } return { lodPlanes: t, sizeLods: i, sigmas: r }; } function q0(e, t, i) { let r = new ii(e, t, i); return (r.texture.mapping = Ch), (r.texture.name = 'PMREM.cubeUv'), (r.scissorTest = !0), r; } function hc(e, t, i, r, s) { e.viewport.set(t, i, r, s), e.scissor.set(t, i, r, s); } function l3(e, t, i) { let r = new Float32Array(ia), s = new E(0, 1, 0); return new ri({ name: 'SphericalGaussianBlur', defines: { n: ia, CUBEUV_TEXEL_WIDTH: 1 / t, CUBEUV_TEXEL_HEIGHT: 1 / i, CUBEUV_MAX_MIP: `${e}.0` }, uniforms: { envMap: { value: null }, samples: { value: 1 }, weights: { value: r }, latitudinal: { value: !1 }, dTheta: { value: 0 }, mipInt: { value: 0 }, poleAxis: { value: s } }, vertexShader: ug(), fragmentShader: ` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `, blending: fi, depthTest: !1, depthWrite: !1 }); } function Y0() { return new ri({ name: 'EquirectangularToCubeUV', uniforms: { envMap: { value: null } }, vertexShader: ug(), fragmentShader: ` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `, blending: fi, depthTest: !1, depthWrite: !1 }); } function Q0() { return new ri({ name: 'CubemapToCubeUV', uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 } }, vertexShader: ug(), fragmentShader: ` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `, blending: fi, depthTest: !1, depthWrite: !1 }); } function ug() { return ` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `; } function h3(e) { let t = new WeakMap(), i = null; function r(o) { if (o && o.isTexture) { let l = o.mapping, h = l === zf || l === Nf, u = l === ya || l === xa; if (h || u) if (o.isRenderTargetTexture && o.needsPMREMUpdate === !0) { o.needsPMREMUpdate = !1; let c = t.get(o); return i === null && (i = new X0(e)), (c = h ? i.fromEquirectangular(o, c) : i.fromCubemap(o, c)), t.set(o, c), c.texture; } else { if (t.has(o)) return t.get(o).texture; { let c = o.image; if ((h && c && c.height > 0) || (u && c && s(c))) { i === null && (i = new X0(e)); let d = h ? i.fromEquirectangular(o) : i.fromCubemap(o); return t.set(o, d), o.addEventListener('dispose', n), d.texture; } else return null; } } } return o; } function s(o) { let l = 0, h = 6; for (let u = 0; u < h; u++) o[u] !== void 0 && l++; return l === h; } function n(o) { let l = o.target; l.removeEventListener('dispose', n); let h = t.get(l); h !== void 0 && (t.delete(l), h.dispose()); } function a() { (t = new WeakMap()), i !== null && (i.dispose(), (i = null)); } return { get: r, dispose: a }; } function c3(e) { let t = {}; function i(r) { if (t[r] !== void 0) return t[r]; let s; switch (r) { case 'WEBGL_depth_texture': s = e.getExtension('WEBGL_depth_texture') || e.getExtension('MOZ_WEBGL_depth_texture') || e.getExtension('WEBKIT_WEBGL_depth_texture'); break; case 'EXT_texture_filter_anisotropic': s = e.getExtension('EXT_texture_filter_anisotropic') || e.getExtension('MOZ_EXT_texture_filter_anisotropic') || e.getExtension('WEBKIT_EXT_texture_filter_anisotropic'); break; case 'WEBGL_compressed_texture_s3tc': s = e.getExtension('WEBGL_compressed_texture_s3tc') || e.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || e.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'); break; case 'WEBGL_compressed_texture_pvrtc': s = e.getExtension('WEBGL_compressed_texture_pvrtc') || e.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); break; default: s = e.getExtension(r); } return (t[r] = s), s; } return { has: function (r) { return i(r) !== null; }, init: function (r) { r.isWebGL2 ? i('EXT_color_buffer_float') : (i('WEBGL_depth_texture'), i('OES_texture_float'), i('OES_texture_half_float'), i('OES_texture_half_float_linear'), i('OES_standard_derivatives'), i('OES_element_index_uint'), i('OES_vertex_array_object'), i('ANGLE_instanced_arrays')), i('OES_texture_float_linear'), i('EXT_color_buffer_half_float'), i('WEBGL_multisampled_render_to_texture'); }, get: function (r) { let s = i(r); return s === null && console.warn('THREE.WebGLRenderer: ' + r + ' extension not supported.'), s; } }; } function d3(e, t, i, r) { let s = {}, n = new WeakMap(); function a(c) { let d = c.target; d.index !== null && t.remove(d.index); for (let f in d.attributes) t.remove(d.attributes[f]); d.removeEventListener('dispose', a), delete s[d.id]; let p = n.get(d); p && (t.remove(p), n.delete(d)), r.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, i.memory.geometries--; } function o(c, d) { return s[d.id] === !0 || (d.addEventListener('dispose', a), (s[d.id] = !0), i.memory.geometries++), d; } function l(c) { let d = c.attributes; for (let f in d) t.update(d[f], 34962); let p = c.morphAttributes; for (let f in p) { let g = p[f]; for (let m = 0, v = g.length; m < v; m++) t.update(g[m], 34962); } } function h(c) { let d = [], p = c.index, f = c.attributes.position, g = 0; if (p !== null) { let y = p.array; g = p.version; for (let b = 0, x = y.length; b < x; b += 3) { let w = y[b + 0], A = y[b + 1], S = y[b + 2]; d.push(w, A, A, S, S, w); } } else { let y = f.array; g = f.version; for (let b = 0, x = y.length / 3 - 1; b < x; b += 3) { let w = b + 0, A = b + 1, S = b + 2; d.push(w, A, A, S, S, w); } } let m = new (dw(d) ? Kl : gw)(d, 1); m.version = g; let v = n.get(c); v && t.remove(v), n.set(c, m); } function u(c) { let d = n.get(c); if (d) { let p = c.index; p !== null && d.version < p.version && h(c); } else h(c); return n.get(c); } return { get: o, update: l, getWireframeAttribute: u }; } function u3(e, t, i, r) { let s = r.isWebGL2, n; function a(d) { n = d; } let o, l; function h(d) { (o = d.type), (l = d.bytesPerElement); } function u(d, p) { e.drawElements(n, p, o, d * l), i.update(p, n, 1); } function c(d, p, f) { if (f === 0) return; let g, m; if (s) (g = e), (m = 'drawElementsInstanced'); else if (((g = t.get('ANGLE_instanced_arrays')), (m = 'drawElementsInstancedANGLE'), g === null)) { console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); return; } g[m](n, p, o, d * l, f), i.update(p, n, f); } (this.setMode = a), (this.setIndex = h), (this.render = u), (this.renderInstances = c); } function p3(e) { let t = { geometries: 0, textures: 0 }, i = { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 }; function r(n, a, o) { switch ((i.calls++, a)) { case 4: i.triangles += o * (n / 3); break; case 1: i.lines += o * (n / 2); break; case 3: i.lines += o * (n - 1); break; case 2: i.lines += o * n; break; case 0: i.points += o * n; break; default: console.error('THREE.WebGLInfo: Unknown draw mode:', a); break; } } function s() { i.frame++, (i.calls = 0), (i.triangles = 0), (i.points = 0), (i.lines = 0); } return { memory: t, render: i, programs: null, autoReset: !0, reset: s, update: r }; } function f3(e, t) { return e[0] - t[0]; } function m3(e, t) { return Math.abs(t[1]) - Math.abs(e[1]); } function g3(e, t, i) { let r = {}, s = new Float32Array(8), n = new WeakMap(), a = new $e(), o = []; for (let h = 0; h < 8; h++) o[h] = [h, 0]; function l(h, u, c, d) { let p = h.morphTargetInfluences; if (t.isWebGL2 === !0) { let f = u.morphAttributes.position || u.morphAttributes.normal || u.morphAttributes.color, g = f !== void 0 ? f.length : 0, m = n.get(u); if (m === void 0 || m.count !== g) { let b = function () { D.dispose(), n.delete(u), u.removeEventListener('dispose', b); }; m !== void 0 && m.texture.dispose(); let x = u.morphAttributes.position !== void 0, w = u.morphAttributes.normal !== void 0, A = u.morphAttributes.color !== void 0, S = u.morphAttributes.position || [], _ = u.morphAttributes.normal || [], M = u.morphAttributes.color || [], C = 0; x === !0 && (C = 1), w === !0 && (C = 2), A === !0 && (C = 3); let T = u.attributes.position.count * C, P = 1; T > t.maxTextureSize && ((P = Math.ceil(T / t.maxTextureSize)), (T = t.maxTextureSize)); let L = new Float32Array(T * P * 4 * g), D = new mw(L, T, P, g); (D.type = vn), (D.needsUpdate = !0); let k = C * 4; for (let W = 0; W < g; W++) { let X = S[W], z = _[W], j = M[W], U = T * P * 4 * W; for (let N = 0; N < X.count; N++) { let B = N * k; x === !0 && (a.fromBufferAttribute(X, N), (L[U + B + 0] = a.x), (L[U + B + 1] = a.y), (L[U + B + 2] = a.z), (L[U + B + 3] = 0)), w === !0 && (a.fromBufferAttribute(z, N), (L[U + B + 4] = a.x), (L[U + B + 5] = a.y), (L[U + B + 6] = a.z), (L[U + B + 7] = 0)), A === !0 && (a.fromBufferAttribute(j, N), (L[U + B + 8] = a.x), (L[U + B + 9] = a.y), (L[U + B + 10] = a.z), (L[U + B + 11] = j.itemSize === 4 ? a.w : 1)); } } (m = { count: g, texture: D, size: new G(T, P) }), n.set(u, m), u.addEventListener('dispose', b); } let v = 0; for (let b = 0; b < p.length; b++) v += p[b]; let y = u.morphTargetsRelative ? 1 : 1 - v; d.getUniforms().setValue(e, 'morphTargetBaseInfluence', y), d.getUniforms().setValue(e, 'morphTargetInfluences', p), d.getUniforms().setValue(e, 'morphTargetsTexture', m.texture, i), d.getUniforms().setValue(e, 'morphTargetsTextureSize', m.size); } else { let f = p === void 0 ? 0 : p.length, g = r[u.id]; if (g === void 0 || g.length !== f) { g = []; for (let x = 0; x < f; x++) g[x] = [x, 0]; r[u.id] = g; } for (let x = 0; x < f; x++) { let w = g[x]; (w[0] = x), (w[1] = p[x]); } g.sort(m3); for (let x = 0; x < 8; x++) x < f && g[x][1] ? ((o[x][0] = g[x][0]), (o[x][1] = g[x][1])) : ((o[x][0] = Number.MAX_SAFE_INTEGER), (o[x][1] = 0)); o.sort(f3); let m = u.morphAttributes.position, v = u.morphAttributes.normal, y = 0; for (let x = 0; x < 8; x++) { let w = o[x], A = w[0], S = w[1]; A !== Number.MAX_SAFE_INTEGER && S ? (m && u.getAttribute('morphTarget' + x) !== m[A] && u.setAttribute('morphTarget' + x, m[A]), v && u.getAttribute('morphNormal' + x) !== v[A] && u.setAttribute('morphNormal' + x, v[A]), (s[x] = S), (y += S)) : (m && u.hasAttribute('morphTarget' + x) === !0 && u.deleteAttribute('morphTarget' + x), v && u.hasAttribute('morphNormal' + x) === !0 && u.deleteAttribute('morphNormal' + x), (s[x] = 0)); } let b = u.morphTargetsRelative ? 1 : 1 - y; d.getUniforms().setValue(e, 'morphTargetBaseInfluence', b), d.getUniforms().setValue(e, 'morphTargetInfluences', s); } } return { update: l }; } function v3(e, t, i, r) { let s = new WeakMap(); function n(l) { let h = r.render.frame, u = l.geometry, c = t.get(l, u); return ( s.get(c) !== h && (t.update(c), s.set(c, h)), l.isInstancedMesh && (l.hasEventListener('dispose', o) === !1 && l.addEventListener('dispose', o), i.update(l.instanceMatrix, 34962), l.instanceColor !== null && i.update(l.instanceColor, 34962)), c ); } function a() { s = new WeakMap(); } function o(l) { let h = l.target; h.removeEventListener('dispose', o), i.remove(h.instanceMatrix), h.instanceColor !== null && i.remove(h.instanceColor); } return { update: n, dispose: a }; } var xw = new ci(), bw = new mw(), ww = new rE(), _w = new cg(), Z0 = [], K0 = [], J0 = new Float32Array(16), $0 = new Float32Array(9), ey = new Float32Array(4); function Qo(e, t, i) { let r = e[0]; if (r <= 0 || r > 0) return e; let s = t * i, n = Z0[s]; if ((n === void 0 && ((n = new Float32Array(s)), (Z0[s] = n)), t !== 0)) { r.toArray(n, 0); for (let a = 1, o = 0; a !== t; ++a) (o += i), e[a].toArray(n, o); } return n; } function si(e, t) { if (e.length !== t.length) return !1; for (let i = 0, r = e.length; i < r; i++) if (e[i] !== t[i]) return !1; return !0; } function ni(e, t) { for (let i = 0, r = t.length; i < r; i++) e[i] = t[i]; } function lu(e, t) { let i = K0[t]; i === void 0 && ((i = new Int32Array(t)), (K0[t] = i)); for (let r = 0; r !== t; ++r) i[r] = e.allocateTextureUnit(); return i; } function y3(e, t) { let i = this.cache; i[0] !== t && (e.uniform1f(this.addr, t), (i[0] = t)); } function x3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y) && (e.uniform2f(this.addr, t.x, t.y), (i[0] = t.x), (i[1] = t.y)); else { if (si(i, t)) return; e.uniform2fv(this.addr, t), ni(i, t); } } function b3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (e.uniform3f(this.addr, t.x, t.y, t.z), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z)); else if (t.r !== void 0) (i[0] !== t.r || i[1] !== t.g || i[2] !== t.b) && (e.uniform3f(this.addr, t.r, t.g, t.b), (i[0] = t.r), (i[1] = t.g), (i[2] = t.b)); else { if (si(i, t)) return; e.uniform3fv(this.addr, t), ni(i, t); } } function w3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (e.uniform4f(this.addr, t.x, t.y, t.z, t.w), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z), (i[3] = t.w)); else { if (si(i, t)) return; e.uniform4fv(this.addr, t), ni(i, t); } } function _3(e, t) { let i = this.cache, r = t.elements; if (r === void 0) { if (si(i, t)) return; e.uniformMatrix2fv(this.addr, !1, t), ni(i, t); } else { if (si(i, r)) return; ey.set(r), e.uniformMatrix2fv(this.addr, !1, ey), ni(i, r); } } function A3(e, t) { let i = this.cache, r = t.elements; if (r === void 0) { if (si(i, t)) return; e.uniformMatrix3fv(this.addr, !1, t), ni(i, t); } else { if (si(i, r)) return; $0.set(r), e.uniformMatrix3fv(this.addr, !1, $0), ni(i, r); } } function S3(e, t) { let i = this.cache, r = t.elements; if (r === void 0) { if (si(i, t)) return; e.uniformMatrix4fv(this.addr, !1, t), ni(i, t); } else { if (si(i, r)) return; J0.set(r), e.uniformMatrix4fv(this.addr, !1, J0), ni(i, r); } } function M3(e, t) { let i = this.cache; i[0] !== t && (e.uniform1i(this.addr, t), (i[0] = t)); } function E3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y) && (e.uniform2i(this.addr, t.x, t.y), (i[0] = t.x), (i[1] = t.y)); else { if (si(i, t)) return; e.uniform2iv(this.addr, t), ni(i, t); } } function C3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (e.uniform3i(this.addr, t.x, t.y, t.z), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z)); else { if (si(i, t)) return; e.uniform3iv(this.addr, t), ni(i, t); } } function T3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (e.uniform4i(this.addr, t.x, t.y, t.z, t.w), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z), (i[3] = t.w)); else { if (si(i, t)) return; e.uniform4iv(this.addr, t), ni(i, t); } } function P3(e, t) { let i = this.cache; i[0] !== t && (e.uniform1ui(this.addr, t), (i[0] = t)); } function D3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y) && (e.uniform2ui(this.addr, t.x, t.y), (i[0] = t.x), (i[1] = t.y)); else { if (si(i, t)) return; e.uniform2uiv(this.addr, t), ni(i, t); } } function L3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z) && (e.uniform3ui(this.addr, t.x, t.y, t.z), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z)); else { if (si(i, t)) return; e.uniform3uiv(this.addr, t), ni(i, t); } } function O3(e, t) { let i = this.cache; if (t.x !== void 0) (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) && (e.uniform4ui(this.addr, t.x, t.y, t.z, t.w), (i[0] = t.x), (i[1] = t.y), (i[2] = t.z), (i[3] = t.w)); else { if (si(i, t)) return; e.uniform4uiv(this.addr, t), ni(i, t); } } function I3(e, t, i) { let r = this.cache, s = i.allocateTextureUnit(); r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture2D(t || xw, s); } function R3(e, t, i) { let r = this.cache, s = i.allocateTextureUnit(); r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture3D(t || ww, s); } function B3(e, t, i) { let r = this.cache, s = i.allocateTextureUnit(); r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTextureCube(t || _w, s); } function z3(e, t, i) { let r = this.cache, s = i.allocateTextureUnit(); r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture2DArray(t || bw, s); } function N3(e) { switch (e) { case 5126: return y3; case 35664: return x3; case 35665: return b3; case 35666: return w3; case 35674: return _3; case 35675: return A3; case 35676: return S3; case 5124: case 35670: return M3; case 35667: case 35671: return E3; case 35668: case 35672: return C3; case 35669: case 35673: return T3; case 5125: return P3; case 36294: return D3; case 36295: return L3; case 36296: return O3; case 35678: case 36198: case 36298: case 36306: case 35682: return I3; case 35679: case 36299: case 36307: return R3; case 35680: case 36300: case 36308: case 36293: return B3; case 36289: case 36303: case 36311: case 36292: return z3; } } function U3(e, t) { e.uniform1fv(this.addr, t); } function F3(e, t) { let i = Qo(t, this.size, 2); e.uniform2fv(this.addr, i); } function k3(e, t) { let i = Qo(t, this.size, 3); e.uniform3fv(this.addr, i); } function j3(e, t) { let i = Qo(t, this.size, 4); e.uniform4fv(this.addr, i); } function G3(e, t) { let i = Qo(t, this.size, 4); e.uniformMatrix2fv(this.addr, !1, i); } function V3(e, t) { let i = Qo(t, this.size, 9); e.uniformMatrix3fv(this.addr, !1, i); } function H3(e, t) { let i = Qo(t, this.size, 16); e.uniformMatrix4fv(this.addr, !1, i); } function W3(e, t) { e.uniform1iv(this.addr, t); } function X3(e, t) { e.uniform2iv(this.addr, t); } function q3(e, t) { e.uniform3iv(this.addr, t); } function Y3(e, t) { e.uniform4iv(this.addr, t); } function Q3(e, t) { e.uniform1uiv(this.addr, t); } function Z3(e, t) { e.uniform2uiv(this.addr, t); } function K3(e, t) { e.uniform3uiv(this.addr, t); } function J3(e, t) { e.uniform4uiv(this.addr, t); } function $3(e, t, i) { let r = this.cache, s = t.length, n = lu(i, s); si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n)); for (let a = 0; a !== s; ++a) i.setTexture2D(t[a] || xw, n[a]); } function eP(e, t, i) { let r = this.cache, s = t.length, n = lu(i, s); si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n)); for (let a = 0; a !== s; ++a) i.setTexture3D(t[a] || ww, n[a]); } function tP(e, t, i) { let r = this.cache, s = t.length, n = lu(i, s); si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n)); for (let a = 0; a !== s; ++a) i.setTextureCube(t[a] || _w, n[a]); } function iP(e, t, i) { let r = this.cache, s = t.length, n = lu(i, s); si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n)); for (let a = 0; a !== s; ++a) i.setTexture2DArray(t[a] || bw, n[a]); } function rP(e) { switch (e) { case 5126: return U3; case 35664: return F3; case 35665: return k3; case 35666: return j3; case 35674: return G3; case 35675: return V3; case 35676: return H3; case 5124: case 35670: return W3; case 35667: case 35671: return X3; case 35668: case 35672: return q3; case 35669: case 35673: return Y3; case 5125: return Q3; case 36294: return Z3; case 36295: return K3; case 36296: return J3; case 35678: case 36198: case 36298: case 36306: case 35682: return $3; case 35679: case 36299: case 36307: return eP; case 35680: case 36300: case 36308: case 36293: return tP; case 36289: case 36303: case 36311: case 36292: return iP; } } var sP = class { constructor(e, t, i) { (this.id = e), (this.addr = i), (this.cache = []), (this.setValue = N3(t.type)); } }, nP = class { constructor(e, t, i) { (this.id = e), (this.addr = i), (this.cache = []), (this.size = t.size), (this.setValue = rP(t.type)); } }, aP = class { constructor(e) { (this.id = e), (this.seq = []), (this.map = {}); } setValue(e, t, i) { let r = this.seq; for (let s = 0, n = r.length; s !== n; ++s) { let a = r[s]; a.setValue(e, t[a.id], i); } } }, wp = /(\w+)(\])?(\[|\.)?/g; function ty(e, t) { e.seq.push(t), (e.map[t.id] = t); } function oP(e, t, i) { let r = e.name, s = r.length; for (wp.lastIndex = 0; ; ) { let n = wp.exec(r), a = wp.lastIndex, o = n[1], l = n[2] === ']', h = n[3]; if ((l && (o = o | 0), h === void 0 || (h === '[' && a + 2 === s))) { ty(i, h === void 0 ? new sP(o, e, t) : new nP(o, e, t)); break; } else { let u = i.map[o]; u === void 0 && ((u = new aP(o)), ty(i, u)), (i = u); } } } var Jc = class { constructor(e, t) { (this.seq = []), (this.map = {}); let i = e.getProgramParameter(t, 35718); for (let r = 0; r < i; ++r) { let s = e.getActiveUniform(t, r), n = e.getUniformLocation(t, s.name); oP(s, n, this); } } setValue(e, t, i, r) { let s = this.map[t]; s !== void 0 && s.setValue(e, i, r); } setOptional(e, t, i) { let r = t[i]; r !== void 0 && this.setValue(e, i, r); } static upload(e, t, i, r) { for (let s = 0, n = t.length; s !== n; ++s) { let a = t[s], o = i[a.id]; o.needsUpdate !== !1 && a.setValue(e, o.value, r); } } static seqWithValue(e, t) { let i = []; for (let r = 0, s = e.length; r !== s; ++r) { let n = e[r]; n.id in t && i.push(n); } return i; } }; function iy(e, t, i) { let r = e.createShader(t); return e.shaderSource(r, i), e.compileShader(r), r; } var lP = 0; function hP(e, t) { let i = e.split(` `), r = [], s = Math.max(t - 6, 0), n = Math.min(t + 6, i.length); for (let a = s; a < n; a++) { let o = a + 1; r.push(`${o === t ? '>' : ' '} ${o}: ${i[a]}`); } return r.join(` `); } function cP(e) { switch (e) { case gs: return ['Linear', '( value )']; case Ke: return ['sRGB', '( value )']; default: return console.warn('THREE.WebGLProgram: Unsupported encoding:', e), ['Linear', '( value )']; } } function ry(e, t, i) { let r = e.getShaderParameter(t, 35713), s = e.getShaderInfoLog(t).trim(); if (r && s === '') return ''; let n = /ERROR: 0:(\d+)/.exec(s); if (n) { let a = parseInt(n[1]); return ( i.toUpperCase() + ` ` + s + ` ` + hP(e.getShaderSource(t), a) ); } else return s; } function dP(e, t) { let i = cP(t); return 'vec4 ' + e + '( vec4 value ) { return LinearTo' + i[0] + i[1] + '; }'; } function uP(e, t) { let i; switch (t) { case vM: i = 'Linear'; break; case yM: i = 'Reinhard'; break; case xM: i = 'OptimizedCineon'; break; case bM: i = 'ACESFilmic'; break; case wM: i = 'Custom'; break; default: console.warn('THREE.WebGLProgram: Unsupported toneMapping:', t), (i = 'Linear'); } return 'vec3 ' + e + '( vec3 color ) { return ' + i + 'ToneMapping( color ); }'; } function pP(e) { return [ e.extensionDerivatives || !!e.envMapCubeUVHeight || e.bumpMap || e.tangentSpaceNormalMap || e.clearcoatNormalMap || e.flatShading || e.shaderID === 'physical' ? '#extension GL_OES_standard_derivatives : enable' : '', (e.extensionFragDepth || e.logarithmicDepthBuffer) && e.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', e.extensionDrawBuffers && e.rendererExtensionDrawBuffers ? '#extension GL_EXT_draw_buffers : require' : '', (e.extensionShaderTextureLOD || e.envMap || e.transmission) && e.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : '' ].filter(Gl).join(` `); } function fP(e) { let t = []; for (let i in e) { let r = e[i]; r !== !1 && t.push('#define ' + i + ' ' + r); } return t.join(` `); } function mP(e, t) { let i = {}, r = e.getProgramParameter(t, 35721); for (let s = 0; s < r; s++) { let n = e.getActiveAttrib(t, s), a = n.name, o = 1; n.type === 35674 && (o = 2), n.type === 35675 && (o = 3), n.type === 35676 && (o = 4), (i[a] = { type: n.type, location: e.getAttribLocation(t, a), locationSize: o }); } return i; } function Gl(e) { return e !== ''; } function sy(e, t) { let i = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps; return e .replace(/NUM_DIR_LIGHTS/g, t.numDirLights) .replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights) .replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps) .replace(/NUM_SPOT_LIGHT_COORDS/g, i) .replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights) .replace(/NUM_POINT_LIGHTS/g, t.numPointLights) .replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights) .replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows) .replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps) .replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows) .replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows); } function ny(e, t) { return e .replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes) .replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection); } var gP = /^[ \t]*#include +<([\w\d./]+)>/gm; function Gf(e) { return e.replace(gP, vP); } function vP(e, t) { let i = Ze[t]; if (i === void 0) throw new Error('Can not resolve #include <' + t + '>'); return Gf(i); } var yP = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; function ay(e) { return e.replace(yP, xP); } function xP(e, t, i, r) { let s = ''; for (let n = parseInt(t); n < parseInt(i); n++) s += r.replace(/\[\s*i\s*\]/g, '[ ' + n + ' ]').replace(/UNROLLED_LOOP_INDEX/g, n); return s; } function oy(e) { let t = 'precision ' + e.precision + ` float; precision ` + e.precision + ' int;'; return ( e.precision === 'highp' ? (t += ` #define HIGH_PRECISION`) : e.precision === 'mediump' ? (t += ` #define MEDIUM_PRECISION`) : e.precision === 'lowp' && (t += ` #define LOW_PRECISION`), t ); } function bP(e) { let t = 'SHADOWMAP_TYPE_BASIC'; return ( e.shadowMapType === og ? (t = 'SHADOWMAP_TYPE_PCF') : e.shadowMapType === sw ? (t = 'SHADOWMAP_TYPE_PCF_SOFT') : e.shadowMapType === jl && (t = 'SHADOWMAP_TYPE_VSM'), t ); } function wP(e) { let t = 'ENVMAP_TYPE_CUBE'; if (e.envMap) switch (e.envMapMode) { case ya: case xa: t = 'ENVMAP_TYPE_CUBE'; break; case Ch: t = 'ENVMAP_TYPE_CUBE_UV'; break; } return t; } function _P(e) { let t = 'ENVMAP_MODE_REFLECTION'; if (e.envMap) switch (e.envMapMode) { case xa: t = 'ENVMAP_MODE_REFRACTION'; break; } return t; } function AP(e) { let t = 'ENVMAP_BLENDING_NONE'; if (e.envMap) switch (e.combine) { case ow: t = 'ENVMAP_BLENDING_MULTIPLY'; break; case mM: t = 'ENVMAP_BLENDING_MIX'; break; case gM: t = 'ENVMAP_BLENDING_ADD'; break; } return t; } function SP(e) { let t = e.envMapCubeUVHeight; if (t === null) return null; let i = Math.log2(t) - 2, r = 1 / t; return { texelWidth: 1 / (3 * Math.max(Math.pow(2, i), 7 * 16)), texelHeight: r, maxMip: i }; } function MP(e, t, i, r) { let s = e.getContext(), n = i.defines, a = i.vertexShader, o = i.fragmentShader, l = bP(i), h = wP(i), u = _P(i), c = AP(i), d = SP(i), p = i.isWebGL2 ? '' : pP(i), f = fP(n), g = s.createProgram(), m, v, y = i.glslVersion ? '#version ' + i.glslVersion + ` ` : ''; i.isRawShaderMaterial ? ((m = [f].filter(Gl).join(` `)), m.length > 0 && (m += ` `), (v = [p, f].filter(Gl).join(` `)), v.length > 0 && (v += ` `)) : ((m = [ oy(i), '#define SHADER_NAME ' + i.shaderName, f, i.instancing ? '#define USE_INSTANCING' : '', i.instancingColor ? '#define USE_INSTANCING_COLOR' : '', i.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', i.useFog && i.fog ? '#define USE_FOG' : '', i.useFog && i.fogExp2 ? '#define FOG_EXP2' : '', i.map ? '#define USE_MAP' : '', i.envMap ? '#define USE_ENVMAP' : '', i.envMap ? '#define ' + u : '', i.lightMap ? '#define USE_LIGHTMAP' : '', i.aoMap ? '#define USE_AOMAP' : '', i.emissiveMap ? '#define USE_EMISSIVEMAP' : '', i.bumpMap ? '#define USE_BUMPMAP' : '', i.normalMap ? '#define USE_NORMALMAP' : '', i.normalMap && i.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', i.normalMap && i.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', i.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', i.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', i.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', i.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '', i.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '', i.displacementMap && i.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', i.specularMap ? '#define USE_SPECULARMAP' : '', i.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', i.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', i.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', i.metalnessMap ? '#define USE_METALNESSMAP' : '', i.alphaMap ? '#define USE_ALPHAMAP' : '', i.transmission ? '#define USE_TRANSMISSION' : '', i.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', i.thicknessMap ? '#define USE_THICKNESSMAP' : '', i.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', i.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', i.vertexTangents ? '#define USE_TANGENT' : '', i.vertexColors ? '#define USE_COLOR' : '', i.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', i.vertexUvs ? '#define USE_UV' : '', i.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', i.flatShading ? '#define FLAT_SHADED' : '', i.skinning ? '#define USE_SKINNING' : '', i.morphTargets ? '#define USE_MORPHTARGETS' : '', i.morphNormals && i.flatShading === !1 ? '#define USE_MORPHNORMALS' : '', i.morphColors && i.isWebGL2 ? '#define USE_MORPHCOLORS' : '', i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + i.morphTextureStride : '', i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + i.morphTargetsCount : '', i.doubleSided ? '#define DOUBLE_SIDED' : '', i.flipSided ? '#define FLIP_SIDED' : '', i.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', i.shadowMapEnabled ? '#define ' + l : '', i.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', i.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', i.logarithmicDepthBuffer && i.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', '\tattribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', '\tattribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', '\tattribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', '\tattribute vec4 color;', '#elif defined( USE_COLOR )', '\tattribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', '\tattribute vec3 morphTarget0;', '\tattribute vec3 morphTarget1;', '\tattribute vec3 morphTarget2;', '\tattribute vec3 morphTarget3;', '\t#ifdef USE_MORPHNORMALS', '\t\tattribute vec3 morphNormal0;', '\t\tattribute vec3 morphNormal1;', '\t\tattribute vec3 morphNormal2;', '\t\tattribute vec3 morphNormal3;', '\t#else', '\t\tattribute vec3 morphTarget4;', '\t\tattribute vec3 morphTarget5;', '\t\tattribute vec3 morphTarget6;', '\t\tattribute vec3 morphTarget7;', '\t#endif', '#endif', '#ifdef USE_SKINNING', '\tattribute vec4 skinIndex;', '\tattribute vec4 skinWeight;', '#endif', ` ` ].filter(Gl).join(` `)), (v = [ p, oy(i), '#define SHADER_NAME ' + i.shaderName, f, i.useFog && i.fog ? '#define USE_FOG' : '', i.useFog && i.fogExp2 ? '#define FOG_EXP2' : '', i.map ? '#define USE_MAP' : '', i.matcap ? '#define USE_MATCAP' : '', i.envMap ? '#define USE_ENVMAP' : '', i.envMap ? '#define ' + h : '', i.envMap ? '#define ' + u : '', i.envMap ? '#define ' + c : '', d ? '#define CUBEUV_TEXEL_WIDTH ' + d.texelWidth : '', d ? '#define CUBEUV_TEXEL_HEIGHT ' + d.texelHeight : '', d ? '#define CUBEUV_MAX_MIP ' + d.maxMip + '.0' : '', i.lightMap ? '#define USE_LIGHTMAP' : '', i.aoMap ? '#define USE_AOMAP' : '', i.emissiveMap ? '#define USE_EMISSIVEMAP' : '', i.bumpMap ? '#define USE_BUMPMAP' : '', i.normalMap ? '#define USE_NORMALMAP' : '', i.normalMap && i.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', i.normalMap && i.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', i.clearcoat ? '#define USE_CLEARCOAT' : '', i.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', i.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', i.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', i.iridescence ? '#define USE_IRIDESCENCE' : '', i.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '', i.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '', i.specularMap ? '#define USE_SPECULARMAP' : '', i.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', i.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', i.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', i.metalnessMap ? '#define USE_METALNESSMAP' : '', i.alphaMap ? '#define USE_ALPHAMAP' : '', i.alphaTest ? '#define USE_ALPHATEST' : '', i.sheen ? '#define USE_SHEEN' : '', i.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', i.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', i.transmission ? '#define USE_TRANSMISSION' : '', i.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', i.thicknessMap ? '#define USE_THICKNESSMAP' : '', i.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '', i.vertexTangents ? '#define USE_TANGENT' : '', i.vertexColors || i.instancingColor ? '#define USE_COLOR' : '', i.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', i.vertexUvs ? '#define USE_UV' : '', i.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', i.gradientMap ? '#define USE_GRADIENTMAP' : '', i.flatShading ? '#define FLAT_SHADED' : '', i.doubleSided ? '#define DOUBLE_SIDED' : '', i.flipSided ? '#define FLIP_SIDED' : '', i.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', i.shadowMapEnabled ? '#define ' + l : '', i.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', i.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', i.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', i.logarithmicDepthBuffer && i.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', i.toneMapping !== Gs ? '#define TONE_MAPPING' : '', i.toneMapping !== Gs ? Ze.tonemapping_pars_fragment : '', i.toneMapping !== Gs ? uP('toneMapping', i.toneMapping) : '', i.dithering ? '#define DITHERING' : '', i.opaque ? '#define OPAQUE' : '', Ze.encodings_pars_fragment, dP('linearToOutputTexel', i.outputEncoding), i.useDepthPacking ? '#define DEPTH_PACKING ' + i.depthPacking : '', ` ` ].filter(Gl).join(` `))), (a = Gf(a)), (a = sy(a, i)), (a = ny(a, i)), (o = Gf(o)), (o = sy(o, i)), (o = ny(o, i)), (a = ay(a)), (o = ay(o)), i.isWebGL2 && i.isRawShaderMaterial !== !0 && ((y = `#version 300 es `), (m = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join(` `) + ` ` + m), (v = [ '#define varying in', i.glslVersion === L0 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', i.glslVersion === L0 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad' ].join(` `) + ` ` + v)); let b = y + m + a, x = y + v + o, w = iy(s, 35633, b), A = iy(s, 35632, x); if ( (s.attachShader(g, w), s.attachShader(g, A), i.index0AttributeName !== void 0 ? s.bindAttribLocation(g, 0, i.index0AttributeName) : i.morphTargets === !0 && s.bindAttribLocation(g, 0, 'position'), s.linkProgram(g), e.debug.checkShaderErrors) ) { let M = s.getProgramInfoLog(g).trim(), C = s.getShaderInfoLog(w).trim(), T = s.getShaderInfoLog(A).trim(), P = !0, L = !0; if (s.getProgramParameter(g, 35714) === !1) { P = !1; let D = ry(s, w, 'vertex'), k = ry(s, A, 'fragment'); console.error( 'THREE.WebGLProgram: Shader Error ' + s.getError() + ' - VALIDATE_STATUS ' + s.getProgramParameter(g, 35715) + ` Program Info Log: ` + M + ` ` + D + ` ` + k ); } else M !== '' ? console.warn('THREE.WebGLProgram: Program Info Log:', M) : (C === '' || T === '') && (L = !1); L && (this.diagnostics = { runnable: P, programLog: M, vertexShader: { log: C, prefix: m }, fragmentShader: { log: T, prefix: v } }); } s.deleteShader(w), s.deleteShader(A); let S; this.getUniforms = function () { return S === void 0 && (S = new Jc(s, g)), S; }; let _; return ( (this.getAttributes = function () { return _ === void 0 && (_ = mP(s, g)), _; }), (this.destroy = function () { r.releaseStatesOfProgram(this), s.deleteProgram(g), (this.program = void 0); }), (this.name = i.shaderName), (this.id = lP++), (this.cacheKey = t), (this.usedTimes = 1), (this.program = g), (this.vertexShader = w), (this.fragmentShader = A), this ); } var EP = 0, CP = class { constructor() { (this.shaderCache = new Map()), (this.materialCache = new Map()); } update(e) { let t = e.vertexShader, i = e.fragmentShader, r = this._getShaderStage(t), s = this._getShaderStage(i), n = this._getShaderCacheForMaterial(e); return n.has(r) === !1 && (n.add(r), r.usedTimes++), n.has(s) === !1 && (n.add(s), s.usedTimes++), this; } remove(e) { let t = this.materialCache.get(e); for (let i of t) i.usedTimes--, i.usedTimes === 0 && this.shaderCache.delete(i.code); return this.materialCache.delete(e), this; } getVertexShaderID(e) { return this._getShaderStage(e.vertexShader).id; } getFragmentShaderID(e) { return this._getShaderStage(e.fragmentShader).id; } dispose() { this.shaderCache.clear(), this.materialCache.clear(); } _getShaderCacheForMaterial(e) { let t = this.materialCache, i = t.get(e); return i === void 0 && ((i = new Set()), t.set(e, i)), i; } _getShaderStage(e) { let t = this.shaderCache, i = t.get(e); return i === void 0 && ((i = new TP(e)), t.set(e, i)), i; } }, TP = class { constructor(e) { (this.id = EP++), (this.code = e), (this.usedTimes = 0); } }; function PP(e, t, i, r, s, n, a) { let o = new hg(), l = new CP(), h = [], u = s.isWebGL2, c = s.logarithmicDepthBuffer, d = s.vertexTextures, p = s.precision, f = { MeshDepthMaterial: 'depth', MeshDistanceMaterial: 'distanceRGBA', MeshNormalMaterial: 'normal', MeshBasicMaterial: 'basic', MeshLambertMaterial: 'lambert', MeshPhongMaterial: 'phong', MeshToonMaterial: 'toon', MeshStandardMaterial: 'physical', MeshPhysicalMaterial: 'physical', MeshMatcapMaterial: 'matcap', LineBasicMaterial: 'basic', LineDashedMaterial: 'dashed', PointsMaterial: 'points', ShadowMaterial: 'shadow', SpriteMaterial: 'sprite' }; function g(_, M, C, T, P) { let L = T.fog, D = P.geometry, k = _.isMeshStandardMaterial ? T.environment : null, W = (_.isMeshStandardMaterial ? i : t).get(_.envMap || k), X = !!W && W.mapping === Ch ? W.image.height : null, z = f[_.type]; _.precision !== null && ((p = s.getMaxPrecision(_.precision)), p !== _.precision && console.warn('THREE.WebGLProgram.getParameters:', _.precision, 'not supported, using', p, 'instead.')); let j = D.morphAttributes.position || D.morphAttributes.normal || D.morphAttributes.color, U = j !== void 0 ? j.length : 0, N = 0; D.morphAttributes.position !== void 0 && (N = 1), D.morphAttributes.normal !== void 0 && (N = 2), D.morphAttributes.color !== void 0 && (N = 3); let B, H, Q, Y; if (z) { let J = ss[z]; (B = J.vertexShader), (H = J.fragmentShader); } else (B = _.vertexShader), (H = _.fragmentShader), l.update(_), (Q = l.getVertexShaderID(_)), (Y = l.getFragmentShaderID(_)); let F = e.getRenderTarget(), se = _.alphaTest > 0, V = _.clearcoat > 0, ee = _.iridescence > 0; return { isWebGL2: u, shaderID: z, shaderName: _.type, vertexShader: B, fragmentShader: H, defines: _.defines, customVertexShaderID: Q, customFragmentShaderID: Y, isRawShaderMaterial: _.isRawShaderMaterial === !0, glslVersion: _.glslVersion, precision: p, instancing: P.isInstancedMesh === !0, instancingColor: P.isInstancedMesh === !0 && P.instanceColor !== null, supportsVertexTextures: d, outputEncoding: F === null ? e.outputEncoding : F.isXRRenderTarget === !0 ? F.texture.encoding : gs, map: !!_.map, matcap: !!_.matcap, envMap: !!W, envMapMode: W && W.mapping, envMapCubeUVHeight: X, lightMap: !!_.lightMap, aoMap: !!_.aoMap, emissiveMap: !!_.emissiveMap, bumpMap: !!_.bumpMap, normalMap: !!_.normalMap, objectSpaceNormalMap: _.normalMapType === FM, tangentSpaceNormalMap: _.normalMapType === UM, decodeVideoTexture: !!_.map && _.map.isVideoTexture === !0 && _.map.encoding === Ke, clearcoat: V, clearcoatMap: V && !!_.clearcoatMap, clearcoatRoughnessMap: V && !!_.clearcoatRoughnessMap, clearcoatNormalMap: V && !!_.clearcoatNormalMap, iridescence: ee, iridescenceMap: ee && !!_.iridescenceMap, iridescenceThicknessMap: ee && !!_.iridescenceThicknessMap, displacementMap: !!_.displacementMap, roughnessMap: !!_.roughnessMap, metalnessMap: !!_.metalnessMap, specularMap: !!_.specularMap, specularIntensityMap: !!_.specularIntensityMap, specularColorMap: !!_.specularColorMap, opaque: _.transparent === !1 && _.blending === Ao, alphaMap: !!_.alphaMap, alphaTest: se, gradientMap: !!_.gradientMap, sheen: _.sheen > 0, sheenColorMap: !!_.sheenColorMap, sheenRoughnessMap: !!_.sheenRoughnessMap, transmission: _.transmission > 0, transmissionMap: !!_.transmissionMap, thicknessMap: !!_.thicknessMap, combine: _.combine, vertexTangents: !!_.normalMap && !!D.attributes.tangent, vertexColors: _.vertexColors, vertexAlphas: _.vertexColors === !0 && !!D.attributes.color && D.attributes.color.itemSize === 4, vertexUvs: !!_.map || !!_.bumpMap || !!_.normalMap || !!_.specularMap || !!_.alphaMap || !!_.emissiveMap || !!_.roughnessMap || !!_.metalnessMap || !!_.clearcoatMap || !!_.clearcoatRoughnessMap || !!_.clearcoatNormalMap || !!_.iridescenceMap || !!_.iridescenceThicknessMap || !!_.displacementMap || !!_.transmissionMap || !!_.thicknessMap || !!_.specularIntensityMap || !!_.specularColorMap || !!_.sheenColorMap || !!_.sheenRoughnessMap, uvsVertexOnly: !( !!_.map || !!_.bumpMap || !!_.normalMap || !!_.specularMap || !!_.alphaMap || !!_.emissiveMap || !!_.roughnessMap || !!_.metalnessMap || !!_.clearcoatNormalMap || !!_.iridescenceMap || !!_.iridescenceThicknessMap || _.transmission > 0 || !!_.transmissionMap || !!_.thicknessMap || !!_.specularIntensityMap || !!_.specularColorMap || _.sheen > 0 || !!_.sheenColorMap || !!_.sheenRoughnessMap ) && !!_.displacementMap, fog: !!L, useFog: _.fog === !0, fogExp2: L && L.isFogExp2, flatShading: !!_.flatShading, sizeAttenuation: _.sizeAttenuation, logarithmicDepthBuffer: c, skinning: P.isSkinnedMesh === !0, morphTargets: D.morphAttributes.position !== void 0, morphNormals: D.morphAttributes.normal !== void 0, morphColors: D.morphAttributes.color !== void 0, morphTargetsCount: U, morphTextureStride: N, numDirLights: M.directional.length, numPointLights: M.point.length, numSpotLights: M.spot.length, numSpotLightMaps: M.spotLightMap.length, numRectAreaLights: M.rectArea.length, numHemiLights: M.hemi.length, numDirLightShadows: M.directionalShadowMap.length, numPointLightShadows: M.pointShadowMap.length, numSpotLightShadows: M.spotShadowMap.length, numSpotLightShadowsWithMaps: M.numSpotLightShadowsWithMaps, numClippingPlanes: a.numPlanes, numClipIntersection: a.numIntersection, dithering: _.dithering, shadowMapEnabled: e.shadowMap.enabled && C.length > 0, shadowMapType: e.shadowMap.type, toneMapping: _.toneMapped ? e.toneMapping : Gs, physicallyCorrectLights: e.physicallyCorrectLights, premultipliedAlpha: _.premultipliedAlpha, doubleSided: _.side === er, flipSided: _.side === hi, useDepthPacking: !!_.depthPacking, depthPacking: _.depthPacking || 0, index0AttributeName: _.index0AttributeName, extensionDerivatives: _.extensions && _.extensions.derivatives, extensionFragDepth: _.extensions && _.extensions.fragDepth, extensionDrawBuffers: _.extensions && _.extensions.drawBuffers, extensionShaderTextureLOD: _.extensions && _.extensions.shaderTextureLOD, rendererExtensionFragDepth: u || r.has('EXT_frag_depth'), rendererExtensionDrawBuffers: u || r.has('WEBGL_draw_buffers'), rendererExtensionShaderTextureLod: u || r.has('EXT_shader_texture_lod'), customProgramCacheKey: _.customProgramCacheKey() }; } function m(_) { let M = []; if ((_.shaderID ? M.push(_.shaderID) : (M.push(_.customVertexShaderID), M.push(_.customFragmentShaderID)), _.defines !== void 0)) for (let C in _.defines) M.push(C), M.push(_.defines[C]); return _.isRawShaderMaterial === !1 && (v(M, _), y(M, _), M.push(e.outputEncoding)), M.push(_.customProgramCacheKey), M.join(); } function v(_, M) { _.push(M.precision), _.push(M.outputEncoding), _.push(M.envMapMode), _.push(M.envMapCubeUVHeight), _.push(M.combine), _.push(M.vertexUvs), _.push(M.fogExp2), _.push(M.sizeAttenuation), _.push(M.morphTargetsCount), _.push(M.morphAttributeCount), _.push(M.numDirLights), _.push(M.numPointLights), _.push(M.numSpotLights), _.push(M.numSpotLightMaps), _.push(M.numHemiLights), _.push(M.numRectAreaLights), _.push(M.numDirLightShadows), _.push(M.numPointLightShadows), _.push(M.numSpotLightShadows), _.push(M.numSpotLightShadowsWithMaps), _.push(M.shadowMapType), _.push(M.toneMapping), _.push(M.numClippingPlanes), _.push(M.numClipIntersection), _.push(M.depthPacking); } function y(_, M) { o.disableAll(), M.isWebGL2 && o.enable(0), M.supportsVertexTextures && o.enable(1), M.instancing && o.enable(2), M.instancingColor && o.enable(3), M.map && o.enable(4), M.matcap && o.enable(5), M.envMap && o.enable(6), M.lightMap && o.enable(7), M.aoMap && o.enable(8), M.emissiveMap && o.enable(9), M.bumpMap && o.enable(10), M.normalMap && o.enable(11), M.objectSpaceNormalMap && o.enable(12), M.tangentSpaceNormalMap && o.enable(13), M.clearcoat && o.enable(14), M.clearcoatMap && o.enable(15), M.clearcoatRoughnessMap && o.enable(16), M.clearcoatNormalMap && o.enable(17), M.iridescence && o.enable(18), M.iridescenceMap && o.enable(19), M.iridescenceThicknessMap && o.enable(20), M.displacementMap && o.enable(21), M.specularMap && o.enable(22), M.roughnessMap && o.enable(23), M.metalnessMap && o.enable(24), M.gradientMap && o.enable(25), M.alphaMap && o.enable(26), M.alphaTest && o.enable(27), M.vertexColors && o.enable(28), M.vertexAlphas && o.enable(29), M.vertexUvs && o.enable(30), M.vertexTangents && o.enable(31), M.uvsVertexOnly && o.enable(32), _.push(o.mask), o.disableAll(), M.fog && o.enable(0), M.useFog && o.enable(1), M.flatShading && o.enable(2), M.logarithmicDepthBuffer && o.enable(3), M.skinning && o.enable(4), M.morphTargets && o.enable(5), M.morphNormals && o.enable(6), M.morphColors && o.enable(7), M.premultipliedAlpha && o.enable(8), M.shadowMapEnabled && o.enable(9), M.physicallyCorrectLights && o.enable(10), M.doubleSided && o.enable(11), M.flipSided && o.enable(12), M.useDepthPacking && o.enable(13), M.dithering && o.enable(14), M.specularIntensityMap && o.enable(15), M.specularColorMap && o.enable(16), M.transmission && o.enable(17), M.transmissionMap && o.enable(18), M.thicknessMap && o.enable(19), M.sheen && o.enable(20), M.sheenColorMap && o.enable(21), M.sheenRoughnessMap && o.enable(22), M.decodeVideoTexture && o.enable(23), M.opaque && o.enable(24), _.push(o.mask); } function b(_) { let M = f[_.type], C; if (M) { let T = ss[M]; C = qo.clone(T.uniforms); } else C = _.uniforms; return C; } function x(_, M) { let C; for (let T = 0, P = h.length; T < P; T++) { let L = h[T]; if (L.cacheKey === M) { (C = L), ++C.usedTimes; break; } } return C === void 0 && ((C = new MP(e, M, _, n)), h.push(C)), C; } function w(_) { if (--_.usedTimes === 0) { let M = h.indexOf(_); (h[M] = h[h.length - 1]), h.pop(), _.destroy(); } } function A(_) { l.remove(_); } function S() { l.dispose(); } return { getParameters: g, getProgramCacheKey: m, getUniforms: b, acquireProgram: x, releaseProgram: w, releaseShaderCache: A, programs: h, dispose: S }; } function DP() { let e = new WeakMap(); function t(n) { let a = e.get(n); return a === void 0 && ((a = {}), e.set(n, a)), a; } function i(n) { e.delete(n); } function r(n, a, o) { e.get(n)[a] = o; } function s() { e = new WeakMap(); } return { get: t, remove: i, update: r, dispose: s }; } function LP(e, t) { return e.groupOrder !== t.groupOrder ? e.groupOrder - t.groupOrder : e.renderOrder !== t.renderOrder ? e.renderOrder - t.renderOrder : e.material.id !== t.material.id ? e.material.id - t.material.id : e.z !== t.z ? e.z - t.z : e.id - t.id; } function ly(e, t) { return e.groupOrder !== t.groupOrder ? e.groupOrder - t.groupOrder : e.renderOrder !== t.renderOrder ? e.renderOrder - t.renderOrder : e.z !== t.z ? t.z - e.z : e.id - t.id; } function hy() { let e = [], t = 0, i = [], r = [], s = []; function n() { (t = 0), (i.length = 0), (r.length = 0), (s.length = 0); } function a(c, d, p, f, g, m) { let v = e[t]; return ( v === void 0 ? ((v = { id: c.id, object: c, geometry: d, material: p, groupOrder: f, renderOrder: c.renderOrder, z: g, group: m }), (e[t] = v)) : ((v.id = c.id), (v.object = c), (v.geometry = d), (v.material = p), (v.groupOrder = f), (v.renderOrder = c.renderOrder), (v.z = g), (v.group = m)), t++, v ); } function o(c, d, p, f, g, m) { let v = a(c, d, p, f, g, m); p.transmission > 0 ? r.push(v) : p.transparent === !0 ? s.push(v) : i.push(v); } function l(c, d, p, f, g, m) { let v = a(c, d, p, f, g, m); p.transmission > 0 ? r.unshift(v) : p.transparent === !0 ? s.unshift(v) : i.unshift(v); } function h(c, d) { i.length > 1 && i.sort(c || LP), r.length > 1 && r.sort(d || ly), s.length > 1 && s.sort(d || ly); } function u() { for (let c = t, d = e.length; c < d; c++) { let p = e[c]; if (p.id === null) break; (p.id = null), (p.object = null), (p.geometry = null), (p.material = null), (p.group = null); } } return { opaque: i, transmissive: r, transparent: s, init: n, push: o, unshift: l, finish: u, sort: h }; } function OP() { let e = new WeakMap(); function t(r, s) { let n = e.get(r), a; return n === void 0 ? ((a = new hy()), e.set(r, [a])) : s >= n.length ? ((a = new hy()), n.push(a)) : (a = n[s]), a; } function i() { e = new WeakMap(); } return { get: t, dispose: i }; } function IP() { let e = {}; return { get: function (t) { if (e[t.id] !== void 0) return e[t.id]; let i; switch (t.type) { case 'DirectionalLight': i = { direction: new E(), color: new Ge() }; break; case 'SpotLight': i = { position: new E(), direction: new E(), color: new Ge(), distance: 0, coneCos: 0, penumbraCos: 0, decay: 0 }; break; case 'PointLight': i = { position: new E(), color: new Ge(), distance: 0, decay: 0 }; break; case 'HemisphereLight': i = { direction: new E(), skyColor: new Ge(), groundColor: new Ge() }; break; case 'RectAreaLight': i = { color: new Ge(), position: new E(), halfWidth: new E(), halfHeight: new E() }; break; } return (e[t.id] = i), i; } }; } function RP() { let e = {}; return { get: function (t) { if (e[t.id] !== void 0) return e[t.id]; let i; switch (t.type) { case 'DirectionalLight': i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G() }; break; case 'SpotLight': i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G() }; break; case 'PointLight': i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G(), shadowCameraNear: 1, shadowCameraFar: 1e3 }; break; } return (e[t.id] = i), i; } }; } var BP = 0; function zP(e, t) { return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (e.map ? 1 : 0); } function NP(e, t) { let i = new IP(), r = RP(), s = { version: 0, hash: { directionalLength: -1, pointLength: -1, spotLength: -1, rectAreaLength: -1, hemiLength: -1, numDirectionalShadows: -1, numPointShadows: -1, numSpotShadows: -1, numSpotMaps: -1 }, ambient: [0, 0, 0], probe: [], directional: [], directionalShadow: [], directionalShadowMap: [], directionalShadowMatrix: [], spot: [], spotLightMap: [], spotShadow: [], spotShadowMap: [], spotLightMatrix: [], rectArea: [], rectAreaLTC1: null, rectAreaLTC2: null, point: [], pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], hemi: [], numSpotLightShadowsWithMaps: 0 }; for (let u = 0; u < 9; u++) s.probe.push(new E()); let n = new E(), a = new ve(), o = new ve(); function l(u, c) { let d = 0, p = 0, f = 0; for (let T = 0; T < 9; T++) s.probe[T].set(0, 0, 0); let g = 0, m = 0, v = 0, y = 0, b = 0, x = 0, w = 0, A = 0, S = 0, _ = 0; u.sort(zP); let M = c !== !0 ? Math.PI : 1; for (let T = 0, P = u.length; T < P; T++) { let L = u[T], D = L.color, k = L.intensity, W = L.distance, X = L.shadow && L.shadow.map ? L.shadow.map.texture : null; if (L.isAmbientLight) (d += D.r * k * M), (p += D.g * k * M), (f += D.b * k * M); else if (L.isLightProbe) for (let z = 0; z < 9; z++) s.probe[z].addScaledVector(L.sh.coefficients[z], k); else if (L.isDirectionalLight) { let z = i.get(L); if ((z.color.copy(L.color).multiplyScalar(L.intensity * M), L.castShadow)) { let j = L.shadow, U = r.get(L); (U.shadowBias = j.bias), (U.shadowNormalBias = j.normalBias), (U.shadowRadius = j.radius), (U.shadowMapSize = j.mapSize), (s.directionalShadow[g] = U), (s.directionalShadowMap[g] = X), (s.directionalShadowMatrix[g] = L.shadow.matrix), x++; } (s.directional[g] = z), g++; } else if (L.isSpotLight) { let z = i.get(L); z.position.setFromMatrixPosition(L.matrixWorld), z.color.copy(D).multiplyScalar(k * M), (z.distance = W), (z.coneCos = Math.cos(L.angle)), (z.penumbraCos = Math.cos(L.angle * (1 - L.penumbra))), (z.decay = L.decay), (s.spot[v] = z); let j = L.shadow; if ( (L.map && ((s.spotLightMap[S] = L.map), S++, j.updateMatrices(L), L.castShadow && _++), (s.spotLightMatrix[v] = j.matrix), L.castShadow) ) { let U = r.get(L); (U.shadowBias = j.bias), (U.shadowNormalBias = j.normalBias), (U.shadowRadius = j.radius), (U.shadowMapSize = j.mapSize), (s.spotShadow[v] = U), (s.spotShadowMap[v] = X), A++; } v++; } else if (L.isRectAreaLight) { let z = i.get(L); z.color.copy(D).multiplyScalar(k), z.halfWidth.set(L.width * 0.5, 0, 0), z.halfHeight.set(0, L.height * 0.5, 0), (s.rectArea[y] = z), y++; } else if (L.isPointLight) { let z = i.get(L); if ((z.color.copy(L.color).multiplyScalar(L.intensity * M), (z.distance = L.distance), (z.decay = L.decay), L.castShadow)) { let j = L.shadow, U = r.get(L); (U.shadowBias = j.bias), (U.shadowNormalBias = j.normalBias), (U.shadowRadius = j.radius), (U.shadowMapSize = j.mapSize), (U.shadowCameraNear = j.camera.near), (U.shadowCameraFar = j.camera.far), (s.pointShadow[m] = U), (s.pointShadowMap[m] = X), (s.pointShadowMatrix[m] = L.shadow.matrix), w++; } (s.point[m] = z), m++; } else if (L.isHemisphereLight) { let z = i.get(L); z.skyColor.copy(L.color).multiplyScalar(k * M), z.groundColor.copy(L.groundColor).multiplyScalar(k * M), (s.hemi[b] = z), b++; } } y > 0 && (t.isWebGL2 || e.has('OES_texture_float_linear') === !0 ? ((s.rectAreaLTC1 = ge.LTC_FLOAT_1), (s.rectAreaLTC2 = ge.LTC_FLOAT_2)) : e.has('OES_texture_half_float_linear') === !0 ? ((s.rectAreaLTC1 = ge.LTC_HALF_1), (s.rectAreaLTC2 = ge.LTC_HALF_2)) : console.error('THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.')), (s.ambient[0] = d), (s.ambient[1] = p), (s.ambient[2] = f); let C = s.hash; (C.directionalLength !== g || C.pointLength !== m || C.spotLength !== v || C.rectAreaLength !== y || C.hemiLength !== b || C.numDirectionalShadows !== x || C.numPointShadows !== w || C.numSpotShadows !== A || C.numSpotMaps !== S) && ((s.directional.length = g), (s.spot.length = v), (s.rectArea.length = y), (s.point.length = m), (s.hemi.length = b), (s.directionalShadow.length = x), (s.directionalShadowMap.length = x), (s.pointShadow.length = w), (s.pointShadowMap.length = w), (s.spotShadow.length = A), (s.spotShadowMap.length = A), (s.directionalShadowMatrix.length = x), (s.pointShadowMatrix.length = w), (s.spotLightMatrix.length = A + S - _), (s.spotLightMap.length = S), (s.numSpotLightShadowsWithMaps = _), (C.directionalLength = g), (C.pointLength = m), (C.spotLength = v), (C.rectAreaLength = y), (C.hemiLength = b), (C.numDirectionalShadows = x), (C.numPointShadows = w), (C.numSpotShadows = A), (C.numSpotMaps = S), (s.version = BP++)); } function h(u, c) { let d = 0, p = 0, f = 0, g = 0, m = 0, v = c.matrixWorldInverse; for (let y = 0, b = u.length; y < b; y++) { let x = u[y]; if (x.isDirectionalLight) { let w = s.directional[d]; w.direction.setFromMatrixPosition(x.matrixWorld), n.setFromMatrixPosition(x.target.matrixWorld), w.direction.sub(n), w.direction.transformDirection(v), d++; } else if (x.isSpotLight) { let w = s.spot[f]; w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(v), w.direction.setFromMatrixPosition(x.matrixWorld), n.setFromMatrixPosition(x.target.matrixWorld), w.direction.sub(n), w.direction.transformDirection(v), f++; } else if (x.isRectAreaLight) { let w = s.rectArea[g]; w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(v), o.identity(), a.copy(x.matrixWorld), a.premultiply(v), o.extractRotation(a), w.halfWidth.set(x.width * 0.5, 0, 0), w.halfHeight.set(0, x.height * 0.5, 0), w.halfWidth.applyMatrix4(o), w.halfHeight.applyMatrix4(o), g++; } else if (x.isPointLight) { let w = s.point[p]; w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(v), p++; } else if (x.isHemisphereLight) { let w = s.hemi[m]; w.direction.setFromMatrixPosition(x.matrixWorld), w.direction.transformDirection(v), m++; } } } return { setup: l, setupView: h, state: s }; } function cy(e, t) { let i = new NP(e, t), r = [], s = []; function n() { (r.length = 0), (s.length = 0); } function a(u) { r.push(u); } function o(u) { s.push(u); } function l(u) { i.setup(r, u); } function h(u) { i.setupView(r, u); } return { init: n, state: { lightsArray: r, shadowsArray: s, lights: i }, setupLights: l, setupLightsView: h, pushLight: a, pushShadow: o }; } function UP(e, t) { let i = new WeakMap(); function r(n, a = 0) { let o = i.get(n), l; return o === void 0 ? ((l = new cy(e, t)), i.set(n, [l])) : a >= o.length ? ((l = new cy(e, t)), o.push(l)) : (l = o[a]), l; } function s() { i = new WeakMap(); } return { get: r, dispose: s }; } var Aw = class extends Th { constructor(e) { super(), (this.isMeshDepthMaterial = !0), (this.type = 'MeshDepthMaterial'), (this.depthPacking = qs), (this.map = null), (this.alphaMap = null), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), (this.wireframe = !1), (this.wireframeLinewidth = 1), this.setValues(e); } copy(e) { return ( super.copy(e), (this.depthPacking = e.depthPacking), (this.map = e.map), (this.alphaMap = e.alphaMap), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), (this.wireframe = e.wireframe), (this.wireframeLinewidth = e.wireframeLinewidth), this ); } }, FP = class extends Th { constructor(e) { super(), (this.isMeshDistanceMaterial = !0), (this.type = 'MeshDistanceMaterial'), (this.referencePosition = new E()), (this.nearDistance = 1), (this.farDistance = 1e3), (this.map = null), (this.alphaMap = null), (this.displacementMap = null), (this.displacementScale = 1), (this.displacementBias = 0), this.setValues(e); } copy(e) { return ( super.copy(e), this.referencePosition.copy(e.referencePosition), (this.nearDistance = e.nearDistance), (this.farDistance = e.farDistance), (this.map = e.map), (this.alphaMap = e.alphaMap), (this.displacementMap = e.displacementMap), (this.displacementScale = e.displacementScale), (this.displacementBias = e.displacementBias), this ); } }, kP = `void main() { gl_Position = vec4( position, 1.0 ); }`, jP = `uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`; function GP(e, t, i) { let r = new dg(), s = new G(), n = new G(), a = new $e(), o = new Aw({ depthPacking: cw }), l = new FP(), h = {}, u = i.maxTextureSize, c = { [Vr]: hi, [hi]: Vr, [er]: er }, d = new ri({ defines: { VSM_SAMPLES: 8 }, uniforms: { shadow_pass: { value: null }, resolution: { value: new G() }, radius: { value: 4 } }, vertexShader: kP, fragmentShader: jP }), p = d.clone(); p.defines.HORIZONTAL_PASS = 1; let f = new Ve(); f.setAttribute('position', new Xe(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3)); let g = new tr(f, d), m = this; (this.enabled = !1), (this.autoUpdate = !0), (this.needsUpdate = !1), (this.type = og), (this.render = function (x, w, A) { if (m.enabled === !1 || (m.autoUpdate === !1 && m.needsUpdate === !1) || x.length === 0) return; let S = e.getRenderTarget(), _ = e.getActiveCubeFace(), M = e.getActiveMipmapLevel(), C = e.state; C.setBlending(fi), C.buffers.color.setClear(1, 1, 1, 1), C.buffers.depth.setTest(!0), C.setScissorTest(!1); for (let T = 0, P = x.length; T < P; T++) { let L = x[T], D = L.shadow; if (D === void 0) { console.warn('THREE.WebGLShadowMap:', L, 'has no shadow.'); continue; } if (D.autoUpdate === !1 && D.needsUpdate === !1) continue; s.copy(D.mapSize); let k = D.getFrameExtents(); if ( (s.multiply(k), n.copy(D.mapSize), (s.x > u || s.y > u) && (s.x > u && ((n.x = Math.floor(u / k.x)), (s.x = n.x * k.x), (D.mapSize.x = n.x)), s.y > u && ((n.y = Math.floor(u / k.y)), (s.y = n.y * k.y), (D.mapSize.y = n.y))), D.map === null) ) { let X = this.type !== jl ? { minFilter: Ot, magFilter: Ot } : {}; (D.map = new ii(s.x, s.y, X)), (D.map.texture.name = L.name + '.shadowMap'), D.camera.updateProjectionMatrix(); } e.setRenderTarget(D.map), e.clear(); let W = D.getViewportCount(); for (let X = 0; X < W; X++) { let z = D.getViewport(X); a.set(n.x * z.x, n.y * z.y, n.x * z.z, n.y * z.w), C.viewport(a), D.updateMatrices(L, X), (r = D.getFrustum()), b(w, A, D.camera, L, this.type); } D.isPointLightShadow !== !0 && this.type === jl && v(D, A), (D.needsUpdate = !1); } (m.needsUpdate = !1), e.setRenderTarget(S, _, M); }); function v(x, w) { let A = t.update(g); d.defines.VSM_SAMPLES !== x.blurSamples && ((d.defines.VSM_SAMPLES = x.blurSamples), (p.defines.VSM_SAMPLES = x.blurSamples), (d.needsUpdate = !0), (p.needsUpdate = !0)), x.mapPass === null && (x.mapPass = new ii(s.x, s.y)), (d.uniforms.shadow_pass.value = x.map.texture), (d.uniforms.resolution.value = x.mapSize), (d.uniforms.radius.value = x.radius), e.setRenderTarget(x.mapPass), e.clear(), e.renderBufferDirect(w, null, A, d, g, null), (p.uniforms.shadow_pass.value = x.mapPass.texture), (p.uniforms.resolution.value = x.mapSize), (p.uniforms.radius.value = x.radius), e.setRenderTarget(x.map), e.clear(), e.renderBufferDirect(w, null, A, p, g, null); } function y(x, w, A, S, _, M) { let C = null, T = A.isPointLight === !0 ? x.customDistanceMaterial : x.customDepthMaterial; if (T !== void 0) C = T; else if ( ((C = A.isPointLight === !0 ? l : o), (e.localClippingEnabled && w.clipShadows === !0 && Array.isArray(w.clippingPlanes) && w.clippingPlanes.length !== 0) || (w.displacementMap && w.displacementScale !== 0) || (w.alphaMap && w.alphaTest > 0) || (w.map && w.alphaTest > 0)) ) { let P = C.uuid, L = w.uuid, D = h[P]; D === void 0 && ((D = {}), (h[P] = D)); let k = D[L]; k === void 0 && ((k = C.clone()), (D[L] = k)), (C = k); } return ( (C.visible = w.visible), (C.wireframe = w.wireframe), M === jl ? (C.side = w.shadowSide !== null ? w.shadowSide : w.side) : (C.side = w.shadowSide !== null ? w.shadowSide : c[w.side]), (C.alphaMap = w.alphaMap), (C.alphaTest = w.alphaTest), (C.map = w.map), (C.clipShadows = w.clipShadows), (C.clippingPlanes = w.clippingPlanes), (C.clipIntersection = w.clipIntersection), (C.displacementMap = w.displacementMap), (C.displacementScale = w.displacementScale), (C.displacementBias = w.displacementBias), (C.wireframeLinewidth = w.wireframeLinewidth), (C.linewidth = w.linewidth), A.isPointLight === !0 && C.isMeshDistanceMaterial === !0 && (C.referencePosition.setFromMatrixPosition(A.matrixWorld), (C.nearDistance = S), (C.farDistance = _)), C ); } function b(x, w, A, S, _) { if (x.visible === !1) return; if ( x.layers.test(w.layers) && (x.isMesh || x.isLine || x.isPoints) && (x.castShadow || (x.receiveShadow && _ === jl)) && (!x.frustumCulled || r.intersectsObject(x)) ) { x.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse, x.matrixWorld); let C = t.update(x), T = x.material; if (Array.isArray(T)) { let P = C.groups; for (let L = 0, D = P.length; L < D; L++) { let k = P[L], W = T[k.materialIndex]; if (W && W.visible) { let X = y(x, W, S, A.near, A.far, _); e.renderBufferDirect(A, null, C, X, x, k); } } } else if (T.visible) { let P = y(x, T, S, A.near, A.far, _); e.renderBufferDirect(A, null, C, P, x, null); } } let M = x.children; for (let C = 0, T = M.length; C < T; C++) b(M[C], w, A, S, _); } } function VP(e, t, i) { let r = i.isWebGL2; function s() { let q = !1, ne = new $e(), de = null, Ae = new $e(0, 0, 0, 0); return { setMask: function (De) { de !== De && !q && (e.colorMask(De, De, De, De), (de = De)); }, setLocked: function (De) { q = De; }, setClear: function (De, ot, Xt, Ft, kn) { kn === !0 && ((De *= Ft), (ot *= Ft), (Xt *= Ft)), ne.set(De, ot, Xt, Ft), Ae.equals(ne) === !1 && (e.clearColor(De, ot, Xt, Ft), Ae.copy(ne)); }, reset: function () { (q = !1), (de = null), Ae.set(-1, 0, 0, 0); } }; } function n() { let q = !1, ne = null, de = null, Ae = null; return { setTest: function (De) { De ? se(2929) : V(2929); }, setMask: function (De) { ne !== De && !q && (e.depthMask(De), (ne = De)); }, setFunc: function (De) { if (de !== De) { switch (De) { case lM: e.depthFunc(512); break; case hM: e.depthFunc(519); break; case cM: e.depthFunc(513); break; case Bf: e.depthFunc(515); break; case dM: e.depthFunc(514); break; case uM: e.depthFunc(518); break; case pM: e.depthFunc(516); break; case fM: e.depthFunc(517); break; default: e.depthFunc(515); } de = De; } }, setLocked: function (De) { q = De; }, setClear: function (De) { Ae !== De && (e.clearDepth(De), (Ae = De)); }, reset: function () { (q = !1), (ne = null), (de = null), (Ae = null); } }; } function a() { let q = !1, ne = null, de = null, Ae = null, De = null, ot = null, Xt = null, Ft = null, kn = null; return { setTest: function (Dt) { q || (Dt ? se(2960) : V(2960)); }, setMask: function (Dt) { ne !== Dt && !q && (e.stencilMask(Dt), (ne = Dt)); }, setFunc: function (Dt, Ms, lr) { (de !== Dt || Ae !== Ms || De !== lr) && (e.stencilFunc(Dt, Ms, lr), (de = Dt), (Ae = Ms), (De = lr)); }, setOp: function (Dt, Ms, lr) { (ot !== Dt || Xt !== Ms || Ft !== lr) && (e.stencilOp(Dt, Ms, lr), (ot = Dt), (Xt = Ms), (Ft = lr)); }, setLocked: function (Dt) { q = Dt; }, setClear: function (Dt) { kn !== Dt && (e.clearStencil(Dt), (kn = Dt)); }, reset: function () { (q = !1), (ne = null), (de = null), (Ae = null), (De = null), (ot = null), (Xt = null), (Ft = null), (kn = null); } }; } let o = new s(), l = new n(), h = new a(), u = new WeakMap(), c = new WeakMap(), d = {}, p = {}, f = new WeakMap(), g = [], m = null, v = !1, y = null, b = null, x = null, w = null, A = null, S = null, _ = null, M = !1, C = null, T = null, P = null, L = null, D = null, k = e.getParameter(35661), W = !1, X = 0, z = e.getParameter(7938); z.indexOf('WebGL') !== -1 ? ((X = parseFloat(/^WebGL (\d)/.exec(z)[1])), (W = X >= 1)) : z.indexOf('OpenGL ES') !== -1 && ((X = parseFloat(/^OpenGL ES (\d)/.exec(z)[1])), (W = X >= 2)); let j = null, U = {}, N = e.getParameter(3088), B = e.getParameter(2978), H = new $e().fromArray(N), Q = new $e().fromArray(B); function Y(q, ne, de) { let Ae = new Uint8Array(4), De = e.createTexture(); e.bindTexture(q, De), e.texParameteri(q, 10241, 9728), e.texParameteri(q, 10240, 9728); for (let ot = 0; ot < de; ot++) e.texImage2D(ne + ot, 0, 6408, 1, 1, 0, 6408, 5121, Ae); return De; } let F = {}; (F[3553] = Y(3553, 3553, 1)), (F[34067] = Y(34067, 34069, 6)), o.setClear(0, 0, 0, 1), l.setClear(1), h.setClear(0), se(2929), l.setFunc(Bf), Te(!1), xe(Jv), se(2884), ue(fi); function se(q) { d[q] !== !0 && (e.enable(q), (d[q] = !0)); } function V(q) { d[q] !== !1 && (e.disable(q), (d[q] = !1)); } function ee(q, ne) { return p[q] !== ne ? (e.bindFramebuffer(q, ne), (p[q] = ne), r && (q === 36009 && (p[36160] = ne), q === 36160 && (p[36009] = ne)), !0) : !1; } function J(q, ne) { let de = g, Ae = !1; if (q) if (((de = f.get(ne)), de === void 0 && ((de = []), f.set(ne, de)), q.isWebGLMultipleRenderTargets)) { let De = q.texture; if (de.length !== De.length || de[0] !== 36064) { for (let ot = 0, Xt = De.length; ot < Xt; ot++) de[ot] = 36064 + ot; (de.length = De.length), (Ae = !0); } } else de[0] !== 36064 && ((de[0] = 36064), (Ae = !0)); else de[0] !== 1029 && ((de[0] = 1029), (Ae = !0)); Ae && (i.isWebGL2 ? e.drawBuffers(de) : t.get('WEBGL_draw_buffers').drawBuffersWEBGL(de)); } function fe(q) { return m !== q ? (e.useProgram(q), (m = q), !0) : !1; } let re = { [no]: 32774, [K2]: 32778, [J2]: 32779 }; if (r) (re[i0] = 32775), (re[r0] = 32776); else { let q = t.get('EXT_blend_minmax'); q !== null && ((re[i0] = q.MIN_EXT), (re[r0] = q.MAX_EXT)); } let oe = { [$2]: 0, [eM]: 1, [tM]: 768, [nw]: 770, [oM]: 776, [nM]: 774, [rM]: 772, [iM]: 769, [aw]: 771, [aM]: 775, [sM]: 773 }; function ue(q, ne, de, Ae, De, ot, Xt, Ft) { if (q === fi) { v === !0 && (V(3042), (v = !1)); return; } if ((v === !1 && (se(3042), (v = !0)), q !== Z2)) { if (q !== y || Ft !== M) { if (((b !== no || A !== no) && (e.blendEquation(32774), (b = no), (A = no)), Ft)) switch (q) { case Ao: e.blendFuncSeparate(1, 771, 1, 771); break; case $v: e.blendFunc(1, 1); break; case e0: e.blendFuncSeparate(0, 769, 0, 1); break; case t0: e.blendFuncSeparate(0, 768, 0, 770); break; default: console.error('THREE.WebGLState: Invalid blending: ', q); break; } else switch (q) { case Ao: e.blendFuncSeparate(770, 771, 1, 771); break; case $v: e.blendFunc(770, 1); break; case e0: e.blendFuncSeparate(0, 769, 0, 1); break; case t0: e.blendFunc(0, 768); break; default: console.error('THREE.WebGLState: Invalid blending: ', q); break; } (x = null), (w = null), (S = null), (_ = null), (y = q), (M = Ft); } return; } (De = De || ne), (ot = ot || de), (Xt = Xt || Ae), (ne !== b || De !== A) && (e.blendEquationSeparate(re[ne], re[De]), (b = ne), (A = De)), (de !== x || Ae !== w || ot !== S || Xt !== _) && (e.blendFuncSeparate(oe[de], oe[Ae], oe[ot], oe[Xt]), (x = de), (w = Ae), (S = ot), (_ = Xt)), (y = q), (M = !1); } function ye(q, ne) { q.side === er ? V(2884) : se(2884); let de = q.side === hi; ne && (de = !de), Te(de), q.blending === Ao && q.transparent === !1 ? ue(fi) : ue( q.blending, q.blendEquation, q.blendSrc, q.blendDst, q.blendEquationAlpha, q.blendSrcAlpha, q.blendDstAlpha, q.premultipliedAlpha ), l.setFunc(q.depthFunc), l.setTest(q.depthTest), l.setMask(q.depthWrite), o.setMask(q.colorWrite); let Ae = q.stencilWrite; h.setTest(Ae), Ae && (h.setMask(q.stencilWriteMask), h.setFunc(q.stencilFunc, q.stencilRef, q.stencilFuncMask), h.setOp(q.stencilFail, q.stencilZFail, q.stencilZPass)), Ie(q.polygonOffset, q.polygonOffsetFactor, q.polygonOffsetUnits), q.alphaToCoverage === !0 ? se(32926) : V(32926); } function Te(q) { C !== q && (q ? e.frontFace(2304) : e.frontFace(2305), (C = q)); } function xe(q) { q !== Y2 ? (se(2884), q !== T && (q === Jv ? e.cullFace(1029) : q === Q2 ? e.cullFace(1028) : e.cullFace(1032))) : V(2884), (T = q); } function we(q) { q !== P && (W && e.lineWidth(q), (P = q)); } function Ie(q, ne, de) { q ? (se(32823), (L !== ne || D !== de) && (e.polygonOffset(ne, de), (L = ne), (D = de))) : V(32823); } function He(q) { q ? se(3089) : V(3089); } function dt(q) { q === void 0 && (q = 33984 + k - 1), j !== q && (e.activeTexture(q), (j = q)); } function I(q, ne, de) { de === void 0 && (j === null ? (de = 33984 + k - 1) : (de = j)); let Ae = U[de]; Ae === void 0 && ((Ae = { type: void 0, texture: void 0 }), (U[de] = Ae)), (Ae.type !== q || Ae.texture !== ne) && (j !== de && (e.activeTexture(de), (j = de)), e.bindTexture(q, ne || F[q]), (Ae.type = q), (Ae.texture = ne)); } function O() { let q = U[j]; q !== void 0 && q.type !== void 0 && (e.bindTexture(q.type, null), (q.type = void 0), (q.texture = void 0)); } function ie() { try { e.compressedTexImage2D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function pe() { try { e.compressedTexImage3D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function me() { try { e.texSubImage2D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function be() { try { e.texSubImage3D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function We() { try { e.compressedTexSubImage2D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function Me() { try { e.compressedTexSubImage3D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function ce() { try { e.texStorage2D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function Fe() { try { e.texStorage3D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function Ee() { try { e.texImage2D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function _e() { try { e.texImage3D.apply(e, arguments); } catch (q) { console.error('THREE.WebGLState:', q); } } function Le(q) { H.equals(q) === !1 && (e.scissor(q.x, q.y, q.z, q.w), H.copy(q)); } function Ne(q) { Q.equals(q) === !1 && (e.viewport(q.x, q.y, q.z, q.w), Q.copy(q)); } function at(q, ne) { let de = c.get(ne); de === void 0 && ((de = new WeakMap()), c.set(ne, de)); let Ae = de.get(q); Ae === void 0 && ((Ae = e.getUniformBlockIndex(ne, q.name)), de.set(q, Ae)); } function Mt(q, ne) { let de = c.get(ne).get(q); u.get(ne) !== de && (e.uniformBlockBinding(ne, de, q.__bindingPointIndex), u.set(ne, de)); } function Wt() { e.disable(3042), e.disable(2884), e.disable(2929), e.disable(32823), e.disable(3089), e.disable(2960), e.disable(32926), e.blendEquation(32774), e.blendFunc(1, 0), e.blendFuncSeparate(1, 0, 1, 0), e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.depthMask(!0), e.depthFunc(513), e.clearDepth(1), e.stencilMask(4294967295), e.stencilFunc(519, 0, 4294967295), e.stencilOp(7680, 7680, 7680), e.clearStencil(0), e.cullFace(1029), e.frontFace(2305), e.polygonOffset(0, 0), e.activeTexture(33984), e.bindFramebuffer(36160, null), r === !0 && (e.bindFramebuffer(36009, null), e.bindFramebuffer(36008, null)), e.useProgram(null), e.lineWidth(1), e.scissor(0, 0, e.canvas.width, e.canvas.height), e.viewport(0, 0, e.canvas.width, e.canvas.height), (d = {}), (j = null), (U = {}), (p = {}), (f = new WeakMap()), (g = []), (m = null), (v = !1), (y = null), (b = null), (x = null), (w = null), (A = null), (S = null), (_ = null), (M = !1), (C = null), (T = null), (P = null), (L = null), (D = null), H.set(0, 0, e.canvas.width, e.canvas.height), Q.set(0, 0, e.canvas.width, e.canvas.height), o.reset(), l.reset(), h.reset(); } return { buffers: { color: o, depth: l, stencil: h }, enable: se, disable: V, bindFramebuffer: ee, drawBuffers: J, useProgram: fe, setBlending: ue, setMaterial: ye, setFlipSided: Te, setCullFace: xe, setLineWidth: we, setPolygonOffset: Ie, setScissorTest: He, activeTexture: dt, bindTexture: I, unbindTexture: O, compressedTexImage2D: ie, compressedTexImage3D: pe, texImage2D: Ee, texImage3D: _e, updateUBOMapping: at, uniformBlockBinding: Mt, texStorage2D: ce, texStorage3D: Fe, texSubImage2D: me, texSubImage3D: be, compressedTexSubImage2D: We, compressedTexSubImage3D: Me, scissor: Le, viewport: Ne, reset: Wt }; } function HP(e, t, i, r, s, n, a) { let o = s.isWebGL2, l = s.maxTextures, h = s.maxCubemapSize, u = s.maxTextureSize, c = s.maxSamples, d = t.has('WEBGL_multisampled_render_to_texture') ? t.get('WEBGL_multisampled_render_to_texture') : null, p = typeof navigator > 'u' ? !1 : /OculusBrowser/g.test(navigator.userAgent), f = new WeakMap(), g, m = new WeakMap(), v = !1; try { v = typeof OffscreenCanvas < 'u' && new OffscreenCanvas(1, 1).getContext('2d') !== null; } catch {} function y(I, O) { return v ? new OffscreenCanvas(I, O) : md('canvas'); } function b(I, O, ie, pe) { let me = 1; if (((I.width > pe || I.height > pe) && (me = pe / Math.max(I.width, I.height)), me < 1 || O === !0)) if ( (typeof HTMLImageElement < 'u' && I instanceof HTMLImageElement) || (typeof HTMLCanvasElement < 'u' && I instanceof HTMLCanvasElement) || (typeof ImageBitmap < 'u' && I instanceof ImageBitmap) ) { let be = O ? fd : Math.floor, We = be(me * I.width), Me = be(me * I.height); g === void 0 && (g = y(We, Me)); let ce = ie ? y(We, Me) : g; return ( (ce.width = We), (ce.height = Me), ce.getContext('2d').drawImage(I, 0, 0, We, Me), console.warn('THREE.WebGLRenderer: Texture has been resized from (' + I.width + 'x' + I.height + ') to (' + We + 'x' + Me + ').'), ce ); } else return 'data' in I && console.warn('THREE.WebGLRenderer: Image in DataTexture is too big (' + I.width + 'x' + I.height + ').'), I; return I; } function x(I) { return jf(I.width) && jf(I.height); } function w(I) { return o ? !1 : I.wrapS !== Ji || I.wrapT !== Ji || (I.minFilter !== Ot && I.minFilter !== mt); } function A(I, O) { return I.generateMipmaps && O && I.minFilter !== Ot && I.minFilter !== mt; } function S(I) { e.generateMipmap(I); } function _(I, O, ie, pe, me = !1) { if (o === !1) return O; if (I !== null) { if (e[I] !== void 0) return e[I]; console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + I + "'"); } let be = O; return ( O === 6403 && (ie === 5126 && (be = 33326), ie === 5131 && (be = 33325), ie === 5121 && (be = 33321)), O === 33319 && (ie === 5126 && (be = 33328), ie === 5131 && (be = 33327), ie === 5121 && (be = 33323)), O === 6408 && (ie === 5126 && (be = 34836), ie === 5131 && (be = 34842), ie === 5121 && (be = pe === Ke && me === !1 ? 35907 : 32856), ie === 32819 && (be = 32854), ie === 32820 && (be = 32855)), (be === 33325 || be === 33326 || be === 33327 || be === 33328 || be === 34842 || be === 34836) && t.get('EXT_color_buffer_float'), be ); } function M(I, O, ie) { return A(I, ie) === !0 || (I.isFramebufferTexture && I.minFilter !== Ot && I.minFilter !== mt) ? Math.log2(Math.max(O.width, O.height)) + 1 : I.mipmaps !== void 0 && I.mipmaps.length > 0 ? I.mipmaps.length : I.isCompressedTexture && Array.isArray(I.image) ? O.mipmaps.length : 1; } function C(I) { return I === Ot || I === s0 || I === Wu ? 9728 : 9729; } function T(I) { let O = I.target; O.removeEventListener('dispose', T), L(O), O.isVideoTexture && f.delete(O); } function P(I) { let O = I.target; O.removeEventListener('dispose', P), k(O); } function L(I) { let O = r.get(I); if (O.__webglInit === void 0) return; let ie = I.source, pe = m.get(ie); if (pe) { let me = pe[O.__cacheKey]; me.usedTimes--, me.usedTimes === 0 && D(I), Object.keys(pe).length === 0 && m.delete(ie); } r.remove(I); } function D(I) { let O = r.get(I); e.deleteTexture(O.__webglTexture); let ie = I.source, pe = m.get(ie); delete pe[O.__cacheKey], a.memory.textures--; } function k(I) { let O = I.texture, ie = r.get(I), pe = r.get(O); if ( (pe.__webglTexture !== void 0 && (e.deleteTexture(pe.__webglTexture), a.memory.textures--), I.depthTexture && I.depthTexture.dispose(), I.isWebGLCubeRenderTarget) ) for (let me = 0; me < 6; me++) e.deleteFramebuffer(ie.__webglFramebuffer[me]), ie.__webglDepthbuffer && e.deleteRenderbuffer(ie.__webglDepthbuffer[me]); else { if ( (e.deleteFramebuffer(ie.__webglFramebuffer), ie.__webglDepthbuffer && e.deleteRenderbuffer(ie.__webglDepthbuffer), ie.__webglMultisampledFramebuffer && e.deleteFramebuffer(ie.__webglMultisampledFramebuffer), ie.__webglColorRenderbuffer) ) for (let me = 0; me < ie.__webglColorRenderbuffer.length; me++) ie.__webglColorRenderbuffer[me] && e.deleteRenderbuffer(ie.__webglColorRenderbuffer[me]); ie.__webglDepthRenderbuffer && e.deleteRenderbuffer(ie.__webglDepthRenderbuffer); } if (I.isWebGLMultipleRenderTargets) for (let me = 0, be = O.length; me < be; me++) { let We = r.get(O[me]); We.__webglTexture && (e.deleteTexture(We.__webglTexture), a.memory.textures--), r.remove(O[me]); } r.remove(O), r.remove(I); } let W = 0; function X() { W = 0; } function z() { let I = W; return ( I >= l && console.warn('THREE.WebGLTextures: Trying to use ' + I + ' texture units while this GPU supports only ' + l), (W += 1), I ); } function j(I) { let O = []; return ( O.push(I.wrapS), O.push(I.wrapT), O.push(I.wrapR || 0), O.push(I.magFilter), O.push(I.minFilter), O.push(I.anisotropy), O.push(I.internalFormat), O.push(I.format), O.push(I.type), O.push(I.generateMipmaps), O.push(I.premultiplyAlpha), O.push(I.flipY), O.push(I.unpackAlignment), O.push(I.encoding), O.join() ); } function U(I, O) { let ie = r.get(I); if ((I.isVideoTexture && He(I), I.isRenderTargetTexture === !1 && I.version > 0 && ie.__version !== I.version)) { let pe = I.image; if (pe === null) console.warn('THREE.WebGLRenderer: Texture marked for update but no image data found.'); else if (pe.complete === !1) console.warn('THREE.WebGLRenderer: Texture marked for update but image is incomplete'); else { V(ie, I, O); return; } } i.bindTexture(3553, ie.__webglTexture, 33984 + O); } function N(I, O) { let ie = r.get(I); if (I.version > 0 && ie.__version !== I.version) { V(ie, I, O); return; } i.bindTexture(35866, ie.__webglTexture, 33984 + O); } function B(I, O) { let ie = r.get(I); if (I.version > 0 && ie.__version !== I.version) { V(ie, I, O); return; } i.bindTexture(32879, ie.__webglTexture, 33984 + O); } function H(I, O) { let ie = r.get(I); if (I.version > 0 && ie.__version !== I.version) { ee(ie, I, O); return; } i.bindTexture(34067, ie.__webglTexture, 33984 + O); } let Q = { [oh]: 10497, [Ji]: 33071, [Uf]: 33648 }, Y = { [Ot]: 9728, [s0]: 9984, [Wu]: 9986, [mt]: 9729, [_M]: 9985, [Bo]: 9987 }; function F(I, O, ie) { if ( (ie ? (e.texParameteri(I, 10242, Q[O.wrapS]), e.texParameteri(I, 10243, Q[O.wrapT]), (I === 32879 || I === 35866) && e.texParameteri(I, 32882, Q[O.wrapR]), e.texParameteri(I, 10240, Y[O.magFilter]), e.texParameteri(I, 10241, Y[O.minFilter])) : (e.texParameteri(I, 10242, 33071), e.texParameteri(I, 10243, 33071), (I === 32879 || I === 35866) && e.texParameteri(I, 32882, 33071), (O.wrapS !== Ji || O.wrapT !== Ji) && console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' ), e.texParameteri(I, 10240, C(O.magFilter)), e.texParameteri(I, 10241, C(O.minFilter)), O.minFilter !== Ot && O.minFilter !== mt && console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' )), t.has('EXT_texture_filter_anisotropic') === !0) ) { let pe = t.get('EXT_texture_filter_anisotropic'); if ( O.magFilter === Ot || (O.minFilter !== Wu && O.minFilter !== Bo) || (O.type === vn && t.has('OES_texture_float_linear') === !1) || (o === !1 && O.type === lh && t.has('OES_texture_half_float_linear') === !1) ) return; (O.anisotropy > 1 || r.get(O).__currentAnisotropy) && (e.texParameterf(I, pe.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(O.anisotropy, s.getMaxAnisotropy())), (r.get(O).__currentAnisotropy = O.anisotropy)); } } function se(I, O) { let ie = !1; I.__webglInit === void 0 && ((I.__webglInit = !0), O.addEventListener('dispose', T)); let pe = O.source, me = m.get(pe); me === void 0 && ((me = {}), m.set(pe, me)); let be = j(O); if (be !== I.__cacheKey) { me[be] === void 0 && ((me[be] = { texture: e.createTexture(), usedTimes: 0 }), a.memory.textures++, (ie = !0)), me[be].usedTimes++; let We = me[I.__cacheKey]; We !== void 0 && (me[I.__cacheKey].usedTimes--, We.usedTimes === 0 && D(O)), (I.__cacheKey = be), (I.__webglTexture = me[be].texture); } return ie; } function V(I, O, ie) { let pe = 3553; (O.isDataArrayTexture || O.isCompressedArrayTexture) && (pe = 35866), O.isData3DTexture && (pe = 32879); let me = se(I, O), be = O.source; i.bindTexture(pe, I.__webglTexture, 33984 + ie); let We = r.get(be); if (be.version !== We.__version || me === !0) { i.activeTexture(33984 + ie), e.pixelStorei(37440, O.flipY), e.pixelStorei(37441, O.premultiplyAlpha), e.pixelStorei(3317, O.unpackAlignment), e.pixelStorei(37443, 0); let Me = w(O) && x(O.image) === !1, ce = b(O.image, Me, !1, u); ce = dt(O, ce); let Fe = x(ce) || o, Ee = n.convert(O.format, O.encoding), _e = n.convert(O.type), Le = _(O.internalFormat, Ee, _e, O.encoding, O.isVideoTexture); F(pe, O, Fe); let Ne, at = O.mipmaps, Mt = o && O.isVideoTexture !== !0, Wt = We.__version === void 0 || me === !0, q = M(O, ce, Fe); if (O.isDepthTexture) (Le = 6402), o ? O.type === vn ? (Le = 36012) : O.type === gn ? (Le = 33190) : O.type === ca ? (Le = 35056) : (Le = 33189) : O.type === vn && console.error('WebGLRenderer: Floating point depth texture requires WebGL2.'), O.format === da && Le === 6402 && O.type !== hw && O.type !== gn && (console.warn('THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.'), (O.type = gn), (_e = n.convert(O.type))), O.format === ba && Le === 6402 && ((Le = 34041), O.type !== ca && (console.warn('THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.'), (O.type = ca), (_e = n.convert(O.type)))), Wt && (Mt ? i.texStorage2D(3553, 1, Le, ce.width, ce.height) : i.texImage2D(3553, 0, Le, ce.width, ce.height, 0, Ee, _e, null)); else if (O.isDataTexture) if (at.length > 0 && Fe) { Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height); for (let ne = 0, de = at.length; ne < de; ne++) (Ne = at[ne]), Mt ? i.texSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, _e, Ne.data) : i.texImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ee, _e, Ne.data); O.generateMipmaps = !1; } else Mt ? (Wt && i.texStorage2D(3553, q, Le, ce.width, ce.height), i.texSubImage2D(3553, 0, 0, 0, ce.width, ce.height, Ee, _e, ce.data)) : i.texImage2D(3553, 0, Le, ce.width, ce.height, 0, Ee, _e, ce.data); else if (O.isCompressedTexture) if (O.isCompressedArrayTexture) { Mt && Wt && i.texStorage3D(35866, q, Le, at[0].width, at[0].height, ce.depth); for (let ne = 0, de = at.length; ne < de; ne++) (Ne = at[ne]), O.format !== Ur ? Ee !== null ? Mt ? i.compressedTexSubImage3D(35866, ne, 0, 0, 0, Ne.width, Ne.height, ce.depth, Ee, Ne.data, 0, 0) : i.compressedTexImage3D(35866, ne, Le, Ne.width, Ne.height, ce.depth, 0, Ne.data, 0, 0) : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()') : Mt ? i.texSubImage3D(35866, ne, 0, 0, 0, Ne.width, Ne.height, ce.depth, Ee, _e, Ne.data) : i.texImage3D(35866, ne, Le, Ne.width, Ne.height, ce.depth, 0, Ee, _e, Ne.data); } else { Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height); for (let ne = 0, de = at.length; ne < de; ne++) (Ne = at[ne]), O.format !== Ur ? Ee !== null ? Mt ? i.compressedTexSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, Ne.data) : i.compressedTexImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ne.data) : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()') : Mt ? i.texSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, _e, Ne.data) : i.texImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ee, _e, Ne.data); } else if (O.isDataArrayTexture) Mt ? (Wt && i.texStorage3D(35866, q, Le, ce.width, ce.height, ce.depth), i.texSubImage3D(35866, 0, 0, 0, 0, ce.width, ce.height, ce.depth, Ee, _e, ce.data)) : i.texImage3D(35866, 0, Le, ce.width, ce.height, ce.depth, 0, Ee, _e, ce.data); else if (O.isData3DTexture) Mt ? (Wt && i.texStorage3D(32879, q, Le, ce.width, ce.height, ce.depth), i.texSubImage3D(32879, 0, 0, 0, 0, ce.width, ce.height, ce.depth, Ee, _e, ce.data)) : i.texImage3D(32879, 0, Le, ce.width, ce.height, ce.depth, 0, Ee, _e, ce.data); else if (O.isFramebufferTexture) { if (Wt) if (Mt) i.texStorage2D(3553, q, Le, ce.width, ce.height); else { let ne = ce.width, de = ce.height; for (let Ae = 0; Ae < q; Ae++) i.texImage2D(3553, Ae, Le, ne, de, 0, Ee, _e, null), (ne >>= 1), (de >>= 1); } } else if (at.length > 0 && Fe) { Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height); for (let ne = 0, de = at.length; ne < de; ne++) (Ne = at[ne]), Mt ? i.texSubImage2D(3553, ne, 0, 0, Ee, _e, Ne) : i.texImage2D(3553, ne, Le, Ee, _e, Ne); O.generateMipmaps = !1; } else Mt ? (Wt && i.texStorage2D(3553, q, Le, ce.width, ce.height), i.texSubImage2D(3553, 0, 0, 0, Ee, _e, ce)) : i.texImage2D(3553, 0, Le, Ee, _e, ce); A(O, Fe) && S(pe), (We.__version = be.version), O.onUpdate && O.onUpdate(O); } I.__version = O.version; } function ee(I, O, ie) { if (O.image.length !== 6) return; let pe = se(I, O), me = O.source; i.bindTexture(34067, I.__webglTexture, 33984 + ie); let be = r.get(me); if (me.version !== be.__version || pe === !0) { i.activeTexture(33984 + ie), e.pixelStorei(37440, O.flipY), e.pixelStorei(37441, O.premultiplyAlpha), e.pixelStorei(3317, O.unpackAlignment), e.pixelStorei(37443, 0); let We = O.isCompressedTexture || O.image[0].isCompressedTexture, Me = O.image[0] && O.image[0].isDataTexture, ce = []; for (let ne = 0; ne < 6; ne++) !We && !Me ? (ce[ne] = b(O.image[ne], !1, !0, h)) : (ce[ne] = Me ? O.image[ne].image : O.image[ne]), (ce[ne] = dt(O, ce[ne])); let Fe = ce[0], Ee = x(Fe) || o, _e = n.convert(O.format, O.encoding), Le = n.convert(O.type), Ne = _(O.internalFormat, _e, Le, O.encoding), at = o && O.isVideoTexture !== !0, Mt = be.__version === void 0 || pe === !0, Wt = M(O, Fe, Ee); F(34067, O, Ee); let q; if (We) { at && Mt && i.texStorage2D(34067, Wt, Ne, Fe.width, Fe.height); for (let ne = 0; ne < 6; ne++) { q = ce[ne].mipmaps; for (let de = 0; de < q.length; de++) { let Ae = q[de]; O.format !== Ur ? _e !== null ? at ? i.compressedTexSubImage2D(34069 + ne, de, 0, 0, Ae.width, Ae.height, _e, Ae.data) : i.compressedTexImage2D(34069 + ne, de, Ne, Ae.width, Ae.height, 0, Ae.data) : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()') : at ? i.texSubImage2D(34069 + ne, de, 0, 0, Ae.width, Ae.height, _e, Le, Ae.data) : i.texImage2D(34069 + ne, de, Ne, Ae.width, Ae.height, 0, _e, Le, Ae.data); } } } else { (q = O.mipmaps), at && Mt && (q.length > 0 && Wt++, i.texStorage2D(34067, Wt, Ne, ce[0].width, ce[0].height)); for (let ne = 0; ne < 6; ne++) if (Me) { at ? i.texSubImage2D(34069 + ne, 0, 0, 0, ce[ne].width, ce[ne].height, _e, Le, ce[ne].data) : i.texImage2D(34069 + ne, 0, Ne, ce[ne].width, ce[ne].height, 0, _e, Le, ce[ne].data); for (let de = 0; de < q.length; de++) { let Ae = q[de].image[ne].image; at ? i.texSubImage2D(34069 + ne, de + 1, 0, 0, Ae.width, Ae.height, _e, Le, Ae.data) : i.texImage2D(34069 + ne, de + 1, Ne, Ae.width, Ae.height, 0, _e, Le, Ae.data); } } else { at ? i.texSubImage2D(34069 + ne, 0, 0, 0, _e, Le, ce[ne]) : i.texImage2D(34069 + ne, 0, Ne, _e, Le, ce[ne]); for (let de = 0; de < q.length; de++) { let Ae = q[de]; at ? i.texSubImage2D(34069 + ne, de + 1, 0, 0, _e, Le, Ae.image[ne]) : i.texImage2D(34069 + ne, de + 1, Ne, _e, Le, Ae.image[ne]); } } } A(O, Ee) && S(34067), (be.__version = me.version), O.onUpdate && O.onUpdate(O); } I.__version = O.version; } function J(I, O, ie, pe, me) { let be = n.convert(ie.format, ie.encoding), We = n.convert(ie.type), Me = _(ie.internalFormat, be, We, ie.encoding); r.get(O).__hasExternalTextures || (me === 32879 || me === 35866 ? i.texImage3D(me, 0, Me, O.width, O.height, O.depth, 0, be, We, null) : i.texImage2D(me, 0, Me, O.width, O.height, 0, be, We, null)), i.bindFramebuffer(36160, I), Ie(O) ? d.framebufferTexture2DMultisampleEXT(36160, pe, me, r.get(ie).__webglTexture, 0, we(O)) : (me === 3553 || (me >= 34069 && me <= 34074)) && e.framebufferTexture2D(36160, pe, me, r.get(ie).__webglTexture, 0), i.bindFramebuffer(36160, null); } function fe(I, O, ie) { if ((e.bindRenderbuffer(36161, I), O.depthBuffer && !O.stencilBuffer)) { let pe = 33189; if (ie || Ie(O)) { let me = O.depthTexture; me && me.isDepthTexture && (me.type === vn ? (pe = 36012) : me.type === gn && (pe = 33190)); let be = we(O); Ie(O) ? d.renderbufferStorageMultisampleEXT(36161, be, pe, O.width, O.height) : e.renderbufferStorageMultisample(36161, be, pe, O.width, O.height); } else e.renderbufferStorage(36161, pe, O.width, O.height); e.framebufferRenderbuffer(36160, 36096, 36161, I); } else if (O.depthBuffer && O.stencilBuffer) { let pe = we(O); ie && Ie(O) === !1 ? e.renderbufferStorageMultisample(36161, pe, 35056, O.width, O.height) : Ie(O) ? d.renderbufferStorageMultisampleEXT(36161, pe, 35056, O.width, O.height) : e.renderbufferStorage(36161, 34041, O.width, O.height), e.framebufferRenderbuffer(36160, 33306, 36161, I); } else { let pe = O.isWebGLMultipleRenderTargets === !0 ? O.texture : [O.texture]; for (let me = 0; me < pe.length; me++) { let be = pe[me], We = n.convert(be.format, be.encoding), Me = n.convert(be.type), ce = _(be.internalFormat, We, Me, be.encoding), Fe = we(O); ie && Ie(O) === !1 ? e.renderbufferStorageMultisample(36161, Fe, ce, O.width, O.height) : Ie(O) ? d.renderbufferStorageMultisampleEXT(36161, Fe, ce, O.width, O.height) : e.renderbufferStorage(36161, ce, O.width, O.height); } } e.bindRenderbuffer(36161, null); } function re(I, O) { if (O && O.isWebGLCubeRenderTarget) throw new Error('Depth Texture with cube render targets is not supported'); if ((i.bindFramebuffer(36160, I), !(O.depthTexture && O.depthTexture.isDepthTexture))) throw new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture'); (!r.get(O.depthTexture).__webglTexture || O.depthTexture.image.width !== O.width || O.depthTexture.image.height !== O.height) && ((O.depthTexture.image.width = O.width), (O.depthTexture.image.height = O.height), (O.depthTexture.needsUpdate = !0)), U(O.depthTexture, 0); let ie = r.get(O.depthTexture).__webglTexture, pe = we(O); if (O.depthTexture.format === da) Ie(O) ? d.framebufferTexture2DMultisampleEXT(36160, 36096, 3553, ie, 0, pe) : e.framebufferTexture2D(36160, 36096, 3553, ie, 0); else if (O.depthTexture.format === ba) Ie(O) ? d.framebufferTexture2DMultisampleEXT(36160, 33306, 3553, ie, 0, pe) : e.framebufferTexture2D(36160, 33306, 3553, ie, 0); else throw new Error('Unknown depthTexture format'); } function oe(I) { let O = r.get(I), ie = I.isWebGLCubeRenderTarget === !0; if (I.depthTexture && !O.__autoAllocateDepthBuffer) { if (ie) throw new Error('target.depthTexture not supported in Cube render targets'); re(O.__webglFramebuffer, I); } else if (ie) { O.__webglDepthbuffer = []; for (let pe = 0; pe < 6; pe++) i.bindFramebuffer(36160, O.__webglFramebuffer[pe]), (O.__webglDepthbuffer[pe] = e.createRenderbuffer()), fe(O.__webglDepthbuffer[pe], I, !1); } else i.bindFramebuffer(36160, O.__webglFramebuffer), (O.__webglDepthbuffer = e.createRenderbuffer()), fe(O.__webglDepthbuffer, I, !1); i.bindFramebuffer(36160, null); } function ue(I, O, ie) { let pe = r.get(I); O !== void 0 && J(pe.__webglFramebuffer, I, I.texture, 36064, 3553), ie !== void 0 && oe(I); } function ye(I) { let O = I.texture, ie = r.get(I), pe = r.get(O); I.addEventListener('dispose', P), I.isWebGLMultipleRenderTargets !== !0 && (pe.__webglTexture === void 0 && (pe.__webglTexture = e.createTexture()), (pe.__version = O.version), a.memory.textures++); let me = I.isWebGLCubeRenderTarget === !0, be = I.isWebGLMultipleRenderTargets === !0, We = x(I) || o; if (me) { ie.__webglFramebuffer = []; for (let Me = 0; Me < 6; Me++) ie.__webglFramebuffer[Me] = e.createFramebuffer(); } else { if (((ie.__webglFramebuffer = e.createFramebuffer()), be)) if (s.drawBuffers) { let Me = I.texture; for (let ce = 0, Fe = Me.length; ce < Fe; ce++) { let Ee = r.get(Me[ce]); Ee.__webglTexture === void 0 && ((Ee.__webglTexture = e.createTexture()), a.memory.textures++); } } else console.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.'); if (o && I.samples > 0 && Ie(I) === !1) { let Me = be ? O : [O]; (ie.__webglMultisampledFramebuffer = e.createFramebuffer()), (ie.__webglColorRenderbuffer = []), i.bindFramebuffer(36160, ie.__webglMultisampledFramebuffer); for (let ce = 0; ce < Me.length; ce++) { let Fe = Me[ce]; (ie.__webglColorRenderbuffer[ce] = e.createRenderbuffer()), e.bindRenderbuffer(36161, ie.__webglColorRenderbuffer[ce]); let Ee = n.convert(Fe.format, Fe.encoding), _e = n.convert(Fe.type), Le = _(Fe.internalFormat, Ee, _e, Fe.encoding, I.isXRRenderTarget === !0), Ne = we(I); e.renderbufferStorageMultisample(36161, Ne, Le, I.width, I.height), e.framebufferRenderbuffer(36160, 36064 + ce, 36161, ie.__webglColorRenderbuffer[ce]); } e.bindRenderbuffer(36161, null), I.depthBuffer && ((ie.__webglDepthRenderbuffer = e.createRenderbuffer()), fe(ie.__webglDepthRenderbuffer, I, !0)), i.bindFramebuffer(36160, null); } } if (me) { i.bindTexture(34067, pe.__webglTexture), F(34067, O, We); for (let Me = 0; Me < 6; Me++) J(ie.__webglFramebuffer[Me], I, O, 36064, 34069 + Me); A(O, We) && S(34067), i.unbindTexture(); } else if (be) { let Me = I.texture; for (let ce = 0, Fe = Me.length; ce < Fe; ce++) { let Ee = Me[ce], _e = r.get(Ee); i.bindTexture(3553, _e.__webglTexture), F(3553, Ee, We), J(ie.__webglFramebuffer, I, Ee, 36064 + ce, 3553), A(Ee, We) && S(3553); } i.unbindTexture(); } else { let Me = 3553; (I.isWebGL3DRenderTarget || I.isWebGLArrayRenderTarget) && (o ? (Me = I.isWebGL3DRenderTarget ? 32879 : 35866) : console.error('THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.')), i.bindTexture(Me, pe.__webglTexture), F(Me, O, We), J(ie.__webglFramebuffer, I, O, 36064, Me), A(O, We) && S(Me), i.unbindTexture(); } I.depthBuffer && oe(I); } function Te(I) { let O = x(I) || o, ie = I.isWebGLMultipleRenderTargets === !0 ? I.texture : [I.texture]; for (let pe = 0, me = ie.length; pe < me; pe++) { let be = ie[pe]; if (A(be, O)) { let We = I.isWebGLCubeRenderTarget ? 34067 : 3553, Me = r.get(be).__webglTexture; i.bindTexture(We, Me), S(We), i.unbindTexture(); } } } function xe(I) { if (o && I.samples > 0 && Ie(I) === !1) { let O = I.isWebGLMultipleRenderTargets ? I.texture : [I.texture], ie = I.width, pe = I.height, me = 16384, be = [], We = I.stencilBuffer ? 33306 : 36096, Me = r.get(I), ce = I.isWebGLMultipleRenderTargets === !0; if (ce) for (let Fe = 0; Fe < O.length; Fe++) i.bindFramebuffer(36160, Me.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(36160, 36064 + Fe, 36161, null), i.bindFramebuffer(36160, Me.__webglFramebuffer), e.framebufferTexture2D(36009, 36064 + Fe, 3553, null, 0); i.bindFramebuffer(36008, Me.__webglMultisampledFramebuffer), i.bindFramebuffer(36009, Me.__webglFramebuffer); for (let Fe = 0; Fe < O.length; Fe++) { be.push(36064 + Fe), I.depthBuffer && be.push(We); let Ee = Me.__ignoreDepthValues !== void 0 ? Me.__ignoreDepthValues : !1; if ( (Ee === !1 && (I.depthBuffer && (me |= 256), I.stencilBuffer && (me |= 1024)), ce && e.framebufferRenderbuffer(36008, 36064, 36161, Me.__webglColorRenderbuffer[Fe]), Ee === !0 && (e.invalidateFramebuffer(36008, [We]), e.invalidateFramebuffer(36009, [We])), ce) ) { let _e = r.get(O[Fe]).__webglTexture; e.framebufferTexture2D(36009, 36064, 3553, _e, 0); } e.blitFramebuffer(0, 0, ie, pe, 0, 0, ie, pe, me, 9728), p && e.invalidateFramebuffer(36008, be); } if ((i.bindFramebuffer(36008, null), i.bindFramebuffer(36009, null), ce)) for (let Fe = 0; Fe < O.length; Fe++) { i.bindFramebuffer(36160, Me.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(36160, 36064 + Fe, 36161, Me.__webglColorRenderbuffer[Fe]); let Ee = r.get(O[Fe]).__webglTexture; i.bindFramebuffer(36160, Me.__webglFramebuffer), e.framebufferTexture2D(36009, 36064 + Fe, 3553, Ee, 0); } i.bindFramebuffer(36009, Me.__webglMultisampledFramebuffer); } } function we(I) { return Math.min(c, I.samples); } function Ie(I) { let O = r.get(I); return o && I.samples > 0 && t.has('WEBGL_multisampled_render_to_texture') === !0 && O.__useRenderToTexture !== !1; } function He(I) { let O = a.render.frame; f.get(I) !== O && (f.set(I, O), I.update()); } function dt(I, O) { let ie = I.encoding, pe = I.format, me = I.type; return ( I.isCompressedTexture === !0 || I.isVideoTexture === !0 || I.format === kf || (ie !== gs && (ie === Ke ? o === !1 ? t.has('EXT_sRGB') === !0 && pe === Ur ? ((I.format = kf), (I.minFilter = mt), (I.generateMipmaps = !1)) : (O = pw.sRGBToLinear(O)) : (pe !== Ur || me !== Mi) && console.warn('THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.') : console.error('THREE.WebGLTextures: Unsupported texture encoding:', ie))), O ); } (this.allocateTextureUnit = z), (this.resetTextureUnits = X), (this.setTexture2D = U), (this.setTexture2DArray = N), (this.setTexture3D = B), (this.setTextureCube = H), (this.rebindTextures = ue), (this.setupRenderTarget = ye), (this.updateRenderTargetMipmap = Te), (this.updateMultisampleRenderTarget = xe), (this.setupDepthRenderbuffer = oe), (this.setupFrameBufferTexture = J), (this.useMultisampledRTT = Ie); } function WP(e, t, i) { let r = i.isWebGL2; function s(n, a = null) { let o; if (n === Mi) return 5121; if (n === EM) return 32819; if (n === CM) return 32820; if (n === AM) return 5120; if (n === SM) return 5122; if (n === hw) return 5123; if (n === MM) return 5124; if (n === gn) return 5125; if (n === vn) return 5126; if (n === lh) return r ? 5131 : ((o = t.get('OES_texture_half_float')), o !== null ? o.HALF_FLOAT_OES : null); if (n === TM) return 6406; if (n === Ur) return 6408; if (n === PM) return 6409; if (n === DM) return 6410; if (n === da) return 6402; if (n === ba) return 34041; if (n === kf) return (o = t.get('EXT_sRGB')), o !== null ? o.SRGB_ALPHA_EXT : null; if (n === LM) return 6403; if (n === OM) return 36244; if (n === IM) return 33319; if (n === RM) return 33320; if (n === BM) return 36249; if (n === Xu || n === qu || n === Yu || n === Qu) if (a === Ke) if (((o = t.get('WEBGL_compressed_texture_s3tc_srgb')), o !== null)) { if (n === Xu) return o.COMPRESSED_SRGB_S3TC_DXT1_EXT; if (n === qu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; if (n === Yu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; if (n === Qu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; } else return null; else if (((o = t.get('WEBGL_compressed_texture_s3tc')), o !== null)) { if (n === Xu) return o.COMPRESSED_RGB_S3TC_DXT1_EXT; if (n === qu) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT; if (n === Yu) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT; if (n === Qu) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT; } else return null; if (n === n0 || n === a0 || n === o0 || n === l0) if (((o = t.get('WEBGL_compressed_texture_pvrtc')), o !== null)) { if (n === n0) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; if (n === a0) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; if (n === o0) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; if (n === l0) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; } else return null; if (n === zM) return (o = t.get('WEBGL_compressed_texture_etc1')), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null; if (n === h0 || n === c0) if (((o = t.get('WEBGL_compressed_texture_etc')), o !== null)) { if (n === h0) return a === Ke ? o.COMPRESSED_SRGB8_ETC2 : o.COMPRESSED_RGB8_ETC2; if (n === c0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : o.COMPRESSED_RGBA8_ETC2_EAC; } else return null; if ( n === d0 || n === u0 || n === p0 || n === f0 || n === m0 || n === g0 || n === v0 || n === y0 || n === x0 || n === b0 || n === w0 || n === _0 || n === A0 || n === S0 ) if (((o = t.get('WEBGL_compressed_texture_astc')), o !== null)) { if (n === d0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : o.COMPRESSED_RGBA_ASTC_4x4_KHR; if (n === u0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : o.COMPRESSED_RGBA_ASTC_5x4_KHR; if (n === p0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : o.COMPRESSED_RGBA_ASTC_5x5_KHR; if (n === f0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : o.COMPRESSED_RGBA_ASTC_6x5_KHR; if (n === m0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : o.COMPRESSED_RGBA_ASTC_6x6_KHR; if (n === g0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : o.COMPRESSED_RGBA_ASTC_8x5_KHR; if (n === v0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : o.COMPRESSED_RGBA_ASTC_8x6_KHR; if (n === y0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : o.COMPRESSED_RGBA_ASTC_8x8_KHR; if (n === x0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : o.COMPRESSED_RGBA_ASTC_10x5_KHR; if (n === b0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : o.COMPRESSED_RGBA_ASTC_10x6_KHR; if (n === w0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : o.COMPRESSED_RGBA_ASTC_10x8_KHR; if (n === _0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : o.COMPRESSED_RGBA_ASTC_10x10_KHR; if (n === A0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : o.COMPRESSED_RGBA_ASTC_12x10_KHR; if (n === S0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : o.COMPRESSED_RGBA_ASTC_12x12_KHR; } else return null; if (n === Zu) if (((o = t.get('EXT_texture_compression_bptc')), o !== null)) { if (n === Zu) return a === Ke ? o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : o.COMPRESSED_RGBA_BPTC_UNORM_EXT; } else return null; if (n === NM || n === M0 || n === E0 || n === C0) if (((o = t.get('EXT_texture_compression_rgtc')), o !== null)) { if (n === Zu) return o.COMPRESSED_RED_RGTC1_EXT; if (n === M0) return o.COMPRESSED_SIGNED_RED_RGTC1_EXT; if (n === E0) return o.COMPRESSED_RED_GREEN_RGTC2_EXT; if (n === C0) return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; } else return null; return n === ca ? r ? 34042 : ((o = t.get('WEBGL_depth_texture')), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null) : e[n] !== void 0 ? e[n] : null; } return { convert: s }; } var XP = class extends wi { constructor(e = []) { super(), (this.isArrayCamera = !0), (this.cameras = e); } }, po = class extends bt { constructor() { super(), (this.isGroup = !0), (this.type = 'Group'); } }, qP = { type: 'move' }, _p = class { constructor() { (this._targetRay = null), (this._grip = null), (this._hand = null); } getHandSpace() { return ( this._hand === null && ((this._hand = new po()), (this._hand.matrixAutoUpdate = !1), (this._hand.visible = !1), (this._hand.joints = {}), (this._hand.inputState = { pinching: !1 })), this._hand ); } getTargetRaySpace() { return ( this._targetRay === null && ((this._targetRay = new po()), (this._targetRay.matrixAutoUpdate = !1), (this._targetRay.visible = !1), (this._targetRay.hasLinearVelocity = !1), (this._targetRay.linearVelocity = new E()), (this._targetRay.hasAngularVelocity = !1), (this._targetRay.angularVelocity = new E())), this._targetRay ); } getGripSpace() { return ( this._grip === null && ((this._grip = new po()), (this._grip.matrixAutoUpdate = !1), (this._grip.visible = !1), (this._grip.hasLinearVelocity = !1), (this._grip.linearVelocity = new E()), (this._grip.hasAngularVelocity = !1), (this._grip.angularVelocity = new E())), this._grip ); } dispatchEvent(e) { return ( this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this ); } connect(e) { if (e && e.hand) { let t = this._hand; if (t) for (let i of e.hand.values()) this._getHandJoint(t, i); } return this.dispatchEvent({ type: 'connected', data: e }), this; } disconnect(e) { return ( this.dispatchEvent({ type: 'disconnected', data: e }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this ); } update(e, t, i) { let r = null, s = null, n = null, a = this._targetRay, o = this._grip, l = this._hand; if (e && t.session.visibilityState !== 'visible-blurred') { if (l && e.hand) { n = !0; for (let f of e.hand.values()) { let g = t.getJointPose(f, i), m = this._getHandJoint(l, f); g !== null && (m.matrix.fromArray(g.transform.matrix), m.matrix.decompose(m.position, m.rotation, m.scale), (m.jointRadius = g.radius)), (m.visible = g !== null); } let h = l.joints['index-finger-tip'], u = l.joints['thumb-tip'], c = h.position.distanceTo(u.position), d = 0.02, p = 0.005; l.inputState.pinching && c > d + p ? ((l.inputState.pinching = !1), this.dispatchEvent({ type: 'pinchend', handedness: e.handedness, target: this })) : !l.inputState.pinching && c <= d - p && ((l.inputState.pinching = !0), this.dispatchEvent({ type: 'pinchstart', handedness: e.handedness, target: this })); } else o !== null && e.gripSpace && ((s = t.getPose(e.gripSpace, i)), s !== null && (o.matrix.fromArray(s.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), s.linearVelocity ? ((o.hasLinearVelocity = !0), o.linearVelocity.copy(s.linearVelocity)) : (o.hasLinearVelocity = !1), s.angularVelocity ? ((o.hasAngularVelocity = !0), o.angularVelocity.copy(s.angularVelocity)) : (o.hasAngularVelocity = !1))); a !== null && ((r = t.getPose(e.targetRaySpace, i)), r === null && s !== null && (r = s), r !== null && (a.matrix.fromArray(r.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), r.linearVelocity ? ((a.hasLinearVelocity = !0), a.linearVelocity.copy(r.linearVelocity)) : (a.hasLinearVelocity = !1), r.angularVelocity ? ((a.hasAngularVelocity = !0), a.angularVelocity.copy(r.angularVelocity)) : (a.hasAngularVelocity = !1), this.dispatchEvent(qP))); } return a !== null && (a.visible = r !== null), o !== null && (o.visible = s !== null), l !== null && (l.visible = n !== null), this; } _getHandJoint(e, t) { if (e.joints[t.jointName] === void 0) { let i = new po(); (i.matrixAutoUpdate = !1), (i.visible = !1), (e.joints[t.jointName] = i), e.add(i); } return e.joints[t.jointName]; } }, pg = class extends ci { constructor(e, t, i, r, s, n, a, o, l, h) { if (((h = h !== void 0 ? h : da), h !== da && h !== ba)) throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat'); i === void 0 && h === da && (i = gn), i === void 0 && h === ba && (i = ca), super(null, r, s, n, a, o, h, i, l), (this.isDepthTexture = !0), (this.image = { width: e, height: t }), (this.magFilter = a !== void 0 ? a : Ot), (this.minFilter = o !== void 0 ? o : Ot), (this.flipY = !1), (this.generateMipmaps = !1); } }, YP = class extends Vi { constructor(e, t) { super(); let i = this, r = null, s = 1, n = null, a = 'local-floor', o = 1, l = null, h = null, u = null, c = null, d = null, p = null, f = t.getContextAttributes(), g = null, m = null, v = [], y = [], b = new Set(), x = new Map(), w = new wi(); w.layers.enable(1), (w.viewport = new $e()); let A = new wi(); A.layers.enable(2), (A.viewport = new $e()); let S = [w, A], _ = new XP(); _.layers.enable(1), _.layers.enable(2); let M = null, C = null; (this.cameraAutoUpdate = !0), (this.enabled = !1), (this.isPresenting = !1), (this.getController = function (N) { let B = v[N]; return B === void 0 && ((B = new _p()), (v[N] = B)), B.getTargetRaySpace(); }), (this.getControllerGrip = function (N) { let B = v[N]; return B === void 0 && ((B = new _p()), (v[N] = B)), B.getGripSpace(); }), (this.getHand = function (N) { let B = v[N]; return B === void 0 && ((B = new _p()), (v[N] = B)), B.getHandSpace(); }); function T(N) { let B = y.indexOf(N.inputSource); if (B === -1) return; let H = v[B]; H !== void 0 && H.dispatchEvent({ type: N.type, data: N.inputSource }); } function P() { r.removeEventListener('select', T), r.removeEventListener('selectstart', T), r.removeEventListener('selectend', T), r.removeEventListener('squeeze', T), r.removeEventListener('squeezestart', T), r.removeEventListener('squeezeend', T), r.removeEventListener('end', P), r.removeEventListener('inputsourceschange', L); for (let N = 0; N < v.length; N++) { let B = y[N]; B !== null && ((y[N] = null), v[N].disconnect(B)); } (M = null), (C = null), e.setRenderTarget(g), (d = null), (c = null), (u = null), (r = null), (m = null), U.stop(), (i.isPresenting = !1), i.dispatchEvent({ type: 'sessionend' }); } (this.setFramebufferScaleFactor = function (N) { (s = N), i.isPresenting === !0 && console.warn('THREE.WebXRManager: Cannot change framebuffer scale while presenting.'); }), (this.setReferenceSpaceType = function (N) { (a = N), i.isPresenting === !0 && console.warn('THREE.WebXRManager: Cannot change reference space type while presenting.'); }), (this.getReferenceSpace = function () { return l || n; }), (this.setReferenceSpace = function (N) { l = N; }), (this.getBaseLayer = function () { return c !== null ? c : d; }), (this.getBinding = function () { return u; }), (this.getFrame = function () { return p; }), (this.getSession = function () { return r; }), (this.setSession = async function (N) { if (((r = N), r !== null)) { if ( ((g = e.getRenderTarget()), r.addEventListener('select', T), r.addEventListener('selectstart', T), r.addEventListener('selectend', T), r.addEventListener('squeeze', T), r.addEventListener('squeezestart', T), r.addEventListener('squeezeend', T), r.addEventListener('end', P), r.addEventListener('inputsourceschange', L), f.xrCompatible !== !0 && (await t.makeXRCompatible()), r.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) ) { let B = { antialias: r.renderState.layers === void 0 ? f.antialias : !0, alpha: f.alpha, depth: f.depth, stencil: f.stencil, framebufferScaleFactor: s }; (d = new XRWebGLLayer(r, t, B)), r.updateRenderState({ baseLayer: d }), (m = new ii(d.framebufferWidth, d.framebufferHeight, { format: Ur, type: Mi, encoding: e.outputEncoding, stencilBuffer: f.stencil })); } else { let B = null, H = null, Q = null; f.depth && ((Q = f.stencil ? 35056 : 33190), (B = f.stencil ? ba : da), (H = f.stencil ? ca : gn)); let Y = { colorFormat: 32856, depthFormat: Q, scaleFactor: s }; (u = new XRWebGLBinding(r, t)), (c = u.createProjectionLayer(Y)), r.updateRenderState({ layers: [c] }), (m = new ii(c.textureWidth, c.textureHeight, { format: Ur, type: Mi, depthTexture: new pg(c.textureWidth, c.textureHeight, H, void 0, void 0, void 0, void 0, void 0, void 0, B), stencilBuffer: f.stencil, encoding: e.outputEncoding, samples: f.antialias ? 4 : 0 })); let F = e.properties.get(m); F.__ignoreDepthValues = c.ignoreDepthValues; } (m.isXRRenderTarget = !0), this.setFoveation(o), (l = null), (n = await r.requestReferenceSpace(a)), U.setContext(r), U.start(), (i.isPresenting = !0), i.dispatchEvent({ type: 'sessionstart' }); } }); function L(N) { for (let B = 0; B < N.removed.length; B++) { let H = N.removed[B], Q = y.indexOf(H); Q >= 0 && ((y[Q] = null), v[Q].disconnect(H)); } for (let B = 0; B < N.added.length; B++) { let H = N.added[B], Q = y.indexOf(H); if (Q === -1) { for (let F = 0; F < v.length; F++) if (F >= y.length) { y.push(H), (Q = F); break; } else if (y[F] === null) { (y[F] = H), (Q = F); break; } if (Q === -1) break; } let Y = v[Q]; Y && Y.connect(H); } } let D = new E(), k = new E(); function W(N, B, H) { D.setFromMatrixPosition(B.matrixWorld), k.setFromMatrixPosition(H.matrixWorld); let Q = D.distanceTo(k), Y = B.projectionMatrix.elements, F = H.projectionMatrix.elements, se = Y[14] / (Y[10] - 1), V = Y[14] / (Y[10] + 1), ee = (Y[9] + 1) / Y[5], J = (Y[9] - 1) / Y[5], fe = (Y[8] - 1) / Y[0], re = (F[8] + 1) / F[0], oe = se * fe, ue = se * re, ye = Q / (-fe + re), Te = ye * -fe; B.matrixWorld.decompose(N.position, N.quaternion, N.scale), N.translateX(Te), N.translateZ(ye), N.matrixWorld.compose(N.position, N.quaternion, N.scale), N.matrixWorldInverse.copy(N.matrixWorld).invert(); let xe = se + ye, we = V + ye, Ie = oe - Te, He = ue + (Q - Te), dt = ((ee * V) / we) * xe, I = ((J * V) / we) * xe; N.projectionMatrix.makePerspective(Ie, He, dt, I, xe, we); } function X(N, B) { B === null ? N.matrixWorld.copy(N.matrix) : N.matrixWorld.multiplyMatrices(B.matrixWorld, N.matrix), N.matrixWorldInverse.copy(N.matrixWorld).invert(); } (this.updateCamera = function (N) { if (r === null) return; (_.near = A.near = w.near = N.near), (_.far = A.far = w.far = N.far), (M !== _.near || C !== _.far) && (r.updateRenderState({ depthNear: _.near, depthFar: _.far }), (M = _.near), (C = _.far)); let B = N.parent, H = _.cameras; X(_, B); for (let Y = 0; Y < H.length; Y++) X(H[Y], B); _.matrixWorld.decompose(_.position, _.quaternion, _.scale), N.matrix.copy(_.matrix), N.matrix.decompose(N.position, N.quaternion, N.scale); let Q = N.children; for (let Y = 0, F = Q.length; Y < F; Y++) Q[Y].updateMatrixWorld(!0); H.length === 2 ? W(_, w, A) : _.projectionMatrix.copy(w.projectionMatrix); }), (this.getCamera = function () { return _; }), (this.getFoveation = function () { if (!(c === null && d === null)) return o; }), (this.setFoveation = function (N) { (o = N), c !== null && (c.fixedFoveation = N), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = N); }), (this.getPlanes = function () { return b; }); let z = null; function j(N, B) { if (((h = B.getViewerPose(l || n)), (p = B), h !== null)) { let H = h.views; d !== null && (e.setRenderTargetFramebuffer(m, d.framebuffer), e.setRenderTarget(m)); let Q = !1; H.length !== _.cameras.length && ((_.cameras.length = 0), (Q = !0)); for (let Y = 0; Y < H.length; Y++) { let F = H[Y], se = null; if (d !== null) se = d.getViewport(F); else { let ee = u.getViewSubImage(c, F); (se = ee.viewport), Y === 0 && (e.setRenderTargetTextures(m, ee.colorTexture, c.ignoreDepthValues ? void 0 : ee.depthStencilTexture), e.setRenderTarget(m)); } let V = S[Y]; V === void 0 && ((V = new wi()), V.layers.enable(Y), (V.viewport = new $e()), (S[Y] = V)), V.matrix.fromArray(F.transform.matrix), V.projectionMatrix.fromArray(F.projectionMatrix), V.viewport.set(se.x, se.y, se.width, se.height), Y === 0 && _.matrix.copy(V.matrix), Q === !0 && _.cameras.push(V); } } for (let H = 0; H < v.length; H++) { let Q = y[H], Y = v[H]; Q !== null && Y !== void 0 && Y.update(Q, B, l || n); } if ((z && z(N, B), B.detectedPlanes)) { i.dispatchEvent({ type: 'planesdetected', data: B.detectedPlanes }); let H = null; for (let Q of b) B.detectedPlanes.has(Q) || (H === null && (H = []), H.push(Q)); if (H !== null) for (let Q of H) b.delete(Q), x.delete(Q), i.dispatchEvent({ type: 'planeremoved', data: Q }); for (let Q of B.detectedPlanes) if (!b.has(Q)) b.add(Q), x.set(Q, B.lastChangedTime), i.dispatchEvent({ type: 'planeadded', data: Q }); else { let Y = x.get(Q); Q.lastChangedTime > Y && (x.set(Q, Q.lastChangedTime), i.dispatchEvent({ type: 'planechanged', data: Q })); } } p = null; } let U = new yw(); U.setAnimationLoop(j), (this.setAnimationLoop = function (N) { z = N; }), (this.dispose = function () {}); } }; function QP(e, t) { function i(g, m) { m.color.getRGB(g.fogColor.value, vw(e)), m.isFog ? ((g.fogNear.value = m.near), (g.fogFar.value = m.far)) : m.isFogExp2 && (g.fogDensity.value = m.density); } function r(g, m, v, y, b) { m.isMeshBasicMaterial || m.isMeshLambertMaterial ? s(g, m) : m.isMeshToonMaterial ? (s(g, m), u(g, m)) : m.isMeshPhongMaterial ? (s(g, m), h(g, m)) : m.isMeshStandardMaterial ? (s(g, m), c(g, m), m.isMeshPhysicalMaterial && d(g, m, b)) : m.isMeshMatcapMaterial ? (s(g, m), p(g, m)) : m.isMeshDepthMaterial ? s(g, m) : m.isMeshDistanceMaterial ? (s(g, m), f(g, m)) : m.isMeshNormalMaterial ? s(g, m) : m.isLineBasicMaterial ? (n(g, m), m.isLineDashedMaterial && a(g, m)) : m.isPointsMaterial ? o(g, m, v, y) : m.isSpriteMaterial ? l(g, m) : m.isShadowMaterial ? (g.color.value.copy(m.color), (g.opacity.value = m.opacity)) : m.isShaderMaterial && (m.uniformsNeedUpdate = !1); } function s(g, m) { (g.opacity.value = m.opacity), m.color && g.diffuse.value.copy(m.color), m.emissive && g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity), m.map && (g.map.value = m.map), m.alphaMap && (g.alphaMap.value = m.alphaMap), m.bumpMap && ((g.bumpMap.value = m.bumpMap), (g.bumpScale.value = m.bumpScale), m.side === hi && (g.bumpScale.value *= -1)), m.displacementMap && ((g.displacementMap.value = m.displacementMap), (g.displacementScale.value = m.displacementScale), (g.displacementBias.value = m.displacementBias)), m.emissiveMap && (g.emissiveMap.value = m.emissiveMap), m.normalMap && ((g.normalMap.value = m.normalMap), g.normalScale.value.copy(m.normalScale), m.side === hi && g.normalScale.value.negate()), m.specularMap && (g.specularMap.value = m.specularMap), m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest); let v = t.get(m).envMap; if ( (v && ((g.envMap.value = v), (g.flipEnvMap.value = v.isCubeTexture && v.isRenderTargetTexture === !1 ? -1 : 1), (g.reflectivity.value = m.reflectivity), (g.ior.value = m.ior), (g.refractionRatio.value = m.refractionRatio)), m.lightMap) ) { g.lightMap.value = m.lightMap; let x = e.physicallyCorrectLights !== !0 ? Math.PI : 1; g.lightMapIntensity.value = m.lightMapIntensity * x; } m.aoMap && ((g.aoMap.value = m.aoMap), (g.aoMapIntensity.value = m.aoMapIntensity)); let y; m.map ? (y = m.map) : m.specularMap ? (y = m.specularMap) : m.displacementMap ? (y = m.displacementMap) : m.normalMap ? (y = m.normalMap) : m.bumpMap ? (y = m.bumpMap) : m.roughnessMap ? (y = m.roughnessMap) : m.metalnessMap ? (y = m.metalnessMap) : m.alphaMap ? (y = m.alphaMap) : m.emissiveMap ? (y = m.emissiveMap) : m.clearcoatMap ? (y = m.clearcoatMap) : m.clearcoatNormalMap ? (y = m.clearcoatNormalMap) : m.clearcoatRoughnessMap ? (y = m.clearcoatRoughnessMap) : m.iridescenceMap ? (y = m.iridescenceMap) : m.iridescenceThicknessMap ? (y = m.iridescenceThicknessMap) : m.specularIntensityMap ? (y = m.specularIntensityMap) : m.specularColorMap ? (y = m.specularColorMap) : m.transmissionMap ? (y = m.transmissionMap) : m.thicknessMap ? (y = m.thicknessMap) : m.sheenColorMap ? (y = m.sheenColorMap) : m.sheenRoughnessMap && (y = m.sheenRoughnessMap), y !== void 0 && (y.isWebGLRenderTarget && (y = y.texture), y.matrixAutoUpdate === !0 && y.updateMatrix(), g.uvTransform.value.copy(y.matrix)); let b; m.aoMap ? (b = m.aoMap) : m.lightMap && (b = m.lightMap), b !== void 0 && (b.isWebGLRenderTarget && (b = b.texture), b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uv2Transform.value.copy(b.matrix)); } function n(g, m) { g.diffuse.value.copy(m.color), (g.opacity.value = m.opacity); } function a(g, m) { (g.dashSize.value = m.dashSize), (g.totalSize.value = m.dashSize + m.gapSize), (g.scale.value = m.scale); } function o(g, m, v, y) { g.diffuse.value.copy(m.color), (g.opacity.value = m.opacity), (g.size.value = m.size * v), (g.scale.value = y * 0.5), m.map && (g.map.value = m.map), m.alphaMap && (g.alphaMap.value = m.alphaMap), m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest); let b; m.map ? (b = m.map) : m.alphaMap && (b = m.alphaMap), b !== void 0 && (b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uvTransform.value.copy(b.matrix)); } function l(g, m) { g.diffuse.value.copy(m.color), (g.opacity.value = m.opacity), (g.rotation.value = m.rotation), m.map && (g.map.value = m.map), m.alphaMap && (g.alphaMap.value = m.alphaMap), m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest); let v; m.map ? (v = m.map) : m.alphaMap && (v = m.alphaMap), v !== void 0 && (v.matrixAutoUpdate === !0 && v.updateMatrix(), g.uvTransform.value.copy(v.matrix)); } function h(g, m) { g.specular.value.copy(m.specular), (g.shininess.value = Math.max(m.shininess, 1e-4)); } function u(g, m) { m.gradientMap && (g.gradientMap.value = m.gradientMap); } function c(g, m) { (g.roughness.value = m.roughness), (g.metalness.value = m.metalness), m.roughnessMap && (g.roughnessMap.value = m.roughnessMap), m.metalnessMap && (g.metalnessMap.value = m.metalnessMap), t.get(m).envMap && (g.envMapIntensity.value = m.envMapIntensity); } function d(g, m, v) { (g.ior.value = m.ior), m.sheen > 0 && (g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen), (g.sheenRoughness.value = m.sheenRoughness), m.sheenColorMap && (g.sheenColorMap.value = m.sheenColorMap), m.sheenRoughnessMap && (g.sheenRoughnessMap.value = m.sheenRoughnessMap)), m.clearcoat > 0 && ((g.clearcoat.value = m.clearcoat), (g.clearcoatRoughness.value = m.clearcoatRoughness), m.clearcoatMap && (g.clearcoatMap.value = m.clearcoatMap), m.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = m.clearcoatRoughnessMap), m.clearcoatNormalMap && (g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale), (g.clearcoatNormalMap.value = m.clearcoatNormalMap), m.side === hi && g.clearcoatNormalScale.value.negate())), m.iridescence > 0 && ((g.iridescence.value = m.iridescence), (g.iridescenceIOR.value = m.iridescenceIOR), (g.iridescenceThicknessMinimum.value = m.iridescenceThicknessRange[0]), (g.iridescenceThicknessMaximum.value = m.iridescenceThicknessRange[1]), m.iridescenceMap && (g.iridescenceMap.value = m.iridescenceMap), m.iridescenceThicknessMap && (g.iridescenceThicknessMap.value = m.iridescenceThicknessMap)), m.transmission > 0 && ((g.transmission.value = m.transmission), (g.transmissionSamplerMap.value = v.texture), g.transmissionSamplerSize.value.set(v.width, v.height), m.transmissionMap && (g.transmissionMap.value = m.transmissionMap), (g.thickness.value = m.thickness), m.thicknessMap && (g.thicknessMap.value = m.thicknessMap), (g.attenuationDistance.value = m.attenuationDistance), g.attenuationColor.value.copy(m.attenuationColor)), (g.specularIntensity.value = m.specularIntensity), g.specularColor.value.copy(m.specularColor), m.specularIntensityMap && (g.specularIntensityMap.value = m.specularIntensityMap), m.specularColorMap && (g.specularColorMap.value = m.specularColorMap); } function p(g, m) { m.matcap && (g.matcap.value = m.matcap); } function f(g, m) { g.referencePosition.value.copy(m.referencePosition), (g.nearDistance.value = m.nearDistance), (g.farDistance.value = m.farDistance); } return { refreshFogUniforms: i, refreshMaterialUniforms: r }; } function ZP(e, t, i, r) { let s = {}, n = {}, a = [], o = i.isWebGL2 ? e.getParameter(35375) : 0; function l(y, b) { let x = b.program; r.uniformBlockBinding(y, x); } function h(y, b) { let x = s[y.id]; x === void 0 && (f(y), (x = u(y)), (s[y.id] = x), y.addEventListener('dispose', m)); let w = b.program; r.updateUBOMapping(y, w); let A = t.render.frame; n[y.id] !== A && (d(y), (n[y.id] = A)); } function u(y) { let b = c(); y.__bindingPointIndex = b; let x = e.createBuffer(), w = y.__size, A = y.usage; return e.bindBuffer(35345, x), e.bufferData(35345, w, A), e.bindBuffer(35345, null), e.bindBufferBase(35345, b, x), x; } function c() { for (let y = 0; y < o; y++) if (a.indexOf(y) === -1) return a.push(y), y; return console.error('THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.'), 0; } function d(y) { let b = s[y.id], x = y.uniforms, w = y.__cache; e.bindBuffer(35345, b); for (let A = 0, S = x.length; A < S; A++) { let _ = x[A]; if (p(_, A, w) === !0) { let M = _.__offset, C = Array.isArray(_.value) ? _.value : [_.value], T = 0; for (let P = 0; P < C.length; P++) { let L = C[P], D = g(L); typeof L == 'number' ? ((_.__data[0] = L), e.bufferSubData(35345, M + T, _.__data)) : L.isMatrix3 ? ((_.__data[0] = L.elements[0]), (_.__data[1] = L.elements[1]), (_.__data[2] = L.elements[2]), (_.__data[3] = L.elements[0]), (_.__data[4] = L.elements[3]), (_.__data[5] = L.elements[4]), (_.__data[6] = L.elements[5]), (_.__data[7] = L.elements[0]), (_.__data[8] = L.elements[6]), (_.__data[9] = L.elements[7]), (_.__data[10] = L.elements[8]), (_.__data[11] = L.elements[0])) : (L.toArray(_.__data, T), (T += D.storage / Float32Array.BYTES_PER_ELEMENT)); } e.bufferSubData(35345, M, _.__data); } } e.bindBuffer(35345, null); } function p(y, b, x) { let w = y.value; if (x[b] === void 0) { if (typeof w == 'number') x[b] = w; else { let A = Array.isArray(w) ? w : [w], S = []; for (let _ = 0; _ < A.length; _++) S.push(A[_].clone()); x[b] = S; } return !0; } else if (typeof w == 'number') { if (x[b] !== w) return (x[b] = w), !0; } else { let A = Array.isArray(x[b]) ? x[b] : [x[b]], S = Array.isArray(w) ? w : [w]; for (let _ = 0; _ < A.length; _++) { let M = A[_]; if (M.equals(S[_]) === !1) return M.copy(S[_]), !0; } } return !1; } function f(y) { let b = y.uniforms, x = 0, w = 16, A = 0; for (let S = 0, _ = b.length; S < _; S++) { let M = b[S], C = { boundary: 0, storage: 0 }, T = Array.isArray(M.value) ? M.value : [M.value]; for (let P = 0, L = T.length; P < L; P++) { let D = T[P], k = g(D); (C.boundary += k.boundary), (C.storage += k.storage); } if (((M.__data = new Float32Array(C.storage / Float32Array.BYTES_PER_ELEMENT)), (M.__offset = x), S > 0)) { A = x % w; let P = w - A; A !== 0 && P - C.boundary < 0 && ((x += w - A), (M.__offset = x)); } x += C.storage; } return (A = x % w), A > 0 && (x += w - A), (y.__size = x), (y.__cache = {}), this; } function g(y) { let b = { boundary: 0, storage: 0 }; return ( typeof y == 'number' ? ((b.boundary = 4), (b.storage = 4)) : y.isVector2 ? ((b.boundary = 8), (b.storage = 8)) : y.isVector3 || y.isColor ? ((b.boundary = 16), (b.storage = 12)) : y.isVector4 ? ((b.boundary = 16), (b.storage = 16)) : y.isMatrix3 ? ((b.boundary = 48), (b.storage = 48)) : y.isMatrix4 ? ((b.boundary = 64), (b.storage = 64)) : y.isTexture ? console.warn('THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.') : console.warn('THREE.WebGLRenderer: Unsupported uniform value type.', y), b ); } function m(y) { let b = y.target; b.removeEventListener('dispose', m); let x = a.indexOf(b.__bindingPointIndex); a.splice(x, 1), e.deleteBuffer(s[b.id]), delete s[b.id], delete n[b.id]; } function v() { for (let y in s) e.deleteBuffer(s[y]); (a = []), (s = {}), (n = {}); } return { bind: l, update: h, dispose: v }; } function KP() { let e = md('canvas'); return (e.style.display = 'block'), e; } function Sw(e = {}) { this.isWebGLRenderer = !0; let t = e.canvas !== void 0 ? e.canvas : KP(), i = e.context !== void 0 ? e.context : null, r = e.depth !== void 0 ? e.depth : !0, s = e.stencil !== void 0 ? e.stencil : !0, n = e.antialias !== void 0 ? e.antialias : !1, a = e.premultipliedAlpha !== void 0 ? e.premultipliedAlpha : !0, o = e.preserveDrawingBuffer !== void 0 ? e.preserveDrawingBuffer : !1, l = e.powerPreference !== void 0 ? e.powerPreference : 'default', h = e.failIfMajorPerformanceCaveat !== void 0 ? e.failIfMajorPerformanceCaveat : !1, u; i !== null ? (u = i.getContextAttributes().alpha) : (u = e.alpha !== void 0 ? e.alpha : !1); let c = null, d = null, p = [], f = []; (this.domElement = t), (this.debug = { checkShaderErrors: !0 }), (this.autoClear = !0), (this.autoClearColor = !0), (this.autoClearDepth = !0), (this.autoClearStencil = !0), (this.sortObjects = !0), (this.clippingPlanes = []), (this.localClippingEnabled = !1), (this.outputEncoding = gs), (this.physicallyCorrectLights = !1), (this.toneMapping = Gs), (this.toneMappingExposure = 1); let g = this, m = !1, v = 0, y = 0, b = null, x = -1, w = null, A = new $e(), S = new $e(), _ = null, M = t.width, C = t.height, T = 1, P = null, L = null, D = new $e(0, 0, M, C), k = new $e(0, 0, M, C), W = !1, X = new dg(), z = !1, j = !1, U = null, N = new ve(), B = new G(), H = new E(), Q = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 }; function Y() { return b === null ? T : 1; } let F = i; function se(R, $) { for (let ae = 0; ae < R.length; ae++) { let K = R[ae], he = t.getContext(K, $); if (he !== null) return he; } return null; } try { let R = { alpha: !0, depth: r, stencil: s, antialias: n, premultipliedAlpha: a, preserveDrawingBuffer: o, powerPreference: l, failIfMajorPerformanceCaveat: h }; if ( ('setAttribute' in t && t.setAttribute('data-engine', `three.js r${Wo}`), t.addEventListener('webglcontextlost', Le, !1), t.addEventListener('webglcontextrestored', Ne, !1), t.addEventListener('webglcontextcreationerror', at, !1), F === null) ) { let $ = ['webgl2', 'webgl', 'experimental-webgl']; if ((g.isWebGL1Renderer === !0 && $.shift(), (F = se($, R)), F === null)) throw se($) ? new Error('Error creating WebGL context with your selected attributes.') : new Error('Error creating WebGL context.'); } F.getShaderPrecisionFormat === void 0 && (F.getShaderPrecisionFormat = function () { return { rangeMin: 1, rangeMax: 1, precision: 1 }; }); } catch (R) { throw (console.error('THREE.WebGLRenderer: ' + R.message), R); } let V, ee, J, fe, re, oe, ue, ye, Te, xe, we, Ie, He, dt, I, O, ie, pe, me, be, We, Me, ce, Fe; function Ee() { (V = new c3(F)), (ee = new s3(F, V, e)), V.init(ee), (Me = new WP(F, V, ee)), (J = new VP(F, V, ee)), (fe = new p3()), (re = new DP()), (oe = new HP(F, V, J, re, ee, Me, fe)), (ue = new a3(g)), (ye = new h3(g)), (Te = new _E(F, ee)), (ce = new i3(F, V, Te, ee)), (xe = new d3(F, Te, fe, ce)), (we = new v3(F, xe, Te, fe)), (me = new g3(F, ee, oe)), (O = new n3(re)), (Ie = new PP(g, ue, ye, V, ee, ce, O)), (He = new QP(g, re)), (dt = new OP()), (I = new UP(V, ee)), (pe = new t3(g, ue, ye, J, we, u, a)), (ie = new GP(g, we, ee)), (Fe = new ZP(F, fe, ee, J)), (be = new r3(F, V, fe, ee)), (We = new u3(F, V, fe, ee)), (fe.programs = Ie.programs), (g.capabilities = ee), (g.extensions = V), (g.properties = re), (g.renderLists = dt), (g.shadowMap = ie), (g.state = J), (g.info = fe); } Ee(); let _e = new YP(g, F); (this.xr = _e), (this.getContext = function () { return F; }), (this.getContextAttributes = function () { return F.getContextAttributes(); }), (this.forceContextLoss = function () { let R = V.get('WEBGL_lose_context'); R && R.loseContext(); }), (this.forceContextRestore = function () { let R = V.get('WEBGL_lose_context'); R && R.restoreContext(); }), (this.getPixelRatio = function () { return T; }), (this.setPixelRatio = function (R) { R !== void 0 && ((T = R), this.setSize(M, C, !1)); }), (this.getSize = function (R) { return R.set(M, C); }), (this.setSize = function (R, $, ae) { if (_e.isPresenting) { console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); return; } (M = R), (C = $), (t.width = Math.floor(R * T)), (t.height = Math.floor($ * T)), ae !== !1 && ((t.style.width = R + 'px'), (t.style.height = $ + 'px')), this.setViewport(0, 0, R, $); }), (this.getDrawingBufferSize = function (R) { return R.set(M * T, C * T).floor(); }), (this.setDrawingBufferSize = function (R, $, ae) { (M = R), (C = $), (T = ae), (t.width = Math.floor(R * ae)), (t.height = Math.floor($ * ae)), this.setViewport(0, 0, R, $); }), (this.getCurrentViewport = function (R) { return R.copy(A); }), (this.getViewport = function (R) { return R.copy(D); }), (this.setViewport = function (R, $, ae, K) { R.isVector4 ? D.set(R.x, R.y, R.z, R.w) : D.set(R, $, ae, K), J.viewport(A.copy(D).multiplyScalar(T).floor()); }), (this.getScissor = function (R) { return R.copy(k); }), (this.setScissor = function (R, $, ae, K) { R.isVector4 ? k.set(R.x, R.y, R.z, R.w) : k.set(R, $, ae, K), J.scissor(S.copy(k).multiplyScalar(T).floor()); }), (this.getScissorTest = function () { return W; }), (this.setScissorTest = function (R) { J.setScissorTest((W = R)); }), (this.setOpaqueSort = function (R) { P = R; }), (this.setTransparentSort = function (R) { L = R; }), (this.getClearColor = function (R) { return R.copy(pe.getClearColor()); }), (this.setClearColor = function () { pe.setClearColor.apply(pe, arguments); }), (this.getClearAlpha = function () { return pe.getClearAlpha(); }), (this.setClearAlpha = function () { pe.setClearAlpha.apply(pe, arguments); }), (this.clear = function (R = !0, $ = !0, ae = !0) { let K = 0; R && (K |= 16384), $ && (K |= 256), ae && (K |= 1024), F.clear(K); }), (this.clearColor = function () { this.clear(!0, !1, !1); }), (this.clearDepth = function () { this.clear(!1, !0, !1); }), (this.clearStencil = function () { this.clear(!1, !1, !0); }), (this.dispose = function () { t.removeEventListener('webglcontextlost', Le, !1), t.removeEventListener('webglcontextrestored', Ne, !1), t.removeEventListener('webglcontextcreationerror', at, !1), dt.dispose(), I.dispose(), re.dispose(), ue.dispose(), ye.dispose(), we.dispose(), ce.dispose(), Fe.dispose(), Ie.dispose(), _e.dispose(), _e.removeEventListener('sessionstart', Ae), _e.removeEventListener('sessionend', De), U && (U.dispose(), (U = null)), ot.stop(); }); function Le(R) { R.preventDefault(), console.log('THREE.WebGLRenderer: Context Lost.'), (m = !0); } function Ne() { console.log('THREE.WebGLRenderer: Context Restored.'), (m = !1); let R = fe.autoReset, $ = ie.enabled, ae = ie.autoUpdate, K = ie.needsUpdate, he = ie.type; Ee(), (fe.autoReset = R), (ie.enabled = $), (ie.autoUpdate = ae), (ie.needsUpdate = K), (ie.type = he); } function at(R) { console.error('THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', R.statusMessage); } function Mt(R) { let $ = R.target; $.removeEventListener('dispose', Mt), Wt($); } function Wt(R) { q(R), re.remove(R); } function q(R) { let $ = re.get(R).programs; $ !== void 0 && ($.forEach(function (ae) { Ie.releaseProgram(ae); }), R.isShaderMaterial && Ie.releaseShaderCache(R)); } (this.renderBufferDirect = function (R, $, ae, K, he, Be) { $ === null && ($ = Q); let Je = he.isMesh && he.matrixWorld.determinant() < 0, et = O2(R, $, ae, K, he); J.setMaterial(K, Je); let st = ae.index, wt = 1; K.wireframe === !0 && ((st = xe.getWireframeAttribute(ae)), (wt = 2)); let ut = ae.drawRange, lt = ae.attributes.position, vi = ut.start * wt, Wi = (ut.start + ut.count) * wt; Be !== null && ((vi = Math.max(vi, Be.start * wt)), (Wi = Math.min(Wi, (Be.start + Be.count) * wt))), st !== null ? ((vi = Math.max(vi, 0)), (Wi = Math.min(Wi, st.count))) : lt != null && ((vi = Math.max(vi, 0)), (Wi = Math.min(Wi, lt.count))); let Es = Wi - vi; if (Es < 0 || Es === 1 / 0) return; ce.setup(he, K, et, ae, st); let jn, qt = be; if ((st !== null && ((jn = Te.get(st)), (qt = We), qt.setIndex(jn)), he.isMesh)) K.wireframe === !0 ? (J.setLineWidth(K.wireframeLinewidth * Y()), qt.setMode(1)) : qt.setMode(4); else if (he.isLine) { let ht = K.linewidth; ht === void 0 && (ht = 1), J.setLineWidth(ht * Y()), he.isLineSegments ? qt.setMode(1) : he.isLineLoop ? qt.setMode(2) : qt.setMode(3); } else he.isPoints ? qt.setMode(0) : he.isSprite && qt.setMode(4); if (he.isInstancedMesh) qt.renderInstances(vi, Es, he.count); else if (ae.isInstancedBufferGeometry) { let ht = ae._maxInstanceCount !== void 0 ? ae._maxInstanceCount : 1 / 0, ku = Math.min(ae.instanceCount, ht); qt.renderInstances(vi, Es, ku); } else qt.render(vi, Es); }), (this.compile = function (R, $) { function ae(K, he, Be) { K.transparent === !0 && K.side === er && K.forceSinglePass === !1 ? ((K.side = hi), (K.needsUpdate = !0), lr(K, he, Be), (K.side = Vr), (K.needsUpdate = !0), lr(K, he, Be), (K.side = er)) : lr(K, he, Be); } (d = I.get(R)), d.init(), f.push(d), R.traverseVisible(function (K) { K.isLight && K.layers.test($.layers) && (d.pushLight(K), K.castShadow && d.pushShadow(K)); }), d.setupLights(g.physicallyCorrectLights), R.traverse(function (K) { let he = K.material; if (he) if (Array.isArray(he)) for (let Be = 0; Be < he.length; Be++) { let Je = he[Be]; ae(Je, R, K); } else ae(he, R, K); }), f.pop(), (d = null); }); let ne = null; function de(R) { ne && ne(R); } function Ae() { ot.stop(); } function De() { ot.start(); } let ot = new yw(); ot.setAnimationLoop(de), typeof self < 'u' && ot.setContext(self), (this.setAnimationLoop = function (R) { (ne = R), _e.setAnimationLoop(R), R === null ? ot.stop() : ot.start(); }), _e.addEventListener('sessionstart', Ae), _e.addEventListener('sessionend', De), (this.render = function (R, $) { if ($ !== void 0 && $.isCamera !== !0) { console.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.'); return; } if (m === !0) return; R.matrixWorldAutoUpdate === !0 && R.updateMatrixWorld(), $.parent === null && $.matrixWorldAutoUpdate === !0 && $.updateMatrixWorld(), _e.enabled === !0 && _e.isPresenting === !0 && (_e.cameraAutoUpdate === !0 && _e.updateCamera($), ($ = _e.getCamera())), R.isScene === !0 && R.onBeforeRender(g, R, $, b), (d = I.get(R, f.length)), d.init(), f.push(d), N.multiplyMatrices($.projectionMatrix, $.matrixWorldInverse), X.setFromProjectionMatrix(N), (j = this.localClippingEnabled), (z = O.init(this.clippingPlanes, j)), (c = dt.get(R, p.length)), c.init(), p.push(c), Xt(R, $, 0, g.sortObjects), c.finish(), g.sortObjects === !0 && c.sort(P, L), z === !0 && O.beginShadows(); let ae = d.state.shadowsArray; if ( (ie.render(ae, R, $), z === !0 && O.endShadows(), this.info.autoReset === !0 && this.info.reset(), pe.render(c, R), d.setupLights(g.physicallyCorrectLights), $.isArrayCamera) ) { let K = $.cameras; for (let he = 0, Be = K.length; he < Be; he++) { let Je = K[he]; Ft(c, R, Je, Je.viewport); } } else Ft(c, R, $); b !== null && (oe.updateMultisampleRenderTarget(b), oe.updateRenderTargetMipmap(b)), R.isScene === !0 && R.onAfterRender(g, R, $), ce.resetDefaultState(), (x = -1), (w = null), f.pop(), f.length > 0 ? (d = f[f.length - 1]) : (d = null), p.pop(), p.length > 0 ? (c = p[p.length - 1]) : (c = null); }); function Xt(R, $, ae, K) { if (R.visible === !1) return; if (R.layers.test($.layers)) { if (R.isGroup) ae = R.renderOrder; else if (R.isLOD) R.autoUpdate === !0 && R.update($); else if (R.isLight) d.pushLight(R), R.castShadow && d.pushShadow(R); else if (R.isSprite) { if (!R.frustumCulled || X.intersectsSprite(R)) { K && H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N); let Be = we.update(R), Je = R.material; Je.visible && c.push(R, Be, Je, ae, H.z, null); } } else if ( (R.isMesh || R.isLine || R.isPoints) && (R.isSkinnedMesh && R.skeleton.frame !== fe.render.frame && (R.skeleton.update(), (R.skeleton.frame = fe.render.frame)), !R.frustumCulled || X.intersectsObject(R)) ) { K && H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N); let Be = we.update(R), Je = R.material; if (Array.isArray(Je)) { let et = Be.groups; for (let st = 0, wt = et.length; st < wt; st++) { let ut = et[st], lt = Je[ut.materialIndex]; lt && lt.visible && c.push(R, Be, lt, ae, H.z, ut); } } else Je.visible && c.push(R, Be, Je, ae, H.z, null); } } let he = R.children; for (let Be = 0, Je = he.length; Be < Je; Be++) Xt(he[Be], $, ae, K); } function Ft(R, $, ae, K) { let he = R.opaque, Be = R.transmissive, Je = R.transparent; d.setupLightsView(ae), z === !0 && O.setGlobalState(g.clippingPlanes, ae), Be.length > 0 && kn(he, $, ae), K && J.viewport(A.copy(K)), he.length > 0 && Dt(he, $, ae), Be.length > 0 && Dt(Be, $, ae), Je.length > 0 && Dt(Je, $, ae), J.buffers.depth.setTest(!0), J.buffers.depth.setMask(!0), J.buffers.color.setMask(!0), J.setPolygonOffset(!1); } function kn(R, $, ae) { let K = ee.isWebGL2; U === null && (U = new ii(1, 1, { generateMipmaps: !0, type: V.has('EXT_color_buffer_half_float') ? lh : Mi, minFilter: Bo, samples: K && n === !0 ? 4 : 0 })), g.getDrawingBufferSize(B), K ? U.setSize(B.x, B.y) : U.setSize(fd(B.x), fd(B.y)); let he = g.getRenderTarget(); g.setRenderTarget(U), g.clear(); let Be = g.toneMapping; (g.toneMapping = Gs), Dt(R, $, ae), (g.toneMapping = Be), oe.updateMultisampleRenderTarget(U), oe.updateRenderTargetMipmap(U), g.setRenderTarget(he); } function Dt(R, $, ae) { let K = $.isScene === !0 ? $.overrideMaterial : null; for (let he = 0, Be = R.length; he < Be; he++) { let Je = R[he], et = Je.object, st = Je.geometry, wt = K === null ? Je.material : K, ut = Je.group; et.layers.test(ae.layers) && Ms(et, $, ae, st, wt, ut); } } function Ms(R, $, ae, K, he, Be) { R.onBeforeRender(g, $, ae, K, he, Be), R.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse, R.matrixWorld), R.normalMatrix.getNormalMatrix(R.modelViewMatrix), he.onBeforeRender(g, $, ae, K, R, Be), he.transparent === !0 && he.side === er && he.forceSinglePass === !1 ? ((he.side = hi), (he.needsUpdate = !0), g.renderBufferDirect(ae, $, K, he, R, Be), (he.side = Vr), (he.needsUpdate = !0), g.renderBufferDirect(ae, $, K, he, R, Be), (he.side = er)) : g.renderBufferDirect(ae, $, K, he, R, Be), R.onAfterRender(g, $, ae, K, he, Be); } function lr(R, $, ae) { $.isScene !== !0 && ($ = Q); let K = re.get(R), he = d.state.lights, Be = d.state.shadowsArray, Je = he.state.version, et = Ie.getParameters(R, he.state, Be, $, ae), st = Ie.getProgramCacheKey(et), wt = K.programs; (K.environment = R.isMeshStandardMaterial ? $.environment : null), (K.fog = $.fog), (K.envMap = (R.isMeshStandardMaterial ? ye : ue).get(R.envMap || K.environment)), wt === void 0 && (R.addEventListener('dispose', Mt), (wt = new Map()), (K.programs = wt)); let ut = wt.get(st); if (ut !== void 0) { if (K.currentProgram === ut && K.lightsStateVersion === Je) return Qv(R, et), ut; } else (et.uniforms = Ie.getUniforms(R)), R.onBuild(ae, et, g), R.onBeforeCompile(et, g), (ut = Ie.acquireProgram(et, st)), wt.set(st, ut), (K.uniforms = et.uniforms); let lt = K.uniforms; ((!R.isShaderMaterial && !R.isRawShaderMaterial) || R.clipping === !0) && (lt.clippingPlanes = O.uniform), Qv(R, et), (K.needsLights = R2(R)), (K.lightsStateVersion = Je), K.needsLights && ((lt.ambientLightColor.value = he.state.ambient), (lt.lightProbe.value = he.state.probe), (lt.directionalLights.value = he.state.directional), (lt.directionalLightShadows.value = he.state.directionalShadow), (lt.spotLights.value = he.state.spot), (lt.spotLightShadows.value = he.state.spotShadow), (lt.rectAreaLights.value = he.state.rectArea), (lt.ltc_1.value = he.state.rectAreaLTC1), (lt.ltc_2.value = he.state.rectAreaLTC2), (lt.pointLights.value = he.state.point), (lt.pointLightShadows.value = he.state.pointShadow), (lt.hemisphereLights.value = he.state.hemi), (lt.directionalShadowMap.value = he.state.directionalShadowMap), (lt.directionalShadowMatrix.value = he.state.directionalShadowMatrix), (lt.spotShadowMap.value = he.state.spotShadowMap), (lt.spotLightMatrix.value = he.state.spotLightMatrix), (lt.spotLightMap.value = he.state.spotLightMap), (lt.pointShadowMap.value = he.state.pointShadowMap), (lt.pointShadowMatrix.value = he.state.pointShadowMatrix)); let vi = ut.getUniforms(), Wi = Jc.seqWithValue(vi.seq, lt); return (K.currentProgram = ut), (K.uniformsList = Wi), ut; } function Qv(R, $) { let ae = re.get(R); (ae.outputEncoding = $.outputEncoding), (ae.instancing = $.instancing), (ae.skinning = $.skinning), (ae.morphTargets = $.morphTargets), (ae.morphNormals = $.morphNormals), (ae.morphColors = $.morphColors), (ae.morphTargetsCount = $.morphTargetsCount), (ae.numClippingPlanes = $.numClippingPlanes), (ae.numIntersection = $.numClipIntersection), (ae.vertexAlphas = $.vertexAlphas), (ae.vertexTangents = $.vertexTangents), (ae.toneMapping = $.toneMapping); } function O2(R, $, ae, K, he) { $.isScene !== !0 && ($ = Q), oe.resetTextureUnits(); let Be = $.fog, Je = K.isMeshStandardMaterial ? $.environment : null, et = b === null ? g.outputEncoding : b.isXRRenderTarget === !0 ? b.texture.encoding : gs, st = (K.isMeshStandardMaterial ? ye : ue).get(K.envMap || Je), wt = K.vertexColors === !0 && !!ae.attributes.color && ae.attributes.color.itemSize === 4, ut = !!K.normalMap && !!ae.attributes.tangent, lt = !!ae.morphAttributes.position, vi = !!ae.morphAttributes.normal, Wi = !!ae.morphAttributes.color, Es = K.toneMapped ? g.toneMapping : Gs, jn = ae.morphAttributes.position || ae.morphAttributes.normal || ae.morphAttributes.color, qt = jn !== void 0 ? jn.length : 0, ht = re.get(K), ku = d.state.lights; if (z === !0 && (j === !0 || R !== w)) { let Xi = R === w && K.id === x; O.setState(K, R, Xi); } let ju = !1; K.version === ht.__version ? ((ht.needsLights && ht.lightsStateVersion !== ku.state.version) || ht.outputEncoding !== et || (he.isInstancedMesh && ht.instancing === !1) || (!he.isInstancedMesh && ht.instancing === !0) || (he.isSkinnedMesh && ht.skinning === !1) || (!he.isSkinnedMesh && ht.skinning === !0) || ht.envMap !== st || (K.fog === !0 && ht.fog !== Be) || (ht.numClippingPlanes !== void 0 && (ht.numClippingPlanes !== O.numPlanes || ht.numIntersection !== O.numIntersection)) || ht.vertexAlphas !== wt || ht.vertexTangents !== ut || ht.morphTargets !== lt || ht.morphNormals !== vi || ht.morphColors !== Wi || ht.toneMapping !== Es || (ee.isWebGL2 === !0 && ht.morphTargetsCount !== qt)) && (ju = !0) : ((ju = !0), (ht.__version = K.version)); let Gn = ht.currentProgram; ju === !0 && (Gn = lr(K, $, he)); let Zv = !1, cl = !1, Gu = !1, Ei = Gn.getUniforms(), Vn = ht.uniforms; if ((J.useProgram(Gn.program) && ((Zv = !0), (cl = !0), (Gu = !0)), K.id !== x && ((x = K.id), (cl = !0)), Zv || w !== R)) { if ( (Ei.setValue(F, 'projectionMatrix', R.projectionMatrix), ee.logarithmicDepthBuffer && Ei.setValue(F, 'logDepthBufFC', 2 / (Math.log(R.far + 1) / Math.LN2)), w !== R && ((w = R), (cl = !0), (Gu = !0)), K.isShaderMaterial || K.isMeshPhongMaterial || K.isMeshToonMaterial || K.isMeshStandardMaterial || K.envMap) ) { let Xi = Ei.map.cameraPosition; Xi !== void 0 && Xi.setValue(F, H.setFromMatrixPosition(R.matrixWorld)); } (K.isMeshPhongMaterial || K.isMeshToonMaterial || K.isMeshLambertMaterial || K.isMeshBasicMaterial || K.isMeshStandardMaterial || K.isShaderMaterial) && Ei.setValue(F, 'isOrthographic', R.isOrthographicCamera === !0), (K.isMeshPhongMaterial || K.isMeshToonMaterial || K.isMeshLambertMaterial || K.isMeshBasicMaterial || K.isMeshStandardMaterial || K.isShaderMaterial || K.isShadowMaterial || he.isSkinnedMesh) && Ei.setValue(F, 'viewMatrix', R.matrixWorldInverse); } if (he.isSkinnedMesh) { Ei.setOptional(F, he, 'bindMatrix'), Ei.setOptional(F, he, 'bindMatrixInverse'); let Xi = he.skeleton; Xi && (ee.floatVertexTextures ? (Xi.boneTexture === null && Xi.computeBoneTexture(), Ei.setValue(F, 'boneTexture', Xi.boneTexture, oe), Ei.setValue(F, 'boneTextureSize', Xi.boneTextureSize)) : console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' )); } let Vu = ae.morphAttributes; if ( ((Vu.position !== void 0 || Vu.normal !== void 0 || (Vu.color !== void 0 && ee.isWebGL2 === !0)) && me.update(he, ae, K, Gn), (cl || ht.receiveShadow !== he.receiveShadow) && ((ht.receiveShadow = he.receiveShadow), Ei.setValue(F, 'receiveShadow', he.receiveShadow)), K.isMeshGouraudMaterial && K.envMap !== null && ((Vn.envMap.value = st), (Vn.flipEnvMap.value = st.isCubeTexture && st.isRenderTargetTexture === !1 ? -1 : 1)), cl && (Ei.setValue(F, 'toneMappingExposure', g.toneMappingExposure), ht.needsLights && I2(Vn, Gu), Be && K.fog === !0 && He.refreshFogUniforms(Vn, Be), He.refreshMaterialUniforms(Vn, K, T, C, U), Jc.upload(F, ht.uniformsList, Vn, oe)), K.isShaderMaterial && K.uniformsNeedUpdate === !0 && (Jc.upload(F, ht.uniformsList, Vn, oe), (K.uniformsNeedUpdate = !1)), K.isSpriteMaterial && Ei.setValue(F, 'center', he.center), Ei.setValue(F, 'modelViewMatrix', he.modelViewMatrix), Ei.setValue(F, 'normalMatrix', he.normalMatrix), Ei.setValue(F, 'modelMatrix', he.matrixWorld), K.isShaderMaterial || K.isRawShaderMaterial) ) { let Xi = K.uniformsGroups; for (let Hu = 0, B2 = Xi.length; Hu < B2; Hu++) if (ee.isWebGL2) { let Kv = Xi[Hu]; Fe.update(Kv, Gn), Fe.bind(Kv, Gn); } else console.warn('THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.'); } return Gn; } function I2(R, $) { (R.ambientLightColor.needsUpdate = $), (R.lightProbe.needsUpdate = $), (R.directionalLights.needsUpdate = $), (R.directionalLightShadows.needsUpdate = $), (R.pointLights.needsUpdate = $), (R.pointLightShadows.needsUpdate = $), (R.spotLights.needsUpdate = $), (R.spotLightShadows.needsUpdate = $), (R.rectAreaLights.needsUpdate = $), (R.hemisphereLights.needsUpdate = $); } function R2(R) { return ( R.isMeshLambertMaterial || R.isMeshToonMaterial || R.isMeshPhongMaterial || R.isMeshStandardMaterial || R.isShadowMaterial || (R.isShaderMaterial && R.lights === !0) ); } (this.getActiveCubeFace = function () { return v; }), (this.getActiveMipmapLevel = function () { return y; }), (this.getRenderTarget = function () { return b; }), (this.setRenderTargetTextures = function (R, $, ae) { (re.get(R.texture).__webglTexture = $), (re.get(R.depthTexture).__webglTexture = ae); let K = re.get(R); (K.__hasExternalTextures = !0), K.__hasExternalTextures && ((K.__autoAllocateDepthBuffer = ae === void 0), K.__autoAllocateDepthBuffer || (V.has('WEBGL_multisampled_render_to_texture') === !0 && (console.warn('THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided'), (K.__useRenderToTexture = !1)))); }), (this.setRenderTargetFramebuffer = function (R, $) { let ae = re.get(R); (ae.__webglFramebuffer = $), (ae.__useDefaultFramebuffer = $ === void 0); }), (this.setRenderTarget = function (R, $ = 0, ae = 0) { (b = R), (v = $), (y = ae); let K = !0, he = null, Be = !1, Je = !1; if (R) { let et = re.get(R); et.__useDefaultFramebuffer !== void 0 ? (J.bindFramebuffer(36160, null), (K = !1)) : et.__webglFramebuffer === void 0 ? oe.setupRenderTarget(R) : et.__hasExternalTextures && oe.rebindTextures(R, re.get(R.texture).__webglTexture, re.get(R.depthTexture).__webglTexture); let st = R.texture; (st.isData3DTexture || st.isDataArrayTexture || st.isCompressedArrayTexture) && (Je = !0); let wt = re.get(R).__webglFramebuffer; R.isWebGLCubeRenderTarget ? ((he = wt[$]), (Be = !0)) : ee.isWebGL2 && R.samples > 0 && oe.useMultisampledRTT(R) === !1 ? (he = re.get(R).__webglMultisampledFramebuffer) : (he = wt), A.copy(R.viewport), S.copy(R.scissor), (_ = R.scissorTest); } else A.copy(D).multiplyScalar(T).floor(), S.copy(k).multiplyScalar(T).floor(), (_ = W); if ( (J.bindFramebuffer(36160, he) && ee.drawBuffers && K && J.drawBuffers(R, he), J.viewport(A), J.scissor(S), J.setScissorTest(_), Be) ) { let et = re.get(R.texture); F.framebufferTexture2D(36160, 36064, 34069 + $, et.__webglTexture, ae); } else if (Je) { let et = re.get(R.texture), st = $ || 0; F.framebufferTextureLayer(36160, 36064, et.__webglTexture, ae || 0, st); } x = -1; }), (this.readRenderTargetPixels = function (R, $, ae, K, he, Be, Je) { if (!(R && R.isWebGLRenderTarget)) { console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.'); return; } let et = re.get(R).__webglFramebuffer; if ((R.isWebGLCubeRenderTarget && Je !== void 0 && (et = et[Je]), et)) { J.bindFramebuffer(36160, et); try { let st = R.texture, wt = st.format, ut = st.type; if (wt !== Ur && Me.convert(wt) !== F.getParameter(35739)) { console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.'); return; } let lt = ut === lh && (V.has('EXT_color_buffer_half_float') || (ee.isWebGL2 && V.has('EXT_color_buffer_float'))); if ( ut !== Mi && Me.convert(ut) !== F.getParameter(35738) && !(ut === vn && (ee.isWebGL2 || V.has('OES_texture_float') || V.has('WEBGL_color_buffer_float'))) && !lt ) { console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' ); return; } $ >= 0 && $ <= R.width - K && ae >= 0 && ae <= R.height - he && F.readPixels($, ae, K, he, Me.convert(wt), Me.convert(ut), Be); } finally { let st = b !== null ? re.get(b).__webglFramebuffer : null; J.bindFramebuffer(36160, st); } } }), (this.copyFramebufferToTexture = function (R, $, ae = 0) { let K = Math.pow(2, -ae), he = Math.floor($.image.width * K), Be = Math.floor($.image.height * K); oe.setTexture2D($, 0), F.copyTexSubImage2D(3553, ae, 0, 0, R.x, R.y, he, Be), J.unbindTexture(); }), (this.copyTextureToTexture = function (R, $, ae, K = 0) { let he = $.image.width, Be = $.image.height, Je = Me.convert(ae.format), et = Me.convert(ae.type); oe.setTexture2D(ae, 0), F.pixelStorei(37440, ae.flipY), F.pixelStorei(37441, ae.premultiplyAlpha), F.pixelStorei(3317, ae.unpackAlignment), $.isDataTexture ? F.texSubImage2D(3553, K, R.x, R.y, he, Be, Je, et, $.image.data) : $.isCompressedTexture ? F.compressedTexSubImage2D(3553, K, R.x, R.y, $.mipmaps[0].width, $.mipmaps[0].height, Je, $.mipmaps[0].data) : F.texSubImage2D(3553, K, R.x, R.y, Je, et, $.image), K === 0 && ae.generateMipmaps && F.generateMipmap(3553), J.unbindTexture(); }), (this.copyTextureToTexture3D = function (R, $, ae, K, he = 0) { if (g.isWebGL1Renderer) { console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.'); return; } let Be = R.max.x - R.min.x + 1, Je = R.max.y - R.min.y + 1, et = R.max.z - R.min.z + 1, st = Me.convert(K.format), wt = Me.convert(K.type), ut; if (K.isData3DTexture) oe.setTexture3D(K, 0), (ut = 32879); else if (K.isDataArrayTexture) oe.setTexture2DArray(K, 0), (ut = 35866); else { console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.'); return; } F.pixelStorei(37440, K.flipY), F.pixelStorei(37441, K.premultiplyAlpha), F.pixelStorei(3317, K.unpackAlignment); let lt = F.getParameter(3314), vi = F.getParameter(32878), Wi = F.getParameter(3316), Es = F.getParameter(3315), jn = F.getParameter(32877), qt = ae.isCompressedTexture ? ae.mipmaps[0] : ae.image; F.pixelStorei(3314, qt.width), F.pixelStorei(32878, qt.height), F.pixelStorei(3316, R.min.x), F.pixelStorei(3315, R.min.y), F.pixelStorei(32877, R.min.z), ae.isDataTexture || ae.isData3DTexture ? F.texSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, wt, qt.data) : ae.isCompressedArrayTexture ? (console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.'), F.compressedTexSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, qt.data)) : F.texSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, wt, qt), F.pixelStorei(3314, lt), F.pixelStorei(32878, vi), F.pixelStorei(3316, Wi), F.pixelStorei(3315, Es), F.pixelStorei(32877, jn), he === 0 && K.generateMipmaps && F.generateMipmap(ut), J.unbindTexture(); }), (this.initTexture = function (R) { R.isCubeTexture ? oe.setTextureCube(R, 0) : R.isData3DTexture ? oe.setTexture3D(R, 0) : R.isDataArrayTexture || R.isCompressedArrayTexture ? oe.setTexture2DArray(R, 0) : oe.setTexture2D(R, 0), J.unbindTexture(); }), (this.resetState = function () { (v = 0), (y = 0), (b = null), J.reset(), ce.reset(); }), typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this })); } var JP = class extends Sw {}; JP.prototype.isWebGL1Renderer = !0; var Mw = class { constructor(e, t = 1, i = 1e3) { (this.isFog = !0), (this.name = ''), (this.color = new Ge(e)), (this.near = t), (this.far = i); } clone() { return new Mw(this.color, this.near, this.far); } toJSON() { return { type: 'Fog', color: this.color.getHex(), near: this.near, far: this.far }; } }, pa = class extends bt { constructor() { super(), (this.isScene = !0), (this.type = 'Scene'), (this.background = null), (this.environment = null), (this.fog = null), (this.backgroundBlurriness = 0), (this.backgroundIntensity = 1), (this.overrideMaterial = null), typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this })); } copy(e, t) { return ( super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), (this.backgroundBlurriness = e.backgroundBlurriness), (this.backgroundIntensity = e.backgroundIntensity), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), (this.matrixAutoUpdate = e.matrixAutoUpdate), this ); } toJSON(e) { let t = super.toJSON(e); return ( this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t ); } get autoUpdate() { return console.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.'), this.matrixWorldAutoUpdate; } set autoUpdate(e) { console.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.'), (this.matrixWorldAutoUpdate = e); } }, $P = class { constructor(e, t) { (this.isInterleavedBuffer = !0), (this.array = e), (this.stride = t), (this.count = e !== void 0 ? e.length / t : 0), (this.usage = Ff), (this.updateRange = { offset: 0, count: -1 }), (this.version = 0), (this.uuid = ps()); } onUploadCallback() {} set needsUpdate(e) { e === !0 && this.version++; } setUsage(e) { return (this.usage = e), this; } copy(e) { return ( (this.array = new e.array.constructor(e.array)), (this.count = e.count), (this.stride = e.stride), (this.usage = e.usage), this ); } copyAt(e, t, i) { (e *= this.stride), (i *= t.stride); for (let r = 0, s = this.stride; r < s; r++) this.array[e + r] = t.array[i + r]; return this; } set(e, t = 0) { return this.array.set(e, t), this; } clone(e) { e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = ps()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), i = new this.constructor(t, this.stride); return i.setUsage(this.usage), i; } onUpload(e) { return (this.onUploadCallback = e), this; } toJSON(e) { return ( e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = ps()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), { uuid: this.uuid, buffer: this.array.buffer._uuid, type: this.array.constructor.name, stride: this.stride } ); } }, Ti = new E(), Vf = class { constructor(e, t, i, r = !1) { (this.isInterleavedBufferAttribute = !0), (this.name = ''), (this.data = e), (this.itemSize = t), (this.offset = i), (this.normalized = r); } get count() { return this.data.count; } get array() { return this.data.array; } set needsUpdate(e) { this.data.needsUpdate = e; } applyMatrix4(e) { for (let t = 0, i = this.data.count; t < i; t++) Ti.fromBufferAttribute(this, t), Ti.applyMatrix4(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z); return this; } applyNormalMatrix(e) { for (let t = 0, i = this.count; t < i; t++) Ti.fromBufferAttribute(this, t), Ti.applyNormalMatrix(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z); return this; } transformDirection(e) { for (let t = 0, i = this.count; t < i; t++) Ti.fromBufferAttribute(this, t), Ti.transformDirection(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z); return this; } setX(e, t) { return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset] = t), this; } setY(e, t) { return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 1] = t), this; } setZ(e, t) { return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 2] = t), this; } setW(e, t) { return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 3] = t), this; } getX(e) { let t = this.data.array[e * this.data.stride + this.offset]; return this.normalized && (t = ks(t, this.array)), t; } getY(e) { let t = this.data.array[e * this.data.stride + this.offset + 1]; return this.normalized && (t = ks(t, this.array)), t; } getZ(e) { let t = this.data.array[e * this.data.stride + this.offset + 2]; return this.normalized && (t = ks(t, this.array)), t; } getW(e) { let t = this.data.array[e * this.data.stride + this.offset + 3]; return this.normalized && (t = ks(t, this.array)), t; } setXY(e, t, i) { return ( (e = e * this.data.stride + this.offset), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array))), (this.data.array[e + 0] = t), (this.data.array[e + 1] = i), this ); } setXYZ(e, t, i, r) { return ( (e = e * this.data.stride + this.offset), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array))), (this.data.array[e + 0] = t), (this.data.array[e + 1] = i), (this.data.array[e + 2] = r), this ); } setXYZW(e, t, i, r, s) { return ( (e = e * this.data.stride + this.offset), this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array)), (s = _t(s, this.array))), (this.data.array[e + 0] = t), (this.data.array[e + 1] = i), (this.data.array[e + 2] = r), (this.data.array[e + 3] = s), this ); } clone(e) { if (e === void 0) { console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.'); let t = []; for (let i = 0; i < this.count; i++) { let r = i * this.data.stride + this.offset; for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[r + s]); } return new Xe(new this.array.constructor(t), this.itemSize, this.normalized); } else return ( e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new Vf(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized) ); } toJSON(e) { if (e === void 0) { console.log( 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.' ); let t = []; for (let i = 0; i < this.count; i++) { let r = i * this.data.stride + this.offset; for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[r + s]); } return { itemSize: this.itemSize, type: this.array.constructor.name, array: t, normalized: this.normalized }; } else return ( e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { isInterleavedBufferAttribute: !0, itemSize: this.itemSize, data: this.data.uuid, offset: this.offset, normalized: this.normalized } ); } }, eD = class extends Xe { constructor(e, t, i, r = 1) { super(e, t, i), (this.isInstancedBufferAttribute = !0), (this.meshPerAttribute = r); } copy(e) { return super.copy(e), (this.meshPerAttribute = e.meshPerAttribute), this; } toJSON() { let e = super.toJSON(); return (e.meshPerAttribute = this.meshPerAttribute), (e.isInstancedBufferAttribute = !0), e; } }, Rn = class extends Th { constructor(e) { super(), (this.isLineBasicMaterial = !0), (this.type = 'LineBasicMaterial'), (this.color = new Ge(16777215)), (this.linewidth = 1), (this.linecap = 'round'), (this.linejoin = 'round'), (this.fog = !0), this.setValues(e); } copy(e) { return ( super.copy(e), this.color.copy(e.color), (this.linewidth = e.linewidth), (this.linecap = e.linecap), (this.linejoin = e.linejoin), (this.fog = e.fog), this ); } }, dy = new E(), uy = new E(), py = new ve(), Ap = new Xo(), cc = new Mr(), vd = class extends bt { constructor(e = new Ve(), t = new Rn()) { super(), (this.isLine = !0), (this.type = 'Line'), (this.geometry = e), (this.material = t), this.updateMorphTargets(); } copy(e, t) { return super.copy(e, t), (this.material = e.material), (this.geometry = e.geometry), this; } computeLineDistances() { let e = this.geometry; if (e.index === null) { let t = e.attributes.position, i = [0]; for (let r = 1, s = t.count; r < s; r++) dy.fromBufferAttribute(t, r - 1), uy.fromBufferAttribute(t, r), (i[r] = i[r - 1]), (i[r] += dy.distanceTo(uy)); e.setAttribute('lineDistance', new Ce(i, 1)); } else console.warn('THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.'); return this; } raycast(e, t) { let i = this.geometry, r = this.matrixWorld, s = e.params.Line.threshold, n = i.drawRange; if ( (i.boundingSphere === null && i.computeBoundingSphere(), cc.copy(i.boundingSphere), cc.applyMatrix4(r), (cc.radius += s), e.ray.intersectsSphere(cc) === !1) ) return; py.copy(r).invert(), Ap.copy(e.ray).applyMatrix4(py); let a = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), o = a * a, l = new E(), h = new E(), u = new E(), c = new E(), d = this.isLineSegments ? 2 : 1, p = i.index, f = i.attributes.position; if (p !== null) { let g = Math.max(0, n.start), m = Math.min(p.count, n.start + n.count); for (let v = g, y = m - 1; v < y; v += d) { let b = p.getX(v), x = p.getX(v + 1); if ((l.fromBufferAttribute(f, b), h.fromBufferAttribute(f, x), Ap.distanceSqToSegment(l, h, c, u) > o)) continue; c.applyMatrix4(this.matrixWorld); let w = e.ray.origin.distanceTo(c); w < e.near || w > e.far || t.push({ distance: w, point: u.clone().applyMatrix4(this.matrixWorld), index: v, face: null, faceIndex: null, object: this }); } } else { let g = Math.max(0, n.start), m = Math.min(f.count, n.start + n.count); for (let v = g, y = m - 1; v < y; v += d) { if ((l.fromBufferAttribute(f, v), h.fromBufferAttribute(f, v + 1), Ap.distanceSqToSegment(l, h, c, u) > o)) continue; c.applyMatrix4(this.matrixWorld); let b = e.ray.origin.distanceTo(c); b < e.near || b > e.far || t.push({ distance: b, point: u.clone().applyMatrix4(this.matrixWorld), index: v, face: null, faceIndex: null, object: this }); } } } updateMorphTargets() { let e = this.geometry.morphAttributes, t = Object.keys(e); if (t.length > 0) { let i = e[t[0]]; if (i !== void 0) { (this.morphTargetInfluences = []), (this.morphTargetDictionary = {}); for (let r = 0, s = i.length; r < s; r++) { let n = i[r].name || String(r); this.morphTargetInfluences.push(0), (this.morphTargetDictionary[n] = r); } } } } }, fy = new E(), my = new E(), Dh = class extends vd { constructor(e, t) { super(e, t), (this.isLineSegments = !0), (this.type = 'LineSegments'); } computeLineDistances() { let e = this.geometry; if (e.index === null) { let t = e.attributes.position, i = []; for (let r = 0, s = t.count; r < s; r += 2) fy.fromBufferAttribute(t, r), my.fromBufferAttribute(t, r + 1), (i[r] = r === 0 ? 0 : i[r - 1]), (i[r + 1] = i[r] + fy.distanceTo(my)); e.setAttribute('lineDistance', new Ce(i, 1)); } else console.warn('THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.'); return this; } }, tD = class extends ci { constructor(e, t, i, r, s, n, a, o, l) { super(e, t, i, r, s, n, a, o, l), (this.isVideoTexture = !0), (this.minFilter = n !== void 0 ? n : mt), (this.magFilter = s !== void 0 ? s : mt), (this.generateMipmaps = !1); let h = this; function u() { (h.needsUpdate = !0), e.requestVideoFrameCallback(u); } 'requestVideoFrameCallback' in e && e.requestVideoFrameCallback(u); } clone() { return new this.constructor(this.image).copy(this); } update() { let e = this.image; !('requestVideoFrameCallback' in e) && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0); } }, _s = class { constructor() { (this.type = 'Curve'), (this.arcLengthDivisions = 200); } getPoint() { return console.warn('THREE.Curve: .getPoint() not implemented.'), null; } getPointAt(e, t) { let i = this.getUtoTmapping(e); return this.getPoint(i, t); } getPoints(e = 5) { let t = []; for (let i = 0; i <= e; i++) t.push(this.getPoint(i / e)); return t; } getSpacedPoints(e = 5) { let t = []; for (let i = 0; i <= e; i++) t.push(this.getPointAt(i / e)); return t; } getLength() { let e = this.getLengths(); return e[e.length - 1]; } getLengths(e = this.arcLengthDivisions) { if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths; this.needsUpdate = !1; let t = [], i, r = this.getPoint(0), s = 0; t.push(0); for (let n = 1; n <= e; n++) (i = this.getPoint(n / e)), (s += i.distanceTo(r)), t.push(s), (r = i); return (this.cacheArcLengths = t), t; } updateArcLengths() { (this.needsUpdate = !0), this.getLengths(); } getUtoTmapping(e, t) { let i = this.getLengths(), r = 0, s = i.length, n; t ? (n = t) : (n = e * i[s - 1]); let a = 0, o = s - 1, l; for (; a <= o; ) if (((r = Math.floor(a + (o - a) / 2)), (l = i[r] - n), l < 0)) a = r + 1; else if (l > 0) o = r - 1; else { o = r; break; } if (((r = o), i[r] === n)) return r / (s - 1); let h = i[r], u = i[r + 1] - h, c = (n - h) / u; return (r + c) / (s - 1); } getTangent(e, t) { let i = e - 1e-4, r = e + 1e-4; i < 0 && (i = 0), r > 1 && (r = 1); let s = this.getPoint(i), n = this.getPoint(r), a = t || (s.isVector2 ? new G() : new E()); return a.copy(n).sub(s).normalize(), a; } getTangentAt(e, t) { let i = this.getUtoTmapping(e); return this.getTangent(i, t); } computeFrenetFrames(e, t) { let i = new E(), r = [], s = [], n = [], a = new E(), o = new ve(); for (let d = 0; d <= e; d++) { let p = d / e; r[d] = this.getTangentAt(p, new E()); } (s[0] = new E()), (n[0] = new E()); let l = Number.MAX_VALUE, h = Math.abs(r[0].x), u = Math.abs(r[0].y), c = Math.abs(r[0].z); h <= l && ((l = h), i.set(1, 0, 0)), u <= l && ((l = u), i.set(0, 1, 0)), c <= l && i.set(0, 0, 1), a.crossVectors(r[0], i).normalize(), s[0].crossVectors(r[0], a), n[0].crossVectors(r[0], s[0]); for (let d = 1; d <= e; d++) { if (((s[d] = s[d - 1].clone()), (n[d] = n[d - 1].clone()), a.crossVectors(r[d - 1], r[d]), a.length() > Number.EPSILON)) { a.normalize(); let p = Math.acos(ti(r[d - 1].dot(r[d]), -1, 1)); s[d].applyMatrix4(o.makeRotationAxis(a, p)); } n[d].crossVectors(r[d], s[d]); } if (t === !0) { let d = Math.acos(ti(s[0].dot(s[e]), -1, 1)); (d /= e), r[0].dot(a.crossVectors(s[0], s[e])) > 0 && (d = -d); for (let p = 1; p <= e; p++) s[p].applyMatrix4(o.makeRotationAxis(r[p], d * p)), n[p].crossVectors(r[p], s[p]); } return { tangents: r, normals: s, binormals: n }; } clone() { return new this.constructor().copy(this); } copy(e) { return (this.arcLengthDivisions = e.arcLengthDivisions), this; } toJSON() { let e = { metadata: { version: 4.5, type: 'Curve', generator: 'Curve.toJSON' } }; return (e.arcLengthDivisions = this.arcLengthDivisions), (e.type = this.type), e; } fromJSON(e) { return (this.arcLengthDivisions = e.arcLengthDivisions), this; } }, hu = class extends _s { constructor(e = 0, t = 0, i = 1, r = 1, s = 0, n = Math.PI * 2, a = !1, o = 0) { super(), (this.isEllipseCurve = !0), (this.type = 'EllipseCurve'), (this.aX = e), (this.aY = t), (this.xRadius = i), (this.yRadius = r), (this.aStartAngle = s), (this.aEndAngle = n), (this.aClockwise = a), (this.aRotation = o); } getPoint(e, t) { let i = t || new G(), r = Math.PI * 2, s = this.aEndAngle - this.aStartAngle, n = Math.abs(s) < Number.EPSILON; for (; s < 0; ) s += r; for (; s > r; ) s -= r; s < Number.EPSILON && (n ? (s = 0) : (s = r)), this.aClockwise === !0 && !n && (s === r ? (s = -r) : (s = s - r)); let a = this.aStartAngle + e * s, o = this.aX + this.xRadius * Math.cos(a), l = this.aY + this.yRadius * Math.sin(a); if (this.aRotation !== 0) { let h = Math.cos(this.aRotation), u = Math.sin(this.aRotation), c = o - this.aX, d = l - this.aY; (o = c * h - d * u + this.aX), (l = c * u + d * h + this.aY); } return i.set(o, l); } copy(e) { return ( super.copy(e), (this.aX = e.aX), (this.aY = e.aY), (this.xRadius = e.xRadius), (this.yRadius = e.yRadius), (this.aStartAngle = e.aStartAngle), (this.aEndAngle = e.aEndAngle), (this.aClockwise = e.aClockwise), (this.aRotation = e.aRotation), this ); } toJSON() { let e = super.toJSON(); return ( (e.aX = this.aX), (e.aY = this.aY), (e.xRadius = this.xRadius), (e.yRadius = this.yRadius), (e.aStartAngle = this.aStartAngle), (e.aEndAngle = this.aEndAngle), (e.aClockwise = this.aClockwise), (e.aRotation = this.aRotation), e ); } fromJSON(e) { return ( super.fromJSON(e), (this.aX = e.aX), (this.aY = e.aY), (this.xRadius = e.xRadius), (this.yRadius = e.yRadius), (this.aStartAngle = e.aStartAngle), (this.aEndAngle = e.aEndAngle), (this.aClockwise = e.aClockwise), (this.aRotation = e.aRotation), this ); } }, iD = class extends hu { constructor(e, t, i, r, s, n) { super(e, t, i, i, r, s, n), (this.isArcCurve = !0), (this.type = 'ArcCurve'); } }; function fg() { let e = 0, t = 0, i = 0, r = 0; function s(n, a, o, l) { (e = n), (t = o), (i = -3 * n + 3 * a - 2 * o - l), (r = 2 * n - 2 * a + o + l); } return { initCatmullRom: function (n, a, o, l, h) { s(a, o, h * (o - n), h * (l - a)); }, initNonuniformCatmullRom: function (n, a, o, l, h, u, c) { let d = (a - n) / h - (o - n) / (h + u) + (o - a) / u, p = (o - a) / u - (l - a) / (u + c) + (l - o) / c; (d *= u), (p *= u), s(a, o, d, p); }, calc: function (n) { let a = n * n, o = a * n; return e + t * n + i * a + r * o; } }; } var dc = new E(), Sp = new fg(), Mp = new fg(), Ep = new fg(), rD = class extends _s { constructor(e = [], t = !1, i = 'centripetal', r = 0.5) { super(), (this.isCatmullRomCurve3 = !0), (this.type = 'CatmullRomCurve3'), (this.points = e), (this.closed = t), (this.curveType = i), (this.tension = r); } getPoint(e, t = new E()) { let i = t, r = this.points, s = r.length, n = (s - (this.closed ? 0 : 1)) * e, a = Math.floor(n), o = n - a; this.closed ? (a += a > 0 ? 0 : (Math.floor(Math.abs(a) / s) + 1) * s) : o === 0 && a === s - 1 && ((a = s - 2), (o = 1)); let l, h; this.closed || a > 0 ? (l = r[(a - 1) % s]) : (dc.subVectors(r[0], r[1]).add(r[0]), (l = dc)); let u = r[a % s], c = r[(a + 1) % s]; if ( (this.closed || a + 2 < s ? (h = r[(a + 2) % s]) : (dc.subVectors(r[s - 1], r[s - 2]).add(r[s - 1]), (h = dc)), this.curveType === 'centripetal' || this.curveType === 'chordal') ) { let d = this.curveType === 'chordal' ? 0.5 : 0.25, p = Math.pow(l.distanceToSquared(u), d), f = Math.pow(u.distanceToSquared(c), d), g = Math.pow(c.distanceToSquared(h), d); f < 1e-4 && (f = 1), p < 1e-4 && (p = f), g < 1e-4 && (g = f), Sp.initNonuniformCatmullRom(l.x, u.x, c.x, h.x, p, f, g), Mp.initNonuniformCatmullRom(l.y, u.y, c.y, h.y, p, f, g), Ep.initNonuniformCatmullRom(l.z, u.z, c.z, h.z, p, f, g); } else this.curveType === 'catmullrom' && (Sp.initCatmullRom(l.x, u.x, c.x, h.x, this.tension), Mp.initCatmullRom(l.y, u.y, c.y, h.y, this.tension), Ep.initCatmullRom(l.z, u.z, c.z, h.z, this.tension)); return i.set(Sp.calc(o), Mp.calc(o), Ep.calc(o)), i; } copy(e) { super.copy(e), (this.points = []); for (let t = 0, i = e.points.length; t < i; t++) { let r = e.points[t]; this.points.push(r.clone()); } return (this.closed = e.closed), (this.curveType = e.curveType), (this.tension = e.tension), this; } toJSON() { let e = super.toJSON(); e.points = []; for (let t = 0, i = this.points.length; t < i; t++) { let r = this.points[t]; e.points.push(r.toArray()); } return (e.closed = this.closed), (e.curveType = this.curveType), (e.tension = this.tension), e; } fromJSON(e) { super.fromJSON(e), (this.points = []); for (let t = 0, i = e.points.length; t < i; t++) { let r = e.points[t]; this.points.push(new E().fromArray(r)); } return (this.closed = e.closed), (this.curveType = e.curveType), (this.tension = e.tension), this; } }; function gy(e, t, i, r, s) { let n = (r - t) * 0.5, a = (s - i) * 0.5, o = e * e, l = e * o; return (2 * i - 2 * r + n + a) * l + (-3 * i + 3 * r - 2 * n - a) * o + n * e + i; } function sD(e, t) { let i = 1 - e; return i * i * t; } function nD(e, t) { return 2 * (1 - e) * e * t; } function aD(e, t) { return e * e * t; } function Jl(e, t, i, r) { return sD(e, t) + nD(e, i) + aD(e, r); } function oD(e, t) { let i = 1 - e; return i * i * i * t; } function lD(e, t) { let i = 1 - e; return 3 * i * i * e * t; } function hD(e, t) { return 3 * (1 - e) * e * e * t; } function cD(e, t) { return e * e * e * t; } function $l(e, t, i, r, s) { return oD(e, t) + lD(e, i) + hD(e, r) + cD(e, s); } var Fr = class extends _s { constructor(e = new G(), t = new G(), i = new G(), r = new G()) { super(), (this.isCubicBezierCurve = !0), (this.type = 'CubicBezierCurve'), (this.v0 = e), (this.v1 = t), (this.v2 = i), (this.v3 = r); } getPoint(e, t = new G()) { let i = t, r = this.v0, s = this.v1, n = this.v2, a = this.v3; return i.set($l(e, r.x, s.x, n.x, a.x), $l(e, r.y, s.y, n.y, a.y)), i; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; } toJSON() { let e = super.toJSON(); return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), (e.v3 = this.v3.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; } }, $c = class extends _s { constructor(e = new E(), t = new E(), i = new E(), r = new E()) { super(), (this.isCubicBezierCurve3 = !0), (this.type = 'CubicBezierCurve3'), (this.v0 = e), (this.v1 = t), (this.v2 = i), (this.v3 = r); } getPoint(e, t = new E()) { let i = t, r = this.v0, s = this.v1, n = this.v2, a = this.v3; return i.set($l(e, r.x, s.x, n.x, a.x), $l(e, r.y, s.y, n.y, a.y), $l(e, r.z, s.z, n.z, a.z)), i; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this; } toJSON() { let e = super.toJSON(); return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), (e.v3 = this.v3.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this; } }, Gr = class extends _s { constructor(e = new G(), t = new G()) { super(), (this.isLineCurve = !0), (this.type = 'LineCurve'), (this.v1 = e), (this.v2 = t); } getPoint(e, t = new G()) { let i = t; return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i; } getPointAt(e, t) { return this.getPoint(e, t); } getTangent(e, t) { let i = t || new G(); return i.copy(this.v2).sub(this.v1).normalize(), i; } copy(e) { return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { let e = super.toJSON(); return (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } }, Ew = class extends _s { constructor(e = new E(), t = new E()) { super(), (this.isLineCurve3 = !0), (this.type = 'LineCurve3'), (this.v1 = e), (this.v2 = t); } getPoint(e, t = new E()) { let i = t; return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i; } getPointAt(e, t) { return this.getPoint(e, t); } copy(e) { return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { let e = super.toJSON(); return (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } }, Pn = class extends _s { constructor(e = new G(), t = new G(), i = new G()) { super(), (this.isQuadraticBezierCurve = !0), (this.type = 'QuadraticBezierCurve'), (this.v0 = e), (this.v1 = t), (this.v2 = i); } getPoint(e, t = new G()) { let i = t, r = this.v0, s = this.v1, n = this.v2; return i.set(Jl(e, r.x, s.x, n.x), Jl(e, r.y, s.y, n.y)), i; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { let e = super.toJSON(); return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } }, dD = class extends _s { constructor(e = new E(), t = new E(), i = new E()) { super(), (this.isQuadraticBezierCurve3 = !0), (this.type = 'QuadraticBezierCurve3'), (this.v0 = e), (this.v1 = t), (this.v2 = i); } getPoint(e, t = new E()) { let i = t, r = this.v0, s = this.v1, n = this.v2; return i.set(Jl(e, r.x, s.x, n.x), Jl(e, r.y, s.y, n.y), Jl(e, r.z, s.z, n.z)), i; } copy(e) { return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this; } toJSON() { let e = super.toJSON(); return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this; } }, mg = class extends _s { constructor(e = []) { super(), (this.isSplineCurve = !0), (this.type = 'SplineCurve'), (this.points = e); } getPoint(e, t = new G()) { let i = t, r = this.points, s = (r.length - 1) * e, n = Math.floor(s), a = s - n, o = r[n === 0 ? n : n - 1], l = r[n], h = r[n > r.length - 2 ? r.length - 1 : n + 1], u = r[n > r.length - 3 ? r.length - 1 : n + 2]; return i.set(gy(a, o.x, l.x, h.x, u.x), gy(a, o.y, l.y, h.y, u.y)), i; } copy(e) { super.copy(e), (this.points = []); for (let t = 0, i = e.points.length; t < i; t++) { let r = e.points[t]; this.points.push(r.clone()); } return this; } toJSON() { let e = super.toJSON(); e.points = []; for (let t = 0, i = this.points.length; t < i; t++) { let r = this.points[t]; e.points.push(r.toArray()); } return e; } fromJSON(e) { super.fromJSON(e), (this.points = []); for (let t = 0, i = e.points.length; t < i; t++) { let r = e.points[t]; this.points.push(new G().fromArray(r)); } return this; } }, uD = Object.freeze({ __proto__: null, ArcCurve: iD, CatmullRomCurve3: rD, CubicBezierCurve: Fr, CubicBezierCurve3: $c, EllipseCurve: hu, LineCurve: Gr, LineCurve3: Ew, QuadraticBezierCurve: Pn, QuadraticBezierCurve3: dD, SplineCurve: mg }), Cw = class extends _s { constructor() { super(), (this.type = 'CurvePath'), (this.curves = []), (this.autoClose = !1); } add(e) { this.curves.push(e); } closePath() { let e = this.curves[0].getPoint(0), t = this.curves[this.curves.length - 1].getPoint(1); e.equals(t) || this.curves.push(new Gr(t, e)); } getPoint(e, t) { let i = e * this.getLength(), r = this.getCurveLengths(), s = 0; for (; s < r.length; ) { if (r[s] >= i) { let n = r[s] - i, a = this.curves[s], o = a.getLength(), l = o === 0 ? 0 : 1 - n / o; return a.getPointAt(l, t); } s++; } return null; } getLength() { let e = this.getCurveLengths(); return e[e.length - 1]; } updateArcLengths() { (this.needsUpdate = !0), (this.cacheLengths = null), this.getCurveLengths(); } getCurveLengths() { if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths; let e = [], t = 0; for (let i = 0, r = this.curves.length; i < r; i++) (t += this.curves[i].getLength()), e.push(t); return (this.cacheLengths = e), e; } getSpacedPoints(e = 40) { let t = []; for (let i = 0; i <= e; i++) t.push(this.getPoint(i / e)); return this.autoClose && t.push(t[0]), t; } getPoints(e = 12) { let t = [], i; for (let r = 0, s = this.curves; r < s.length; r++) { let n = s[r], a = n.isEllipseCurve ? e * 2 : n.isLineCurve || n.isLineCurve3 ? 1 : n.isSplineCurve ? e * n.points.length : e, o = n.getPoints(a); for (let l = 0; l < o.length; l++) { let h = o[l]; (i && i.equals(h)) || (t.push(h), (i = h)); } } return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; } copy(e) { super.copy(e), (this.curves = []); for (let t = 0, i = e.curves.length; t < i; t++) { let r = e.curves[t]; this.curves.push(r.clone()); } return (this.autoClose = e.autoClose), this; } toJSON() { let e = super.toJSON(); (e.autoClose = this.autoClose), (e.curves = []); for (let t = 0, i = this.curves.length; t < i; t++) { let r = this.curves[t]; e.curves.push(r.toJSON()); } return e; } fromJSON(e) { super.fromJSON(e), (this.autoClose = e.autoClose), (this.curves = []); for (let t = 0, i = e.curves.length; t < i; t++) { let r = e.curves[t]; this.curves.push(new uD[r.type]().fromJSON(r)); } return this; } }, yd = class extends Cw { constructor(e) { super(), (this.type = 'Path'), (this.currentPoint = new G()), e && this.setFromPoints(e); } setFromPoints(e) { this.moveTo(e[0].x, e[0].y); for (let t = 1, i = e.length; t < i; t++) this.lineTo(e[t].x, e[t].y); return this; } moveTo(e, t) { return this.currentPoint.set(e, t), this; } lineTo(e, t) { let i = new Gr(this.currentPoint.clone(), new G(e, t)); return this.curves.push(i), this.currentPoint.set(e, t), this; } quadraticCurveTo(e, t, i, r) { let s = new Pn(this.currentPoint.clone(), new G(e, t), new G(i, r)); return this.curves.push(s), this.currentPoint.set(i, r), this; } bezierCurveTo(e, t, i, r, s, n) { let a = new Fr(this.currentPoint.clone(), new G(e, t), new G(i, r), new G(s, n)); return this.curves.push(a), this.currentPoint.set(s, n), this; } splineThru(e) { let t = [this.currentPoint.clone()].concat(e), i = new mg(t); return this.curves.push(i), this.currentPoint.copy(e[e.length - 1]), this; } arc(e, t, i, r, s, n) { let a = this.currentPoint.x, o = this.currentPoint.y; return this.absarc(e + a, t + o, i, r, s, n), this; } absarc(e, t, i, r, s, n) { return this.absellipse(e, t, i, i, r, s, n), this; } ellipse(e, t, i, r, s, n, a, o) { let l = this.currentPoint.x, h = this.currentPoint.y; return this.absellipse(e + l, t + h, i, r, s, n, a, o), this; } absellipse(e, t, i, r, s, n, a, o) { let l = new hu(e, t, i, r, s, n, a, o); if (this.curves.length > 0) { let u = l.getPoint(0); u.equals(this.currentPoint) || this.lineTo(u.x, u.y); } this.curves.push(l); let h = l.getPoint(1); return this.currentPoint.copy(h), this; } copy(e) { return super.copy(e), this.currentPoint.copy(e.currentPoint), this; } toJSON() { let e = super.toJSON(); return (e.currentPoint = this.currentPoint.toArray()), e; } fromJSON(e) { return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this; } }, Tw = class extends Ve { constructor(e = [new G(0, -0.5), new G(0.5, 0), new G(0, 0.5)], t = 12, i = 0, r = Math.PI * 2) { super(), (this.type = 'LatheGeometry'), (this.parameters = { points: e, segments: t, phiStart: i, phiLength: r }), (t = Math.floor(t)), (r = ti(r, 0, Math.PI * 2)); let s = [], n = [], a = [], o = [], l = [], h = 1 / t, u = new E(), c = new G(), d = new E(), p = new E(), f = new E(), g = 0, m = 0; for (let v = 0; v <= e.length - 1; v++) switch (v) { case 0: (g = e[v + 1].x - e[v].x), (m = e[v + 1].y - e[v].y), (d.x = m * 1), (d.y = -g), (d.z = m * 0), f.copy(d), d.normalize(), o.push(d.x, d.y, d.z); break; case e.length - 1: o.push(f.x, f.y, f.z); break; default: (g = e[v + 1].x - e[v].x), (m = e[v + 1].y - e[v].y), (d.x = m * 1), (d.y = -g), (d.z = m * 0), p.copy(d), (d.x += f.x), (d.y += f.y), (d.z += f.z), d.normalize(), o.push(d.x, d.y, d.z), f.copy(p); } for (let v = 0; v <= t; v++) { let y = i + v * h * r, b = Math.sin(y), x = Math.cos(y); for (let w = 0; w <= e.length - 1; w++) { (u.x = e[w].x * b), (u.y = e[w].y), (u.z = e[w].x * x), n.push(u.x, u.y, u.z), (c.x = v / t), (c.y = w / (e.length - 1)), a.push(c.x, c.y); let A = o[3 * w + 0] * b, S = o[3 * w + 1], _ = o[3 * w + 0] * x; l.push(A, S, _); } } for (let v = 0; v < t; v++) for (let y = 0; y < e.length - 1; y++) { let b = y + v * e.length, x = b, w = b + e.length, A = b + e.length + 1, S = b + 1; s.push(x, w, S), s.push(A, S, w); } this.setIndex(s), this.setAttribute('position', new Ce(n, 3)), this.setAttribute('uv', new Ce(a, 2)), this.setAttribute('normal', new Ce(l, 3)); } static fromJSON(e) { return new Tw(e.points, e.segments, e.phiStart, e.phiLength); } }, gg = class extends Ve { constructor(e = 1, t = 1, i = 1, r = 32, s = 1, n = !1, a = 0, o = Math.PI * 2) { super(), (this.type = 'CylinderGeometry'), (this.parameters = { radiusTop: e, radiusBottom: t, height: i, radialSegments: r, heightSegments: s, openEnded: n, thetaStart: a, thetaLength: o }); let l = this; (r = Math.floor(r)), (s = Math.floor(s)); let h = [], u = [], c = [], d = [], p = 0, f = [], g = i / 2, m = 0; v(), n === !1 && (e > 0 && y(!0), t > 0 && y(!1)), this.setIndex(h), this.setAttribute('position', new Ce(u, 3)), this.setAttribute('normal', new Ce(c, 3)), this.setAttribute('uv', new Ce(d, 2)); function v() { let b = new E(), x = new E(), w = 0, A = (t - e) / i; for (let S = 0; S <= s; S++) { let _ = [], M = S / s, C = M * (t - e) + e; for (let T = 0; T <= r; T++) { let P = T / r, L = P * o + a, D = Math.sin(L), k = Math.cos(L); (x.x = C * D), (x.y = -M * i + g), (x.z = C * k), u.push(x.x, x.y, x.z), b.set(D, A, k).normalize(), c.push(b.x, b.y, b.z), d.push(P, 1 - M), _.push(p++); } f.push(_); } for (let S = 0; S < r; S++) for (let _ = 0; _ < s; _++) { let M = f[_][S], C = f[_ + 1][S], T = f[_ + 1][S + 1], P = f[_][S + 1]; h.push(M, C, P), h.push(C, T, P), (w += 6); } l.addGroup(m, w, 0), (m += w); } function y(b) { let x = p, w = new G(), A = new E(), S = 0, _ = b === !0 ? e : t, M = b === !0 ? 1 : -1; for (let T = 1; T <= r; T++) u.push(0, g * M, 0), c.push(0, M, 0), d.push(0.5, 0.5), p++; let C = p; for (let T = 0; T <= r; T++) { let P = (T / r) * o + a, L = Math.cos(P), D = Math.sin(P); (A.x = _ * D), (A.y = g * M), (A.z = _ * L), u.push(A.x, A.y, A.z), c.push(0, M, 0), (w.x = L * 0.5 + 0.5), (w.y = D * 0.5 * M + 0.5), d.push(w.x, w.y), p++; } for (let T = 0; T < r; T++) { let P = x + T, L = C + T; b === !0 ? h.push(L, L + 1, P) : h.push(L + 1, L, P), (S += 3); } l.addGroup(m, S, b === !0 ? 1 : 2), (m += S); } } static fromJSON(e) { return new gg(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); } }, Pw = class extends gg { constructor(e = 1, t = 1, i = 32, r = 1, s = !1, n = 0, a = Math.PI * 2) { super(0, e, t, i, r, s, n, a), (this.type = 'ConeGeometry'), (this.parameters = { radius: e, height: t, radialSegments: i, heightSegments: r, openEnded: s, thetaStart: n, thetaLength: a }); } static fromJSON(e) { return new Pw(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength); } }, vg = class extends Ve { constructor(e = [], t = [], i = 1, r = 0) { super(), (this.type = 'PolyhedronGeometry'), (this.parameters = { vertices: e, indices: t, radius: i, detail: r }); let s = [], n = []; a(r), l(i), h(), this.setAttribute('position', new Ce(s, 3)), this.setAttribute('normal', new Ce(s.slice(), 3)), this.setAttribute('uv', new Ce(n, 2)), r === 0 ? this.computeVertexNormals() : this.normalizeNormals(); function a(v) { let y = new E(), b = new E(), x = new E(); for (let w = 0; w < t.length; w += 3) d(t[w + 0], y), d(t[w + 1], b), d(t[w + 2], x), o(y, b, x, v); } function o(v, y, b, x) { let w = x + 1, A = []; for (let S = 0; S <= w; S++) { A[S] = []; let _ = v.clone().lerp(b, S / w), M = y.clone().lerp(b, S / w), C = w - S; for (let T = 0; T <= C; T++) T === 0 && S === w ? (A[S][T] = _) : (A[S][T] = _.clone().lerp(M, T / C)); } for (let S = 0; S < w; S++) for (let _ = 0; _ < 2 * (w - S) - 1; _++) { let M = Math.floor(_ / 2); _ % 2 === 0 ? (c(A[S][M + 1]), c(A[S + 1][M]), c(A[S][M])) : (c(A[S][M + 1]), c(A[S + 1][M + 1]), c(A[S + 1][M])); } } function l(v) { let y = new E(); for (let b = 0; b < s.length; b += 3) (y.x = s[b + 0]), (y.y = s[b + 1]), (y.z = s[b + 2]), y.normalize().multiplyScalar(v), (s[b + 0] = y.x), (s[b + 1] = y.y), (s[b + 2] = y.z); } function h() { let v = new E(); for (let y = 0; y < s.length; y += 3) { (v.x = s[y + 0]), (v.y = s[y + 1]), (v.z = s[y + 2]); let b = g(v) / 2 / Math.PI + 0.5, x = m(v) / Math.PI + 0.5; n.push(b, 1 - x); } p(), u(); } function u() { for (let v = 0; v < n.length; v += 6) { let y = n[v + 0], b = n[v + 2], x = n[v + 4], w = Math.max(y, b, x), A = Math.min(y, b, x); w > 0.9 && A < 0.1 && (y < 0.2 && (n[v + 0] += 1), b < 0.2 && (n[v + 2] += 1), x < 0.2 && (n[v + 4] += 1)); } } function c(v) { s.push(v.x, v.y, v.z); } function d(v, y) { let b = v * 3; (y.x = e[b + 0]), (y.y = e[b + 1]), (y.z = e[b + 2]); } function p() { let v = new E(), y = new E(), b = new E(), x = new E(), w = new G(), A = new G(), S = new G(); for (let _ = 0, M = 0; _ < s.length; _ += 9, M += 6) { v.set(s[_ + 0], s[_ + 1], s[_ + 2]), y.set(s[_ + 3], s[_ + 4], s[_ + 5]), b.set(s[_ + 6], s[_ + 7], s[_ + 8]), w.set(n[M + 0], n[M + 1]), A.set(n[M + 2], n[M + 3]), S.set(n[M + 4], n[M + 5]), x.copy(v).add(y).add(b).divideScalar(3); let C = g(x); f(w, M + 0, v, C), f(A, M + 2, y, C), f(S, M + 4, b, C); } } function f(v, y, b, x) { x < 0 && v.x === 1 && (n[y] = v.x - 1), b.x === 0 && b.z === 0 && (n[y] = x / 2 / Math.PI + 0.5); } function g(v) { return Math.atan2(v.z, -v.x); } function m(v) { return Math.atan2(-v.y, Math.sqrt(v.x * v.x + v.z * v.z)); } } static fromJSON(e) { return new vg(e.vertices, e.indices, e.radius, e.details); } }, Dw = class extends vg { constructor(e = 1, t = 0) { let i = (1 + Math.sqrt(5)) / 2, r = 1 / i, s = [ -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 0, -r, -i, 0, -r, i, 0, r, -i, 0, r, i, -r, -i, 0, -r, i, 0, r, -i, 0, r, i, 0, -i, 0, -r, i, 0, -r, -i, 0, r, i, 0, r ], n = [ 3, 11, 7, 3, 7, 15, 3, 15, 13, 7, 19, 17, 7, 17, 6, 7, 6, 15, 17, 4, 8, 17, 8, 10, 17, 10, 6, 8, 0, 16, 8, 16, 2, 8, 2, 10, 0, 12, 1, 0, 1, 18, 0, 18, 16, 6, 10, 2, 6, 2, 13, 6, 13, 15, 2, 16, 18, 2, 18, 3, 2, 3, 13, 18, 1, 9, 18, 9, 11, 18, 11, 3, 4, 14, 12, 4, 12, 0, 4, 0, 8, 11, 9, 5, 11, 5, 19, 11, 19, 7, 19, 5, 14, 19, 14, 4, 19, 4, 17, 1, 12, 14, 1, 14, 5, 1, 5, 9 ]; super(s, n, e, t), (this.type = 'DodecahedronGeometry'), (this.parameters = { radius: e, detail: t }); } static fromJSON(e) { return new Dw(e.radius, e.detail); } }, xd = class extends yd { constructor(e) { super(e), (this.uuid = ps()), (this.type = 'Shape'), (this.holes = []); } getPointsHoles(e) { let t = []; for (let i = 0, r = this.holes.length; i < r; i++) t[i] = this.holes[i].getPoints(e); return t; } extractPoints(e) { return { shape: this.getPoints(e), holes: this.getPointsHoles(e) }; } copy(e) { super.copy(e), (this.holes = []); for (let t = 0, i = e.holes.length; t < i; t++) { let r = e.holes[t]; this.holes.push(r.clone()); } return this; } toJSON() { let e = super.toJSON(); (e.uuid = this.uuid), (e.holes = []); for (let t = 0, i = this.holes.length; t < i; t++) { let r = this.holes[t]; e.holes.push(r.toJSON()); } return e; } fromJSON(e) { super.fromJSON(e), (this.uuid = e.uuid), (this.holes = []); for (let t = 0, i = e.holes.length; t < i; t++) { let r = e.holes[t]; this.holes.push(new yd().fromJSON(r)); } return this; } }, pD = { triangulate: function (e, t, i = 2) { let r = t && t.length, s = r ? t[0] * i : e.length, n = Lw(e, 0, s, i, !0), a = []; if (!n || n.next === n.prev) return a; let o, l, h, u, c, d, p; if ((r && (n = yD(e, t, n, i)), e.length > 80 * i)) { (o = h = e[0]), (l = u = e[1]); for (let f = i; f < s; f += i) (c = e[f]), (d = e[f + 1]), c < o && (o = c), d < l && (l = d), c > h && (h = c), d > u && (u = d); (p = Math.max(h - o, u - l)), (p = p !== 0 ? 32767 / p : 0); } return ch(n, a, i, o, l, p, 0), a; } }; function Lw(e, t, i, r, s) { let n, a; if (s === PD(e, t, i, r) > 0) for (n = t; n < i; n += r) a = vy(n, e[n], e[n + 1], a); else for (n = i - r; n >= t; n -= r) a = vy(n, e[n], e[n + 1], a); return a && cu(a, a.next) && (uh(a), (a = a.next)), a; } function wa(e, t) { if (!e) return e; t || (t = e); let i = e, r; do { if (((r = !1), !i.steiner && (cu(i, i.next) || It(i.prev, i, i.next) === 0))) { if ((uh(i), (i = t = i.prev), i === i.next)) break; r = !0; } else i = i.next; } while (r || i !== t); return t; } function ch(e, t, i, r, s, n, a) { if (!e) return; !a && n && AD(e, r, s, n); let o = e, l, h; for (; e.prev !== e.next; ) { if (((l = e.prev), (h = e.next), n ? mD(e, r, s, n) : fD(e))) { t.push((l.i / i) | 0), t.push((e.i / i) | 0), t.push((h.i / i) | 0), uh(e), (e = h.next), (o = h.next); continue; } if (((e = h), e === o)) { a ? (a === 1 ? ((e = gD(wa(e), t, i)), ch(e, t, i, r, s, n, 2)) : a === 2 && vD(e, t, i, r, s, n)) : ch(wa(e), t, i, r, s, n, 1); break; } } } function fD(e) { let t = e.prev, i = e, r = e.next; if (It(t, i, r) >= 0) return !1; let s = t.x, n = i.x, a = r.x, o = t.y, l = i.y, h = r.y, u = s < n ? (s < a ? s : a) : n < a ? n : a, c = o < l ? (o < h ? o : h) : l < h ? l : h, d = s > n ? (s > a ? s : a) : n > a ? n : a, p = o > l ? (o > h ? o : h) : l > h ? l : h, f = r.next; for (; f !== t; ) { if (f.x >= u && f.x <= d && f.y >= c && f.y <= p && fo(s, o, n, l, a, h, f.x, f.y) && It(f.prev, f, f.next) >= 0) return !1; f = f.next; } return !0; } function mD(e, t, i, r) { let s = e.prev, n = e, a = e.next; if (It(s, n, a) >= 0) return !1; let o = s.x, l = n.x, h = a.x, u = s.y, c = n.y, d = a.y, p = o < l ? (o < h ? o : h) : l < h ? l : h, f = u < c ? (u < d ? u : d) : c < d ? c : d, g = o > l ? (o > h ? o : h) : l > h ? l : h, m = u > c ? (u > d ? u : d) : c > d ? c : d, v = Hf(p, f, t, i, r), y = Hf(g, m, t, i, r), b = e.prevZ, x = e.nextZ; for (; b && b.z >= v && x && x.z <= y; ) { if ( (b.x >= p && b.x <= g && b.y >= f && b.y <= m && b !== s && b !== a && fo(o, u, l, c, h, d, b.x, b.y) && It(b.prev, b, b.next) >= 0) || ((b = b.prevZ), x.x >= p && x.x <= g && x.y >= f && x.y <= m && x !== s && x !== a && fo(o, u, l, c, h, d, x.x, x.y) && It(x.prev, x, x.next) >= 0) ) return !1; x = x.nextZ; } for (; b && b.z >= v; ) { if (b.x >= p && b.x <= g && b.y >= f && b.y <= m && b !== s && b !== a && fo(o, u, l, c, h, d, b.x, b.y) && It(b.prev, b, b.next) >= 0) return !1; b = b.prevZ; } for (; x && x.z <= y; ) { if (x.x >= p && x.x <= g && x.y >= f && x.y <= m && x !== s && x !== a && fo(o, u, l, c, h, d, x.x, x.y) && It(x.prev, x, x.next) >= 0) return !1; x = x.nextZ; } return !0; } function gD(e, t, i) { let r = e; do { let s = r.prev, n = r.next.next; !cu(s, n) && Ow(s, r, r.next, n) && dh(s, n) && dh(n, s) && (t.push((s.i / i) | 0), t.push((r.i / i) | 0), t.push((n.i / i) | 0), uh(r), uh(r.next), (r = e = n)), (r = r.next); } while (r !== e); return wa(r); } function vD(e, t, i, r, s, n) { let a = e; do { let o = a.next.next; for (; o !== a.prev; ) { if (a.i !== o.i && ED(a, o)) { let l = Iw(a, o); (a = wa(a, a.next)), (l = wa(l, l.next)), ch(a, t, i, r, s, n, 0), ch(l, t, i, r, s, n, 0); return; } o = o.next; } a = a.next; } while (a !== e); } function yD(e, t, i, r) { let s = [], n, a, o, l, h; for (n = 0, a = t.length; n < a; n++) (o = t[n] * r), (l = n < a - 1 ? t[n + 1] * r : e.length), (h = Lw(e, o, l, r, !1)), h === h.next && (h.steiner = !0), s.push(MD(h)); for (s.sort(xD), n = 0; n < s.length; n++) i = bD(s[n], i); return i; } function xD(e, t) { return e.x - t.x; } function bD(e, t) { let i = wD(e, t); if (!i) return t; let r = Iw(i, e); return wa(r, r.next), wa(i, i.next); } function wD(e, t) { let i = t, r = -1 / 0, s, n = e.x, a = e.y; do { if (a <= i.y && a >= i.next.y && i.next.y !== i.y) { let d = i.x + ((a - i.y) * (i.next.x - i.x)) / (i.next.y - i.y); if (d <= n && d > r && ((r = d), (s = i.x < i.next.x ? i : i.next), d === n)) return s; } i = i.next; } while (i !== t); if (!s) return null; let o = s, l = s.x, h = s.y, u = 1 / 0, c; i = s; do { n >= i.x && i.x >= l && n !== i.x && fo(a < h ? n : r, a, l, h, a < h ? r : n, a, i.x, i.y) && ((c = Math.abs(a - i.y) / (n - i.x)), dh(i, e) && (c < u || (c === u && (i.x > s.x || (i.x === s.x && _D(s, i))))) && ((s = i), (u = c))), (i = i.next); } while (i !== o); return s; } function _D(e, t) { return It(e.prev, e, t.prev) < 0 && It(t.next, e, e.next) < 0; } function AD(e, t, i, r) { let s = e; do { s.z === 0 && (s.z = Hf(s.x, s.y, t, i, r)), (s.prevZ = s.prev), (s.nextZ = s.next), (s = s.next); } while (s !== e); (s.prevZ.nextZ = null), (s.prevZ = null), SD(s); } function SD(e) { let t, i, r, s, n, a, o, l, h = 1; do { for (i = e, e = null, n = null, a = 0; i; ) { for (a++, r = i, o = 0, t = 0; t < h && (o++, (r = r.nextZ), !!r); t++); for (l = h; o > 0 || (l > 0 && r); ) o !== 0 && (l === 0 || !r || i.z <= r.z) ? ((s = i), (i = i.nextZ), o--) : ((s = r), (r = r.nextZ), l--), n ? (n.nextZ = s) : (e = s), (s.prevZ = n), (n = s); i = r; } (n.nextZ = null), (h *= 2); } while (a > 1); return e; } function Hf(e, t, i, r, s) { return ( (e = ((e - i) * s) | 0), (t = ((t - r) * s) | 0), (e = (e | (e << 8)) & 16711935), (e = (e | (e << 4)) & 252645135), (e = (e | (e << 2)) & 858993459), (e = (e | (e << 1)) & 1431655765), (t = (t | (t << 8)) & 16711935), (t = (t | (t << 4)) & 252645135), (t = (t | (t << 2)) & 858993459), (t = (t | (t << 1)) & 1431655765), e | (t << 1) ); } function MD(e) { let t = e, i = e; do { (t.x < i.x || (t.x === i.x && t.y < i.y)) && (i = t), (t = t.next); } while (t !== e); return i; } function fo(e, t, i, r, s, n, a, o) { return (s - a) * (t - o) >= (e - a) * (n - o) && (e - a) * (r - o) >= (i - a) * (t - o) && (i - a) * (n - o) >= (s - a) * (r - o); } function ED(e, t) { return ( e.next.i !== t.i && e.prev.i !== t.i && !CD(e, t) && ((dh(e, t) && dh(t, e) && TD(e, t) && (It(e.prev, e, t.prev) || It(e, t.prev, t))) || (cu(e, t) && It(e.prev, e, e.next) > 0 && It(t.prev, t, t.next) > 0)) ); } function It(e, t, i) { return (t.y - e.y) * (i.x - t.x) - (t.x - e.x) * (i.y - t.y); } function cu(e, t) { return e.x === t.x && e.y === t.y; } function Ow(e, t, i, r) { let s = pc(It(e, t, i)), n = pc(It(e, t, r)), a = pc(It(i, r, e)), o = pc(It(i, r, t)); return !!( (s !== n && a !== o) || (s === 0 && uc(e, i, t)) || (n === 0 && uc(e, r, t)) || (a === 0 && uc(i, e, r)) || (o === 0 && uc(i, t, r)) ); } function uc(e, t, i) { return t.x <= Math.max(e.x, i.x) && t.x >= Math.min(e.x, i.x) && t.y <= Math.max(e.y, i.y) && t.y >= Math.min(e.y, i.y); } function pc(e) { return e > 0 ? 1 : e < 0 ? -1 : 0; } function CD(e, t) { let i = e; do { if (i.i !== e.i && i.next.i !== e.i && i.i !== t.i && i.next.i !== t.i && Ow(i, i.next, e, t)) return !0; i = i.next; } while (i !== e); return !1; } function dh(e, t) { return It(e.prev, e, e.next) < 0 ? It(e, t, e.next) >= 0 && It(e, e.prev, t) >= 0 : It(e, t, e.prev) < 0 || It(e, e.next, t) < 0; } function TD(e, t) { let i = e, r = !1, s = (e.x + t.x) / 2, n = (e.y + t.y) / 2; do { i.y > n != i.next.y > n && i.next.y !== i.y && s < ((i.next.x - i.x) * (n - i.y)) / (i.next.y - i.y) + i.x && (r = !r), (i = i.next); } while (i !== e); return r; } function Iw(e, t) { let i = new Wf(e.i, e.x, e.y), r = new Wf(t.i, t.x, t.y), s = e.next, n = t.prev; return (e.next = t), (t.prev = e), (i.next = s), (s.prev = i), (r.next = i), (i.prev = r), (n.next = r), (r.prev = n), r; } function vy(e, t, i, r) { let s = new Wf(e, t, i); return r ? ((s.next = r.next), (s.prev = r), (r.next.prev = s), (r.next = s)) : ((s.prev = s), (s.next = s)), s; } function uh(e) { (e.next.prev = e.prev), (e.prev.next = e.next), e.prevZ && (e.prevZ.nextZ = e.nextZ), e.nextZ && (e.nextZ.prevZ = e.prevZ); } function Wf(e, t, i) { (this.i = e), (this.x = t), (this.y = i), (this.prev = null), (this.next = null), (this.z = 0), (this.prevZ = null), (this.nextZ = null), (this.steiner = !1); } function PD(e, t, i, r) { let s = 0; for (let n = t, a = i - r; n < i; n += r) (s += (e[a] - e[n]) * (e[n + 1] + e[a + 1])), (a = n); return s; } var Rw = class { static area(e) { let t = e.length, i = 0; for (let r = t - 1, s = 0; s < t; r = s++) i += e[r].x * e[s].y - e[s].x * e[r].y; return i * 0.5; } static isClockWise(e) { return Rw.area(e) < 0; } static triangulateShape(e, t) { let i = [], r = [], s = []; yy(e), xy(i, e); let n = e.length; t.forEach(yy); for (let o = 0; o < t.length; o++) r.push(n), (n += t[o].length), xy(i, t[o]); let a = pD.triangulate(i, r); for (let o = 0; o < a.length; o += 3) s.push(a.slice(o, o + 3)); return s; } }; function yy(e) { let t = e.length; t > 2 && e[t - 1].equals(e[0]) && e.pop(); } function xy(e, t) { for (let i = 0; i < t.length; i++) e.push(t[i].x), e.push(t[i].y); } var Bw = class extends vg { constructor(e = 1, t = 0) { let i = (1 + Math.sqrt(5)) / 2, r = [-1, i, 0, 1, i, 0, -1, -i, 0, 1, -i, 0, 0, -1, i, 0, 1, i, 0, -1, -i, 0, 1, -i, i, 0, -1, i, 0, 1, -i, 0, -1, -i, 0, 1], s = [ 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 ]; super(r, s, e, t), (this.type = 'IcosahedronGeometry'), (this.parameters = { radius: e, detail: t }); } static fromJSON(e) { return new Bw(e.radius, e.detail); } }, yg = class extends Ve { constructor(e = 1, t = 32, i = 16, r = 0, s = Math.PI * 2, n = 0, a = Math.PI) { super(), (this.type = 'SphereGeometry'), (this.parameters = { radius: e, widthSegments: t, heightSegments: i, phiStart: r, phiLength: s, thetaStart: n, thetaLength: a }), (t = Math.max(3, Math.floor(t))), (i = Math.max(2, Math.floor(i))); let o = Math.min(n + a, Math.PI), l = 0, h = [], u = new E(), c = new E(), d = [], p = [], f = [], g = []; for (let m = 0; m <= i; m++) { let v = [], y = m / i, b = 0; m == 0 && n == 0 ? (b = 0.5 / t) : m == i && o == Math.PI && (b = -0.5 / t); for (let x = 0; x <= t; x++) { let w = x / t; (u.x = -e * Math.cos(r + w * s) * Math.sin(n + y * a)), (u.y = e * Math.cos(n + y * a)), (u.z = e * Math.sin(r + w * s) * Math.sin(n + y * a)), p.push(u.x, u.y, u.z), c.copy(u).normalize(), f.push(c.x, c.y, c.z), g.push(w + b, 1 - y), v.push(l++); } h.push(v); } for (let m = 0; m < i; m++) for (let v = 0; v < t; v++) { let y = h[m][v + 1], b = h[m][v], x = h[m + 1][v], w = h[m + 1][v + 1]; (m !== 0 || n > 0) && d.push(y, b, w), (m !== i - 1 || o < Math.PI) && d.push(b, x, w); } this.setIndex(d), this.setAttribute('position', new Ce(p, 3)), this.setAttribute('normal', new Ce(f, 3)), this.setAttribute('uv', new Ce(g, 2)); } static fromJSON(e) { return new yg(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength); } }, zw = class extends Ve { constructor(e = 1, t = 0.4, i = 64, r = 8, s = 2, n = 3) { super(), (this.type = 'TorusKnotGeometry'), (this.parameters = { radius: e, tube: t, tubularSegments: i, radialSegments: r, p: s, q: n }), (i = Math.floor(i)), (r = Math.floor(r)); let a = [], o = [], l = [], h = [], u = new E(), c = new E(), d = new E(), p = new E(), f = new E(), g = new E(), m = new E(); for (let y = 0; y <= i; ++y) { let b = (y / i) * s * Math.PI * 2; v(b, s, n, e, d), v(b + 0.01, s, n, e, p), g.subVectors(p, d), m.addVectors(p, d), f.crossVectors(g, m), m.crossVectors(f, g), f.normalize(), m.normalize(); for (let x = 0; x <= r; ++x) { let w = (x / r) * Math.PI * 2, A = -t * Math.cos(w), S = t * Math.sin(w); (u.x = d.x + (A * m.x + S * f.x)), (u.y = d.y + (A * m.y + S * f.y)), (u.z = d.z + (A * m.z + S * f.z)), o.push(u.x, u.y, u.z), c.subVectors(u, d).normalize(), l.push(c.x, c.y, c.z), h.push(y / i), h.push(x / r); } } for (let y = 1; y <= i; y++) for (let b = 1; b <= r; b++) { let x = (r + 1) * (y - 1) + (b - 1), w = (r + 1) * y + (b - 1), A = (r + 1) * y + b, S = (r + 1) * (y - 1) + b; a.push(x, w, S), a.push(w, A, S); } this.setIndex(a), this.setAttribute('position', new Ce(o, 3)), this.setAttribute('normal', new Ce(l, 3)), this.setAttribute('uv', new Ce(h, 2)); function v(y, b, x, w, A) { let S = Math.cos(y), _ = Math.sin(y), M = (x / b) * y, C = Math.cos(M); (A.x = w * (2 + C) * 0.5 * S), (A.y = w * (2 + C) * _ * 0.5), (A.z = w * Math.sin(M) * 0.5); } } static fromJSON(e) { return new zw(e.radius, e.tube, e.tubularSegments, e.radialSegments, e.p, e.q); } }; function tn(e, t, i) { return Nw(e) ? new e.constructor(e.subarray(t, i !== void 0 ? i : e.length)) : e.slice(t, i); } function fc(e, t, i) { return !e || (!i && e.constructor === t) ? e : typeof t.BYTES_PER_ELEMENT == 'number' ? new t(e) : Array.prototype.slice.call(e); } function Nw(e) { return ArrayBuffer.isView(e) && !(e instanceof DataView); } var du = class { constructor(e, t, i, r) { (this.parameterPositions = e), (this._cachedIndex = 0), (this.resultBuffer = r !== void 0 ? r : new t.constructor(i)), (this.sampleValues = t), (this.valueSize = i), (this.settings = null), (this.DefaultSettings_ = {}); } evaluate(e) { let t = this.parameterPositions, i = this._cachedIndex, r = t[i], s = t[i - 1]; i: { e: { let n; t: { r: if (!(e < r)) { for (let a = i + 2; ; ) { if (r === void 0) { if (e < s) break r; return (i = t.length), (this._cachedIndex = i), this.copySampleValue_(i - 1); } if (i === a) break; if (((s = r), (r = t[++i]), e < r)) break e; } n = t.length; break t; } if (!(e >= s)) { let a = t[1]; e < a && ((i = 2), (s = a)); for (let o = i - 2; ; ) { if (s === void 0) return (this._cachedIndex = 0), this.copySampleValue_(0); if (i === o) break; if (((r = s), (s = t[--i - 1]), e >= s)) break e; } (n = i), (i = 0); break t; } break i; } for (; i < n; ) { let a = (i + n) >>> 1; e < t[a] ? (n = a) : (i = a + 1); } if (((r = t[i]), (s = t[i - 1]), s === void 0)) return (this._cachedIndex = 0), this.copySampleValue_(0); if (r === void 0) return (i = t.length), (this._cachedIndex = i), this.copySampleValue_(i - 1); } (this._cachedIndex = i), this.intervalChanged_(i, s, r); } return this.interpolate_(i, s, e, r); } getSettings_() { return this.settings || this.DefaultSettings_; } copySampleValue_(e) { let t = this.resultBuffer, i = this.sampleValues, r = this.valueSize, s = e * r; for (let n = 0; n !== r; ++n) t[n] = i[s + n]; return t; } interpolate_() { throw new Error('call to abstract method'); } intervalChanged_() {} }, DD = class extends du { constructor(e, t, i, r) { super(e, t, i, r), (this._weightPrev = -0), (this._offsetPrev = -0), (this._weightNext = -0), (this._offsetNext = -0), (this.DefaultSettings_ = { endingStart: T0, endingEnd: T0 }); } intervalChanged_(e, t, i) { let r = this.parameterPositions, s = e - 2, n = e + 1, a = r[s], o = r[n]; if (a === void 0) switch (this.getSettings_().endingStart) { case P0: (s = e), (a = 2 * t - i); break; case D0: (s = r.length - 2), (a = t + r[s] - r[s + 1]); break; default: (s = e), (a = i); } if (o === void 0) switch (this.getSettings_().endingEnd) { case P0: (n = e), (o = 2 * i - t); break; case D0: (n = 1), (o = i + r[1] - r[0]); break; default: (n = e - 1), (o = t); } let l = (i - t) * 0.5, h = this.valueSize; (this._weightPrev = l / (t - a)), (this._weightNext = l / (o - i)), (this._offsetPrev = s * h), (this._offsetNext = n * h); } interpolate_(e, t, i, r) { let s = this.resultBuffer, n = this.sampleValues, a = this.valueSize, o = e * a, l = o - a, h = this._offsetPrev, u = this._offsetNext, c = this._weightPrev, d = this._weightNext, p = (i - t) / (r - t), f = p * p, g = f * p, m = -c * g + 2 * c * f - c * p, v = (1 + c) * g + (-1.5 - 2 * c) * f + (-0.5 + c) * p + 1, y = (-1 - d) * g + (1.5 + d) * f + 0.5 * p, b = d * g - d * f; for (let x = 0; x !== a; ++x) s[x] = m * n[h + x] + v * n[l + x] + y * n[o + x] + b * n[u + x]; return s; } }, LD = class extends du { constructor(e, t, i, r) { super(e, t, i, r); } interpolate_(e, t, i, r) { let s = this.resultBuffer, n = this.sampleValues, a = this.valueSize, o = e * a, l = o - a, h = (i - t) / (r - t), u = 1 - h; for (let c = 0; c !== a; ++c) s[c] = n[l + c] * u + n[o + c] * h; return s; } }, OD = class extends du { constructor(e, t, i, r) { super(e, t, i, r); } interpolate_(e) { return this.copySampleValue_(e - 1); } }, Ys = class { constructor(e, t, i, r) { if (e === void 0) throw new Error('THREE.KeyframeTrack: track name is undefined'); if (t === void 0 || t.length === 0) throw new Error('THREE.KeyframeTrack: no keyframes in track named ' + e); (this.name = e), (this.times = fc(t, this.TimeBufferType)), (this.values = fc(i, this.ValueBufferType)), this.setInterpolation(r || this.DefaultInterpolation); } static toJSON(e) { let t = e.constructor, i; if (t.toJSON !== this.toJSON) i = t.toJSON(e); else { i = { name: e.name, times: fc(e.times, Array), values: fc(e.values, Array) }; let r = e.getInterpolation(); r !== e.DefaultInterpolation && (i.interpolation = r); } return (i.type = e.ValueTypeName), i; } InterpolantFactoryMethodDiscrete(e) { return new OD(this.times, this.values, this.getValueSize(), e); } InterpolantFactoryMethodLinear(e) { return new LD(this.times, this.values, this.getValueSize(), e); } InterpolantFactoryMethodSmooth(e) { return new DD(this.times, this.values, this.getValueSize(), e); } setInterpolation(e) { let t; switch (e) { case dd: t = this.InterpolantFactoryMethodDiscrete; break; case ud: t = this.InterpolantFactoryMethodLinear; break; case Ku: t = this.InterpolantFactoryMethodSmooth; break; } if (t === void 0) { let i = 'unsupported interpolation for ' + this.ValueTypeName + ' keyframe track named ' + this.name; if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); else throw new Error(i); return console.warn('THREE.KeyframeTrack:', i), this; } return (this.createInterpolant = t), this; } getInterpolation() { switch (this.createInterpolant) { case this.InterpolantFactoryMethodDiscrete: return dd; case this.InterpolantFactoryMethodLinear: return ud; case this.InterpolantFactoryMethodSmooth: return Ku; } } getValueSize() { return this.values.length / this.times.length; } shift(e) { if (e !== 0) { let t = this.times; for (let i = 0, r = t.length; i !== r; ++i) t[i] += e; } return this; } scale(e) { if (e !== 1) { let t = this.times; for (let i = 0, r = t.length; i !== r; ++i) t[i] *= e; } return this; } trim(e, t) { let i = this.times, r = i.length, s = 0, n = r - 1; for (; s !== r && i[s] < e; ) ++s; for (; n !== -1 && i[n] > t; ) --n; if ((++n, s !== 0 || n !== r)) { s >= n && ((n = Math.max(n, 1)), (s = n - 1)); let a = this.getValueSize(); (this.times = tn(i, s, n)), (this.values = tn(this.values, s * a, n * a)); } return this; } validate() { let e = !0, t = this.getValueSize(); t - Math.floor(t) !== 0 && (console.error('THREE.KeyframeTrack: Invalid value size in track.', this), (e = !1)); let i = this.times, r = this.values, s = i.length; s === 0 && (console.error('THREE.KeyframeTrack: Track is empty.', this), (e = !1)); let n = null; for (let a = 0; a !== s; a++) { let o = i[a]; if (typeof o == 'number' && isNaN(o)) { console.error('THREE.KeyframeTrack: Time is not a valid number.', this, a, o), (e = !1); break; } if (n !== null && n > o) { console.error('THREE.KeyframeTrack: Out of order keys.', this, a, o, n), (e = !1); break; } n = o; } if (r !== void 0 && Nw(r)) for (let a = 0, o = r.length; a !== o; ++a) { let l = r[a]; if (isNaN(l)) { console.error('THREE.KeyframeTrack: Value is not a valid number.', this, a, l), (e = !1); break; } } return e; } optimize() { let e = tn(this.times), t = tn(this.values), i = this.getValueSize(), r = this.getInterpolation() === Ku, s = e.length - 1, n = 1; for (let a = 1; a < s; ++a) { let o = !1, l = e[a], h = e[a + 1]; if (l !== h && (a !== 1 || l !== e[0])) if (r) o = !0; else { let u = a * i, c = u - i, d = u + i; for (let p = 0; p !== i; ++p) { let f = t[u + p]; if (f !== t[c + p] || f !== t[d + p]) { o = !0; break; } } } if (o) { if (a !== n) { e[n] = e[a]; let u = a * i, c = n * i; for (let d = 0; d !== i; ++d) t[c + d] = t[u + d]; } ++n; } } if (s > 0) { e[n] = e[s]; for (let a = s * i, o = n * i, l = 0; l !== i; ++l) t[o + l] = t[a + l]; ++n; } return n !== e.length ? ((this.times = tn(e, 0, n)), (this.values = tn(t, 0, n * i))) : ((this.times = e), (this.values = t)), this; } clone() { let e = tn(this.times, 0), t = tn(this.values, 0), i = this.constructor, r = new i(this.name, e, t); return (r.createInterpolant = this.createInterpolant), r; } }; Ys.prototype.TimeBufferType = Float32Array; Ys.prototype.ValueBufferType = Float32Array; Ys.prototype.DefaultInterpolation = ud; var Lh = class extends Ys {}; Lh.prototype.ValueTypeName = 'bool'; Lh.prototype.ValueBufferType = Array; Lh.prototype.DefaultInterpolation = dd; Lh.prototype.InterpolantFactoryMethodLinear = void 0; Lh.prototype.InterpolantFactoryMethodSmooth = void 0; var ID = class extends Ys {}; ID.prototype.ValueTypeName = 'color'; var RD = class extends Ys {}; RD.prototype.ValueTypeName = 'number'; var BD = class extends du { constructor(e, t, i, r) { super(e, t, i, r); } interpolate_(e, t, i, r) { let s = this.resultBuffer, n = this.sampleValues, a = this.valueSize, o = (i - t) / (r - t), l = e * a; for (let h = l + a; l !== h; l += 4) ct.slerpFlat(s, 0, n, l - a, n, l, o); return s; } }, xg = class extends Ys { InterpolantFactoryMethodLinear(e) { return new BD(this.times, this.values, this.getValueSize(), e); } }; xg.prototype.ValueTypeName = 'quaternion'; xg.prototype.DefaultInterpolation = ud; xg.prototype.InterpolantFactoryMethodSmooth = void 0; var Oh = class extends Ys {}; Oh.prototype.ValueTypeName = 'string'; Oh.prototype.ValueBufferType = Array; Oh.prototype.DefaultInterpolation = dd; Oh.prototype.InterpolantFactoryMethodLinear = void 0; Oh.prototype.InterpolantFactoryMethodSmooth = void 0; var zD = class extends Ys {}; zD.prototype.ValueTypeName = 'vector'; var by = { enabled: !1, files: {}, add: function (e, t) { this.enabled !== !1 && (this.files[e] = t); }, get: function (e) { if (this.enabled !== !1) return this.files[e]; }, remove: function (e) { delete this.files[e]; }, clear: function () { this.files = {}; } }, Uw = class { constructor(e, t, i) { let r = this, s = !1, n = 0, a = 0, o, l = []; (this.onStart = void 0), (this.onLoad = e), (this.onProgress = t), (this.onError = i), (this.itemStart = function (h) { a++, s === !1 && r.onStart !== void 0 && r.onStart(h, n, a), (s = !0); }), (this.itemEnd = function (h) { n++, r.onProgress !== void 0 && r.onProgress(h, n, a), n === a && ((s = !1), r.onLoad !== void 0 && r.onLoad()); }), (this.itemError = function (h) { r.onError !== void 0 && r.onError(h); }), (this.resolveURL = function (h) { return o ? o(h) : h; }), (this.setURLModifier = function (h) { return (o = h), this; }), (this.addHandler = function (h, u) { return l.push(h, u), this; }), (this.removeHandler = function (h) { let u = l.indexOf(h); return u !== -1 && l.splice(u, 2), this; }), (this.getHandler = function (h) { for (let u = 0, c = l.length; u < c; u += 2) { let d = l[u], p = l[u + 1]; if ((d.global && (d.lastIndex = 0), d.test(h))) return p; } return null; }); } }, ND = new Uw(), bg = class { constructor(e) { (this.manager = e !== void 0 ? e : ND), (this.crossOrigin = 'anonymous'), (this.withCredentials = !1), (this.path = ''), (this.resourcePath = ''), (this.requestHeader = {}); } load() {} loadAsync(e, t) { let i = this; return new Promise(function (r, s) { i.load(e, r, t, s); }); } parse() {} setCrossOrigin(e) { return (this.crossOrigin = e), this; } setWithCredentials(e) { return (this.withCredentials = e), this; } setPath(e) { return (this.path = e), this; } setResourcePath(e) { return (this.resourcePath = e), this; } setRequestHeader(e) { return (this.requestHeader = e), this; } }, Os = {}, UD = class extends Error { constructor(e, t) { super(e), (this.response = t); } }, Xf = class extends bg { constructor(e) { super(e); } load(e, t, i, r) { e === void 0 && (e = ''), this.path !== void 0 && (e = this.path + e), (e = this.manager.resolveURL(e)); let s = by.get(e); if (s !== void 0) return ( this.manager.itemStart(e), setTimeout(() => { t && t(s), this.manager.itemEnd(e); }, 0), s ); if (Os[e] !== void 0) { Os[e].push({ onLoad: t, onProgress: i, onError: r }); return; } (Os[e] = []), Os[e].push({ onLoad: t, onProgress: i, onError: r }); let n = new Request(e, { headers: new Headers(this.requestHeader), credentials: this.withCredentials ? 'include' : 'same-origin' }), a = this.mimeType, o = this.responseType; fetch(n) .then((l) => { if (l.status === 200 || l.status === 0) { if ( (l.status === 0 && console.warn('THREE.FileLoader: HTTP Status 0 received.'), typeof ReadableStream > 'u' || l.body === void 0 || l.body.getReader === void 0) ) return l; let h = Os[e], u = l.body.getReader(), c = l.headers.get('Content-Length') || l.headers.get('X-File-Size'), d = c ? parseInt(c) : 0, p = d !== 0, f = 0, g = new ReadableStream({ start(m) { v(); function v() { u.read().then(({ done: y, value: b }) => { if (y) m.close(); else { f += b.byteLength; let x = new ProgressEvent('progress', { lengthComputable: p, loaded: f, total: d }); for (let w = 0, A = h.length; w < A; w++) { let S = h[w]; S.onProgress && S.onProgress(x); } m.enqueue(b), v(); } }); } } }); return new Response(g); } else throw new UD(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`, l); }) .then((l) => { switch (o) { case 'arraybuffer': return l.arrayBuffer(); case 'blob': return l.blob(); case 'document': return l.text().then((h) => new DOMParser().parseFromString(h, a)); case 'json': return l.json(); default: if (a === void 0) return l.text(); { let h = /charset="?([^;"\s]*)"?/i.exec(a), u = h && h[1] ? h[1].toLowerCase() : void 0, c = new TextDecoder(u); return l.arrayBuffer().then((d) => c.decode(d)); } } }) .then((l) => { by.add(e, l); let h = Os[e]; delete Os[e]; for (let u = 0, c = h.length; u < c; u++) { let d = h[u]; d.onLoad && d.onLoad(l); } }) .catch((l) => { let h = Os[e]; if (h === void 0) throw (this.manager.itemError(e), l); delete Os[e]; for (let u = 0, c = h.length; u < c; u++) { let d = h[u]; d.onError && d.onError(l); } this.manager.itemError(e); }) .finally(() => { this.manager.itemEnd(e); }), this.manager.itemStart(e); } setResponseType(e) { return (this.responseType = e), this; } setMimeType(e) { return (this.mimeType = e), this; } }, Ih = class extends bt { constructor(e, t = 1) { super(), (this.isLight = !0), (this.type = 'Light'), (this.color = new Ge(e)), (this.intensity = t); } dispose() {} copy(e, t) { return super.copy(e, t), this.color.copy(e.color), (this.intensity = e.intensity), this; } toJSON(e) { let t = super.toJSON(e); return ( (t.object.color = this.color.getHex()), (t.object.intensity = this.intensity), this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t ); } }, FD = class extends Ih { constructor(e, t, i) { super(e, i), (this.isHemisphereLight = !0), (this.type = 'HemisphereLight'), this.position.copy(bt.DEFAULT_UP), this.updateMatrix(), (this.groundColor = new Ge(t)); } copy(e, t) { return super.copy(e, t), this.groundColor.copy(e.groundColor), this; } }, Cp = new ve(), wy = new E(), _y = new E(), wg = class { constructor(e) { (this.camera = e), (this.bias = 0), (this.normalBias = 0), (this.radius = 1), (this.blurSamples = 8), (this.mapSize = new G(512, 512)), (this.map = null), (this.mapPass = null), (this.matrix = new ve()), (this.autoUpdate = !0), (this.needsUpdate = !1), (this._frustum = new dg()), (this._frameExtents = new G(1, 1)), (this._viewportCount = 1), (this._viewports = [new $e(0, 0, 1, 1)]); } getViewportCount() { return this._viewportCount; } getFrustum() { return this._frustum; } updateMatrices(e) { let t = this.camera, i = this.matrix; wy.setFromMatrixPosition(e.matrixWorld), t.position.copy(wy), _y.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(_y), t.updateMatrixWorld(), Cp.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Cp), i.set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1), i.multiply(Cp); } getViewport(e) { return this._viewports[e]; } getFrameExtents() { return this._frameExtents; } dispose() { this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose(); } copy(e) { return (this.camera = e.camera.clone()), (this.bias = e.bias), (this.radius = e.radius), this.mapSize.copy(e.mapSize), this; } clone() { return new this.constructor().copy(this); } toJSON() { let e = {}; return ( this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), (e.camera = this.camera.toJSON(!1).object), delete e.camera.matrix, e ); } }, kD = class extends wg { constructor() { super(new wi(50, 1, 0.5, 500)), (this.isSpotLightShadow = !0), (this.focus = 1); } updateMatrices(e) { let t = this.camera, i = hh * 2 * e.angle * this.focus, r = this.mapSize.width / this.mapSize.height, s = e.distance || t.far; (i !== t.fov || r !== t.aspect || s !== t.far) && ((t.fov = i), (t.aspect = r), (t.far = s), t.updateProjectionMatrix()), super.updateMatrices(e); } copy(e) { return super.copy(e), (this.focus = e.focus), this; } }, jD = class extends Ih { constructor(e, t, i = 0, r = Math.PI / 3, s = 0, n = 2) { super(e, t), (this.isSpotLight = !0), (this.type = 'SpotLight'), this.position.copy(bt.DEFAULT_UP), this.updateMatrix(), (this.target = new bt()), (this.distance = i), (this.angle = r), (this.penumbra = s), (this.decay = n), (this.map = null), (this.shadow = new kD()); } get power() { return this.intensity * Math.PI; } set power(e) { this.intensity = e / Math.PI; } dispose() { this.shadow.dispose(); } copy(e, t) { return ( super.copy(e, t), (this.distance = e.distance), (this.angle = e.angle), (this.penumbra = e.penumbra), (this.decay = e.decay), (this.target = e.target.clone()), (this.shadow = e.shadow.clone()), this ); } }, Ay = new ve(), yl = new E(), Tp = new E(), GD = class extends wg { constructor() { super(new wi(90, 1, 0.5, 500)), (this.isPointLightShadow = !0), (this._frameExtents = new G(4, 2)), (this._viewportCount = 6), (this._viewports = [ new $e(2, 1, 1, 1), new $e(0, 1, 1, 1), new $e(3, 1, 1, 1), new $e(1, 1, 1, 1), new $e(3, 0, 1, 1), new $e(1, 0, 1, 1) ]), (this._cubeDirections = [new E(1, 0, 0), new E(-1, 0, 0), new E(0, 0, 1), new E(0, 0, -1), new E(0, 1, 0), new E(0, -1, 0)]), (this._cubeUps = [new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 0, 1), new E(0, 0, -1)]); } updateMatrices(e, t = 0) { let i = this.camera, r = this.matrix, s = e.distance || i.far; s !== i.far && ((i.far = s), i.updateProjectionMatrix()), yl.setFromMatrixPosition(e.matrixWorld), i.position.copy(yl), Tp.copy(i.position), Tp.add(this._cubeDirections[t]), i.up.copy(this._cubeUps[t]), i.lookAt(Tp), i.updateMatrixWorld(), r.makeTranslation(-yl.x, -yl.y, -yl.z), Ay.multiplyMatrices(i.projectionMatrix, i.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Ay); } }, VD = class extends Ih { constructor(e, t, i = 0, r = 2) { super(e, t), (this.isPointLight = !0), (this.type = 'PointLight'), (this.distance = i), (this.decay = r), (this.shadow = new GD()); } get power() { return this.intensity * 4 * Math.PI; } set power(e) { this.intensity = e / (4 * Math.PI); } dispose() { this.shadow.dispose(); } copy(e, t) { return super.copy(e, t), (this.distance = e.distance), (this.decay = e.decay), (this.shadow = e.shadow.clone()), this; } }, HD = class extends wg { constructor() { super(new gd(-5, 5, 5, -5, 0.5, 500)), (this.isDirectionalLightShadow = !0); } }, WD = class extends Ih { constructor(e, t) { super(e, t), (this.isDirectionalLight = !0), (this.type = 'DirectionalLight'), this.position.copy(bt.DEFAULT_UP), this.updateMatrix(), (this.target = new bt()), (this.shadow = new HD()); } dispose() { this.shadow.dispose(); } copy(e) { return super.copy(e), (this.target = e.target.clone()), (this.shadow = e.shadow.clone()), this; } }, XD = class extends Ve { constructor() { super(), (this.isInstancedBufferGeometry = !0), (this.type = 'InstancedBufferGeometry'), (this.instanceCount = 1 / 0); } copy(e) { return super.copy(e), (this.instanceCount = e.instanceCount), this; } toJSON() { let e = super.toJSON(); return (e.instanceCount = this.instanceCount), (e.isInstancedBufferGeometry = !0), e; } }, Fw = class extends bg { constructor(e) { super(e); } load(e, t, i, r) { let s = this, n = new Xf(s.manager); n.setPath(s.path), n.setRequestHeader(s.requestHeader), n.setWithCredentials(s.withCredentials), n.load( e, function (a) { try { t(s.parse(JSON.parse(a))); } catch (o) { r ? r(o) : console.error(o), s.manager.itemError(e); } }, i, r ); } parse(e) { let t = {}, i = {}; function r(c, d) { if (t[d] !== void 0) return t[d]; let p = c.interleavedBuffers[d], f = s(c, p.buffer), g = Wh(p.type, f), m = new $P(g, p.stride); return (m.uuid = p.uuid), (t[d] = m), m; } function s(c, d) { if (i[d] !== void 0) return i[d]; let p = c.arrayBuffers[d], f = new Uint32Array(p).buffer; return (i[d] = f), f; } let n = e.isInstancedBufferGeometry ? new XD() : new Ve(), a = e.data.index; if (a !== void 0) { let c = Wh(a.type, a.array); n.setIndex(new Xe(c, 1)); } let o = e.data.attributes; for (let c in o) { let d = o[c], p; if (d.isInterleavedBufferAttribute) { let f = r(e.data, d.data); p = new Vf(f, d.itemSize, d.offset, d.normalized); } else { let f = Wh(d.type, d.array), g = d.isInstancedBufferAttribute ? eD : Xe; p = new g(f, d.itemSize, d.normalized); } d.name !== void 0 && (p.name = d.name), d.usage !== void 0 && p.setUsage(d.usage), d.updateRange !== void 0 && ((p.updateRange.offset = d.updateRange.offset), (p.updateRange.count = d.updateRange.count)), n.setAttribute(c, p); } let l = e.data.morphAttributes; if (l) for (let c in l) { let d = l[c], p = []; for (let f = 0, g = d.length; f < g; f++) { let m = d[f], v; if (m.isInterleavedBufferAttribute) { let y = r(e.data, m.data); v = new Vf(y, m.itemSize, m.offset, m.normalized); } else { let y = Wh(m.type, m.array); v = new Xe(y, m.itemSize, m.normalized); } m.name !== void 0 && (v.name = m.name), p.push(v); } n.morphAttributes[c] = p; } e.data.morphTargetsRelative && (n.morphTargetsRelative = !0); let h = e.data.groups || e.data.drawcalls || e.data.offsets; if (h !== void 0) for (let c = 0, d = h.length; c !== d; ++c) { let p = h[c]; n.addGroup(p.start, p.count, p.materialIndex); } let u = e.data.boundingSphere; if (u !== void 0) { let c = new E(); u.center !== void 0 && c.fromArray(u.center), (n.boundingSphere = new Mr(c, u.radius)); } return e.name && (n.name = e.name), e.userData && (n.userData = e.userData), n; } }, qD = class { constructor(e = !0) { (this.autoStart = e), (this.startTime = 0), (this.oldTime = 0), (this.elapsedTime = 0), (this.running = !1); } start() { (this.startTime = Sy()), (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 e = 0; if (this.autoStart && !this.running) return this.start(), 0; if (this.running) { let t = Sy(); (e = (t - this.oldTime) / 1e3), (this.oldTime = t), (this.elapsedTime += e); } return e; } }; function Sy() { return (typeof performance > 'u' ? Date : performance).now(); } var _g = '\\[\\]\\.:\\/', YD = new RegExp('[' + _g + ']', 'g'), Ag = '[^' + _g + ']', QD = '[^' + _g.replace('\\.', '') + ']', ZD = /((?:WC+[\/:])*)/.source.replace('WC', Ag), KD = /(WCOD+)?/.source.replace('WCOD', QD), JD = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace('WC', Ag), $D = /\.(WC+)(?:\[(.+)\])?/.source.replace('WC', Ag), eL = new RegExp('^' + ZD + KD + JD + $D + '$'), tL = ['material', 'materials', 'bones', 'map'], iL = class { constructor(e, t, i) { let r = i || At.parseTrackName(t); (this._targetGroup = e), (this._bindings = e.subscribe_(t, r)); } getValue(e, t) { this.bind(); let i = this._targetGroup.nCachedObjects_, r = this._bindings[i]; r !== void 0 && r.getValue(e, t); } setValue(e, t) { let i = this._bindings; for (let r = this._targetGroup.nCachedObjects_, s = i.length; r !== s; ++r) i[r].setValue(e, t); } bind() { let e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, i = e.length; t !== i; ++t) e[t].bind(); } unbind() { let e = this._bindings; for (let t = this._targetGroup.nCachedObjects_, i = e.length; t !== i; ++t) e[t].unbind(); } }, At = class { constructor(e, t, i) { (this.path = t), (this.parsedPath = i || At.parseTrackName(t)), (this.node = At.findNode(e, this.parsedPath.nodeName) || e), (this.rootNode = e), (this.getValue = this._getValue_unbound), (this.setValue = this._setValue_unbound); } static create(e, t, i) { return e && e.isAnimationObjectGroup ? new At.Composite(e, t, i) : new At(e, t, i); } static sanitizeNodeName(e) { return e.replace(/\s/g, '_').replace(YD, ''); } static parseTrackName(e) { let t = eL.exec(e); if (t === null) throw new Error('PropertyBinding: Cannot parse trackName: ' + e); let i = { nodeName: t[2], objectName: t[3], objectIndex: t[4], propertyName: t[5], propertyIndex: t[6] }, r = i.nodeName && i.nodeName.lastIndexOf('.'); if (r !== void 0 && r !== -1) { let s = i.nodeName.substring(r + 1); tL.indexOf(s) !== -1 && ((i.nodeName = i.nodeName.substring(0, r)), (i.objectName = s)); } if (i.propertyName === null || i.propertyName.length === 0) throw new Error('PropertyBinding: can not parse propertyName from trackName: ' + e); return i; } static findNode(e, t) { if (t === void 0 || t === '' || t === '.' || t === -1 || t === e.name || t === e.uuid) return e; if (e.skeleton) { let i = e.skeleton.getBoneByName(t); if (i !== void 0) return i; } if (e.children) { let i = function (s) { for (let n = 0; n < s.length; n++) { let a = s[n]; if (a.name === t || a.uuid === t) return a; let o = i(a.children); if (o) return o; } return null; }, r = i(e.children); if (r) return r; } return null; } _getValue_unavailable() {} _setValue_unavailable() {} _getValue_direct(e, t) { e[t] = this.targetObject[this.propertyName]; } _getValue_array(e, t) { let i = this.resolvedProperty; for (let r = 0, s = i.length; r !== s; ++r) e[t++] = i[r]; } _getValue_arrayElement(e, t) { e[t] = this.resolvedProperty[this.propertyIndex]; } _getValue_toArray(e, t) { this.resolvedProperty.toArray(e, t); } _setValue_direct(e, t) { this.targetObject[this.propertyName] = e[t]; } _setValue_direct_setNeedsUpdate(e, t) { (this.targetObject[this.propertyName] = e[t]), (this.targetObject.needsUpdate = !0); } _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { (this.targetObject[this.propertyName] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0); } _setValue_array(e, t) { let i = this.resolvedProperty; for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++]; } _setValue_array_setNeedsUpdate(e, t) { let i = this.resolvedProperty; for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++]; this.targetObject.needsUpdate = !0; } _setValue_array_setMatrixWorldNeedsUpdate(e, t) { let i = this.resolvedProperty; for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++]; this.targetObject.matrixWorldNeedsUpdate = !0; } _setValue_arrayElement(e, t) { this.resolvedProperty[this.propertyIndex] = e[t]; } _setValue_arrayElement_setNeedsUpdate(e, t) { (this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.needsUpdate = !0); } _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { (this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0); } _setValue_fromArray(e, t) { this.resolvedProperty.fromArray(e, t); } _setValue_fromArray_setNeedsUpdate(e, t) { this.resolvedProperty.fromArray(e, t), (this.targetObject.needsUpdate = !0); } _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { this.resolvedProperty.fromArray(e, t), (this.targetObject.matrixWorldNeedsUpdate = !0); } _getValue_unbound(e, t) { this.bind(), this.getValue(e, t); } _setValue_unbound(e, t) { this.bind(), this.setValue(e, t); } bind() { let e = this.node, t = this.parsedPath, i = t.objectName, r = t.propertyName, s = t.propertyIndex; if ( (e || ((e = At.findNode(this.rootNode, t.nodeName) || this.rootNode), (this.node = e)), (this.getValue = this._getValue_unavailable), (this.setValue = this._setValue_unavailable), !e) ) { console.error('THREE.PropertyBinding: Trying to update node for track: ' + this.path + " but it wasn't found."); return; } if (i) { let l = t.objectIndex; switch (i) { case 'materials': if (!e.material) { console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this); return; } if (!e.material.materials) { console.error( 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this ); return; } e = e.material.materials; break; case 'bones': if (!e.skeleton) { console.error('THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this); return; } e = e.skeleton.bones; for (let h = 0; h < e.length; h++) if (e[h].name === l) { l = h; break; } break; case 'map': if ('map' in e) { e = e.map; break; } if (!e.material) { console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this); return; } if (!e.material.map) { console.error('THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.', this); return; } e = e.material.map; break; default: if (e[i] === void 0) { console.error('THREE.PropertyBinding: Can not bind to objectName of node undefined.', this); return; } e = e[i]; } if (l !== void 0) { if (e[l] === void 0) { console.error('THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, e); return; } e = e[l]; } } let n = e[r]; if (n === void 0) { let l = t.nodeName; console.error('THREE.PropertyBinding: Trying to update property for track: ' + l + '.' + r + " but it wasn't found.", e); return; } let a = this.Versioning.None; (this.targetObject = e), e.needsUpdate !== void 0 ? (a = this.Versioning.NeedsUpdate) : e.matrixWorldNeedsUpdate !== void 0 && (a = this.Versioning.MatrixWorldNeedsUpdate); let o = this.BindingType.Direct; if (s !== void 0) { if (r === 'morphTargetInfluences') { if (!e.geometry) { console.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this); return; } if (!e.geometry.morphAttributes) { console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this ); return; } e.morphTargetDictionary[s] !== void 0 && (s = e.morphTargetDictionary[s]); } (o = this.BindingType.ArrayElement), (this.resolvedProperty = n), (this.propertyIndex = s); } else n.fromArray !== void 0 && n.toArray !== void 0 ? ((o = this.BindingType.HasFromToArray), (this.resolvedProperty = n)) : Array.isArray(n) ? ((o = this.BindingType.EntireArray), (this.resolvedProperty = n)) : (this.propertyName = r); (this.getValue = this.GetterByBindingType[o]), (this.setValue = this.SetterByBindingTypeAndVersioning[o][a]); } unbind() { (this.node = null), (this.getValue = this._getValue_unbound), (this.setValue = this._setValue_unbound); } }; At.Composite = iL; At.prototype.BindingType = { Direct: 0, EntireArray: 1, ArrayElement: 2, HasFromToArray: 3 }; At.prototype.Versioning = { None: 0, NeedsUpdate: 1, MatrixWorldNeedsUpdate: 2 }; At.prototype.GetterByBindingType = [ At.prototype._getValue_direct, At.prototype._getValue_array, At.prototype._getValue_arrayElement, At.prototype._getValue_toArray ]; At.prototype.SetterByBindingTypeAndVersioning = [ [At.prototype._setValue_direct, At.prototype._setValue_direct_setNeedsUpdate, At.prototype._setValue_direct_setMatrixWorldNeedsUpdate], [At.prototype._setValue_array, At.prototype._setValue_array_setNeedsUpdate, At.prototype._setValue_array_setMatrixWorldNeedsUpdate], [ At.prototype._setValue_arrayElement, At.prototype._setValue_arrayElement_setNeedsUpdate, At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate ], [ At.prototype._setValue_fromArray, At.prototype._setValue_fromArray_setNeedsUpdate, At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate ] ]; var p9 = new Float32Array(1), Oe = class { constructor(e) { this.value = e; } clone() { return new Oe(this.value.clone === void 0 ? this.value : this.value.clone()); } }, kw = class { constructor(e, t, i = 0, r = 1 / 0) { (this.ray = new Xo(e, t)), (this.near = i), (this.far = r), (this.camera = null), (this.layers = new hg()), (this.params = { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} }); } set(e, t) { this.ray.set(e, t); } setFromCamera(e, t) { t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(), (this.camera = t)) : t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), (this.camera = t)) : console.error('THREE.Raycaster: Unsupported camera type: ' + t.type); } intersectObject(e, t = !0, i = []) { return qf(e, this, i, t), i.sort(My), i; } intersectObjects(e, t = !0, i = []) { for (let r = 0, s = e.length; r < s; r++) qf(e[r], this, i, t); return i.sort(My), i; } }; function My(e, t) { return e.distance - t.distance; } function qf(e, t, i, r) { if ((e.layers.test(t.layers) && e.raycast(t, i), r === !0)) { let s = e.children; for (let n = 0, a = s.length; n < a; n++) qf(s[n], t, i, !0); } } var Ey = class { constructor(e = 1, t = 0, i = 0) { return (this.radius = e), (this.phi = t), (this.theta = i), this; } set(e, t, i) { return (this.radius = e), (this.phi = t), (this.theta = i), this; } copy(e) { return (this.radius = e.radius), (this.phi = e.phi), (this.theta = e.theta), this; } makeSafe() { return (this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi))), this; } setFromVector3(e) { return this.setFromCartesianCoords(e.x, e.y, e.z); } setFromCartesianCoords(e, t, i) { return ( (this.radius = Math.sqrt(e * e + t * t + i * i)), this.radius === 0 ? ((this.theta = 0), (this.phi = 0)) : ((this.theta = Math.atan2(e, i)), (this.phi = Math.acos(ti(t / this.radius, -1, 1)))), this ); } clone() { return new this.constructor().copy(this); } }, Cy = new G(), rL = class { constructor(e = new G(1 / 0, 1 / 0), t = new G(-1 / 0, -1 / 0)) { (this.isBox2 = !0), (this.min = e), (this.max = t); } set(e, t) { return this.min.copy(e), this.max.copy(t), this; } setFromPoints(e) { this.makeEmpty(); for (let t = 0, i = e.length; t < i; t++) this.expandByPoint(e[t]); return this; } setFromCenterAndSize(e, t) { let i = Cy.copy(t).multiplyScalar(0.5); return this.min.copy(e).sub(i), this.max.copy(e).add(i), this; } clone() { return new this.constructor().copy(this); } copy(e) { return this.min.copy(e.min), this.max.copy(e.max), this; } makeEmpty() { return (this.min.x = this.min.y = 1 / 0), (this.max.x = this.max.y = -1 / 0), this; } isEmpty() { return this.max.x < this.min.x || this.max.y < this.min.y; } getCenter(e) { return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5); } getSize(e) { return this.isEmpty() ? e.set(0, 0) : e.subVectors(this.max, this.min); } expandByPoint(e) { return this.min.min(e), this.max.max(e), this; } expandByVector(e) { return this.min.sub(e), this.max.add(e), this; } expandByScalar(e) { return this.min.addScalar(-e), this.max.addScalar(e), this; } containsPoint(e) { return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y); } containsBox(e) { return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y; } getParameter(e, t) { return t.set((e.x - this.min.x) / (this.max.x - this.min.x), (e.y - this.min.y) / (this.max.y - this.min.y)); } intersectsBox(e) { return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y); } clampPoint(e, t) { return t.copy(e).clamp(this.min, this.max); } distanceToPoint(e) { return Cy.copy(e).clamp(this.min, this.max).sub(e).length(); } intersect(e) { return this.min.max(e.min), this.max.min(e.max), this; } union(e) { return this.min.min(e.min), this.max.max(e.max), this; } translate(e) { return this.min.add(e), this.max.add(e), this; } equals(e) { return e.min.equals(this.min) && e.max.equals(this.max); } }, Ty = new E(), mc = new E(), _r = class { constructor(e = new E(), t = new E()) { (this.start = e), (this.end = t); } set(e, t) { return this.start.copy(e), this.end.copy(t), this; } copy(e) { return this.start.copy(e.start), this.end.copy(e.end), this; } getCenter(e) { return e.addVectors(this.start, this.end).multiplyScalar(0.5); } delta(e) { return e.subVectors(this.end, this.start); } distanceSq() { return this.start.distanceToSquared(this.end); } distance() { return this.start.distanceTo(this.end); } at(e, t) { return this.delta(t).multiplyScalar(e).add(this.start); } closestPointToPointParameter(e, t) { Ty.subVectors(e, this.start), mc.subVectors(this.end, this.start); let i = mc.dot(mc), r = mc.dot(Ty) / i; return t && (r = ti(r, 0, 1)), r; } closestPointToPoint(e, t, i) { let r = this.closestPointToPointParameter(e, t); return this.delta(i).multiplyScalar(r).add(this.start); } applyMatrix4(e) { return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this; } equals(e) { return e.start.equals(this.start) && e.end.equals(this.end); } clone() { return new this.constructor().copy(this); } }, Py = new E(), sL = class extends bt { constructor(e, t) { super(), (this.light = e), (this.matrix = e.matrixWorld), (this.matrixAutoUpdate = !1), (this.color = t), (this.type = 'SpotLightHelper'); let i = new Ve(), r = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, 1]; for (let n = 0, a = 1, o = 32; n < o; n++, a++) { let l = (n / o) * Math.PI * 2, h = (a / o) * Math.PI * 2; r.push(Math.cos(l), Math.sin(l), 1, Math.cos(h), Math.sin(h), 1); } i.setAttribute('position', new Ce(r, 3)); let s = new Rn({ fog: !1, toneMapped: !1 }); (this.cone = new Dh(i, s)), this.add(this.cone), this.update(); } dispose() { this.cone.geometry.dispose(), this.cone.material.dispose(); } update() { this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1); let e = this.light.distance ? this.light.distance : 1e3, t = e * Math.tan(this.light.angle); this.cone.scale.set(t, t, e), Py.setFromMatrixPosition(this.light.target.matrixWorld), this.cone.lookAt(Py), this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color); } }, nL = class extends tr { constructor(e, t, i) { let r = new yg(t, 4, 2), s = new Ph({ wireframe: !0, fog: !1, toneMapped: !1 }); super(r, s), (this.light = e), (this.color = i), (this.type = 'PointLightHelper'), (this.matrix = this.light.matrixWorld), (this.matrixAutoUpdate = !1), this.update(); } dispose() { this.geometry.dispose(), this.material.dispose(); } update() { this.light.updateWorldMatrix(!0, !1), this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color); } }, Dy = new E(), gc = new E(), Ly = new E(), aL = class extends bt { constructor(e, t, i) { super(), (this.light = e), (this.matrix = e.matrixWorld), (this.matrixAutoUpdate = !1), (this.color = i), (this.type = 'DirectionalLightHelper'), t === void 0 && (t = 1); let r = new Ve(); r.setAttribute('position', new Ce([-t, t, 0, t, t, 0, t, -t, 0, -t, -t, 0, -t, t, 0], 3)); let s = new Rn({ fog: !1, toneMapped: !1 }); (this.lightPlane = new vd(r, s)), this.add(this.lightPlane), (r = new Ve()), r.setAttribute('position', new Ce([0, 0, 0, 0, 0, 1], 3)), (this.targetLine = new vd(r, s)), this.add(this.targetLine), this.update(); } dispose() { this.lightPlane.geometry.dispose(), this.lightPlane.material.dispose(), this.targetLine.geometry.dispose(), this.targetLine.material.dispose(); } update() { this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1), Dy.setFromMatrixPosition(this.light.matrixWorld), gc.setFromMatrixPosition(this.light.target.matrixWorld), Ly.subVectors(gc, Dy), this.lightPlane.lookAt(gc), this.color !== void 0 ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color)) : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)), this.targetLine.lookAt(gc), (this.targetLine.scale.z = Ly.length()); } }, vc = new E(), Rt = new Yo(), bd = class extends Dh { constructor(e) { let t = new Ve(), i = new Rn({ color: 16777215, vertexColors: !0, toneMapped: !1 }), r = [], s = [], n = {}; a('n1', 'n2'), a('n2', 'n4'), a('n4', 'n3'), a('n3', 'n1'), a('f1', 'f2'), a('f2', 'f4'), a('f4', 'f3'), a('f3', 'f1'), a('n1', 'f1'), a('n2', 'f2'), a('n3', 'f3'), a('n4', 'f4'), a('p', 'n1'), a('p', 'n2'), a('p', 'n3'), a('p', 'n4'), a('u1', 'u2'), a('u2', 'u3'), a('u3', 'u1'), a('c', 't'), a('p', 'c'), a('cn1', 'cn2'), a('cn3', 'cn4'), a('cf1', 'cf2'), a('cf3', 'cf4'); function a(p, f) { o(p), o(f); } function o(p) { r.push(0, 0, 0), s.push(0, 0, 0), n[p] === void 0 && (n[p] = []), n[p].push(r.length / 3 - 1); } t.setAttribute('position', new Ce(r, 3)), t.setAttribute('color', new Ce(s, 3)), super(t, i), (this.type = 'CameraHelper'), (this.camera = e), this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), (this.matrix = e.matrixWorld), (this.matrixAutoUpdate = !1), (this.pointMap = n), this.update(); let l = new Ge(16755200), h = new Ge(16711680), u = new Ge(43775), c = new Ge(16777215), d = new Ge(3355443); this.setColors(l, h, u, c, d); } setColors(e, t, i, r, s) { let n = this.geometry.getAttribute('color'); n.setXYZ(0, e.r, e.g, e.b), n.setXYZ(1, e.r, e.g, e.b), n.setXYZ(2, e.r, e.g, e.b), n.setXYZ(3, e.r, e.g, e.b), n.setXYZ(4, e.r, e.g, e.b), n.setXYZ(5, e.r, e.g, e.b), n.setXYZ(6, e.r, e.g, e.b), n.setXYZ(7, e.r, e.g, e.b), n.setXYZ(8, e.r, e.g, e.b), n.setXYZ(9, e.r, e.g, e.b), n.setXYZ(10, e.r, e.g, e.b), n.setXYZ(11, e.r, e.g, e.b), n.setXYZ(12, e.r, e.g, e.b), n.setXYZ(13, e.r, e.g, e.b), n.setXYZ(14, e.r, e.g, e.b), n.setXYZ(15, e.r, e.g, e.b), n.setXYZ(16, e.r, e.g, e.b), n.setXYZ(17, e.r, e.g, e.b), n.setXYZ(18, e.r, e.g, e.b), n.setXYZ(19, e.r, e.g, e.b), n.setXYZ(20, e.r, e.g, e.b), n.setXYZ(21, e.r, e.g, e.b), n.setXYZ(22, e.r, e.g, e.b), n.setXYZ(23, e.r, e.g, e.b), n.setXYZ(24, t.r, t.g, t.b), n.setXYZ(25, t.r, t.g, t.b), n.setXYZ(26, t.r, t.g, t.b), n.setXYZ(27, t.r, t.g, t.b), n.setXYZ(28, t.r, t.g, t.b), n.setXYZ(29, t.r, t.g, t.b), n.setXYZ(30, t.r, t.g, t.b), n.setXYZ(31, t.r, t.g, t.b), n.setXYZ(32, i.r, i.g, i.b), n.setXYZ(33, i.r, i.g, i.b), n.setXYZ(34, i.r, i.g, i.b), n.setXYZ(35, i.r, i.g, i.b), n.setXYZ(36, i.r, i.g, i.b), n.setXYZ(37, i.r, i.g, i.b), n.setXYZ(38, r.r, r.g, r.b), n.setXYZ(39, r.r, r.g, r.b), n.setXYZ(40, s.r, s.g, s.b), n.setXYZ(41, s.r, s.g, s.b), n.setXYZ(42, s.r, s.g, s.b), n.setXYZ(43, s.r, s.g, s.b), n.setXYZ(44, s.r, s.g, s.b), n.setXYZ(45, s.r, s.g, s.b), n.setXYZ(46, s.r, s.g, s.b), n.setXYZ(47, s.r, s.g, s.b), n.setXYZ(48, s.r, s.g, s.b), n.setXYZ(49, s.r, s.g, s.b), (n.needsUpdate = !0); } update() { let e = this.geometry, t = this.pointMap, i = 1, r = 1; Rt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse), kt('c', t, e, Rt, 0, 0, -1), kt('t', t, e, Rt, 0, 0, 1), kt('n1', t, e, Rt, -i, -r, -1), kt('n2', t, e, Rt, i, -r, -1), kt('n3', t, e, Rt, -i, r, -1), kt('n4', t, e, Rt, i, r, -1), kt('f1', t, e, Rt, -i, -r, 1), kt('f2', t, e, Rt, i, -r, 1), kt('f3', t, e, Rt, -i, r, 1), kt('f4', t, e, Rt, i, r, 1), kt('u1', t, e, Rt, i * 0.7, r * 1.1, -1), kt('u2', t, e, Rt, -i * 0.7, r * 1.1, -1), kt('u3', t, e, Rt, 0, r * 2, -1), kt('cf1', t, e, Rt, -i, 0, 1), kt('cf2', t, e, Rt, i, 0, 1), kt('cf3', t, e, Rt, 0, -r, 1), kt('cf4', t, e, Rt, 0, r, 1), kt('cn1', t, e, Rt, -i, 0, -1), kt('cn2', t, e, Rt, i, 0, -1), kt('cn3', t, e, Rt, 0, -r, -1), kt('cn4', t, e, Rt, 0, r, -1), (e.getAttribute('position').needsUpdate = !0); } dispose() { this.geometry.dispose(), this.material.dispose(); } }; function kt(e, t, i, r, s, n, a) { vc.set(s, n, a).unproject(r); let o = t[e]; if (o !== void 0) { let l = i.getAttribute('position'); for (let h = 0, u = o.length; h < u; h++) l.setXYZ(o[h], vc.x, vc.y, vc.z); } } var wd = class extends Dh { constructor(e, t = 16776960) { let i = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]), r = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1], s = new Ve(); s.setIndex(new Xe(i, 1)), s.setAttribute('position', new Ce(r, 3)), super(s, new Rn({ color: t, toneMapped: !1 })), (this.box = e), (this.type = 'Box3Helper'), this.geometry.computeBoundingSphere(); } updateMatrixWorld(e) { let t = this.box; t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(0.5), super.updateMatrixWorld(e)); } dispose() { this.geometry.dispose(), this.material.dispose(); } }, oL = class extends Dh { constructor(e = 1) { let t = [0, 0, 0, e, 0, 0, 0, 0, 0, 0, e, 0, 0, 0, 0, 0, 0, e], i = [1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1], r = new Ve(); r.setAttribute('position', new Ce(t, 3)), r.setAttribute('color', new Ce(i, 3)); let s = new Rn({ vertexColors: !0, toneMapped: !1 }); super(r, s), (this.type = 'AxesHelper'); } setColors(e, t, i) { let r = new Ge(), s = this.geometry.attributes.color.array; return ( r.set(e), r.toArray(s, 0), r.toArray(s, 3), r.set(t), r.toArray(s, 6), r.toArray(s, 9), r.set(i), r.toArray(s, 12), r.toArray(s, 15), (this.geometry.attributes.color.needsUpdate = !0), this ); } dispose() { this.geometry.dispose(), this.material.dispose(); } }; typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', { detail: { revision: Wo } })); typeof window < 'u' && (window.__THREE__ ? console.warn('WARNING: Multiple instances of Three.js being imported.') : (window.__THREE__ = Wo)); var xl = '.', Sg = Symbol('target'), jw = Symbol('unsubscribe'); function Yf(e) { return e instanceof Date || e instanceof Set || e instanceof Map || e instanceof WeakSet || e instanceof WeakMap || ArrayBuffer.isView(e); } function lL(e) { return (typeof e == 'object' ? e === null : typeof e != 'function') || e instanceof RegExp; } var as = Array.isArray; function Mg(e) { return typeof e == 'symbol'; } var hL = { after: (e, t) => (as(e) ? e.slice(t.length) : t === '' ? e : e.slice(t.length + 1)), concat: (e, t) => as(e) ? ((e = [...e]), t && e.push(t), e) : t && t.toString !== void 0 ? (e !== '' && (e += xl), Mg(t) ? e + t.toString() : e + t) : e, initial: (e) => { if (as(e)) return e.slice(0, -1); if (e === '') return e; let t = e.lastIndexOf(xl); return t === -1 ? '' : e.slice(0, t); }, last: (e) => { if (as(e)) return e[e.length - 1] || ''; if (e === '') return e; let t = e.lastIndexOf(xl); return t === -1 ? e : e.slice(t + 1); }, walk: (e, t) => { if (as(e)) for (let i of e) t(i); else if (e !== '') { let i = 0, r = e.indexOf(xl); if (r === -1) t(e); else for (; i < e.length; ) r === -1 && (r = e.length), t(e.slice(i, r)), (i = r + 1), (r = e.indexOf(xl, i)); } }, get(e, t) { return ( this.walk(t, (i) => { e && (e = e[i]); }), e ); } }, mr = hL; function cL(e) { return typeof e == 'object' && typeof e.next == 'function'; } function dL(e, t, i, r, s) { let n = e.next; if (t.name === 'entries') e.next = function () { let a = n.call(this); return a.done === !1 && ((a.value[0] = s(a.value[0], t, a.value[0], r)), (a.value[1] = s(a.value[1], t, a.value[0], r))), a; }; else if (t.name === 'values') { let a = i[Sg].keys(); e.next = function () { let o = n.call(this); return o.done === !1 && (o.value = s(o.value, t, a.next().value, r)), o; }; } else e.next = function () { let a = n.call(this); return a.done === !1 && (a.value = s(a.value, t, a.value, r)), a; }; return e; } function Oy(e, t, i) { return ( e.isUnsubscribed || (t.ignoreSymbols && Mg(i)) || (t.ignoreUnderscores && i.charAt(0) === '_') || ('ignoreKeys' in t && t.ignoreKeys.includes(i)) ); } var uL = class { constructor(e) { (this._equals = e), (this._proxyCache = new WeakMap()), (this._pathCache = new WeakMap()), (this.isUnsubscribed = !1); } _getDescriptorCache() { return this._descriptorCache === void 0 && (this._descriptorCache = new WeakMap()), this._descriptorCache; } _getProperties(e) { let t = this._getDescriptorCache(), i = t.get(e); return i === void 0 && ((i = {}), t.set(e, i)), i; } _getOwnPropertyDescriptor(e, t) { if (this.isUnsubscribed) return Reflect.getOwnPropertyDescriptor(e, t); let i = this._getProperties(e), r = i[t]; return r === void 0 && ((r = Reflect.getOwnPropertyDescriptor(e, t)), (i[t] = r)), r; } getProxy(e, t, i, r) { if (this.isUnsubscribed) return e; let s = e[r], n = s || e; this._pathCache.set(n, t); let a = this._proxyCache.get(n); return a === void 0 && ((a = s === void 0 ? new Proxy(e, i) : e), this._proxyCache.set(n, a)), a; } getPath(e) { return this.isUnsubscribed ? void 0 : this._pathCache.get(e); } isDetached(e, t) { return !Object.is(e, mr.get(t, this.getPath(e))); } defineProperty(e, t, i) { return Reflect.defineProperty(e, t, i) ? (this.isUnsubscribed || (this._getProperties(e)[t] = i), !0) : !1; } setProperty(e, t, i, r, s) { if (!this._equals(s, i) || !(t in e)) { let n = this._getOwnPropertyDescriptor(e, t); return n !== void 0 && 'set' in n ? Reflect.set(e, t, i, r) : Reflect.set(e, t, i); } return !0; } deleteProperty(e, t, i) { if (Reflect.deleteProperty(e, t)) { if (!this.isUnsubscribed) { let r = this._getDescriptorCache().get(e); r && (delete r[t], this._pathCache.delete(i)); } return !0; } return !1; } isSameDescriptor(e, t, i) { let r = this._getOwnPropertyDescriptor(t, i); return ( e !== void 0 && r !== void 0 && Object.is(e.value, r.value) && (e.writable || !1) === (r.writable || !1) && (e.enumerable || !1) === (r.enumerable || !1) && (e.configurable || !1) === (r.configurable || !1) && e.get === r.get && e.set === r.set ); } isGetInvariant(e, t) { let i = this._getOwnPropertyDescriptor(e, t); return i !== void 0 && i.configurable !== !0 && i.writable !== !0; } unsubscribe() { (this._descriptorCache = null), (this._pathCache = null), (this._proxyCache = null), (this.isUnsubscribed = !0); } }; function Qf(e) { return toString.call(e) === '[object Object]'; } function yc() { return !0; } function Ya(e, t) { return e.length !== t.length || e.some((i, r) => t[r] !== i); } var Gw = new Set(['hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']), pL = new Set(['concat', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf']), Vw = { push: yc, pop: yc, shift: yc, unshift: yc, copyWithin: Ya, reverse: Ya, sort: Ya, splice: Ya, flat: Ya, fill: Ya }, fL = new Set([...Gw, ...pL, ...Object.keys(Vw)]); function xc(e, t) { if (e.size !== t.size) return !0; for (let i of e) if (!t.has(i)) return !0; return !1; } var Hw = ['keys', 'values', 'entries'], Ww = new Set(['has', 'toString']), Xw = { add: xc, clear: xc, delete: xc, forEach: xc }, mL = new Set([...Ww, ...Object.keys(Xw), ...Hw]); function bc(e, t) { if (e.size !== t.size) return !0; let i; for (let [r, s] of e) if (((i = t.get(r)), i !== s || (i === void 0 && !t.has(r)))) return !0; return !1; } var gL = new Set([...Ww, 'get']), qw = { set: bc, clear: bc, delete: bc, forEach: bc }, vL = new Set([...gL, ...Object.keys(qw), ...Hw]), Dn = class { constructor(e, t, i, r) { (this._path = t), (this._isChanged = !1), (this._clonedCache = new Set()), (this._hasOnValidate = r), (this._changes = r ? [] : null), (this.clone = t === void 0 ? e : this._shallowClone(e)); } static isHandledMethod(e) { return Gw.has(e); } _shallowClone(e) { let t = e; if (Qf(e)) t = { ...e }; else if (as(e)) t = [...e]; else if (e instanceof Date) t = new Date(e); else if (e instanceof Set) t = new Set([...e].map((i) => this._shallowClone(i))); else if (e instanceof Map) { t = new Map(); for (let [i, r] of e.entries()) t.set(i, this._shallowClone(r)); } return this._clonedCache.add(t), t; } preferredThisArg(e, t, i, r) { return e ? (as(r) ? (this._onIsChanged = Vw[t]) : r instanceof Set ? (this._onIsChanged = Xw[t]) : r instanceof Map && (this._onIsChanged = qw[t]), r) : i; } update(e, t, i) { let r = mr.after(e, this._path); if (t !== 'length') { let s = this.clone; mr.walk(r, (n) => { s && s[n] && (this._clonedCache.has(s[n]) || (s[n] = this._shallowClone(s[n])), (s = s[n])); }), this._hasOnValidate && this._changes.push({ path: r, property: t, previous: i }), s && s[t] && (s[t] = i); } this._isChanged = !0; } undo(e) { let t; for (let i = this._changes.length - 1; i !== -1; i--) (t = this._changes[i]), (mr.get(e, t.path)[t.property] = t.previous); } isChanged(e) { return this._onIsChanged === void 0 ? this._isChanged : this._onIsChanged(this.clone, e); } }, Iy = class extends Dn { static isHandledMethod(e) { return fL.has(e); } }, yL = class extends Dn { undo(e) { e.setTime(this.clone.getTime()); } isChanged(e, t) { return !t(this.clone.valueOf(), e.valueOf()); } }, Ry = class extends Dn { static isHandledMethod(e) { return mL.has(e); } undo(e) { for (let t of this.clone) e.add(t); for (let t of e) this.clone.has(t) || e.delete(t); } }, By = class extends Dn { static isHandledMethod(e) { return vL.has(e); } undo(e) { for (let [t, i] of this.clone.entries()) e.set(t, i); for (let t of e.keys()) this.clone.has(t) || e.delete(t); } }, xL = class extends Dn { constructor(e, t, i, r) { super(void 0, t, i, r), (this._arg1 = i[0]), (this._weakValue = e.has(this._arg1)); } isChanged(e) { return this._weakValue !== e.has(this._arg1); } undo(e) { this._weakValue && !e.has(this._arg1) ? e.add(this._arg1) : e.delete(this._arg1); } }, bL = class extends Dn { constructor(e, t, i, r) { super(void 0, t, i, r), (this._weakKey = i[0]), (this._weakHas = e.has(this._weakKey)), (this._weakValue = e.get(this._weakKey)); } isChanged(e) { return this._weakValue !== e.get(this._weakKey); } undo(e) { let t = e.has(this._weakKey); this._weakHas && !t ? e.set(this._weakKey, this._weakValue) : !this._weakHas && t ? e.delete(this._weakKey) : this._weakValue !== e.get(this._weakKey) && e.set(this._weakKey, this._weakValue); } }, ao = class { constructor(e) { (this._stack = []), (this._hasOnValidate = e); } static isHandledType(e) { return Qf(e) || as(e) || Yf(e); } static isHandledMethod(e, t) { return Qf(e) ? Dn.isHandledMethod(t) : as(e) ? Iy.isHandledMethod(t) : e instanceof Set ? Ry.isHandledMethod(t) : e instanceof Map ? By.isHandledMethod(t) : Yf(e); } get isCloning() { return this._stack.length > 0; } start(e, t, i) { let r = Dn; as(e) ? (r = Iy) : e instanceof Date ? (r = yL) : e instanceof Set ? (r = Ry) : e instanceof Map ? (r = By) : e instanceof WeakSet ? (r = xL) : e instanceof WeakMap && (r = bL), this._stack.push(new r(e, t, i, this._hasOnValidate)); } update(e, t, i) { this._stack[this._stack.length - 1].update(e, t, i); } preferredThisArg(e, t, i) { let { name: r } = e, s = ao.isHandledMethod(i, r); return this._stack[this._stack.length - 1].preferredThisArg(s, r, t, i); } isChanged(e, t, i) { return this._stack[this._stack.length - 1].isChanged(e, t, i); } undo(e) { this._previousClone !== void 0 && this._previousClone.undo(e); } stop() { return (this._previousClone = this._stack.pop()), this._previousClone.clone; } }, wL = { equals: Object.is, isShallow: !1, pathAsArray: !1, ignoreSymbols: !1, ignoreUnderscores: !1, ignoreDetached: !1, details: !1 }, Eg = (e, t, i = {}) => { i = { ...wL, ...i }; let r = Symbol('ProxyTarget'), { equals: s, isShallow: n, ignoreDetached: a, details: o } = i, l = new uL(s), h = typeof i.onValidate == 'function', u = new ao(h), c = (y, b, x, w, A) => !h || u.isCloning || i.onValidate(mr.concat(l.getPath(y), b), x, w, A) === !0, d = (y, b, x, w) => { !Oy(l, i, b) && !(a && l.isDetached(y, e)) && p(l.getPath(y), b, x, w); }, p = (y, b, x, w, A) => { u.isCloning ? u.update(y, b, w) : t(mr.concat(y, b), x, w, A); }, f = (y) => y && (y[r] || y), g = (y, b, x, w) => lL(y) || x === 'constructor' || (n && !ao.isHandledMethod(b, x)) || Oy(l, i, x) || l.isGetInvariant(b, x) || (a && l.isDetached(b, e)) ? y : (w === void 0 && (w = l.getPath(b)), l.getProxy(y, mr.concat(w, x), m, r)), m = { get(y, b, x) { if (Mg(b)) { if (b === r || b === Sg) return y; if (b === jw && !l.isUnsubscribed && l.getPath(y).length === 0) return l.unsubscribe(), y; } let w = Yf(y) ? Reflect.get(y, b) : Reflect.get(y, b, x); return g(w, y, b); }, set(y, b, x, w) { x = f(x); let A = y[r] || y, S = A[b]; if (s(S, x) && b in y) return !0; let _ = c(y, b, x, S); return _ && l.setProperty(A, b, x, w, S) ? (d(y, b, y[b], S), !0) : !_; }, defineProperty(y, b, x) { if (!l.isSameDescriptor(x, y, b)) { let w = y[b]; c(y, b, x.value, w) && l.defineProperty(y, b, x, w) && d(y, b, x.value, w); } return !0; }, deleteProperty(y, b) { if (!Reflect.has(y, b)) return !0; let x = Reflect.get(y, b), w = c(y, b, void 0, x); return w && l.deleteProperty(y, b, x) ? (d(y, b, void 0, x), !0) : !w; }, apply(y, b, x) { let w = b[r] || b; if (l.isUnsubscribed) return Reflect.apply(y, w, x); if ((o === !1 || (o !== !0 && !o.includes(y.name))) && ao.isHandledType(w)) { let A = mr.initial(l.getPath(y)), S = ao.isHandledMethod(w, y.name); u.start(w, A, x); let _ = Reflect.apply(y, u.preferredThisArg(y, b, w), S ? x.map((T) => f(T)) : x), M = u.isChanged(w, s), C = u.stop(); if ( (ao.isHandledType(_) && S && (b instanceof Map && y.name === 'get' && (A = mr.concat(A, x[0])), (_ = l.getProxy(_, A, m))), M) ) { let T = { name: y.name, args: x, result: _ }, P = u.isCloning ? mr.initial(A) : A, L = u.isCloning ? mr.last(A) : ''; c(mr.get(e, P), L, w, C, T) ? p(P, L, w, C, T) : u.undo(w); } return (b instanceof Map || b instanceof Set) && cL(_) ? dL(_, y, b, A, g) : _; } return Reflect.apply(y, b, x); } }, v = l.getProxy(e, i.pathAsArray ? [] : '', m); return (t = t.bind(v)), h && (i.onValidate = i.onValidate.bind(v)), v; }; Eg.target = (e) => (e && e[Sg]) || e; Eg.unsubscribe = (e) => e[jw] || e; var zy = Eg, _L = typeof global == 'object' && global && global.Object === Object && global, Yw = _L, AL = typeof self == 'object' && self && self.Object === Object && self, SL = Yw || AL || Function('return this')(), Hr = SL, ML = Hr.Symbol, Er = ML, Qw = Object.prototype, EL = Qw.hasOwnProperty, CL = Qw.toString, bl = Er ? Er.toStringTag : void 0; function TL(e) { var t = EL.call(e, bl), i = e[bl]; try { e[bl] = void 0; var r = !0; } catch {} var s = CL.call(e); return r && (t ? (e[bl] = i) : delete e[bl]), s; } var PL = TL, DL = Object.prototype, LL = DL.toString; function OL(e) { return LL.call(e); } var IL = OL, RL = '[object Null]', BL = '[object Undefined]', Ny = Er ? Er.toStringTag : void 0; function zL(e) { return e == null ? (e === void 0 ? BL : RL) : Ny && Ny in Object(e) ? PL(e) : IL(e); } var Ma = zL; function NL(e) { return e != null && typeof e == 'object'; } var Ws = NL, UL = '[object Symbol]'; function FL(e) { return typeof e == 'symbol' || (Ws(e) && Ma(e) == UL); } var uu = FL; function kL(e, t) { for (var i = -1, r = e == null ? 0 : e.length, s = Array(r); ++i < r; ) s[i] = t(e[i], i, e); return s; } var Zw = kL, jL = Array.isArray, ys = jL, GL = 1 / 0, Uy = Er ? Er.prototype : void 0, Fy = Uy ? Uy.toString : void 0; function Kw(e) { if (typeof e == 'string') return e; if (ys(e)) return Zw(e, Kw) + ''; if (uu(e)) return Fy ? Fy.call(e) : ''; var t = e + ''; return t == '0' && 1 / e == -GL ? '-0' : t; } var VL = Kw, HL = /\s/; function WL(e) { for (var t = e.length; t-- && HL.test(e.charAt(t)); ); return t; } var XL = WL, qL = /^\s+/; function YL(e) { return e && e.slice(0, XL(e) + 1).replace(qL, ''); } var QL = YL; function ZL(e) { var t = typeof e; return e != null && (t == 'object' || t == 'function'); } var xs = ZL, ky = 0 / 0, KL = /^[-+]0x[0-9a-f]+$/i, JL = /^0b[01]+$/i, $L = /^0o[0-7]+$/i, eO = parseInt; function tO(e) { if (typeof e == 'number') return e; if (uu(e)) return ky; if (xs(e)) { var t = typeof e.valueOf == 'function' ? e.valueOf() : e; e = xs(t) ? t + '' : t; } if (typeof e != 'string') return e === 0 ? e : +e; e = QL(e); var i = JL.test(e); return i || $L.test(e) ? eO(e.slice(2), i ? 2 : 8) : KL.test(e) ? ky : +e; } var jy = tO; function iO(e) { return e; } var rO = iO, sO = '[object AsyncFunction]', nO = '[object Function]', aO = '[object GeneratorFunction]', oO = '[object Proxy]'; function lO(e) { if (!xs(e)) return !1; var t = Ma(e); return t == nO || t == aO || t == sO || t == oO; } var Jw = lO, hO = Hr['__core-js_shared__'], Pp = hO, Gy = (function () { var e = /[^.]+$/.exec((Pp && Pp.keys && Pp.keys.IE_PROTO) || ''); return e ? 'Symbol(src)_1.' + e : ''; })(); function cO(e) { return !!Gy && Gy in e; } var dO = cO, uO = Function.prototype, pO = uO.toString; function fO(e) { if (e != null) { try { return pO.call(e); } catch {} try { return e + ''; } catch {} } return ''; } var Ea = fO, mO = /[\\^$.*+?()[\]{}|]/g, gO = /^\[object .+?Constructor\]$/, vO = Function.prototype, yO = Object.prototype, xO = vO.toString, bO = yO.hasOwnProperty, wO = RegExp( '^' + xO .call(bO) .replace(mO, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); function _O(e) { if (!xs(e) || dO(e)) return !1; var t = Jw(e) ? wO : gO; return t.test(Ea(e)); } var AO = _O; function SO(e, t) { return e?.[t]; } var MO = SO; function EO(e, t) { var i = MO(e, t); return AO(i) ? i : void 0; } var Ca = EO, CO = Ca(Hr, 'WeakMap'), Zf = CO, Vy = Object.create, TO = (function () { function e() {} return function (t) { if (!xs(t)) return {}; if (Vy) return Vy(t); e.prototype = t; var i = new e(); return (e.prototype = void 0), i; }; })(), PO = TO; function DO(e, t, i) { switch (i.length) { case 0: return e.call(t); case 1: return e.call(t, i[0]); case 2: return e.call(t, i[0], i[1]); case 3: return e.call(t, i[0], i[1], i[2]); } return e.apply(t, i); } var LO = DO; function OO(e, t) { var i = -1, r = e.length; for (t || (t = Array(r)); ++i < r; ) t[i] = e[i]; return t; } var IO = OO, RO = 800, BO = 16, zO = Date.now; function NO(e) { var t = 0, i = 0; return function () { var r = zO(), s = BO - (r - i); if (((i = r), s > 0)) { if (++t >= RO) return arguments[0]; } else t = 0; return e.apply(void 0, arguments); }; } var UO = NO; function FO(e) { return function () { return e; }; } var kO = FO, jO = (function () { try { var e = Ca(Object, 'defineProperty'); return e({}, '', {}), e; } catch {} })(), _d = jO, GO = _d ? function (e, t) { return _d(e, 'toString', { configurable: !0, enumerable: !1, value: kO(t), writable: !0 }); } : rO, VO = GO, HO = UO(VO), WO = HO; function XO(e, t) { for (var i = -1, r = e == null ? 0 : e.length; ++i < r && t(e[i], i, e) !== !1; ); return e; } var qO = XO, YO = 9007199254740991, QO = /^(?:0|[1-9]\d*)$/; function ZO(e, t) { var i = typeof e; return (t = t ?? YO), !!t && (i == 'number' || (i != 'symbol' && QO.test(e))) && e > -1 && e % 1 == 0 && e < t; } var Cg = ZO; function KO(e, t, i) { t == '__proto__' && _d ? _d(e, t, { configurable: !0, enumerable: !0, value: i, writable: !0 }) : (e[t] = i); } var $w = KO; function JO(e, t) { return e === t || (e !== e && t !== t); } var Tg = JO, $O = Object.prototype, eI = $O.hasOwnProperty; function tI(e, t, i) { var r = e[t]; (!(eI.call(e, t) && Tg(r, i)) || (i === void 0 && !(t in e))) && $w(e, t, i); } var Pg = tI; function iI(e, t, i, r) { var s = !i; i || (i = {}); for (var n = -1, a = t.length; ++n < a; ) { var o = t[n], l = r ? r(i[o], e[o], o, i, e) : void 0; l === void 0 && (l = e[o]), s ? $w(i, o, l) : Pg(i, o, l); } return i; } var Rh = iI, Hy = Math.max; function rI(e, t, i) { return ( (t = Hy(t === void 0 ? e.length - 1 : t, 0)), function () { for (var r = arguments, s = -1, n = Hy(r.length - t, 0), a = Array(n); ++s < n; ) a[s] = r[t + s]; s = -1; for (var o = Array(t + 1); ++s < t; ) o[s] = r[s]; return (o[t] = i(a)), LO(e, this, o); } ); } var sI = rI, nI = 9007199254740991; function aI(e) { return typeof e == 'number' && e > -1 && e % 1 == 0 && e <= nI; } var Dg = aI; function oI(e) { return e != null && Dg(e.length) && !Jw(e); } var e_ = oI, lI = Object.prototype; function hI(e) { var t = e && e.constructor, i = (typeof t == 'function' && t.prototype) || lI; return e === i; } var Lg = hI; function cI(e, t) { for (var i = -1, r = Array(e); ++i < e; ) r[i] = t(i); return r; } var dI = cI, uI = '[object Arguments]'; function pI(e) { return Ws(e) && Ma(e) == uI; } var Wy = pI, t_ = Object.prototype, fI = t_.hasOwnProperty, mI = t_.propertyIsEnumerable, gI = Wy( (function () { return arguments; })() ) ? Wy : function (e) { return Ws(e) && fI.call(e, 'callee') && !mI.call(e, 'callee'); }, Og = gI; function vI() { return !1; } var yI = vI, i_ = typeof exports == 'object' && exports && !exports.nodeType && exports, Xy = i_ && typeof module == 'object' && module && !module.nodeType && module, xI = Xy && Xy.exports === i_, qy = xI ? Hr.Buffer : void 0, bI = qy ? qy.isBuffer : void 0, wI = bI || yI, Ad = wI, _I = '[object Arguments]', AI = '[object Array]', SI = '[object Boolean]', MI = '[object Date]', EI = '[object Error]', CI = '[object Function]', TI = '[object Map]', PI = '[object Number]', DI = '[object Object]', LI = '[object RegExp]', OI = '[object Set]', II = '[object String]', RI = '[object WeakMap]', BI = '[object ArrayBuffer]', zI = '[object DataView]', NI = '[object Float32Array]', UI = '[object Float64Array]', FI = '[object Int8Array]', kI = '[object Int16Array]', jI = '[object Int32Array]', GI = '[object Uint8Array]', VI = '[object Uint8ClampedArray]', HI = '[object Uint16Array]', WI = '[object Uint32Array]', Tt = {}; Tt[NI] = Tt[UI] = Tt[FI] = Tt[kI] = Tt[jI] = Tt[GI] = Tt[VI] = Tt[HI] = Tt[WI] = !0; Tt[_I] = Tt[AI] = Tt[BI] = Tt[SI] = Tt[zI] = Tt[MI] = Tt[EI] = Tt[CI] = Tt[TI] = Tt[PI] = Tt[DI] = Tt[LI] = Tt[OI] = Tt[II] = Tt[RI] = !1; function XI(e) { return Ws(e) && Dg(e.length) && !!Tt[Ma(e)]; } var qI = XI; function YI(e) { return function (t) { return e(t); }; } var Ig = YI, r_ = typeof exports == 'object' && exports && !exports.nodeType && exports, eh = r_ && typeof module == 'object' && module && !module.nodeType && module, QI = eh && eh.exports === r_, Dp = QI && Yw.process, ZI = (function () { try { var e = eh && eh.require && eh.require('util').types; return e || (Dp && Dp.binding && Dp.binding('util')); } catch {} })(), No = ZI, Yy = No && No.isTypedArray, KI = Yy ? Ig(Yy) : qI, s_ = KI, JI = Object.prototype, $I = JI.hasOwnProperty; function e4(e, t) { var i = ys(e), r = !i && Og(e), s = !i && !r && Ad(e), n = !i && !r && !s && s_(e), a = i || r || s || n, o = a ? dI(e.length, String) : [], l = o.length; for (var h in e) (t || $I.call(e, h)) && !( a && (h == 'length' || (s && (h == 'offset' || h == 'parent')) || (n && (h == 'buffer' || h == 'byteLength' || h == 'byteOffset')) || Cg(h, l)) ) && o.push(h); return o; } var n_ = e4; function t4(e, t) { return function (i) { return e(t(i)); }; } var a_ = t4, i4 = a_(Object.keys, Object), r4 = i4, s4 = Object.prototype, n4 = s4.hasOwnProperty; function a4(e) { if (!Lg(e)) return r4(e); var t = []; for (var i in Object(e)) n4.call(e, i) && i != 'constructor' && t.push(i); return t; } var o4 = a4; function l4(e) { return e_(e) ? n_(e) : o4(e); } var Rg = l4; function h4(e) { var t = []; if (e != null) for (var i in Object(e)) t.push(i); return t; } var c4 = h4, d4 = Object.prototype, u4 = d4.hasOwnProperty; function p4(e) { if (!xs(e)) return c4(e); var t = Lg(e), i = []; for (var r in e) (r == 'constructor' && (t || !u4.call(e, r))) || i.push(r); return i; } var f4 = p4; function m4(e) { return e_(e) ? n_(e, !0) : f4(e); } var Bg = m4, g4 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, v4 = /^\w*$/; function y4(e, t) { if (ys(e)) return !1; var i = typeof e; return i == 'number' || i == 'symbol' || i == 'boolean' || e == null || uu(e) ? !0 : v4.test(e) || !g4.test(e) || (t != null && e in Object(t)); } var x4 = y4, b4 = Ca(Object, 'create'), ph = b4; function w4() { (this.__data__ = ph ? ph(null) : {}), (this.size = 0); } var _4 = w4; function A4(e) { var t = this.has(e) && delete this.__data__[e]; return (this.size -= t ? 1 : 0), t; } var S4 = A4, M4 = '__lodash_hash_undefined__', E4 = Object.prototype, C4 = E4.hasOwnProperty; function T4(e) { var t = this.__data__; if (ph) { var i = t[e]; return i === M4 ? void 0 : i; } return C4.call(t, e) ? t[e] : void 0; } var P4 = T4, D4 = Object.prototype, L4 = D4.hasOwnProperty; function O4(e) { var t = this.__data__; return ph ? t[e] !== void 0 : L4.call(t, e); } var I4 = O4, R4 = '__lodash_hash_undefined__'; function B4(e, t) { var i = this.__data__; return (this.size += this.has(e) ? 0 : 1), (i[e] = ph && t === void 0 ? R4 : t), this; } var z4 = B4; function Zo(e) { var t = -1, i = e == null ? 0 : e.length; for (this.clear(); ++t < i; ) { var r = e[t]; this.set(r[0], r[1]); } } Zo.prototype.clear = _4; Zo.prototype.delete = S4; Zo.prototype.get = P4; Zo.prototype.has = I4; Zo.prototype.set = z4; var Qy = Zo; function N4() { (this.__data__ = []), (this.size = 0); } var U4 = N4; function F4(e, t) { for (var i = e.length; i--; ) if (Tg(e[i][0], t)) return i; return -1; } var pu = F4, k4 = Array.prototype, j4 = k4.splice; function G4(e) { var t = this.__data__, i = pu(t, e); if (i < 0) return !1; var r = t.length - 1; return i == r ? t.pop() : j4.call(t, i, 1), --this.size, !0; } var V4 = G4; function H4(e) { var t = this.__data__, i = pu(t, e); return i < 0 ? void 0 : t[i][1]; } var W4 = H4; function X4(e) { return pu(this.__data__, e) > -1; } var q4 = X4; function Y4(e, t) { var i = this.__data__, r = pu(i, e); return r < 0 ? (++this.size, i.push([e, t])) : (i[r][1] = t), this; } var Q4 = Y4; function Ko(e) { var t = -1, i = e == null ? 0 : e.length; for (this.clear(); ++t < i; ) { var r = e[t]; this.set(r[0], r[1]); } } Ko.prototype.clear = U4; Ko.prototype.delete = V4; Ko.prototype.get = W4; Ko.prototype.has = q4; Ko.prototype.set = Q4; var fu = Ko, Z4 = Ca(Hr, 'Map'), fh = Z4; function K4() { (this.size = 0), (this.__data__ = { hash: new Qy(), map: new (fh || fu)(), string: new Qy() }); } var J4 = K4; function $4(e) { var t = typeof e; return t == 'string' || t == 'number' || t == 'symbol' || t == 'boolean' ? e !== '__proto__' : e === null; } var eR = $4; function tR(e, t) { var i = e.__data__; return eR(t) ? i[typeof t == 'string' ? 'string' : 'hash'] : i.map; } var mu = tR; function iR(e) { var t = mu(this, e).delete(e); return (this.size -= t ? 1 : 0), t; } var rR = iR; function sR(e) { return mu(this, e).get(e); } var nR = sR; function aR(e) { return mu(this, e).has(e); } var oR = aR; function lR(e, t) { var i = mu(this, e), r = i.size; return i.set(e, t), (this.size += i.size == r ? 0 : 1), this; } var hR = lR; function Jo(e) { var t = -1, i = e == null ? 0 : e.length; for (this.clear(); ++t < i; ) { var r = e[t]; this.set(r[0], r[1]); } } Jo.prototype.clear = J4; Jo.prototype.delete = rR; Jo.prototype.get = nR; Jo.prototype.has = oR; Jo.prototype.set = hR; var gu = Jo, cR = 'Expected a function'; function zg(e, t) { if (typeof e != 'function' || (t != null && typeof t != 'function')) throw new TypeError(cR); var i = function () { var r = arguments, s = t ? t.apply(this, r) : r[0], n = i.cache; if (n.has(s)) return n.get(s); var a = e.apply(this, r); return (i.cache = n.set(s, a) || n), a; }; return (i.cache = new (zg.Cache || gu)()), i; } zg.Cache = gu; var dR = zg, uR = 500; function pR(e) { var t = dR(e, function (r) { return i.size === uR && i.clear(), r; }), i = t.cache; return t; } var fR = pR, mR = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, gR = /\\(\\)?/g, vR = fR(function (e) { var t = []; return ( e.charCodeAt(0) === 46 && t.push(''), e.replace(mR, function (i, r, s, n) { t.push(s ? n.replace(gR, '$1') : r || i); }), t ); }), yR = vR; function xR(e) { return e == null ? '' : VL(e); } var bR = xR; function wR(e, t) { return ys(e) ? e : x4(e, t) ? [e] : yR(bR(e)); } var $o = wR, _R = 1 / 0; function AR(e) { if (typeof e == 'string' || uu(e)) return e; var t = e + ''; return t == '0' && 1 / e == -_R ? '-0' : t; } var vu = AR; function SR(e, t) { t = $o(t, e); for (var i = 0, r = t.length; e != null && i < r; ) e = e[vu(t[i++])]; return i && i == r ? e : void 0; } var o_ = SR; function MR(e, t) { for (var i = -1, r = t.length, s = e.length; ++i < r; ) e[s + i] = t[i]; return e; } var Ng = MR, Zy = Er ? Er.isConcatSpreadable : void 0; function ER(e) { return ys(e) || Og(e) || !!(Zy && e && e[Zy]); } var CR = ER; function l_(e, t, i, r, s) { var n = -1, a = e.length; for (i || (i = CR), s || (s = []); ++n < a; ) { var o = e[n]; t > 0 && i(o) ? (t > 1 ? l_(o, t - 1, i, r, s) : Ng(s, o)) : r || (s[s.length] = o); } return s; } var TR = l_; function PR(e) { var t = e == null ? 0 : e.length; return t ? TR(e, 1) : []; } var DR = PR; function LR(e) { return WO(sI(e, void 0, DR), e + ''); } var h_ = LR, OR = a_(Object.getPrototypeOf, Object), Ug = OR, IR = '[object Object]', RR = Function.prototype, BR = Object.prototype, c_ = RR.toString, zR = BR.hasOwnProperty, NR = c_.call(Object); function UR(e) { if (!Ws(e) || Ma(e) != IR) return !1; var t = Ug(e); if (t === null) return !0; var i = zR.call(t, 'constructor') && t.constructor; return typeof i == 'function' && i instanceof i && c_.call(i) == NR; } var FR = UR; function kR(e, t, i) { var r = -1, s = e.length; t < 0 && (t = -t > s ? 0 : s + t), (i = i > s ? s : i), i < 0 && (i += s), (s = t > i ? 0 : (i - t) >>> 0), (t >>>= 0); for (var n = Array(s); ++r < s; ) n[r] = e[r + t]; return n; } var jR = kR; function GR() { (this.__data__ = new fu()), (this.size = 0); } var VR = GR; function HR(e) { var t = this.__data__, i = t.delete(e); return (this.size = t.size), i; } var WR = HR; function XR(e) { return this.__data__.get(e); } var qR = XR; function YR(e) { return this.__data__.has(e); } var QR = YR, ZR = 200; function KR(e, t) { var i = this.__data__; if (i instanceof fu) { var r = i.__data__; if (!fh || r.length < ZR - 1) return r.push([e, t]), (this.size = ++i.size), this; i = this.__data__ = new gu(r); } return i.set(e, t), (this.size = i.size), this; } var JR = KR; function el(e) { var t = (this.__data__ = new fu(e)); this.size = t.size; } el.prototype.clear = VR; el.prototype.delete = WR; el.prototype.get = qR; el.prototype.has = QR; el.prototype.set = JR; var ed = el; function $R(e, t) { return e && Rh(t, Rg(t), e); } var eB = $R; function tB(e, t) { return e && Rh(t, Bg(t), e); } var iB = tB, d_ = typeof exports == 'object' && exports && !exports.nodeType && exports, Ky = d_ && typeof module == 'object' && module && !module.nodeType && module, rB = Ky && Ky.exports === d_, Jy = rB ? Hr.Buffer : void 0, $y = Jy ? Jy.allocUnsafe : void 0; function sB(e, t) { if (t) return e.slice(); var i = e.length, r = $y ? $y(i) : new e.constructor(i); return e.copy(r), r; } var nB = sB; function aB(e, t) { for (var i = -1, r = e == null ? 0 : e.length, s = 0, n = []; ++i < r; ) { var a = e[i]; t(a, i, e) && (n[s++] = a); } return n; } var oB = aB; function lB() { return []; } var u_ = lB, hB = Object.prototype, cB = hB.propertyIsEnumerable, e1 = Object.getOwnPropertySymbols, dB = e1 ? function (e) { return e == null ? [] : ((e = Object(e)), oB(e1(e), function (t) { return cB.call(e, t); })); } : u_, Fg = dB; function uB(e, t) { return Rh(e, Fg(e), t); } var pB = uB, fB = Object.getOwnPropertySymbols, mB = fB ? function (e) { for (var t = []; e; ) Ng(t, Fg(e)), (e = Ug(e)); return t; } : u_, p_ = mB; function gB(e, t) { return Rh(e, p_(e), t); } var vB = gB; function yB(e, t, i) { var r = t(e); return ys(e) ? r : Ng(r, i(e)); } var f_ = yB; function xB(e) { return f_(e, Rg, Fg); } var Kf = xB; function bB(e) { return f_(e, Bg, p_); } var m_ = bB, wB = Ca(Hr, 'DataView'), Jf = wB, _B = Ca(Hr, 'Promise'), $f = _B, AB = Ca(Hr, 'Set'), em = AB, t1 = '[object Map]', SB = '[object Object]', i1 = '[object Promise]', r1 = '[object Set]', s1 = '[object WeakMap]', n1 = '[object DataView]', MB = Ea(Jf), EB = Ea(fh), CB = Ea($f), TB = Ea(em), PB = Ea(Zf), $n = Ma; ((Jf && $n(new Jf(new ArrayBuffer(1))) != n1) || (fh && $n(new fh()) != t1) || ($f && $n($f.resolve()) != i1) || (em && $n(new em()) != r1) || (Zf && $n(new Zf()) != s1)) && ($n = function (e) { var t = Ma(e), i = t == SB ? e.constructor : void 0, r = i ? Ea(i) : ''; if (r) switch (r) { case MB: return n1; case EB: return t1; case CB: return i1; case TB: return r1; case PB: return s1; } return t; }); var mh = $n, DB = Object.prototype, LB = DB.hasOwnProperty; function OB(e) { var t = e.length, i = new e.constructor(t); return t && typeof e[0] == 'string' && LB.call(e, 'index') && ((i.index = e.index), (i.input = e.input)), i; } var IB = OB, RB = Hr.Uint8Array, Sd = RB; function BB(e) { var t = new e.constructor(e.byteLength); return new Sd(t).set(new Sd(e)), t; } var kg = BB; function zB(e, t) { var i = t ? kg(e.buffer) : e.buffer; return new e.constructor(i, e.byteOffset, e.byteLength); } var NB = zB, UB = /\w*$/; function FB(e) { var t = new e.constructor(e.source, UB.exec(e)); return (t.lastIndex = e.lastIndex), t; } var kB = FB, a1 = Er ? Er.prototype : void 0, o1 = a1 ? a1.valueOf : void 0; function jB(e) { return o1 ? Object(o1.call(e)) : {}; } var GB = jB; function VB(e, t) { var i = t ? kg(e.buffer) : e.buffer; return new e.constructor(i, e.byteOffset, e.length); } var HB = VB, WB = '[object Boolean]', XB = '[object Date]', qB = '[object Map]', YB = '[object Number]', QB = '[object RegExp]', ZB = '[object Set]', KB = '[object String]', JB = '[object Symbol]', $B = '[object ArrayBuffer]', e5 = '[object DataView]', t5 = '[object Float32Array]', i5 = '[object Float64Array]', r5 = '[object Int8Array]', s5 = '[object Int16Array]', n5 = '[object Int32Array]', a5 = '[object Uint8Array]', o5 = '[object Uint8ClampedArray]', l5 = '[object Uint16Array]', h5 = '[object Uint32Array]'; function c5(e, t, i) { var r = e.constructor; switch (t) { case $B: return kg(e); case WB: case XB: return new r(+e); case e5: return NB(e, i); case t5: case i5: case r5: case s5: case n5: case a5: case o5: case l5: case h5: return HB(e, i); case qB: return new r(); case YB: case KB: return new r(e); case QB: return kB(e); case ZB: return new r(); case JB: return GB(e); } } var d5 = c5; function u5(e) { return typeof e.constructor == 'function' && !Lg(e) ? PO(Ug(e)) : {}; } var p5 = u5, f5 = '[object Map]'; function m5(e) { return Ws(e) && mh(e) == f5; } var g5 = m5, l1 = No && No.isMap, v5 = l1 ? Ig(l1) : g5, y5 = v5, x5 = '[object Set]'; function b5(e) { return Ws(e) && mh(e) == x5; } var w5 = b5, h1 = No && No.isSet, _5 = h1 ? Ig(h1) : w5, A5 = _5, S5 = 1, M5 = 2, E5 = 4, g_ = '[object Arguments]', C5 = '[object Array]', T5 = '[object Boolean]', P5 = '[object Date]', D5 = '[object Error]', v_ = '[object Function]', L5 = '[object GeneratorFunction]', O5 = '[object Map]', I5 = '[object Number]', y_ = '[object Object]', R5 = '[object RegExp]', B5 = '[object Set]', z5 = '[object String]', N5 = '[object Symbol]', U5 = '[object WeakMap]', F5 = '[object ArrayBuffer]', k5 = '[object DataView]', j5 = '[object Float32Array]', G5 = '[object Float64Array]', V5 = '[object Int8Array]', H5 = '[object Int16Array]', W5 = '[object Int32Array]', X5 = '[object Uint8Array]', q5 = '[object Uint8ClampedArray]', Y5 = '[object Uint16Array]', Q5 = '[object Uint32Array]', Et = {}; Et[g_] = Et[C5] = Et[F5] = Et[k5] = Et[T5] = Et[P5] = Et[j5] = Et[G5] = Et[V5] = Et[H5] = Et[W5] = Et[O5] = Et[I5] = Et[y_] = Et[R5] = Et[B5] = Et[z5] = Et[N5] = Et[X5] = Et[q5] = Et[Y5] = Et[Q5] = !0; Et[D5] = Et[v_] = Et[U5] = !1; function td(e, t, i, r, s, n) { var a, o = t & S5, l = t & M5, h = t & E5; if ((i && (a = s ? i(e, r, s, n) : i(e)), a !== void 0)) return a; if (!xs(e)) return e; var u = ys(e); if (u) { if (((a = IB(e)), !o)) return IO(e, a); } else { var c = mh(e), d = c == v_ || c == L5; if (Ad(e)) return nB(e, o); if (c == y_ || c == g_ || (d && !s)) { if (((a = l || d ? {} : p5(e)), !o)) return l ? vB(e, iB(a, e)) : pB(e, eB(a, e)); } else { if (!Et[c]) return s ? e : {}; a = d5(e, c, o); } } n || (n = new ed()); var p = n.get(e); if (p) return p; n.set(e, a), A5(e) ? e.forEach(function (m) { a.add(td(m, t, i, m, e, n)); }) : y5(e) && e.forEach(function (m, v) { a.set(v, td(m, t, i, v, e, n)); }); var f = h ? (l ? m_ : Kf) : l ? Bg : Rg, g = u ? void 0 : f(e); return ( qO(g || e, function (m, v) { g && ((v = m), (m = e[v])), Pg(a, v, td(m, t, i, v, e, n)); }), a ); } var x_ = td, Z5 = 1, K5 = 4; function J5(e) { return x_(e, Z5 | K5); } var yu = J5, $5 = '__lodash_hash_undefined__'; function ez(e) { return this.__data__.set(e, $5), this; } var tz = ez; function iz(e) { return this.__data__.has(e); } var rz = iz; function Md(e) { var t = -1, i = e == null ? 0 : e.length; for (this.__data__ = new gu(); ++t < i; ) this.add(e[t]); } Md.prototype.add = Md.prototype.push = tz; Md.prototype.has = rz; var sz = Md; function nz(e, t) { for (var i = -1, r = e == null ? 0 : e.length; ++i < r; ) if (t(e[i], i, e)) return !0; return !1; } var az = nz; function oz(e, t) { return e.has(t); } var lz = oz, hz = 1, cz = 2; function dz(e, t, i, r, s, n) { var a = i & hz, o = e.length, l = t.length; if (o != l && !(a && l > o)) return !1; var h = n.get(e), u = n.get(t); if (h && u) return h == t && u == e; var c = -1, d = !0, p = i & cz ? new sz() : void 0; for (n.set(e, t), n.set(t, e); ++c < o; ) { var f = e[c], g = t[c]; if (r) var m = a ? r(g, f, c, t, e, n) : r(f, g, c, e, t, n); if (m !== void 0) { if (m) continue; d = !1; break; } if (p) { if ( !az(t, function (v, y) { if (!lz(p, y) && (f === v || s(f, v, i, r, n))) return p.push(y); }) ) { d = !1; break; } } else if (!(f === g || s(f, g, i, r, n))) { d = !1; break; } } return n.delete(e), n.delete(t), d; } var b_ = dz; function uz(e) { var t = -1, i = Array(e.size); return ( e.forEach(function (r, s) { i[++t] = [s, r]; }), i ); } var pz = uz; function fz(e) { var t = -1, i = Array(e.size); return ( e.forEach(function (r) { i[++t] = r; }), i ); } var mz = fz, gz = 1, vz = 2, yz = '[object Boolean]', xz = '[object Date]', bz = '[object Error]', wz = '[object Map]', _z = '[object Number]', Az = '[object RegExp]', Sz = '[object Set]', Mz = '[object String]', Ez = '[object Symbol]', Cz = '[object ArrayBuffer]', Tz = '[object DataView]', c1 = Er ? Er.prototype : void 0, Lp = c1 ? c1.valueOf : void 0; function Pz(e, t, i, r, s, n, a) { switch (i) { case Tz: if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset) return !1; (e = e.buffer), (t = t.buffer); case Cz: return !(e.byteLength != t.byteLength || !n(new Sd(e), new Sd(t))); case yz: case xz: case _z: return Tg(+e, +t); case bz: return e.name == t.name && e.message == t.message; case Az: case Mz: return e == t + ''; case wz: var o = pz; case Sz: var l = r & gz; if ((o || (o = mz), e.size != t.size && !l)) return !1; var h = a.get(e); if (h) return h == t; (r |= vz), a.set(e, t); var u = b_(o(e), o(t), r, s, n, a); return a.delete(e), u; case Ez: if (Lp) return Lp.call(e) == Lp.call(t); } return !1; } var Dz = Pz, Lz = 1, Oz = Object.prototype, Iz = Oz.hasOwnProperty; function Rz(e, t, i, r, s, n) { var a = i & Lz, o = Kf(e), l = o.length, h = Kf(t), u = h.length; if (l != u && !a) return !1; for (var c = l; c--; ) { var d = o[c]; if (!(a ? d in t : Iz.call(t, d))) return !1; } var p = n.get(e), f = n.get(t); if (p && f) return p == t && f == e; var g = !0; n.set(e, t), n.set(t, e); for (var m = a; ++c < l; ) { d = o[c]; var v = e[d], y = t[d]; if (r) var b = a ? r(y, v, d, t, e, n) : r(v, y, d, e, t, n); if (!(b === void 0 ? v === y || s(v, y, i, r, n) : b)) { g = !1; break; } m || (m = d == 'constructor'); } if (g && !m) { var x = e.constructor, w = t.constructor; x != w && 'constructor' in e && 'constructor' in t && !(typeof x == 'function' && x instanceof x && typeof w == 'function' && w instanceof w) && (g = !1); } return n.delete(e), n.delete(t), g; } var Bz = Rz, zz = 1, d1 = '[object Arguments]', u1 = '[object Array]', wc = '[object Object]', Nz = Object.prototype, p1 = Nz.hasOwnProperty; function Uz(e, t, i, r, s, n) { var a = ys(e), o = ys(t), l = a ? u1 : mh(e), h = o ? u1 : mh(t); (l = l == d1 ? wc : l), (h = h == d1 ? wc : h); var u = l == wc, c = h == wc, d = l == h; if (d && Ad(e)) { if (!Ad(t)) return !1; (a = !0), (u = !1); } if (d && !u) return n || (n = new ed()), a || s_(e) ? b_(e, t, i, r, s, n) : Dz(e, t, l, i, r, s, n); if (!(i & zz)) { var p = u && p1.call(e, '__wrapped__'), f = c && p1.call(t, '__wrapped__'); if (p || f) { var g = p ? e.value() : e, m = f ? t.value() : t; return n || (n = new ed()), s(g, m, i, r, n); } } return d ? (n || (n = new ed()), Bz(e, t, i, r, s, n)) : !1; } var Fz = Uz; function w_(e, t, i, r, s) { return e === t ? !0 : e == null || t == null || (!Ws(e) && !Ws(t)) ? e !== e && t !== t : Fz(e, t, i, r, w_, s); } var kz = w_; function jz(e, t) { return e != null && t in Object(e); } var Gz = jz; function Vz(e, t, i) { t = $o(t, e); for (var r = -1, s = t.length, n = !1; ++r < s; ) { var a = vu(t[r]); if (!(n = e != null && i(e, a))) break; e = e[a]; } return n || ++r != s ? n : ((s = e == null ? 0 : e.length), !!s && Dg(s) && Cg(a, s) && (ys(e) || Og(e))); } var Hz = Vz; function Wz(e, t) { return e != null && Hz(e, t, Gz); } var Xz = Wz, qz = function () { return Hr.Date.now(); }, Op = qz, Yz = 'Expected a function', Qz = Math.max, Zz = Math.min; function Kz(e, t, i) { var r, s, n, a, o, l, h = 0, u = !1, c = !1, d = !0; if (typeof e != 'function') throw new TypeError(Yz); (t = jy(t) || 0), xs(i) && ((u = !!i.leading), (c = 'maxWait' in i), (n = c ? Qz(jy(i.maxWait) || 0, t) : n), (d = 'trailing' in i ? !!i.trailing : d)); function p(A) { var S = r, _ = s; return (r = s = void 0), (h = A), (a = e.apply(_, S)), a; } function f(A) { return (h = A), (o = setTimeout(v, t)), u ? p(A) : a; } function g(A) { var S = A - l, _ = A - h, M = t - S; return c ? Zz(M, n - _) : M; } function m(A) { var S = A - l, _ = A - h; return l === void 0 || S >= t || S < 0 || (c && _ >= n); } function v() { var A = Op(); if (m(A)) return y(A); o = setTimeout(v, g(A)); } function y(A) { return (o = void 0), d && r ? p(A) : ((r = s = void 0), a); } function b() { o !== void 0 && clearTimeout(o), (h = 0), (r = l = s = o = void 0); } function x() { return o === void 0 ? a : y(Op()); } function w() { var A = Op(), S = m(A); if (((r = arguments), (s = this), (l = A), S)) { if (o === void 0) return f(l); if (c) return clearTimeout(o), (o = setTimeout(v, t)), p(l); } return o === void 0 && (o = setTimeout(v, t)), a; } return (w.cancel = b), (w.flush = x), w; } var __ = Kz; function Jz(e) { var t = e == null ? 0 : e.length; return t ? e[t - 1] : void 0; } var $z = Jz; function eN(e, t) { return t.length < 2 ? e : o_(e, jR(t, 0, -1)); } var tN = eN; function iN(e, t) { return kz(e, t); } var jg = iN; function rN(e, t) { return (t = $o(t, e)), (e = tN(e, t)), e == null || delete e[vu($z(t))]; } var sN = rN; function nN(e) { return FR(e) ? void 0 : e; } var aN = nN, oN = 1, lN = 2, hN = 4, cN = h_(function (e, t) { var i = {}; if (e == null) return i; var r = !1; (t = Zw(t, function (n) { return (n = $o(n, e)), r || (r = n.length > 1), n; })), Rh(e, m_(e), i), r && (i = x_(i, oN | lN | hN, aN)); for (var s = t.length; s--; ) sN(i, t[s]); return i; }), tm = cN; function dN(e, t, i, r) { if (!xs(e)) return e; t = $o(t, e); for (var s = -1, n = t.length, a = n - 1, o = e; o != null && ++s < n; ) { var l = vu(t[s]), h = i; if (l === '__proto__' || l === 'constructor' || l === 'prototype') return e; if (s != a) { var u = o[l]; (h = r ? r(u, l, o) : void 0), h === void 0 && (h = xs(u) ? u : Cg(t[s + 1]) ? [] : {}); } Pg(o, l, h), (o = o[l]); } return e; } var uN = dN; function pN(e, t, i) { for (var r = -1, s = t.length, n = {}; ++r < s; ) { var a = t[r], o = o_(e, a); i(o, a) && uN(n, $o(a, e), o); } return n; } var fN = pN; function mN(e, t) { return fN(e, t, function (i, r) { return Xz(e, r); }); } var gN = mN, vN = h_(function (e, t) { return e == null ? {} : gN(e, t); }), gh = vN, A_, yN = new Promise((e) => { A_ = e; }), f1 = !1; async function xN() { if (f1) return; let e = await import('./physics.js'); await e.init(), A_(e), (f1 = !0); } var Qt = class { modifyById(e, t) { let i = this; if (i[e] === void 0) throw new Error('not expected'); { let r = { ...i, [e]: t }; return Object.setPrototypeOf(r, Qt.prototype), r; } } add(e, t) { return this.runOp({ type: 1, id: e, data: t })?.data ?? this; } runOp(e) { let t = this; if (e.type === 1) { let i = t[e.id], r; i === void 0 ? (r = { type: 2, id: e.id }) : (r = { type: 1, id: e.id, data: i }); let { id: s, data: n } = e, a = { ...t, [s]: n }; return Object.setPrototypeOf(a, Qt.prototype), { data: a, actual: e, reverse: r }; } else if (e.type === 2) { let { id: i } = e, r = t[i]; if (r === void 0) return null; { let s = { ...t }; return Object.setPrototypeOf(s, Qt.prototype), delete s[i], { data: s, actual: e, reverse: { type: 1, id: i, data: r } }; } } return null; } }; function Gg(e) { if (e.deepFreeze !== void 0) { e.deepFreeze(e); return; } let t = Object.getOwnPropertyNames(e); for (let i of t) { let r = e[i]; r && typeof r == 'object' && Gg(r); } return Object.freeze(e); } function bN(e, t) { let i = 0; for (; i < e.length && i < t.length; ) { if (e[i] < t[i]) return -1; if (e[i] > t[i]) return 1; i += 1; } return i !== t.length ? -1 : i !== e.length ? 1 : 0; } var S_ = class extends Error {}; function Ip(e) { let t = { ...e }; return Object.setPrototypeOf(t, Object.getPrototypeOf(e)), t; } function yn(e, t, i) { if ((e === void 0 ? (t === void 0 ? ((e = 0), (t = 10)) : (e = t - 10)) : t === void 0 && (t = e + 10), e > t)) { let n = e; (e = t), (t = n); } let r = [], s = 1 / (i + 1); for (let n = 0; n < i; n++) { let a = e + (t - e) * (n + 0.75 + Math.random() * 0.5) * s; r.push(a); } return r; } function Vg(e) { return ( e instanceof Uint8Array || e instanceof Uint16Array || e instanceof Uint32Array || e instanceof Int8Array || e instanceof Int16Array || e instanceof Int32Array || e instanceof Float32Array || e instanceof Float64Array ); } function wN() { return typeof process < 'u'; } function M_(e, t) { for (let i of e) t(i.id, i.data) !== !0 && M_(i.children, t); } function E_(e, t) { if (t(e.id, e.data) !== !0) for (let i of e.children) E_(i, t); } var ki = class extends Array { constructor(...e) { super(...e), Object.setPrototypeOf(this, ki.prototype); } deepFreeze() { let e = 0; for (; e < this.length; ) Gg(this[e]), e++; } fillCaches0(e, t) { this.objCaches.set(e.id, e), this.parentCaches.set(e.id, t); for (let i of e.children) this.fillCaches0(i, e.id); } fillCaches() { if (this.objCaches === void 0) { (this.objCaches = new Map()), (this.parentCaches = new Map()); for (let e of this) this.fillCaches0(e, null); } } randomId() { this.fillCaches(); let e = Array.from(this.objCaches.keys()); if (e.length !== 0) return e[Math.max(0, Math.floor(Math.random() * e.length) - 1)]; } nonExistOrDescendantOf(e, t) { if (!this.has(e)) return !0; for (; e; ) { let i = this.parent(e); if (i === t) return !0; e = i; } return !1; } isDescendantOf(e, t) { for (; e; ) { let i = this.parent(e); if (i === t) return !0; e = i; } return !1; } data(e) { return this.get(e)?.data; } has(e) { return this.childrenOf(e) !== void 0; } get(e) { return this.fillCaches(), this.objCaches.get(e); } childrenOf(e) { return e === null ? this : this.get(e)?.children; } traverseFrom(e, t) { if (e === null) this.traverse(t); else { let i = this.get(e); i && E_(i, t); } } traverse(e) { M_(this, e); } totalSize() { return this.fillCaches(), this.objCaches.size; } parent(e) { return this.fillCaches(), this.parentCaches.get(e); } childrenArray(e) { return e === null ? this : this.get(e).children; } modifyById(e, t) { if (this.get(e) === void 0) throw new Error('not expected'); { let i = this.parent(e), r = this.childrenArray(i), s = r.findIndex((a) => a.id === e); if (s < 0) throw new Error('not expected'); let n = r[s]; return (r = [...r]), (r[s] = { ...n, data: t }), this.modifyArrayBy(i, r); } } modifyArrayBy(e, t) { let i = e, r = t; for (; i !== null; ) { let n = r, a = i; if (((i = this.parent(i)), i === void 0)) throw new Error(); r = this.childrenArray(i); let o = r.findIndex((l) => l.id === a); if (o < 0) throw new Error(); (r = [...r]), (r[o] = { ...r[o], children: n }); } Object.setPrototypeOf(r, ki.prototype); let s = r; return s.fillCaches(), s; } runOp(e) { switch (e.type) { case 7: return this.addOp(e); case 8: return this.deleteOp(e); case 9: return this.moveOp(e); } return null; } checkDuplicatedIdRec({ id: e, children: t }) { if (this.get(e) !== void 0) return !0; for (let i of t) if (this.checkDuplicatedIdRec(i)) return !0; return !1; } addOp(e) { let { parent: t, fi: i, id: r, data: s, children: n } = e; if ((t !== null && this.get(t) === void 0) || this.checkDuplicatedIdRec(e)) return null; { let a = t, o = this.childrenArray(a), l = { fi: i, id: r, data: s, children: n }; return ( (o = [...o, l]), o.sort((h, u) => h.fi - u.fi), (e.localIndex = o.indexOf(l)), { data: this.modifyArrayBy(a, o), actual: e, reverse: { type: 8, id: r } } ); } } deleteOp(e) { let { id: t } = e; if (this.get(t) === null) return null; { let i = this.parent(t); if (i === void 0) return null; let r = this.childrenArray(i), s = r.findIndex((a) => a.id === t); (e.localIndex = s), (r = [...r]); let n = r.splice(s, 1)[0]; return { data: this.modifyArrayBy(i, r), actual: e, reverse: { type: 7, ...n, parent: i } }; } } moveOp(e) { let { parent: t, fi: i, id: r } = e; if (t !== null && this.get(t) === void 0) return this.deleteOp({ type: 8, id: r }); if (t !== null) { let c = t; for (; c !== null; ) { if (c === void 0) throw new Error(); if (c === r) throw new S_('cyclic tree'); c = this.parent(c); } } let s = this.parent(r); if (s === void 0) return null; let n = s, a = this.childrenArray(s), o = a.findIndex((c) => c.id === r); a = [...a]; let l = a.splice(o, 1)[0], h = this.modifyArrayBy(s, a); (s = t), (a = h.childrenArray(s)); let u = l.fi; return ( (l = { ...l, fi: i }), (a = [...a, l]), a.sort((c, d) => c.fi - d.fi), (e.localIndex = a.indexOf(l)), (h = h.modifyArrayBy(s, a)), { data: h, actual: e, reverse: { type: 9, parent: n, fi: u, id: r } } ); } previous(e, t) { if (t === null) { let r = this.childrenArray(e); return r.length === 0 ? null : r[r.length - 1].id; } let i = null; for (let r of this.childrenArray(e)) { if (r.id === t) return i; i = r.id; } return null; } traverseSortNext(e) { let t = this.parent(e); if (t !== void 0) { let i = this.childrenArray(t), r = i.findIndex((s) => s.id === e) + 1; if (r < i.length) return i[r].id; if (t) return this.traverseSortNext(t); } } sortNext(e) { let t = this.childrenArray(e); return t.length > 0 ? t[0].id : this.traverseSortNext(e); } traverseSortPrevious(e) { let t = this.childrenArray(e); return t.length > 0 ? this.traverseSortPrevious(t[t.length - 1].id) : e; } sortPrevious(e) { let t = this.parent(e); if (t !== void 0) { let i = this.childrenArray(t), r = i.findIndex((s) => s.id === e) - 1; return r >= 0 ? this.traverseSortPrevious(i[r].id) : t; } } getAllSorted(e) { let t = []; for (let i of e) { let r = this.getWithSortKey(i.id); r !== void 0 && t.push({ ...i, ...r }); } t.sort((i, r) => bN(i.sortKey, r.sortKey)); for (let i of t) delete i.sortKey; return t; } getWithSortKey(e) { var t = e; let i = [], r = this.get(t), s = r; if (r !== void 0) { for (; t; ) i.splice(0, 0, r.fi), (t = this.parent(t)), t !== null && (r = this.get(t)); return { ...s, sortKey: i }; } } insertBeforeHelper(e, t, i) { return this.insertAfterHelper(e, this.previous(e, t), i); } insertAfterHelper(e, t, i) { let r = this.childrenArray(e); if (t === null) { if (r.length === 0) return yn(0, i, i); { let s = r[0].fi; return yn(s - i, s, i); } } else { let s = this.get(t); if (s === void 0 || this.parent(t) !== e) throw new Error('illegal args'); let n = r.find((a) => a.fi > s.fi); if (n === void 0) { let a = r[r.length - 1].fi; return yn(a, a + i, i); } else return yn(s.fi, n.fi, i); } } }, Ed; ((e) => { function t(i, r) { if (r.type !== 0) return null; if (Array.isArray(i)) { let s = r.props, n = {}, a = [...i], o = !1; if (s) for (let l of Object.keys(s)) { let h = parseInt(l); if (isNaN(h)) throw new Error('wrong index'); (n[l] = a[h]), (a[h] = s[l]), (o = !0); } return o ? { data: a, actual: r, reverse: { type: 0, props: n } } : null; } else { let s = r.props, n = {}, a = { ...i }, o = !1; if (s) for (let l of Object.keys(s)) { n[l] = a[l]; let h = s[l]; h === void 0 ? delete a[l] : (a[l] = h), (o = !0); } return o ? { data: a, actual: r, reverse: { type: 0, props: n } } : null; } } e.runOp = t; })(Ed || (Ed = {})); var rt = class extends Array { constructor(...e) { super(...e), Object.setPrototypeOf(this, rt.prototype); } deepFreeze() { let e = 0; for (; e < this.length; ) Gg(this[e]), e++; } fillCaches0(e) { this.objCaches.set(e.id, e); } fillCaches() { if (this.objCaches === void 0) { (this.objCaches = new Map()), (Object.getOwnPropertyDescriptor(this, 'objCaches').enumerable = !1); for (let e of this) this.fillCaches0(e); } } randomId() { this.fillCaches(); let e = Array.from(this.objCaches.keys()); if (e.length !== 0) return e[Math.max(0, Math.floor(Math.random() * e.length) - 1)]; } data(e) { return this.get(e)?.data; } get(e) { return this.fillCaches(), this.objCaches.get(e); } modifyById(e, t) { if (this.get(e) === void 0) throw new Error('not expected'); { let i = this, r = i.findIndex((n) => n.id === e); if (r < 0) throw new Error('not expected'); let s = i[r]; return (i = [...i]), (i[r] = { ...s, data: t }), this.modifyArrayBy(i); } } modifyArrayBy(e) { Object.setPrototypeOf(e, rt.prototype); let t = e; return wN() || t.fillCaches(), t; } runOp(e) { switch (e.type) { case 4: return this.addOp(e); case 5: return this.deleteOp(e); case 6: return this.moveOp(e); } return null; } addOp(e) { let { fi: t, id: i, data: r } = e, s = this, n = { fi: t, id: i, data: r }; return ( (s = [...s, n]), s.sort((a, o) => a.fi - o.fi), (e.localIndex = s.indexOf(n)), { data: this.modifyArrayBy(s), actual: e, reverse: { type: 5, id: i } } ); } deleteOp(e) { let { id: t } = e, i = this, r = i.findIndex((n) => n.id === t); if (r === -1) return null; (e.localIndex = r), (i = [...i]); let s = i.splice(r, 1)[0]; return { data: this.modifyArrayBy(i), actual: e, reverse: { type: 4, ...s } }; } moveOp(e) { let { fi: t, id: i } = e, r = this; r = [...r]; let s = r.findIndex((o) => o.id === i); if (s === -1) return null; let n = r[s].fi, a = { ...r[s], fi: t }; return ( (r[s] = a), r.sort((o, l) => o.fi - l.fi), (e.localIndex = r.indexOf(a)), { data: this.modifyArrayBy(r), actual: e, reverse: { type: 6, fi: n, id: i } } ); } previous(e) { if (e === null) return this.length === 0 ? null : this[this.length - 1].id; let t = null; for (let i of this) { if (i.id === e) return t; t = i.id; } return null; } insertBeforeHelper(e, t) { return this.insertAfterHelper(this.previous(e), t); } insertAfterHelper(e, t) { let i = this; if (e === null) { if (i.length === 0) return yn(0, t, t); { let r = i[0].fi; return yn(r - t, r, t); } } else { let r = this.get(e); if (r === void 0) throw new Error('illegal args'); let s = i.find((n) => n.fi > r.fi); if (s === void 0) { let n = i[i.length - 1].fi; return yn(n, n + t, t); } else return yn(r.fi, s.fi, t); } } }; function Uo(e) { return e && typeof e == 'object' && e instanceof mi; } var mi = class { unusedFunOverridesTable(e) {} runOp(e) { let t = [], i = this, r = 0, s = {}; for (; r < e.path.length; ) { if ((t.push(i), (i = i === void 0 ? void 0 : i[e.path[r]]), i !== void 0 && !Uo(i))) return null; r += 1; } i = i ? Ip(i) : new mi(); for (let [o, l] of Object.entries(e.props)) { let h = i[o]; (s[o] = h), l === void 0 ? delete i[o] : (i[o] = l); } for (; r > 0; ) { if (Object.keys(i).length === 0) { let o = t[r - 1]; o && ((i = Ip(o)), delete i[e.path[r - 1]]); } else { let o = t[r - 1]; if (o) { let l = Ip(o); (l[e.path[r - 1]] = i), (i = l); } else { let l = new mi(); (l[e.path[r - 1]] = i), (i = l); } } r -= 1; } let n = Object.setPrototypeOf(i, mi.prototype), a = { ...e, props: s }; return { data: n, actual: e, reverse: a }; } }, fa; ((e) => { function t(s, n) { return vh(s, n) ?? s; } e.apply = t; function i(s, n) { return Wg(s, n); } e.merge = i; function r(s, n) { let a = 0, o = n.path, l = s; for (; a < o.length && l !== void 0; ) { if (((l = fs.zoomOnce(l, o[a])), l === void 0)) return n; if (!Uo(l)) return; a += 1; } if (l === void 0) return n; if (Uo(l)) if (n.type === 0) { let h = { ...n.props }; for (let u of Object.keys(l)) delete h[u]; return { ...n, props: h }; } else if (n.type === 1 || n.type === 4 || n.type === 7) { let h = Hg([n], l); return h ? (console.log(h), h) : n; } else return n; } e.filterOp = r; })(fa || (fa = {})); function Hg(e, t) { if (t === void 0) return; let i = !1, r = e.map((s) => { let n = s.id, a = vh(s.data, t[n]); if (((i = i || a !== void 0), a === void 0 && (a = s.data), s.children)) { let o = Hg(s.children, t); return o !== void 0 ? (i = !0) : (o = s.children), { ...s, id: n, data: a, children: o }; } else return { ...s, id: n, data: a }; }); if (i) return r; } function _N(e, t) { if (t === void 0) return; let i = !1, r = e.map((s) => { let n = s.id, a = vh(s.data, t[n]); return (i = i || a !== void 0), a === void 0 && (a = s.data), { ...s, id: n, data: a }; }); if (i) return Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r; } function vh(e, t) { if (!Uo(t)) return t; if (e instanceof ki) { let i = Hg(e, t); return i !== void 0 && Object.setPrototypeOf(i, Object.getPrototypeOf(e)), i; } else { if (e instanceof rt) return _N(e, t); if (Array.isArray(e)) { let i = !1, r = e.map((s, n) => { let a = vh(s, t[n]); return (i = i || a !== void 0), a === void 0 && (a = s), a; }); return i ? (Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r) : void 0; } else { if (e instanceof mi) return Wg(e, t); if (e && typeof e == 'object') { let i = {}, r = !1; for (let [s, n] of Object.entries(e)) { let a = vh(n, t[s]); (r = r || a !== void 0), a === void 0 && (a = n), (i[s] = a); } return r ? (Object.setPrototypeOf(i, Object.getPrototypeOf(e)), i) : void 0; } } } } function Wg(e, t) { if (e === void 0) return t; if (t === void 0) return e; if (!Uo(t)) return t; if (!Uo(e)) return fa.apply(e, t); let i = new Set(); for (let s of Object.keys(e)) i.add(s); for (let s of Object.keys(t)) i.add(s); let r = new mi(); for (let s of i) { let n = Wg(e === void 0 ? void 0 : e[s], t === void 0 ? void 0 : t[s]); r[s] = n; } return r; } function AN(e, t) { let i = { cur: [], result: [], len: 0 }; return (e = yh(e, t, i) ?? e), [e, i.result]; } function Cd(e, t) { return e === null ? null : ((e.cur[e.len] = t), (e.len += 1), e); } function Td(e) { e && (e.len -= 1); } function SN(e) { if (e === null) return null; e.result.push(e.cur.slice(0, e.len)); } function C_(e, t, i) { let r = !1, s = e.map((n) => { let a = n.id, o = t[a]; if (o !== void 0 && typeof o == 'string' && ((r = !0), (a = o), i !== null)) throw new Error('not supported'); let l = yh(n.data, t, Cd(i, a)); Td(i), (r = r || l !== void 0), l === void 0 && (l = n.data); let h = C_(n.children, t, i); return h !== void 0 ? (r = !0) : (h = n.children), { ...n, id: a, data: l, children: h }; }); if (r) return s; } function MN(e, t, i) { let r = !1, s = e.map((n) => { let a = n.id, o = t[a]; if (o !== void 0 && typeof o == 'string' && ((r = !0), (a = o), i !== null)) throw new Error('not supported'); let l = yh(n.data, t, Cd(i, a)); return Td(i), (r = r || l !== void 0), l === void 0 && (l = n.data), { ...n, id: a, data: l }; }); if (r) return Object.setPrototypeOf(s, Object.getPrototypeOf(e)), s; } function yh(e, t, i) { if (e instanceof ki) { let r = C_(e, t, i); return r !== void 0 && Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r; } else { if (e instanceof rt) return MN(e, t, i); if (Array.isArray(e)) { let r = !1, s = e.map((n, a) => { let o = yh(n, t, Cd(i, a)); return Td(i), (r = r || o !== void 0), o === void 0 && (o = n), o; }); return r ? (Object.setPrototypeOf(s, Object.getPrototypeOf(e)), s) : void 0; } else if (e && typeof e == 'object' && !Vg(e)) { let r = {}, s = !1; for (let [n, a] of Object.entries(e)) if (n !== 'name' && n !== 'text') { let o = t[n]; if (typeof o == 'string') { if (i !== null) throw new Error('not supported'); (s = !0), (n = o); } let l = yh(a, t, Cd(i, n)); Td(i), (s = s || l !== void 0), l === void 0 && (l = a), (r[n] = l); } else r[n] = a; return s ? (Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r) : void 0; } else if (typeof e == 'string') { let r = t[e]; if (r !== void 0) { if (e.length !== 36) throw new Error('for now you should only call this method when the key is a uuid'); SN(i); } return r; } else return; } } var im; ((e) => { function t(i, r) { let s = fs.zoom(r, i.path); if (typeof s == 'object') { let n = {}; for (let a of Object.keys(i.props)) n[a] = s[a]; return { ...i, props: n }; } else return { ...i, props: {} }; } e.replaceProps = t; })(im || (im = {})); var ir; ((e) => { function t(l, h) { return { ...l, path: l.path.slice(h) }; } e.drop = t; function i(l, h) { return r(l, h)?.data ?? l; } e.applySimple = i; function r(l, h) { let u = h.path; for (var c = []; ; ) { let d; if ( (l instanceof mi && h.type === 0 && ((d = l.runOp({ ...h, path: u.slice(c.length) })), d === null && (d = void 0)), c.length === u.length && (l instanceof ki || l instanceof rt || l instanceof Qt ? (d = l.runOp(h)) : (d = Ed.runOp(l, h))), d !== void 0) ) if (d !== null) { let g = d.data; for (let m = c.length - 1; m >= 0; m--) { let v = u[m], y = c[m]; if (y instanceof ki) { if (typeof v == 'number') throw new Error('illegal arg'); g = y.modifyById(v, g); } else if (y instanceof rt) { if (typeof v == 'number') throw new Error('illegal arg'); g = y.modifyById(v, g); } else if (y instanceof Qt) { if (typeof v == 'number') throw new Error('illegal arg'); g = y.modifyById(v, g); } else if (y instanceof mi) { let b = { ...y, [v]: g }; g = Object.setPrototypeOf(b, mi.prototype); } else if (typeof y == 'object') if (Array.isArray(y)) { if (typeof v == 'string' && ((v = parseInt(v)), isNaN(v))) throw new Error('Invalid path'); let b = g; (g = [...y]), (g[v] = b); } else g = { ...y, [v]: g }; else return null; } return { data: g, actual: { ...d.actual, path: u }, reverse: { ...d.reverse, path: u } }; } else return null; let p = u[c.length], f; if (l instanceof ki) { if (typeof p == 'number') throw new Error(''); f = l.get(p)?.data; } else if (l instanceof rt) { if (typeof p == 'number') throw new Error(''); f = l.get(p)?.data; } else l !== null && (f = l[p]); if (f !== void 0) c.push(l), (l = f); else return null; } } e.apply = r; function s(l, h) { for (let u = 0; u < l.length && u < h.length; u++) if (l[u] !== h[u]) return !0; return !1; } e.pathDisjoint = s; function n(l, h) { if (l.length !== h.length) return !1; for (let u = 0; u < l.length; u++) if (l[u] !== h[u]) return !1; return !0; } e.pathEq = n; function a(l, h) { return s(l.path, h.path); } e.commutative = a; function o(l, h) { return l.type === 0 && h.type === 0 && n(l.path, h.path) ? Object.keys(l.props).every((u) => h.props[u] !== void 0) : !1; } e.subsumed = o; })(ir || (ir = {})); var m1; ((e) => { function t() { return []; } e.empty = t; function i(h, u) { let c = []; for (let d of h) { let [p, ...f] = d.path; p === u && c.push({ ...d, path: f }); } return c; } e.removePrefix = i; function r(h, u) { return h.map((c) => ({ ...c, path: [u, ...c.path] })); } e.addPrefix = r; function s(h, u) { return [...h, ...u]; } e.concat = s; function n(h, u) { return [...h.filter((c) => !u.some((d) => ir.subsumed(c, d))), ...u]; } e.compress = n; function a(h, u) { return h.every((c) => u.every((d) => ir.commutative(c, d))); } e.commutative = a; function o(h, u) { for (let c of u) { let d = l(h, c); d !== null && (h = d.data); } return h; } e.applyAll = o; function l(h, u) { var c = h; let d = [], p = []; for (let f of u) try { if (f.type === 3) { let g = fs.zoom(c, [...f.path, f.id]), m = ir.apply(c, { ...f, type: 2 }); if (m !== null) { c = m.data; let [v, y] = AN(c, { [f.id]: g }); c = v; for (let b of y) { let x = b[b.length - 1]; b.splice(b.length - 1, 1), d.push({ type: 0, path: b, props: { [x]: g } }), p.push({ type: 0, path: b, props: { [x]: f.id } }); } p.push(m.reverse), d.push(m.actual); } } else { let g = ir.apply(c, f); g !== null && (d.push(g.actual), (c = g.data), p.push(g.reverse)); } } catch (g) { if (g instanceof S_) return null; throw g; } return { data: c, actual: d, reverse: p.reverse() }; } e.apply = l; })(m1 || (m1 = {})); var T_ = Symbol(), EN = Symbol(), xu = Symbol(), Bh = class { reportOp(e, t, i = []) { let r = this; if (t === null) return; r._current = t.data; let s = i; for (; !(r instanceof D_); ) { let n = r._path, a = r._current; if ((n !== '' && s.splice(0, 0, n), (r = r._parent), r === null)) return; r.update(n, a); } r.push(s, e, t.actual, t.reverse); } deleteChildren(e) { if (this._children) { let t = this._children[e]; if (t) { let i = t[xu]; i && i(), delete this._children[e]; } } } }, CN = class extends Bh { constructor(e, t, i) { super(), (this._parent = e), (this._path = t), (this._current = i); } update(e, t) { if (Array.isArray(this._current)) { if (typeof e == 'string' && ((e = parseInt(e)), isNaN(e))) throw new Error('Invalid path'); (this._current = [...this._current]), (this._current[e] = t); } else this._current = { ...this._current, [e]: t }; } runOp(e) { this.reportOp(e, Ed.runOp(this._current, e), e.path); } }, TN = class extends Bh { constructor(e, t, i) { super(), (this._parent = e), (this._path = t), (this._current = i); } update(e, t) { (this._current = { ...this._current, [e]: t }), Object.setPrototypeOf(this._current, Qt.prototype); } runOp(e) { this.reportOp(e, this._current.runOp(e)); } }, P_ = { get(e, t) { if (t === xu) return () => { e._parent = null; }; if (t === T_) return e._current; if (t === EN) return e; let { _current: i, _children: r } = e; if (t === 'push' && Array.isArray(i)) throw new Error('not supported to expand array'); let s = r === void 0 ? void 0 : r[t]; if (s !== void 0) return s; let n = i[t], a = bu(e, t, n); return a !== n ? (r === void 0 && ((r = {}), (e._children = r)), (r[t] = a), a) : n; }, has(e, t) { return t in e._current; }, ownKeys(e) { return Reflect.ownKeys(e._current); }, defineProperty() { throw Error('not supported'); }, getPrototypeOf(e) { return Object.getPrototypeOf(e._current); }, setPrototypeOf() { throw Error('not supported'); }, getOwnPropertyDescriptor(e, t) { let i = e._current, r = Reflect.getOwnPropertyDescriptor(i, t); return r && { writable: !0, configurable: !0, enumerable: r.enumerable, value: i[t] }; } }, PN = { ...P_, set(e, t, i) { let r = { type: 0, props: { [t]: Si(i) ?? i } }; return e.deleteChildren(t), e.runOp(r), !0; }, deleteProperty(e, t) { let i = { type: 0, props: { [t]: void 0 } }; return e.deleteChildren(t), e.runOp(i), !0; } }, DN = { ...P_, set(e, t, i) { return i === void 0 ? this.deleteProperty(e, t) : (e.deleteChildren(t), e.runOp({ type: 1, id: t, data: i })), !0; }, deleteProperty(e, t) { return e.runOp({ type: 2, id: t }), !0; } }, Xg = class extends Bh { constructor(e, t, i) { super(), (this._children = {}), (this._parent = e), (this._path = t), (this._current = i), (this[xu] = () => { this._parent = null; }); } unproxy() { return this._current; } update(e, t) { this._current = this._current.modifyById(e, t); } runOp(e) { this.reportOp(e, this._current.runOp(e)); } randomId() { return this._current.randomId(); } isDescendantOf(e, t) { return this._current.isDescendantOf(e, t); } childrenOf(e) { return this._current.childrenOf(e); } traverse(e) { return this._current.traverse(e); } get(e) { return this._current.get(e); } parent(e) { return this._current.parent(e); } traverse(e) { this._current.traverse((t, i) => { e(t, this.data(t)); }); } data(e) { let { _current: t, _children: i } = this, r = i === void 0 ? void 0 : i[e]; if (r !== void 0) return r; let s = t.get(e)?.data, n = bu(this, e, s); return n !== s ? (i === void 0 && ((i = {}), (this._children = i)), (i[e] = n), n) : s; } add(e, t, i, r, s) { this.runOp({ type: 7, parent: e, fi: t, id: i, data: r, children: s }); } move(e, t, i) { this.runOp({ type: 9, parent: e, fi: t, id: i }); } insertAfter(e, t, i) { let r = this._current.insertAfterHelper(e, t, i.length); for (let s = 0; s < i.length; s++) { let n = i[s]; this.add(e, r[s], n.id, n.data, n.children); } } insertBefore(e, t, i) { let r = this._current.insertBeforeHelper(e, t, i.length); for (let s = 0; s < i.length; s++) { let n = i[s]; this.add(e, r[s], n.id, n.data, n.children); } } moveAfter(e, t, i) { let r = this._current.insertAfterHelper(e, t, i.length); for (let s = 0; s < i.length; s++) { let n = i[s]; this.move(e, r[s], n); } } moveBefore(e, t, i) { let r = this._current.insertBeforeHelper(e, t, i.length); for (let s = 0; s < i.length; s++) { let n = i[s]; this.move(e, r[s], n); } } delete(e) { this.deleteChildren(e), this.runOp({ type: 8, id: e }); } sortNext(e) { return this._current.sortNext(e); } sortPrevious(e) { return this._current.sortPrevious(e); } getAllSorted(e) { return this._current.getAllSorted(e); } }, qg = class extends Bh { constructor(e, t, i) { super(), (this._children = {}), (this._parent = e), (this._path = t), (this._current = i), (this[xu] = () => { this._parent = null; }); } unproxy() { return this._current; } get length() { return this._current.length; } forEach(e) { let t = this.length; for (let i = 0; i < t; i++) { let r = this._current[i].id, s = this._current[i].fi; e(this.data(this._current[i].id), r, s); } } find(e) { let t = this.length; for (let i = 0; i < t; i++) { let r = this._current[i].id; if (e(this.data(r), r)) return this.get(r); } } update(e, t) { this._current = this._current.modifyById(e, t); } randomId() { return this._current.randomId(); } get(e) { return { ...this._current.get(e), data: this.data(e) }; } data(e) { let { _current: t, _children: i } = this, r = i === void 0 ? void 0 : i[e]; if (r !== void 0) return r; let s = t.get(e)?.data, n = bu(this, e, s); return n !== s ? (i === void 0 && ((i = {}), (this._children = i)), (i[e] = n), n) : s; } runOp(e) { this.reportOp(e, this._current.runOp(e)); } add(e, t, i) { this.runOp({ type: 4, fi: e, id: t, data: i }); } move(e, t) { this.runOp({ type: 6, fi: e, id: t }); } insertAfter(e, t) { let i = this._current.insertAfterHelper(e, t.length); for (let r = 0; r < t.length; r++) { let s = t[r]; this.add(i[r], s.id, s.data); } } insertBefore(e, t) { let i = this._current.insertBeforeHelper(e, t.length); for (let r = 0; r < t.length; r++) { let s = t[r]; this.add(i[r], s.id, s.data); } } moveAfter(e, t) { let i = this._current.insertAfterHelper(e, t.length); for (let r = 0; r < t.length; r++) { let s = t[r]; this.move(i[r], s); } } moveBefore(e, t) { let i = this._current.insertBeforeHelper(e, t.length); for (let r = 0; r < t.length; r++) { let s = t[r]; this.move(i[r], s); } } delete(e) { this.deleteChildren(e), this.runOp({ type: 5, id: e }); } }; function Rp(e, t, i) { if (e.length > 0) { let r = e[e.length - 1]; if (r.type === 0 && t.type === 0 && fs.equal(r.path, i)) { Object.assign(r.props, t.props); return; } } e.push({ ...t, path: i }); } var D_ = class extends Bh { constructor(e) { super(), (this.ts = []), (this.actual = []), (this.reverse = []), (this._current = e); } update(e, t) { if (e !== '') throw new Error(''); this._current = t; } push(e, t, i, r) { Rp(this.ts, t, e), Rp(this.actual, i, e), Rp(this.reverse, r, e); } result() { return { data: this._current, ts: this.ts, actual: this.actual, reverse: this.reverse.reverse() }; } }; function bu(e, t, i) { return i instanceof ki ? new Xg(e, t, i) : i instanceof rt ? new qg(e, t, i) : i instanceof Qt ? new Proxy(new TN(e, t, i), DN) : i !== null && typeof i == 'object' ? Vg(i) ? i : new Proxy(new CN(e, t, i), PN) : i; } function L_(e) { let t = new D_(e); return [bu(t, '', e), t]; } function Pd(e, t) { let [i, r] = L_(e); return t(i), r.result(); } function Si(e) { return e instanceof Xg || e instanceof qg ? e._current : e !== null && typeof e == 'object' ? e[T_] : e; } var fs; ((e) => { function t(n, a) { if (a.length === n.length) for (var o = 0; o < n.length; ) { if (n[o] !== a[o]) return !1; o += 1; } else return !1; return !0; } e.equal = t; function i(n, a, o) { let l = s(o, n); if (l !== void 0 && typeof l == 'object' && l !== null) { let h = { ...a }; return ( Object.keys(l).forEach((u) => { delete h[u]; }), h ); } else return a; } e.removeOverridden = i; function r(n, a) { if (((n instanceof ki || n instanceof Xg) && typeof a == 'string') || ((n instanceof rt || n instanceof qg) && typeof a == 'string')) return n.data(a); if ((typeof a == 'number' && Array.isArray(n)) || (typeof a == 'string' && typeof n == 'object' && n !== null)) return n[a]; } e.zoomOnce = r; function s(n, a, o = 0) { for (; o < a.length && n !== void 0; ) (n = r(n, a[o])), (o += 1); return n; } e.zoom = s; })(fs || (fs = {})); function LN(e, t) { let i = []; if (t.length === e.length) for (var r = 0; r < e.length; ) { if (t[r] === '*') i.push(e[r]); else if (e[r] !== t[r]) return null; r += 1; } else return null; return i; } function pn(e, t) { let i = []; if (t.length <= e.length) for (var r = 0; r < t.length; ) { if (t[r] === '*') i.push(e[r]); else if (e[r] !== t[r]) return null; r += 1; } else return null; return i; } var O_ = class {}, g1 = class extends O_ { constructor(e) { super(), (this.id = e); } }, v1 = class extends O_ { constructor(e) { super(), (this.data = e); } }, rm; try { rm = new TextDecoder(); } catch {} var Se, En, Z = 0, I_ = [], sm = I_, nm = 0, zi = {}, pt, xn, gr = 0, os = 0, Zi, Vs, Ii = [], ft, y1 = { useRecords: !1, mapsAsObjects: !0 }, R_ = class {}, B_ = new R_(); B_.name = 'MessagePack 0xC1'; var Fo = !1, Dd = class { constructor(e) { e && (e.useRecords === !1 && e.mapsAsObjects === void 0 && (e.mapsAsObjects = !0), e.structures ? (e.structures.sharedLength = e.structures.length) : e.getStructures && (((e.structures = []).uninitialized = !0), (e.structures.sharedLength = 0))), Object.assign(this, e); } unpack(e, t) { if (Se) return j_(() => (om(), this ? this.unpack(e, t) : Dd.prototype.unpack.call(y1, e, t))); (En = t > -1 ? t : e.length), (Z = 0), (nm = 0), (os = 0), (xn = null), (sm = I_), (Zi = null), (Se = e); try { ft = e.dataView || (e.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength)); } catch (i) { throw ( ((Se = null), e instanceof Uint8Array ? i : new Error('Source must be a Uint8Array or Buffer but was a ' + (e && typeof e == 'object' ? e.constructor.name : typeof e))) ); } if (this instanceof Dd) { if (((zi = this), this.structures)) return (pt = this.structures), _c(); (!pt || pt.length > 0) && (pt = []); } else (zi = y1), (!pt || pt.length > 0) && (pt = []); return _c(); } unpackMultiple(e, t) { let i, r = 0; try { Fo = !0; let s = e.length, n = this ? this.unpack(e, s) : _u.unpack(e, s); if (t) { for (t(n); Z < s; ) if (((r = Z), t(_c()) === !1)) return; } else { for (i = [n]; Z < s; ) (r = Z), i.push(_c()); return i; } } catch (s) { throw ((s.lastPosition = r), (s.values = i), s); } finally { (Fo = !1), om(); } } _mergeStructures(e, t) { e = e || []; for (let i = 0, r = e.length; i < r; i++) { let s = e[i]; s && ((s.isShared = !0), i >= 32 && (s.highByte = (i - 32) >> 5)); } e.sharedLength = e.length; for (let i in t || []) if (i >= 0) { let r = e[i], s = t[i]; s && (r && ((e.restoreStructures || (e.restoreStructures = []))[i] = r), (e[i] = s)); } return (this.structures = e); } decode(e, t) { return this.unpack(e, t); } }; function _c() { try { if (!zi.trusted && !Fo) { let t = pt.sharedLength || 0; t < pt.length && (pt.length = t); } let e = zt(); if (Z == En) pt.restoreStructures && x1(), (pt = null), (Se = null), Vs && (Vs = null); else if (Z > En) { let t = new Error('Unexpected end of MessagePack data'); throw ((t.incomplete = !0), t); } else if (!Fo) throw new Error('Data read, but end of buffer not reached'); return e; } catch (e) { throw ( (pt.restoreStructures && x1(), om(), (e instanceof RangeError || e.message.startsWith('Unexpected end of buffer')) && (e.incomplete = !0), e) ); } } function x1() { for (let e in pt.restoreStructures) pt[e] = pt.restoreStructures[e]; pt.restoreStructures = null; } function zt() { let e = Se[Z++]; if (e < 160) if (e < 128) { if (e < 64) return e; { let t = pt[e & 63] || (zi.getStructures && z_()[e & 63]); return t ? (t.read || (t.read = Yg(t, e & 63)), t.read()) : e; } } else if (e < 144) if (((e -= 128), zi.mapsAsObjects)) { let t = {}; for (let i = 0; i < e; i++) t[U_()] = zt(); return t; } else { let t = new Map(); for (let i = 0; i < e; i++) t.set(zt(), zt()); return t; } else { e -= 144; let t = new Array(e); for (let i = 0; i < e; i++) t[i] = zt(); return t; } else if (e < 192) { let t = e - 160; if (os >= Z) return xn.slice(Z - gr, (Z += t) - gr); if (os == 0 && En < 140) { let i = t < 16 ? Qg(t) : N_(t); if (i != null) return i; } return am(t); } else { let t; switch (e) { case 192: return null; case 193: return Zi ? ((t = zt()), t > 0 ? Zi[1].slice(Zi.position1, (Zi.position1 += t)) : Zi[0].slice(Zi.position0, (Zi.position0 -= t))) : B_; case 194: return !1; case 195: return !0; case 196: return Bp(Se[Z++]); case 197: return (t = ft.getUint16(Z)), (Z += 2), Bp(t); case 198: return (t = ft.getUint32(Z)), (Z += 4), Bp(t); case 199: return qn(Se[Z++]); case 200: return (t = ft.getUint16(Z)), (Z += 2), qn(t); case 201: return (t = ft.getUint32(Z)), (Z += 4), qn(t); case 202: if (((t = ft.getFloat32(Z)), zi.useFloat32 > 2)) { let i = Zg[((Se[Z] & 127) << 1) | (Se[Z + 1] >> 7)]; return (Z += 4), ((i * t + (t > 0 ? 0.5 : -0.5)) >> 0) / i; } return (Z += 4), t; case 203: return (t = ft.getFloat64(Z)), (Z += 8), t; case 204: return Se[Z++]; case 205: return (t = ft.getUint16(Z)), (Z += 2), t; case 206: return (t = ft.getUint32(Z)), (Z += 4), t; case 207: return zi.int64AsNumber ? ((t = ft.getUint32(Z) * 4294967296), (t += ft.getUint32(Z + 4))) : (t = ft.getBigUint64(Z)), (Z += 8), t; case 208: return ft.getInt8(Z++); case 209: return (t = ft.getInt16(Z)), (Z += 2), t; case 210: return (t = ft.getInt32(Z)), (Z += 4), t; case 211: return zi.int64AsNumber ? ((t = ft.getInt32(Z) * 4294967296), (t += ft.getUint32(Z + 4))) : (t = ft.getBigInt64(Z)), (Z += 8), t; case 212: if (((t = Se[Z++]), t == 114)) return S1(Se[Z++] & 63); { let i = Ii[t]; if (i) return i.read ? (Z++, i.read(zt())) : i.noBuffer ? (Z++, i()) : i(Se.subarray(Z, ++Z)); throw new Error('Unknown extension ' + t); } case 213: return (t = Se[Z]), t == 114 ? (Z++, S1(Se[Z++] & 63, Se[Z++])) : qn(2); case 214: return qn(4); case 215: return qn(8); case 216: return qn(16); case 217: return (t = Se[Z++]), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : IN(t); case 218: return (t = ft.getUint16(Z)), (Z += 2), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : RN(t); case 219: return (t = ft.getUint32(Z)), (Z += 4), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : BN(t); case 220: return (t = ft.getUint16(Z)), (Z += 2), w1(t); case 221: return (t = ft.getUint32(Z)), (Z += 4), w1(t); case 222: return (t = ft.getUint16(Z)), (Z += 2), _1(t); case 223: return (t = ft.getUint32(Z)), (Z += 4), _1(t); default: if (e >= 224) return e - 256; if (e === void 0) { let i = new Error('Unexpected end of MessagePack data'); throw ((i.incomplete = !0), i); } throw new Error('Unknown MessagePack token ' + e); } } } var ON = /^[a-zA-Z_$][a-zA-Z\d_$]*$/; function Yg(e, t) { function i() { if (i.count++ > 2) { let s = (e.read = new Function( 'r', 'return function(){return {' + e.map((n) => (ON.test(n) ? n + ':r()' : '[' + JSON.stringify(n) + ']:r()')).join(',') + '}}' )(zt)); return e.highByte === 0 && (e.read = b1(t, e.read)), s(); } let r = {}; for (let s = 0, n = e.length; s < n; s++) { let a = e[s]; r[a] = zt(); } return r; } return (i.count = 0), e.highByte === 0 ? b1(t, i) : i; } var b1 = (e, t) => function () { let i = Se[Z++]; if (i === 0) return t(); let r = e < 32 ? -(e + (i << 5)) : e + (i << 5), s = pt[r] || z_()[r]; if (!s) throw new Error('Record id is not defined for ' + r); return s.read || (s.read = Yg(s, e)), s.read(); }; function z_() { let e = j_(() => ((Se = null), zi.getStructures())); return (pt = zi._mergeStructures(e, pt)); } var am = wu, IN = wu, RN = wu, BN = wu; function wu(e) { let t; if (e < 16 && (t = Qg(e))) return t; if (e > 64 && rm) return rm.decode(Se.subarray(Z, (Z += e))); let i = Z + e, r = []; for (t = ''; Z < i; ) { let s = Se[Z++]; if ((s & 128) === 0) r.push(s); else if ((s & 224) === 192) { let n = Se[Z++] & 63; r.push(((s & 31) << 6) | n); } else if ((s & 240) === 224) { let n = Se[Z++] & 63, a = Se[Z++] & 63; r.push(((s & 31) << 12) | (n << 6) | a); } else if ((s & 248) === 240) { let n = Se[Z++] & 63, a = Se[Z++] & 63, o = Se[Z++] & 63, l = ((s & 7) << 18) | (n << 12) | (a << 6) | o; l > 65535 && ((l -= 65536), r.push(((l >>> 10) & 1023) | 55296), (l = 56320 | (l & 1023))), r.push(l); } else r.push(s); r.length >= 4096 && ((t += li.apply(String, r)), (r.length = 0)); } return r.length > 0 && (t += li.apply(String, r)), t; } function w1(e) { let t = new Array(e); for (let i = 0; i < e; i++) t[i] = zt(); return t; } function _1(e) { if (zi.mapsAsObjects) { let t = {}; for (let i = 0; i < e; i++) t[U_()] = zt(); return t; } else { let t = new Map(); for (let i = 0; i < e; i++) t.set(zt(), zt()); return t; } } var li = String.fromCharCode; function N_(e) { let t = Z, i = new Array(e); for (let r = 0; r < e; r++) { let s = Se[Z++]; if ((s & 128) > 0) { Z = t; return; } i[r] = s; } return li.apply(String, i); } function Qg(e) { if (e < 4) if (e < 2) { if (e === 0) return ''; { let t = Se[Z++]; if ((t & 128) > 1) { Z -= 1; return; } return li(t); } } else { let t = Se[Z++], i = Se[Z++]; if ((t & 128) > 0 || (i & 128) > 0) { Z -= 2; return; } if (e < 3) return li(t, i); let r = Se[Z++]; if ((r & 128) > 0) { Z -= 3; return; } return li(t, i, r); } else { let t = Se[Z++], i = Se[Z++], r = Se[Z++], s = Se[Z++]; if ((t & 128) > 0 || (i & 128) > 0 || (r & 128) > 0 || (s & 128) > 0) { Z -= 4; return; } if (e < 6) { if (e === 4) return li(t, i, r, s); { let n = Se[Z++]; if ((n & 128) > 0) { Z -= 5; return; } return li(t, i, r, s, n); } } else if (e < 8) { let n = Se[Z++], a = Se[Z++]; if ((n & 128) > 0 || (a & 128) > 0) { Z -= 6; return; } if (e < 7) return li(t, i, r, s, n, a); let o = Se[Z++]; if ((o & 128) > 0) { Z -= 7; return; } return li(t, i, r, s, n, a, o); } else { let n = Se[Z++], a = Se[Z++], o = Se[Z++], l = Se[Z++]; if ((n & 128) > 0 || (a & 128) > 0 || (o & 128) > 0 || (l & 128) > 0) { Z -= 8; return; } if (e < 10) { if (e === 8) return li(t, i, r, s, n, a, o, l); { let h = Se[Z++]; if ((h & 128) > 0) { Z -= 9; return; } return li(t, i, r, s, n, a, o, l, h); } } else if (e < 12) { let h = Se[Z++], u = Se[Z++]; if ((h & 128) > 0 || (u & 128) > 0) { Z -= 10; return; } if (e < 11) return li(t, i, r, s, n, a, o, l, h, u); let c = Se[Z++]; if ((c & 128) > 0) { Z -= 11; return; } return li(t, i, r, s, n, a, o, l, h, u, c); } else { let h = Se[Z++], u = Se[Z++], c = Se[Z++], d = Se[Z++]; if ((h & 128) > 0 || (u & 128) > 0 || (c & 128) > 0 || (d & 128) > 0) { Z -= 12; return; } if (e < 14) { if (e === 12) return li(t, i, r, s, n, a, o, l, h, u, c, d); { let p = Se[Z++]; if ((p & 128) > 0) { Z -= 13; return; } return li(t, i, r, s, n, a, o, l, h, u, c, d, p); } } else { let p = Se[Z++], f = Se[Z++]; if ((p & 128) > 0 || (f & 128) > 0) { Z -= 14; return; } if (e < 15) return li(t, i, r, s, n, a, o, l, h, u, c, d, p, f); let g = Se[Z++]; if ((g & 128) > 0) { Z -= 15; return; } return li(t, i, r, s, n, a, o, l, h, u, c, d, p, f, g); } } } } } function Bp(e) { return zi.copyBuffers ? Uint8Array.prototype.slice.call(Se, Z, (Z += e)) : Se.subarray(Z, (Z += e)); } function qn(e) { let t = Se[Z++]; if (Ii[t]) return Ii[t](Se.subarray(Z, (Z += e))); throw new Error('Unknown extension type ' + t); } var A1 = new Array(4096); function U_() { let e = Se[Z++]; if (e >= 160 && e < 192) { if (((e = e - 160), os >= Z)) return xn.slice(Z - gr, (Z += e) - gr); if (!(os == 0 && En < 180)) return am(e); } else return Z--, zt(); let t = ((e << 5) ^ (e > 1 ? ft.getUint16(Z) : e > 0 ? Se[Z] : 0)) & 4095, i = A1[t], r = Z, s = Z + e - 3, n, a = 0; if (i && i.bytes == e) { for (; r < s; ) { if (((n = ft.getUint32(r)), n != i[a++])) { r = 1879048192; break; } r += 4; } for (s += 3; r < s; ) if (((n = Se[r++]), n != i[a++])) { r = 1879048192; break; } if (r === s) return (Z = r), i.string; (s -= 3), (r = Z); } for (i = [], A1[t] = i, i.bytes = e; r < s; ) (n = ft.getUint32(r)), i.push(n), (r += 4); for (s += 3; r < s; ) (n = Se[r++]), i.push(n); let o = e < 16 ? Qg(e) : N_(e); return o != null ? (i.string = o) : (i.string = am(e)); } var S1 = (e, t) => { var i = zt(); let r = e; t !== void 0 && ((e = e < 32 ? -((t << 5) + e) : (t << 5) + e), (i.highByte = t)); let s = pt[e]; return s && s.isShared && ((pt.restoreStructures || (pt.restoreStructures = []))[e] = s), (pt[e] = i), (i.read = Yg(i, r)), i.read(); }, F_ = typeof self == 'object' ? self : global; Ii[0] = () => {}; Ii[0].noBuffer = !0; Ii[101] = () => { let e = zt(); return (F_[e[0]] || Error)(e[1]); }; Ii[105] = (e) => { let t = ft.getUint32(Z - 4); Vs || (Vs = new Map()); let i = Se[Z], r; (i >= 144 && i < 160) || i == 220 || i == 221 ? (r = []) : (r = {}); let s = { target: r }; Vs.set(t, s); let n = zt(); return s.used ? Object.assign(r, n) : ((s.target = n), n); }; Ii[112] = (e) => { let t = ft.getUint32(Z - 4), i = Vs.get(t); return (i.used = !0), i.target; }; Ii[115] = () => new Set(zt()); var k_ = ['Int8', 'Uint8', 'Uint8Clamped', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Float32', 'Float64', 'BigInt64', 'BigUint64'].map( (e) => e + 'Array' ); Ii[116] = (e) => { let t = e[0], i = k_[t]; if (!i) throw new Error('Could not find typed array for code ' + t); return new F_[i](Uint8Array.prototype.slice.call(e, 1).buffer); }; Ii[120] = () => { let e = zt(); return new RegExp(e[0], e[1]); }; Ii[98] = (e) => { let t = (e[0] << 24) + (e[1] << 16) + (e[2] << 8) + e[3], i = Z; (Z += t - 4), (Zi = [zt(), zt()]), (Zi.position0 = 0), (Zi.position1 = 0); let r = Z; Z = i; try { return zt(); } finally { Z = r; } }; Ii[255] = (e) => e.length == 4 ? new Date((e[0] * 16777216 + (e[1] << 16) + (e[2] << 8) + e[3]) * 1e3) : e.length == 8 ? new Date( ((e[0] << 22) + (e[1] << 14) + (e[2] << 6) + (e[3] >> 2)) / 1e6 + ((e[3] & 3) * 4294967296 + e[4] * 16777216 + (e[5] << 16) + (e[6] << 8) + e[7]) * 1e3 ) : e.length == 12 ? new Date( ((e[0] << 24) + (e[1] << 16) + (e[2] << 8) + e[3]) / 1e6 + ((e[4] & 128 ? -281474976710656 : 0) + e[6] * 1099511627776 + e[7] * 4294967296 + e[8] * 16777216 + (e[9] << 16) + (e[10] << 8) + e[11]) * 1e3 ) : new Date('invalid'); function j_(e) { let t = En, i = Z, r = nm, s = gr, n = os, a = xn, o = sm, l = Vs, h = Zi, u = new Uint8Array(Se.slice(0, En)), c = pt, d = pt.slice(0, pt.length), p = zi, f = Fo, g = e(); return ( (En = t), (Z = i), (nm = r), (gr = s), (os = n), (xn = a), (sm = o), (Vs = l), (Zi = h), (Se = u), (Fo = f), (pt = c), pt.splice(0, pt.length, ...d), (zi = p), (ft = new DataView(Se.buffer, Se.byteOffset, Se.byteLength)), g ); } function om() { (Se = null), (Vs = null), (pt = null); } function zN(e) { e.unpack ? (Ii[e.type] = e.unpack) : (Ii[e.type] = e); } var Zg = new Array(147); for (let e = 0; e < 256; e++) Zg[e] = +('1e' + Math.floor(45.15 - e * 0.30103)); var _u = new Dd({ useRecords: !1 }), f9 = _u.unpack, m9 = _u.unpackMultiple, g9 = _u.unpack, NN = { NEVER: 0, ALWAYS: 1, DECIMAL_ROUND: 3, DECIMAL_FIT: 4 }, UN = new Float32Array(1), v9 = new Uint8Array(UN.buffer, 0, 4), id; try { id = new TextEncoder(); } catch {} var Ld, Kg, Au = typeof Buffer < 'u', zp = Au ? Buffer.allocUnsafeSlow : Uint8Array, G_ = Au ? Buffer : Uint8Array, M1 = Au ? 4294967296 : 2144337920, le, jt, te = 0, Xr, qr = null, FN = /[\u0080-\uFFFF]/, wl = Symbol('record-id'), V_ = class extends Dd { constructor(e) { super(e), (this.offset = 0); let t, i, r, s, n, a, o = 0, l = G_.prototype.utf8Write ? function (S, _, M) { return le.utf8Write(S, _, M); } : id && id.encodeInto ? function (S, _) { return id.encodeInto(S, le.subarray(_)).written; } : !1, h = this; e || (e = {}); let u = e && e.sequential, c = e.structures || e.saveStructures, d = e.maxSharedStructures; if ((d == null && (d = c ? 32 : 0), d > 8160)) throw new Error('Maximum maxSharedStructure is 8160'); let p = e.maxOwnStructures; p == null && (p = c ? 32 : 64), u && !e.saveStructures && (this.structures = []); let f = d > 32 || p + d > 64, g = d + 64, m = d + p + 64; if (m > 8256) throw new Error('Maximum maxSharedStructure + maxOwnStructure is 8192'); let v = [], y = 0, b = 0; this.pack = this.encode = function (S, _) { if ( (le || ((le = new zp(8192)), (jt = new DataView(le.buffer, 0, 8192)), (te = 0)), (Xr = le.length - 10), Xr - te < 2048 ? ((le = new zp(le.length)), (jt = new DataView(le.buffer, 0, le.length)), (Xr = le.length - 10), (te = 0)) : (te = (te + 7) & 2147483640), (i = te), (a = h.structuredClone ? new Map() : null), h.bundleStrings ? ((qr = ['', '']), (le[te++] = 214), (le[te++] = 98), (qr.position = te - i), (te += 4)) : (qr = null), (r = h.structures), r) ) { r.uninitialized && (r = h._mergeStructures(h.getStructures())); let M = r.sharedLength || 0; if (M > d) throw new Error( 'Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to ' + r.sharedLength ); if (!r.transitions) { r.transitions = Object.create(null); for (let C = 0; C < M; C++) { let T = r[C]; if (!T) continue; let P, L = r.transitions; for (let D = 0, k = T.length; D < k; D++) { let W = T[D]; (P = L[W]), P || (P = L[W] = Object.create(null)), (L = P); } L[wl] = C + 64; } o = M; } u || (r.nextId = M + 64); } s && (s = !1), (n = r || []); try { if ((x(S), qr)) { jt.setUint32(qr.position + i, te - qr.position - i); let M = qr; (qr = null), x(M[0]), x(M[1]); } if (((h.offset = te), a && a.idsToInsert)) { (te += a.idsToInsert.length * 6), te > Xr && A(te), (h.offset = te); let M = jN(le.subarray(i, te), a.idsToInsert); return (a = null), M; } return _ & GN ? ((le.start = i), (le.end = te), le) : le.subarray(i, te); } finally { if (r) { if ((b < 10 && b++, y > 1e4)) (r.transitions = null), (b = 0), (y = 0), v.length > 0 && (v = []); else if (v.length > 0 && !u) { for (let M = 0, C = v.length; M < C; M++) v[M][wl] = 0; v = []; } if (s && h.saveStructures) { let M = r.sharedLength || d; r.length > M && (r = r.slice(0, M)); let C = le.subarray(i, te); return h.saveStructures(r, o) === !1 ? (h._mergeStructures(h.getStructures()), h.pack(S)) : ((o = M), C); } } _ & VN && (te = i); } }; let x = (S) => { te > Xr && (le = A(te)); var _ = typeof S, M; if (_ === 'string') { let C = S.length; if (qr && C >= 8 && C < 4096) { let L = FN.test(S); (qr[L ? 0 : 1] += S), (le[te++] = 193), x(L ? -C : C); return; } let T; C < 32 ? (T = 1) : C < 256 ? (T = 2) : C < 65536 ? (T = 3) : (T = 5); let P = C * 3; if ((te + P > Xr && (le = A(te + P)), C < 64 || !l)) { let L, D, k, W = te + T; for (L = 0; L < C; L++) (D = S.charCodeAt(L)), D < 128 ? (le[W++] = D) : D < 2048 ? ((le[W++] = (D >> 6) | 192), (le[W++] = (D & 63) | 128)) : (D & 64512) === 55296 && ((k = S.charCodeAt(L + 1)) & 64512) === 56320 ? ((D = 65536 + ((D & 1023) << 10) + (k & 1023)), L++, (le[W++] = (D >> 18) | 240), (le[W++] = ((D >> 12) & 63) | 128), (le[W++] = ((D >> 6) & 63) | 128), (le[W++] = (D & 63) | 128)) : ((le[W++] = (D >> 12) | 224), (le[W++] = ((D >> 6) & 63) | 128), (le[W++] = (D & 63) | 128)); M = W - te - T; } else M = l(S, te + T, P); M < 32 ? (le[te++] = 160 | M) : M < 256 ? (T < 2 && le.copyWithin(te + 2, te + 1, te + 1 + M), (le[te++] = 217), (le[te++] = M)) : M < 65536 ? (T < 3 && le.copyWithin(te + 3, te + 2, te + 2 + M), (le[te++] = 218), (le[te++] = M >> 8), (le[te++] = M & 255)) : (T < 5 && le.copyWithin(te + 5, te + 3, te + 3 + M), (le[te++] = 219), jt.setUint32(te, M), (te += 4)), (te += M); } else if (_ === 'number') if (S >>> 0 === S) S < 64 ? (le[te++] = S) : S < 256 ? ((le[te++] = 204), (le[te++] = S)) : S < 65536 ? ((le[te++] = 205), (le[te++] = S >> 8), (le[te++] = S & 255)) : ((le[te++] = 206), jt.setUint32(te, S), (te += 4)); else if (S >> 0 === S) S >= -32 ? (le[te++] = 256 + S) : S >= -128 ? ((le[te++] = 208), (le[te++] = S + 256)) : S >= -32768 ? ((le[te++] = 209), jt.setInt16(te, S), (te += 2)) : ((le[te++] = 210), jt.setInt32(te, S), (te += 4)); else { let C; if ((C = this.useFloat32) > 0 && S < 4294967296 && S >= -2147483648) { (le[te++] = 202), jt.setFloat32(te, S); let T; if (C < 4 || (T = S * Zg[((le[te] & 127) << 1) | (le[te + 1] >> 7)]) >> 0 === T) { te += 4; return; } else te--; } (le[te++] = 203), jt.setFloat64(te, S), (te += 8); } else if (_ === 'object') if (!S) le[te++] = 192; else { if (a) { let T = a.get(S); if (T) { if (!T.id) { let P = a.idsToInsert || (a.idsToInsert = []); T.id = P.push(T); } (le[te++] = 214), (le[te++] = 112), jt.setUint32(te, T.id), (te += 4); return; } else a.set(S, { offset: te - i }); } let C = S.constructor; if (C === Object) w(S, !0); else if (C === Array) { (M = S.length), M < 16 ? (le[te++] = 144 | M) : M < 65536 ? ((le[te++] = 220), (le[te++] = M >> 8), (le[te++] = M & 255)) : ((le[te++] = 221), jt.setUint32(te, M), (te += 4)); for (let T = 0; T < M; T++) x(S[T]); } else if (C === Map) { (M = S.size), M < 16 ? (le[te++] = 128 | M) : M < 65536 ? ((le[te++] = 222), (le[te++] = M >> 8), (le[te++] = M & 255)) : ((le[te++] = 223), jt.setUint32(te, M), (te += 4)); for (let [T, P] of S) x(T), x(P); } else { for (let T = 0, P = Ld.length; T < P; T++) { let L = Kg[T]; if (S instanceof L) { let D = Ld[T]; if (D.write) { D.type && ((le[te++] = 212), (le[te++] = D.type), (le[te++] = 0)), x(D.write.call(this, S)); return; } let k = le, W = jt, X = te; le = null; let z; try { z = D.pack.call( this, S, (j) => ((le = k), (k = null), (te += j), te > Xr && A(te), { target: le, targetView: jt, position: te - j }), x ); } finally { k && ((le = k), (jt = W), (te = X), (Xr = le.length - 10)); } z && (z.length + te > Xr && A(z.length + te), (te = kN(z, le, te, D.type))); return; } } w(S, !S.hasOwnProperty); } } else if (_ === 'boolean') le[te++] = S ? 195 : 194; else if (_ === 'bigint') { if (S < BigInt(1) << BigInt(63) && S >= -(BigInt(1) << BigInt(63))) (le[te++] = 211), jt.setBigInt64(te, S); else if (S < BigInt(1) << BigInt(64) && S > 0) (le[te++] = 207), jt.setBigUint64(te, S); else if (this.largeBigIntToFloat) (le[te++] = 203), jt.setFloat64(te, Number(S)); else throw new RangeError( S + ' was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64' ); te += 8; } else if (_ === 'undefined') this.encodeUndefinedAsNil ? (le[te++] = 192) : ((le[te++] = 212), (le[te++] = 0), (le[te++] = 0)); else if (_ === 'function') x(this.writeFunction && this.writeFunction()); else throw new Error('Unknown type: ' + _); }, w = this.useRecords === !1 ? this.variableMapSize ? (S) => { let _ = Object.keys(S), M = _.length; M < 16 ? (le[te++] = 128 | M) : M < 65536 ? ((le[te++] = 222), (le[te++] = M >> 8), (le[te++] = M & 255)) : ((le[te++] = 223), jt.setUint32(te, M), (te += 4)); let C; for (let T = 0; T < M; T++) x((C = _[T])), x(S[C]); } : (S, _) => { le[te++] = 222; let M = te - i; te += 2; let C = 0; for (let T in S) (_ || S.hasOwnProperty(T)) && (x(T), x(S[T]), C++); (le[M++ + i] = C >> 8), (le[M + i] = C & 255); } : (S) => { let _ = Object.keys(S), M, C = n.transitions || (n.transitions = Object.create(null)), T = 0; for (let L = 0, D = _.length; L < D; L++) { let k = _[L]; (M = C[k]), M || ((M = C[k] = Object.create(null)), T++), (C = M); } let P = C[wl]; if (P) P >= 96 && f ? ((le[te++] = ((P -= 96) & 31) + 96), (le[te++] = P >> 5)) : (le[te++] = P); else { (P = n.nextId), P || (P = 64), P < g && this.shouldShareStructure && !this.shouldShareStructure(_) ? ((P = n.nextOwnId), P < m || (P = g), (n.nextOwnId = P + 1)) : (P >= m && (P = g), (n.nextId = P + 1)); let L = (_.highByte = P >= 96 && f ? (P - 96) >> 5 : -1); (C[wl] = P), (n[P - 64] = _), P < g ? ((_.isShared = !0), (n.sharedLength = P - 63), (s = !0), L >= 0 ? ((le[te++] = (P & 31) + 96), (le[te++] = L)) : (le[te++] = P)) : (L >= 0 ? ((le[te++] = 213), (le[te++] = 114), (le[te++] = (P & 31) + 96), (le[te++] = L)) : ((le[te++] = 212), (le[te++] = 114), (le[te++] = P)), T && (y += b * T), v.length >= p && (v.shift()[wl] = 0), v.push(C), x(_)); } for (let L = 0, D = _.length; L < D; L++) x(S[_[L]]); }, A = (S) => { let _; if (S > 16777216) { if (S - i > M1) throw new Error('Packed buffer would be larger than maximum buffer size'); _ = Math.min(M1, Math.round(Math.max((S - i) * (S > 67108864 ? 1.25 : 2), 4194304) / 4096) * 4096); } else _ = ((Math.max((S - i) << 2, le.length - 1) >> 12) + 1) << 12; let M = new zp(_); return ( (jt = new DataView(M.buffer, 0, _)), le.copy ? le.copy(M, 0, i, S) : M.set(le.slice(i, S)), (te -= i), (i = 0), (Xr = M.length - 10), (le = M) ); }; } useBuffer(e) { (le = e), (jt = new DataView(le.buffer, le.byteOffset, le.byteLength)), (te = 0); } }; Kg = [Date, Set, Error, RegExp, ArrayBuffer, Object.getPrototypeOf(Uint8Array.prototype).constructor, R_]; Ld = [ { pack(e, t, i) { let r = e.getTime() / 1e3; if ((this.useTimestamp32 || e.getMilliseconds() === 0) && r >= 0 && r < 4294967296) { let { target: s, targetView: n, position: a } = t(6); (s[a++] = 214), (s[a++] = 255), n.setUint32(a, r); } else if (r > 0 && r < 17179869184) { let { target: s, targetView: n, position: a } = t(10); (s[a++] = 215), (s[a++] = 255), n.setUint32(a, e.getMilliseconds() * 4e6 + ((r / 1e3 / 4294967296) >> 0)), n.setUint32(a + 4, r); } else if (isNaN(r)) { if (this.onInvalidDate) return t(0), i(this.onInvalidDate()); let { target: s, targetView: n, position: a } = t(3); (s[a++] = 212), (s[a++] = 255), (s[a++] = 255); } else { let { target: s, targetView: n, position: a } = t(15); (s[a++] = 199), (s[a++] = 12), (s[a++] = 255), n.setUint32(a, e.getMilliseconds() * 1e6), n.setBigInt64(a + 4, BigInt(Math.floor(r))); } } }, { pack(e, t, i) { let r = Array.from(e), { target: s, position: n } = t(this.structuredClone ? 3 : 0); this.structuredClone && ((s[n++] = 212), (s[n++] = 115), (s[n++] = 0)), i(r); } }, { pack(e, t, i) { let { target: r, position: s } = t(this.structuredClone ? 3 : 0); this.structuredClone && ((r[s++] = 212), (r[s++] = 101), (r[s++] = 0)), i([e.name, e.message]); } }, { pack(e, t, i) { let { target: r, position: s } = t(this.structuredClone ? 3 : 0); this.structuredClone && ((r[s++] = 212), (r[s++] = 120), (r[s++] = 0)), i([e.source, e.flags]); } }, { pack(e, t) { this.structuredClone ? E1(e, 16, t) : C1(Au ? Buffer.from(e) : new Uint8Array(e), t); } }, { pack(e, t) { let i = e.constructor; i !== G_ && this.structuredClone ? E1(e, k_.indexOf(i.name), t) : C1(e, t); } }, { pack(e, t) { let { target: i, position: r } = t(1); i[r] = 193; } } ]; function E1(e, t, i, r) { let s = e.byteLength; if (s + 1 < 256) { var { target: n, position: a } = i(4 + s); (n[a++] = 199), (n[a++] = s + 1); } else if (s + 1 < 65536) { var { target: n, position: a } = i(5 + s); (n[a++] = 200), (n[a++] = (s + 1) >> 8), (n[a++] = (s + 1) & 255); } else { var { target: n, position: a, targetView: o } = i(7 + s); (n[a++] = 201), o.setUint32(a, s + 1), (a += 4); } (n[a++] = 116), (n[a++] = t), n.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength), a); } function C1(e, t) { let i = e.byteLength; var r, s; if (i < 256) { var { target: r, position: s } = t(i + 2); (r[s++] = 196), (r[s++] = i); } else if (i < 65536) { var { target: r, position: s } = t(i + 3); (r[s++] = 197), (r[s++] = i >> 8), (r[s++] = i & 255); } else { var { target: r, position: s, targetView: n } = t(i + 5); (r[s++] = 198), n.setUint32(s, i), (s += 4); } r.set(e, s); } function kN(e, t, i, r) { let s = e.length; switch (s) { case 1: t[i++] = 212; break; case 2: t[i++] = 213; break; case 4: t[i++] = 214; break; case 8: t[i++] = 215; break; case 16: t[i++] = 216; break; default: s < 256 ? ((t[i++] = 199), (t[i++] = s)) : s < 65536 ? ((t[i++] = 200), (t[i++] = s >> 8), (t[i++] = s & 255)) : ((t[i++] = 201), (t[i++] = s >> 24), (t[i++] = (s >> 16) & 255), (t[i++] = (s >> 8) & 255), (t[i++] = s & 255)); } return (t[i++] = r), t.set(e, i), (i += s), i; } function jN(e, t) { let i, r = t.length * 6, s = e.length - r; for (t.sort((n, a) => (n.offset > a.offset ? 1 : -1)); (i = t.pop()); ) { let n = i.offset, a = i.id; e.copyWithin(n + r, n, s), (r -= 6); let o = n + r; (e[o++] = 214), (e[o++] = 105), (e[o++] = a >> 24), (e[o++] = (a >> 16) & 255), (e[o++] = (a >> 8) & 255), (e[o++] = a & 255), (s = n); } return e; } function tl(e) { if (e.Class) { if (!e.pack && !e.write) throw new Error('Extension has no pack or write function'); if (e.pack && !e.type) throw new Error('Extension has no type (numeric code to identify the extension)'); Kg.unshift(e.Class), Ld.unshift(e); } zN(e); } var H_ = new V_({ useRecords: !1 }), y9 = H_.pack, x9 = H_.pack, { NEVER: b9, ALWAYS: w9, DECIMAL_ROUND: _9, DECIMAL_FIT: A9 } = NN, GN = 512, VN = 1024, T1 = new V_({ structuredClone: !0 }); tl({ Class: Qt.prototype.constructor, type: 1, write(e) { return { ...e }; }, read(e) { return Object.setPrototypeOf(e, Qt.prototype), e; } }); tl({ Class: rt.prototype.constructor, type: 2, write(e) { return [...e]; }, read(e) { return Object.setPrototypeOf(e, rt.prototype), e; } }); tl({ Class: ki.prototype.constructor, type: 3, write(e) { return [...e]; }, read(e) { return Object.setPrototypeOf(e, ki.prototype), e; } }); tl({ Class: g1.prototype.constructor, type: 4, write(e) { return e.id; }, read(e) { return new g1(e); } }); tl({ Class: v1.prototype.constructor, type: 5, write(e) { return e.data; }, read(e) { return new v1(e); } }); tl({ Class: mi.prototype.constructor, type: 6, write(e) { return { ...e }; }, read(e) { return Object.setPrototypeOf(e, mi.prototype), e; } }); function HN(e) { var t = 0; if (e.length === 0) return t; for (let i = 0; i < e.length; i++) { let r = e[i]; (t = (t << 5) - t + r), (t = t & t); } return t; } function lm(e) { if (Vg(e)) return e; if (Array.isArray(e)) return e.map(lm); if (typeof e == 'object' && e !== null) { let t = {}; for (let i of Object.keys(e).sort()) t[i] = lm(e[i]); return Object.setPrototypeOf(t, Object.getPrototypeOf(e)), t; } else return e; } var hm; ((e) => { function t(s) { return T1.pack(s); } e.serialize = t; function i(s) { return T1.unpack(s); } e.deserialize = i; function r(s) { return HN(t(lm(s))).toString(); } e.checksum = r; })(hm || (hm = {})); var _l = { LookAt: [], Follow: [], MouseHover: ['Transition'], Scroll: ['Transition'], Start: ['Transition', 'Audio', 'Video'], Conditional: ['Transition', 'Audio', 'Video'], MouseDown: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], MouseUp: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], MousePress: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], KeyDown: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], KeyUp: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], KeyPress: ['Transition', 'Audio', 'Video', 'Link', 'Reset'], GameControl: ['Transition', 'Audio'], Collision: ['Transition', 'Audio'] }, P1; ((e) => { function t(r) { return ( r.type === 'MouseDown' || r.type === 'MouseUp' || r.type === 'MousePress' || r.type === 'KeyDown' || r.type === 'KeyUp' || r.type === 'KeyPress' ); } e.is = t; function i(r) { return r === 'MouseDown' || r === 'MouseUp' || r === 'MousePress' ? { type: r, disabled: !1, toggle: !1, actions: new rt() } : { type: r, disabled: !1, key: void 0, toggle: !1, actions: new rt() }; } e.defaultData = i; })(P1 || (P1 = {})); var Od; ((e) => { function t(i) { return { type: 'Property', value: [i ?? null, 'position', 'x'] }; } (e.propertyDefaultData = t), (e.valueDefaultData = { type: 'Literal', value: 0 }); })(Od || (Od = {})); var cm; ((e) => { function t(s) { return { type: 'Comparison', operator: '==', lOperand: Od.propertyDefaultData(s), rOperand: { ...Od.valueDefaultData } }; } e.comparisonDefaultData = t; function i(s) { return { type: 'Distance', toObject: s ?? null, fromObject: s ?? null, distance: 200 }; } e.distanceDefaultData = i; function r(s, n) { return { type: 'State', object: s ?? null, state: n ?? null }; } e.stateDefaultData = r; })(cm || (cm = {})); var D1; ((e) => { function t(r) { return r.type === 'Conditional'; } e.is = t; function i(r) { return { type: 'Conditional', disabled: !1, inActions: new rt(), outActions: new rt(), condition: cm.distanceDefaultData(r) }; } e.defaultData = i; })(D1 || (D1 = {})); var dm; ((e) => (e.defaultData = { type: 'Follow', disabled: !1, maxDelta: 0, dampingFactor: 1, target: 'cursor', plane: 'custom', resetOnPointerLeave: !0, resetAfterDistanceLimit: !0, enabledTranslation: [!0, !0, !0], limitDistanceEnabled: !1, limitDistance: 1e3, snapDelay: 0, resetSpeed: 5 }))(dm || (dm = {})); var um; ((e) => (e.defaultData = { type: 'LookAt', disabled: !1, distance: 1e3, dampingFactor: 1, target: 'cursor', tilt: 'up', axis: 'z', plane: 'custom', resetOnPointerLeave: !0, resetAfterDistanceLimit: !0, enabledRotation: [!0, !0, !0], limitDistanceEnabled: !1, limitDistance: 1e3, snapDelay: 0, resetSpeed: 5 }))(um || (um = {})); var L1; ((e) => { function t(r) { return r.type === 'MouseHover'; } e.is = t; function i() { return { type: 'MouseHover', disabled: !1, actions: new rt() }; } e.defaultData = i; })(L1 || (L1 = {})); var O1; ((e) => { function t(r) { return r.type === 'Scroll'; } e.is = t; function i() { return { type: 'Scroll', disabled: !1, steps: 100, trigger: 'load', startFrom: 'enter', enterAnchor: 'top', startOffset: 0, endAfter: 400, actions: new rt() }; } e.defaultData = i; })(O1 || (O1 = {})); var I1; ((e) => { function t(r) { return r.type === 'Start'; } e.is = t; function i() { return { type: 'Start', disabled: !1, actions: new rt() }; } e.defaultData = i; })(I1 || (I1 = {})); var R1; ((e) => { function t(r) { return r.type === 'Collision'; } e.is = t; function i() { return { type: 'Collision', disabled: !1, toggle: !1, target: 'character', actions: new rt() }; } e.defaultData = i; })(R1 || (R1 = {})); var mo; ((e) => { function t(r, s) { return r[0] === s[0] && r[1] === s[1]; } e.isEqual = t; function i(r, s, n) { return [r[0] + (s[0] - r[0]) * n, r[1] + (s[1] - r[1]) * n]; } e.lerp = i; })(mo || (mo = {})); var ma; ((e) => { function t(l, h) { return l[0] === h[0] && l[1] === h[1] && l[2] === h[2]; } e.isEqual = t; function i(l, h) { return [l[0] + h[0], l[1] + h[1], l[2] + h[2]]; } e.add = i; function r(l, h) { return [l[0] - h[0], l[1] - h[1], l[2] - h[2]]; } e.sub = r; function s(l, h) { return [l[0] / h[0], l[1] / h[1], l[2] / h[2]]; } e.div = s; function n(l, h) { return [l[0] * h[0], l[1] * h[1], l[2] * h[2]]; } e.mul = n; function a(l, h) { return Math.hypot(l[0] - h[0], l[1] - h[1], l[2] - h[2]); } e.dist = a; function o(l, h, u) { return [l[0] + (h[0] - l[0]) * u, l[1] + (h[1] - l[1]) * u, l[2] + (h[2] - l[2]) * u]; } e.lerp = o; })(ma || (ma = {})); var Id; ((e) => { function t(r, s) { return r[0] === s[0] && r[1] === s[1] && r[2] === s[2] && r[3] === s[3]; } e.isEqual = t; function i(r, s, n) { return [r[0] + (s[0] - r[0]) * n, r[1] + (s[1] - r[1]) * n, r[2] + (s[2] - r[2]) * n, r[3] + (s[3] - r[3]) * n]; } e.lerp = i; })(Id || (Id = {})); var ko; ((e) => { e.identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; function t(s, n) { for (let a = 0; a < 16; a++) if (s[a] !== n[a]) return !1; return !0; } e.isEqual = t; function i(s) { return s ?? e.identity; } e.simplify = i; function r(s, n) { let a = n.slice(0); for (var o = 0, l = n.length; o < l; o += 3) { let h = s[3] * n[o] + s[7] * n[o + 1] + s[11] * n[o + 2] + s[15]; (a[o] = (s[0] * n[o] + s[4] * n[o + 1] + s[8] * n[o + 2] + s[12]) / h), (a[o + 1] = (s[1] * n[o] + s[5] * n[o + 1] + s[9] * n[o + 2] + s[13]) / h), (a[o + 2] = (s[2] * n[o] + s[6] * n[o + 1] + s[10] * n[o + 2] + s[14]) / h); } return a; } e.applyMatrix4 = r; })(ko || (ko = {})); var $i; ((e) => { function t(o) { return typeof o == 'object' && typeof o.r == 'number' && typeof o.g == 'number' && typeof o.b == 'number'; } (e.isRGB = t), (e.white = { r: 1, g: 1, b: 1 }), (e.red = { r: 1, g: 0, b: 0 }), (e.black = { r: 0, g: 0, b: 0 }); function i(o) { return { r: Math.round(o.r * 255), g: Math.round(o.g * 255), b: Math.round(o.b * 255), a: 1 }; } e.toRgb255a1 = i; function r(o) { return { r: o.r, g: o.g, b: o.b }; } e.clone = r; function s(o) { return (o = Math.floor(o)), { r: ((o >> 16) & 255) / 255, g: ((o >> 8) & 255) / 255, b: (o & 255) / 255 }; } e.fromHex = s; function n(o, l) { return o.r === l.r && o.g === l.g && o.b === l.b; } e.equals = n; function a(o, l, h) { return { r: o.r + (l.r - o.r) * h, g: o.g + (l.g - o.g) * h, b: o.b + (l.b - o.b) * h }; } e.lerp = a; })($i || ($i = {})); var kr; ((e) => { (e.white = { ...$i.white, a: 1 }), (e.transparent = { ...$i.white, a: 0 }); function t(a) { return { r: a[0], g: a[1], b: a[2], a: a[3] }; } e.from0to1 = t; function i(a, o) { return { ...$i.fromHex(a), a: o }; } e.fromHexAndA = i; function r(a) { return { r: Math.round(a.r * 255), g: Math.round(a.g * 255), b: Math.round(a.b * 255), a: a.a }; } e.toRgb255a1 = r; function s(a, o) { return $i.equals(a, o) && a.a === o.a; } e.equals = s; function n(a, o, l) { return { r: a.r + (o.r - a.r) * l, g: a.g + (o.g - a.g) * l, b: a.b + (o.b - a.b) * l, a: a.a + (o.a - a.a) * l }; } e.lerp = n; })(kr || (kr = {})); var pm; ((e) => (e.identity = { position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }))(pm || (pm = {})); var B1; ((e) => (e.defaultData = { mass: 1, stiffness: 80, damping: 10, velocity: 0 }))(B1 || (B1 = {})); var z1; ((e) => (e.defaultData = { control1: [0.5, 0.05], control2: [0.1, 0.3] }))(z1 || (z1 = {})); var _a; ((e) => { e.all = ['PerspectiveCamera', 'OrthographicCamera']; function t(i) { return e.all.includes(i); } e.is = t; })(_a || (_a = {})); var xh; ((e) => { (e.DefaultUp = [0, 1, 0]), (e.DefaultTargetOffset = 1e3), (e.defaultData = { far: 1e5, type: 'OrthographicCamera', perspective: { near: 70, fov: 45, zoom: 1 }, orthographic: { near: -1e5, zoom: 1, autoZoom: !1, autoZoomFrustumSize: 790 }, up: e.DefaultUp, isUpVectorFlipped: !1, targetOffset: e.DefaultTargetOffset }); function t(i) { return i.type === 'PerspectiveCamera' ? i.perspective.zoom : i.orthographic.zoom; } e.getZoom = t; })(xh || (xh = {})); var bn; ((e) => { function t(r, s = 0.1) { return { disabled: !1, type: 'linear', hideBase: !1, count: 3, radial: { radius: Math.max(r[0], r[1]) * 2, start: 0, end: 360, alignment: !1, axis: 'y', scale: [1, 1, 1], rotation: [0, 0, 0], position: [0, 0, 0] }, toObject: { object: '', spreadType: 'random', scale: [0, 0, 0], rotation: [0, 0, 0], position: [0, 0, 0], axis: 'x', seed: 0, count: 99, align: 'normal' }, linear: { scale: [1, 1, 1], rotation: [0, 0, 0], position: [r[0] + r[0] * s, 0, 0] }, grid: { count: [2, 2, 2], size: r.map((n) => n * (1 + s)), useCenter: !0 }, randomness: !1, randomnessObject: { strength: 100, scale: [0, 0, 0], rotation: [0, 0, 0], position: [0, 0, 0], movement: 1, seed: 0, freqScale: 10, noiseType: 'perlin' } }; } e.defaultData = t; function i(r, s) { let n = { ...r }; if ( (W_.forEach((a) => { Object.assign(n, { [a]: s[a] ?? r[a] }); }), (n.radial = { ...r.radial }), s.radial) ) { let a = r.radial, o = s.radial; X_.forEach((l) => { Object.assign(n.radial, { [l]: o[l] ?? a[l] }); }); } if (((n.linear = { ...r.linear }), s.linear)) { let a = r.linear, o = s.linear; q_.forEach((l) => { Object.assign(n.linear, { [l]: o[l] ?? a[l] }); }); } if (((n.grid = { ...r.grid }), s.grid)) { let a = r.grid, o = s.grid; Y_.forEach((l) => { Object.assign(n.grid, { [l]: o[l] ?? a[l] }); }); } if (((n.toObject = { ...r.toObject }), s.toObject)) { let a = r.toObject, o = s.toObject; Q_.forEach((l) => { Object.assign(n.toObject, { [l]: o[l] ?? a[l] }); }); } if (((n.randomnessObject = { ...r.randomnessObject }), s.randomnessObject)) { let a = r.randomnessObject, o = s.randomnessObject; Z_.forEach((l) => { Object.assign(n.randomnessObject, { [l]: o[l] ?? a[l] }); }); } return n; } e.merge = i; })(bn || (bn = {})); var fm; ((e) => { e.defaultData = { radial: {}, linear: {}, grid: {}, toObject: {}, randomnessObject: {} }; let t = ['radial', 'linear', 'grid', 'toObject', 'randomnessObject']; function i(r, s) { let n = []; r.count !== void 0 && n.push({ type: 0, path: s, props: { count: r.count } }); for (let a of t) { let o = r[a]; o && Object.keys(o).length > 0 && n.push({ type: 0, path: [...s, a], props: o }); } return n; } e.toOps = i; })(fm || (fm = {})); var W_ = ['count'], X_ = ['radius', 'start', 'end', 'position', 'scale', 'rotation'], q_ = ['position', 'scale', 'rotation'], Y_ = ['count', 'size'], Q_ = ['count', 'position', 'scale', 'rotation'], Z_ = ['strength', 'scale', 'rotation', 'position', 'movement', 'seed', 'freqScale'], bh; ((e) => { let t = { opacity: 1, blendFunction: 13, enabled: !1 }; e.defaultData = { enabled: !1, pixelation: { ...t, blendFunction: 16, granularity: 15 }, bloom: { ...t, blendFunction: 16, intensity: 1, blurScale: 1, luminanceThreshold: 0.25, luminanceSmoothing: 0.025, kernelSize: 3 }, chromaticAberration: { ...t, offset: [2, 2] }, vignette: { ...t, darkness: 1, offset: 0 }, hueSaturation: { ...t, hue: 3, saturation: 0 }, brightnessContrast: { ...t, brightness: 0.25, contrast: 0 }, depthOfField: { ...t, focalLength: 2, focusDistance: 2, bokehScale: 2 }, noise: { ...t, blendFunction: 16 } }; })(bh || (bh = {})); var mm; ((e) => { e.all = ['PointLight', 'SpotLight', 'DirectionalLight', 'HemisphereLight']; function t(i) { return e.all.includes(i); } e.is = t; })(mm || (mm = {})); var gm; ((e) => { function t(r) { return i(r); } e.defaultData = t; function i(r) { if (r === 'PointLight') return { type: r, color: kr.white, intensity: 1, distance: 2e3, decay: 1, shadows: !0, shadowResolution: 1024, shadowRadius: 1, depth: 1e5 }; if (r === 'SpotLight') return { type: r, color: kr.white, intensity: 1, distance: 2e3, decay: 1, shadows: !0, penumbra: 0, angle: (30 / 180) * Math.PI, depth: 1e5, shadowResolution: 1024, shadowRadius: 1 }; if (r === 'DirectionalLight') return { type: r, color: kr.white, intensity: 1, shadows: !0, size: 2e3, depth: 1e5, shadowResolution: 1024, shadowRadius: 1 }; throw new Error('not implemented'); } })(gm || (gm = {})); var vm; ((e) => { e.defaultData = { castShadow: !0, receiveShadow: !0 }; function t(i, r) { return i.castShadow === r.castShadow && i.receiveShadow === r.receiveShadow; } e.equals = t; })(vm || (vm = {})); var ym; ((e) => { e.defaultData = { flatShading: !1, wireframe: !1, side: 0 }; function t(i, r) { return i.flatShading === r.flatShading && i.side === r.side && i.wireframe === r.wireframe; } e.equals = t; })(ym || (ym = {})); var xm; ((e) => (e.defaultData = { ...ym.defaultData, ...vm.defaultData }))(xm || (xm = {})); var Rd; ((e) => ((e.defaultVideo = { data: '', thumb: '/_assets/_videos/catThumb.png', type: 'video', name: 'Cat video' }), (e.maxSize = 3e7)))( Rd || (Rd = {}) ); var N1; ((e) => { function t(i) { return ( i === 'texture' || i === 'video' || i === 'color' || i === 'depth' || i === 'normal' || i === 'gradient' || i === 'noise' || i === 'fresnel' || i === 'rainbow' || i === 'toon' || i === 'outline' || i === 'transmission' || i === 'matcap' || i === 'displace' || i === 'light' ); } e.is = t; })(N1 || (N1 = {})); var U1; ((e) => { function t(i) { return i === 'phong' || i === 'toon' || i === 'lambert' || i === 'physical'; } e.is = t; })(U1 || (U1 = {})); var K_ = ['mode', 'gradientType', 'noiseType', 'displacementType', 'projection', 'cnormal', 'crop', 'axis', 'side'], WN = ['wrapping', 'image', 'video'], xr; ((e) => { function t(n, a) { let { texture: o, ...l } = a; if ((Object.assign(n, l), o)) { let h = n.texture; h && Object.assign(h, o); } } e.patch = t; function i(n, a) { return n === 'light' && a ? r(a) : s(n); } e.defaultData = i; function r(n) { switch (n) { case 'phong': return { category: 'phong', specular: { r: 0.2, g: 0.2, b: 0.2 }, shininess: 5, type: 'light', alpha: 0.6, visible: !0, mode: 0 }; case 'toon': return { category: 'toon', specular: { r: 0.2, g: 0.2, b: 0.2 }, shininess: 10, type: 'light', alpha: 1, visible: !0, mode: 0 }; case 'lambert': return { category: 'lambert', emissive: { r: 0, g: 0, b: 0 }, type: 'light', alpha: 1, visible: !0, mode: 0 }; case 'physical': return { category: 'physical', roughness: 0.2, metalness: 0.2, reflectivity: 0.2, type: 'light', alpha: 1, visible: !0, mode: 0 }; } } function s(n) { switch (n) { case 'texture': return { alpha: 1, visible: !0, size: [128, 128], mode: 0, axis: 'x', side: 2, type: 'texture', projection: 0, texture: { image: 'image_0', wrapping: 1e3, repeat: [1, 1], offset: [0, 0] }, crop: !1 }; case 'video': return { alpha: 1, visible: !0, size: [128, 128], mode: 0, axis: 'x', side: 2, type: 'video', projection: 0, texture: { video: Rd.defaultVideo, wrapping: 1001, repeat: [1, 1], offset: [0, 0] }, crop: !0 }; case 'color': return { type: 'color', alpha: 1, visible: !0, mode: 0, color: $i.fromHex(5526619) }; case 'depth': return { type: 'depth', alpha: 1, visible: !0, mode: 0, gradientType: 1, smooth: !1, isVector: !0, isWorldSpace: !1, origin: [0, 0, 0], direction: [1, 0, 0], colors: [ [1, 1, 1, 1], [0, 0, 0, 1] ], steps: [0, 1], near: 50, far: 200 }; case 'normal': return { type: 'normal', alpha: 1, visible: !0, mode: 0, cnormal: [1, 1, 1] }; case 'gradient': return { type: 'gradient', alpha: 1, visible: !0, mode: 0, gradientType: 0, smooth: !1, colors: [ [0, 0, 0, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1] ], steps: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1], num: 2, angle: 0, offset: [0, 0], morph: [0, 0] }; case 'noise': return { type: 'noise', alpha: 1, visible: !0, mode: 0, size: [100, 100, 100], noiseType: 0, scale: 1, move: 1, colorA: { ...$i.fromHex(6710886), a: 1 }, colorB: { ...$i.fromHex(6710886), a: 1 }, colorC: { ...$i.fromHex(16777215), a: 1 }, colorD: { ...$i.fromHex(16777215), a: 1 }, distortion: [1, 1], fA: [1.7, 9.2], fB: [8.3, 2.8] }; case 'fresnel': return { type: 'fresnel', alpha: 1, visible: !0, mode: 0, color: kr.fromHexAndA(16777215, 1), bias: 0.1, scale: 1, intensity: 2, factor: 1 }; case 'rainbow': return { type: 'rainbow', alpha: 1, visible: !0, mode: 0, filmThickness: 30, movement: 0, wavelengths: [0, 0, 0], noiseStrength: 0, noiseScale: 1, offset: [0, 0, 0] }; case 'toon': return { type: 'toon', alpha: 1, visible: !0, mode: 0, positioning: 2, colors: [ [0, 0, 0, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1] ], steps: [0, 0.475, 0.525, 1, 1, 1, 1, 1, 1, 1], num: 4, source: [0, 1e3, 0], isWorldSpace: !0, noiseStrength: 0, noiseScale: 1, shadowColor: kr.fromHexAndA(0, 0), offset: [0, 0, 0] }; case 'outline': return { type: 'outline', alpha: 1, visible: !0, mode: 0, outlineColor: kr.fromHexAndA(0, 1), contourColor: kr.fromHexAndA(0, 1), outlineWidth: 2, contourWidth: 5, outlineThreshold: 0.4, contourThreshold: 0, outlineSmoothing: 0, contourFrequency: 10, contourDirection: [0, 1, 0], positionalLines: !1, compensation: !0 }; case 'matcap': return { type: 'matcap', alpha: 1, visible: !0, mode: 0, texture: { image: 'matcap_0', wrapping: 1001, repeat: [1, 1], offset: [0, 0] } }; case 'transmission': return { type: 'transmission', alpha: 1, visible: !0, mode: 0, thickness: 10, ior: 1.5, roughness: 1 }; case 'displace': return { type: 'displace', displacementType: 'noise', noiseType: 0, scale: 10, movement: 1, offset: [0, 0, 0], intensity: 8, visible: !0 }; } } })(xr || (xr = {})); var nr; ((e) => { function t(h) { return !h.layers.some( (u) => (u.data.type === 'texture' && u.data.projection !== 0) || (u.data.type === 'depth' && !u.data.isWorldSpace) || u.data.type === 'noise' || u.data.type === 'displace' ); } e.isMergable = t; function i(h) { let u = ''; return ( h.layers.forEach((c) => { Object.entries(c.data).forEach(([d, p]) => { (u += `${d}${p}`), Array.isArray(p) ? p.forEach((f) => (u += `${f}`)) : typeof p == 'object' ? Object.values(p).forEach((f) => { typeof f == 'number' ? (u += `${f.toFixed(4)}`) : (u += `${f}`); }) : (u += `${p}`); }); }), u ); } e.getHash = i; function r() { return { layers: new rt() }; } e.defaultEmptyData = r; function s(h = 'layer1', u = 'layer2') { return a('phong', h, u); } e.defaultData = s; function n(h, u) { return { ...h, name: u }; } e.withName = n; function a(h, u = 'layer1', c = 'layer2') { let d = new rt(); return ( d.push({ fi: 0, data: xr.defaultData('light', h), id: u }), d.push({ fi: 1, data: xr.defaultData('color'), id: c }), { layers: d } ); } e.defaultTwoLayerData = a; function o(h, u = 'phong', c = 'layer1', d = 'layer2') { let p = xr.defaultData('texture'); Object.assign(p.texture, { image: h }); let f = new rt(); return f.push({ fi: 0, data: p, id: c }), f.push({ fi: 1, data: xr.defaultData('light', u), id: d }), { layers: f }; } e.defaultTwoLayerTextureData = o; function l(h, u = 'phong', c = 'layer1', d = 'layer2') { let p = xr.defaultData('video'); Object.assign(p.texture, { video: h }); let f = new rt(); return f.push({ fi: 0, data: p, id: c }), f.push({ fi: 1, data: xr.defaultData('light', u), id: d }), { layers: f }; } e.defaultTwoLayerVideoTextureData = l; })(nr || (nr = {})); var Bd; ((e) => { function t() { return { points: new rt(), roundness: 0, shapeHoles: [], isClosed: !1 }; } e.defaultData = t; })(Bd || (Bd = {})); var zd; ((e) => { function t() { return { points: new rt(), lastInsertionPlane: null, subdivisions: 12, isClosed: !1 }; } e.defaultData = t; })(zd || (zd = {})); var J_ = { type: 'Ellipse', width: 100, height: 100, spikes: 64, angle: 360, innerRadius: 0 }, bm; ((e) => { function t(i, r) { let s = { ...i }; return ( eA.forEach((n) => { Object.assign(s, { [n]: r[n] ?? i[n] }); }), s ); } e.merge = t; })(bm || (bm = {})); var $_ = { shape: J_, depth: 1, offset: 0, bevel: 0, bevelSides: 1, angle: 0, twist: 0, startScale: 1, endScale: 1 }, eA = ['depth', 'offset', 'angle', 'twist', 'startScale', 'endScale'], Nd; ((e) => { function t(r) { return ( r === 'PolygonGeometry' || r === 'RectangleGeometry' || r === 'StarGeometry' || r === 'TriangleGeometry' || r === 'EllipseGeometry' ); } e.is2DParametricMesh = t; function i(r) { return ( r === 'PolygonGeometry' || r === 'PolygonGeometry' || r === 'RectangleGeometry' || r === 'StarGeometry' || r === 'TriangleGeometry' || r === 'EllipseGeometry' || r === 'PathGeometry' || r === 'VectorGeometry' || r === 'ConeGeometry' || r === 'CubeGeometry' || r === 'CylinderGeometry' || r === 'DodecahedronGeometry' || r === 'HelixGeometry' || r === 'IcosahedronGeometry' || r === 'LatheGeometry' || r === 'PyramidGeometry' || r === 'SphereGeometry' || r === 'PlaneGeometry' || r === 'BackdropGeometry' || r === 'TorusGeometry' || r === 'TorusKnotGeometry' || r === 'BooleanGeometry' || r === 'TextGeometry' ); } e.isParametricMesh = i; })(Nd || (Nd = {})); var wm; ((e) => { function t(i, r) { let s = { ...i }; return ( Object.assign(s, r), s.type === 'PathGeometry' && 'extrusion' in r && r.extrusion && ((s.extrusion = { ...i.extrusion }), Object.assign(s.extrusion, bm.merge(s.extrusion, r.extrusion))), s ); } e.merge = t; })(wm || (wm = {})); var So; ((e) => { function t(i) { if (i === 'RectangleGeometry') return { width: 320, height: 320, type: i, cornerRadius: [0, 0, 0, 0], cornerType: 0, depth: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1 }; if (i === 'PathGeometry') return { type: i, width: 1, height: 1, depth: 1, path: zd.defaultData(), extrusion: $_ }; if (i === 'VectorGeometry') return { width: 1, height: 1, type: i, subdivisions: 12, shape: Bd.defaultData(), depth: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1 }; if (i === 'BooleanGeometry') return { type: i, operation: 2, width: 0, height: 0, depth: 0, phongAngle: 35 }; if (i === 'TextGeometry') return { type: i, width: 100, height: 100, depth: 0, horizontalAlign: 1, verticalAlign: 1, fontSize: 16, lineHeight: 1.2, letterSpacing: 0, text: '', textTransform: 1, font: 'Roboto_regular', extrudeBevelSize: 0, extrudeBevelSegments: 1 }; throw new Error('not implemented'); } e.defaultData = t; })(So || (So = {})); var F1 = ['width', 'height', 'depth'], k1; ((e) => { function t(r) { return r === 'Component' || r === 'Instance'; } e.isComponentRelated = t; function i(r) { return r === 'Empty' || r === 'Instance'; } e.isEmptyOrComponent = i; })(k1 || (k1 = {})); var jo; ((e) => { e.identity = { ...pm.identity, hiddenMatrix: ko.identity }; function t(s) { return { position: s.position, rotation: s.rotation, scale: s.scale, hiddenMatrix: s.hiddenMatrix }; } e.fromObject = t; function i(s, n) { return { position: n?.position || s.position, rotation: n?.rotation || s.rotation, scale: n?.scale || s.scale, hiddenMatrix: n?.hiddenMatrix || s.hiddenMatrix }; } e.merge = i; function r(s, n) { return { position: ma.isEqual(s.position, n.position) ? null : n.position, rotation: ma.isEqual(s.rotation, n.rotation) ? null : n.rotation, scale: ma.isEqual(s.scale, n.scale) ? null : n.scale, hiddenMatrix: ko.isEqual(s.hiddenMatrix, n.hiddenMatrix) ? null : n.hiddenMatrix }; } e.diff = r; })(jo || (jo = {})); var _m; ((e) => (e.defaultData = { fusedBody: !0, rigidBody: 'positioned', density: 1, pointMass: 0, gravityScale: 1, friction: 0.5, damping: 0, restitution: 0.2, colliderType: 'convex', enabledRotation: [!0, !0, !0], enabledTranslation: [!0, !0, !0] }))(_m || (_m = {})); var Ar; ((e) => (e.defaultData = { states: new rt(), events: new rt(), visible: !0, raycastLock: !1, physics: null, pathSnapping: { pathId: null, slide: 0, offset: 0, orientation: 'tangential' }, ...jo.identity, cloner: null }))(Ar || (Ar = {})); var j1; ((e) => (e.defaultData = { type: 'Empty', ...Ar.defaultData }))(j1 || (j1 = {})); var G1; ((e) => (e.defaultData = { type: 'Component', ...Ar.defaultData }))(G1 || (G1 = {})); var Mo; ((e) => (e.defaultData = { type: 'Mesh', ...Ar.defaultData, ...xm.defaultData }))(Mo || (Mo = {})); var Ud; ((e) => (e.defaultData = { ...Ar.defaultData, ...jo.identity, ...xh.defaultData }))(Ud || (Ud = {})); var Am; ((e) => { function t(i) { return { ...Ar.defaultData, ...gm.defaultData(i) }; } e.defaultData = t; })(Am || (Am = {})); var Fd; ((e) => { function t(r, s, n = 0) { for (; n < s.length; ) { let a = r ? r[s[n]] : void 0; if (s.length === n + 1) return a; if (a) (r = a.descendants), (n += 1); else return; } } e.resolveWithDes = t; function i(r, s, n = 0) { let a = t(r, s, n); if (a) { let o = Object.keys(a); if (o.length === 1 && o[0] === 'descendants') return; } return a; } e.resolve = i; })(Fd || (Fd = {})); var Go; ((e) => { (e.rootOverrideProps = ['physics']), (e.compositeNonOptionalOverrideProps = ['geometry']), (e.compositeEntireOverrideOverrideProps = ['material']); function t(r, s) { return { ...Ar.defaultData, ...s, component: r, overrides: new mi(), physics: void 0, type: 'Instance' }; } e.ofComponent = t; function i(r) { let s = jo.fromObject(r.data); return t(r.id, s); } e.fromComponentData = i; })(Go || (Go = {})); var Sm; ((e) => ( (e.defaultCamera = { position: [0, 0, 1e3], scale: [1, 1, 1], rotation: [0, 0, 0], hiddenMatrix: ko.identity, name: 'Play Camera', visible: !0, raycastLock: !1, physics: _m.defaultData, states: new rt(), events: new rt(), cloner: null, pathSnapping: { pathId: null, orientation: 'tangential', slide: 0, offset: 0 }, ...xh.defaultData }), (e.KeysByResetCategory = { States: ['states'], Events: ['events'], Material: ['material', 'materials'], Geometry: ['geometry'], Position: ['position'], Rotation: ['rotation'], Scale: ['scale'], Transform: ['position', 'scale', 'rotation', 'hiddenMatrix'], Name: ['name'], Visibility: ['visible', 'raycastLock', 'flatShading', 'wireframe', 'side'], Shadows: ['castShadow', 'receiveShadow'], Cloner: ['cloner'], Physics: ['physics'] }), (e.defaultMeshObject = { name: 'Rectangle', ...Ar.defaultData, ...Mo.defaultData, geometry: So.defaultData('RectangleGeometry'), material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2') }), (e.defaultBooleanObject = { name: 'Boolean', ...Ar.defaultData, ...Mo.defaultData, geometry: So.defaultData('BooleanGeometry'), material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2') }), (e.defaultTextObject = { name: 'Text', ...Ar.defaultData, ...Mo.defaultData, geometry: So.defaultData('TextGeometry'), material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2') }) ))(Sm || (Sm = {})); var oa; ((e) => { function t(n, a) { let o = { name: a }; return ( n.type === 'Mesh' ? ((o.geometry = {}), 'material' in n && (o.material = { layers: new mi() }), 'materials' in n && (o.materials = n.materials.map((l) => ({ layers: new mi() })))) : _a.is(n.type) && ((o.perspective = {}), (o.orthographic = {})), o ); } e.newEmpty = t; function i(n, a) { if (a === void 0) return n; let o = { ...n }; return ( 'material' in o && 'material' in a && a.material && (o.material = Pd(o.material, (l) => { if (typeof l != 'string') for (let [h, u] of Object.entries(a.material.layers)) { let c = l.layers.data(h); c && xr.patch(c, u); } }).data), o.materials && a.materials && (o.materials = Pd(o.materials, (l) => { for (let h = 0; h < o.materials.length; h++) { let u = a.materials[h]; if (typeof u != 'string') for (let [c, d] of Object.entries(u.layers)) { let p = l[h]?.layers?.data(c); p && xr.patch(p, d); } } }).data), o ); } function r(n, a) { let o, l = [], h = { orthographic: 0, perspective: 0, geometry: 0 }; function u(c, d) { for (let [p, f] of Object.entries(d.layers)) { let { texture: g, ...m } = f; if (g !== void 0 && Object.keys(g).length > 0) { let v = { path: [...c, 'layers', p, 'texture'], props: g, type: 0 }; l.push(v); } if (Object.keys(m).length > 0) { let v = { path: [...c, 'layers', p], props: m, type: 0 }; l.push(v); } } } for (let [c, d] of Object.entries(a)) if (c !== 'name') if (c === 'cloner') l.push(...fm.toOps(d, ['cloner'])); else if (c === 'pathSnapping') l.push({ path: [c], props: { slide: d.slide, offset: d.offset }, type: 0 }); else if (c === 'material') u(['material'], d); else if (c === 'materials') for (let [p, f] of Object.entries(d)) u(['materials', p], f); else if (h[c] === 0) { if (c === 'geometry' && d.extrusion !== void 0) { let p = { path: [c, 'extrusion'], props: d.extrusion, type: 0 }; l.push(p), (d = { ...d }), delete d.extrusion; } if (Object.keys(d).length > 0) { let p = { path: [c], props: d, type: 0 }; l.push(p); } } else o === void 0 && ((o = { path: [], props: {}, type: 0 }), l.push(o)), (o.props[c] = d); return l; } e.toOps = r; function s(n, a) { if (a === void 0) return n; let o = { ...n }; if ( (Object.assign(o, jo.merge(o, a)), Object.assign(o, { pathSnapping: Object.assign({}, o.pathSnapping, { slide: a.pathSnapping?.slide ?? o.pathSnapping?.slide ?? 0, offset: a.pathSnapping?.offset ?? o.pathSnapping?.offset ?? 0 }) }), _a.is(n.type)) ) { (o.orthographic = { ...o.orthographic }), (o.perspective = { ...o.perspective }); let l = a; l.orthographic?.zoom !== void 0 && (o.orthographic.zoom = l.orthographic.zoom), l.perspective?.zoom !== void 0 && (o.perspective.zoom = l.perspective.zoom), l.isUpVectorFlipped !== void 0 && (o.isUpVectorFlipped = l.isUpVectorFlipped), l.targetOffset !== void 0 && (o.targetOffset = l.targetOffset); } else if (n.type === 'Mesh') 'geometry' in a && Object.assign(o, { geometry: wm.merge(o.geometry, a.geometry) }), (a.material || a.materials) && (o = i(o, a)), o.cloner && 'cloner' in a && Object.assign(o, { cloner: bn.merge(o.cloner, a.cloner) }); else if (n.type === 'Empty') o.cloner && 'cloner' in a && Object.assign(o, { cloner: bn.merge(o.cloner, a.cloner) }); else if (mm.is(n.type)) { let l = a; l.intensity !== void 0 && (o.intensity = l.intensity), l.color !== void 0 && (typeof l.color == 'string' ? (o.color = l.color) : (o.color = $i.clone(l.color))); } return o; } e.patch = s; })(oa || (oa = {})); var kd; ((e) => (e.defaultData = { enabled: !1, useBackgroundColor: !1, color: $i.white, near: 0.1, far: 2e3 }))(kd || (kd = {})); var jd; ((e) => (e.defaultData = { enablePan: !0, enableZoom: !0, enableRotate: !0, enableDamping: !0, rotationLimitsMode: 0, rotationVerticalOffset: { min: Math.PI / 4, max: Math.PI / 4 }, rotationHorizontalOffset: { min: Math.PI / 4, max: Math.PI / 4 }, rotationSoftLimit: 2, panLimitsMode: 0, panVerticalOffset: { min: 250, max: 250 }, panHorizontalOffset: { min: 250, max: 250 }, panSoftLimit: 2, zoomLimitsEnabled: !1, zoomLimits: { min: 0.1, max: 2 }, autoRotate: !1, autoRotateSpeed: 2, autoRotateClockwise: !0, hoverRotatePanMode: 0, hoverRotatePanStrength: 20, isTouchZoom: !0, orbitTouches: 2, panTouches: 3, resetHoverEffectOnPointerLeave: !0, autoZoom: !1 }))(jd || (jd = {})); var Vo; ((e) => (e.defaultData = { orbitControls: jd.defaultData, playCamera: null, withBackground: !0, preventScroll: !1, preventTouchScroll: !1, hideCursor: !1, mouseEventTarget: 'canvas', settings: { image: { format: 'jpg', ratio: 1 }, video: { format: 'mp4', imageFormat: 'jpg', fps: 30, mbps: 80, ratio: typeof window < 'u' ? Math.floor(window.devicePixelRatio) : 1, stopMode: 'manual', duration: 5e3 }, web: { logo: !0, compress: !0, preset: 1, preload: !0, hint: !1 } }, stopRaycast: !0, joystickSizeAndXYOffset: Array(12) .fill(0) .map((t, i) => { let r = 0, s = 0; return ( i < 5 ? (s = -30) : i < 10 && (s = 30), i === 0 || i === 10 || i === 5 ? (r = 30) : (i === 4 || i === 11 || i === 9) && (r = -30), [120, [r, s], 'show'] ); }), gameControlObject: null }))(Vo || (Vo = {})); function Aa(e, t) { return Object.setPrototypeOf(e, t), e; } var XN = () => (typeof window > 'u' ? !1 : window.navigator.userAgent.toLowerCase().includes(' electron/')), qN = () => (typeof window > 'u' ? !1 : window.navigator.platform.toUpperCase().includes('MAC')), YN = () => (typeof window > 'u' ? !1 : /iPad|iPhone|iPod/.test(window.navigator.userAgent) || (Su && 'ontouchend' in document)), QN = () => (typeof window > 'u' ? !1 : window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1), ZN = () => (typeof window > 'u' ? !1 : 'ontouchstart' in window || navigator.maxTouchPoints > 0), KN = () => { if (typeof window > 'u') return !1; let e = navigator.userAgent, t = navigator.vendor; return /Safari/i.test(e) && /Apple Computer/.test(t); }, JN = () => { if (typeof window > 'u') return null; let e = navigator.userAgent.match(/Version\/(\d+\.\d)/); return e && e[1]; }, S9 = XN(), Su = qN(), Mm = YN(), $N = QN(), rr = ZN(), V1 = KN(), H1 = Number(JN()); function tA(e) { return Array.isArray(e) ? e : [e]; } function eU(e, t) { let i = 0; for (; i < e.length && i < t.length; ) { if (e[i] < t[i]) return -1; if (e[i] > t[i]) return 1; i += 1; } return i !== t.length ? -1 : i !== e.length ? 1 : 0; } function Ac(e) { return Su ? e.metaKey : e.ctrlKey; } var Qe = [], Gd = {}, Vl = {}, rd = {}; function iA(e) { Qe.includes(e) || Qe.push(e); } function Eo(e) { delete Gd[e.pointerId]; for (let t = 0; t < Qe.length; t++) if (Qe[t].pointerId === e.pointerId) { Qe.splice(t, 1); break; } } function tU() { Qe.splice(0, Qe.length); } function Vd(e) { if (e.pointerType !== 'touch') return; let t = Gd[e.pointerId]; t === void 0 && ((t = { x: 0, y: 0 }), (Gd[e.pointerId] = t)), (t.x = e.pageX), (t.y = e.pageY); } function Np(e) { let t = e.pointerId === Qe[0].pointerId ? Qe[1] : Qe[0]; return Gd[t.pointerId]; } function rA(e) { (Vl[e.key] = !0), (rd[e.key] = rd[e.key] === void 0 ? 1 : rd[e.key] + 1); } function sA(e) { if (Su && Vl.Meta) for (let t in Vl) Vl[t] = !1; else Vl[e.key] = !1; rd = {}; } function iU(e) { e.addEventListener('pointerdown', iA, !0), e.addEventListener('pointerdown', Vd, !0), e.addEventListener('pointermove', Vd, !0), e.addEventListener('pointerup', Eo, !0), e.addEventListener('pointercancel', Eo, !0), e.addEventListener('pointerleave', Eo, !0), window.addEventListener('keydown', rA, !0), window.addEventListener('keyup', sA, !0); } function rU(e) { e.removeEventListener('pointerdown', iA, !0), e.removeEventListener('pointerdown', Vd, !0), e.removeEventListener('pointermove', Vd, !0), e.removeEventListener('pointerup', Eo, !0), e.removeEventListener('pointercancel', Eo, !0), e.removeEventListener('pointerleave', Eo, !0), window.removeEventListener('keydown', rA, !0), window.removeEventListener('keyup', sA, !0); } var Ki; ((e) => (e.defaultData = { ambientLight: { enabled: !0, color: { r: 0.8274509803921568, g: 0.8274509803921568, b: 0.8274509803921568 }, intensity: 0.75, depth: 100, groundColor: { r: 0.5098039215686274, g: 0.5098039215686274, b: 0.5098039215686274 }, softShadows: !0, softShadowQuality: 'low' }, usePhysics: !1, gravity: -10, pixelsPerMeter: 200, skinWidthRelative: 0.02, stepThreshRelative: 0.3, slopeThresh: 65 }))(Ki || (Ki = {})); var Em; ((e) => { e.TRASH_CAN_ID = '830a2708-8ed9-49cf-a68e-085299892222'; function t(s = { withLight: !0, withSquare: !0 }) { let n = new ki(), a = Sm.defaultMeshObject; return ( s.withLight === !0 && n.push({ fi: -1, data: { ...Am.defaultData('DirectionalLight'), position: [200, 300, 300], name: 'Directional Light', intensity: 0.7 }, id: '830a2708-8ed9-49cf-a68e-085299899103', children: [] }), s.withSquare === !0 && n.push({ fi: 1, id: '7ba78968-2a55-48f2-b14c-5191da3e075e', data: a, children: [] }), n ); } (e.defaultData = { backgroundColor: kr.fromHexAndA(2960946, 1), postprocessing: bh.defaultData, fog: kd.defaultData, objects: t(), environment: Ki.defaultData, publish: Vo.defaultData }), (e.emptyData = function (s) { return { backgroundColor: kr.fromHexAndA(2960946, 1), postprocessing: bh.defaultData, fog: kd.defaultData, objects: s ? t(s) : new ki(), environment: Ki.defaultData, publish: Vo.defaultData }; }); function i(s) { return { ...e.defaultData, objects: Aa(s, ki.prototype) }; } e.withObjs = i; function r(s, n) { return i([{ id: s, data: n, children: [], fi: 0 }]); } e.withObj = r; })(Em || (Em = {})); var Hd; ((e) => (e.emptyImage = { data: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=' }))(Hd || (Hd = {})); var Wd; ((e) => { function t() { let s = {}; return (s['89b10010-844c-11ec-a8a3-0242ac120002'] = { r: 0.5, g: 0.5, b: 0.5, a: 1, name: 'Default Color' }), Aa(s, Qt.prototype); } e.defaultColors = t; function i(s) { let n = {}; return ( s?.withAITexture && (n['a1b10010-844c-a8a3-11ec-0242ac2011ec'] = { ...Hd.emptyImage, name: 'AI generated image' }), Aa(n, Qt.prototype) ); } e.defaultImages = i; function r() { return { materials: new Qt(), images: new Qt(), videos: new Qt(), colors: new Qt(), audios: new Qt(), fonts: new Qt(), penumbraSize: [2, 2, 2] }; } e.emptyData = r; })(Wd || (Wd = {})); function W1(e) { e.layers.forEach((t) => { if (t.type === 'depth' && t.colorA !== void 0) { let i = t.colorA, r = t.colorB, s = [ [i.r, i.g, i.b, i.a], [r.r, r.g, r.b, r.a] ], n = [0, 1]; for (let o = 2; o < 10; o++) s.push(s[1]), n.push(1); let a = { ...gh(Si(t), 'type', 'visible', 'isVector', 'isWorldSpace', 'origin', 'alpha', 'mode'), near: Math.max(0, t.near), far: Math.max(0, t.far), colors: s, steps: n, num: 2, direction: [1, 0, 0], smooth: !1, gradientType: 1 }; Object.assign(t, a); } else if (t.type === 'depth' && t.gradientType === 1 && (t.near < 0 || t.far < 0)) { let i = { ...Si(t), near: Math.max(t.near, 0), far: Math.max(t.far, 0) }; Object.assign(t, i); } }); } function sd(e, t) { Object.values(e.shared.materials).forEach((i) => t(i)); } function nd(e, t) { e.scene.objects.traverse((i, r) => { 'materials' in r ? r.materials.forEach((s) => { typeof s != 'string' && t(s); }) : 'material' in r && typeof r.material != 'string' && t(r.material); }); } function sU(e) { Object.assign(e.scene.publish, { orbitControls: { ...jd.defaultData, ...Si(e.scene.publish.orbitControls) } }); } function nU(e) { Object.assign(e.scene.publish.settings, { video: { ...Vo.defaultData.settings.video, ...Si(e.scene.publish.settings.video) } }); } function aU(e) { function t(i) { if (i.layers) { for (let r of Object.values(i.layers)) if (r) { for (let [s, n] of Object.entries(r)) if (((K_.includes(s) || typeof n == 'boolean') && delete r[s], s === 'texture')) for (let [a, o] of Object.entries(n)) (WN.includes(a) || typeof o == 'boolean') && delete n[a]; } } } e.scene.objects.traverse((i, r) => { r.states.forEach((s) => { let n = s; n.material ? t(n.material) : n.materials && n.materials.forEach((a) => { t(a); }); }); }); } function oU(e) { e.scene.publish.withBackground = !0; } function lU(e) { e.scene.publish.settings.web = { compress: !0, preload: !0, preset: 1, logo: !0, hint: !1 }; } function hU(e) { e.scene.objects.traverse((t, i) => { let r = i.cloner; r && ((r.radial.scale = r.radial.scale.map((s) => s + 1)), (r.linear.scale = r.linear.scale.map((s) => s + 1))); }); } function cU(e) { e.scene.objects.traverse((t, i) => { let r = i.geometry; r && (r.type === 'DodecahedronGeometry' || r.type === 'IcosahedronGeometry') && (r.detail = Math.round(r.detail)); }); } function dU(e) { e.scene.objects.traverse((t, i) => { let r = e.scene.objects.unproxy().parent(t); if (r) { let s = Si(e.scene.objects.data(r)); s && s.type === 'Mesh' && s.geometry.type === 'BooleanGeometry' && i.type === 'Mesh' && (i.visible = Si(i).booleanExclude !== !0); } }); } function uU(e) { e.scene.objects.traverse((t, i) => { if (i.type === 'Mesh') { let r = i; i.geometry.type === 'NonParametricGeometry' ? r.material !== void 0 && delete r.material : r.materials !== void 0 && delete r.materials; } }); } function pU(e) { function t(r) { Object.setPrototypeOf(r, mi.prototype), r.texture && Object.setPrototypeOf(r.texture, mi.prototype); } function i(r) { Object.setPrototypeOf(r, mi.prototype); for (let s in r) t(r[s]); } e.scene.objects.traverse((r, s) => { s.states.forEach((n) => { let a = n; if (a.material) { let o = Si(a.material).layers; i(o), (a.material.layers = o); } if (a.materials) for (let o = 0; o < a.materials.length; o++) { let l = a.materials[o], h = Si(l).layers; i(h), (l.layers = h); } }); }); } function X1(e) { e.layers === void 0 && Object.assign(e, nr.defaultTwoLayerData('lambert')); } function Up(e) { !e.layers || e.layers.forEach((t) => { if (t.type === 'depth' && t.colors.length === 10) { let i = [...t.colors]; i.push(t.colors[9]); let r = [...t.steps]; r.push(t.steps[9]); let s = { ...Si(t), colors: i, steps: r }; Object.assign(t, s); } }); } function fU(e) { e.scene.objects.traverse((t, i) => { i.type === 'Mesh' && (i.geometry.type === 'BooleanGeometry' || i.geometry.type === 'SubdivGeometry') && (i.geometry.phongAngle = 35); }); } function q1(e) { e.scene.objects.traverse((t, i) => { 'materials' in i ? i.materials.forEach((r) => { typeof r != 'string' && Up(r); }) : 'material' in i && typeof i.material != 'string' && Up(i.material); }), Object.values(e.shared.materials).forEach((t) => Up(t)); } function mU(e) { (e.scene.environment.ambientLight.softShadows = !1), (e.scene.environment.ambientLight.softShadowQuality = 'low'), e.scene.objects.traverse((t, i) => { (i.type === 'DirectionalLight' || i.type === 'SpotLight') && ((i.shadowResolution = 1024), (i.shadowRadius = 1), (i.depth = 1e5)); }), (e.shared.penumbraSize = new Array(5).fill(0.5)); } function gU(e) { e.shared.audios = Aa({}, Qt.prototype); } function vU(e) { e.shared.videos = Aa({}, Qt.prototype); } function yU(e) { let t = e.shared.materials; Object.entries(t).forEach(([i, r]) => { if (!r.layers) { let s = { name: 'Untitled Material', layers: [ { fi: 0, data: { type: 'light', category: 'phong', alpha: 0.6, visible: !0, mode: 0, specular: { r: 0.2, g: 0.2, b: 0.2 }, shininess: 5 }, id: 'layer1' }, { fi: 1, data: { type: 'color', alpha: 1, visible: !0, mode: 0, color: { r: 0.2823529411764706, g: 0.2823529411764706, b: 0.30196078431372547 } }, id: 'layer2' } ] }; Object.assign(t, { [i]: s }); } }); } function xU(e) { Object.entries(Si(e.shared.images)) .filter((t) => t[1].asset === !1) .map((t) => t[0]) .forEach((t) => { delete e.shared.images[t]; }), Object.entries(Si(e.shared.audios)) .filter((t) => t[1].asset === !1) .map((t) => t[0]) .forEach((t) => { delete e.shared.audios[t]; }); } function bU(e) { e.scene.publish.settings.web.preload = !1; } function Y1(e) { e.layers && e.layers.forEach((t) => { t.type === 'depth' && t.num !== void 0 && ((t.colors = t.colors.slice(0, t.num)), (t.steps = t.steps.slice(0, t.num)), delete t.num); }); } function wU(e) { e.shared.fonts = Aa({}, Qt.prototype); } function _U(e) { return e .replace('.typeface', '') .replace(/optimer/gi, 'open sans') .replace('space_mono', 'space mono') .replace(/alma_mono/gi, 'varela round') .replace(/droid_sans_mono/gi, 'noto sans mono') .replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi, 'roboto') .replace(/droid_serif/gi, 'roboto slab') .replace('_sans', ' sans') .replace('crimson_text', 'crimson text') .replace('medium_medium', 'medium') .replace('fatface_fatface', 'fatface') .replace('100hairline', 'thin') .replace('200thin', 'extralight') .replace('300light', 'light') .replace('500medium', 'medium') .replace('600semi', 'semibold') .replace('800heavy', 'extrabold') .replace('900black', 'black') .replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi, 'bodoni_$1_$2') .replace(/bodoni_(11|16|24|36|48|72|96)/gi, 'bodoni moda') .replace(/(thin|hairline)(_regular)?/gi, '100') .replace(/(extra|ultra)light(_regular)?/gi, '200') .replace(/light(_regular)?/gi, '300') .replace(/_book|_normal|_roman/gi, '_regular') .replace(/medium(_regular)?/gi, '500') .replace(/(semi|demi)bold(_regular)?/gi, '600') .replace(/(extra|ultra)bold(_regular)?/gi, '800') .replace(/bold(_regular)?/gi, '700') .replace(/(black|heavy|fatface)(_regular)?/gi, '900') .replace(/([1-9]00)_italic/gi, '$1italic') .replace(/regularitalic/gi, 'italic') .replace(/regularitalic/gi, 'italic') .split(' ') .map((t) => t.charAt(0).toUpperCase() + t.slice(1)) .join(' '); } function AU(e) { let t = []; e.scene.objects.traverse((i, r) => { let s = r; if (s.type === 'TextFrame') { let n = nr.defaultTwoLayerData('phong'), a = typeof s.color == 'string' ? e.shared.colors[s.color] : s.color; (n.layers[1].data.color = { r: a.r, g: a.g, b: a.b }), (n.layers[1].data.alpha = s.alpha); let o = _U(s.font); e.shared.fonts[o] === void 0 && (e.shared.fonts[o] = { name: o }); let l = { name: s.name, ...Ar.defaultData, ...Mo.defaultData, flatShading: !1, wireframe: !1, geometry: { ...So.defaultData('TextGeometry'), width: s.width, height: s.height, font: o, depth: 0, horizontalAlign: s.horizontalAlign, verticalAlign: s.verticalAlign, fontSize: s.fontSize * 1.40625, lineHeight: s.lineHeight / 1.40625, letterSpacing: s.letterSpacing - 1, text: s.text, textTransform: s.textTransform, extrudeBevelSize: 0, extrudeBevelSegments: 1 }, material: n, states: Si(s.states), events: Si(s.events), visible: s.visible, raycastLock: s.raycastLock, position: s.position, rotation: s.rotation, scale: s.scale, hiddenMatrix: s.hiddenMatrix }, h = Si(e.scene.objects).parent(i); e.scene.objects.insertAfter(h ?? null, i, [{ id: i + 'new', data: l, children: [] }]), t.push(i); } }), t.forEach((i) => { e.scene.objects.delete(i); }); } function SU(e) { let t = { 0: 'MouseDown', 1: 'MouseUp', 2: 'MouseHover', 5: 'KeyDown', 6: 'KeyUp', 7: 'Start', 9: 'LookAt', 10: 'Follow', 11: 'Scroll', 12: 'Audio', 13: 'GameControl' }; e.scene.objects.traverse((i, r) => { r.events.forEach((s) => { if (t[Number(s.type)]) if ( (Object.assign(s, { type: t[Number(s.type)] }), s.type === 'Audio' && 'audioEvent' in s && (Object.assign(s, { playAudio: s.audioEvent }), delete s.audioEvent), s.type === 'GameControl') ) Object.assign(s, { gameActions: { idle: new rt(), move: new rt(), jump: new rt() } }); else { let n = new rt(); Object.assign(s, { actions: n }), (s.type === 'MouseDown' || s.type === 'MouseUp' || s.type === 'KeyDown' || s.type === 'KeyUp') && 'url' in s && n.push({ fi: 0, id: it.generateUUID(), data: { type: 'Link', url: s.url, delay: 0 } }), 'targets' in s && (s.targets.forEach((a, o, l) => { let h = { state: void 0, repeat: 0, delay: 0, delayDirection: void 0, direction: 'normal', duration: 0, easing: 4 }, u = { easing: a.easing, duration: a.duration }; a.easing === 6 ? Object.assign(u, gh(a, 'mass', 'stiffness', 'damping', 'velocity')) : a.easing === 5 && Object.assign(u, { control1: { ...a.control1 }, control2: { ...a.control2 } }); let c = { repeat: a.repeat ? -1 : 0, delay: a.delay, delayDirection: a.delayDirection, direction: a.cycle && a.rewind ? 'pingpong-rewind' : a.cycle ? 'pingpong' : 'normal' }, d = { state: a.state, ...c, ...u }, p = { allowSlerp: !0, type: 'Transition', object: a.object, repeat: 0, delay: 0, delayDirection: void 0, direction: 'normal', tweens: new rt({ fi: 0, id: it.generateUUID(), data: h }, { fi: 1, id: it.generateUUID(), data: d }) }; n.push({ fi: l, id: o, data: p }); }), delete s.targets); } }); }); } function MU(e) { e.scene.objects.traverse((t, i) => { function r(s, n) { let a = new rt(), o = []; if ( (i.events.forEach((l, h, u) => { if (l.type === 'Audio' && l.trigger === n) { let c; o.push(h), l.interaction === 'play' ? (c = { ...gh(l, 'interaction', 'audio', 'delay', 'volume', 'loop'), triggerAfter: 'after' in l ? l.after : void 0, toggle: 'after' in l ? l.toggle : void 0, type: 'Audio' }) : (l.interaction === 'pause' || l.interaction === 'stop') && (c = { ...gh(l, 'interaction', 'delay', 'object', 'playAudio'), type: 'Audio' }), c && a.push({ fi: u, id: h, data: c }); } }), o.forEach((l) => i.events.delete(l)), a.length) ) { let l = i.events.find((h) => h.type === s)?.data; l ? 'actions' in l && l.actions.insertBefore(null, a) : i.events.insertBefore(null, [{ id: it.generateUUID(), data: { type: s, actions: a } }]); } } r('Start', 'start'), r('MouseDown', 'mouseDown'), r('MouseUp', 'mouseUp'), r('KeyDown', 'keyDown'), r('KeyUp', 'keyUp'); }); } function Q1(e) { let t = e.layers.find((i) => i.type === 'light')?.data; if (t?.category === 'basic') { let i = xr.defaultData('light', 'phong'), r = t; Object.assign(r, i), (r.visible = !1); } } function Z1(e) { sd(e, Q1), nd(e, Q1); } function EU(e) { e.scene.objects.traverse((t, i) => { i.type === 'Mesh' && i.geometry.type === 'SubdivGeometry' && (i.geometry.scaleBaked || (i.geometry.scaleBaked = [1, 1, 1])); }); } function CU(e) { e.scene.objects.traverse((t, i) => { (i.type === 'Empty' || i.type === 'Mesh') && i.cloner && !i.cloner.randomnessObject && !i.cloner.toObject && !i.cloner.randomness && (i.cloner = { ...i.cloner, toObject: { object: '', spreadType: 'random', scale: [0, 0, 0], rotation: [0, 0, 0], position: [0, 0, 0], axis: 'x', seed: 0, count: 99, align: 'normal' }, randomness: !1, randomnessObject: { strength: 100, scale: [0, 0, 0], rotation: [0, 0, 0], position: [0, 0, 0], movement: 1, seed: 0, freqScale: 10, noiseType: 'perlin' } }); }); } function TU(e) { e.scene.objects.traverse((t, i) => { i.type === 'Mesh' && i.geometry.type === 'NonParametricGeometry' && !('material' in i) && !('materials' in i) && (i.material = nr.defaultTwoLayerData('phong')); }); } function PU(e) { e.scene.publish.orbitControls.autoZoom === void 0 && (e.scene.publish.orbitControls.autoZoom = !1), e.scene.objects.traverse((t, i) => { (i.type === 'OrthographicCamera' || i.type === 'PerspectiveCamera') && (i.orthographic.autoZoom === void 0 && (i.orthographic.autoZoom = !1), i.orthographic.autoZoomFrustumSize === void 0 && (i.orthographic.autoZoomFrustumSize = 790)); }); } function DU(e) { e.scene.objects.traverse((t, i) => { i.pathSnapping === void 0 && (i.pathSnapping = { pathId: null, slide: 0, offset: 0, orientation: 'tangential' }), i.pathSnapping.offset === void 0 && (i.pathSnapping.offset = 0); }); } function LU(e) { e.scene.publish.mouseEventTarget === void 0 && (e.scene.publish.mouseEventTarget = 'canvas'), e.scene.publish.settings.web.hint === void 0 && (e.scene.publish.settings.web.hint = !1); } function OU(e) { let { video: t } = e.scene.publish.settings; t.format === 'gif' && t.fps > 48 && (t.fps = 15); } function IU(e) { e.scene.objects.traverse((t, i) => { i.events.forEach((r) => { r.type === 'GameControl' && (r.resetYPosition = Math.abs(r.resetYPosition - i.position[1])); }); }); } var K1 = 36; function RU(e) { let t = e.schema ?? 0; t !== K1 && (console.warn('updating from ', t, 'to ', K1), t < 1 && (nd(e, W1), sd(e, W1), (e.schema = 1)), t < 2 && (sU(e), (e.schema = 2)), t < 3 && (aU(e), (e.schema = 3)), t < 4 && (oU(e), (e.schema = 4)), t < 5 && (lU(e), (e.schema = 5)), t < 6 && (hU(e), (e.schema = 6)), t < 7 && (cU(e), (e.schema = 7)), t < 8 && (e.schema = 8), t < 9 && (q1(e), (e.schema = 9)), t < 10 && (fU(e), (e.schema = 10)), t < 11 && (mU(e), (e.schema = 11)), t < 12 && (q1(e), (e.schema = 12)), t < 13 && (gU(e), (e.schema = 13)), t < 14 && (yU(e), (e.schema = 14)), t < 15 && (xU(e), (e.schema = 15)), t < 16 && (bU(e), (e.schema = 16)), t < 17 && (nd(e, Y1), sd(e, Y1), (e.schema = 17)), t < 18 && (nd(e, X1), sd(e, X1), (e.schema = 18)), t < 19 && (nU(e), (e.schema = 19)), t < 20 && (wU(e), AU(e), (e.schema = 20)), t < 21 && (SU(e), MU(e), (e.schema = 21)), t < 22 && (Z1(e), (e.schema = 22)), t < 23 && (EU(e), (e.schema = 23)), t < 24 && (CU(e), (e.schema = 24)), (t < 25 || e.shared.videos === void 0) && (vU(e), t < 25 && (e.schema = 25)), t < 26 && (dU(e), (e.schema = 26)), t < 27 && (uU(e), (e.schema = 27)), t < 28 && (Z1(e), (e.schema = 28)), t < 29 && (pU(e), (e.schema = 29)), t < 30 && (TU(e), (e.schema = 30)), t < 31 && (PU(e), (e.schema = 31)), t < 33 && (DU(e), (e.schema = 33)), t < 34 && (LU(e), (e.schema = 34)), t < 35 && (OU(e), (e.schema = 35)), t < 36 && (IU(e), (e.schema = 36))); } function go(e, t = !1) { let i = e[0].index !== null, r = new Set(Object.keys(e[0].attributes)), s = new Set(Object.keys(e[0].morphAttributes)), n = {}, a = {}, o = e[0].morphTargetsRelative, l = new Ve(), h = 0; for (let u = 0; u < e.length; ++u) { let c = e[u], d = 0; if (i !== (c.index !== null)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' ), null ); for (let p in c.attributes) { if (!r.has(p)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. All geometries must have compatible attributes; make sure "' + p + '" attribute exists among all geometries, or in none of them.' ), null ); n[p] === void 0 && (n[p] = []), n[p].push(c.attributes[p]), d++; } if (d !== r.size) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. Make sure all geometries have the same number of attributes.' ), null ); if (o !== c.morphTargetsRelative) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. .morphTargetsRelative must be consistent throughout all geometries.' ), null ); for (let p in c.morphAttributes) { if (!s.has(p)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. .morphAttributes must be consistent throughout all geometries.' ), null ); a[p] === void 0 && (a[p] = []), a[p].push(c.morphAttributes[p]); } if (t) { let p; if (i) p = c.index.count; else if (c.attributes.position !== void 0) p = c.attributes.position.count; else return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + u + '. The geometry must have either an index or a position attribute' ), null ); l.addGroup(h, p, u), (h += p); } } if (i) { let u = 0, c = []; for (let d = 0; d < e.length; ++d) { let p = e[d].index; for (let f = 0; f < p.count; ++f) c.push(p.getX(f) + u); u += e[d].attributes.position.count; } l.setIndex(c); } for (let u in n) { let c = J1(n[u]); if (!c) return ( console.error('THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + u + ' attribute.'), null ); l.setAttribute(u, c); } for (let u in a) { let c = a[u][0].length; if (c === 0) break; (l.morphAttributes = l.morphAttributes || {}), (l.morphAttributes[u] = []); for (let d = 0; d < c; ++d) { let p = []; for (let g = 0; g < a[u].length; ++g) p.push(a[u][g][d]); let f = J1(p); if (!f) return ( console.error('THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + u + ' morphAttribute.'), null ); l.morphAttributes[u].push(f); } } return l; } function J1(e) { let t, i, r, s = 0; for (let o = 0; o < e.length; ++o) { let l = e[o]; if (l.isInterleavedBufferAttribute) return ( console.error('THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.'), null ); if ((t === void 0 && (t = l.array.constructor), t !== l.array.constructor)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' ), null ); if ((i === void 0 && (i = l.itemSize), i !== l.itemSize)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' ), null ); if ((r === void 0 && (r = l.normalized), r !== l.normalized)) return ( console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' ), null ); s += l.array.length; } let n = new t(s), a = 0; for (let o = 0; o < e.length; ++o) n.set(e[o].array, a), (a += e[o].array.length); return new Xe(n, i, r); } var Cm; ((e) => ( (e.defaultColliderData = { type: 'capsule', height: 200, radius: 50, position: [0, 0, 0], rotation: [0, 0, 0] }), (e.defaultDataThirdPerson = { moveMode: 'walk', speedTranslate: 1e3, speedRotate: 100, rotationMode: 'normal', rotBy: 'keys', rotByTouch: 'drag', delayPos: [0.3, 0.3], delayRot: [0.3, 0.3], keyAssignments: [ ['moveNegZ', 'W'], ['moveNegX', 'A'], ['movePosZ', 'S'], ['movePosX', 'D'], ['rotPosX', 'â–²'], ['rotPosY', 'â—€'], ['rotNegX', 'â–¼'], ['rotNegY', 'â–¶'], ['jump', 'Space'] ], touchControl: !0, joystickPosLoc: 5, joystickRotLoc: 11, jumpTouchButtonLoc: 9, collider: e.defaultColliderData, colliderHelperVisible: !0, collisionEnabled: !0, jumpPower: 100, resetYPosition: 3e3, alignToGround: !1, autoOrientMove: !0, orientWith: 'camera', orientMode: 'radial', delayPosCamera: 0.3, delayRotCamera: 0.3, camera: '', cameraXAxis: 'Limit', cameraYAxis: 'Free', cameraRotXLimits: [0, Math.PI / 2], cameraRotYLimits: [-Math.PI / 2, Math.PI / 2], gameActions: { idle: new rt(), move: new rt(), jump: new rt() } }) ))(Cm || (Cm = {})); var BU = Math.pow(2, -24), Sc = class { constructor() {} }; function ls(e, t, i) { return (i.min.x = t[e]), (i.min.y = t[e + 1]), (i.min.z = t[e + 2]), (i.max.x = t[e + 3]), (i.max.y = t[e + 4]), (i.max.z = t[e + 5]), i; } function $1(e) { let t = -1, i = -1 / 0; for (let r = 0; r < 3; r++) { let s = e[r + 3] - e[r]; s > i && ((i = s), (t = r)); } return t; } function ex(e, t) { t.set(e); } function tx(e, t, i) { let r, s; for (let n = 0; n < 3; n++) { let a = n + 3; (r = e[n]), (s = t[n]), (i[n] = r < s ? r : s), (r = e[a]), (s = t[a]), (i[a] = r > s ? r : s); } } function Mc(e, t, i) { for (let r = 0; r < 3; r++) { let s = t[e + 2 * r], n = t[e + 2 * r + 1], a = s - n, o = s + n; a < i[r] && (i[r] = a), o > i[r + 3] && (i[r + 3] = o); } } function Al(e) { let t = e[3] - e[0], i = e[4] - e[1], r = e[5] - e[2]; return 2 * (t * i + i * r + r * t); } function zU(e, t) { if (!e.index) { let i = e.attributes.position.count, r = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, s; i > 65535 ? (s = new Uint32Array(new r(4 * i))) : (s = new Uint16Array(new r(2 * i))), e.setIndex(new Xe(s, 1)); for (let n = 0; n < i; n++) s[n] = n; } } function NU(e) { if (!e.groups || !e.groups.length) return [{ offset: 0, count: e.index.count / 3 }]; let t = [], i = new Set(); for (let s of e.groups) i.add(s.start), i.add(s.start + s.count); let r = Array.from(i.values()).sort((s, n) => s - n); for (let s = 0; s < r.length - 1; s++) { let n = r[s], a = r[s + 1]; t.push({ offset: n / 3, count: (a - n) / 3 }); } return t; } function Fp(e, t, i, r, s = null) { let n = 1 / 0, a = 1 / 0, o = 1 / 0, l = -1 / 0, h = -1 / 0, u = -1 / 0, c = 1 / 0, d = 1 / 0, p = 1 / 0, f = -1 / 0, g = -1 / 0, m = -1 / 0, v = s !== null; for (let y = t * 6, b = (t + i) * 6; y < b; y += 6) { let x = e[y + 0], w = e[y + 1], A = x - w, S = x + w; A < n && (n = A), S > l && (l = S), v && x < c && (c = x), v && x > f && (f = x); let _ = e[y + 2], M = e[y + 3], C = _ - M, T = _ + M; C < a && (a = C), T > h && (h = T), v && _ < d && (d = _), v && _ > g && (g = _); let P = e[y + 4], L = e[y + 5], D = P - L, k = P + L; D < o && (o = D), k > u && (u = k), v && P < p && (p = P), v && P > m && (m = P); } (r[0] = n), (r[1] = a), (r[2] = o), (r[3] = l), (r[4] = h), (r[5] = u), v && ((s[0] = c), (s[1] = d), (s[2] = p), (s[3] = f), (s[4] = g), (s[5] = m)); } function UU(e, t, i, r) { let s = 1 / 0, n = 1 / 0, a = 1 / 0, o = -1 / 0, l = -1 / 0, h = -1 / 0; for (let u = t * 6, c = (t + i) * 6; u < c; u += 6) { let d = e[u + 0]; d < s && (s = d), d > o && (o = d); let p = e[u + 2]; p < n && (n = p), p > l && (l = p); let f = e[u + 4]; f < a && (a = f), f > h && (h = f); } (r[0] = s), (r[1] = n), (r[2] = a), (r[3] = o), (r[4] = l), (r[5] = h); } function FU(e, t, i, r, s) { let n = i, a = i + r - 1, o = s.pos, l = s.axis * 2; for (;;) { for (; n <= a && t[n * 6 + l] < o; ) n++; for (; n <= a && t[a * 6 + l] >= o; ) a--; if (n < a) { for (let h = 0; h < 3; h++) { let u = e[n * 3 + h]; (e[n * 3 + h] = e[a * 3 + h]), (e[a * 3 + h] = u); let c = t[n * 6 + h * 2 + 0]; (t[n * 6 + h * 2 + 0] = t[a * 6 + h * 2 + 0]), (t[a * 6 + h * 2 + 0] = c); let d = t[n * 6 + h * 2 + 1]; (t[n * 6 + h * 2 + 1] = t[a * 6 + h * 2 + 1]), (t[a * 6 + h * 2 + 1] = d); } n++, a--; } else return n; } } var Us = 32, kU = (e, t) => e.candidate - t.candidate, rn = new Array(Us) .fill() .map(() => ({ count: 0, bounds: new Float32Array(6), rightCacheBounds: new Float32Array(6), leftCacheBounds: new Float32Array(6), candidate: 0 })), Ec = new Float32Array(6); function jU(e, t, i, r, s, n) { let a = -1, o = 0; if (n === 0) (a = $1(t)), a !== -1 && (o = (t[a] + t[a + 3]) / 2); else if (n === 1) (a = $1(e)), a !== -1 && (o = GU(i, r, s, a)); else if (n === 2) { let l = Al(e), h = 1.25 * s, u = r * 6, c = (r + s) * 6; for (let d = 0; d < 3; d++) { let p = t[d], f = (t[d + 3] - p) / Us; if (s < Us / 4) { let g = [...rn]; g.length = s; let m = 0; for (let y = u; y < c; y += 6, m++) { let b = g[m]; (b.candidate = i[y + 2 * d]), (b.count = 0); let { bounds: x, leftCacheBounds: w, rightCacheBounds: A } = b; for (let S = 0; S < 3; S++) (A[S] = 1 / 0), (A[S + 3] = -1 / 0), (w[S] = 1 / 0), (w[S + 3] = -1 / 0), (x[S] = 1 / 0), (x[S + 3] = -1 / 0); Mc(y, i, x); } g.sort(kU); let v = s; for (let y = 0; y < v; y++) { let b = g[y]; for (; y + 1 < v && g[y + 1].candidate === b.candidate; ) g.splice(y + 1, 1), v--; } for (let y = u; y < c; y += 6) { let b = i[y + 2 * d]; for (let x = 0; x < v; x++) { let w = g[x]; b >= w.candidate ? Mc(y, i, w.rightCacheBounds) : (Mc(y, i, w.leftCacheBounds), w.count++); } } for (let y = 0; y < v; y++) { let b = g[y], x = b.count, w = s - b.count, A = b.leftCacheBounds, S = b.rightCacheBounds, _ = 0; x !== 0 && (_ = Al(A) / l); let M = 0; w !== 0 && (M = Al(S) / l); let C = 1 + 1.25 * (_ * x + M * w); C < h && ((a = d), (h = C), (o = b.candidate)); } } else { for (let v = 0; v < Us; v++) { let y = rn[v]; (y.count = 0), (y.candidate = p + f + v * f); let b = y.bounds; for (let x = 0; x < 3; x++) (b[x] = 1 / 0), (b[x + 3] = -1 / 0); } for (let v = u; v < c; v += 6) { let y = ~~((i[v + 2 * d] - p) / f); y >= Us && (y = Us - 1); let b = rn[y]; b.count++, Mc(v, i, b.bounds); } let g = rn[Us - 1]; ex(g.bounds, g.rightCacheBounds); for (let v = Us - 2; v >= 0; v--) { let y = rn[v], b = rn[v + 1]; tx(y.bounds, b.rightCacheBounds, y.rightCacheBounds); } let m = 0; for (let v = 0; v < Us - 1; v++) { let y = rn[v], b = y.count, x = y.bounds, w = rn[v + 1].rightCacheBounds; b !== 0 && (m === 0 ? ex(x, Ec) : tx(x, Ec, Ec)), (m += b); let A = 0, S = 0; m !== 0 && (A = Al(Ec) / l); let _ = s - m; _ !== 0 && (S = Al(w) / l); let M = 1 + 1.25 * (A * m + S * _); M < h && ((a = d), (h = M), (o = y.candidate)); } } } } else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`); return { axis: a, pos: o }; } function GU(e, t, i, r) { let s = 0; for (let n = t, a = t + i; n < a; n++) s += e[n * 6 + r * 2]; return s / i; } function VU(e, t) { let i = e.attributes.position, r = i.array, s = e.index.array, n = s.length / 3, a = new Float32Array(n * 6), o = i.offset || 0, l = 3; i.isInterleavedBufferAttribute && (l = i.data.stride); for (let h = 0; h < n; h++) { let u = h * 3, c = h * 6, d = s[u + 0] * l + o, p = s[u + 1] * l + o, f = s[u + 2] * l + o; for (let g = 0; g < 3; g++) { let m = r[d + g], v = r[p + g], y = r[f + g], b = m; v < b && (b = v), y < b && (b = y); let x = m; v > x && (x = v), y > x && (x = y); let w = (x - b) / 2, A = g * 2; (a[c + A + 0] = b + w), (a[c + A + 1] = w + (Math.abs(b) + w) * BU), b < t[g] && (t[g] = b), x > t[g + 3] && (t[g + 3] = x); } } return a; } function HU(e, t) { function i(v) { d && d(v / p); } function r(v, y, b, x = null, w = 0) { if ( (!f && w >= l && ((f = !0), h && (console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`), console.warn(e))), b <= u || w >= l) ) return i(y + b), (v.offset = y), (v.count = b), v; let A = jU(v.boundingData, x, a, y, b, c); if (A.axis === -1) return i(y + b), (v.offset = y), (v.count = b), v; let S = FU(o, a, y, b, A); if (S === y || S === y + b) i(y + b), (v.offset = y), (v.count = b); else { v.splitAxis = A.axis; let _ = new Sc(), M = y, C = S - y; (v.left = _), (_.boundingData = new Float32Array(6)), Fp(a, M, C, _.boundingData, n), r(_, M, C, n, w + 1); let T = new Sc(), P = S, L = b - C; (v.right = T), (T.boundingData = new Float32Array(6)), Fp(a, P, L, T.boundingData, n), r(T, P, L, n, w + 1); } return v; } zU(e, t); let s = new Float32Array(6), n = new Float32Array(6), a = VU(e, s), o = e.index.array, l = t.maxDepth, h = t.verbose, u = t.maxLeafTris, c = t.strategy, d = t.onProgress, p = e.index.count / 3, f = !1, g = [], m = NU(e); if (m.length === 1) { let v = m[0], y = new Sc(); (y.boundingData = s), UU(a, v.offset, v.count, n), r(y, v.offset, v.count, n), g.push(y); } else for (let v of m) { let y = new Sc(); (y.boundingData = new Float32Array(6)), Fp(a, v.offset, v.count, y.boundingData, n), r(y, v.offset, v.count, n), g.push(y); } return g; } function WU(e, t) { let i = HU(e, t), r, s, n, a = [], o = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer; for (let u = 0; u < i.length; u++) { let c = i[u], d = l(c), p = new o(32 * d); (r = new Float32Array(p)), (s = new Uint32Array(p)), (n = new Uint16Array(p)), h(0, c), a.push(p); } return a; function l(u) { return u.count ? 1 : 1 + l(u.left) + l(u.right); } function h(u, c) { let d = u / 4, p = u / 2, f = !!c.count, g = c.boundingData; for (let m = 0; m < 6; m++) r[d + m] = g[m]; if (f) { let m = c.offset, v = c.count; return (s[d + 6] = m), (n[p + 14] = v), (n[p + 15] = 65535), u + 32; } else { let m = c.left, v = c.right, y = c.splitAxis, b; if (((b = h(u + 32, m)), b / 4 > Math.pow(2, 32))) throw new Error('MeshBVH: Cannot store child pointer greater than 32 bits.'); return (s[d + 6] = b / 4), (b = h(b, v)), (s[d + 7] = y), b; } } } var bs = class { constructor() { (this.min = 1 / 0), (this.max = -1 / 0); } setFromPointsField(e, t) { let i = 1 / 0, r = -1 / 0; for (let s = 0, n = e.length; s < n; s++) { let a = e[s][t]; (i = a < i ? a : i), (r = a > r ? a : r); } (this.min = i), (this.max = r); } setFromPoints(e, t) { let i = 1 / 0, r = -1 / 0; for (let s = 0, n = t.length; s < n; s++) { let a = t[s], o = e.dot(a); (i = o < i ? o : i), (r = o > r ? o : r); } (this.min = i), (this.max = r); } isSeparated(e) { return this.min > e.max || e.min > this.max; } }; bs.prototype.setFromBox = (function () { let e = new E(); return function (t, i) { let r = i.min, s = i.max, n = 1 / 0, a = -1 / 0; for (let o = 0; o <= 1; o++) for (let l = 0; l <= 1; l++) for (let h = 0; h <= 1; h++) { (e.x = r.x * o + s.x * (1 - o)), (e.y = r.y * l + s.y * (1 - l)), (e.z = r.z * h + s.z * (1 - h)); let u = t.dot(e); (n = Math.min(u, n)), (a = Math.max(u, a)); } (this.min = n), (this.max = a); }; })(); var M9 = (function () { let e = new bs(); return function (t, i) { let r = t.points, s = t.satAxes, n = t.satBounds, a = i.points, o = i.satAxes, l = i.satBounds; for (let h = 0; h < 3; h++) { let u = n[h], c = s[h]; if ((e.setFromPoints(c, a), u.isSeparated(e))) return !1; } for (let h = 0; h < 3; h++) { let u = l[h], c = o[h]; if ((e.setFromPoints(c, r), u.isSeparated(e))) return !1; } }; })(), XU = (function () { let e = new E(), t = new E(), i = new E(); return function (r, s, n) { let a = r.start, o = e, l = s.start, h = t; i.subVectors(a, l), e.subVectors(r.end, s.start), t.subVectors(s.end, s.start); let u = i.dot(h), c = h.dot(o), d = h.dot(h), p = i.dot(o), f = o.dot(o) * d - c * c, g, m; f !== 0 ? (g = (u * c - p * d) / f) : (g = 0), (m = (u + g * c) / d), (n.x = g), (n.y = m); }; })(), Jg = (function () { let e = new G(), t = new E(), i = new E(); return function (r, s, n, a) { XU(r, s, e); let o = e.x, l = e.y; if (o >= 0 && o <= 1 && l >= 0 && l <= 1) { r.at(o, n), s.at(l, a); return; } else if (o >= 0 && o <= 1) { l < 0 ? s.at(0, a) : s.at(1, a), r.closestPointToPoint(a, !0, n); return; } else if (l >= 0 && l <= 1) { o < 0 ? r.at(0, n) : r.at(1, n), s.closestPointToPoint(n, !0, a); return; } else { let h; o < 0 ? (h = r.start) : (h = r.end); let u; l < 0 ? (u = s.start) : (u = s.end); let c = t, d = i; if ((r.closestPointToPoint(u, !0, t), s.closestPointToPoint(h, !0, i), c.distanceToSquared(u) <= d.distanceToSquared(h))) { n.copy(c), a.copy(u); return; } else { n.copy(h), a.copy(d); return; } } }; })(), qU = (function () { let e = new E(), t = new E(), i = new yr(), r = new _r(); return function (s, n) { let { radius: a, center: o } = s, { a: l, b: h, c: u } = n; if ( ((r.start = l), (r.end = h), r.closestPointToPoint(o, !0, e).distanceTo(o) <= a || ((r.start = l), (r.end = u), r.closestPointToPoint(o, !0, e).distanceTo(o) <= a) || ((r.start = h), (r.end = u), r.closestPointToPoint(o, !0, e).distanceTo(o) <= a)) ) return !0; let c = n.getPlane(i); if (Math.abs(c.distanceToPoint(o)) <= a) { let d = c.projectPoint(o, t); if (n.containsPoint(d)) return !0; } return !1; }; })(), YU = 1e-15; function Qa(e) { return Math.abs(e) < YU; } var Xs = class extends Bi { constructor(...e) { super(...e), (this.isExtendedTriangle = !0), (this.satAxes = new Array(4).fill().map(() => new E())), (this.satBounds = new Array(4).fill().map(() => new bs())), (this.points = [this.a, this.b, this.c]), (this.sphere = new Mr()), (this.plane = new yr()), (this.needsUpdate = !0); } intersectsSphere(e) { return qU(e, this); } update() { let e = this.a, t = this.b, i = this.c, r = this.points, s = this.satAxes, n = this.satBounds, a = s[0], o = n[0]; this.getNormal(a), o.setFromPoints(a, r); let l = s[1], h = n[1]; l.subVectors(e, t), h.setFromPoints(l, r); let u = s[2], c = n[2]; u.subVectors(t, i), c.setFromPoints(u, r); let d = s[3], p = n[3]; d.subVectors(i, e), p.setFromPoints(d, r), this.sphere.setFromPoints(this.points), this.plane.setFromNormalAndCoplanarPoint(a, e), (this.needsUpdate = !1); } }; Xs.prototype.closestPointToSegment = (function () { let e = new E(), t = new E(), i = new _r(); return function (r, s = null, n = null) { let { start: a, end: o } = r, l = this.points, h, u = 1 / 0; for (let c = 0; c < 3; c++) { let d = (c + 1) % 3; i.start.copy(l[c]), i.end.copy(l[d]), Jg(i, r, e, t), (h = e.distanceToSquared(t)), h < u && ((u = h), s && s.copy(e), n && n.copy(t)); } return ( this.closestPointToPoint(a, e), (h = a.distanceToSquared(e)), h < u && ((u = h), s && s.copy(e), n && n.copy(a)), this.closestPointToPoint(o, e), (h = o.distanceToSquared(e)), h < u && ((u = h), s && s.copy(e), n && n.copy(o)), Math.sqrt(u) ); }; })(); Xs.prototype.intersectsTriangle = (function () { let e = new Xs(), t = new Array(3), i = new Array(3), r = new bs(), s = new bs(), n = new E(), a = new E(), o = new E(), l = new E(), h = new _r(), u = new _r(), c = new _r(); return function (d, p = null) { this.needsUpdate && this.update(), d.isExtendedTriangle ? d.needsUpdate && d.update() : (e.copy(d), e.update(), (d = e)); let f = this.plane, g = d.plane; if (Math.abs(f.normal.dot(g.normal)) > 1 - 1e-10) { let m = this.satBounds, v = this.satAxes; (i[0] = d.a), (i[1] = d.b), (i[2] = d.c); for (let x = 0; x < 4; x++) { let w = m[x], A = v[x]; if ((r.setFromPoints(A, i), w.isSeparated(r))) return !1; } let y = d.satBounds, b = d.satAxes; (t[0] = this.a), (t[1] = this.b), (t[2] = this.c); for (let x = 0; x < 4; x++) { let w = y[x], A = b[x]; if ((r.setFromPoints(A, t), w.isSeparated(r))) return !1; } for (let x = 0; x < 4; x++) { let w = v[x]; for (let A = 0; A < 4; A++) { let S = b[A]; if ((n.crossVectors(w, S), r.setFromPoints(n, t), s.setFromPoints(n, i), r.isSeparated(s))) return !1; } } return ( p && (console.warn( 'ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.' ), p.start.set(0, 0, 0), p.end.set(0, 0, 0)), !0 ); } else { let m = this.points, v = !1, y = 0; for (let P = 0; P < 3; P++) { let L = m[P], D = m[(P + 1) % 3]; h.start.copy(L), h.end.copy(D), h.delta(a); let k = v ? u.start : u.end, W = Qa(g.distanceToPoint(L)); if (Qa(g.normal.dot(a)) && W) { u.copy(h), (y = 2); break; } if ((g.intersectLine(h, k) || W) && !Qa(k.distanceTo(D))) { if ((y++, v)) break; v = !0; } } if (y === 1 && this.containsPoint(u.start)) return p && (p.start.copy(u.start), p.end.copy(u.start)), !0; if (y !== 2) return !1; let b = d.points, x = !1, w = 0; for (let P = 0; P < 3; P++) { let L = b[P], D = b[(P + 1) % 3]; h.start.copy(L), h.end.copy(D), h.delta(o); let k = x ? c.start : c.end, W = Qa(f.distanceToPoint(L)); if (Qa(f.normal.dot(o)) && W) { c.copy(h), (w = 2); break; } if ((f.intersectLine(h, k) || W) && !Qa(k.distanceTo(D))) { if ((w++, x)) break; x = !0; } } if (w === 1 && this.containsPoint(c.start)) return p && (p.start.copy(c.start), p.end.copy(c.start)), !0; if (w !== 2) return !1; if ((u.delta(a), c.delta(o), a.dot(o) < 0)) { let P = c.start; (c.start = c.end), (c.end = P); } let A = u.start.dot(a), S = u.end.dot(a), _ = c.start.dot(a), M = c.end.dot(a), C = S < _, T = A < M; return A !== M && _ !== S && C === T ? !1 : (p && (l.subVectors(u.start, c.start), l.dot(a) > 0 ? p.start.copy(u.start) : p.start.copy(c.start), l.subVectors(u.end, c.end), l.dot(a) < 0 ? p.end.copy(u.end) : p.end.copy(c.end)), !0); } }; })(); Xs.prototype.distanceToPoint = (function () { let e = new E(); return function (t) { return this.closestPointToPoint(t, e), t.distanceTo(e); }; })(); Xs.prototype.distanceToTriangle = (function () { let e = new E(), t = new E(), i = ['a', 'b', 'c'], r = new _r(), s = new _r(); return function (n, a = null, o = null) { let l = a || o ? r : null; if (this.intersectsTriangle(n, l)) return (a || o) && (a && l.getCenter(a), o && l.getCenter(o)), 0; let h = 1 / 0; for (let u = 0; u < 3; u++) { let c, d = i[u], p = n[d]; this.closestPointToPoint(p, e), (c = p.distanceToSquared(e)), c < h && ((h = c), a && a.copy(e), o && o.copy(p)); let f = this[d]; n.closestPointToPoint(f, e), (c = f.distanceToSquared(e)), c < h && ((h = c), a && a.copy(f), o && o.copy(e)); } for (let u = 0; u < 3; u++) { let c = i[u], d = i[(u + 1) % 3]; r.set(this[c], this[d]); for (let p = 0; p < 3; p++) { let f = i[p], g = i[(p + 1) % 3]; s.set(n[f], n[g]), Jg(r, s, e, t); let m = e.distanceToSquared(t); m < h && ((h = m), a && a.copy(e), o && o.copy(t)); } } return Math.sqrt(h); }; })(); var ws = class extends Kt { constructor(...e) { super(...e), (this.isOrientedBox = !0), (this.matrix = new ve()), (this.invMatrix = new ve()), (this.points = new Array(8).fill().map(() => new E())), (this.satAxes = new Array(3).fill().map(() => new E())), (this.satBounds = new Array(3).fill().map(() => new bs())), (this.alignedSatBounds = new Array(3).fill().map(() => new bs())), (this.needsUpdate = !1); } set(e, t, i) { super.set(e, t), this.matrix.copy(i), (this.needsUpdate = !0); } copy(e) { super.copy(e), this.matrix.copy(e.matrix), (this.needsUpdate = !0); } }; ws.prototype.update = (function () { return function () { let e = this.matrix, t = this.min, i = this.max, r = this.points; for (let l = 0; l <= 1; l++) for (let h = 0; h <= 1; h++) for (let u = 0; u <= 1; u++) { let c = (1 * l) | (2 * h) | (4 * u), d = r[c]; (d.x = l ? i.x : t.x), (d.y = h ? i.y : t.y), (d.z = u ? i.z : t.z), d.applyMatrix4(e); } let s = this.satBounds, n = this.satAxes, a = r[0]; for (let l = 0; l < 3; l++) { let h = n[l], u = s[l], c = 1 << l, d = r[c]; h.subVectors(a, d), u.setFromPoints(h, r); } let o = this.alignedSatBounds; o[0].setFromPointsField(r, 'x'), o[1].setFromPointsField(r, 'y'), o[2].setFromPointsField(r, 'z'), this.invMatrix.copy(this.matrix).invert(), (this.needsUpdate = !1); }; })(); ws.prototype.intersectsBox = (function () { let e = new bs(); return function (t) { this.needsUpdate && this.update(); let i = t.min, r = t.max, s = this.satBounds, n = this.satAxes, a = this.alignedSatBounds; if ( ((e.min = i.x), (e.max = r.x), a[0].isSeparated(e) || ((e.min = i.y), (e.max = r.y), a[1].isSeparated(e)) || ((e.min = i.z), (e.max = r.z), a[2].isSeparated(e))) ) return !1; for (let o = 0; o < 3; o++) { let l = n[o], h = s[o]; if ((e.setFromBox(l, t), h.isSeparated(e))) return !1; } return !0; }; })(); ws.prototype.intersectsTriangle = (function () { let e = new Xs(), t = new Array(3), i = new bs(), r = new bs(), s = new E(); return function (n) { this.needsUpdate && this.update(), n.isExtendedTriangle ? n.needsUpdate && n.update() : (e.copy(n), e.update(), (n = e)); let a = this.satBounds, o = this.satAxes; (t[0] = n.a), (t[1] = n.b), (t[2] = n.c); for (let c = 0; c < 3; c++) { let d = a[c], p = o[c]; if ((i.setFromPoints(p, t), d.isSeparated(i))) return !1; } let l = n.satBounds, h = n.satAxes, u = this.points; for (let c = 0; c < 3; c++) { let d = l[c], p = h[c]; if ((i.setFromPoints(p, u), d.isSeparated(i))) return !1; } for (let c = 0; c < 3; c++) { let d = o[c]; for (let p = 0; p < 4; p++) { let f = h[p]; if ((s.crossVectors(d, f), i.setFromPoints(s, t), r.setFromPoints(s, u), i.isSeparated(r))) return !1; } } return !0; }; })(); ws.prototype.closestPointToPoint = (function () { return function (e, t) { return this.needsUpdate && this.update(), t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min, this.max).applyMatrix4(this.matrix), t; }; })(); ws.prototype.distanceToPoint = (function () { let e = new E(); return function (t) { return this.closestPointToPoint(t, e), t.distanceTo(e); }; })(); ws.prototype.distanceToBox = (function () { let e = ['x', 'y', 'z'], t = new Array(12).fill().map(() => new _r()), i = new Array(12).fill().map(() => new _r()), r = new E(), s = new E(); return function (n, a = 0, o = null, l = null) { if ((this.needsUpdate && this.update(), this.intersectsBox(n))) return (o || l) && (n.getCenter(s), this.closestPointToPoint(s, r), n.closestPointToPoint(r, s), o && o.copy(r), l && l.copy(s)), 0; let h = a * a, u = n.min, c = n.max, d = this.points, p = 1 / 0; for (let g = 0; g < 8; g++) { let m = d[g]; s.copy(m).clamp(u, c); let v = m.distanceToSquared(s); if (v < p && ((p = v), o && o.copy(m), l && l.copy(s), v < h)) return Math.sqrt(v); } let f = 0; for (let g = 0; g < 3; g++) for (let m = 0; m <= 1; m++) for (let v = 0; v <= 1; v++) { let y = (g + 1) % 3, b = (g + 2) % 3, x = (m << y) | (v << b), w = (1 << g) | (m << y) | (v << b), A = d[x], S = d[w]; t[f].set(A, S); let _ = e[g], M = e[y], C = e[b], T = i[f], P = T.start, L = T.end; (P[_] = u[_]), (P[M] = m ? u[M] : c[M]), (P[C] = v ? u[C] : c[M]), (L[_] = c[_]), (L[M] = m ? u[M] : c[M]), (L[C] = v ? u[C] : c[M]), f++; } for (let g = 0; g <= 1; g++) for (let m = 0; m <= 1; m++) for (let v = 0; v <= 1; v++) { (s.x = g ? c.x : u.x), (s.y = m ? c.y : u.y), (s.z = v ? c.z : u.z), this.closestPointToPoint(s, r); let y = s.distanceToSquared(r); if (y < p && ((p = y), o && o.copy(r), l && l.copy(s), y < h)) return Math.sqrt(y); } for (let g = 0; g < 12; g++) { let m = t[g]; for (let v = 0; v < 12; v++) { let y = i[v]; Jg(m, y, r, s); let b = r.distanceToSquared(s); if (b < p && ((p = b), o && o.copy(r), l && l.copy(s), b < h)) return Math.sqrt(b); } } return Math.sqrt(p); }; })(); var Cc = new E(), Tc = new E(), Pc = new E(), ix = new G(), rx = new G(), sx = new G(), nx = new E(); function QU(e, t, i, r, s, n) { let a; return ( n === hi ? (a = e.intersectTriangle(r, i, t, !0, s)) : (a = e.intersectTriangle(t, i, r, n !== er, s)), a === null ? null : { distance: e.origin.distanceTo(s), point: s.clone() } ); } function ZU(e, t, i, r, s, n, a) { Cc.fromBufferAttribute(t, r), Tc.fromBufferAttribute(t, s), Pc.fromBufferAttribute(t, n); let o = QU(e, Cc, Tc, Pc, nx, a); if (o) { i && (ix.fromBufferAttribute(i, r), rx.fromBufferAttribute(i, s), sx.fromBufferAttribute(i, n), (o.uv = Bi.getUV(nx, Cc, Tc, Pc, ix, rx, sx, new G()))); let l = { a: r, b: s, c: n, normal: new E(), materialIndex: 0 }; Bi.getNormal(Cc, Tc, Pc, l.normal), (o.face = l), (o.faceIndex = r); } return o; } function nA(e, t, i, r, s) { let n = r * 3, a = e.index.getX(n), o = e.index.getX(n + 1), l = e.index.getX(n + 2), h = ZU(i, e.attributes.position, e.attributes.uv, a, o, l, t); return h ? ((h.faceIndex = r), s && s.push(h), h) : null; } function KU(e, t, i, r, s, n) { for (let a = r, o = r + s; a < o; a++) nA(e, t, i, a, n); } function JU(e, t, i, r, s) { let n = 1 / 0, a = null; for (let o = r, l = r + s; o < l; o++) { let h = nA(e, t, i, o); h && h.distance < n && ((a = h), (n = h.distance)); } return a; } function aA(e, t, i) { return e === null || (e.point.applyMatrix4(t.matrixWorld), (e.distance = e.point.distanceTo(i.ray.origin)), (e.object = t), e.distance < i.near || e.distance > i.far) ? null : e; } function ns(e, t, i, r) { let s = e.a, n = e.b, a = e.c, o = t, l = t + 1, h = t + 2; i && ((o = i.getX(t)), (l = i.getX(t + 1)), (h = i.getX(t + 2))), (s.x = r.getX(o)), (s.y = r.getY(o)), (s.z = r.getZ(o)), (n.x = r.getX(l)), (n.y = r.getY(l)), (n.z = r.getZ(l)), (a.x = r.getX(h)), (a.y = r.getY(h)), (a.z = r.getZ(h)); } function ax(e, t, i, r, s, n, a) { let o = i.index, l = i.attributes.position; for (let h = e, u = t + e; h < u; h++) if ((ns(a, h * 3, o, l), (a.needsUpdate = !0), r(a, h, s, n))) return !0; return !1; } var oA = class { constructor(e) { (this._getNewPrimitive = e), (this._primitives = []); } getPrimitive() { let e = this._primitives; return e.length === 0 ? this._getNewPrimitive() : e.pop(); } releasePrimitive(e) { this._primitives.push(e); } }; function fn(e, t) { return t[e + 15] === 65535; } function Co(e, t) { return t[e + 6]; } function wh(e, t) { return t[e + 14]; } function _h(e) { return e + 8; } function Ah(e, t) { return t[e + 6]; } function $U(e, t) { return t[e + 7]; } var vo = new Kt(), Xd = new E(), eF = ['x', 'y', 'z']; function Tm(e, t, i, r, s) { let n = e * 2, a = il, o = Cn, l = Tn; if (fn(n, o)) { let h = Co(e, l), u = wh(n, o); KU(t, i, r, h, u, s); } else { let h = _h(e); qd(h, a, r, Xd) && Tm(h, t, i, r, s); let u = Ah(e, l); qd(u, a, r, Xd) && Tm(u, t, i, r, s); } } function Pm(e, t, i, r) { let s = e * 2, n = il, a = Cn, o = Tn; if (fn(s, a)) { let l = Co(e, o), h = wh(s, a); return JU(t, i, r, l, h); } else { let l = $U(e, o), h = eF[l], u = r.direction[h] >= 0, c, d; u ? ((c = _h(e)), (d = Ah(e, o))) : ((c = Ah(e, o)), (d = _h(e))); let p = qd(c, n, r, Xd) ? Pm(c, t, i, r) : null; if (p) { let g = p.point[h]; if (u ? g <= n[d + l] : g >= n[d + l + 3]) return p; } let f = qd(d, n, r, Xd) ? Pm(d, t, i, r) : null; return p && f ? (p.distance <= f.distance ? p : f) : p || f || null; } } var tF = (function () { let e, t, i = [], r = new oA(() => new Kt()); return function (...n) { (e = r.getPrimitive()), (t = r.getPrimitive()), i.push(e, t); let a = s(...n); r.releasePrimitive(e), r.releasePrimitive(t), i.pop(), i.pop(); let o = i.length; return o > 0 && ((t = i[o - 1]), (e = i[o - 2])), a; }; function s(n, a, o, l, h = null, u = 0, c = 0) { function d(y) { let b = y * 2, x = Cn, w = Tn; for (; !fn(b, x); ) (y = _h(y)), (b = y * 2); return Co(y, w); } function p(y) { let b = y * 2, x = Cn, w = Tn; for (; !fn(b, x); ) (y = Ah(y, w)), (b = y * 2); return Co(y, w) + wh(b, x); } let f = n * 2, g = il, m = Cn, v = Tn; if (fn(f, m)) { let y = Co(n, v), b = wh(f, m); return ls(n, g, e), l(y, b, !1, c, u + n, e); } else { let y = _h(n), b = Ah(n, v), x = y, w = b, A, S, _, M; if (h && ((_ = e), (M = t), ls(x, g, _), ls(w, g, M), (A = h(_)), (S = h(M)), S < A)) { (x = b), (w = y); let W = A; (A = S), (S = W), (_ = M); } _ || ((_ = e), ls(x, g, _)); let C = fn(x * 2, m), T = o(_, C, A, c + 1, u + x), P; if (T === 2) { let W = d(x), X = p(x) - W; P = l(W, X, !0, c + 1, u + x, _); } else P = T && s(x, a, o, l, h, u, c + 1); if (P) return !0; (M = t), ls(w, g, M); let L = fn(w * 2, m), D = o(M, L, S, c + 1, u + w), k; if (D === 2) { let W = d(w), X = p(w) - W; k = l(W, X, !0, c + 1, u + w, M); } else k = D && s(w, a, o, l, h, u, c + 1); return !!k; } } })(), iF = (function () { let e = new Xs(), t = new Xs(), i = new ve(), r = new ws(), s = new ws(); return function n(a, o, l, h, u = null) { let c = a * 2, d = il, p = Cn, f = Tn; if ((u === null && (l.boundingBox || l.computeBoundingBox(), r.set(l.boundingBox.min, l.boundingBox.max, h), (u = r)), fn(c, p))) { let g = o, m = g.index, v = g.attributes.position, y = l.index, b = l.attributes.position, x = Co(a, f), w = wh(c, p); if ((i.copy(h).invert(), l.boundsTree)) return ( ls(a, d, s), s.matrix.copy(i), (s.needsUpdate = !0), l.boundsTree.shapecast({ intersectsBounds: (A) => s.intersectsBox(A), intersectsTriangle: (A) => { A.a.applyMatrix4(h), A.b.applyMatrix4(h), A.c.applyMatrix4(h), (A.needsUpdate = !0); for (let S = x * 3, _ = (w + x) * 3; S < _; S += 3) if ((ns(t, S, m, v), (t.needsUpdate = !0), A.intersectsTriangle(t))) return !0; return !1; } }) ); for (let A = x * 3, S = w + x * 3; A < S; A += 3) { ns(e, A, m, v), e.a.applyMatrix4(i), e.b.applyMatrix4(i), e.c.applyMatrix4(i), (e.needsUpdate = !0); for (let _ = 0, M = y.count; _ < M; _ += 3) if ((ns(t, _, y, b), (t.needsUpdate = !0), e.intersectsTriangle(t))) return !0; } } else { let g = a + 8, m = f[a + 6]; return ls(g, d, vo), !!((u.intersectsBox(vo) && n(g, o, l, h, u)) || (ls(m, d, vo), u.intersectsBox(vo) && n(m, o, l, h, u))); } }; })(); function qd(e, t, i, r) { return ls(e, t, vo), i.intersectBox(vo, r); } var Dm = [], ad, il, Cn, Tn; function Hl(e) { ad && Dm.push(ad), (ad = e), (il = new Float32Array(e)), (Cn = new Uint16Array(e)), (Tn = new Uint32Array(e)); } function Dc() { (ad = null), (il = null), (Cn = null), (Tn = null), Dm.length && Hl(Dm.pop()); } var kp = Symbol('skip tree generation'), jp = new Kt(), Gp = new Kt(), Za = new ve(), Yn = new ws(), Sl = new ws(), Ml = new E(), Lc = new E(), rF = new E(), sF = new E(), nF = new E(), ox = new Kt(), Yr = new oA(() => new Xs()), gi = class { static serialize(e, t = {}) { if (t.isBufferGeometry) return ( console.warn('MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature.'), gi.serialize(arguments[0], { cloneBuffers: arguments[2] === void 0 ? !0 : arguments[2] }) ); t = { cloneBuffers: !0, ...t }; let i = e.geometry, r = e._roots, s = i.getIndex(), n; return t.cloneBuffers ? (n = { roots: r.map((a) => a.slice()), index: s.array.slice() }) : (n = { roots: r, index: s.array }), n; } static deserialize(e, t, i = {}) { if (typeof i == 'boolean') return ( console.warn('MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature.'), gi.deserialize(arguments[0], arguments[1], { setIndex: arguments[2] === void 0 ? !0 : arguments[2] }) ); i = { setIndex: !0, ...i }; let { index: r, roots: s } = e, n = new gi(t, { ...i, [kp]: !0 }); if (((n._roots = s), i.setIndex)) { let a = t.getIndex(); if (a === null) { let o = new Xe(e.index, 1, !1); t.setIndex(o); } else a.array !== r && (a.array.set(r), (a.needsUpdate = !0)); } return n; } constructor(e, t = {}) { if (e.isBufferGeometry) { if (e.index && e.index.isInterleavedBufferAttribute) throw new Error('MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.'); } else throw new Error('MeshBVH: Only BufferGeometries are supported.'); if ( ((t = Object.assign( { strategy: 0, maxDepth: 40, maxLeafTris: 10, verbose: !0, useSharedArrayBuffer: !1, setBoundingBox: !0, onProgress: null, [kp]: !1 }, t )), t.useSharedArrayBuffer && typeof SharedArrayBuffer > 'u') ) throw new Error('MeshBVH: SharedArrayBuffer is not available.'); (this._roots = null), t[kp] || ((this._roots = WU(e, t)), !e.boundingBox && t.setBoundingBox && (e.boundingBox = this.getBoundingBox(new Kt()))), (this.geometry = e); } refit(e = null) { e && Array.isArray(e) && (e = new Set(e)); let t = this.geometry, i = t.index.array, r = t.attributes.position, s = r.array, n = r.offset || 0, a = 3; r.isInterleavedBufferAttribute && (a = r.data.stride); let o, l, h, u, c = 0, d = this._roots; for (let f = 0, g = d.length; f < g; f++) (o = d[f]), (l = new Uint32Array(o)), (h = new Uint16Array(o)), (u = new Float32Array(o)), p(0, c), (c += o.byteLength); function p(f, g, m = !1) { let v = f * 2; if (h[v + 15] === 65535) { let y = l[f + 6], b = h[v + 14], x = 1 / 0, w = 1 / 0, A = 1 / 0, S = -1 / 0, _ = -1 / 0, M = -1 / 0; for (let C = 3 * y, T = 3 * (y + b); C < T; C++) { let P = i[C] * a + n, L = s[P + 0], D = s[P + 1], k = s[P + 2]; L < x && (x = L), L > S && (S = L), D < w && (w = D), D > _ && (_ = D), k < A && (A = k), k > M && (M = k); } return u[f + 0] !== x || u[f + 1] !== w || u[f + 2] !== A || u[f + 3] !== S || u[f + 4] !== _ || u[f + 5] !== M ? ((u[f + 0] = x), (u[f + 1] = w), (u[f + 2] = A), (u[f + 3] = S), (u[f + 4] = _), (u[f + 5] = M), !0) : !1; } else { let y = f + 8, b = l[f + 6], x = y + g, w = b + g, A = m, S = !1, _ = !1; e ? A || ((S = e.has(x)), (_ = e.has(w)), (A = !S && !_)) : ((S = !0), (_ = !0)); let M = A || S, C = A || _, T = !1; M && (T = p(y, g, A)); let P = !1; C && (P = p(b, g, A)); let L = T || P; if (L) for (let D = 0; D < 3; D++) { let k = y + D, W = b + D, X = u[k], z = u[k + 3], j = u[W], U = u[W + 3]; (u[f + D] = X < j ? X : j), (u[f + D + 3] = z > U ? z : U); } return L; } } } traverse(e, t = 0) { let i = this._roots[t], r = new Uint32Array(i), s = new Uint16Array(i); n(0); function n(a, o = 0) { let l = a * 2, h = s[l + 15] === 65535; if (h) { let u = r[a + 6], c = s[l + 14]; e(o, h, new Float32Array(i, a * 4, 6), u, c); } else { let u = a + 8, c = r[a + 6], d = r[a + 7]; e(o, h, new Float32Array(i, a * 4, 6), d) || (n(u, o + 1), n(c, o + 1)); } } } raycast(e, t = Vr) { let i = this._roots, r = this.geometry, s = [], n = t.isMaterial, a = Array.isArray(t), o = r.groups, l = n ? t.side : t; for (let h = 0, u = i.length; h < u; h++) { let c = a ? t[o[h].materialIndex].side : l, d = s.length; if ((Hl(i[h]), Tm(0, r, c, e, s), Dc(), a)) { let p = o[h].materialIndex; for (let f = d, g = s.length; f < g; f++) s[f].face.materialIndex = p; } } return s; } raycastFirst(e, t = Vr) { let i = this._roots, r = this.geometry, s = t.isMaterial, n = Array.isArray(t), a = null, o = r.groups, l = s ? t.side : t; for (let h = 0, u = i.length; h < u; h++) { let c = n ? t[o[h].materialIndex].side : l; Hl(i[h]); let d = Pm(0, r, c, e); Dc(), d != null && (a == null || d.distance < a.distance) && ((a = d), n && (d.face.materialIndex = o[h].materialIndex)); } return a; } intersectsGeometry(e, t) { let i = this.geometry, r = !1; for (let s of this._roots) if ((Hl(s), (r = iF(0, i, e, t)), Dc(), r)) break; return r; } shapecast(e, t, i) { let r = this.geometry; if (e instanceof Function) { if (t) { let c = t; t = (d, p, f, g) => { let m = p * 3; return c(d, m, m + 1, m + 2, f, g); }; } (e = { boundsTraverseOrder: i, intersectsBounds: e, intersectsTriangle: t, intersectsRange: null }), console.warn( 'MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.' ); } let s = Yr.getPrimitive(), { boundsTraverseOrder: n, intersectsBounds: a, intersectsRange: o, intersectsTriangle: l } = e; if (o && l) { let c = o; o = (d, p, f, g, m) => (c(d, p, f, g, m) ? !0 : ax(d, p, r, l, f, g, s)); } else o || (l ? (o = (c, d, p, f) => ax(c, d, r, l, p, f, s)) : (o = (c, d, p) => p)); let h = !1, u = 0; for (let c of this._roots) { if ((Hl(c), (h = tF(0, r, a, o, n, u)), Dc(), h)) break; u += c.byteLength; } return Yr.releasePrimitive(s), h; } bvhcast(e, t, i) { let { intersectsRanges: r, intersectsTriangles: s } = i, n = this.geometry.index, a = this.geometry.attributes.position, o = e.geometry.index, l = e.geometry.attributes.position; Za.copy(t).invert(); let h = Yr.getPrimitive(), u = Yr.getPrimitive(); if (s) { let d = function (p, f, g, m, v, y, b, x) { for (let w = g, A = g + m; w < A; w++) { ns(u, w * 3, o, l), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), (u.needsUpdate = !0); for (let S = p, _ = p + f; S < _; S++) if ((ns(h, S * 3, n, a), (h.needsUpdate = !0), s(h, u, S, w, v, y, b, x))) return !0; } return !1; }; if (r) { let p = r; r = function (f, g, m, v, y, b, x, w) { return p(f, g, m, v, y, b, x, w) ? !0 : d(f, g, m, v, y, b, x, w); }; } else r = d; } e.getBoundingBox(Gp), Gp.applyMatrix4(t); let c = this.shapecast({ intersectsBounds: (d) => Gp.intersectsBox(d), intersectsRange: (d, p, f, g, m, v) => ( jp.copy(v), jp.applyMatrix4(Za), e.shapecast({ intersectsBounds: (y) => jp.intersectsBox(y), intersectsRange: (y, b, x, w, A) => r(d, p, y, b, g, m, w, A) }) ) }); return Yr.releasePrimitive(h), Yr.releasePrimitive(u), c; } intersectsBox(e, t) { return ( Yn.set(e.min, e.max, t), (Yn.needsUpdate = !0), this.shapecast({ intersectsBounds: (i) => Yn.intersectsBox(i), intersectsTriangle: (i) => Yn.intersectsTriangle(i) }) ); } intersectsSphere(e) { return this.shapecast({ intersectsBounds: (t) => e.intersectsBox(t), intersectsTriangle: (t) => t.intersectsSphere(e) }); } closestPointToGeometry(e, t, i = {}, r = {}, s = 0, n = 1 / 0) { e.boundingBox || e.computeBoundingBox(), Yn.set(e.boundingBox.min, e.boundingBox.max, t), (Yn.needsUpdate = !0); let a = this.geometry, o = a.attributes.position, l = a.index, h = e.attributes.position, u = e.index, c = Yr.getPrimitive(), d = Yr.getPrimitive(), p = Lc, f = rF, g = null, m = null; r && ((g = sF), (m = nF)); let v = 1 / 0, y = null, b = null; return ( Za.copy(t).invert(), Sl.matrix.copy(Za), this.shapecast({ boundsTraverseOrder: (x) => Yn.distanceToBox(x), intersectsBounds: (x, w, A) => (A < v && A < n ? (w && (Sl.min.copy(x.min), Sl.max.copy(x.max), (Sl.needsUpdate = !0)), !0) : !1), intersectsRange: (x, w) => { if (e.boundsTree) return e.boundsTree.shapecast({ boundsTraverseOrder: (A) => Sl.distanceToBox(A), intersectsBounds: (A, S, _) => _ < v && _ < n, intersectsRange: (A, S) => { for (let _ = A * 3, M = (A + S) * 3; _ < M; _ += 3) { ns(d, _, u, h), d.a.applyMatrix4(t), d.b.applyMatrix4(t), d.c.applyMatrix4(t), (d.needsUpdate = !0); for (let C = x * 3, T = (x + w) * 3; C < T; C += 3) { ns(c, C, l, o), (c.needsUpdate = !0); let P = c.distanceToTriangle(d, p, g); if ((P < v && (f.copy(p), m && m.copy(g), (v = P), (y = C / 3), (b = _ / 3)), P < s)) return !0; } } } }); { let A = u ? u.count : h.count; for (let S = 0, _ = A; S < _; S += 3) { ns(d, S, u, h), d.a.applyMatrix4(t), d.b.applyMatrix4(t), d.c.applyMatrix4(t), (d.needsUpdate = !0); for (let M = x * 3, C = (x + w) * 3; M < C; M += 3) { ns(c, M, l, o), (c.needsUpdate = !0); let T = c.distanceToTriangle(d, p, g); if ((T < v && (f.copy(p), m && m.copy(g), (v = T), (y = M / 3), (b = S / 3)), T < s)) return !0; } } } } }), Yr.releasePrimitive(c), Yr.releasePrimitive(d), v === 1 / 0 ? null : (i.point ? i.point.copy(f) : (i.point = f.clone()), (i.distance = v), (i.faceIndex = y), r && (r.point ? r.point.copy(m) : (r.point = m.clone()), r.point.applyMatrix4(Za), f.applyMatrix4(Za), (r.distance = f.sub(r.point).length()), (r.faceIndex = b)), i) ); } closestPointToPoint(e, t = {}, i = 0, r = 1 / 0) { let s = i * i, n = r * r, a = 1 / 0, o = null; if ( (this.shapecast({ boundsTraverseOrder: (h) => (Ml.copy(e).clamp(h.min, h.max), Ml.distanceToSquared(e)), intersectsBounds: (h, u, c) => c < a && c < n, intersectsTriangle: (h, u) => { h.closestPointToPoint(e, Ml); let c = e.distanceToSquared(Ml); return c < a && (Lc.copy(Ml), (a = c), (o = u)), c < s; } }), a === 1 / 0) ) return null; let l = Math.sqrt(a); return t.point ? t.point.copy(Lc) : (t.point = Lc.clone()), (t.distance = l), (t.faceIndex = o), t; } getBoundingBox(e) { return ( e.makeEmpty(), this._roots.forEach((t) => { ls(0, new Float32Array(t), ox), e.union(ox); }), e ); } }, lx = gi.prototype.raycast; gi.prototype.raycast = function (...e) { if (e[0].isMesh) { console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.'); let [t, i, r, s] = e; return ( lx.call(this, r, t.material).forEach((n) => { (n = aA(n, t, i)), n && s.push(n); }), s ); } else return lx.apply(this, e); }; var hx = gi.prototype.raycastFirst; gi.prototype.raycastFirst = function (...e) { if (e[0].isMesh) { console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.'); let [t, i, r] = e; return aA(hx.call(this, r, t.material), t, i); } else return hx.apply(this, e); }; var cx = gi.prototype.closestPointToPoint; gi.prototype.closestPointToPoint = function (...e) { if (e[0].isMesh) { console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'), e.unshift(); let t = e[1], i = {}; return (e[1] = i), cx.apply(this, e), t && t.copy(i.point), i.distance; } else return cx.apply(this, e); }; var dx = gi.prototype.closestPointToGeometry; gi.prototype.closestPointToGeometry = function (...e) { let t = e[2], i = e[3]; if ((t && t.isVector3) || (i && i.isVector3)) { console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.'); let r = {}, s = {}, n = e[1]; return (e[2] = r), (e[3] = s), dx.apply(this, e), t && t.copy(r.point), i && i.copy(s.point).applyMatrix4(n), r.distance; } else return dx.apply(this, e); }; var ux = gi.prototype.refit; gi.prototype.refit = function (...e) { let t = e[0], i = e[1]; if (i && (i instanceof Set || Array.isArray(i))) { console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.'); let r = new Set(); i.forEach((s) => r.add(s)), t && t.forEach((s) => r.add(s)), ux.call(this, r); } else ux.apply(this, e); }; ['intersectsGeometry', 'shapecast', 'intersectsBox', 'intersectsSphere'].forEach((e) => { let t = gi.prototype[e]; gi.prototype[e] = function (...i) { return ( (i[0] === null || i[0].isMesh) && (i.shift(), console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)), t.apply(this, i) ); }; }); var El = Eh(W2()), aF = 0.5 * (Math.sqrt(3) - 1), Cl = (3 - Math.sqrt(3)) / 6, oF = 1 / 3, Qr = 1 / 6, E9 = (Math.sqrt(5) - 1) / 4, C9 = (5 - Math.sqrt(5)) / 20, th = (e) => Math.floor(e) | 0, px = new Float64Array([1, 1, -1, 1, 1, -1, -1, -1, 1, 0, -1, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, -1]), Vp = new Float64Array([ 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1, 0, 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1, 0, 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1 ]); function Hp(e = Math.random) { let t = lA(e), i = new Float64Array(t).map((s) => px[(s % 12) * 2]), r = new Float64Array(t).map((s) => px[(s % 12) * 2 + 1]); return function (s, n) { let a = 0, o = 0, l = 0, h = (s + n) * aF, u = th(s + h), c = th(n + h), d = (u + c) * Cl, p = u - d, f = c - d, g = s - p, m = n - f, v, y; g > m ? ((v = 1), (y = 0)) : ((v = 0), (y = 1)); let b = g - v + Cl, x = m - y + Cl, w = g - 1 + 2 * Cl, A = m - 1 + 2 * Cl, S = u & 255, _ = c & 255, M = 0.5 - g * g - m * m; if (M >= 0) { let P = S + t[_], L = i[P], D = r[P]; (M *= M), (a = M * M * (L * g + D * m)); } let C = 0.5 - b * b - x * x; if (C >= 0) { let P = S + v + t[_ + y], L = i[P], D = r[P]; (C *= C), (o = C * C * (L * b + D * x)); } let T = 0.5 - w * w - A * A; if (T >= 0) { let P = S + 1 + t[_ + 1], L = i[P], D = r[P]; (T *= T), (l = T * T * (L * w + D * A)); } return 70 * (a + o + l); }; } function lF(e = Math.random) { let t = lA(e), i = new Float64Array(t).map((n) => Vp[(n % 12) * 3]), r = new Float64Array(t).map((n) => Vp[(n % 12) * 3 + 1]), s = new Float64Array(t).map((n) => Vp[(n % 12) * 3 + 2]); return function (n, a, o) { let l, h, u, c, d = (n + a + o) * oF, p = th(n + d), f = th(a + d), g = th(o + d), m = (p + f + g) * Qr, v = p - m, y = f - m, b = g - m, x = n - v, w = a - y, A = o - b, S, _, M, C, T, P; x >= w ? w >= A ? ((S = 1), (_ = 0), (M = 0), (C = 1), (T = 1), (P = 0)) : x >= A ? ((S = 1), (_ = 0), (M = 0), (C = 1), (T = 0), (P = 1)) : ((S = 0), (_ = 0), (M = 1), (C = 1), (T = 0), (P = 1)) : w < A ? ((S = 0), (_ = 0), (M = 1), (C = 0), (T = 1), (P = 1)) : x < A ? ((S = 0), (_ = 1), (M = 0), (C = 0), (T = 1), (P = 1)) : ((S = 0), (_ = 1), (M = 0), (C = 1), (T = 1), (P = 0)); let L = x - S + Qr, D = w - _ + Qr, k = A - M + Qr, W = x - C + 2 * Qr, X = w - T + 2 * Qr, z = A - P + 2 * Qr, j = x - 1 + 3 * Qr, U = w - 1 + 3 * Qr, N = A - 1 + 3 * Qr, B = p & 255, H = f & 255, Q = g & 255, Y = 0.6 - x * x - w * w - A * A; if (Y < 0) l = 0; else { let ee = B + t[H + t[Q]]; (Y *= Y), (l = Y * Y * (i[ee] * x + r[ee] * w + s[ee] * A)); } let F = 0.6 - L * L - D * D - k * k; if (F < 0) h = 0; else { let ee = B + S + t[H + _ + t[Q + M]]; (F *= F), (h = F * F * (i[ee] * L + r[ee] * D + s[ee] * k)); } let se = 0.6 - W * W - X * X - z * z; if (se < 0) u = 0; else { let ee = B + C + t[H + T + t[Q + P]]; (se *= se), (u = se * se * (i[ee] * W + r[ee] * X + s[ee] * z)); } let V = 0.6 - j * j - U * U - N * N; if (V < 0) c = 0; else { let ee = B + 1 + t[H + 1 + t[Q + 1]]; (V *= V), (c = V * V * (i[ee] * j + r[ee] * U + s[ee] * N)); } return 32 * (l + h + u + c); }; } function lA(e) { let t = new Uint8Array(512); for (let i = 0; i < 512 / 2; i++) t[i] = i; for (let i = 0; i < 512 / 2 - 1; i++) { let r = i + ~~(e() * (256 - i)), s = t[i]; (t[i] = t[r]), (t[r] = s); } for (let i = 256; i < 512; i++) t[i] = t[i - 256]; return t; } var Ir = new Bi(), hF = class { constructor(e) { this.weightAttribute = null; let t = e.geometry; if (!t.isBufferGeometry || t.attributes.position.itemSize !== 3) throw new Error('THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.'); t.index && (t = t.toNonIndexed()), (this.geometry = t), (this.randomFunction = Math.random), (this.positionAttribute = this.geometry.getAttribute('position')), (this.distribution = null); } build() { let e = this.positionAttribute, t = new Float32Array(e.count / 3); for (let r = 0; r < e.count; r += 3) { let s = 1; Ir.a.fromBufferAttribute(e, r), Ir.b.fromBufferAttribute(e, r + 1), Ir.c.fromBufferAttribute(e, r + 2), (s *= Ir.getArea()), (t[r / 3] = s); } this.distribution = new Float32Array(e.count / 3); let i = 0; for (let r = 0; r < t.length; r++) (i += t[r]), (this.distribution[r] = i); return this; } setRandomGenerator(e) { return (this.randomFunction = e), this; } sample(e, t) { if (this.distribution) { let i = this.distribution[this.distribution.length - 1], r = this.binarySearch(this.randomFunction() * i); return this.sampleFace(r, e, t); } } binarySearch(e) { if (!this.distribution) return 0; let t = this.distribution, i = 0, r = t.length - 1, s = -1; for (; i <= r; ) { let n = Math.ceil((i + r) / 2); if (n === 0 || (t[n - 1] <= e && t[n] > e)) { s = n; break; } else e < t[n] ? (r = n - 1) : (i = n + 1); } return s; } sampleFace(e, t, i) { let r = this.randomFunction(), s = this.randomFunction(); return ( r + s > 1 && ((r = 1 - r), (s = 1 - s)), Ir.a.fromBufferAttribute(this.positionAttribute, e * 3), Ir.b.fromBufferAttribute(this.positionAttribute, e * 3 + 1), Ir.c.fromBufferAttribute(this.positionAttribute, e * 3 + 2), t .set(0, 0, 0) .addScaledVector(Ir.a, r) .addScaledVector(Ir.b, s) .addScaledVector(Ir.c, 1 - (r + s)), Ir.getNormal(i), this ); } }, cF = Eh(rw()), dF = new ve(), uF = new ve(), pF = new ve(), Yd; ((e) => { function t(i) { return i && i.__isSPEObject; } e.is = t; })(Yd || (Yd = {})); var $g = (e) => class extends e { constructor() { super(...arguments), (this.hiddenMatrix = new ve()), (this.matrixWorldRigid = new ve()), (this.shearScale = new ve()), (this.shearScaleInv = new ve()); } get __isSPEObject() { return !0; } isDescendantOf(t) { t instanceof bt && (t = t.uuid); let i = this; for (; i.parent; ) { if (i.parent.uuid === t) return !0; i = i.parent; } return !1; } updateMatrixWorld(t) { this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.parent === null ? this.matrixWorld.multiplyMatrices(this.hiddenMatrix, this.matrix) : (this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.hiddenMatrix), this.matrixWorld.multiplyMatrices(this.matrixWorld, this.matrix)), (this.matrixWorldNeedsUpdate = !1), (t = !0)); for (let i of this.children) i.updateMatrixWorld(t); } updateWorldMatrix(t, i) { let r = this.parent; if ( (t && r !== null && r.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.multiplyMatrices(this.hiddenMatrix, this.matrix) : (this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.hiddenMatrix), this.matrixWorld.multiplyMatrices(this.matrixWorld, this.matrix)), i) ) for (let s of this.children) s.updateWorldMatrix(!1, !0); } traverseObject(t, i = 0) { if (t(this, i) !== !0) for (let r of this.children) Yd.is(r) && r.traverseObject(t, i + 1); } updateMatrixWorldSVD() { let t = this.matrixWorld.elements, i = [ [t[0], t[4], t[8]], [t[1], t[5], t[9]], [t[2], t[6], t[10]] ], { u: r, v: s, q: n } = (0, cF.SVD)(i), a = dF.set(r[0][0], r[0][1], r[0][2], 0, r[1][0], r[1][1], r[1][2], 0, r[2][0], r[2][1], r[2][2], 0, 0, 0, 0, 1), o = uF.set(s[0][0], s[0][1], s[0][2], 0, s[1][0], s[1][1], s[1][2], 0, s[2][0], s[2][1], s[2][2], 0, 0, 0, 0, 1), l = pF.copy(o).transpose(); this.shearScale.makeScale(n[0], n[1], n[2]).multiply(l).premultiply(o), this.shearScaleInv.copy(this.shearScale).invert(), this.matrixWorldRigid.multiplyMatrices(a, l).copyPosition(this.matrixWorld), n.every((h) => Math.abs(n[0] - h) < 0.01) ? (this.hasNonUniformScale = !1) : (this.hasNonUniformScale = !0); } attach(t, i) { this.updateWorldMatrix(!0, !1); let r = new ve().copy(this.matrixWorld).invert(); return ( t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), r.multiply(t.parent.matrixWorld)), 'hiddenMatrix' in t && t.hiddenMatrix instanceof ve ? t.hiddenMatrix.premultiply(r) : t.applyMatrix4(r), t.updateWorldMatrix(!1, !1), this.add(t), i !== void 0 && (this.children.pop(), this.children.splice(i, 0, t)), this ); } }, fF = class extends $g(bt) {}, mF = (e) => e.type === 'Mesh', la = class extends fF { constructor(e) { super(), (this.object = e), (this.matrixAutoUpdate = !1); } expand() { let e = 0, t = this.object.entityChildren(e); for (; t; ) { let i = this.children[e]; i?.object !== t && (i && this.remove(i), (i = new la(t)), this.add(i), this.children.splice(e, 0, this.children.pop()), (i.matrixWorldNeedsUpdate = !0), (i.matrixAutoUpdate = !1), (i.matrix = t.matrix), (i.hiddenMatrix = t.hiddenMatrix)), i.expand(), (e += 1), (t = this.object.entityChildren(e)); } for (; this.children.length > e; ) this.remove(this.children[e]); } get visible() { return this.object.visible || (this.object.dataPatched.visible && this.object.dataPatched.cloner?.hideBase === !0); } set visible(e) {} get castShadow() { return this.object.castShadow; } set castShadow(e) {} get receiveShadow() { return this.object.receiveShadow; } set receiveShadow(e) {} get isMesh() { return mF(this.object); } get isLight() { return this.object.isLight; } get layers() { return this.object.layers; } set layers(e) {} get isCamera() { return !1; } get geometry() { if (this.object.geometry) return this.object.geometry; } get material() { if (this.object.material) return this.object.material; } }, ra = new E(), sa = new E(), To = new ve(), hA = [ new E(-1, 1, 1), new E(-1, -1, 1), new E(1, -1, 1), new E(1, 1, 1), new E(-1, 1, -1), new E(-1, -1, -1), new E(1, -1, -1), new E(1, 1, -1) ], gF = [ [0, 3], [1, 2], [5, 6], [4, 7], [0, 1], [3, 2], [7, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7] ], vF = [ [0, 2], [7, 5], [4, 1], [3, 6], [4, 3], [1, 6] ], fx = (e, t, i) => { e.updateEntityBoxSize(ra, sa), To.copy(t).multiply(e.matrixWorld), sa.x === 0 && sa.y === 0 && sa.z === 0 ? i.push(new E(ra.x, ra.y, ra.z).applyMatrix4(To)) : hA.forEach((r) => { i.push(r.clone().multiply(sa).add(ra).applyMatrix4(To)); }); }, mx = class extends Kt { constructor() { super(...arguments), (this.matrix = new ve()), (this.vertices = []), (this.faces = []), (this.edges = []), (this.centerEdges = []); } copy(e) { return ( super.copy(e), this.matrix.copy(e.matrix), (this.vertices = e.vertices.map((t) => t.clone())), (this.faces = e.faces.map((t) => t.clone())), (this.edges = e.edges.map((t) => t.clone())), (this.centerEdges = e.centerEdges.map((t) => t.clone())), this ); } setFromObjectSize(e, t = !1) { e.updateWorldMatrix(!1, t), this.makeEmpty(), this.matrix.copy(e.matrixWorld); let i = new ve().copy(e.matrixWorld).invert(); return this.expandByObjectSize(e, i, t); } expandByObjectSize(e, t, i = !1) { let r = []; return ( i === !0 ? e.traverseEntity((s) => { (s.visible || (s.cloner && s.data.visible)) && fx(s, t, r); }) : fx(e, t, r), this.setFromPoints(r) ); } getCenter(e) { return (e = super.getCenter(e)), e.applyMatrix4(this.matrix), e; } getPositionToCenter(e) { return (e = super.getCenter(e)), e.applyMatrix4(To.copy(this.matrix).setPosition(0, 0, 0)), e; } computeVertices() { this.getSize(sa).multiplyScalar(0.5), this.getCenter(ra), To.copy(this.matrix).setPosition(ra), (this.vertices = hA.map((e) => e.clone().multiply(sa).applyMatrix4(To))); } computeEdges() { this.vertices.length > 0 && this.computeVertices(), (this.edges = gF.map(([e, t]) => new _r(this.vertices[e], this.vertices[t]))), (this.centerEdges = this.edges.map((e) => e.getCenter(new E()))); } computeFaces() { this.vertices.length > 0 && this.computeVertices(), (this.faces = vF.map(([e, t]) => this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(0.5))); } }, wn = { Cloner: () => {}, changeEntityProptotype: () => {}, createEntity: () => {} }, yF = class extends Cw { constructor() { super(); } getPoints(e = 12) { let t = [], i, r = this.getCurveLengths(), s = r[r.length - 1] / r.length; for (let n = 0, a = this.curves; n < a.length; n++) { let o = a[n], l = n === 0 ? r[n] : r[n] - r[n - 1], h = Math.ceil((e * l) / s), u = o.getPoints(h); for (let c = 0; c < u.length; c++) { let d = u[c]; (i && i.equals(d)) || (t.push(d), (i = d)); } } return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t; } }, Lm = 0.001; function Om(e, t, i) { return t.clone().sub(e).cross(t.clone().sub(i)).length() <= Lm; } function Wp(e, t) { let i = new E(...e.position), r = new E(...e.controlNext.position), s = new E(...t.controlPrevious.position), n = new E(...t.position); return Om(i, r, n) && Om(i, s, n); } function cA(e) { let t = e.points.map((u) => new E(...u.data.position)), i = [e.points[0]], r = new E(...i[0].data.position); for (let u = 0; u < e.points.length - 1; u++) Om(r, t[u], t[u + 1]) || (i.push(e.points[u]), (r = t[u])); i.push(e.points[e.points.length - 1]); let s = e.isClosed, n = i.length - (s ? 0 : 1), a = i.length, o = []; for (let u = 0; u < a; u++) { let c = i[u].data, d = new E(...c.position), p = new E(...c.controlPrevious.position), f = new E(...c.controlNext.position), g = { position: d, baseRoundness: c.roundness, controlPrevious: p, controlNext: f }; if (c.roundness === 0 || (!e.isClosed && (u === 0 || u === a - 1))) { o[u] = { ...g, removedLength: 0 }; continue; } let m = s && u == 0 ? a - 1 : u - 1, v = s && u == a - 1 ? 0 : u + 1, y = i[m].data, b = i[v].data, x = new E(...y.position), w = new E(...b.position), A = x.clone().sub(d).normalize(), S = w.clone().sub(d).normalize(); Object.assign(g, { prevDir: A, nextDir: S }); let _ = Wp(y, c), M = Wp(c, b); if (!_ || !M) o[u] = { ...g, removedLength: 0 }; else { let C = A.clone().add(S).normalize(), T = C.clone().cross(A).length() / A.dot(C); o[u] = { ...g, tan: T, removedLength: c.roundness / T }; } } for (let u = 0; u < n; u++) { let c = u, d = s && u === a - 1 ? 0 : u + 1, p = o[c], f = o[d]; if (p.removedLength !== 0 || f.removedLength !== 0) { let g = p.position.distanceTo(f.position); (p.removedLength = Math.min(p.removedLength, g / 2)), (f.removedLength = Math.min(f.removedLength, g / 2)); } } let l = []; for (let u = 0; u < n; u++) { let c = u, d = s && u === a - 1 ? 0 : u + 1, p = o[c], f = o[d], g = null; if (!Wp(i[c].data, i[d].data)) p.position.distanceTo(f.position) > Lm && (g = new $c(p.position, p.controlNext, f.controlPrevious, f.position)); else { let m = p.position.clone(), v = f.position.clone(); (p.removedLength !== 0 || f.removedLength !== 0) && (p.nextDir && m.add(p.nextDir.clone().setLength(p.removedLength)), f.prevDir && v.add(f.prevDir.clone().setLength(f.removedLength))), m.distanceTo(v) > Lm && (g = new $c(m, m.clone().lerp(v, 0.3), v.clone().lerp(m, 0.3), v)); } l[2 * u + 1] = g; } for (let u = 0; u < a; u++) { let c = o[u]; if (c.removedLength === 0) { l[2 * u] = null; continue; } let d = c.position, p = c.prevDir.clone().multiplyScalar(c.removedLength).add(d), f = c.nextDir.clone().multiplyScalar(c.removedLength).add(d), g = c.tan * c.removedLength, m = c.prevDir.clone().add(c.nextDir).normalize(), v = p.clone().lerp(f, 0.5), y = p.distanceTo(f) / 2, b = m .clone() .multiplyScalar(Math.sqrt(Math.pow(g, 2) - Math.pow(y, 2))) .add(v), x = m.clone().multiplyScalar(-g).add(b), w = d.distanceTo(x) / d.distanceTo(v), A = c.prevDir .clone() .multiplyScalar(w * d.distanceTo(p)) .add(d), S = A.clone().lerp(x, 2), _ = p.clone().lerp(A, 4 / 3), M = f.clone().lerp(S, 4 / 3); l[2 * u] = new $c(p, _, M, f); } let h = new yF(); return ( l.forEach((u) => { u && h.add(u); }), h ); } var Ct; ((e) => { function t(i) { return i && i.__isEntity; } e.is = t; })(Ct || (Ct = {})); var mn = (e) => Ct.is(e), xF = { type: 'completeState', isfromEntity: !0 }, dA = (e) => class extends $g(e) { constructor() { super(...arguments), (this.raycastLock = !1), (this.scaleLock = !1), (this.disposed = !1), (this.stateSelection = null), (this.instances = []), (this.prevState = null), (this.currentState = null), (this.reversibleToState = null), (this.currentTransitionEvent = null), (this.previousAction = null), (this._singleBBox = new mx()), (this._recursiveBBox = new mx()), (this.singleBBoxNeedsUpdate = !0), (this.recursiveBBoxNeedsUpdate = !0), (this._needApplyPathSnapping = !0), (this.attachedPaths = new Set()); } get __isEntity() { return !0; } entityChildren(t) { let i = this.children[t]; if (Ct.is(i)) return i; } get isConcreteEntity() { return typeof this.identity == 'string'; } get isVirtualEntity() { return typeof this.identity != 'string'; } get isInstanceRoot() { return this.isConcreteEntity && this.data.type === 'Instance'; } nearestInstanceSelfOrParent() { let t = this; for (; t.data.type !== 'Instance'; ) { let i = t.parent; if (Ct.is(i)) t = i; else return; } return t; } forInstancesRec(t) { this.instances.forEach((i) => { i.disposed || t(i), i.forInstancesRec(t); }); } super_Entity(t, i) { typeof t == 'string' && (this.uuid = t), (this.identity = t), (this.data = i), (this.matrixAutoUpdate = !1), (this.dataPatched = this.data); } changeSelectedState(t, i, r = !1) { if (!(this.data.states.length === 0 && !r)) { for (let s of this.data.states) oa.toOps(this.data, s.data).forEach((n) => { let a = im.replaceProps(n, this.data); (this.dataPatched = this.data), this.updateByPatchedOp(a, this.data, i); }); if (t !== null) { let s = this.data.states.data(t); s && ((this.dataPatched = oa.patch(this.data, s)), oa.toOps(this.data, s).forEach((n) => { this.updateByPatchedOp(n, this.dataPatched, i); })); } r && this.updateTransformState(this.dataPatched), (this.stateSelection = t), this.updatePathSnapping(this.dataPatched.pathSnapping); } } get singleBBox() { return ( this.singleBBoxNeedsUpdate && ((this.singleBBoxNeedsUpdate = !1), this._singleBBox.setFromObjectSize(this, !1), this._singleBBox.computeVertices(), this._singleBBox.computeEdges(), this._singleBBox.computeFaces()), this._singleBBox ); } get recursiveBBox() { return ( this.recursiveBBoxNeedsUpdate && ((this.recursiveBBoxNeedsUpdate = !1), this._recursiveBBox.setFromObjectSize(this, !0), this._recursiveBBox.computeVertices(), this._recursiveBBox.computeEdges(), this._recursiveBBox.computeFaces()), this._recursiveBBox ); } updateEntityBoxSize(t, i) { t.setScalar(0), i.setScalar(0); } resetBBoxNeedsUpdateSelf() { (this.singleBBoxNeedsUpdate = !0), (this.recursiveBBoxNeedsUpdate = !0); } resetBBoxNeedsUpdate() { this.resetBBoxNeedsUpdateSelf(), this.traverseAncestors((t) => { mn(t) && t.resetBBoxNeedsUpdateSelf(); }), this.traverseEntity((t) => { t.resetBBoxNeedsUpdateSelf(); }); } find(t) { let i; return ( this.traverseEntity((r) => { r.uuid === t && (i = r); }), i ); } traverseSortNextHelper() { let t = this.parent; if (t) { let i = t.children, r = i.indexOf(this) + 1; if (Ct.is(i[r])) return i[r]; if (Ct.is(t)) return t.traverseSortNextHelper(); } } sortNext() { let t = this.children; return this.children.length > 0 && Ct.is(this.children[0]) ? t[0] : this.traverseSortNextHelper(); } goUp(t) { let i = this; for (; t > 0 && i !== null; ) (i = i.parent), (t -= 1); return i; } hasAnccestorOrSelf(t) { return this === t || this.hasAnccestor(t); } hasAnccestor(t) { let i = this.parent; for (; i; ) { if (t === i) return !0; i = i.parent; } return !1; } countToAccestor(t) { let i = 0, r = this; for (; r !== t; ) { if (r === null) return -1; (r = r.parent), (i += 1); } return i; } forEachEntity(t) { for (let i of this.children) mn(i) && t(i); } traverseEntityAncestors(t) { this.traverseAncestors((i) => { Ct.is(i) && t(i); }); } traverseEntity(t, i = 0) { if (t(this, i) !== !0) for (let r of this.children) mn(r) && r.traverseEntity(t, i + 1); } traverseVisibleEntity(t) { t(this); for (let i of this.children) mn(i) && i.visible && i.traverseVisibleEntity(t); } updateMatrix() { super.updateMatrix(), this.cloner && this.cloner.onObjUpdateMatrix(), this.dispatchEvent({ type: 'updateMatrix' }); } copy(t, i = !0) { return ( super.copy(t, !1), (this.raycastLock = t.raycastLock), (this.scaleLock = t.scaleLock), this.hiddenMatrix.copy(t.hiddenMatrix), this ); } hasEntityChild() { return this.children.some((t) => mn(t)); } isAncestorOf(t) { if (this.uuid === t) return !1; let i = !1; return ( this.traverseEntity((r) => { r.uuid === t && (i = !0); }), i ); } toObjectTransformState(t = []) { this.updateWorldMatrix(!0, !1); let i = { position: this.position.toArray(), rotation: [this.rotation.x, this.rotation.y, this.rotation.z], scale: this.scale.toArray(), hiddenMatrix: this.hiddenMatrix.toArray() }; return tm(i, t); } updateTransformState(t) { let i = !1; return ( t.position && (this.position.fromArray(t.position), (i = !0)), t.rotation && (this.rotation.fromArray(t.rotation), (i = !0)), t.scale && ((i = !0), this.scale.fromArray(t.scale)), t.hiddenMatrix !== void 0 && ((i = !0), this.hiddenMatrix.fromArray(t.hiddenMatrix ?? ko.identity)), i && (this.updateMatrix(), this.resetBBoxNeedsUpdate(), this.invalidateClonerTransform(this), this.traverseEntityAncestors((r) => { r.invalidateClonerTransform(this); })), t.position && t.rotation && t.scale && t.hiddenMatrix !== void 0 && this.updateWorldMatrix(!1, !0), i ); } dispose() { (this.disposed = !0), this.cloner && (this.cloner.removeFromParent(), (this.cloner = void 0)); } disposeChildrenRecursively() { for (let t of this.children) Ct.is(t) && t.disposeRecursively(); } disposeRecursively() { this.dispose(), this.children.forEach((t) => { Ct.is(t) && t.disposeRecursively(); }); } toState(t = []) { let i = { name: this.name, visible: this.visible, raycastLock: this.raycastLock, ...this.toObjectTransformState(t) }; return tm(i, t); } updateByOp(t, i, r, s) { let n = this.data; this.data = i; let a = t, o = pn(t.path, ['states', '*']); if (o !== null) { if (t.type === 0) { let [l] = o; if (this?.stateSelection === l) { let h = { ...t.props }; if (Object.values(t.props).some((u) => u === void 0)) { let u = this.data; if (u !== void 0) { let c = fs.zoom(u, t.path.slice(2)); if (c) for (let d in t.props) t.props[d] === void 0 && d in c && (h[d] = c[d]); } } a = { ...t, props: h, path: t.path.slice(2) }; } } } else if (t.type === 0) { let l = this.stateSelection ? this.data.states.data(this.stateSelection) : void 0; if (l !== void 0) { if (t.props.name !== void 0 && l.name) { let { name: u, ...c } = l; l = c; } if (t.props.material !== void 0 && 'material' in l) { let { material: u, ...c } = l; l = c; } let h = fs.removeOverridden(t.path, t.props, l); a = { ...t, props: h }; } } if ( (this.updateByPatchedOpBase(a, oa.patch(this.data, this.stateSelection ? this.data.states.data(this.stateSelection) : void 0), r), pn(t.path, ['overrides'])) ) { let l = [], h = [...t.path]; for (l.push(h[1]), h.splice(0, 2); h.length > 0 && h[0] === 'descendants'; ) l.push(h[1]), h.splice(0, 2); if (l[l.length - 1] === void 0) { if (t.type === 0) for (let u of Object.keys(t.props)) { l[l.length - 1] = u; let c = r.scene.findInstance([this.uuid, ...l]); c && ((c.overrideData = t.props[u]), c.updateState(fa.apply(c.component.data, c.overrideData), r)); } } else { let u = r.scene.findInstance([this.uuid, ...l]); if (u) { let c = fs.zoom(u.component.data, h); if (((t = { ...t, path: h }), t.type === 0)) { let d = t.props; if (c) for (let [p, f] of Object.entries(t.props)) f === void 0 && (d === t.props && (d = { ...t.props }), (d[p] = c[p])); t = { ...t, props: d }; } (u.overrideData = Fd.resolve(i.overrides, l)), u.updateByOp(t, ir.applySimple(u.data, t), r, !1); } } } else if (this.instances.length > 0) { let l; if (t.path.length === 0 && t.type === 0) { let h; for (let u of Go.rootOverrideProps) u in t.props && (h === void 0 && (h = {}), (h[u] = t.props[u])); h && (l = { ...t, props: h }); } else for (let h of Go.rootOverrideProps) if (pn(t.path, [h])) { l = t; break; } l !== void 0 && this.instances.forEach((h) => { if (h.isInstanceRoot) { let u = fa.filterOp(h.overrideData, l); u && h.updateByOp(u, ir.applySimple(h.data, u), r, !0); } }), this.instances.forEach((h) => { if (!h.isInstanceRoot) { let u = fa.filterOp(h.overrideData, t); if (u) { let c; n === h.data && t === u ? (c = i) : (c = ir.applySimple(h.data, u)), h.updateByOp(u, c, r, !0); } } }); } } updateByPatchedOpBase(t, i, r) { if (((this.dataPatched = i), t.path.length === 0 && t.type === 0)) t.props.type !== void 0 && !_a.is(t.props.type) && wn.changeEntityProptotype(this, i, r); else if (t.path.length === 1 && t.path[0] === 'geometry' && t.type === 0 && 'type' in t.props) { wn.changeEntityProptotype(this, i, r); for (let s of this.children) Ct.is(s) && s.updateVisible(); } this.updateByPatchedOp(t, i, r); } updateByPatchedOp(t, i, r) { if ( (t.path.length === 0 && t.type === 0 && this.updateState(t.props, r), pn(t.path, ['pathSnapping']) !== null && this.updatePathSnapping(i.pathSnapping), pn(t.path, ['cloner']) !== null) ) { let s = ir.drop(t, 1); s.path.length === 0 && s.type === 0 && s.props.disabled === !0 ? this.setFromClonerState(null, r) : this.cloner ? this.cloner.updateState(i.cloner, r.scene) : (this.setFromClonerState(i.cloner, r), this.expandCloner(r.scene)), this.updateVisible(); } } updatePathSnapping(t) { (this._updatedPathSnapping = t), (this._needApplyPathSnapping = !0); } applyPathSnapping(t) { let i = this._updatedPathSnapping?.pathId ?? this.dataPatched.pathSnapping.pathId, r = this._updatedPathSnapping?.slide ?? this.dataPatched.pathSnapping.slide, s = this._updatedPathSnapping?.offset ?? this.dataPatched.pathSnapping.offset, n = this._updatedPathSnapping?.orientation ?? this.dataPatched.pathSnapping.orientation; if (i === null) return; let a = t.find(i); if (!a || this._needApplyPathSnapping === !1) return; this._needApplyPathSnapping = !1; let o = a.data, l = cA(o.geometry.path), h = (r + s) % 1, u = l.getPointAt(h), c = this.parent ? this.parent?.matrixWorld : new ve(); a.updateMatrixWorld(); let d = new ve().multiplyMatrices(c.clone().invert(), a.matrixWorld); u.applyMatrix4(d); let p = { position: u.toArray(), rotation: o.rotation }; if (n === 'tangential') { let f = new ve().extractRotation(a.matrixWorld), g = l.getTangentAt(h).applyMatrix4(f).add(u), m = new ve().lookAt(u, g, new E(0, 1, 0)), v = new _i().setFromRotationMatrix(m); p = { ...p, rotation: [v.x, v.y, v.z] }; } this.updateTransformState(p), this.traverseEntity((f) => { f._cameraType && f.dispatchEvent(xF); }); } updateVisible() { this.visible = this.dataPatched.visible && (!this.dataPatched.cloner || (this.dataPatched.cloner.disabled ?? !1) || this.dataPatched.cloner?.hideBase !== !0); } updateState_Entity(t, i) { t.name !== void 0 && (this.name = t.name), t.raycastLock !== void 0 && (this.raycastLock = t.raycastLock), t.visible !== void 0 && (this.updateVisible(), this.resetBBoxNeedsUpdate()), 'cloner' in t && t.cloner !== void 0 && (this.setFromClonerState(t.cloner, i), this.updateVisible()), this.updateTransformState(t); } get attachedSurfaceCloners() { return this.children.filter((t) => t instanceof wn.Cloner && t.parameters.type === 'toObject'); } setFromClonerState(t, i) { this.disposed || (t === null || t.disabled ? (this.cloner && this.cloner.removeFromParent(), (this.cloner = void 0)) : this.cloner === void 0 ? ((this.cloner = new wn.Cloner(this, t)), i.scene.addPendingExpandCloner(this)) : this.cloner.updateState(t, i.scene)); } expandCloner(t) { !this.disposed && this.cloner && this.cloner.expandClones(t); } invalidateClonerTransform(t) { this.cloner && this.cloner.invalidateTransform(t); } }, bF = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, radialSegments: 64, heightSegments: 1, openEnded: !1, thetaStart: 0, thetaLength: 360, cornerRadius: 8, cornerSegments: 8, hollow: 0 }, e.parameters ), r = i.width / 2, s = i.radiusTop ?? r, n = i.radiusBottom ?? r; return ( s === n ? ((s = r), (n = r)) : s > n ? ((s = r), (n = (n * r) / s)) : ((s = (s * r) / n), (n = r)), { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width), radiusTop: s, radiusBottom: n }) } ); } static build(e) { let { width: t, depth: i, height: r, radialSegments: s, heightSegments: n, openEnded: a, thetaStart: o, thetaLength: l, radiusTop: h, radiusBottom: u, cornerRadius: c, cornerSegments: d, hollow: p } = e.parameters, f; return ( c || p ? (f = new uA(h, u, r, s, n, a, o, (l * Math.PI) / 180, c, c, d, p)) : (f = new gg(h, u, r, s, n, a, o, (l * Math.PI) / 180)), f.scale(1, 1, i / t), Object.assign(f, { userData: { ...e, type: 'CylinderGeometry' } }) ); } }; function sn(e, t, i) { (i.x = e.x * t.x), (i.y = e.y), (i.z = e.x * t.y); } function gx(e) { return new G(e.y, -e.x); } var uA = class extends Ve { constructor(e, t, i, r, s, n, a, o, l, h, u, c, d = !1) { super(), (this.type = 'RoundedCylinderBufferGeometry'), (e = e !== void 0 ? e : 1), (t = t !== void 0 ? t : 1), (i = i || 1), (r = Math.floor(r) || 8), (s = Math.floor(s) || 1), (n = n !== void 0 ? n : !1), (a = a !== void 0 ? a : 0), (o = o !== void 0 ? o : Math.PI * 2), n && ((l = 0), (h = 0)); let p = [], f = [], g = [], m = [], v = 0, y = i / 2, b = new E(), x = new E(); d && e == 0 && (e = l), d && t == 0 && (t = h); let w = new G(e, y), A = new G(t, -y), S = null, _ = null, M = null, C = null, T = w.clone().sub(A), P = 0, L = 0, D = 0; c > 0 && ((P = Math.min(e, t) * (1 - c)), (L = e - P), (D = t - P)); let k = w.clone(); k.x -= P; let W = Math.PI - T.angle(), X = T.angle(), z = Math.tan(X / 2), j = Math.tan(W / 2), U = z + j, N = c ? U : j, B = c ? U : z; if (((l = Math.min(l, (e - L) / N, T.length() / U)), (h = Math.min(h, (t - D) / B, T.length() / U)), l > 0)) { let V = l / z; (S = w.clone().sub(new G(V, l))), c && ((M = S.clone()), (M.x -= P - U * l)), w.sub(T.clone().setLength(V)); } if (h > 0) { let V = h / j; (_ = A.clone().sub(new G(V, -h))), A.add(T.clone().setLength(V)), c && ((C = _.clone()), (C.x -= P - U * h), k.sub(T.clone().setLength(V))); } T = w.clone().sub(A); let H = T.length() < 0.5, Q = []; for (let V = 0; V <= r; V++) { let ee = [], J = V / r, fe = J * o + a, re = new G(Math.sin(fe), Math.cos(fe)); C && _ ? (Y(ee, J, re, W, h, C, -1, !0), Y(ee, J, re, X, h, _, -1, !1)) : _ ? (F(ee, re, _.x, 0, -1), Y(ee, J, re, X, h, _, -1, !1)) : n || F(ee, re, t, D, -1); let oe = gx(T).normalize(); if ((sn(oe, re, b), !H)) for (let ue = 0; ue <= s; ue++) { let ye = ue / s, Te = T.clone().multiplyScalar(ye).add(A); sn(Te, re, x), f.push(x.x, x.y, x.z), g.push(b.x, b.y, b.z), m.push(J, 0.5 + x.y / i), ee.push(v++); } if ( (M && S ? (Y(ee, J, re, W, l, S, 1, !1), Y(ee, J, re, X, l, M, 1, !0)) : S ? (Y(ee, J, re, W, l, S, 1, !1), F(ee, re, S.x, 0, 1)) : n || F(ee, re, e, L, 1), c && !H) ) { let ue = gx(T).multiplyScalar(-1).normalize(); sn(ue, re, b); for (let ye = 0; ye <= s; ye++) { let Te = ye / s, xe = T.clone().multiplyScalar(-Te).add(k); sn(xe, re, x), f.push(x.x, x.y, x.z), g.push(b.x, b.y, b.z), m.push(J, 0.5 + x.y / i), ee.push(v++); } } c && !n && ee.push(ee[0]), Q.push(ee); } for (let V = 0; V < Q.length - 1; V++) for (let ee = 0; ee < Q[0].length - 1; ee++) { if (n && c && ee == s) continue; let J = Q[V][ee], fe = Q[V + 1][ee], re = Q[V + 1][ee + 1], oe = Q[V][ee + 1], ue = f[re * 3 + 0], ye = f[re * 3 + 2]; p.push(J, fe, oe), (ue != 0 || ye != 0) && p.push(fe, re, oe); } o < Math.PI * 2 && (se(-1, Q[0], a), se(1, Q[Q.length - 1], a + o)), this.setIndex(p), this.setAttribute('position', new Ce(f, 3)), this.setAttribute('normal', new Ce(g, 3)), this.setAttribute('uv', new Ce(m, 2)); function Y(V, ee, J, fe, re, oe, ue, ye) { for (let Te = 0; Te < u + 1; Te++) { let xe = Te / u, we = ue < 0 ? xe : 1 - xe; ye && (we -= 1), (we *= fe); let Ie = new G(Math.sin(we), Math.cos(we) * ue), He = Ie.clone().multiplyScalar(re).add(oe); sn(He, J, x), f.push(x.x, x.y, x.z), sn(Ie, J, b), g.push(b.x, b.y, b.z), m.push(ee, 0.5 + x.y / i), V.push(v++); } } function F(V, ee, J, fe, re) { let oe = new E(), ue = new G(), ye = [J, fe]; re < 0 && ye.reverse(); for (let Te of ye) ue.set(Te, y * re), sn(ue, ee, oe), f.push(oe.x, oe.y, oe.z), g.push(0, re, 0), m.push(0.5, 0.5), V.push(v++); } function se(V, ee, J) { let fe = new G(Math.sin(J), Math.cos(J)), re = new G(-Math.cos(J), Math.sin(J)), oe = new E(), ue = V < 0 ? (xe, we, Ie) => p.push(xe, we, Ie) : (xe, we, Ie) => p.push(xe, Ie, we), ye = new G((e + t + L + D) / 4, 0); sn(ye, fe, oe), f.push(oe.x, oe.y, oe.z), g.push(re.x, 0, re.y), m.push(0.5, 0.5); let Te = v++; for (let xe of ee) { let we = f.slice(xe * 3, xe * 3 + 3); f.push(...we), g.push(re.x, 0, re.y); let Ie = m.slice(xe * 2, xe * 2 + 2); m.push(...Ie), v++; } for (let xe = Te + 1; xe < v - 1; xe++) ue(Te, xe, xe + 1); ue(Te, v - 1, Te + 1); } } }, wF = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, radialSegments: 32, heightSegments: 8, openEnded: !1, thetaStart: 0, thetaLength: 360, cornerRadiusTop: 8, cornerRadiusBottom: 8, cornerSegments: 8 }, e.parameters ); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, depth: i, height: r, radialSegments: s, heightSegments: n, openEnded: a, thetaStart: o, thetaLength: l, cornerRadiusTop: h, cornerRadiusBottom: u, cornerSegments: c } = e.parameters, d; return ( h > 0 || u > 0 || l < 360 ? (d = new uA(0, t / 2, r, s, n, a, o, (l * Math.PI) / 180, h, u, c, 0, !0)) : (d = new Pw(t / 2, r, s, n, a)), d.scale(1, 1, i / t), Object.assign(d, { userData: { ...e, type: 'ConeGeometry' } }) ); } }, _F = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, widthSegments: 1, heightSegments: 1, depthSegments: 1, cornerRadius: 8, cornerSegments: 8 }, e.parameters ); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, height: i, depth: r, widthSegments: s, heightSegments: n, depthSegments: a, cornerRadius: o, cornerSegments: l } = e.parameters, h; return ( o == 0 ? (h = new vs(t, i, r, s, n, a)) : (h = new AF(t, i, r, s, n, a, o, l)), Object.assign(h, { userData: { ...e, type: 'CubeGeometry' } }) ); } }, Xp = Math.PI / 2, AF = class extends Ve { constructor(e = 1, t = 1, i = 1, r = 1, s = 1, n = 1, a = 0, o = 4) { super(), (this.type = 'BoxGeometry'); let l = this; (r = Math.floor(r)), (s = Math.floor(s)), (n = Math.floor(n)), (o = Math.floor(o)), (a = Math.min(a, e / 2, t / 2, i / 2)); let h = [], u = [], c = [], d = [], p = 0, f = 0; g('z', 'y', 'x', -1, -1, i, t, e, n, s, 0), g('z', 'y', 'x', 1, -1, i, t, -e, n, s, 1), g('x', 'z', 'y', 1, 1, e, i, t, r, n, 2), g('x', 'z', 'y', 1, -1, e, i, -t, r, n, 3), g('x', 'y', 'z', 1, -1, e, t, i, r, s, 4), g('x', 'y', 'z', -1, -1, e, t, -i, r, s, 5), a > 0 && (m('z', 'y', 'x', -1, -1, 1, i, t, e, n, 0), m('z', 'y', 'x', 1, -1, -1, i, t, e, n, 1), m('z', 'y', 'x', -1, 1, -1, i, t, e, n, 1), m('z', 'y', 'x', 1, 1, 1, i, t, e, n, 0), m('x', 'y', 'z', -1, -1, -1, e, t, i, r, 0), m('x', 'y', 'z', 1, -1, 1, e, t, i, r, 1), m('x', 'y', 'z', -1, 1, 1, e, t, i, r, 0), m('x', 'y', 'z', 1, 1, -1, e, t, i, r, 1), m('y', 'x', 'z', -1, -1, 1, t, e, i, s, 0), m('y', 'x', 'z', 1, -1, -1, t, e, i, s, 1), m('y', 'x', 'z', 1, 1, 1, t, e, i, s, 1), m('y', 'x', 'z', -1, 1, -1, t, e, i, s, 0), v(1, 1, 1), v(-1, 1, 1), v(1, -1, 1), v(-1, -1, 1), v(1, 1, -1), v(-1, 1, -1), v(1, -1, -1), v(-1, -1, -1)), this.setIndex(h), this.setAttribute('position', new Ce(u, 3)), this.setAttribute('normal', new Ce(c, 3)), this.setAttribute('uv', new Ce(d, 2)); function g(y, b, x, w, A, S, _, M, C, T, P) { let L = (S - 2 * a) / C, D = (_ - 2 * a) / T, k = S / 2 - a, W = _ / 2 - a, X = M / 2, z = C + 1, j = T + 1, U = 0, N = 0, B = new E(); for (let H = 0; H < j; H++) { let Q = H * D - W; for (let Y = 0; Y < z; Y++) { let F = Y * L - k; (B[y] = F * w), (B[b] = Q * A), (B[x] = X), u.push(B.x, B.y, B.z), (B[y] = 0), (B[b] = 0), (B[x] = M > 0 ? 1 : -1), c.push(B.x, B.y, B.z), d.push(Y / C), d.push(1 - H / T), (U += 1); } } for (let H = 0; H < T; H++) for (let Q = 0; Q < C; Q++) { let Y = p + Q + z * H, F = p + Q + z * (H + 1), se = p + (Q + 1) + z * (H + 1), V = p + (Q + 1) + z * H; h.push(Y, F, V), h.push(F, se, V), (N += 6); } l.addGroup(f, N, P), (f += N), (p += U); } function m(y, b, x, w, A, S, _, M, C, T, P) { let L = (_ - 2 * a) / T, D = _ / 2 - a, k = M / 2 - a, W = C / 2, X = T + 1, z = 0, j = 0, U = new E(), N = new E(); for (let B = 0; B < o + 1; B++) { let H = (B / o) * Xp, Q = Math.sin(H) * a, Y = (1 - Math.cos(H)) * a, F = Math.sin(H), se = Math.cos(H); (U[b] = (k + Q) * A), (U[x] = (W - Y) * S), (N[y] = 0), (N[b] = F * Math.sign(U[b])), (N[x] = se * Math.sign(U[x])); for (let V = 0; V < X; V++) { let ee = V * L - D; (U[y] = ee * w), u.push(U.x, U.y, U.z), c.push(N.x, N.y, N.z), d.push(V / T), d.push(0), (z += 1); } } for (let B = 0; B < o; B++) for (let H = 0; H < T; H++) { let Q = p + H + X * B, Y = p + H + X * (B + 1), F = p + (H + 1) + X * (B + 1), se = p + (H + 1) + X * B; h.push(Q, Y, se), h.push(Y, F, se), (j += 6); } l.addGroup(f, j, P), (f += j), (p += z); } function v(y, b, x) { let w = new E(), A = new E(e / 2, t / 2, i / 2); A.subScalar(a); let S = [], _ = y * b * x > 0 ? (C, T, P) => h.push(C, T, P) : (C, T, P) => h.push(C, P, T); for (let C = 0; C <= o; C++) { let T = [], P = Xp * (1 - C / o), L = Math.cos(P), D = Math.sin(P), k = 0; for (let W = 0; W <= C; W++) { let X = Math.cos(k), z = Math.sin(k); (w.x = L * X), (w.y = D), (w.z = L * z); let j = A.clone().addScaledVector(w, a); u.push(y * j.x, b * j.y, x * j.z), c.push(y * w.x, b * w.y, x * w.z), d.push(0, 0), T.push(p++), (k += Xp / C); } S.push(T); } let M = S.length - 1; for (let C = 0; C < M; C++) { let T = S[C], P = S[C + 1], L = T.length - 1; _(T[0], P[1], P[0]); for (let D = 1; D <= L; D++) _(T[D - 1], T[D], P[D]), _(T[D], P[D + 1], P[D]); } } } }, ev = class extends Ve { constructor(e = [], t = [], i = '', r = 1, s = 0.2, n = 4) { super(), (this.type = 'PolyhedronGeometryRound'); let a = [], o = [], l = []; h(), u(), this.setAttribute('position', new Ce(a, 3)), this.setAttribute('normal', new Ce(l, 3)), this.setAttribute('uv', new Ce(o, 2)); return; function h() { (s = Math.min(1 - 1e-5, s)), s == 0 && (n = 0); let c = { IcosahedronGeometry: 5, DodecahedronGeometry: 3, HexahedronGeometry: 3, OctahedronGeometry: 4, TetrahedronGeometry: 3 }[ i ], d = new E(), p = d.clone(), f = new Bi(), g = s * r, m = r - g, v = n + 1, y = new E(), b = (X, z) => y.subVectors(X, z).normalize(), x = (X, z) => Array(X) .fill(void 0) .map(z), w = x(e.length / 3, (X, z) => new E().fromArray(e, z * 3).setLength(r)), A = [], S = 1e6; for (let X = 0; X < w.length; X++) { let z = w[X], j = [], U, N, B, H = 1e10, Q = -1; for (; (Q = t.indexOf(X, Q + 1)) != -1; ) { let V = Q - (Q % 3); (U = t[V + ((Q + 1) % 3)]), (N = t[V + ((Q + 2) % 3)]), (B = z.distanceToSquared(w[U])), (H = Math.min(H, B)), j.push([U, N, B]); } H += 1e-6; let Y = [], F = 0, se = j.length; for (let V = 0; V < se; V++) { [U, N, B] = j[F]; let ee = A[U]?.includes(X) == !0; B <= H && Y.push(U + +ee * S), (F = j.findIndex((J) => J[0] == N)); } A.push(Y); } let _ = []; { let X = 0, z = 0, j, U, N = c == 3; for (let B = 0; B <= n; B++) { (j = (B * (B + 1)) / 2), (U = ((B + 1) * (B + 2)) / 2); for (let H = 0; H < n - B; H++) ([X, z] = [j + H + B + 2, U + H + B + 3]), _.push(j, U, ...(N ? [z, j] : [X, U]), z, X), ([j, U] = [X, z]); _.push(j, U, j + n + 2); } } let M = d.clone(), C = d.clone(), T = d.clone(), P = d.clone(), L = d.clone(), D = [], k = x(w.length, () => x(c, () => d.clone())); for (let X = 0; X < w.length; X++) { d.copy(w[X]).normalize(), M.copy(d).multiplyScalar(m); let z = A[X]; for (let Y = 0; Y < z.length; Y++) { let F = z[Y], se = z[(Y + 1) % c]; f.setFromPointsAndIndices(w, X, F % S, se % S), f.b.sub(f.a).setLength(1e10).add(f.a), f.c.sub(f.a).setLength(1e10).add(f.a), f.closestPointToPoint(M, k[X][Y]); } let j = [], U = [], N = [], B = new E(); n == 0 && [...k[X]].reduce((Y, F) => Y.add(F), B).multiplyScalar(1 / c); for (let Y = 0; Y < c; Y++) { let F = [], se = (Y - 1 + c) % c, V = k[X][se], ee = k[X][Y]; d.copy(V).sub(M), p.copy(ee).sub(M); let J = M.angleTo(d), fe = d.angleTo(p), re = Math.cos(J) * g; n == 0 ? C.copy(B) : C.copy(M).setLength(m + re), U.push(re); let oe = [C, V, ee]; for (let ue = 0; ue < 2; ue++) { let ye = oe[ue], Te = oe[ue + 1]; P.subVectors(ye, M), L.subVectors(Te, M), T.crossVectors(P, L).normalize(); for (let xe = 0; xe < v; xe++) { let we = ([J, fe][ue] * xe) / v; d.copy(P).applyAxisAngle(T, we).add(M), j.push(d.clone()), ue && (b(d, M), F.push([xe == 0 ? ye : d.clone(), y.clone()])); } ue && (b(Te, M), F.push([Te, y.clone()])); } N.push(F); } D.push(N); let H = 2 * v, Q = 2; for (let Y = 0; Y < c; Y++) { let F = H * Y, se = H * ((Y + 1) % c), V = [j[F]]; for (let J = 1; J < v; J++) { (P = j[F + J]), (L = j[se + J]), V.push(P); for (let fe = 1, re = J - Q + 1; fe <= re; fe++) d.lerpVectors(P, L, fe / (re + 1)), d.sub(M).setLength(U[Y]).add(M), V.push(d.clone()); V.push(L); } for (let J = 0; J < v; J++) V.push(j[J + v + F]); V.push(j[se + v]); let ee = _.map((J) => V[J]); a.push(...ee.map((J) => [J.x, J.y, J.z]).flat()), l.push(...ee.map((J) => (b(J, M), [y.x, y.y, y.z])).flat()); } } let W = []; for (let X = 0; X < A.length; X++) for (let z = 0; z < c; z++) { let j = A[X][z]; if (j < S) { let U = A[j].findIndex((H) => H % S == X), N = D[X][z], B = D[j][U]; for (let H = 0; H < v; H++) { let Q = N[H], Y = B[v - H], F = N[H + 1], se = B[v - (H + 1)]; [Q, Y, F, F, Y, se].forEach((V) => { a.push(V[0].x, V[0].y, V[0].z), l.push(V[1].x, V[1].y, V[1].z); }); } W.push(N[0][0], B[v][0], N[v][0], B[0][0]); } } for (; W.length; ) { let X, z, j, U; [X, z] = W.splice(0, 2); let N = [X]; for (; X != z; ) N.push(z), (j = W.indexOf(z)), (U = j % 2), (z = W.splice(j - U, 2)[1 - U]); y.subVectors(N[0], N[1]).cross(d.subVectors(N[0], N[2])).normalize(); let B = y.dot(N[0]) < 0; B && y.negate(); for (let H = 1; H <= N.length - 2; H++) [N[H + +B], N[H + 1 - +B], N[0]].forEach((Q) => { a.push(Q.x, Q.y, Q.z), l.push(y.x, y.y, y.z); }); } } function u() { let c = new E(); for (let A = 0; A < a.length; A += 3) { (c.x = a[A + 0]), (c.y = a[A + 1]), (c.z = a[A + 2]); let S = x(c) / 2 / Math.PI + 0.5, _ = w(c) / Math.PI + 0.5; o.push(S, 1 - _); } let d = new E(), p = new E(), f = new E(), g = new E(), m = new G(), v = new G(), y = new G(), b = (A, S, _, M) => { M < 0 && A.x === 1 && (o[S] = A.x - 1), _.x === 0 && _.z === 0 && (o[S] = M / 2 / Math.PI + 0.5); }; for (let A = 0, S = 0; A < a.length; A += 9, S += 6) { d.set(a[A + 0], a[A + 1], a[A + 2]), p.set(a[A + 3], a[A + 4], a[A + 5]), f.set(a[A + 6], a[A + 7], a[A + 8]), m.set(o[S + 0], o[S + 1]), v.set(o[S + 2], o[S + 3]), y.set(o[S + 4], o[S + 5]), g.copy(d).add(p).add(f).divideScalar(3); let _ = x(g); b(m, S + 0, d, _), b(v, S + 2, p, _), b(y, S + 4, f, _); } for (let A = 0; A < o.length; A += 6) { let S = o[A + 0], _ = o[A + 2], M = o[A + 4], C = Math.max(S, _, M), T = Math.min(S, _, M); C > 0.9 && T < 0.1 && (S < 0.2 && (o[A + 0] += 1), _ < 0.2 && (o[A + 2] += 1), M < 0.2 && (o[A + 4] += 1)); } function x(A) { return Math.atan2(A.z, -A.x); } function w(A) { return Math.atan2(-A.y, Math.sqrt(A.x * A.x + A.z * A.z)); } } } static fromJSON(e) { return new ev(e.vertices, e.indices, e.radius, e.corner, e.cornerSides); } }, SF = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, detail: 0, corner: 0, cornerSides: 4 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, height: i, depth: r, detail: s, corner: n, cornerSides: a } = e.parameters, o = s === 0 && n !== 0 ? new pA(t * 0.5, n, a) : new Dw(t * 0.5, s); return o.scale(1, i / t, r / t), Object.assign(o, { userData: { ...e, type: 'DodecahedronGeometry' } }); } }, pA = class extends ev { constructor(e = 1, t = 0.2, i = 4) { let r = (1 + Math.sqrt(5)) / 2, s = 1 / r, n = [ -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 0, -s, -r, 0, -s, r, 0, s, -r, 0, s, r, -s, -r, 0, -s, r, 0, s, -r, 0, s, r, 0, -r, 0, -s, r, 0, -s, -r, 0, s, r, 0, s ], a = [ 3, 11, 7, 3, 7, 15, 3, 15, 13, 7, 19, 17, 7, 17, 6, 7, 6, 15, 17, 4, 8, 17, 8, 10, 17, 10, 6, 8, 0, 16, 8, 16, 2, 8, 2, 10, 0, 12, 1, 0, 1, 18, 0, 18, 16, 6, 10, 2, 6, 2, 13, 6, 13, 15, 2, 16, 18, 2, 18, 3, 2, 3, 13, 18, 1, 9, 18, 9, 11, 18, 11, 3, 4, 14, 12, 4, 12, 0, 4, 0, 8, 11, 9, 5, 11, 5, 19, 11, 19, 7, 19, 5, 14, 19, 14, 4, 19, 4, 17, 1, 12, 14, 1, 14, 5, 1, 5, 9 ], o = 'DodecahedronGeometry'; super(n, a, o, e, t, i), (this.type = o); } static fromJSON(e) { return new pA(e.radius, e.corner, e.cornerSides); } }, Tl = 1e-12, tv = class { constructor(e) { (this.position = new G()), (this.startPosition = new G()), (this.uuid = it.generateUUID()), (this.position = e.clone()); } start() { this.reset(); } reset() { this.startPosition.copy(this.position); } applyOffset(e) { this.position.copy(this.startPosition).add(e); } copy(e) { return this.position.copy(e.position), this.startPosition.copy(e.startPosition), this; } clone() { return new tv(this.position).copy(this); } toJSON() { return [this.position.x, this.position.y]; } }, Im = class extends tv { constructor(e) { super(e.position), (this.parent = e); } copy(e) { return super.copy(e), this; } clone() { return new Im(this.parent).copy(this); } }, Po = class extends tv { constructor(e, t) { super(t), (this.controls = []), (this.roundness = 0), (this.areControlsDirectionsMirrored = !0), (this.uuid = e), this.controls.push(new Im(this), new Im(this)); } static create(e, t) { let i = new Po(e, new G(...t.position)); return ( i.controls[0].position.set(...t.controlPrevious.position), i.controls[1].position.set(...t.controlNext.position), (i.roundness = t.roundness), (i.areControlsDirectionsMirrored = t.areControlsDirectionsMirrored), i ); } getOppositeControl(e) { let t = this.controls.indexOf(e); return t === 0 ? this.controls[1] : t === 1 ? this.controls[0] : null; } applyOffsetToControls(e, t = 1) { for (let i = 0, r = this.controls.length; i < r; i++) { let s = this.controls[i]; this.position.distanceTo(s.position) <= t ? s.position.copy(this.position) : s.applyOffset(e); } } controlsMoved() { return !(this.position.equals(this.controls[0].position) && this.position.equals(this.controls[1].position)); } copy(e) { return ( super.copy(e), this.controls[0].copy(e.controls[0]), this.controls[1].copy(e.controls[1]), (this.roundness = e.roundness), (this.uuid = e.uuid), this ); } clone() { return new Po(this.uuid, this.position).copy(this); } toJSON() { return super.toJSON().concat(this.controls[0].toJSON(), this.controls[1].toJSON(), [this.roundness]); } computeTangents() { let e = this.curveBefore?.getTangentAt(1), t = this.curveAfter?.getTangentAt(0); return [e, t]; } computeNormals(e = new G(), t = new G()) { let [i, r] = this.computeTangents(); return i && r && (vx(i, e), vx(r, t)), [e, t]; } computeTangent(e = new G()) { let [t, i] = this.computeTangents(); return t && i && e.copy(t).add(i).normalize(), e; } computeNormal(e = new G()) { let [t, i] = this.computeNormals(); return e.copy(t).add(i).normalize(), e; } }; function vx(e, t = new G()) { let i = e.length(); return t.set(-e.y / i, e.x / i); } var iv = (e) => e, rl = new G(), Mu = new G(), MF = new G(), EF = new G(), CF = new G(), TF = new G(), fA = new E(), mA = new E(); function PF(e) { let t = new G(); t.addVectors(e.v0, rl.subVectors(e.v1, e.v0).multiplyScalar(2 / 3)); let i = new G(); return i.addVectors(e.v2, Mu.subVectors(e.v1, e.v2).multiplyScalar(2 / 3)), new Fr(e.v0, t, i, e.v2); } function Wl(e, t, i = Number.EPSILON) { return Math.abs(e - t) < i; } function DF(e, t, i = Number.EPSILON) { return e.distanceTo(t) < i; } function LF(e, t, i = Number.EPSILON) { return e.distanceTo(t) < i; } function gA(e, t, i) { let r = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)), s = Math.sqrt(Math.pow(t.x - i.x, 2) + Math.pow(t.y - i.y, 2)), n = Math.sqrt(Math.pow(i.x - e.x, 2) + Math.pow(i.y - e.y, 2)); return Math.acos((s * s + r * r - n * n) / (2 * s * r)); } function OF(e, t, i) { return xx(e, t) && xx(t, i) && Rm(e.position, t.position, i.position); } function Rm(e, t, i) { return rl.copy(t).sub(e).cross(Mu.copy(i).sub(e)) === 0; } function IF(e, t, i, r, s) { let n = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)), a = (e.y + t.y) / 2, o = (e.x + t.x) / 2, l = (Math.sqrt(Math.pow(i, 2) - Math.pow(n / 2, 2)) * (e.y - t.y)) / n, h = (Math.sqrt(Math.pow(i, 2) - Math.pow(n / 2, 2)) * (t.x - e.x)) / n; return r.set(o + l, a + h), s.set(o - l, a - h), [r, s]; } function RF(e, t, i) { let r = e.distanceTo(i), s = t.distanceTo(i); return r < s ? t : e; } function BF(e, t, i, r, s, n) { let a = t.x - e.x, o = t.y - e.y, l = i.x - e.x, h = i.y - e.y, u = Math.sqrt((a + l) * (a + l) + (o + h) * (o + h)), c; return ( gA(t, e, i) > Math.PI && (u *= -1), Wl(h, o) ? (c = ((o + h) * (r / u - 0.5) * 8) / 3 / (a - l)) : (c = ((a + l) * (r / u - 0.5) * 8) / 3 / (h - o)), s.set(t.x - c * o, t.y + c * a), n.set(i.x + c * h, i.y - c * l), [s, n] ); } function yx(e, t) { return e.position.equals(e.controls[1].position) && t.position.equals(t.controls[0].position); } function xx(e, t) { return Rm(e.position, e.controls[1].position, t.position) && Rm(e.position, t.controls[0].position, t.position); } function zF(e, t, i, r, s = 0.5) { let n = rl.subVectors(t, e).multiplyScalar(s).add(e), a = Mu.subVectors(i, t).multiplyScalar(s).add(t), o = MF.subVectors(r, i).multiplyScalar(s).add(i), l = n, h = EF.subVectors(a, n).multiplyScalar(s).add(n), u = CF.subVectors(o, a).multiplyScalar(s).add(a), c = o, d = TF.subVectors(u, h).multiplyScalar(s).add(h); return [e.x, e.y, l.x, l.y, h.x, h.y, d.x, d.y, u.x, u.y, c.x, c.y, r.x, r.y]; } function NF(e, t, i = 12, r = !0) { let s = mA.set(0, 0, 0), n, a = 0, o = []; for (let l = 0; l < t.length; l++) { let h = iv(t[l]), u = rl, c = ga(h, i); o.push(c); for (let d = 0; d <= c; d++) if (h instanceof Fr || h instanceof Pn || h instanceof Gr) { if ((h.getPoint(d / c, u), s.set(u.x, u.y, 0), n !== void 0 && LF(n, s))) continue; n === void 0 && (n = fA), n.copy(s), e.setXYZ(a, s.x, s.y, s.z), a++; } } return ( r && a > 1 && !(e.getX(a - 1) === e.getX(0) && e.getY(a - 1) === e.getY(0) && e.getZ(a - 1) === e.getZ(0)) && (e.setXYZ(a, e.getX(0), e.getY(0), e.getZ(0)), a++), e ); } function UF(e, t, i, r = 12, s = !0) { let n = mA.set(0, 0, 0), a = 0, o = []; for (let l = 0; l < t.length; l++) { if (i[l] === !1) continue; let h, u = iv(t[l]), c = rl, d = ga(u, r); o.push(d); for (let p = 0; p <= d; p++) if (u instanceof Fr || u instanceof Pn || u instanceof Gr) { if ((u.getPoint(p / d, c), n.set(c.x, c.y, 0), h?.equals(n))) continue; h === void 0 ? (h = fA) : (e.setXYZ(a, h.x, h.y, h.z), a++, e.setXYZ(a, n.x, n.y, n.z), a++), h.copy(n); } } return ( s && a > 1 && !(e.getX(a - 1) === e.getX(0) && e.getY(a - 1) === e.getY(0) && e.getZ(a - 1) === e.getZ(0)) && (e.setXYZ(a, e.getX(0), e.getY(0), e.getZ(0)), a++), o ); } function bx(e, t = 12, i = !1) { let r = []; for (let s = 0, n = e.length; s < n; s++) { let a = e[s], o = 0; if (i && a.roundedCurveCorner !== void 0) { let l = ga(a.roundedCurveCorner, t) * 0.5; s > 0 && (r[s - 1] += l), (o += l); } a.curveAfter !== void 0 && (o += ga(a.curveAfter, t)), r.push(o); } return e.length > 0 && i && e[0].roundedCurveCorner !== void 0 && (r[e.length - 1] += ga(e[0].roundedCurveCorner, t) * 0.5), r; } function ga(e, t = 12) { return e && e instanceof hu ? t * 2 : e && (e instanceof Gr || e instanceof Ew) ? 1 : e && e instanceof mg ? t * e.points.length : t; } function FF(e, t, i = 12, r = !0) { let s, n = 0; for (let a = 0; a < t.length; a++) { let o = iv(t[a]), l = ga(o, i), h = rl; for (let u = 0; u <= l; u++) if (o instanceof Fr || o instanceof Pn || o instanceof Gr) { if ((o.getPoint(u / l, h), s !== void 0 && DF(s, h, Tl))) continue; s === void 0 && (s = Mu), s.copy(h), e.push(h.x, h.y), n++; } } return ( Wl(e[0], e[e.length - 2], Tl) && Wl(e[1], e[e.length - 1], Tl) && (e.pop(), e.pop()), r && n > 1 && !(Wl(e[n - 1], e[1], Tl) && Wl(e[n - 2], e[0], Tl)) && (e.push(e[0], e[1]), n++), e ); } var qp = new G(), kF = new G(), jF = new G(), GF = new G(), VF = new G(), HF = new G(), Nt = class extends xd { constructor(e = 100, t = 100) { super(), (this.points = []), (this.shapeHoles = []), (this.plane = new yr(new E(0, 0, -1))), (this.subdivision = 0), (this.controlSnapDistance = 4), (this.pointIDs = 0), (this.isMesh2D = !1), (this._roundness = 0), (this.isClosed = !1), (this.useCubicForRoundedCorners = !0), (this.uuid = it.generateUUID()), (this.needsUpdate = !1), (this.roundedCurves = []), (this._width = e), (this._height = t); } static createFromState(e, t, i) { let r = new Nt(); return ( (r.isClosed = e.isClosed), (r.points = e.points.map((s) => Po.create(s.id, s.data))), typeof e.roundness == 'number' && (r.roundness = e.roundness), (r.shapeHoles = e.shapeHoles.map((s) => Nt.createFromState(s))), t !== void 0 && i !== void 0 && r.applySize(t, i), r.update(), r ); } get width() { return this._width; } get height() { return this._height; } get roundness() { return this._roundness; } set roundness(e) { if (this._roundness !== e) { this._roundness = e; for (let t = 0, i = this.points.length; t < i; t++) this.points[t].roundness = e; this.needsUpdate = !0; } } getPointsIndexesByIds(e) { return e.map((t) => this.getPointIndexById(t)).filter((t) => t >= 0); } getPointIndexById(e) { let t = this.points.length, i = this.points.findIndex((r) => r.uuid === e); if (i < 0) { let r = t; for (let s = 0, n = this.shapeHoles.length; s < n; s++) { let a = this.shapeHoles[s], o = a.points.length, l = a.getPointIndexById(e); if (l < 0) r += o; else return l + r; } } return i; } getLineIndexById(e) { return this.getPointIndexById(e); } getBezierPoint(e) { if (e <= this.points.length - 1) return this.points[e]; if (this.shapeHoles.length > 0) { let t = this.points.length; for (let i = 0, r = this.shapeHoles.length; i < r; i++) { let s = this.shapeHoles[i], n = e - t; if (n <= s.points.length - 1) return s.points[n]; t += s.points.length; } } throw new Error('This shape does not have a point for this index: ' + e); } getBezierPointIndex(e) { let t = this.points.indexOf(e); if (t >= 0) return t; if (((t = this.points.length), this.shapeHoles.length > 0)) for (let i = 0, r = this.shapeHoles.length; i < r; i++) { let s = this.shapeHoles[i], n = s.points.indexOf(e); if (n >= 0) return t + n; t += s.points.length; } return -1; } getAllPoints() { let e = [].concat(...this.shapeHoles.map((t) => t.points)); return [...this.points, ...e]; } applySize(e, t) { e === 0 && (e = 0.001), t === 0 && (t = 0.001), (this._width = e), (this._height = t); } applyScale(e, t) { let i = qp.set(e, t); for (let r = 0, s = this.points.length; r < s; r++) { let n = this.points[r]; n.position.multiply(i), n.controls[0].position.multiply(i), n.controls[1].position.multiply(i); } for (let r = 0, s = this.shapeHoles.length; r < s; r++) this.shapeHoles[r].applyScale(e, t); this._update(); } createPoint(e, t = 0, i = it.generateUUID()) { let r; e instanceof G ? (r = e) : (r = new G(e, t)); let s = new Po(i, r); return (s.roundness = this.roundness), s; } addPoint(e) { this.points.push(e), (this.needsUpdate = !0); } addPointAt(e, t) { this.points.splice(t, 0, e), (this.needsUpdate = !0); } getPointByUuid(e) { for (let t = 0, i = this.points.length; t < i; t++) { let r = this.points[t]; if (r.uuid === e) return r; } for (let t = 0, i = this.shapeHoles.length; t < i; t++) { let r = this.shapeHoles[t].getPointByUuid(e); if (r) return r; } } getFirstPoint() { return this.points[0]; } getLastPoint() { return this.points[this.points.length - 1]; } removePoint(e) { let t = this.points.indexOf(e); t >= 0 && this.points.splice(t, 1), (this.needsUpdate = !0); } removePointById(e) { let t = this.points.find((i) => i.uuid === e); t && this.removePoint(t); } update() { for (let e = 0, t = this.shapeHoles.length; e < t; e++) this.shapeHoles[e].update(); this._update(); } extractShapePointsToBuffer(e, t = 12, i = !1) { (this.subdivision = t), this.curveDivisions === void 0 && this.computeCurveDivisions(t); let r = i ? this.roundedCurveDivisions : this.curveDivisions; return NF(e, i ? this.roundedCurves : this.curves, t, this.autoClose), r.reduce((s, n) => s + n, 0) + 1; } computeCurveDivisions(e = 12) { return (this.curveDivisions = bx(this.points, e, !1)), (this.roundedCurveDivisions = bx(this.points, e, !0)), this.curveDivisions; } extractFilteredShapePointsToBuffer(e, t, i = 12) { return UF(e, this.curves, t, i, this.autoClose).reduce((r, s) => r + s, 0) * 2; } extractShapePointsToFlatArray(e, t = 12) { return ( (this.subdivision = t), this.curveDivisions === void 0 && this.computeCurveDivisions(t), FF(e, this.roundedCurves, t, this.autoClose) ); } getCurveIndexFromVertexId(e, t = !1) { let i = 0; this.curveDivisions === void 0 && this.computeCurveDivisions(this.subdivision); let r = t ? this.roundedCurveDivisions : this.curveDivisions, s = 0; t && this.points[0].roundedCurveCorner !== void 0 && (s = ga(this.points[0].roundedCurveCorner, this.subdivision) * 0.5); let n = e - s; n < 0 && (n += r.reduce((a, o) => a + o, 0)); for (let a = 0, o = r.length; a < o; a++) { let l = r[a]; if (n < i + l) return [a, (n - i + 1) / l]; i += l; } return [0, 1]; } getCurveT(e, t, i) { let r = this.points[e], s = this.points[e >= this.points.length - 1 ? 0 : e + 1], n = this.curveDivisions, a = n[e]; if (yx(r, s)) { let l = r.position.distanceTo(s.position); return r.position.distanceTo(qp.set(i.x, i.y)) / l; } let o = 0; for (let l = 0; l < e; l++) o += n[l]; return (t - o) / a; } dispose() {} _applyCurveForPoint(e, t) { yx(t, e) ? this.lineTo(e.position.x, e.position.y) : this.bezierCurveTo( t.controls[1].position.x, t.controls[1].position.y, e.controls[0].position.x, e.controls[0].position.y, e.position.x, e.position.y ); let i = this.curves[this.curves.length - 1]; (e.curveBefore = i), (t.curveAfter = i); let r = i.clone(); (e.roundedCurveBefore = r), (t.roundedCurveAfter = r), (e.roundedCurveCorner = void 0), this.roundedCurves.push(r); } _update() { if (((this.curves = []), (this.roundedCurves = []), !this.points.length)) return; for (let t = 0, i = this.points.length; t < i; t++) { let r = this.points[t]; if (t === 0) this.moveTo(r.position.x, r.position.y); else { let s = this.points[t - 1]; this._applyCurveForPoint(r, s); } } let e = this.getLastPoint(); if ((e?.curveAfter && (e.curveAfter = void 0), this.isClosed)) { let t = this.points[0], i = this.points[this.points.length - 1]; this._applyCurveForPoint(t, i); } if (this.points.length > 2) { let t = 0; for (let i = 0, r = this.points.length; i < r; i++) { let s = this.points[i], n = this.points[i - 1] ?? this.points[this.points.length - 1], a = this.points[i + 1] ?? this.points[0], o = s.roundness, l = n && a && OF(n, s, a); if (!s.controlsMoved() && o > 0 && !l) { let h = s.curveBefore, u = s.curveAfter; if (h === void 0 || u === void 0) continue; let c = s.roundedCurveBefore, d = s.roundedCurveAfter, p = h.getLength(), f = u.getLength(), g = Math.min(o, p * 0.499), m = Math.min(o, f * 0.499), v = Math.min(g, m), y = 1 - v / p, b = v / f, x = h.getPointAt(y, qp), w = u.getPointAt(b, kF); this._subSplitCurve(h, c, y, x, void 0), this._subSplitCurve(u, d, b, void 0, w); let A; if (this.useCubicForRoundedCorners) { let S = gA(x, s.position, w) / 2, _ = Math.tan(S) * x.distanceTo(s.position), [M, C] = IF(x, w, _, jF, GF), T = RF(M, C, s.position), [P, L] = BF(T, x, w, _, VF, HF); A = new Fr(x.clone(), P.clone(), L.clone(), w.clone()); } else A = new Pn(x.clone(), s.position.clone(), w.clone()); (s.roundedCurveCorner = A), this.roundedCurves.splice(i + t, 0, A), t++; } } } } _subSplitCurve(e, t, i, r, s) { if (e instanceof Gr) r !== void 0 && t.v2.copy(r), s !== void 0 && t.v1.copy(s); else { let n = e, a = t, o = n.getUtoTmapping(i, 0), l = zF(n.v0, n.v1, n.v2, n.v3, o); return ( r !== void 0 && (a.v0.set(l[0], l[1]), a.v1.set(l[2], l[3]), a.v2.set(l[4], l[5]), a.v3.set(l[6], l[7])), s !== void 0 && (a.v0.set(l[6], l[7]), a.v1.set(l[8], l[9]), a.v2.set(l[10], l[11]), a.v3.set(l[12], l[13])), a ); } return t; } clone() { let e = new Nt(this._width, this._height); return ( (e.points = this.points.map((t) => t.clone())), (e.isClosed = this.isClosed), (e.roundness = this.roundness), (e.isMesh2D = this.isMesh2D), (e.shapeHoles = this.shapeHoles.map((t) => t.clone())), e ); } toJSON() { return { points: this.points.reduce((e, t) => e.concat(t.toJSON()), []), shapeHoles: this.shapeHoles.map((e) => e.toJSON()), isClosed: this.isClosed, roundness: this.roundness }; } fromJSON(e) { (this.points = []), (this.pointIDs = 0); let t = e.points.length / 7; for (let i = 0; i < t; i++) { let r = i * 7, s = e.points[r + 0], n = e.points[r + 1], a = e.points[r + 2], o = e.points[r + 3], l = e.points[r + 4], h = e.points[r + 5], u = e.points[r + 6], c = new Po(it.generateUUID(), new G(s, n)); c.controls[0].position.set(a, o), c.controls[1].position.set(l, h), (c.roundness = u), this.points.push(c); } return ( (this.shapeHoles = e.shapeHoles?.length ? e.shapeHoles.map((i) => { let r = new Nt(); return r.fromJSON(i), r; }) : []), (this.isClosed = e.isClosed), (this._roundness = e.roundness), this._update(), this ); } fromShape(e) { let t = (r, s) => { s instanceof Fr && s.v3.equals(r.position) && r.controls[0].position.copy(s.v2); }, i = (r) => { let s = [], n, a; for (n = 0, a = r.length; n < a; n++) r[n] instanceof Pn && (r[n] = PF(r[n])); for (n = 0, a = r.length; n < a; n++) { let h = r[n], u = n > 0 ? r[n - 1] : null, c; h instanceof Fr ? ((c = this.createPoint(h.v0)), c.controls[1].position.copy(h.v1)) : h instanceof Gr && (c = this.createPoint(h.v1)), c !== void 0 && (u !== null && t(c, u), s.push(c)); } let o = r[r.length - 1], l = !1; return ( o instanceof Fr ? o.v3.equals(s[0].position) && (s[0].controls[0].position.copy(o.v2), (l = !0)) : o instanceof Gr && o.v2.equals(s[0].position) && (l = !0), (this.isClosed = l), s ); }; return ( (this.points = i(e.curves)), e instanceof xd && (this.shapeHoles = e.holes.map((r) => { let s = new Nt(); return s.fromShape(r), s; })), this.update(), this ); } updatePoint(e, t) { let i = this.getPointByUuid(e); i && (t.position !== void 0 && i.position.fromArray(t.position), t.roundness !== void 0 && (i.roundness = t.roundness), t.areControlsDirectionsMirrored !== void 0 && (i.areControlsDirectionsMirrored = t.areControlsDirectionsMirrored), (this.needsUpdate = !0)); } updatePreviousControl(e, t) { let i = this.getPointByUuid(e)?.controls[0]; i && (t.position && i.position.fromArray(t.position), (this.needsUpdate = !0)); } updateNextControl(e, t) { let i = this.getPointByUuid(e)?.controls[1]; i && (t.position && i.position.fromArray(t.position), (this.needsUpdate = !0)); } }, Bm = Math.PI * 2; function Yp({ x: e, y: t }, i, r, s, n) { return { x: e * i + s, y: t * r + n }; } function WF(e, t) { let i = t === 1.5707963267948966 ? 0.551915024494 : t === -1.5707963267948966 ? -0.551915024494 : 1.3333333333333333 * Math.tan(t / 4), r = Math.cos(e), s = Math.sin(e), n = Math.cos(e + t), a = Math.sin(e + t); return [ { x: r - s * i, y: s + r * i }, { x: n + a * i, y: a - n * i }, { x: n, y: a } ]; } function wx(e, t, i, r) { let s = e * r - t * i < 0 ? -1 : 1, n = Math.min(1, Math.max(-1, e * i + t * r)); return s * Math.acos(n); } function XF(e, t, i, r, s, n, a, o, l, h) { let u = Math.pow(s, 2), c = Math.pow(n, 2), d = Math.pow(a, 2), p = Math.pow(o, 2), f = u * c - u * p - c * d; f < 0 && (f = 0), (f /= u * p + c * d), (f = Math.sqrt(f) * (l === h ? -1 : 1)); let g = ((f * s) / n) * o, m = ((f * -n) / s) * a, v = g + (e + i) / 2, y = m + (t + r) / 2, b = (a - g) / s, x = (o - m) / n, w = (-a - g) / s, A = (-o - m) / n, S = wx(1, 0, b, x), _ = wx(b, x, w, A); return !h && _ > 0 && (_ -= Bm), h && _ < 0 && (_ += Bm), { centerx: v, centery: y, ang1: S, ang2: _ }; } function qF({ px: e, py: t, cx: i, cy: r, rx: s, ry: n, largeArcFlag: a, sweepFlag: o }) { let l = []; if (s === 0 || n === 0) return []; let h = (e - i) / 2, u = (t - r) / 2; if (h === 0 && u === 0) return []; (s = Math.abs(s)), (n = Math.abs(n)); let c = Math.pow(h, 2) / Math.pow(s, 2) + Math.pow(u, 2) / Math.pow(n, 2); c > 1 && ((s *= Math.sqrt(c)), (n *= Math.sqrt(c))); let d = XF(e, t, i, r, s, n, h, u, a, o), { ang1: p, ang2: f } = d, { centerx: g, centery: m } = d, v = Math.abs(f) / (Bm / 4); Math.abs(1 - v) < 1e-7 && (v = 1); let y = Math.max(Math.ceil(v), 1); f /= y; for (let b = 0; b < y; b++) l.push(WF(p, f)), (p += f); return l.map((b) => { let { x, y: w } = Yp(b[0], s, n, g, m), { x: A, y: S } = Yp(b[1], s, n, g, m), { x: _, y: M } = Yp(b[2], s, n, g, m); return { x1: x, y1: w, x2: A, y2: S, x: _, y: M }; }); } var yt; (function (e) { (e[(e.ODD = 0)] = 'ODD'), (e[(e.NONZERO = 1)] = 'NONZERO'), (e[(e.POSITIVE = 2)] = 'POSITIVE'), (e[(e.NEGATIVE = 3)] = 'NEGATIVE'), (e[(e.ABS_GEQ_TWO = 4)] = 'ABS_GEQ_TWO'); })(yt || (yt = {})); var Zt; (function (e) { (e[(e.POLYGONS = 0)] = 'POLYGONS'), (e[(e.CONNECTED_POLYGONS = 1)] = 'CONNECTED_POLYGONS'), (e[(e.BOUNDARY_CONTOURS = 2)] = 'BOUNDARY_CONTOURS'); })(Zt || (Zt = {})); function ke(e, t) { if (!e) throw t || 'Assertion Failed!'; } var ze = (function () { function e() {} return ( (e.vertEq = function (t, i) { return t.s === i.s && t.t === i.t; }), (e.vertLeq = function (t, i) { return t.s < i.s || (t.s === i.s && t.t <= i.t); }), (e.transLeq = function (t, i) { return t.t < i.t || (t.t === i.t && t.s <= i.s); }), (e.edgeGoesLeft = function (t) { return e.vertLeq(t.Dst, t.Org); }), (e.edgeGoesRight = function (t) { return e.vertLeq(t.Org, t.Dst); }), (e.vertL1dist = function (t, i) { return Math.abs(t.s - i.s) + Math.abs(t.t - i.t); }), (e.edgeEval = function (t, i, r) { ke(e.vertLeq(t, i) && e.vertLeq(i, r)); var s = i.s - t.s, n = r.s - i.s; return s + n > 0 ? (s < n ? i.t - t.t + (t.t - r.t) * (s / (s + n)) : i.t - r.t + (r.t - t.t) * (n / (s + n))) : 0; }), (e.edgeSign = function (t, i, r) { ke(e.vertLeq(t, i) && e.vertLeq(i, r)); var s = i.s - t.s, n = r.s - i.s; return s + n > 0 ? (i.t - r.t) * s + (i.t - t.t) * n : 0; }), (e.transEval = function (t, i, r) { ke(e.transLeq(t, i) && e.transLeq(i, r)); var s = i.t - t.t, n = r.t - i.t; return s + n > 0 ? (s < n ? i.s - t.s + (t.s - r.s) * (s / (s + n)) : i.s - r.s + (r.s - t.s) * (n / (s + n))) : 0; }), (e.transSign = function (t, i, r) { ke(e.transLeq(t, i) && e.transLeq(i, r)); var s = i.t - t.t, n = r.t - i.t; return s + n > 0 ? (i.s - r.s) * s + (i.s - t.s) * n : 0; }), (e.vertCCW = function (t, i, r) { return t.s * (i.t - r.t) + i.s * (r.t - t.t) + r.s * (t.t - i.t) >= 0; }), (e.interpolate = function (t, i, r, s) { return ( (t = t < 0 ? 0 : t), (r = r < 0 ? 0 : r), t <= r ? (r === 0 ? (i + s) / 2 : i + (s - i) * (t / (t + r))) : s + (i - s) * (r / (t + r)) ); }), (e.intersect = function (t, i, r, s, n) { var a, o, l; e.vertLeq(t, i) || ((l = t), (t = i), (i = l)), e.vertLeq(r, s) || ((l = r), (r = s), (s = l)), e.vertLeq(t, r) || ((l = t), (t = r), (r = l), (l = i), (i = s), (s = l)), e.vertLeq(r, i) ? e.vertLeq(i, s) ? ((a = e.edgeEval(t, r, i)), (o = e.edgeEval(r, i, s)), a + o < 0 && ((a = -a), (o = -o)), (n.s = e.interpolate(a, r.s, o, i.s))) : ((a = e.edgeSign(t, r, i)), (o = -e.edgeSign(t, s, i)), a + o < 0 && ((a = -a), (o = -o)), (n.s = e.interpolate(a, r.s, o, s.s))) : (n.s = (r.s + i.s) / 2), e.transLeq(t, i) || ((l = t), (t = i), (i = l)), e.transLeq(r, s) || ((l = r), (r = s), (s = l)), e.transLeq(t, r) || ((l = t), (t = r), (r = l), (l = i), (i = s), (s = l)), e.transLeq(r, i) ? e.transLeq(i, s) ? ((a = e.transEval(t, r, i)), (o = e.transEval(r, i, s)), a + o < 0 && ((a = -a), (o = -o)), (n.t = e.interpolate(a, r.t, o, i.t))) : ((a = e.transSign(t, r, i)), (o = -e.transSign(t, s, i)), a + o < 0 && ((a = -a), (o = -o)), (n.t = e.interpolate(a, r.t, o, s.t))) : (n.t = (r.t + i.t) / 2); }), e ); })(), Pl = (function () { function e() { (this.next = null), (this.prev = null), (this.anEdge = null), (this.trail = null), (this.n = 0), (this.marked = !1), (this.inside = !1); } return e; })(), Oc = (function () { function e(t) { (this.side = t), (this.next = null), (this.Org = null), (this.Sym = null), (this.Onext = null), (this.Lnext = null), (this.Lface = null), (this.activeRegion = null), (this.winding = 0); } return ( Object.defineProperty(e.prototype, 'Rface', { get: function () { return this.Sym.Lface; }, set: function (t) { this.Sym.Lface = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Dst', { get: function () { return this.Sym.Org; }, set: function (t) { this.Sym.Org = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Oprev', { get: function () { return this.Sym.Lnext; }, set: function (t) { this.Sym.Lnext = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Lprev', { get: function () { return this.Onext.Sym; }, set: function (t) { this.Onext.Sym = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Dprev', { get: function () { return this.Lnext.Sym; }, set: function (t) { this.Lnext.Sym = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Rprev', { get: function () { return this.Sym.Onext; }, set: function (t) { this.Sym.Onext = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Dnext', { get: function () { return this.Sym.Onext.Sym; }, set: function (t) { this.Sym.Onext.Sym = t; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e.prototype, 'Rnext', { get: function () { return this.Sym.Lnext.Sym; }, set: function (t) { this.Sym.Lnext.Sym = t; }, enumerable: !0, configurable: !0 }), e ); })(), oo = (function () { function e() { (this.next = null), (this.prev = null), (this.anEdge = null), (this.coords = [0, 0, 0]), (this.s = 0), (this.t = 0), (this.pqHandle = 0), (this.n = 0), (this.idx = 0); } return e; })(), _x = (function () { function e() { var t = new oo(), i = new Pl(), r = new Oc(0), s = new Oc(1); (t.next = t.prev = t), (t.anEdge = null), (i.next = i.prev = i), (r.next = r), (r.Sym = s), (s.next = s), (s.Sym = r), (this.vHead = t), (this.fHead = i), (this.eHead = r), (this.eHeadSym = s); } return ( (e.prototype.makeEdge_ = function (t) { var i = new Oc(0), r = new Oc(1); t.Sym.side < t.side && (t = t.Sym); var s = t.Sym.next; return ( (r.next = s), (s.Sym.next = i), (i.next = t), (t.Sym.next = r), (i.Sym = r), (i.Onext = i), (i.Lnext = r), (i.Org = null), (i.Lface = null), (i.winding = 0), (i.activeRegion = null), (r.Sym = i), (r.Onext = r), (r.Lnext = i), (r.Org = null), (r.Lface = null), (r.winding = 0), (r.activeRegion = null), i ); }), (e.prototype.splice_ = function (t, i) { var r = t.Onext, s = i.Onext; (r.Sym.Lnext = i), (s.Sym.Lnext = t), (t.Onext = s), (i.Onext = r); }), (e.prototype.makeVertex_ = function (t, i, r) { var s = t; ke(s, "Vertex can't be null!"); var n = r.prev; (s.prev = n), (n.next = s), (s.next = r), (r.prev = s), (s.anEdge = i); var a = i; do { (a.Org = s), (a = a.Onext); } while (a !== i); }), (e.prototype.makeFace_ = function (t, i, r) { var s = t; ke(s, "Face can't be null"); var n = r.prev; (s.prev = n), (n.next = s), (s.next = r), (r.prev = s), (s.anEdge = i), (s.trail = null), (s.marked = !1), (s.inside = r.inside); var a = i; do { (a.Lface = s), (a = a.Lnext); } while (a !== i); }), (e.prototype.killEdge_ = function (t) { t.Sym.side < t.side && (t = t.Sym); var i = t.next, r = t.Sym.next; (i.Sym.next = r), (r.Sym.next = i); }), (e.prototype.killVertex_ = function (t, i) { var r = t.anEdge, s = r; do { (s.Org = i), (s = s.Onext); } while (s !== r); var n = t.prev, a = t.next; (a.prev = n), (n.next = a); }), (e.prototype.killFace_ = function (t, i) { var r = t.anEdge, s = r; do { (s.Lface = i), (s = s.Lnext); } while (s !== r); var n = t.prev, a = t.next; (a.prev = n), (n.next = a); }), (e.prototype.makeEdge = function () { var t = new oo(), i = new oo(), r = new Pl(), s = this.makeEdge_(this.eHead); return this.makeVertex_(t, s, this.vHead), this.makeVertex_(i, s.Sym, this.vHead), this.makeFace_(r, s, this.fHead), s; }), (e.prototype.splice = function (t, i) { var r = !1, s = !1; if (t !== i) { if ( (i.Org !== t.Org && ((s = !0), this.killVertex_(i.Org, t.Org)), i.Lface !== t.Lface && ((r = !0), this.killFace_(i.Lface, t.Lface)), this.splice_(i, t), !s) ) { var n = new oo(); this.makeVertex_(n, i, t.Org), (t.Org.anEdge = t); } if (!r) { var a = new Pl(); this.makeFace_(a, i, t.Lface), (t.Lface.anEdge = t); } } }), (e.prototype.delete = function (t) { var i = t.Sym, r = !1; if ((t.Lface !== t.Rface && ((r = !0), this.killFace_(t.Lface, t.Rface)), t.Onext === t)) this.killVertex_(t.Org, null); else if (((t.Rface.anEdge = t.Oprev), (t.Org.anEdge = t.Onext), this.splice_(t, t.Oprev), !r)) { var s = new Pl(); this.makeFace_(s, t, t.Lface); } i.Onext === i ? (this.killVertex_(i.Org, null), this.killFace_(i.Lface, null)) : ((t.Lface.anEdge = i.Oprev), (i.Org.anEdge = i.Onext), this.splice_(i, i.Oprev)), this.killEdge_(t); }), (e.prototype.addEdgeVertex = function (t) { var i = this.makeEdge_(t), r = i.Sym; this.splice_(i, t.Lnext), (i.Org = t.Dst); var s = new oo(); return this.makeVertex_(s, r, i.Org), (i.Lface = r.Lface = t.Lface), i; }), (e.prototype.splitEdge = function (t) { var i = this.addEdgeVertex(t), r = i.Sym; return ( this.splice_(t.Sym, t.Sym.Oprev), this.splice_(t.Sym, r), (t.Dst = r.Org), (r.Dst.anEdge = r.Sym), (r.Rface = t.Rface), (r.winding = t.winding), (r.Sym.winding = t.Sym.winding), (r.idx = t.idx), (r.Sym.idx = t.Sym.idx), r ); }), (e.prototype.connect = function (t, i) { var r = !1, s = this.makeEdge_(t), n = s.Sym; if ( (i.Lface !== t.Lface && ((r = !0), this.killFace_(i.Lface, t.Lface)), this.splice_(s, t.Lnext), this.splice_(n, i), (s.Org = t.Dst), (n.Org = i.Org), (s.Lface = n.Lface = t.Lface), (t.Lface.anEdge = n), !r) ) { var a = new Pl(); this.makeFace_(a, s, t.Lface); } return s; }), (e.prototype.zapFace = function (t) { var i = t.anEdge, r, s, n, a, o; s = i.Lnext; do { (r = s), (s = r.Lnext), (r.Lface = null), r.Rface === null && (r.Onext === r ? this.killVertex_(r.Org, null) : ((r.Org.anEdge = r.Onext), this.splice_(r, r.Oprev)), (n = r.Sym), n.Onext === n ? this.killVertex_(n.Org, null) : ((n.Org.anEdge = n.Onext), this.splice_(n, n.Oprev)), this.killEdge_(r)); } while (r != i); (a = t.prev), (o = t.next), (o.prev = a), (a.next = o); }), (e.prototype.countFaceVerts_ = function (t) { var i = t.anEdge, r = 0; do { r++, (i = i.Lnext); } while (i !== t.anEdge); return r; }), (e.prototype.mergeConvexFaces = function (t) { var i, r, s, n, a, o, l; for (i = this.fHead.next; i !== this.fHead; i = i.next) if (i.inside) for ( r = i.anEdge, a = r.Org; (s = r.Lnext), (n = r.Sym), n && n.Lface && n.Lface.inside && ((o = this.countFaceVerts_(i)), (l = this.countFaceVerts_(n.Lface)), o + l - 2 <= t && ze.vertCCW(r.Lprev.Org, r.Org, n.Lnext.Lnext.Org) && ze.vertCCW(n.Lprev.Org, n.Org, r.Lnext.Lnext.Org) && ((s = n.Lnext), this.delete(n), (r = null), (n = null))), !(r && r.Lnext.Org === a); ) r = s; return !0; }), (e.prototype.check = function () { var t = this.fHead, i = this.vHead, r = this.eHead, s, n, a, o, l, h; for (n = t, n = t; (s = n.next) !== t; n = s) { ke(s.prev === n), (l = s.anEdge); do { ke(l.Sym !== l), ke(l.Sym.Sym === l), ke(l.Lnext.Onext.Sym === l), ke(l.Onext.Sym.Lnext === l), ke(l.Lface === s), (l = l.Lnext); } while (l !== s.anEdge); } for (ke(s.prev === n && s.anEdge === null), o = i, o = i; (a = o.next) !== i; o = a) { ke(a.prev === o), (l = a.anEdge); do { ke(l.Sym !== l), ke(l.Sym.Sym === l), ke(l.Lnext.Onext.Sym === l), ke(l.Onext.Sym.Lnext === l), ke(l.Org === a), (l = l.Onext); } while (l !== a.anEdge); } for (ke(a.prev === o && a.anEdge === null), h = r, h = r; (l = h.next) !== r; h = l) ke(l.Sym.next === h.Sym), ke(l.Sym !== l), ke(l.Sym.Sym === l), ke(l.Org !== null), ke(l.Dst !== null), ke(l.Lnext.Onext.Sym === l), ke(l.Onext.Sym.Lnext === l); ke( l.Sym.next === h.Sym && l.Sym === this.eHeadSym && l.Sym.Sym === l && l.Org === null && l.Dst === null && l.Lface === null && l.Rface === null ); }), e ); })(), Ax = (function () { function e() { this.handle = null; } return e; })(), Sx = (function () { function e() { (this.key = null), (this.node = 0); } return e; })(), YF = (function () { function e(t, i) { (this.leq = i), (this.max = 0), (this.nodes = []), (this.handles = []), (this.initialized = !1), (this.freeList = 0), (this.size = 0), (this.max = t), (this.nodes = []), (this.handles = []); for (var r = 0; r < t + 1; r++) (this.nodes[r] = new Ax()), (this.handles[r] = new Sx()); (this.initialized = !1), (this.nodes[1].handle = 1), (this.handles[1].key = null); } return ( (e.prototype.floatDown_ = function (t) { var i = this.nodes, r = this.handles, s, n, a; for (s = i[t].handle; ; ) { if ( ((a = t << 1), a < this.size && this.leq(r[i[a + 1].handle].key, r[i[a].handle].key) && ++a, ke(a <= this.max), (n = i[a].handle), a > this.size || this.leq(r[s].key, r[n].key)) ) { (i[t].handle = s), (r[s].node = t); break; } (i[t].handle = n), (r[n].node = t), (t = a); } }), (e.prototype.floatUp_ = function (t) { var i = this.nodes, r = this.handles, s, n, a; for (s = i[t].handle; ; ) { if (((a = t >> 1), (n = i[a].handle), a === 0 || this.leq(r[n].key, r[s].key))) { (i[t].handle = s), (r[s].node = t); break; } (i[t].handle = n), (r[n].node = t), (t = a); } }), (e.prototype.init = function () { for (var t = this.size; t >= 1; --t) this.floatDown_(t); this.initialized = !0; }), (e.prototype.min = function () { return this.handles[this.nodes[1].handle].key; }), (e.prototype.insert = function (t) { var i, r; if (((i = ++this.size), i * 2 > this.max)) { this.max *= 2; var s, n; for (n = this.nodes.length, this.nodes.length = this.max + 1, s = n; s < this.nodes.length; s++) this.nodes[s] = new Ax(); for (n = this.handles.length, this.handles.length = this.max + 1, s = n; s < this.handles.length; s++) this.handles[s] = new Sx(); } return ( this.freeList === 0 ? (r = i) : ((r = this.freeList), (this.freeList = this.handles[r].node)), (this.nodes[i].handle = r), (this.handles[r].node = i), (this.handles[r].key = t), this.initialized && this.floatUp_(i), r ); }), (e.prototype.extractMin = function () { var t = this.nodes, i = this.handles, r = t[1].handle, s = i[r].key; return ( this.size > 0 && ((t[1].handle = t[this.size].handle), (i[t[1].handle].node = 1), (i[r].key = null), (i[r].node = this.freeList), (this.freeList = r), --this.size, this.size > 0 && this.floatDown_(1)), s ); }), (e.prototype.delete = function (t) { var i = this.nodes, r = this.handles, s; ke(t >= 1 && t <= this.max && r[t].key !== null), (s = r[t].node), (i[s].handle = i[this.size].handle), (r[i[s].handle].node = s), --this.size, s <= this.size && (s <= 1 || this.leq(r[i[s >> 1].handle].key, r[i[s].handle].key) ? this.floatDown_(s) : this.floatUp_(s)), (r[t].key = null), (r[t].node = this.freeList), (this.freeList = t); }), e ); })(), Qp = (function () { function e() { (this.eUp = null), (this.nodeUp = null), (this.windingNumber = 0), (this.inside = !1), (this.sentinel = !1), (this.dirty = !1), (this.fixUpperEdge = !1); } return e; })(), Mx = (function () { function e() { (this.key = null), (this.next = null), (this.prev = null); } return e; })(), QF = (function () { function e(t, i) { (this.frame = t), (this.leq = i), (this.head = new Mx()), (this.head.next = this.head), (this.head.prev = this.head); } return ( (e.prototype.min = function () { return this.head.next; }), (e.prototype.max = function () { return this.head.prev; }), (e.prototype.insert = function (t) { return this.insertBefore(this.head, t); }), (e.prototype.search = function (t) { var i = this.head; do { i = i.next; } while (i.key !== null && !this.leq(this.frame, t, i.key)); return i; }), (e.prototype.insertBefore = function (t, i) { do { t = t.prev; } while (t.key !== null && !this.leq(this.frame, t.key, i)); var r = new Mx(); return (r.key = i), (r.next = t.next), (t.next.prev = r), (r.prev = t), (t.next = r), r; }), (e.prototype.delete = function (t) { (t.next.prev = t.prev), (t.prev.next = t.next); }), e ); })(), ZF = (function () { function e() {} return ( (e.regionBelow = function (t) { return t.nodeUp.prev.key; }), (e.regionAbove = function (t) { return t.nodeUp.next.key; }), (e.debugEvent = function (t) {}), (e.addWinding = function (t, i) { (t.winding += i.winding), (t.Sym.winding += i.Sym.winding); }), (e.edgeLeq = function (t, i, r) { var s = t.event, n = i.eUp, a = r.eUp; if (n.Dst === s) return a.Dst === s ? ze.vertLeq(n.Org, a.Org) ? ze.edgeSign(a.Dst, n.Org, a.Org) <= 0 : ze.edgeSign(n.Dst, a.Org, n.Org) >= 0 : ze.edgeSign(a.Dst, s, a.Org) <= 0; if (a.Dst === s) return ze.edgeSign(n.Dst, s, n.Org) >= 0; var o = ze.edgeEval(n.Dst, s, n.Org), l = ze.edgeEval(a.Dst, s, a.Org); return o >= l; }), (e.deleteRegion = function (t, i) { i.fixUpperEdge && ke(i.eUp.winding === 0), (i.eUp.activeRegion = null), t.dict.delete(i.nodeUp); }), (e.fixUpperEdge = function (t, i, r) { ke(i.fixUpperEdge), t.mesh.delete(i.eUp), (i.fixUpperEdge = !1), (i.eUp = r), (r.activeRegion = i); }), (e.topLeftRegion = function (t, i) { var r = i.eUp.Org, s; do { i = e.regionAbove(i); } while (i.eUp.Org === r); if (i.fixUpperEdge) { if (((s = t.mesh.connect(e.regionBelow(i).eUp.Sym, i.eUp.Lnext)), s === null)) return null; e.fixUpperEdge(t, i, s), (i = e.regionAbove(i)); } return i; }), (e.topRightRegion = function (t) { var i = t.eUp.Dst; do { t = e.regionAbove(t); } while (t.eUp.Dst === i); return t; }), (e.addRegionBelow = function (t, i, r) { var s = new Qp(); return ( (s.eUp = r), (s.nodeUp = t.dict.insertBefore(i.nodeUp, s)), (s.fixUpperEdge = !1), (s.sentinel = !1), (s.dirty = !1), (r.activeRegion = s), s ); }), (e.isWindingInside = function (t, i) { switch (t.windingRule) { case yt.ODD: return (i & 1) !== 0; case yt.NONZERO: return i !== 0; case yt.POSITIVE: return i > 0; case yt.NEGATIVE: return i < 0; case yt.ABS_GEQ_TWO: return i >= 2 || i <= -2; } throw new Error('Invalid winding rulle'); }), (e.computeWinding = function (t, i) { (i.windingNumber = e.regionAbove(i).windingNumber + i.eUp.winding), (i.inside = e.isWindingInside(t, i.windingNumber)); }), (e.finishRegion = function (t, i) { var r = i.eUp, s = r.Lface; (s.inside = i.inside), (s.anEdge = r), e.deleteRegion(t, i); }), (e.finishLeftRegions = function (t, i, r) { for (var s, n = null, a = i, o = i.eUp; a !== r; ) { if (((a.fixUpperEdge = !1), (n = e.regionBelow(a)), (s = n.eUp), s.Org != o.Org)) { if (!n.fixUpperEdge) { e.finishRegion(t, a); break; } (s = t.mesh.connect(o.Lprev, s.Sym)), e.fixUpperEdge(t, n, s); } o.Onext !== s && (t.mesh.splice(s.Oprev, s), t.mesh.splice(o, s)), e.finishRegion(t, a), (o = n.eUp), (a = n); } return o; }), (e.addRightEdges = function (t, i, r, s, n, a) { var o, l, h, u, c = !0; h = r; do { ke(ze.vertLeq(h.Org, h.Dst)), e.addRegionBelow(t, i, h.Sym), (h = h.Onext); } while (h !== s); for (n === null && (n = e.regionBelow(i).eUp.Rprev), l = i, u = n; (o = e.regionBelow(l)), (h = o.eUp.Sym), h.Org === u.Org; ) h.Onext !== u && (t.mesh.splice(h.Oprev, h), t.mesh.splice(u.Oprev, h)), (o.windingNumber = l.windingNumber - h.winding), (o.inside = e.isWindingInside(t, o.windingNumber)), (l.dirty = !0), !c && e.checkForRightSplice(t, l) && (e.addWinding(h, u), e.deleteRegion(t, l), t.mesh.delete(u)), (c = !1), (l = o), (u = h); (l.dirty = !0), ke(l.windingNumber - h.winding === o.windingNumber), a && e.walkDirtyRegions(t, l); }), (e.spliceMergeVertices = function (t, i, r) { t.mesh.splice(i, r); }), (e.vertexWeights = function (t, i, r) { var s = ze.vertL1dist(i, t), n = ze.vertL1dist(r, t), a = (0.5 * n) / (s + n), o = (0.5 * s) / (s + n); (t.coords[0] += a * i.coords[0] + o * r.coords[0]), (t.coords[1] += a * i.coords[1] + o * r.coords[1]), (t.coords[2] += a * i.coords[2] + o * r.coords[2]); }), (e.getIntersectData = function (t, i, r, s, n, a) { (i.coords[0] = i.coords[1] = i.coords[2] = 0), (i.idx = -1), e.vertexWeights(i, r, s), e.vertexWeights(i, n, a); }), (e.checkForRightSplice = function (t, i) { var r = e.regionBelow(i), s = i.eUp, n = r.eUp; if (ze.vertLeq(s.Org, n.Org)) { if (ze.edgeSign(n.Dst, s.Org, n.Org) > 0) return !1; ze.vertEq(s.Org, n.Org) ? s.Org !== n.Org && (t.pq.delete(s.Org.pqHandle), e.spliceMergeVertices(t, n.Oprev, s)) : (t.mesh.splitEdge(n.Sym), t.mesh.splice(s, n.Oprev), (i.dirty = r.dirty = !0)); } else { if (ze.edgeSign(s.Dst, n.Org, s.Org) < 0) return !1; (e.regionAbove(i).dirty = i.dirty = !0), t.mesh.splitEdge(s.Sym), t.mesh.splice(n.Oprev, s); } return !0; }), (e.checkForLeftSplice = function (t, i) { var r = e.regionBelow(i), s = i.eUp, n = r.eUp, a; if ((ke(!ze.vertEq(s.Dst, n.Dst)), ze.vertLeq(s.Dst, n.Dst))) { if (ze.edgeSign(s.Dst, n.Dst, s.Org) < 0) return !1; (e.regionAbove(i).dirty = i.dirty = !0), (a = t.mesh.splitEdge(s)), t.mesh.splice(n.Sym, a), (a.Lface.inside = i.inside); } else { if (ze.edgeSign(n.Dst, s.Dst, n.Org) > 0) return !1; (i.dirty = r.dirty = !0), (a = t.mesh.splitEdge(n)), t.mesh.splice(s.Lnext, n.Sym), (a.Rface.inside = i.inside); } return !0; }), (e.checkForIntersect = function (t, i) { var r = e.regionBelow(i), s = i.eUp, n = r.eUp, a = s.Org, o = n.Org, l = s.Dst, h = n.Dst, u, c, d = new oo(), p, f; if ( (ke(!ze.vertEq(h, l)), ke(ze.edgeSign(l, t.event, a) <= 0), ke(ze.edgeSign(h, t.event, o) >= 0), ke(a !== t.event && o !== t.event), ke(!i.fixUpperEdge && !r.fixUpperEdge), a === o || ((u = Math.min(a.t, l.t)), (c = Math.max(o.t, h.t)), u > c)) ) return !1; if (ze.vertLeq(a, o)) { if (ze.edgeSign(h, a, o) > 0) return !1; } else if (ze.edgeSign(l, o, a) < 0) return !1; return ( e.debugEvent(t), ze.intersect(l, a, h, o, d), ke(Math.min(a.t, l.t) <= d.t), ke(d.t <= Math.max(o.t, h.t)), ke(Math.min(h.s, l.s) <= d.s), ke(d.s <= Math.max(o.s, a.s)), ze.vertLeq(d, t.event) && ((d.s = t.event.s), (d.t = t.event.t)), (p = ze.vertLeq(a, o) ? a : o), ze.vertLeq(p, d) && ((d.s = p.s), (d.t = p.t)), ze.vertEq(d, a) || ze.vertEq(d, o) ? (e.checkForRightSplice(t, i), !1) : (!ze.vertEq(l, t.event) && ze.edgeSign(l, t.event, d) >= 0) || (!ze.vertEq(h, t.event) && ze.edgeSign(h, t.event, d) <= 0) ? h === t.event ? (t.mesh.splitEdge(s.Sym), t.mesh.splice(n.Sym, s), (i = e.topLeftRegion(t, i)), (s = e.regionBelow(i).eUp), e.finishLeftRegions(t, e.regionBelow(i), r), e.addRightEdges(t, i, s.Oprev, s, s, !0), !0) : l === t.event ? (t.mesh.splitEdge(n.Sym), t.mesh.splice(s.Lnext, n.Oprev), (r = i), (i = e.topRightRegion(i)), (f = e.regionBelow(i).eUp.Rprev), (r.eUp = n.Oprev), (n = e.finishLeftRegions(t, r, null)), e.addRightEdges(t, i, n.Onext, s.Rprev, f, !0), !0) : (ze.edgeSign(l, t.event, d) >= 0 && ((e.regionAbove(i).dirty = i.dirty = !0), t.mesh.splitEdge(s.Sym), (s.Org.s = t.event.s), (s.Org.t = t.event.t)), ze.edgeSign(h, t.event, d) <= 0 && ((i.dirty = r.dirty = !0), t.mesh.splitEdge(n.Sym), (n.Org.s = t.event.s), (n.Org.t = t.event.t)), !1) : (t.mesh.splitEdge(s.Sym), t.mesh.splitEdge(n.Sym), t.mesh.splice(n.Oprev, s), (s.Org.s = d.s), (s.Org.t = d.t), (s.Org.pqHandle = t.pq.insert(s.Org)), e.getIntersectData(t, s.Org, a, l, o, h), (e.regionAbove(i).dirty = i.dirty = r.dirty = !0), !1) ); }), (e.walkDirtyRegions = function (t, i) { for (var r = e.regionBelow(i), s, n; ; ) { for (; r.dirty; ) (i = r), (r = e.regionBelow(r)); if (!i.dirty && ((r = i), (i = e.regionAbove(i)), i === null || !i.dirty)) return; if ( ((i.dirty = !1), (s = i.eUp), (n = r.eUp), s.Dst !== n.Dst && e.checkForLeftSplice(t, i) && (r.fixUpperEdge ? (e.deleteRegion(t, r), t.mesh.delete(n), (r = e.regionBelow(i)), (n = r.eUp)) : i.fixUpperEdge && (e.deleteRegion(t, i), t.mesh.delete(s), (i = e.regionAbove(r)), (s = i.eUp))), s.Org !== n.Org) ) if (s.Dst !== n.Dst && !i.fixUpperEdge && !r.fixUpperEdge && (s.Dst === t.event || n.Dst === t.event)) { if (e.checkForIntersect(t, i)) return; } else e.checkForRightSplice(t, i); s.Org === n.Org && s.Dst === n.Dst && (e.addWinding(n, s), e.deleteRegion(t, i), t.mesh.delete(s), (i = e.regionAbove(r))); } }), (e.connectRightVertex = function (t, i, r) { var s, n = r.Onext, a = e.regionBelow(i), o = i.eUp, l = a.eUp, h = !1; if ( (o.Dst !== l.Dst && e.checkForIntersect(t, i), ze.vertEq(o.Org, t.event) && (t.mesh.splice(n.Oprev, o), (i = e.topLeftRegion(t, i)), (n = e.regionBelow(i).eUp), e.finishLeftRegions(t, e.regionBelow(i), a), (h = !0)), ze.vertEq(l.Org, t.event) && (t.mesh.splice(r, l.Oprev), (r = e.finishLeftRegions(t, a, null)), (h = !0)), h) ) { e.addRightEdges(t, i, r.Onext, n, n, !0); return; } ze.vertLeq(l.Org, o.Org) ? (s = l.Oprev) : (s = o), (s = t.mesh.connect(r.Lprev, s)), e.addRightEdges(t, i, s, s.Onext, s.Onext, !1), (s.Sym.activeRegion.fixUpperEdge = !0), e.walkDirtyRegions(t, i); }), (e.connectLeftDegenerate = function (t, i, r) { var s, n, a, o, l; if (((s = i.eUp), ze.vertEq(s.Org, r))) { ke(!1), e.spliceMergeVertices(t, s, r.anEdge); return; } if (!ze.vertEq(s.Dst, r)) { t.mesh.splitEdge(s.Sym), i.fixUpperEdge && (t.mesh.delete(s.Onext), (i.fixUpperEdge = !1)), t.mesh.splice(r.anEdge, s), e.sweepEvent(t, r); return; } ke(!1), (i = e.topRightRegion(i)), (l = e.regionBelow(i)), (a = l.eUp.Sym), (n = o = a.Onext), l.fixUpperEdge && (ke(n !== a), e.deleteRegion(t, l), t.mesh.delete(a), (a = n.Oprev)), t.mesh.splice(r.anEdge, a), ze.edgeGoesLeft(n) || (n = null), e.addRightEdges(t, i, a.Onext, o, n, !0); }), (e.connectLeftVertex = function (t, i) { var r, s, n, a, o, l, h = new Qp(); if (((h.eUp = i.anEdge.Sym), (r = t.dict.search(h).key), (s = e.regionBelow(r)), !!s)) { if (((a = r.eUp), (o = s.eUp), ze.edgeSign(a.Dst, i, a.Org) === 0)) { e.connectLeftDegenerate(t, r, i); return; } if (((n = ze.vertLeq(o.Dst, a.Dst) ? r : s), r.inside || n.fixUpperEdge)) { if (n === r) l = t.mesh.connect(i.anEdge.Sym, a.Lnext); else { var u = t.mesh.connect(o.Dnext, i.anEdge); l = u.Sym; } n.fixUpperEdge ? e.fixUpperEdge(t, n, l) : e.computeWinding(t, e.addRegionBelow(t, r, l)), e.sweepEvent(t, i); } else e.addRightEdges(t, r, i.anEdge, i.anEdge, null, !0); } }), (e.sweepEvent = function (t, i) { (t.event = i), e.debugEvent(t); for (var r = i.anEdge; r.activeRegion === null; ) if (((r = r.Onext), r === i.anEdge)) { e.connectLeftVertex(t, i); return; } var s = e.topLeftRegion(t, r.activeRegion); ke(s !== null); var n = e.regionBelow(s), a = n.eUp, o = e.finishLeftRegions(t, n, null); o.Onext === a ? e.connectRightVertex(t, s, o) : e.addRightEdges(t, s, o.Onext, a, a, !0); }), (e.addSentinel = function (t, i, r, s) { var n = new Qp(), a = t.mesh.makeEdge(); (a.Org.s = r), (a.Org.t = s), (a.Dst.s = i), (a.Dst.t = s), (t.event = a.Dst), (n.eUp = a), (n.windingNumber = 0), (n.inside = !1), (n.fixUpperEdge = !1), (n.sentinel = !0), (n.dirty = !1), (n.nodeUp = t.dict.insert(n)); }), (e.initEdgeDict = function (t) { t.dict = new QF(t, e.edgeLeq); var i = t.bmax[0] - t.bmin[0], r = t.bmax[1] - t.bmin[1], s = t.bmin[0] - i, n = t.bmax[0] + i, a = t.bmin[1] - r, o = t.bmax[1] + r; e.addSentinel(t, s, n, a), e.addSentinel(t, s, n, o); }), (e.doneEdgeDict = function (t) { for (var i, r = 0; (i = t.dict.min().key) !== null; ) i.sentinel || (ke(i.fixUpperEdge), ke(++r === 1)), ke(i.windingNumber === 0), e.deleteRegion(t, i); }), (e.removeDegenerateEdges = function (t) { var i, r, s, n = t.mesh.eHead; for (i = n.next; i !== n; i = r) (r = i.next), (s = i.Lnext), ze.vertEq(i.Org, i.Dst) && i.Lnext.Lnext !== i && (e.spliceMergeVertices(t, s, i), t.mesh.delete(i), (i = s), (s = i.Lnext)), s.Lnext === i && (s !== i && ((s === r || s === r.Sym) && (r = r.next), t.mesh.delete(s)), (i === r || i === r.Sym) && (r = r.next), t.mesh.delete(i)); }), (e.initPriorityQ = function (t) { var i, r, s, n = 0; for (s = t.mesh.vHead, r = s.next; r !== s; r = r.next) n++; for (n += 8, i = t.pq = new YF(n, ze.vertLeq), s = t.mesh.vHead, r = s.next; r !== s; r = r.next) r.pqHandle = i.insert(r); return r !== s ? !1 : (i.init(), !0); }), (e.donePriorityQ = function (t) { t.pq = null; }), (e.removeDegenerateFaces = function (t, i) { var r, s, n; for (r = i.fHead.next; r !== i.fHead; r = s) (s = r.next), (n = r.anEdge), ke(n.Lnext !== n), n.Lnext.Lnext === n && (e.addWinding(n.Onext, n), t.mesh.delete(n)); return !0; }), (e.computeInterior = function (t, i) { i === void 0 && (i = !0); var r, s; if ((e.removeDegenerateEdges(t), !e.initPriorityQ(t))) return !1; for (e.initEdgeDict(t); (r = t.pq.extractMin()) !== null; ) { for (; (s = t.pq.min()), !(s === null || !ze.vertEq(s, r)); ) (s = t.pq.extractMin()), e.spliceMergeVertices(t, r.anEdge, s.anEdge); e.sweepEvent(t, r); } return ( (t.event = t.dict.min().key.eUp.Org), e.debugEvent(t), e.doneEdgeDict(t), e.donePriorityQ(t), e.removeDegenerateFaces(t, t.mesh) ? (i && t.mesh.check(), !0) : !1 ); }), e ); })(), KF = (function () { function e() { (this.mesh = new _x()), (this.normal = [0, 0, 0]), (this.sUnit = [0, 0, 0]), (this.tUnit = [0, 0, 0]), (this.bmin = [0, 0]), (this.bmax = [0, 0]), (this.windingRule = yt.ODD), (this.dict = null), (this.pq = null), (this.event = null), (this.vertexIndexCounter = 0), (this.vertices = []), (this.vertexIndices = []), (this.vertexCount = 0), (this.elements = []), (this.elementCount = 0); } return ( (e.prototype.dot_ = function (t, i) { return t[0] * i[0] + t[1] * i[1] + t[2] * i[2]; }), (e.prototype.normalize_ = function (t) { var i = t[0] * t[0] + t[1] * t[1] + t[2] * t[2]; if (!i) throw 'Zero-size vector!'; (i = Math.sqrt(i)), (t[0] /= i), (t[1] /= i), (t[2] /= i); }), (e.prototype.longAxis_ = function (t) { var i = 0; return Math.abs(t[1]) > Math.abs(t[0]) && (i = 1), Math.abs(t[2]) > Math.abs(t[i]) && (i = 2), i; }), (e.prototype.computeNormal_ = function (t) { var i, r, s, n, a, o, l = [0, 0, 0], h = [0, 0, 0], u = [0, 0, 0], c = [0, 0, 0], d = [0, 0, 0], p = [null, null, null], f = [null, null, null], g = this.mesh.vHead; i = g.next; for (var m = 0; m < 3; ++m) (n = i.coords[m]), (h[m] = n), (f[m] = i), (l[m] = n), (p[m] = i); for (i = g.next; i !== g; i = i.next) for (var v = 0; v < 3; ++v) (n = i.coords[v]), n < h[v] && ((h[v] = n), (f[v] = i)), n > l[v] && ((l[v] = n), (p[v] = i)); var y = 0; if ((l[1] - h[1] > l[0] - h[0] && (y = 1), l[2] - h[2] > l[y] - h[y] && (y = 2), h[y] >= l[y])) { (t[0] = 0), (t[1] = 0), (t[2] = 1); return; } for ( o = 0, r = f[y], s = p[y], u[0] = r.coords[0] - s.coords[0], u[1] = r.coords[1] - s.coords[1], u[2] = r.coords[2] - s.coords[2], i = g.next; i !== g; i = i.next ) (c[0] = i.coords[0] - s.coords[0]), (c[1] = i.coords[1] - s.coords[1]), (c[2] = i.coords[2] - s.coords[2]), (d[0] = u[1] * c[2] - u[2] * c[1]), (d[1] = u[2] * c[0] - u[0] * c[2]), (d[2] = u[0] * c[1] - u[1] * c[0]), (a = d[0] * d[0] + d[1] * d[1] + d[2] * d[2]), a > o && ((o = a), (t[0] = d[0]), (t[1] = d[1]), (t[2] = d[2])); o <= 0 && ((t[0] = t[1] = t[2] = 0), (t[this.longAxis_(u)] = 1)); }), (e.prototype.checkOrientation_ = function () { for (var t = this.mesh.fHead, i, r = this.mesh.vHead, s, n = 0, a = t.next; a !== t; a = a.next) if (((s = a.anEdge), !(s.winding <= 0))) do { (n += (s.Org.s - s.Dst.s) * (s.Org.t + s.Dst.t)), (s = s.Lnext); } while (s !== a.anEdge); if (n < 0) { for (i = r.next; i !== r; i = i.next) i.t = -i.t; (this.tUnit[0] = -this.tUnit[0]), (this.tUnit[1] = -this.tUnit[1]), (this.tUnit[2] = -this.tUnit[2]); } }), (e.prototype.projectPolygon_ = function () { var t = this.mesh.vHead, i = [0, 0, 0], r, s, n = !1; (i[0] = this.normal[0]), (i[1] = this.normal[1]), (i[2] = this.normal[2]), !i[0] && !i[1] && !i[2] && (this.computeNormal_(i), (n = !0)), (r = this.sUnit), (s = this.tUnit); var a = this.longAxis_(i); (r[a] = 0), (r[(a + 1) % 3] = 1), (r[(a + 2) % 3] = 0), (s[a] = 0), (s[(a + 1) % 3] = 0), (s[(a + 2) % 3] = i[a] > 0 ? 1 : -1); for (var o = t.next; o !== t; o = o.next) (o.s = this.dot_(o.coords, r)), (o.t = this.dot_(o.coords, s)); n && this.checkOrientation_(); for (var l = !0, h = t.next; h !== t; h = h.next) l ? ((this.bmin[0] = this.bmax[0] = h.s), (this.bmin[1] = this.bmax[1] = h.t), (l = !1)) : (h.s < this.bmin[0] && (this.bmin[0] = h.s), h.s > this.bmax[0] && (this.bmax[0] = h.s), h.t < this.bmin[1] && (this.bmin[1] = h.t), h.t > this.bmax[1] && (this.bmax[1] = h.t)); }), (e.prototype.addWinding_ = function (t, i) { (t.winding += i.winding), (t.Sym.winding += i.Sym.winding); }), (e.prototype.tessellateMonoRegion_ = function (t, i) { var r, s; if (((r = i.anEdge), !(r.Lnext !== r && r.Lnext.Lnext !== r))) throw 'Mono region invalid'; for (; ze.vertLeq(r.Dst, r.Org); r = r.Lprev); for (; ze.vertLeq(r.Org, r.Dst); r = r.Lnext); s = r.Lprev; for (var n = void 0; r.Lnext !== s; ) if (ze.vertLeq(r.Dst, s.Org)) { for (; s.Lnext !== r && (ze.edgeGoesLeft(s.Lnext) || ze.edgeSign(s.Org, s.Dst, s.Lnext.Dst) <= 0); ) (n = t.connect(s.Lnext, s)), (s = n.Sym); s = s.Lprev; } else { for (; s.Lnext !== r && (ze.edgeGoesRight(r.Lprev) || ze.edgeSign(r.Dst, r.Org, r.Lprev.Org) >= 0); ) (n = t.connect(r, r.Lprev)), (r = n.Sym); r = r.Lnext; } if (s.Lnext === r) throw 'Mono region invalid'; for (; s.Lnext.Lnext !== r; ) (n = t.connect(s.Lnext, s)), (s = n.Sym); return !0; }), (e.prototype.tessellateInterior_ = function (t) { for (var i, r = t.fHead.next; r !== t.fHead; r = i) if (((i = r.next), r.inside && !this.tessellateMonoRegion_(t, r))) return !1; return !0; }), (e.prototype.discardExterior_ = function (t) { for (var i, r = t.fHead.next; r !== t.fHead; r = i) (i = r.next), r.inside || t.zapFace(r); }), (e.prototype.setWindingNumber_ = function (t, i, r) { for (var s, n = t.eHead.next; n !== t.eHead; n = s) (s = n.next), n.Rface.inside !== n.Lface.inside ? (n.winding = n.Lface.inside ? i : -i) : r ? t.delete(n) : (n.winding = 0); }), (e.prototype.getNeighbourFace_ = function (t) { return !t.Rface || !t.Rface.inside ? -1 : t.Rface.n; }), (e.prototype.outputPolymesh_ = function (t, i, r, s) { var n, a = 0, o = 0, l; r > 3 && t.mergeConvexFaces(r); for (var h = t.vHead.next; h !== t.vHead; h = h.next) h.n = -1; for (var u = t.fHead.next; u !== t.fHead; u = u.next) if (((u.n = -1), !!u.inside)) { (n = u.anEdge), (l = 0); do { var h = n.Org; h.n === -1 && ((h.n = o), o++), l++, (n = n.Lnext); } while (n !== u.anEdge); if (l > r) throw 'Face vertex greater that support polygon'; (u.n = a), ++a; } (this.elementCount = a), i === Zt.CONNECTED_POLYGONS && (a *= 2), (this.elements = []), (this.elements.length = a * r), (this.vertexCount = o), (this.vertices = []), (this.vertices.length = o * s), (this.vertexIndices = []), (this.vertexIndices.length = o); for (var h = t.vHead.next; h !== t.vHead; h = h.next) if (h.n !== -1) { var c = h.n * s; (this.vertices[c + 0] = h.coords[0]), (this.vertices[c + 1] = h.coords[1]), s > 2 && (this.vertices[c + 2] = h.coords[2]), (this.vertexIndices[h.n] = h.idx); } for (var d = 0, u = t.fHead.next; u !== t.fHead; u = u.next) if (u.inside) { (n = u.anEdge), (l = 0); do { var h = n.Org; (this.elements[d++] = h.n), l++, (n = n.Lnext); } while (n !== u.anEdge); for (var p = l; p < r; ++p) this.elements[d++] = -1; if (i === Zt.CONNECTED_POLYGONS) { n = u.anEdge; do { (this.elements[d++] = this.getNeighbourFace_(n)), (n = n.Lnext); } while (n !== u.anEdge); for (var f = l; f < r; ++f) this.elements[d++] = -1; } } }), (e.prototype.outputContours_ = function (t, i) { var r, s, n = 0, a = 0; (this.vertexCount = 0), (this.elementCount = 0); for (var o = t.fHead.next; o !== t.fHead; o = o.next) if (o.inside) { s = r = o.anEdge; do { this.vertexCount++, (r = r.Lnext); } while (r !== s); this.elementCount++; } (this.elements = []), (this.elements.length = this.elementCount * 2), (this.vertices = []), (this.vertices.length = this.vertexCount * i), (this.vertexIndices = []), (this.vertexIndices.length = this.vertexCount); var l = 0, h = 0, u = 0; n = 0; for (var o = t.fHead.next; o !== t.fHead; o = o.next) if (o.inside) { (a = 0), (s = r = o.anEdge); do { (this.vertices[l++] = r.Org.coords[0]), (this.vertices[l++] = r.Org.coords[1]), i > 2 && (this.vertices[l++] = r.Org.coords[2]), (this.vertexIndices[h++] = this.vertexIdCallback ? this.vertexIdCallback(r) : r.Org.idx), a++, (r = r.Lnext); } while (r !== s); (this.elements[u++] = n), (this.elements[u++] = a), (n += a); } }), (e.prototype.addContour = function (t, i) { this.mesh === null && (this.mesh = new _x()), t < 2 && (t = 2), t > 3 && (t = 3); for (var r = null, s = 0; s < i.length; s += t) r === null ? ((r = this.mesh.makeEdge()), this.mesh.splice(r, r.Sym)) : (this.mesh.splitEdge(r), (r = r.Lnext)), (r.Org.coords[0] = i[s + 0]), (r.Org.coords[1] = i[s + 1]), t > 2 ? (r.Org.coords[2] = i[s + 2]) : (r.Org.coords[2] = 0), (r.Org.idx = this.vertexIndexCounter++), this.edgeCreateCallback && this.edgeCreateCallback(r), (r.winding = 1), (r.Sym.winding = -1); }), (e.prototype.tesselate = function (t, i, r, s, n, a) { if ( (t === void 0 && (t = yt.ODD), i === void 0 && (i = Zt.POLYGONS), a === void 0 && (a = !0), (this.vertices = []), (this.elements = []), (this.vertexIndices = []), (this.vertexIndexCounter = 0), n && ((this.normal[0] = n[0]), (this.normal[1] = n[1]), (this.normal[2] = n[2])), (this.windingRule = t), s < 2 && (s = 2), s > 3 && (s = 3), !this.mesh) ) return !1; this.projectPolygon_(), ZF.computeInterior(this, a); var o = this.mesh; return ( i === Zt.BOUNDARY_CONTOURS ? this.setWindingNumber_(o, 1, !0) : this.tessellateInterior_(o), a && o.check(), i === Zt.BOUNDARY_CONTOURS ? this.outputContours_(o, s) : this.outputPolymesh_(o, i, r, s), !0 ); }), e ); })(); function _n(e) { var t = e.windingRule, i = t === void 0 ? yt.ODD : t, r = e.elementType, s = r === void 0 ? Zt.POLYGONS : r, n = e.polySize, a = n === void 0 ? 3 : n, o = e.vertexSize, l = o === void 0 ? 2 : o, h = e.normal, u = h === void 0 ? [0, 0, 1] : h, c = e.contours, d = c === void 0 ? [] : c, p = e.strict, f = p === void 0 ? !0 : p, g = e.debug, m = g === void 0 ? !1 : g; if (!d && f) throw new Error("Contours can't be empty"); if (d) { var v = new KF(); e.edgeCreateCallback && (v.edgeCreateCallback = e.edgeCreateCallback), e.vertexIdCallback && (v.vertexIdCallback = e.vertexIdCallback); for (var y = 0; y < d.length; y++) v.addContour(l || 2, d[y]); return ( v.tesselate(i, s, a, l, u, f), { vertices: v.vertices, vertexIndices: v.vertexIndices, vertexCount: v.vertexCount, elements: v.elements, elementCount: v.elementCount, mesh: m ? v.mesh : void 0 } ); } } var T9 = yt.ODD, P9 = yt.NONZERO, D9 = yt.POSITIVE, L9 = yt.NEGATIVE, O9 = yt.ABS_GEQ_TWO, I9 = Zt.POLYGONS, R9 = Zt.CONNECTED_POLYGONS, B9 = Zt.BOUNDARY_CONTOURS, zm = class { constructor(e = 256, t = !1) { (this.capacity = e), (this.size = 0), (this.debug = t), this.debug && console.log(`allocating with cap ${e}`); let i = e * zm.eSize; this.buffer = new ArrayBuffer(i); let r = Float32Array.BYTES_PER_ELEMENT, s = 0; (this.positions = new Float32Array(this.buffer, s * r, 3 * e)), (s += 3 * e), (this.normals = new Float32Array(this.buffer, s * r, 3 * e)), (s += 3 * e), (this.uvs = new Float32Array(this.buffer, s * r, 2 * e)); } realloc(e, t = !1) { if (e < this.size) throw Error('cannot shrink buffer'); if (e <= this.capacity && !t) return; this.debug && console.log(`resizing from ${this.capacity} \u2192 ${e}`); let i = e * zm.eSize, r = new ArrayBuffer(i), s = Float32Array.BYTES_PER_ELEMENT, n = 0, a = new Float32Array(r, n * s, 3 * e); n += 3 * e; let o = new Float32Array(r, n * s, 3 * e); n += 3 * e; let l = new Float32Array(r, n * s, 2 * e); a.set(this.positions.slice(0, this.size * 3)), o.set(this.normals.slice(0, this.size * 3)), l.set(this.uvs.slice(0, this.size * 2)), (this.buffer = r), (this.positions = a), (this.normals = o), (this.uvs = l), (this.capacity = e); } get(e = 1) { let t = this.size + e; if (t > this.capacity) { let r = this.capacity; for (; t > r; ) r *= 2; this.realloc(r); } let i = this.size; return (this.size = t), i; } reserve(e) { let t = this.size + e; t > this.capacity && this.realloc(t); } shrink() { this.debug && console.log(`shrinking ${this.capacity} \u2192 ${this.size}`), this.realloc(this.size, !0); } }, vA = zm; vA.eSize = (3 + 3 + 2) * Float32Array.BYTES_PER_ELEMENT; var rv = { vertices: [160, 160, -160, 160, -160, -160, 160, -160], vertexIndices: [1, 0, 3, 2], vertexCount: 4, elements: [0, 4], elementCount: 1, mesh: void 0 }, yA = { vertices: [], vertexIndices: [], vertexCount: 0, elements: [], elementCount: 0, mesh: void 0 }, xA = { vertices: [-160, 160, 160, -160, 160, 160, -160, -160], vertexIndices: [1, 3, 0, 2], vertexCount: 4, elements: [0, 1, 2, 1, 0, 3], elementCount: 2, mesh: void 0 }, Zp = (e, t) => ([i, r]) => (r < i && (r += t), (e >= i ? e : e + t) <= r), bA = class extends Ve { constructor(e, t, i = 0, r = 12, s = 3, n = yt.ODD) { super(), (this.type = 'ShapeGeometry'), (this.vertexCache = {}), (this._shape = e), (this._depth = t), (this._bevel = i), (this._curveSegments = r), (this._bevelSegmentsInput = s), i <= 0 ? ((this._bevelSize = 0), (this._bevelSegments = 0)) : ((this._bevelSize = Math.min(i, t / 2 - 1e-12)), (this._bevelSegments = Math.floor(s))); let a = this._shape.extractShapePointsToFlatArray([], r), o = this._shape.shapeHoles.map((w) => { let A = w.extractShapePointsToFlatArray([], r), S = []; for (let _ = A.length - 1; _ >= 1; _ -= 2) { let M = A[_ - 1], C = A[_ - 0]; S.push(M, C); } return S; }), l; try { l = _n({ windingRule: n, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [a] }); } catch { l = rv; } let h; try { h = _n({ windingRule: yt.ODD, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [...o] }); } catch { h = yA; } if (!l) throw new Error('error generating geometry'); let u = l.elementCount; if (h) { l.elementCount += h.elementCount; for (let w = 0; w < h.elements.length; w++) { let A = h.elements[w], S = w % 2 === 0 ? l.vertexCount : 0; l.elements.push(A + S); } for (let w = 0; w < h.vertexIndices.length; w++) { let A = h.vertexIndices[w], S = l.vertexCount; l.vertexIndices.push(A + S); } for (let w = 0; w < h.vertices.length; w++) { let A = h.vertices[w]; l.vertices.push(A); } } let c = 1 / 0, d = -1 / 0, p = 1 / 0, f = -1 / 0; for (let w = 0, A = l.vertexCount; w < A; w++) { let S = w * 2, _ = l.vertices[S + 0], M = l.vertices[S + 1]; _ < c && (c = _), _ > d && (d = _), M < p && (p = M), M > f && (f = M); } (this._minX = c), (this._minY = p), (this._width = d - c), (this._height = f - p), (this._buffer = new vA(this._computeBufferEstimatedSize(l))); let g = [], m = []; for (let w = l.elementCount - 1; w >= 0; w--) { let A = w >= u, S = w * 2, _ = l.elements[S + 0], M = l.elements[S + 1], C = _ + M, T = { start: _, count: M, normals: [], continuous: [], concave: [] }, P = _, L = C - 1, D = _ + 1, k = this._shape.roundedCurves.length; do { let j = P - _, U = l.vertices[L * 2 + 0], N = l.vertices[L * 2 + 1], B = l.vertices[P * 2 + 0], H = l.vertices[P * 2 + 1], Q = l.vertices[D * 2 + 0], Y = l.vertices[D * 2 + 1], F = B - U, se = H - N, V = Math.sqrt(F * F + se * se); (F /= V), (se /= V); let ee = B - Q, J = H - Y, fe = Math.sqrt(ee * ee + J * J); (ee /= fe), (J /= fe), (T.normals[j * 2 + 0] = -J), (T.normals[j * 2 + 1] = ee), (T.concave[j] = F * J - se * ee > 0); let re = l.vertexIndices[P]; if (Array.isArray(re)) T.continuous[j] = !1; else { let [oe, ue] = this._shape.getCurveIndexFromVertexId(re - 1, !0); if (ue > 0 && ue < 1) T.continuous[j] = !0; else { let ye = ue === 1 ? oe + 1 : oe - 1; ye = (ye + k) % k; let Te = ue === 1 ? 0 : 1, xe = this._shape.roundedCurves[oe].getTangent(ue), we = this._shape.roundedCurves[ye].getTangent(Te); T.continuous[j] = xe.dot(we) > 0.95; } } A && ((T.normals[j * 2 + 0] *= -1), (T.normals[j * 2 + 1] *= -1)), ([L, P, D] = [P, D, D + 1]), D >= C && (D -= M); } while (D !== _ + 1); let W = []; W.push({ bevelI: 0, angle: 0, size: 0, boundary: { vertices: l.vertices.slice(_ * 2, C * 2), vertexCount: M, vertexIndices: new Array(M).fill(!0).map((j, U) => [U, U]), elements: [0, M], elementCount: 1, mesh: null }, reverseMap: [], insetPoints: l.vertices.slice(_ * 2, C * 2) }); for (let j = 1; j <= this._bevelSegments; j++) { let U = ((j / this._bevelSegments) * Math.PI) / 2, N = (1 - Math.cos(U)) * this._bevelSize, B = [], H = [], Q = [], Y = [], F = 0; for (let V = 0; V < M; V++) { let ee = V * 2, J = ((V - 1 + M) % M) * 2, fe = l.vertices[T.start * 2 + ee + 0], re = l.vertices[T.start * 2 + ee + 1], oe = -T.normals[J + 0] * N, ue = -T.normals[J + 1] * N, ye = -T.normals[ee + 0] * N, Te = -T.normals[ee + 1] * N; if (T.concave[V] || (!T.concave[V] && A)) { let xe = Math.atan2(ue, oe), we = Math.atan2(Te, ye); we > xe && (we -= Math.PI * 2); let Ie = we - xe; if (T.continuous[V] || A) { let He = xe + Ie / 2, dt = Math.cos(He) * N, I = Math.sin(He) * N; (B[2 * F + 0] = fe + dt * (A ? -1 : 1)), (B[2 * F + 1] = re + I * (A ? -1 : 1)), (Y[F] = V), F++; } else { let He = Math.max(1, Math.floor(((r / 4) * Math.abs(Ie)) / Math.PI)); for (let dt = 0; dt <= He; dt++) { let I = xe + Ie * (dt / He), O = Math.cos(I) * N, ie = Math.sin(I) * N; (B[2 * F + 0] = fe + O), (B[2 * F + 1] = re + ie), (Y[F] = V), F++; } } } else (B[2 * F + 0] = fe + oe), (B[2 * F + 1] = re + ue), (Y[F] = V), (H[V] = F), F++, (B[2 * F + 0] = fe), (B[2 * F + 1] = re), (Y[F] = V), F++, (B[2 * F + 0] = fe + ye), (B[2 * F + 1] = re + Te), (Y[F] = V), (Q[V] = F), F++; } let se = _n({ windingRule: yt.POSITIVE, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [B], edgeCreateCallback: (V) => { let ee = V.Org.idx, J = Y[ee], fe = Y[(ee + 1) % Y.length]; (V.idx = [J, fe]), (V.Sym.idx = [fe, J]); }, vertexIdCallback: (V) => { let ee = V.Lprev.idx; return [ee ? ee[1] : 0, V.idx ? V.idx[0] : 0]; } }); if (!se) throw (console.log('Error'), new Error(`error generating bevel geometry for ${j}'th loop`)); if (!se.vertexCount) break; for (let V = 0; V < se.vertexIndices.length; V++) { let [ee, J] = se.vertexIndices[V]; if (ee === J) continue; let fe = J; J < ee && (fe += M); for (let re = ee; re < fe; re++) { let oe = re % M, ue = (re + 1) % M; if (!T.continuous[oe] || !T.continuous[ue]) { (se.vertexIndices[V] = [ee, oe]), se.vertexIndices.splice(V + 1, 0, [ue, J]), se.vertices.splice((V + 1) * 2, 0, se.vertices[V * 2], se.vertices[V * 2 + 1]); break; } } } W.push({ bevelI: j, angle: U, size: N, boundary: se, reverseMap: Y, insetPoints: B }); } let X = (j, U, N) => { let B = 0, H = j.boundary.vertexIndices.length; for (; B < H && N(j.boundary.vertexIndices[U]); ) (U = (U + 1) % H), B++; return B; }, z = g.length; for (let j = 1; j < W.length; j++) { let U = W[j - 1], N = W[j], B = U.boundary.vertexIndices.length, H = N.boundary.vertexIndices.length; if (!B || !H) break; let Q = T.concave.length, Y = 0, F = Zp(Y, M); for (; !U.boundary.vertexIndices.filter(F).length || !N.boundary.vertexIndices.filter(F).length; ) Y++, (F = Zp(Y, M)); let se = U.boundary.vertexIndices.findIndex(F), V = N.boundary.vertexIndices.findIndex(F); do { se = (se + 1) % B; } while (F(U.boundary.vertexIndices[se])); do { V = (V + 1) % H; } while (F(N.boundary.vertexIndices[V])); Y = (Y + 1) % M; let ee = Y, J = this._buildBevelVert(T, U, (se - 1 + B) % B), fe = this._buildBevelVert(T, N, (V - 1 + H) % H), re = J, oe = fe, ue, ye, Te = !1; do { F = Zp(Y, M); let xe = X(U, se, F), we = X(N, V, F), Ie = Te; if (((Te = !1), xe && !we)) { for (let He = 0; He < xe; He++) (ue = this._buildBevelVert(T, U, (se + He) % B, He / (xe - 1))), g.push(re.topN, ue.topP, oe.topN), g.push(ue.bottomP, re.bottomN, oe.bottomN), (re = ue); Te = !0; } else if (!xe && we) for (let He = 0; He < we; He++) (ye = this._buildBevelVert(T, N, (V + He) % H, He / (we - 1))), g.push(oe.topN, re.topP, ye.topP), g.push(re.bottomP, oe.bottomN, ye.bottomP), (oe = ye); else if (xe && we) if ( ((ue = this._buildBevelVert(T, U, se, 0)), (ye = this._buildBevelVert(T, N, V, 0)), Ie ? (g.push(re.topN, ye.topP, oe.topN), g.push(re.topN, ue.topP, ye.topP), g.push(ye.bottomP, re.bottomN, oe.bottomN), g.push(ye.bottomP, ue.bottomP, re.bottomN)) : (g.push(oe.topN, re.topN, ue.topP), g.push(oe.topN, ue.topP, ye.topP), g.push(ue.bottomP, re.bottomN, oe.bottomN), g.push(ue.bottomP, oe.bottomN, ye.bottomP)), (re = ue), (oe = ye), xe === we) ) for (let He = 1; He < xe; He++) (ue = this._buildBevelVert(T, U, (se + He) % B, He / (xe - 1))), (ye = this._buildBevelVert(T, N, (V + He) % H, He / (we - 1))), g.push(re.topN, ue.topP, oe.topN), g.push(oe.topN, ue.topP, ye.topP), g.push(ue.bottomP, re.bottomN, oe.bottomN), g.push(ue.bottomP, oe.bottomN, ye.bottomP), (re = ue), (oe = ye); else if (xe > we) { let He = xe / we, dt = 0; for (let I = 1; I < xe; I++) (ue = this._buildBevelVert(T, U, (se + I) % B, I / (xe - 1))), g.push(re.topN, ue.topP, oe.topN), g.push(ue.bottomP, re.bottomN, oe.bottomN), (re = ue), I > (dt + 1) * He && (dt++, (ye = this._buildBevelVert(T, N, (V + dt) % H, dt / (we - 1))), g.push(oe.topN, ue.topP, ye.topP), g.push(ue.bottomP, oe.bottomN, ye.bottomP), (oe = ye)); } else { let He = we / xe, dt = 0; for (let I = 1; I < we; I++) (ye = this._buildBevelVert(T, N, (V + I) % H, I / (we - 1))), g.push(oe.topN, ue.topP, ye.topP), g.push(ue.bottomP, oe.bottomN, ye.bottomP), (oe = ye), I > (dt + 1) * He && (dt++, (ue = this._buildBevelVert(T, U, (se + dt) % B, dt / (xe - 1))), g.push(re.topN, ue.topP, oe.topN), g.push(ue.bottomP, re.bottomN, oe.bottomN), (re = ue)); } (se = (se + xe) % B), (V = (V + we) % H), (Y = (Y + 1) % Q); } while (Y !== ee); } if ((this._buildWall(W, T, g), A)) { let j = []; for (let U = g.length - 1; U >= z + 2; U -= 3) { let N = g[U - 2], B = g[U - 1], H = g[U - 0]; j.push(H, B, N); } g.splice(z, g.length - z, ...j); } if (A) { let j = []; for (let U = W[W.length - 1].boundary.vertices.length - 1; U >= 1; U -= 2) { let N = W[W.length - 1].boundary.vertices[U - 1], B = W[W.length - 1].boundary.vertices[U - 0]; j.push(N, B); } m.push(j); } if (!A) { let j = W[W.length - 1], U; try { U = _n({ windingRule: W.length > 1 ? yt.POSITIVE : yt.ODD, elementType: Zt.POLYGONS, vertexSize: 2, strict: !0, contours: [j.insetPoints, ...m] }); } catch { U = xA; } if (!U) throw new Error('Error generating geometry for surface'); o.length === 0 && Object.assign(this, { capStartIndex: g.length }); for (let N = 0; N < U.elementCount * 3; N += 3) { let B = this._buildSurfaceVert(U, U.elements[N + 0]), H = this._buildSurfaceVert(U, U.elements[N + 1]), Q = this._buildSurfaceVert(U, U.elements[N + 2]); g.push(B.top, H.top, Q.top), g.push(Q.bottom, H.bottom, B.bottom); } } this.vertexCache = {}; } this._buffer.shrink(); let v = new Xe(Uint32Array.from(g), 1), y = new Xe(this._buffer.positions, 3), b = new Xe(this._buffer.normals, 3), x = new Xe(this._buffer.uvs, 2); (y.needsUpdate = !0), (b.needsUpdate = !0), (x.needsUpdate = !0), (v.needsUpdate = !0), this.setAttribute('position', y), this.setAttribute('normal', b), this.setAttribute('uv', x), this.setIndex(v); } _computeBufferEstimatedSize(e) { return e.vertexCount * 2 * (2 + this._bevelSegments); } _buildWall(e, t, i) { let r = e[0]; for (let s = 0, n = r.boundary.vertexCount; s < n; s++) { let a = this._buildBevelVert(t, r, s), o = this._buildBevelVert(t, r, (s + 1) % n); i.push(o.topP, a.topN, a.bottomN), i.push(o.topP, a.bottomN, o.bottomP); } } _buildSurfaceVert(e, t) { let i = t.toString(); if (i in this.vertexCache) return this.vertexCache[i]; let r = e.vertices[t * 2 + 0], s = e.vertices[t * 2 + 1], n = (r - this._minX) / this._width, a = (s - this._minY) / this._height, o = this._buffer.get(2), l = o * 3, h = o * 2, u = { top: o + 0, bottom: o + 1 }; return ( (this._buffer.positions[l + 0] = r), (this._buffer.positions[l + 1] = s), (this._buffer.positions[l + 2] = this._depth), (this._buffer.normals[l + 0] = 0), (this._buffer.normals[l + 1] = 0), (this._buffer.normals[l + 2] = 1), (this._buffer.uvs[h + 0] = n), (this._buffer.uvs[h + 1] = a), (this._buffer.positions[l + 3] = r), (this._buffer.positions[l + 4] = s), (this._buffer.positions[l + 5] = 0), (this._buffer.normals[l + 3] = 0), (this._buffer.normals[l + 4] = 0), (this._buffer.normals[l + 5] = -1), (this._buffer.uvs[h + 2] = n), (this._buffer.uvs[h + 3] = a), (this.vertexCache[i] = u), u ); } _buildBevelVert(e, t, i, r = 1) { let s = `${t.bevelI}:${i}`; if (s in this.vertexCache) return this.vertexCache[s]; let [n, a] = t.boundary.vertexIndices[i], o, l, h, u; n !== a ? ((l = n), (o = a), (u = !1), (h = e.continuous[l] && e.continuous[o])) : ((o = n), (l = (o - 1 + e.count) % e.count), (u = e.concave[o] && t.bevelI > 0), (h = e.continuous[o] || u)); let c = Math.cos(t.angle), d = Math.sin(t.angle), p = i * 2, f = o * 2, g = l * 2, m = t.boundary.vertices[p + 0], v = t.boundary.vertices[p + 1], y = (1 - d) * this._bevelSize, b = (m - this._minX) / this._width, x = (v - this._minY) / this._height, w = e.normals[f + 0], A = e.normals[f + 1], S = e.normals[g + 0], _ = e.normals[g + 1]; if (u) { let L = S - w, D = _ - A; (w = w + L * (1 - r)), (A = A + D * (1 - r)); let k = Math.sqrt(w * w + A * A); (w /= k), (A /= k); } let M = this._buffer.get(h ? 2 : 4), C = M * 3, T = M * 2, P = { i: i, fi: o, topP: M + 0, topN: M + 0, bottomP: M + 1, bottomN: M + 1 }; return ( (this._buffer.positions[C + 0] = m), (this._buffer.positions[C + 1] = v), (this._buffer.positions[C + 2] = this._depth - y), (this._buffer.normals[C + 0] = w * c), (this._buffer.normals[C + 1] = A * c), (this._buffer.normals[C + 2] = d), (this._buffer.uvs[T + 0] = b), (this._buffer.uvs[T + 1] = x), (this._buffer.positions[C + 3] = m), (this._buffer.positions[C + 4] = v), (this._buffer.positions[C + 5] = y), (this._buffer.normals[C + 3] = w * c), (this._buffer.normals[C + 4] = A * c), (this._buffer.normals[C + 5] = -d), (this._buffer.uvs[T + 2] = x), (this._buffer.uvs[T + 3] = b), h || ((M += 2), (C += 6), (T += 4), (P.topP = M + 0), (P.bottomP = M + 1), (this._buffer.positions[C + 0] = m), (this._buffer.positions[C + 1] = v), (this._buffer.positions[C + 2] = this._depth - y), (this._buffer.normals[C + 0] = S * c), (this._buffer.normals[C + 1] = _ * c), (this._buffer.normals[C + 2] = d), (this._buffer.uvs[T + 0] = b), (this._buffer.uvs[T + 1] = x), (this._buffer.positions[C + 3] = m), (this._buffer.positions[C + 4] = v), (this._buffer.positions[C + 5] = y), (this._buffer.normals[C + 3] = S * c), (this._buffer.normals[C + 4] = _ * c), (this._buffer.normals[C + 5] = -d), (this._buffer.uvs[T + 2] = x), (this._buffer.uvs[T + 3] = b)), (this.vertexCache[s] = P), P ); } clone() { let e = new bA(this._shape, this._depth, this._bevel, this._curveSegments, this._bevelSegmentsInput); return (e.userData = yu(this.userData)), e; } }, wA = class extends Ve { constructor(e, t = 12, i = {}) { super(), (this.type = 'ShapeGeometry'), (this.windingRule = yt.ODD), (this.elementType = Zt.POLYGONS), (this.polySize = 3), (this.vertexSize = 2), (this.strict = !0), (this._shape = e), (this._curveSegments = t), (this._triangulationOptions = Object.assign( { windingRule: yt.ODD, elementType: Zt.POLYGONS, polySize: 3, vertexSize: 2, strict: !0 }, i )); let r = this._shape.extractShapePointsToFlatArray([], this._curveSegments), s = this._shape.shapeHoles.map((d) => d.extractShapePointsToFlatArray([], this._curveSegments)), n, a = !0, o = !0, l, h; for (let d = 0, p = r.length / 2; d < p; d++) { let f = d * 2, g = r[f + 0], m = r[f + 1]; if ((l !== void 0 && g !== l && (a = !1), h !== void 0 && m !== h && (o = !1), (l = g), (h = m), !a && !o)) break; } if (!a && !o) try { n = _n({ contours: [r, ...s], windingRule: this._triangulationOptions.windingRule, elementType: this._triangulationOptions.elementType, polySize: this._triangulationOptions.polySize, vertexSize: this._triangulationOptions.vertexSize, strict: this._triangulationOptions.strict }); } catch { n = rv; } let u = n?.vertexCount ?? 1, c = n?.elementCount ?? 1; if ( ((this._positionAttribute = new Xe(new Float32Array(u * 3), 3)), (this._normalAttribute = new Xe(new Float32Array(u * 3), 3)), (this._uvAttribute = new Xe(new Float32Array(u * 2), 2)), (this._indexAttribute = new Xe(new Uint32Array(c * 3), 1)), n) ) { let d = 1 / 0, p = -1 / 0, f = 1 / 0, g = -1 / 0; for (let y = 0, b = u; y < b; y++) { let x = y * 2, w = n.vertices[x + 0], A = n.vertices[x + 1]; w < d && (d = w), w > p && (p = w), A < f && (f = A), A > g && (g = A); } let m = p - d, v = g - f; for (let y = 0, b = u; y < b; y++) { let x = y * 2, w = n.vertices[x + 0], A = n.vertices[x + 1], S = (w - d) / m, _ = (A - f) / v; this._positionAttribute.setXYZ(y, w, A, 0), this._normalAttribute.setXYZ(y, 0, 0, 1), this._uvAttribute.setXY(y, S, _); } for (let y = 0, b = c; y < b; y++) { let x = y * 3, w = n.elements[x + 0], A = n.elements[x + 1], S = n.elements[x + 2]; this._indexAttribute.setX(x + 0, w), this._indexAttribute.setX(x + 1, A), this._indexAttribute.setX(x + 2, S); } } this.setAttribute('position', this._positionAttribute), this.setAttribute('normal', this._normalAttribute), this.setAttribute('uv', this._uvAttribute), this.setIndex(this._indexAttribute), this.setDrawRange(0, (n?.elementCount ?? 1) * 3); } clone() { let e = new wA(this._shape, this._curveSegments); return (e.userData = yu(this.userData)), e; } }, _A = class extends bA { constructor(e, t, i = 0, r = 12, s = 3, n = yt.ODD) { super(e, t, i, r, s, n), (this.type = 'ShapeGeometry'); } _computeBufferEstimatedSize(e) { return e.vertexCount * 2 * (2 + this._bevelSegments); } _buildWall(e, t, i) { let r = e[0]; for (let s = 0, n = r.boundary.vertexCount; s < n; s++) { let a = this._buildBevelVert(t, r, s), o = this._buildBevelVert(t, r, (s + 1) % n); i.push(o.topP, a.topN, a.bottomN), i.push(o.topP, a.bottomN, o.bottomP); } } clone() { let e = new _A(this._shape, this._depth, this._bevel, this._curveSegments, this._bevelSegmentsInput); return (e.userData = yu(this.userData)), e; } }, Ta = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, subdivisions: 40, roundness: 0, extrudeBevelSize: 0, extrudeBevelSegments: 3, windingRule: yt.ODD }, e.parameters ), r = Math.abs(i.width), s = Math.abs(i.height ?? i.width), n = Math.abs(i.depth ?? 0), a = e.shape ?? t?.shape, o = a?.roundness ?? i.roundness; a !== void 0 && (a instanceof Nt ? (a.width !== r || a.height !== s) && a.applySize(r, s) : (a = new Nt(r, s).fromJSON(a)), e.parameters?.roundness !== void 0 && e.parameters?.roundness > 0 && a.update()); let l = a ?? new Nt(r, s); return { parameters: Object.assign(i, { width: r, height: s, depth: n, roundness: o }), shape: l }; } static build(e) { let { depth: t, extrudeBevelSize: i, extrudeBevelSegments: r, subdivisions: s, roundness: n, windingRule: a } = e.parameters; e.shape.roundness = n; let o; return ( t <= 0 ? (o = new wA(e.shape, s, { windingRule: a })) : (o = new _A(e.shape, t, i, s, r, a)), Object.assign(o, { userData: { ...e, type: 'VectorGeometry' } }) ); } }, AA = Math.PI * 2, sv = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, depth: 0, spikes: 64, angle: 360, innerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1 }, e.parameters ); return { shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(), parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }) }; } static build(e) { let { width: t, height: i, spikes: r, angle: s, innerRadius: n, depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } = e.parameters, h = e.shape, u = t * 0.5, c = i * 0.5, d = JF(h, u, c, (s * Math.PI) / 180, r, n); (h.isClosed = !0), h.update(); let p = Ta.create({ shape: h, parameters: { subdivisions: d, depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } }); return Object.assign(p, { userData: { ...e, type: 'EllipseGeometry' } }); } }; function JF(e, t, i, r, s, n) { if (r >= AA) return s > 30 || s % 4 === 0 ? (e6(e, t, i, n), Math.round(s / 4)) : Ex(e, r, s, t, i, n); r = Math.max(r, 0.001); let a = { x: 0, y: i }, o = r + Math.PI * 0.5, l = { x: Math.cos(o) * t, y: Math.sin(o) * i }, h = qF({ px: a.x, py: a.y, cx: l.x, cy: l.y, rx: t, ry: i, largeArcFlag: r > Math.PI, sweepFlag: !0 }); return s > 30 || s % h.length === 0 ? $F(e, a.x, a.y, h, s, t, i, n) : Ex(e, r, s, t, i, n); } function $F(e, t, i, r, s, n, a, o) { let l = Math.round(s / r.length); e.addPoint(Do(t, i)); for (let h = 0, u = r.length; h < u; h++) { let c = r[h], d = e.points[h], p = Do(c.x, c.y); d.controls[1].position.set(c.x1, c.y1), p.controls[0].position.set(c.x2, c.y2), e.addPoint(p); } return o > 0 ? SA(e, n, a, o) : e.addPoint(Do(0, 0)), l; } function Ex(e, t, i, r, s, n) { let a = -t / i; for (let o = 0; o <= i; o++) { let l = a * o, h = Math.sin(l) * r, u = Math.cos(l) * s; e.addPoint(Do(h, u)); } return ( t < AA ? (n > 0 ? SA(e, r, s, n) : e.addPoint(Do(0, 0))) : (e.removePoint(e.points[e.points.length - 1]), n > 0 && MA(e, r, s, n)), 1 ); } function e6(e, t, i, r = 0, s = 0, n = 0) { let a = 0.5522847498, o = t * a, l = i * a; e.addPoint(Ic(s - t, n, s - t, n - l, s - t, n + l)), e.addPoint(Ic(s, n + i, s - o, n + i, s + o, n + i)), e.addPoint(Ic(s + t, n, s + t, n + l, s + t, n - l)), e.addPoint(Ic(s, n - i, s + o, n - i, s - o, n - i)), r > 0 && MA(e, t, i, r); } function Do(e, t) { return new Po(it.generateUUID(), new G(e, t)); } function Ic(e, t, i, r, s, n) { let a = Do(e, t); return a.controls[0].position.set(i, r), a.controls[1].position.set(s, n), a; } function SA(e, t, i, r) { EA(e, t, i, r).forEach((s) => e.addPoint(s)); } function MA(e, t, i, r) { let s = EA(e, t, i, r), n = new Nt(); s.forEach((a) => n.addPoint(a)), (n.isClosed = !0), e.shapeHoles.push(n); } function EA(e, t, i, r) { let s = (r * t) / 100, n = s * (Math.abs(i) / Math.abs(t)), a = new G(s / t, n / i), o = e.points .map((l) => { let h = l.clone(); return (h.uuid = it.generateUUID()), h; }) .reverse(); return ( o.forEach((l) => { l.position.multiply(a); let h = l.controls[0].position.clone().multiply(a), u = l.controls[1].position.clone().multiply(a); l.controls[0].position.copy(u), l.controls[1].position.copy(h); }), o ); } var t6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, revolutions: 2, segments: 40, pathRadius: 10, pathType: 0, pathSegments: 30, cornerRadius: 30, cornerSegments: 4 }, e.parameters ), r = Math.abs(i.width), s = Math.abs(i.height ?? r), n = Math.abs(i.depth ?? r), a = Math.abs(Math.min(r, n)) / 2; return { parameters: Object.assign(i, { width: r, height: s, depth: n, radius: a, segments: Math.round(i.segments), pathSegments: Math.round(i.pathSegments), cornerSegments: Math.round(i.cornerSegments) }) }; } static build(e) { let { width: t, height: i, depth: r, radius: s, revolutions: n, segments: a, pathRadius: o, pathType: l, pathSegments: h, cornerRadius: u, cornerSegments: c } = e.parameters, d = new nv(!1, t, i, r, s, n, a, o, l, h, u, c); return Object.assign(d, { userData: { ...e, type: 'HelixGeometry' } }); } }, nv = class extends Ve { constructor(e = !0, t = 1, i = 1, r = 1, s = 1, n = 1, a = 1, o = 1, l = 1, h = 1, u = 1, c = 1, d = !1) { super(); let p = e && n === 1; p && (c = 0), u > 100 && (u = 100); let f = () => new E(), g = new E(), m = f(), v = f(), y = f(), b, x, w, A, S, _, M, C, T = f(), P = f(), L = f(), D = f(), k = f(), W = f(), X = f(), z = f(), j = i - 2 * o + 0.001, U = j / n, N = Math.ceil(a * n), B = N + 1, H = j / N, Q = -j / 2, Y = h + 1, F = (2 * Math.PI) / h, se = Math.PI / 2 / c, V = 0.01, ee = Math.min((1 - u / 100) * o, o - V), J = o - ee, fe = 0, re = 2, oe = c * re + re, ue = (Y * oe) / re, ye = ue + Y * B, Te = Y * (B + oe), [xe, we, Ie] = [3, 3, 2].map((Ee) => Array(Te * Ee).fill(0)), He = [], dt = s - o; function I(Ee, _e) { let Le = Math.PI / 2; (_ = _e * H), (C = (2 * Math.PI * (_ % U)) / U + Le), (_ += Q), (M = Math.sin(C) * dt), (S = Math.cos(C) * dt), e ? Ee.set(S, M, _) : Ee.set(S, _, M); } I(g, -1e-10), I(m, 0), T.copy(g), I(g, 1); let O = g.distanceTo(m), ie = p ? 0 : J + ee, pe = O * N + 2 * ie, me = ee, be = pe - ie; for (let Ee = 0; Ee <= N; Ee++) { I(v, Ee), z.subVectors(v, T).normalize(), T.copy(v), W.copy(v) .setComponent(+e + 1, 0) .normalize(), X.crossVectors(z, W).normalize(); let _e = Ee === 0, Le = Ee === N, Ne = _e ? (3 * Math.PI) / 2 : se, at = _e ? me : be, Mt = _e ? Y : ye, Wt = _e ? 0 : Te - Y, q = z .clone() .multiplyScalar(_e ? -J : J) .add(v), ne = z .clone() .multiplyScalar(_e ? -1 : 1) .normalize(); for (let de = 0; de < Y; de++) { let Ae = de * F; if ( (P.addVectors(g.copy(W).multiplyScalar(o * Math.cos(Ae)), m.copy(X).multiplyScalar(o * Math.sin(Ae))), L.copy(P).normalize(), _e || Le) ) { p || ((fe = Wt + de), [0, 1, 2].forEach((De) => { (xe[fe * 3 + De] = q.getComponent(De)), (we[fe * 3 + De] = ne.getComponent(De)); }), (Ie[fe * 2] = +Le), (Ie[fe * 2 + 1] = de / h)), m.copy(L).multiplyScalar(ee), y.addVectors(v, m); for (let De = 0; De < c; De++) { let ot = De * se + Ne; D.addVectors(g.copy(z).multiplyScalar(J * Math.sin(ot)), m.copy(L).multiplyScalar(J * Math.cos(ot))), k.copy(D).normalize(), m.addVectors(y, D), D.normalize(), (fe = Mt + De * Y + de), [0, 1, 2].forEach((Ft) => { (xe[fe * 3 + Ft] = m.getComponent(Ft)), (we[fe * 3 + Ft] = k.getComponent(Ft)); }); let Xt = +_e + Math.sin(ot); (Ie[fe * 2] = (at + J * Xt) / pe), (Ie[fe * 2 + 1] = de / h); } } m.addVectors(v, P), (fe = ue + Ee * Y + de), [0, 1, 2].forEach((De) => { (xe[fe * 3 + De] = m.getComponent(De)), (we[fe * 3 + De] = L.getComponent(De)); }), (Ie[fe * 2] = (ie + Ee * O) / pe), (Ie[fe * 2 + 1] = de / h); } } let We = B + 2 * c + re, Me = 1, [ce, Fe] = [+p, We - 1]; d && (Fe -= 1); for (let Ee = ce; Ee <= Fe - 1; Ee++) { let _e = p && Ee === Fe - 1; for (let Le = 0; Le < Y - 1; Le++) (b = Ee * Y + Le), (x = b + 1), (w = (_e ? Le : b) + Y), (A = (_e ? Le + 1 : x) + Y), Ee === 0 ? He.push(x, A, w) : Ee === We - 2 ? He.push(b, x, w) : He.push(b, x, w, x, A, w); } this.setIndex(He), this.setAttribute('position', new Ce(xe, 3)), this.setAttribute('normal', new Ce(we, 3)), this.setAttribute('uv', new Ce(Ie, 2)); } }, i6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, detail: 0, corner: 0, cornerSides: 4 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, height: i, depth: r, detail: s, corner: n, cornerSides: a } = e.parameters, o = s === 0 && n !== 0 ? new CA(t * 0.5, n, a) : new Bw(t * 0.5, s); return o.scale(1, i / t, r / t), Object.assign(o, { userData: { ...e, type: 'IcosahedronGeometry' } }); } }, CA = class extends ev { constructor(e = 1, t = 0.2, i = 4) { let r = (1 + Math.sqrt(5)) / 2, s = [-1, r, 0, 1, r, 0, -1, -r, 0, 1, -r, 0, 0, -1, r, 0, 1, r, 0, -1, -r, 0, 1, -r, r, 0, -1, r, 0, 1, -r, 0, -1, -r, 0, 1], n = [ 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 ], a = 'IcosahedronGeometry'; super(s, n, a, e, t, i), (this.type = a); } static fromJSON(e) { return new CA(e.radius, e.corner, e.cornerSides); } }, r6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { (e.parameters?.points ?? []).forEach((r) => { Array.isArray(r) && ((r.x = r[0]), (r.y = r[1])); }); let i = Object.assign( {}, t?.parameters ?? { width: 100, segments: 64, verticalSegments: 64, points: [ { x: 0, y: -50, id: 0 }, { x: 50, y: -50, id: 1 }, { x: 50, y: 50, id: 2 }, { x: 0, y: 50, id: 3 } ] }, e.parameters ); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { points: t, segments: i, verticalSegments: r } = e.parameters, s = new xd(); s.moveTo(t[0].x, t[0].y), s.bezierCurveTo(t[1].x, t[1].y, t[2].x, t[2].y, t[3].x, t[3].y); let n = new Tw(s.extractPoints(r).shape, i); return n.rotateZ(Math.PI), Object.assign(n, { userData: { ...e, type: 'LatheGeometry' } }); } }, Zr = new ve(), Kp = new bt(), Rc = new E(), Qd = class extends Vi { constructor() { super(), (this.uuid = it.generateUUID()), (this.name = ''), (this.type = 'Geometry'), (this.vertices = []), (this.colors = []), (this.faces = []), (this.faceVertexUvs = [[]]), (this.morphTargets = []), (this.morphNormals = []), (this.skinWeights = []), (this.skinIndices = []), (this.lineDistances = []), (this.boundingBox = null), (this.boundingSphere = null), (this.elementsNeedUpdate = !1), (this.verticesNeedUpdate = !1), (this.uvsNeedUpdate = !1), (this.normalsNeedUpdate = !1), (this.colorsNeedUpdate = !1), (this.lineDistancesNeedUpdate = !1), (this.groupsNeedUpdate = !1); } applyMatrix4(e) { let t = new Ai().getNormalMatrix(e); for (let i = 0, r = this.vertices.length; i < r; i++) this.vertices[i].applyMatrix4(e); for (let i = 0, r = this.faces.length; i < r; i++) { let s = this.faces[i]; s.normal.applyMatrix3(t).normalize(); for (let n = 0, a = s.vertexNormals.length; n < a; n++) s.vertexNormals[n].applyMatrix3(t).normalize(); } return ( this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), (this.verticesNeedUpdate = !0), (this.normalsNeedUpdate = !0), this ); } rotateX(e) { return Zr.makeRotationX(e), this.applyMatrix4(Zr), this; } rotateY(e) { return Zr.makeRotationY(e), this.applyMatrix4(Zr), this; } rotateZ(e) { return Zr.makeRotationZ(e), this.applyMatrix4(Zr), this; } translate(e, t, i) { return Zr.makeTranslation(e, t, i), this.applyMatrix4(Zr), this; } scale(e, t, i) { return Zr.makeScale(e, t, i), this.applyMatrix4(Zr), this; } lookAt(e) { return Kp.lookAt(e), Kp.updateMatrix(), this.applyMatrix4(Kp.matrix), this; } fromBufferGeometry(e) { let t = this, i = e.index !== null ? e.index : void 0, r = e.attributes; if (r.position === void 0) return console.error('THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.'), this; let s = r.position, n = r.normal, a = r.color, o = r.uv, l = r.uv2; l !== void 0 && (this.faceVertexUvs[1] = []); for (let c = 0; c < s.count; c++) t.vertices.push(new E().fromBufferAttribute(s, c)), a !== void 0 && t.colors.push(new Ge().fromBufferAttribute(a, c)); function h(c, d, p, f) { let g = a === void 0 ? [] : [t.colors[c].clone(), t.colors[d].clone(), t.colors[p].clone()], m = n === void 0 ? [] : [new E().fromBufferAttribute(n, c), new E().fromBufferAttribute(n, d), new E().fromBufferAttribute(n, p)], v = new Nm(c, d, p, m, g, f); t.faces.push(v), o !== void 0 && t.faceVertexUvs[0].push([ new G().fromBufferAttribute(o, c), new G().fromBufferAttribute(o, d), new G().fromBufferAttribute(o, p) ]), l !== void 0 && t.faceVertexUvs[1].push([ new G().fromBufferAttribute(l, c), new G().fromBufferAttribute(l, d), new G().fromBufferAttribute(l, p) ]); } let u = e.groups; if (u.length > 0) for (let c = 0; c < u.length; c++) { let d = u[c], p = d.start, f = d.count; for (let g = p, m = p + f; g < m; g += 3) i !== void 0 ? h(i.getX(g), i.getX(g + 1), i.getX(g + 2), d.materialIndex) : h(g, g + 1, g + 2, d.materialIndex); } else if (i !== void 0) for (let c = 0; c < i.count; c += 3) h(i.getX(c), i.getX(c + 1), i.getX(c + 2)); else for (let c = 0; c < s.count; c += 3) h(c, c + 1, c + 2); return ( this.computeFaceNormals(), e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this ); } center() { return this.computeBoundingBox(), this.boundingBox.getCenter(Rc).negate(), this.translate(Rc.x, Rc.y, Rc.z), this; } normalize() { this.computeBoundingSphere(); let e = this.boundingSphere.center, t = this.boundingSphere.radius, i = t === 0 ? 1 : 1 / t, r = new ve(); return r.set(i, 0, 0, -i * e.x, 0, i, 0, -i * e.y, 0, 0, i, -i * e.z, 0, 0, 0, 1), this.applyMatrix4(r), this; } computeFaceNormals() { let e = new E(), t = new E(); for (let i = 0, r = this.faces.length; i < r; i++) { let s = this.faces[i], n = this.vertices[s.a], a = this.vertices[s.b], o = this.vertices[s.c]; e.subVectors(o, a), t.subVectors(n, a), e.cross(t), e.normalize(), s.normal.copy(e); } } computeVertexNormals(e = !0) { let t = new Array(this.vertices.length); for (let i = 0, r = this.vertices.length; i < r; i++) t[i] = new E(); if (e) { let i = new E(), r = new E(); for (let s = 0, n = this.faces.length; s < n; s++) { let a = this.faces[s], o = this.vertices[a.a], l = this.vertices[a.b], h = this.vertices[a.c]; i.subVectors(h, l), r.subVectors(o, l), i.cross(r), t[a.a].add(i), t[a.b].add(i), t[a.c].add(i); } } else { this.computeFaceNormals(); for (let i = 0, r = this.faces.length; i < r; i++) { let s = this.faces[i]; t[s.a].add(s.normal), t[s.b].add(s.normal), t[s.c].add(s.normal); } } for (let i = 0, r = this.vertices.length; i < r; i++) t[i].normalize(); for (let i = 0, r = this.faces.length; i < r; i++) { let s = this.faces[i], n = s.vertexNormals; n.length === 3 ? (n[0].copy(t[s.a]), n[1].copy(t[s.b]), n[2].copy(t[s.c])) : ((n[0] = t[s.a].clone()), (n[1] = t[s.b].clone()), (n[2] = t[s.c].clone())); } this.faces.length > 0 && (this.normalsNeedUpdate = !0); } computeFlatVertexNormals() { this.computeFaceNormals(); for (let e = 0, t = this.faces.length; e < t; e++) { let i = this.faces[e], r = i.vertexNormals; r.length === 3 ? (r[0].copy(i.normal), r[1].copy(i.normal), r[2].copy(i.normal)) : ((r[0] = i.normal.clone()), (r[1] = i.normal.clone()), (r[2] = i.normal.clone())); } this.faces.length > 0 && (this.normalsNeedUpdate = !0); } computeMorphNormals() { for (let t = 0, i = this.faces.length; t < i; t++) { let r = this.faces[t]; r.__originalFaceNormal ? r.__originalFaceNormal.copy(r.normal) : (r.__originalFaceNormal = r.normal.clone()), r.__originalVertexNormals || (r.__originalVertexNormals = []); for (let s = 0, n = r.vertexNormals.length; s < n; s++) r.__originalVertexNormals[s] ? r.__originalVertexNormals[s].copy(r.vertexNormals[s]) : (r.__originalVertexNormals[s] = r.vertexNormals[s].clone()); } let e = new Qd(); e.faces = this.faces; for (let t = 0, i = this.morphTargets.length; t < i; t++) { if (!this.morphNormals[t]) { (this.morphNormals[t] = {}), (this.morphNormals[t].faceNormals = []), (this.morphNormals[t].vertexNormals = []); let s = this.morphNormals[t].faceNormals, n = this.morphNormals[t].vertexNormals; for (let a = 0, o = this.faces.length; a < o; a++) { let l = new E(), h = { a: new E(), b: new E(), c: new E() }; s.push(l), n.push(h); } } let r = this.morphNormals[t]; (e.vertices = this.morphTargets[t].vertices), e.computeFaceNormals(), e.computeVertexNormals(); for (let s = 0, n = this.faces.length; s < n; s++) { let a = this.faces[s], o = r.faceNormals[s], l = r.vertexNormals[s]; o.copy(a.normal), l.a.copy(a.vertexNormals[0]), l.b.copy(a.vertexNormals[1]), l.c.copy(a.vertexNormals[2]); } } for (let t = 0, i = this.faces.length; t < i; t++) { let r = this.faces[t]; (r.normal = r.__originalFaceNormal), (r.vertexNormals = r.__originalVertexNormals); } } computeBoundingBox() { this.boundingBox === null && (this.boundingBox = new Kt()), this.boundingBox.setFromPoints(this.vertices); } computeBoundingSphere() { this.boundingSphere === null && (this.boundingSphere = new Mr()), this.boundingSphere.setFromPoints(this.vertices); } merge(e, t, i = 0) { if (!(e && e.isGeometry)) { console.error('THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', e); return; } let r, s = this.vertices.length, n = this.vertices, a = e.vertices, o = this.faces, l = e.faces, h = this.colors, u = e.colors; t !== void 0 && (r = new Ai().getNormalMatrix(t)); for (let c = 0, d = a.length; c < d; c++) { let p = a[c].clone(); t !== void 0 && p.applyMatrix4(t), n.push(p); } for (let c = 0, d = u.length; c < d; c++) h.push(u[c].clone()); for (let c = 0, d = l.length; c < d; c++) { let p = l[c], f, g, m = p.vertexNormals, v = p.vertexColors, y = new Nm(p.a + s, p.b + s, p.c + s); y.normal.copy(p.normal), r !== void 0 && y.normal.applyMatrix3(r).normalize(); for (let b = 0, x = m.length; b < x; b++) (f = m[b].clone()), r !== void 0 && f.applyMatrix3(r).normalize(), y.vertexNormals.push(f); y.color.copy(p.color); for (let b = 0, x = v.length; b < x; b++) (g = v[b]), y.vertexColors.push(g.clone()); (y.materialIndex = p.materialIndex + i), o.push(y); } for (let c = 0, d = e.faceVertexUvs.length; c < d; c++) { let p = e.faceVertexUvs[c]; this.faceVertexUvs[c] === void 0 && (this.faceVertexUvs[c] = []); for (let f = 0, g = p.length; f < g; f++) { let m = p[f], v = []; for (let y = 0, b = m.length; y < b; y++) v.push(m[y].clone()); this.faceVertexUvs[c].push(v); } } } mergeMesh(e) { if (!(e && e.isMesh)) { console.error('THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', e); return; } e.matrixAutoUpdate && e.updateMatrix(), this.merge(e.geometry, e.matrix); } mergeVertices(e = 4) { let t = {}, i = [], r = [], s = Math.pow(10, e); for (let o = 0, l = this.vertices.length; o < l; o++) { let h = this.vertices[o], u = Math.round(h.x * s) + '_' + Math.round(h.y * s) + '_' + Math.round(h.z * s); t[u] === void 0 ? ((t[u] = o), i.push(this.vertices[o]), (r[o] = i.length - 1)) : (r[o] = r[t[u]]); } let n = []; for (let o = 0, l = this.faces.length; o < l; o++) { let h = this.faces[o]; (h.a = r[h.a]), (h.b = r[h.b]), (h.c = r[h.c]); let u = [h.a, h.b, h.c]; for (let c = 0; c < 3; c++) if (u[c] === u[(c + 1) % 3]) { n.push(o); break; } } for (let o = n.length - 1; o >= 0; o--) { let l = n[o]; this.faces.splice(l, 1); for (let h = 0, u = this.faceVertexUvs.length; h < u; h++) this.faceVertexUvs[h].splice(l, 1); } let a = this.vertices.length - i.length; return (this.vertices = i), a; } setFromPoints(e) { this.vertices = []; for (let t = 0, i = e.length; t < i; t++) { let r = e[t]; this.vertices.push(new E(r.x, r.y, r.z || 0)); } return this; } sortFacesByMaterialIndex() { let e = this.faces, t = e.length; for (let o = 0; o < t; o++) e[o]._id = o; function i(o, l) { return o.materialIndex - l.materialIndex; } e.sort(i); let r = this.faceVertexUvs[0], s = this.faceVertexUvs[1], n, a; r && r.length === t && (n = []), s && s.length === t && (a = []); for (let o = 0; o < t; o++) { let l = e[o]._id; n && n.push(r[l]), a && a.push(s[l]); } n && (this.faceVertexUvs[0] = n), a && (this.faceVertexUvs[1] = a); } toJSON() { let e = { metadata: { version: 4.5, type: 'Geometry', generator: 'Geometry.toJSON' } }; if (((e.uuid = this.uuid), (e.type = this.type), this.name !== '' && (e.name = this.name), this.parameters !== void 0)) { let p = this.parameters; for (let f in p) p[f] !== void 0 && (e[f] = p[f]); return e; } let t = []; for (let p = 0; p < this.vertices.length; p++) { let f = this.vertices[p]; t.push(f.x, f.y, f.z); } let i = [], r = [], s = {}, n = [], a = {}, o = [], l = {}; for (let p = 0; p < this.faces.length; p++) { let f = this.faces[p], g = !0, m = !1, v = this.faceVertexUvs[0][p] !== void 0, y = f.normal.length() > 0, b = f.vertexNormals.length > 0, x = f.color.r !== 1 || f.color.g !== 1 || f.color.b !== 1, w = f.vertexColors.length > 0, A = 0; if ( ((A = h(A, 0, 0)), (A = h(A, 1, g)), (A = h(A, 2, m)), (A = h(A, 3, v)), (A = h(A, 4, y)), (A = h(A, 5, b)), (A = h(A, 6, x)), (A = h(A, 7, w)), i.push(A), i.push(f.a, f.b, f.c), i.push(f.materialIndex), v) ) { let S = this.faceVertexUvs[0][p]; i.push(d(S[0]), d(S[1]), d(S[2])); } if ((y && i.push(u(f.normal)), b)) { let S = f.vertexNormals; i.push(u(S[0]), u(S[1]), u(S[2])); } if ((x && i.push(c(f.color)), w)) { let S = f.vertexColors; i.push(c(S[0]), c(S[1]), c(S[2])); } } function h(p, f, g) { return g ? p | (1 << f) : p & ~(1 << f); } function u(p) { let f = p.x.toString() + p.y.toString() + p.z.toString(); return s[f] !== void 0 || ((s[f] = r.length / 3), r.push(p.x, p.y, p.z)), s[f]; } function c(p) { let f = p.r.toString() + p.g.toString() + p.b.toString(); return a[f] !== void 0 || ((a[f] = n.length), n.push(p.getHex())), a[f]; } function d(p) { let f = p.x.toString() + p.y.toString(); return l[f] !== void 0 || ((l[f] = o.length / 2), o.push(p.x, p.y)), l[f]; } return ( (e.data = {}), (e.data.vertices = t), (e.data.normals = r), n.length > 0 && (e.data.colors = n), o.length > 0 && (e.data.uvs = [o]), (e.data.faces = i), e ); } clone() { return new Qd().copy(this); } copy(e) { (this.vertices = []), (this.colors = []), (this.faces = []), (this.faceVertexUvs = [[]]), (this.morphTargets = []), (this.morphNormals = []), (this.skinWeights = []), (this.skinIndices = []), (this.lineDistances = []), (this.boundingBox = null), (this.boundingSphere = null), (this.name = e.name); let t = e.vertices; for (let c = 0, d = t.length; c < d; c++) this.vertices.push(t[c].clone()); let i = e.colors; for (let c = 0, d = i.length; c < d; c++) this.colors.push(i[c].clone()); let r = e.faces; for (let c = 0, d = r.length; c < d; c++) this.faces.push(r[c].clone()); for (let c = 0, d = e.faceVertexUvs.length; c < d; c++) { let p = e.faceVertexUvs[c]; this.faceVertexUvs[c] === void 0 && (this.faceVertexUvs[c] = []); for (let f = 0, g = p.length; f < g; f++) { let m = p[f], v = []; for (let y = 0, b = m.length; y < b; y++) { let x = m[y]; v.push(x.clone()); } this.faceVertexUvs[c].push(v); } } let s = e.morphTargets; for (let c = 0, d = s.length; c < d; c++) { let p = {}; if (((p.name = s[c].name), s[c].vertices !== void 0)) { p.vertices = []; for (let f = 0, g = s[c].vertices.length; f < g; f++) p.vertices.push(s[c].vertices[f].clone()); } if (s[c].normals !== void 0) { p.normals = []; for (let f = 0, g = s[c].normals.length; f < g; f++) p.normals.push(s[c].normals[f].clone()); } this.morphTargets.push(p); } let n = e.morphNormals; for (let c = 0, d = n.length; c < d; c++) { let p = {}; if (n[c].vertexNormals !== void 0) { p.vertexNormals = []; for (let f = 0, g = n[c].vertexNormals.length; f < g; f++) { let m = n[c].vertexNormals[f], v = {}; (v.a = m.a.clone()), (v.b = m.b.clone()), (v.c = m.c.clone()), p.vertexNormals.push(v); } } if (n[c].faceNormals !== void 0) { p.faceNormals = []; for (let f = 0, g = n[c].faceNormals.length; f < g; f++) p.faceNormals.push(n[c].faceNormals[f].clone()); } this.morphNormals.push(p); } let a = e.skinWeights; for (let c = 0, d = a.length; c < d; c++) this.skinWeights.push(a[c].clone()); let o = e.skinIndices; for (let c = 0, d = o.length; c < d; c++) this.skinIndices.push(o[c].clone()); let l = e.lineDistances; for (let c = 0, d = l.length; c < d; c++) this.lineDistances.push(l[c]); let h = e.boundingBox; h !== null && (this.boundingBox = h.clone()); let u = e.boundingSphere; return ( u !== null && (this.boundingSphere = u.clone()), (this.elementsNeedUpdate = e.elementsNeedUpdate), (this.verticesNeedUpdate = e.verticesNeedUpdate), (this.uvsNeedUpdate = e.uvsNeedUpdate), (this.normalsNeedUpdate = e.normalsNeedUpdate), (this.colorsNeedUpdate = e.colorsNeedUpdate), (this.lineDistancesNeedUpdate = e.lineDistancesNeedUpdate), (this.groupsNeedUpdate = e.groupsNeedUpdate), this ); } toBufferGeometry() { let e = new s6().fromGeometry(this), t = new Ve(), i = new Float32Array(e.vertices.length * 3); if ((t.setAttribute('position', Bc.call(new Xe(i, 3), e.vertices)), e.normals.length > 0)) { let r = new Float32Array(e.normals.length * 3); t.setAttribute('normal', Bc.call(new Xe(r, 3), e.normals)); } if (e.colors.length > 0) { let r = new Float32Array(e.colors.length * 3); t.setAttribute('color', Cx.call(new Xe(r, 3), e.colors)); } if (e.uvs.length > 0) { let r = new Float32Array(e.uvs.length * 2); t.setAttribute('uv', Tx.call(new Xe(r, 2), e.uvs)); } if (e.uvs2.length > 0) { let r = new Float32Array(e.uvs2.length * 2); t.setAttribute('uv2', Tx.call(new Xe(r, 2), e.uvs2)); } t.groups = e.groups; for (let r in e.morphTargets) { let s = [], n = e.morphTargets[r]; for (let a = 0, o = n.length; a < o; a++) { let l = n[a], h = new Ce(l.data.length * 3, 3); (h.name = l.name), s.push(Bc.call(h, l.data)); } t.morphAttributes[r] = s; } if (e.skinIndices.length > 0) { let r = new Ce(e.skinIndices.length * 4, 4); t.setAttribute('skinIndex', Px.call(r, e.skinIndices)); } if (e.skinWeights.length > 0) { let r = new Ce(e.skinWeights.length * 4, 4); t.setAttribute('skinWeight', Px.call(r, e.skinWeights)); } return ( e.boundingSphere !== null && (t.boundingSphere = e.boundingSphere.clone()), e.boundingBox !== null && (t.boundingBox = e.boundingBox.clone()), t ); } computeTangents() { console.error('THREE.Geometry: .computeTangents() has been removed.'); } computeLineDistances() { console.error('THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.'); } applyMatrix(e) { return console.warn('THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().'), this.applyMatrix4(e); } dispose() { this.dispatchEvent({ type: 'dispose' }); } static createBufferGeometryFromObject(e) { let t = new Ve(), i = e.geometry; if (e.isPoints || e.isLine) { let r = new Ce(i.vertices.length * 3, 3), s = new Ce(i.colors.length * 3, 3); if ( (t.setAttribute('position', Bc.call(r, i.vertices)), t.setAttribute('color', Cx.call(s, i.colors)), i.lineDistances && i.lineDistances.length === i.vertices.length) ) { let n = new Ce(i.lineDistances.length, 1); t.setAttribute('lineDistance', n6.call(n, i.lineDistances)); } i.boundingSphere !== null && (t.boundingSphere = i.boundingSphere.clone()), i.boundingBox !== null && (t.boundingBox = i.boundingBox.clone()); } else e.isMesh && (t = i.toBufferGeometry()); return t; } }; Qd.prototype.isGeometry = !0; var s6 = class { constructor() { (this.vertices = []), (this.normals = []), (this.colors = []), (this.uvs = []), (this.uvs2 = []), (this.groups = []), (this.morphTargets = {}), (this.skinWeights = []), (this.skinIndices = []), (this.boundingBox = null), (this.boundingSphere = null), (this.verticesNeedUpdate = !1), (this.normalsNeedUpdate = !1), (this.colorsNeedUpdate = !1), (this.uvsNeedUpdate = !1), (this.groupsNeedUpdate = !1); } computeGroups(e) { let t = [], i, r, s, n = e.faces; for (r = 0; r < n.length; r++) { let a = n[r]; a.materialIndex !== s && ((s = a.materialIndex), i !== void 0 && ((i.count = r * 3 - i.start), t.push(i)), (i = { start: r * 3, materialIndex: s })); } i !== void 0 && ((i.count = r * 3 - i.start), t.push(i)), (this.groups = t); } fromGeometry(e) { let t = e.faces, i = e.vertices, r = e.faceVertexUvs, s = r[0] && r[0].length > 0, n = r[1] && r[1].length > 0, a = e.morphTargets, o = a.length, l; if (o > 0) { l = []; for (let m = 0; m < o; m++) l[m] = { name: a[m].name, data: [] }; this.morphTargets.position = l; } let h = e.morphNormals, u = h.length, c; if (u > 0) { c = []; for (let m = 0; m < u; m++) c[m] = { name: h[m].name, data: [] }; this.morphTargets.normal = c; } let d = e.skinIndices, p = e.skinWeights, f = d.length === i.length, g = p.length === i.length; i.length > 0 && t.length === 0 && console.error('THREE.DirectGeometry: Faceless geometries are not supported.'); for (let m = 0; m < t.length; m++) { let v = t[m]; this.vertices.push(i[v.a], i[v.b], i[v.c]); let y = v.vertexNormals; if (y.length === 3) this.normals.push(y[0], y[1], y[2]); else { let x = v.normal; this.normals.push(x, x, x); } let b = v.vertexColors; if (b.length === 3) this.colors.push(b[0], b[1], b[2]); else { let x = v.color; this.colors.push(x, x, x); } if (s === !0) { let x = r[0][m]; x !== void 0 ? this.uvs.push(x[0], x[1], x[2]) : (console.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', m), this.uvs.push(new G(), new G(), new G())); } if (n === !0) { let x = r[1][m]; x !== void 0 ? this.uvs2.push(x[0], x[1], x[2]) : (console.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', m), this.uvs2.push(new G(), new G(), new G())); } for (let x = 0; x < o; x++) { let w = a[x].vertices; l[x].data.push(w[v.a], w[v.b], w[v.c]); } for (let x = 0; x < u; x++) { let w = h[x].vertexNormals[m]; c[x].data.push(w.a, w.b, w.c); } f && this.skinIndices.push(d[v.a], d[v.b], d[v.c]), g && this.skinWeights.push(p[v.a], p[v.b], p[v.c]); } return ( this.computeGroups(e), (this.verticesNeedUpdate = e.verticesNeedUpdate), (this.normalsNeedUpdate = e.normalsNeedUpdate), (this.colorsNeedUpdate = e.colorsNeedUpdate), (this.uvsNeedUpdate = e.uvsNeedUpdate), (this.groupsNeedUpdate = e.groupsNeedUpdate), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), this ); } }, Nm = class { constructor(e, t, i, r, s, n = 0) { (this.a = e), (this.b = t), (this.c = i), (this.normal = r && r.isVector3 ? r : new E()), (this.vertexNormals = Array.isArray(r) ? r : []), (this.color = s && s.isColor ? s : new Ge()), (this.vertexColors = Array.isArray(s) ? s : []), (this.materialIndex = n); } clone() { return new this.constructor().copy(this); } copy(e) { (this.a = e.a), (this.b = e.b), (this.c = e.c), this.normal.copy(e.normal), this.color.copy(e.color), (this.materialIndex = e.materialIndex); for (let t = 0, i = e.vertexNormals.length; t < i; t++) this.vertexNormals[t] = e.vertexNormals[t].clone(); for (let t = 0, i = e.vertexColors.length; t < i; t++) this.vertexColors[t] = e.vertexColors[t].clone(); return this; } }; function n6(e) { return this.array.set(e), this; } function Cx(e) { let t = this.array, i = 0; for (let r = 0, s = e.length; r < s; r++) { let n = e[r]; n === void 0 && (console.warn('THREE.BufferAttribute.copyColorsArray(): color is undefined', r), (n = new Ge())), (t[i++] = n.r), (t[i++] = n.g), (t[i++] = n.b); } return this; } function Tx(e) { let t = this.array, i = 0; for (let r = 0, s = e.length; r < s; r++) { let n = e[r]; n === void 0 && (console.warn('THREE.BufferAttribute.copyVector2sArray(): vector is undefined', r), (n = new G())), (t[i++] = n.x), (t[i++] = n.y); } return this; } function Bc(e) { let t = this.array, i = 0; for (let r = 0, s = e.length; r < s; r++) { let n = e[r]; n === void 0 && (console.warn('THREE.BufferAttribute.copyVector3sArray(): vector is undefined', r), (n = new E())), (t[i++] = n.x), (t[i++] = n.y), (t[i++] = n.z); } return this; } function Px(e) { let t = this.array, i = 0; for (let r = 0, s = e.length; r < s; r++) { let n = e[r]; n === void 0 && (console.warn('THREE.BufferAttribute.copyVector4sArray(): vector is undefined', r), (n = new $e())), (t[i++] = n.x), (t[i++] = n.y), (t[i++] = n.z), (t[i++] = n.w); } return this; } var a6 = ['a', 'b', 'c']; function o6(e, t) { switch (t) { case 'c': return e.c; case 'b': return e.b; case 'a': default: return e.a; } } function Jp(e, t, i) { let r = Math.min(e, t), s = Math.max(e, t), n = r + '_' + s; return i.get(n); } function $p(e, t, i, r, s, n) { let a = Math.min(e, t), o = Math.max(e, t), l = a + '_' + o, h; if (r.has(l)) h = r.get(l); else { let u = i[a], c = i[o]; (h = { a: u, b: c, newEdge: null, faces: [] }), r.set(l, h); } h.faces.push(s), n[e].edges.push(h), n[t].edges.push(h); } function l6(e, t, i, r) { let s, n, a; for (s = 0, n = e.length; s < n; s++) i[s] = { edges: [] }; for (s = 0, n = t.length; s < n; s++) (a = t[s]), $p(a.a, a.b, e, r, a, i), $p(a.b, a.c, e, r, a, i), $p(a.c, a.a, e, r, a, i); } function zc(e, t, i, r, s) { e.push(new Nm(t, i, r, void 0, void 0, s)); } function Ka(e, t) { return Math.abs(t - e) / 2 + Math.min(e, t); } function Nc(e, t, i, r) { e.push([t.clone(), i.clone(), r.clone()]); } var h6 = class { constructor(e = 1) { this.subdivisions = e; } modify(e) { e instanceof Ve ? (e = new Qd().fromBufferGeometry(e)) : (e = e.clone()), e.mergeVertices(); let t = this.subdivisions; for (; t-- > 0; ) this._smooth(e); return e.computeFaceNormals(), e.computeVertexNormals(), e; } _smooth(e) { let t = new E(), i, r, s, n, a, o = e.vertices, l = e.faces, h = e.faceVertexUvs[0], u = h !== void 0 && h.length > 0, c = [], d = new Map(); l6(o, l, c, d); let p = [], f, g, m, v, y, b, x; for (let se of Array.from(d.keys())) { for ( g = d.get(se), m = new E(), y = 3 / 8, b = 1 / 8, x = g.faces.length, x != 2 && ((y = 0.5), (b = 0), x != 1), m.addVectors(g.a, g.b).multiplyScalar(y), t.set(0, 0, 0), n = 0; n < x; n++ ) { for (v = g.faces[n], a = 0; a < 3 && ((f = o[o6(v, a6[a])]), !(f !== g.a && f !== g.b)); a++); f && t.add(f); } t.multiplyScalar(b), m.add(t), (g.newEdge = p.length), p.push(m); } let w, A, S, _, M, C, T, P = []; for (r = 0, s = o.length; r < s; r++) { for ( C = o[r], M = c[r].edges, i = M.length, i == 3 ? (w = 3 / 16) : i > 3 && (w = 3 / (8 * i)), A = 1 - i * Number(w), S = w, i <= 2 && (i == 2 ? ((A = 3 / 4), (S = 1 / 8)) : i == 1 || i == 0), T = C.clone().multiplyScalar(A), t.set(0, 0, 0), n = 0; n < i; n++ ) (_ = M[n]), (f = _.a !== C ? _.a : _.b), t.add(f); t.multiplyScalar(Number(S)), T.add(t), P.push(T); } let L = P.concat(p), D = P.length, k, W, X, z = [], j = [], U, N, B, H, Q = new G(), Y = new G(), F = new G(); for (r = 0, s = l.length; r < s; r++) (v = l[r]), (k = Number(Jp(v.a, v.b, d).newEdge) + D), (W = Number(Jp(v.b, v.c, d).newEdge) + D), (X = Number(Jp(v.c, v.a, d).newEdge) + D), zc(z, k, W, X, v.materialIndex), zc(z, v.a, k, X, v.materialIndex), zc(z, v.b, W, k, v.materialIndex), zc(z, v.c, X, W, v.materialIndex), u && ((U = h[r]), (N = U[0]), (B = U[1]), (H = U[2]), Q.set(Ka(N.x, B.x), Ka(N.y, B.y)), Y.set(Ka(B.x, H.x), Ka(B.y, H.y)), F.set(Ka(N.x, H.x), Ka(N.y, H.y)), Nc(j, Q, Y, F), Nc(j, N, Q, F), Nc(j, B, Y, Q), Nc(j, H, F, Y)); (e.vertices = L), (e.faces = z), u && (e.faceVertexUvs[0] = j); } }, $t = new E(), c6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = e.geometry ?? t?.geometry ?? new Ve().copy(new vs(100, 100, 100)), r; t === void 0 ? (i.computeBoundingBox(), i.boundingBox.getSize($t), (r = { width: $t.x, height: $t.y, depth: $t.z, subdivisions: 0 })) : (r = t.parameters); let s = { ...r, ...e.parameters }; return { parameters: { width: Math.abs(s.width), height: Math.abs(s.height), depth: Math.abs(s.depth), subdivisions: Math.abs(s.subdivisions) }, geometry: i }; } static build(e) { let { width: t, height: i, depth: r, subdivisions: s } = e.parameters, n = e.geometry ?? new Ve().copy(new vs(100, 100, 100)), a = n.userData.parameters; a === void 0 ? (n.computeBoundingBox(), n.boundingBox.getSize($t)) : $t.set(a.width, a.height, a.depth), (t !== $t.x || i !== $t.y || r !== $t.z) && n.scale($t.x === 0 ? 1 : t / $t.x, $t.y === 0 ? 1 : i / $t.y, $t.z === 0 ? 1 : r / $t.z); let o = n.originalGeometry; return ( s > 0 ? (o === void 0 || a?.subdivisions !== s) && (o === void 0 && (o = n), (n = new h6(s).modify(o).toBufferGeometry())) : (o !== void 0 && (n = o), (o = void 0), n.getAttribute('normal') === void 0 && n.computeVertexNormals()), o !== void 0 && Object.assign(n, { originalGeometry: o }), delete e.geometry, Object.assign(n, { userData: { ...e, type: 'NonParametricGeometry' } }) ); } static loadFromUrl(e, t, i) { new Fw(i).load(e, (r) => { let s = this.normalizeInputs({ geometry: r }); r.boundingBox.getSize($t); let n = 100 / $t.x; Object.assign(s.parameters, { width: 100, height: $t.y * n, depth: $t.z * n }), t(this.build(s)); }); } }, TA = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, depth: 0, spikes: 5, cornerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 3 }, e.parameters ); return { shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(), parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }) }; } static build(e) { let { width: t, height: i, spikes: r, cornerRadius: s, depth: n, extrudeBevelSize: a, extrudeBevelSegments: o } = e.parameters, l = e.shape, h = t * 0.5, u = i * 0.5, c = 0, d = 0, p = (2 * Math.PI) / r; for (let g = 0; g < r; g++) { let m = p * g, v = c + Math.sin(m) * h, y = d + Math.cos(m) * u; l.addPoint(l.createPoint(v, y)); } l.isClosed = !0; for (let g = 0, m = l.points.length; g < m; g++) l.points[g].roundness = s; (l.roundness = s), l.update(); let f = Ta.create({ shape: l, parameters: { roundness: s, depth: n, extrudeBevelSize: a, extrudeBevelSegments: o } }); return Object.assign(f, { userData: { ...e, type: 'PolygonGeometry' } }); } }, d6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, radialSegments: 4, heightSegments: 1, cornerRadius: 0, cornerSegments: 8, openEnded: !1 }, e.parameters ); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, height: i, depth: r, radialSegments: s, heightSegments: n, openEnded: a, cornerRadius: o, cornerSegments: l } = e.parameters, h = new p6(t * 0.5, i, s, n, a, o, l); return h.scale(1, 1, r / t), Object.assign(h, { userData: { ...e, type: 'PyramidGeometry' } }); } }; function Dl(e, t, i) { (i.x = e.x * t.x), (i.y = e.y), (i.z = e.x * t.y); } function ef(e, t, i, r, s, n) { let a = t.clone().sub(e), o = i.clone().sub(e), l = a.angleTo(o); if ((a.normalize(), o.normalize(), r === s)) { let h = a.add(o).normalize(); n.copy(e).addScaledVector(h, r / Math.sin(l / 2)); } else { let h = a.angleTo(o); n.copy(e), n.addScaledVector(a, s / Math.sin(h)), n.addScaledVector(o, r / Math.sin(h)); } } function u6(e, t, i) { let r = e.clone().sub(t), s = i.clone().sub(t); return r.projectOnVector(s), r.add(t); } var p6 = class extends Ve { constructor(e = 0.5, t = 1, i = 4, r = 1, s = !1, n = 0, a = 4) { super(), (i = Math.floor(Math.max(3, i))), (r = Math.floor(r)), (a = Math.floor(a)); let o = [], l = [], h = [], u = [], c = 0, d = t / 2, p = Math.PI / i, f = e * Math.cos(Math.PI / i), g = (2 * Math.PI) / i, m = ((i - 2) * Math.PI) / i, v = Math.PI - m, y = new E(0, -d, 0), b = new E(0, d, 0), x = new G(e, -d), w = new G(f, -d), A = new G(0, b.y).sub(w), S = new G(0, b.y).sub(x), _ = new G(A.y, -A.x).normalize(), M = new G(S.y, -S.x).normalize(), C = e * Math.cos(Math.PI / i) * Math.tan((Math.PI - A.angle()) / 2) - 1e-8; n = Math.min(n, C); let T; { let z = new E(_.x, _.y, 0), j = new E(Math.cos(g) * z.x, z.y, Math.sin(g) * z.x); T = z.angleTo(j); } let P = n / Math.tan((Math.PI - A.angle()) / 2), L = n / Math.tan((Math.PI - T) / 2), D = new E(); if (!s) { l.push(y.x, y.y, y.z), h.push(0, -1, 0), u.push(0, 0); let z = c++, j = [], U = x.clone(), N = P / Math.cos(Math.PI / i); U.x -= N; for (let B = 0; B < i; B++) { let H = (B / i) * Math.PI * 2 + p, Q = new G(Math.sin(H), Math.cos(H)); Dl(U, Q, D), l.push(D.x, D.y, D.z), h.push(0, -1, 0), u.push(0, 0), j.push(c++); } for (let B = 0; B < j.length; B++) o.push(j[B], z, j[(B + 1) % j.length]); } let k = []; { let z = new E(), j = new E(), U = new E(), N = new E(), B = new E(), H = new E(); for (let Q = 0; Q < i; Q++) { let Y = (Q / i) * Math.PI * 2 + p, F = ((Q + 0.5) / i) * Math.PI * 2 + p, se = ((Q + 1) / i) * Math.PI * 2 + p, V = new G(Math.sin(Y), Math.cos(Y)), ee = new G(Math.sin(F), Math.cos(F)), J = new G(Math.sin(se), Math.cos(se)); Dl(x, V, j), Dl(x, J, U), Dl(_, ee, z), ef(b, j, U, L, L, N), l.push(N.x, N.y, N.z), ef(j, b, U, L, P, B), l.push(B.x, B.y, B.z), ef(U, j, b, P, L, H), l.push(H.x, H.y, H.z), h.push(z.x, z.y, z.z), h.push(z.x, z.y, z.z), h.push(z.x, z.y, z.z), u.push(0, 0), u.push(0, 0), u.push(0, 0); let fe = c++, re = c++, oe = c++; if ((o.push(fe, re, oe), n > 0)) { { let Te = j.clone().add(U).multiplyScalar(0.5), xe = b.clone().sub(Te).normalize(), we = y.clone().sub(Te).normalize().add(xe).normalize().multiplyScalar(-1), Ie = H.clone().sub(B); W(Te, Ie, we, A.angle()); } let ue, ye; { let Te = new E(); Dl(M, J, Te); let xe = H.clone().add(N).multiplyScalar(0.5); xe = u6(xe, U, b); let we = H.clone().sub(N); [ue, ye] = W(xe, we, Te, T, N.y); } { let Te = ue, xe = Te.clone().setY(0).normalize(), we = new E(0, -1, 0), Ie = xe.clone().cross(we); X(Te, xe, we, Ie); } k.concat(ye); { let Te = A.angle(), xe = Math.PI - Te, we = b.clone(); we.y -= n / Math.sin(Te - Math.PI / 2); let Ie = new E(), He = []; for (let I = 0; I < a; I++) { let O = [], ie = Math.PI / 2 - (xe * I) / a, pe = Math.cos(ie), me = Math.sin(ie), be = F; for (let We = 0; We <= I; We++) { let Me = Math.cos(be), ce = Math.sin(be); (z.x = pe * ce), (z.y = me), (z.z = pe * Me), Ie.copy(we).addScaledVector(z, n), l.push(Ie.x, Ie.y, Ie.z), h.push(z.x, z.y, z.z), u.push(0, 0), O.push(c++), (be += (Math.PI * 2) / I / i); } He.push(O); } ye.reverse(), He.push(ye); let dt = He.length - 1; for (let I = 0; I < dt; I++) { let O = He[I], ie = He[I + 1], pe = O.length - 1; o.push(ie[1], O[0], ie[0]); for (let me = 1; me <= pe; me++) o.push(O[me], O[me - 1], ie[me]), o.push(ie[me + 1], O[me], ie[me]); } } } } } this.setIndex(o), this.setAttribute('position', new Ce(l, 3)), this.setAttribute('normal', new Ce(h, 3)), this.setAttribute('uv', new Ce(u, 2)); function W(z, j, U, N, B) { let H = -N / 2, Q = (Math.PI - N) / 2, Y = j.clone().normalize().cross(U); z.addScaledVector(U, -n / Math.sin(Q)); let F = new E(), se = new E(), V = 1, ee = c, J = []; for (let fe = 0; fe <= a; fe++) { let re = H + (fe / a) * N; se.set(0, 0, 0), se.addScaledVector(Y, Math.sin(re)), se.addScaledVector(U, Math.cos(re)); for (let oe = 0; oe <= V; oe++) { let ue = oe / V - 0.5; if ((F.copy(z), F.addScaledVector(j, ue), F.addScaledVector(se, n), B != null)) { let ye = Math.max(0, F.y - B); F.addScaledVector(j, -ye / j.y); } l.push(F.x, F.y, F.z), h.push(se.x, se.y, se.z), u.push(0, 0), oe === 0 && J.push(c), c++; } } for (let fe = 0; fe < a; fe++) for (let re = 0; re < V; re++) { let oe = ee + re + (V + 1) * fe, ue = oe + (V + 1), ye = ue + 1, Te = oe + 1; o.push(oe, ue, Te), o.push(ue, ye, Te); } return [z.clone().addScaledVector(j, 0.5), J]; } function X(z, j, U, N) { let B = Math.PI / 2, H = S.angle() - B, Q = [], Y = new E(), F = new E(); for (let V = 0; V <= a; V++) { let ee = [], J = V / a; for (let fe = 0; fe <= V; fe++) { let re = ((V ? fe / V : 0) - 0.5) * v, oe = Math.cos(re), ue = Math.sin(re), ye = Math.atan(Math.tan(H) * oe), Te = (B + ye) * J, xe = Math.cos(Te), we = Math.sin(Te); Y.set(0, 0, 0), Y.addScaledVector(j, we * oe), Y.addScaledVector(U, xe), Y.addScaledVector(N, we * ue), F.copy(z).addScaledVector(Y, n), l.push(F.x, F.y, F.z), h.push(Y.x, Y.y, Y.z), u.push(0, 0), ee.push(c++); } Q.push(ee); } let se = Q.length - 1; for (let V = 0; V < se; V++) { let ee = Q[V], J = Q[V + 1], fe = ee.length - 1; o.push(ee[0], J[1], J[0]); for (let re = 1; re <= fe; re++) o.push(ee[re - 1], ee[re], J[re]), o.push(ee[re], J[re + 1], J[re]); } } } }, PA = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, depth: 0, cornerRadius: [0, 0, 0, 0], cornerType: 1, extrudeBevelSize: 0, extrudeBevelSegments: 1 }, e.parameters ), r = Object.assign(t?.ui ?? { enabledIndieCorners: !1 }, e.ui); return { shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(), parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }), ui: r }; } static build(e) { let t = e.shape, { width: i, height: r, cornerRadius: s, cornerType: n, depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } = e.parameters, h = { x: i * 0.5, y: r * 0.5 }, u = { x: -h.x, y: -h.y }, c = { x: h.x, y: h.y }; function d(x, w, A) { return w > i && A > r ? Math.min((x * i) / w, (x * r) / A) : w > i ? (x * i) / w : A > r ? (x * r) / A : x; } let p = []; (p[0] = s[0] === 0 ? 0 : d(s[0], s[0] + s[3], s[0] + s[1])), (p[1] = s[1] === 0 ? 0 : d(s[1], s[1] + s[2], s[1] + s[0])), (p[2] = s[2] === 0 ? 0 : d(s[2], s[2] + s[1], s[2] + s[3])), (p[3] = s[3] === 0 ? 0 : d(s[3], s[3] + s[0], s[3] + s[2])); let f = u.x, g = c.x, m = c.y, v = u.y; t.addPoint(t.createPoint(f, m)), t.addPoint(t.createPoint(g, m)), t.addPoint(t.createPoint(g, v)), t.addPoint(t.createPoint(f, v)), (t.isClosed = !0); let y = !0; for (let x = 0, w = t.points.length; x < w; x++) (t.points[x].roundness = p[x]), x > 0 && p[x] !== p[x - 1] && (y = !1); y && (t.roundness = p[0]), (t.useCubicForRoundedCorners = n !== 1), t.update(); let b = Ta.create({ shape: t, parameters: { depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } }); return Object.assign(b, { userData: { ...e, type: 'RectangleGeometry' } }); } }, f6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, widthSegments: 64, heightSegments: 64, phiStart: 0, phiLength: 2 * Math.PI, thetaStart: 0, thetaLength: Math.PI }, e.parameters ); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t = 100, height: i = t, depth: r = t, widthSegments: s = 64, heightSegments: n = 64, phiStart: a, phiLength: o, thetaStart: l, thetaLength: h } = e.parameters, u = new yg(0.5 * t, s, n, a, o, l, h); return u.scale(1, i / t, r / t), Object.assign(u, { userData: { ...e, type: 'SphereGeometry' } }); } }, m6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, depth: 0, widthSegments: 8, heightSegments: 8 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: 0 }) }; } static build(e) { let { width: t = 100, height: i = t, widthSegments: r = 8, heightSegments: s = 8 } = e.parameters, n = new ou(t, i, r, s); return n.scale(1, 1, 1), Object.assign(n, { userData: { ...e, type: 'PlaneGeometry' } }); } }, g6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, angle: 90, cornerRadius: 24, cornerSegments: 8 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width) }) }; } static build(e) { let { width: t, height: i, depth: r, angle: s, cornerRadius: n, cornerSegments: a } = e.parameters, o = new v6(t, i, r, s, n, a); return Object.assign(o, { userData: { ...e, type: 'BackdropGeometry' } }); } }, v6 = class extends Ve { constructor(e = 1, t = 1, i = 1, r = 90, s = 10, n = 24) { super(), (this.type = 'BackdropGeometry'); let a = [], o = [], l = [], h = 0.001; s == 0 && (n = 1), (n = Math.max(1, Math.floor(n))), (s = Math.min(s, 100)), (r = Math.min(180 - h, r)), (r *= Math.PI / 180); let u = [], c = Math.PI / 2, d = (se = 0, V = 0, ee = 0) => new E(se, V, ee), p = d(), f = d(), [g, m, v] = [t / 2, e / 2, i / 2], y = -m, b = +m, [x, w, A] = [d(y, -g, +v), d(y, -g, -v), d(y, +g, -v)], S = (se, V = !1) => Math.sin(se - Math.PI / (1 + +V)), _ = (se, V = !1) => Math.cos(se - Math.PI / (1 + +V)); A.y = Math.sin(r) * t - g; let M = Math.cos(r) * t - v, C = x.z - h; r <= c ? ((A.z = Math.min(M, C)), A.z == C && (A.y -= (M - C) / Math.tan(c - r))) : (w.z = Math.min(w.z - M - v, x.z - h)), p.subVectors(x, w), f.subVectors(A, w); let T = (Math.min(p.length(), f.length()) * s) / 100, P = T * Math.tan(r / 2), L = T / Math.cos(r / 2), D = p.clone().normalize().add(f.normalize()).setLength(L).add(w); p.set(0, S(r, !0), _(r, !0)), u.push([A, p.clone()]); let k = (Math.PI - r) / n; for (let se = 0; se <= n; se++) { let V = c + r + se * k; p.set(0, Math.sin(V) * P, Math.cos(V) * P), p.add(D), f.set(0, S(V), _(V)), u.push([p.clone(), f.clone()]); } u.push([x, d(0, 1, 0)]); let W = Math.sin(k / 2) * P * 2, X = u.length - 1, z = u[0][0].distanceTo(u[1][0]), j = u[X - 1][0].distanceTo(u[X][0]), U = z + W * n + j; u[0].push(1); for (let se = 0; se <= n; se++) u[se + 1].push(1 - (z + se * W) / U); u[X].push(0); let [N, B, H] = u[0], Q, Y, F; for (let se = 1; se < u.length; se++) ([Q, Y, F] = u[se]), a.push(y, N.y, N.z, y, Q.y, Q.z, b, N.y, N.z, b, N.y, N.z, y, Q.y, Q.z, b, Q.y, Q.z), o.push(0, B.y, B.z, 0, Y.y, Y.z, 0, B.y, B.z, 0, B.y, B.z, 0, Y.y, Y.z, 0, Y.y, Y.z), l.push(0, H, 0, F, 1, H, 1, H, 0, F, 1, F), ([N, B, H] = [Q, Y, F]); this.setAttribute('position', new Ce(a, 3)), this.setAttribute('normal', new Ce(o, 3)), this.setAttribute('uv', new Ce(l, 2)); } }, DA = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, depth: 0, innerRadiusPercent: 38.19, spikes: 5, cornerRadius: 0, angle: 360, extrudeBevelSize: 0, extrudeBevelSegments: 1 }, e.parameters ); return { shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(), parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }) }; } static build(e) { let { width: t, height: i, innerRadiusPercent: r, spikes: s, cornerRadius: n, angle: a, depth: o, extrudeBevelSize: l, extrudeBevelSegments: h } = e.parameters, u = e.shape, c = t * 0.5, d = i * 0.5, p = 0, f = 0, g = (a * Math.PI) / 360 / s, m = (Math.PI / 2) * 3 * -1, v = (c * r) / 100, y = (d * r) / 100; if (s === 3 && r === 50) { g = (2 * Math.PI) / s; for (let x = 0; x < s; x++) { let w = g * x, A = p + Math.sin(w) * c, S = f + Math.cos(w) * d; u.addPoint(u.createPoint(A, S)); } } else for (let x = 0; x < s; x++) { let w = p + Math.cos(m) * c, A = f + Math.sin(m) * d; u.addPoint(u.createPoint(w, A)), (m += g), (w = p + Math.cos(m) * v), (A = f + Math.sin(m) * y), x <= s, u.addPoint(u.createPoint(w, A)), (m += g); } u.isClosed = !0; for (let x = 0, w = u.points.length; x < w; x++) u.points[x].roundness = n; (u.roundness = n), u.update(); let b = Ta.create({ shape: u, parameters: { roundness: n, depth: o, extrudeBevelSize: l, extrudeBevelSegments: h } }); return Object.assign(b, { userData: { ...e, type: 'StarGeometry' } }); } }, y6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, depth: 0 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }) }; } static build(e) { let { width: t, height: i } = e.parameters, r = new ou(t, i); return Object.assign(r, { userData: { ...e, type: 'TextFrameGeometry' } }); } }, x6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, radialSegments: 32, tubularSegments: 64, arc: Math.PI * 2, cornerRadius: 30, cornerSegments: 8 }, e.parameters ), r = Math.abs(i.width), s = Math.abs(i.height ?? i.width), n = Math.round(Math.abs(i.depth ?? i.width * 0.25)); return { parameters: Object.assign(i, { width: r, height: s, depth: n }) }; } static build(e) { let { width: t, height: i, depth: r, radialSegments: s, tubularSegments: n, arc: a, cornerRadius: o, cornerSegments: l } = e.parameters, h = b6(t, i, r, t * 0.5, a, n, 0, 0, s, o, l); return h.scale(1, i / t, 1), Object.assign(h, { userData: { ...e, type: 'TorusGeometry' } }); } }; function b6(e, t, i, r, s, n, a, o, l, h, u) { return ([t, i] = [i, t]), (a = t / 2), (s /= 2 * Math.PI), s == 1 && (h = 0), new nv(!0, e, t, i, r, s, n, a, o, l, h, u); } var w6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign({}, t?.parameters ?? { width: 100, tubularSegments: 64, radialSegments: 32, p: 2, q: 3 }, e.parameters); return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? i.width), tube: i.tube ?? i.width * 0.125 }) }; } static build(e) { let { width: t, tube: i, tubularSegments: r, radialSegments: s, p: n, q: a } = e.parameters, o = t * 0.5; o !== i && (o -= i); let l = new zw(o, i, r, s, n, a); return Object.assign(l, { userData: { ...e, type: 'TorusKnotGeometry' } }); } }, _6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, depth: 0, spikes: 5, cornerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1, isRect: !1 }, e.parameters ); return { shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(), parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width * (i.isRect ? 1 : Math.sqrt(3) / 2)), depth: Math.abs(i.depth ?? 0) }) }; } static build(e) { let { width: t = 100, height: i, cornerRadius: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a, isRect: o } = e.parameters, l = e.shape, h = t * 0.5, u = i * 0.5; o ? (l.addPoint(l.createPoint(-h, u)), l.addPoint(l.createPoint(h, -u)), l.addPoint(l.createPoint(-h, -u))) : (l.addPoint(l.createPoint(0, u)), l.addPoint(l.createPoint(h, -u)), l.addPoint(l.createPoint(-h, -u))), (l.isClosed = !0); for (let d = 0, p = l.points.length; d < p; d++) l.points[d].roundness = r; (l.roundness = r), l.update(); let c = Ta.create({ shape: l, parameters: { roundness: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a } }); return Object.assign(c, { userData: { ...e, type: 'TriangleGeometry' } }); } }; function A6(e, t) { let i = 2 * Math.PI; return ((e % i) + i) % i === ((t % i) + i) % i; } function S6(e, t, i) { let r = [new E(), new E(), new E()], s = [new E(), new E(), new E()]; return ( e.extractBasis(r[0], r[1], r[2]), t.extractBasis(s[0], s[1], s[2]), r.forEach((n, a) => { let o = s[a], l = it.lerp(n.length(), o.length(), i); n.lerp(o, i).setLength(l); }), new ve().makeBasis(r[0], r[1], r[2]) ); } var M6 = class { static create(e) { return this.build(this.normalizeInputs(e)); } static normalizeInputs(e, t) { let i = Object.assign( {}, t?.parameters ?? { width: 100, height: 100, depth: 1, subdivisions: 12, roundness: 0, extrudeBevelSize: 0, extrudeBevelSegments: 3 }, e.parameters ), r = Math.abs(i.width), s = Math.abs(i.height ?? i.width), n = Math.abs(i.depth ?? 0), a = t?.shapeData ?? sv.create({ parameters: J_ }).userData.shape; return { path: e.path ?? zd.defaultData(), parameters: Object.assign(i, { width: r, height: s, depth: n, extrusion: { ...$_, ...i.extrusion } }), shapeData: a }; } static build(e) { if (e.path.points.length >= 2) { let t = new E6(e); return Object.assign(t, { userData: { ...e, type: 'PathGeometry' } }); } else return Object.assign(new Ve(), { userData: { ...e, type: 'PathGeometry' } }); } }, E6 = class extends Ve { constructor(e) { super(), (this.type = 'PathExtrusionGeometry'), (this.inputs = e), this.build(); } _isGeometryClosed() { return this.inputs.path.isClosed && this.inputs.parameters.extrusion.depth === 1; } _isOpenEnded() { let e = this.inputs.parameters.extrusion; return !(this.inputs.path.isClosed && e.depth === 1) || !A6(e.twist, 0) || e.startScale !== e.endScale; } build() { let e = this._extractPathPoints(); if (e.length < 2) return; let t = this._computeBasisMatrices(e), { depth: i, offset: r } = this.inputs.parameters.extrusion, s = this.inputs.path.isClosed ? e.length : e.length - 1, n = Math.floor(r * s), a = this.inputs.path.isClosed ? Math.ceil((i + r) * s) : Math.ceil(Math.min(1, i + r) * s), o = Math.min(Math.max(2, a - n + 1), s + 2), l = [], h = []; for (let C = 0; C < o; C++) { let T = this.inputs.path.isClosed ? (C + n) % e.length : Math.min(C + n, e.length - 1); l.push(e[T].clone()), h.push(t[T].clone()); } let u = (C, T, P) => { (l[C] = l[C].clone().lerp(l[T], P)), (h[C] = S6(h[C], h[T], P)); }, c = 0, d = (r * s) % 1; (!this.inputs.path.isClosed || i <= 1) && (d || r === 0) && ((c = d), u(0, 1, c)); let p = 0, f = ((r + i) * s) % 1; if ( (((this.inputs.path.isClosed && i <= 1) || (!this.inputs.path.isClosed && r + i < 1)) && f && ((p = f), u(l.length - 1, l.length - 2, 1 - p)), i === 0) ) { let C = l.length - 1; l[C].copy(l[0]), h[C].copy(h[0]); } this._applyPathModifiers(h, c, p); let { regions: g, infos: m, vertices: v } = this._computeShapePoints(5), y = 0, b = 0; m.sort((C, T) => C.start - T.start), m.forEach((C) => { (C.verticesStart = y), (C.verticesCount = C.continuous.reduce((T, P, L) => T + (L === 0 || !P ? 2 : 1), 0)), (b += C.verticesCount), (y = b); }); let x = b * o, w, A = 0; if (this._isOpenEnded()) { try { w = _n({ windingRule: yt.ODD, elementType: Zt.POLYGONS, polySize: 3, vertexSize: 2, strict: !0, contours: g }); } catch { w = xA; } A = w.vertexCount; } let S = x + 2 * A, _ = { positions: new Float32Array(S * 3), normals: new Float32Array(S * 3), uvs: new Float32Array(S * 2) }, M = []; m.forEach((C) => { this._extrudeRegion(C, v, h, l, _, M, this._isGeometryClosed() && !this._isOpenEnded()); }), w && (this._closeEnd(w, x, M, _, h[0], l[0], !1), this._closeEnd(w, x + A, M, _, h[h.length - 1], l[l.length - 1], !0)), this.setAttribute('position', new Xe(_.positions, 3)), this.setAttribute('normal', new Xe(_.normals, 3)), this.setAttribute('uv', new Xe(_.uvs, 2)), this.setIndex(M); } _extractPathPoints() { let e = cA(this.inputs.path).getPoints(this.inputs.path.subdivisions); if (e.length < 2) return []; let t = [e[0]]; return ( e.forEach((i) => { t[t.length - 1].distanceToSquared(i) > 0.001 && t.push(i); }), this.inputs.path.isClosed && t[t.length - 1].distanceTo(t[0]) < 0.001 && t.pop(), t ); } _computeBasisMatrices(e) { let t = [], i = e.length, r = this.inputs.path.isClosed, s = new E(), n = new E(), a = new E(), o = new E(), l = new E(0, 1, 0); for (let f = 0; f < i; f++) { let g = e[f], m; f === 0 ? (m = r ? e[e.length - 2] : g.clone().multiplyScalar(2).sub(e[1])) : (m = e[f - 1]); let v; f === i - 1 ? (v = r ? e[1] : g .clone() .multiplyScalar(2) .sub(e[f - 1])) : (v = e[f + 1]); let y = g.clone().sub(m).normalize(), b = v.clone().sub(g).normalize(), x = y.clone().add(b).normalize(); a.copy(x), f === 0 && (x.equals(l) || x.clone().negate().equals(l)) && l.set(0, 0, 1); let w = l.clone().cross(x).normalize(), A = x.clone().cross(w).normalize(); l.copy(A), o.copy(w), f === 0 && (s.copy(A), n.copy(x)); let S = new ve().makeBasis(w, A, x); t.push(S); } let h = r ? n : a, u = r ? s : new E(0, 1, 0), c = h.clone().cross(o).normalize(), d = Math.acos(u.dot(c)); if (isNaN(d)) return t; let p = u.clone().cross(c); h.dot(p) > 0 && (d *= -1); for (let f = 1; f < t.length; f++) { let g = new ve().makeRotationZ((d * f) / t.length); t[f].multiply(g); } return t; } _applyPathModifiers(e, t, i) { let r = e.length, { angle: s, twist: n, startScale: a, endScale: o } = this.inputs.parameters.extrusion, l = new ve(), h = new ve(); return ( e.forEach((u, c) => { let d = c === 0 ? 0 : c === r - 1 ? 1 : (c - t) / (r - (i === 0 ? 0 : 1) - (t + (1 - i))); l.makeRotationZ(it.lerp(s, s + n, d)); let p = it.lerp(a, o, d); h.makeScale(p, p, p), u.multiply(l).multiply(h); }), e ); } _computeShapePoints(e = 12, t = yt.ODD) { let i = this.inputs.shapeData, r = i.extractShapePointsToFlatArray([], e), s = i.shapeHoles.map((p) => { let f = p.extractShapePointsToFlatArray([], e), g = []; for (let m = f.length - 1; m >= 1; m -= 2) { let v = f[m - 1], y = f[m - 0]; g.push(v, y); } return g; }), n; try { n = _n({ windingRule: t, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [r] }); } catch { n = rv; } let a; try { a = _n({ windingRule: yt.ODD, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [...s] }); } catch { a = yA; } if (!n) throw new Error('error generating geometry'); let o = n.elementCount; if (a) { n.elementCount += a.elementCount; for (let p = 0; p < a.elements.length; p++) { let f = a.elements[p], g = p % 2 === 0 ? n.vertexCount : 0; n.elements.push(f + g); } for (let p = 0; p < a.vertexIndices.length; p++) { let f = a.vertexIndices[p], g = n.vertexCount; n.vertexIndices.push(f + g); } for (let p = 0; p < a.vertices.length; p++) { let f = a.vertices[p]; n.vertices.push(f); } } let l = 1 / 0, h = -1 / 0, u = 1 / 0, c = -1 / 0; for (let p = 0, f = n.vertexCount; p < f; p++) { let g = p * 2, m = n.vertices[g + 0], v = n.vertices[g + 1]; m < l && (l = m), m > h && (h = m), v < u && (u = v), v > c && (c = v); } let d = []; for (let p = n.elementCount - 1; p >= 0; p--) { let f = p >= o, g = p * 2, m = n.elements[g + 0], v = n.elements[g + 1], y = m + v, b = { start: m, count: v, normals: [], isHole: f, continuous: [], verticesStart: 0, verticesCount: 0 }; d.push(b); let x = m, w = y - 1, A = m + 1, S = i.roundedCurves.length; do { let _ = x - m, M = n.vertices[w * 2 + 0], C = n.vertices[w * 2 + 1], T = n.vertices[x * 2 + 0], P = n.vertices[x * 2 + 1], L = n.vertices[A * 2 + 0], D = n.vertices[A * 2 + 1], k = T - M, W = P - C, X = Math.sqrt(k * k + W * W); (k /= X), (W /= X); let z = T - L, j = P - D, U = Math.sqrt(z * z + j * j); (z /= U), (j /= U), (b.normals[_ * 2 + 0] = -j), (b.normals[_ * 2 + 1] = z); let N = n.vertexIndices[x]; if (Array.isArray(N)) b.continuous[_] = !1; else { let [B, H] = i.getCurveIndexFromVertexId(N - 1, !0); if (H > 0 && H < 1) b.continuous[_] = !0; else { let Q = H === 1 ? B + 1 : B - 1; Q = (Q + S) % S; let Y = H === 1 ? 0 : 1, F = i.roundedCurves[B].getTangent(H), se = i.roundedCurves[Q].getTangent(Y); b.continuous[_] = F.dot(se) > 0.95; } } f && ((b.normals[_ * 2 + 0] *= -1), (b.normals[_ * 2 + 1] *= -1)), ([w, x, A] = [x, A, A + 1]), A >= y && (A -= v); } while (A !== m + 1); } return { regions: [r, ...s], infos: d, vertices: n.vertices }; } _insertVertex(e, t, i, r, s) { let n = t * 2, a = t * 3; (e.positions[a + 0] = i.x), (e.positions[a + 1] = i.y), (e.positions[a + 2] = i.z), (e.normals[a + 0] = r.x), (e.normals[a + 1] = r.y), (e.normals[a + 2] = r.z), (e.uvs[n + 0] = s.x), (e.uvs[n + 1] = s.y); } _extrudeRegion(e, t, i, r, s, n, a) { let o = new E(), l = new E(), h = new E(), u = new E(), c = new G(); i.forEach((p, f) => { let g = r[f], m = e.verticesStart * i.length + e.verticesCount * f; for (let v = 0; v < e.count; v++) { let y = (e.start + v) * 2; if ((o.set(t[y + 0], t[y + 1], 0), h.copy(o).applyMatrix4(p).add(g), e.continuous[v])) u.set(e.normals[v * 2 + 0], e.normals[v * 2 + 1], 0); else { let b = v == 0 ? (e.start + e.count - 1) * 2 : y - 2; l.set(t[b + 0], t[b + 1], 0), u.copy(o).sub(l), u.set(-u.y, u.x, 0), e.isHole || u.negate(); } if ( (u.applyMatrix4(p).normalize(), c.set(v === 0 ? 1 : v / e.count, f / (i.length - 1)), this._insertVertex(s, m, h, u, c), m++, !e.continuous[v] || v === 0) ) { if (v === 0) u.set(e.normals[v * 2 + 0], e.normals[v * 2 + 1], 0), c.set(0, f / (i.length - 1)); else { let b = v === e.count - 1 ? e.start * 2 : y + 2; l.set(t[b + 0], t[b + 1], 0), u.copy(l).sub(o), u.set(-u.y, u.x, 0), e.isHole || u.negate(); } u.applyMatrix4(p).normalize(), this._insertVertex(s, m, h, u, c), m++; } } }); let d = i.length - 1; for (let p = 0; p < d; p++) { let f = e.verticesStart * i.length + e.verticesCount * p, g = e.verticesStart * i.length + e.verticesCount * (p + 1), m = 0; for (let v = 0; v < e.count; v++) { (!e.continuous[v] || v === 0) && m++; let y = v === e.count - 1 ? 0 : m + 1, b = f + m, x = f + y, w = g + y, A = g + m; e.isHole ? n.push(b, w, x, b, A, w) : n.push(b, x, w, b, w, A), m++; } } } _closeEnd(e, t, i, r, s, n, a) { let o = e.vertexCount, l = new E(0, 0, a ? -1 : 1).applyMatrix4(s), h = new E(), u = new G(); for (let d = 0; d < o; d++) { let p = 2 * d; h .set(e.vertices[p + 0], e.vertices[p + 1], 0) .applyMatrix4(s) .add(n), this._insertVertex(r, t + d, h, l, u); } let c = e.elements; for (let d = 0; d < e.elementCount; d++) { let p = 3 * d, f = c[p + 0] + t, g = c[p + (a ? 1 : 2)] + t, m = c[p + (a ? 2 : 1)] + t; i.push(f, g, m); } } }; function C6() { let e = new Ve(); return e.setAttribute('position', new Xe(new Float32Array([]), 3)), e.setIndex(new Xe(new Uint16Array([]), 1)), e; } var T6 = 12, P6 = 1, LA = class extends Ve { constructor(e, t) { super(), (this.charWidths = []), (this.charCoords = []), (this.wrappedText = []), (this.isLowResolution = !1), (this.vectorShapes = []), (this.userData = { parameters: e, type: 'TextGeometry' }); let i = t.getFont(e.font); i?.isLoaded ? ((this.font = i), this.update(e)) : this.updateFont(e.font, t).then(() => { this.update(e), t?.requestRender(); }); } async updateFont(e, t) { let i = t.getFont(e); i && ((this.font = i), await i.loadingPromise); } update(e) { let t = this.font; if (((this.userData = { parameters: e, type: 'TextGeometry' }), !t?.isLoaded)) { console.warn('Cannot update text because its font is not loaded'); return; } let { width: i, height: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a, text: o, textTransform: l } = e, h = l === 2 ? o.toUpperCase() : l === 3 ? o.toLowerCase() : o, u = D6(e, t, h), { shapes: c, charWidths: d, charCoords: p } = t.generateShapes(u, e), f = i * 0.5, g = r * 0.5, m = c.map((b) => new Nt().fromShape(b)); this.vectorShapes = m; let v = m.map((b) => Ta.create({ shape: b, parameters: { depth: s, extrudeBevelSegments: a, extrudeBevelSize: n, windingRule: s <= 0 ? yt.NONZERO : yt.ODD, subdivisions: this.isLowResolution && s > 0 ? P6 : T6 } }) ), y = v.length ? go(v) : C6(); y.translate(-f, g, 0), this.dispose(), (this.wrappedText = u), (this.charCoords = p), (this.charWidths = d), this.deleteAttribute('extrudeNormal'), Object.entries(y.attributes).forEach(([b, x]) => { this.setAttribute(b, x); }), this.setIndex(y.index), this.computeBoundingSphere(); } clone() { let e = Aa(new Ve(), LA.prototype); return e.copy(this), console.log('CloneGeometry', this, e), e; } copy(e) { return ( Object.entries(e.attributes).forEach(([t, i]) => { this.setAttribute(t, i); }), this.setIndex(e.index), (this.userData = { parameters: { ...e.userData.parameters }, type: 'TextGeometry' }), this ); } async setText(e) { this.font && (await this.font.loadingPromise), await this.update({ ...this.userData.parameters, text: e }); } get text() { return this.userData.parameters.text ?? ''; } }; function D6(e, t, i) { i = i ?? e.text; let r = [''], s = ''; for (let n of i) (s += n), n === ' ' || n === ` ` ? ((r[r.length - 1] += s), (s = ''), n === ` ` && r.push('')) : t.getTextWidth(r[r.length - 1] + s, e) > e.width && (r[r.length - 1].length && r.push(''), t.getTextWidth(r[r.length - 1] + s, e) > e.width && (s.length === 1 ? ((r[r.length - 1] += s), (s = '')) : ((r[r.length - 1] += s.slice(0, -1)), (s = s[s.length - 1]), r.push('')))); return (r[r.length - 1] += s), r; } var OA, av = new Promise((e) => { OA = e; }), Dx = !1; async function L6() { if (Dx) return; let e = './assets/3d', [t, i] = await Promise.all([import('./process.js'), fetch(`${e}/process.wasm`).then((n) => n.arrayBuffer())]), r = t.default, s = await r({ wasmBinary: i }); OA(s), (Dx = !0); } function Zd(e, t, i) { let r = { parameters: e, type: e.type }; if (e.type === 'PathGeometry') r.path = e.path; else if (e.type === 'VectorGeometry') { let n = Nt.createFromState(e.shape, e.width, e.height); r.shape = n; } else if (e.type === 'NonParametricGeometry') e.data.groups && e.data.groups.forEach((n) => (n.materialIndex = Math.max(n.materialIndex ?? 0, 0))), (r.geometry = new Fw().parse(e)); else { if (e.type === 'SubdivGeometry') return new Oi(e, i); if (e.type === 'TextGeometry') return new LA(e, t); } let s; try { s = zx(r); } catch (n) { console.error(n); } if (!s) { let n = Nt.createFromState(Bd.defaultData(), 100, 100); (r.shape = n), (s = zx(r)); } return s; } var O6 = new ve(); function Um(e, t, i, r) { let s = e.position.array, n = e.normal.array, a = O6.makeScale(t, i, r).invert().elements, o, l, h; for (var u = 0, c = s.length; u < c; u += 3) (s[u] *= t), (s[u + 1] *= i), (s[u + 2] *= r), (o = n[u]), (l = n[u + 1]), (h = n[u + 2]), (n[u] = a[0] * o + a[4] * l + a[8] * h), (n[u + 1] = a[1] * o + a[5] * l + a[9] * h), (n[u + 2] = a[2] * o + a[6] * l + a[10] * h); (e.position.needsUpdate = !0), (e.normal.needsUpdate = !0); } var Uc = new Kt(), Ja = new E(), Ue; av.then((e) => { Ue = e; }); var Lx = new Float32Array([10, 10, 0, -10, 10, 0, -10, -10, 0, 10, -10, 0]), Ox = new Uint32Array([0, 1, 2, 3]), Ix = new Uint8Array([4]), Oi = class extends Ve { constructor(e, t) { super(), (this.data = e), (this.flatShading = t), (this.subdivPointer = 0), this.rebuild(), this.freeSubdivPointer(); } mutateDirectlyScaleBaked(e, t) { this.freeSubdivPointer(); let i = this.data.scaleBaked, r = ma.div(t, i); this.subdividedGeometry && Um(this.subdividedGeometry.attributes, ...r), this.originalGeometry && Um(this.originalGeometry.attributes, ...r), (this.data = e); let s = this.userData.parameters; (this.userData.parameters = { width: s.width * r[0], height: s.height * r[1], depth: s.depth * r[2] }), this.originalGeometry.boundingSphere.center.multiply(Ja.fromArray(r)); let n = Ja.set(s.width, s.height, s.depth).length(); this.originalGeometry.boundingSphere.radius = n / 2; } ensureSubdivPointer() { return this.subdivPointer === 0 && this.rebuild(), this.subdivPointer; } rebuild() { let e, t, i; try { ({ originalGeometry: e, subdividedGeometry: t, subdivPointer: i } = Oi.build(this.data, void 0, !this.flatShading, void 0)); } catch { (e = new vs(100, 100, 100)), (i = 0); } (this.subdivPointer = i), (this.originalGeometry = e), (this.subdividedGeometry = t ?? void 0); let r = this.subdividedGeometry ?? this.originalGeometry; Object.assign(this, r), this.calcBoundingBox(); } freeSubdivPointer() { this.subdivPointer && (Oi.freeSubdivPointer(this.subdivPointer), (this.subdivPointer = 0)); } dispose() { super.dispose(), this.freeSubdivPointer(); } calcBoundingBox() { let e = this.originalGeometry; e.boundingSphere === null && ((e.boundingSphere = new Mr()), this.subdividedGeometry && (this.subdividedGeometry.boundingSphere = e.boundingSphere)); let t = e.attributes.position, i = e.boundingSphere.center; Uc.setFromBufferAttribute(t), Uc.getCenter(i), (e.boundingSphere.radius = i.distanceTo(Uc.max)), isNaN(e.boundingSphere.radius) && console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ), Uc.getSize(Ja); let r = { width: Ja.x, height: Ja.y, depth: Ja.z }; return (this.userData.parameters = r), r; } static build(e, t, i, r) { let s, n, a, o = e?.phongAngle ?? 35; i === !1 && (o = -1), t && (Ue.free_bvh(t), Ue.free_subdivision_surface(t)); try { s = Oi.allocate(e, r); } catch (l) { console.error(l, e), (s = Oi.allocate({ positionWASM: Lx, indexWASM: Ox, verticesPerFaceWASM: Ix }, r)); } if ((Ue.set_destination_refinement_level(s, 0), (n = Oi.buildLevel(s, !0, o)), e.subdivisions > 0)) try { Ue.set_destination_refinement_level(s, e.subdivisions), (a = Oi.buildLevel(s, !1, o)); } catch { try { Ue.set_destination_refinement_level(s, e.subdivisions - 1), (a = Oi.buildLevel(s, !1, o)); } catch { a = null; } } else a = null; return { subdivPointer: s, originalGeometry: n, subdividedGeometry: a }; } static primitiveToQuads(e, t, i) { e.widthSegments > 16 && (e.widthSegments = 16), e.heightSegments > 16 && (e.heightSegments = 16), e.depthSegments > 16 && (e.depthSegments = 16), e.radialSegments > 16 && (e.radialSegments = 16), e.type === 'DodecahedronGeometry' && (e.detail = 0); let r; if (e.type === 'TorusGeometry' && e.arc === Math.PI * 2) { let { width: h, height: u, depth: c, arc: d, tubularSegments: p, radialSegments: f } = e; r = new nv(!0, h, c, u, h * 0.5, d / (2 * Math.PI), p, c / 2, 0, f, 0, 0, !0); } else r = e.shape !== void 0 ? t.geometry : Zd(e, i, !1); let s, n, a, o; ({ positions: s, triIndices: o } = ov(r.getAttribute('position'), r.getIndex())); let l; if (e.type === 'CylinderGeometry' && e.cornerRadius === 0 && e.hollow === 0 && e.openEnded === !1) { let h = e.radialSegments * e.heightSegments * 3 * 2, u = h + e.radialSegments * 3; l = [h, u]; } return ({ indices: n, verticesPerFace: a } = IA(s, o, r, l)), { positions: s, indices: n, verticesPerFace: a }; } static allocate(e, t) { let i, r, s, n = [], a = []; e.positionWASM && e.positionWASM.length > 0 ? ((i = e.positionWASM), (r = e.indexWASM), (s = e.verticesPerFaceWASM)) : ((i = Lx), (r = Ox), (s = Ix)); let o = i.length, l = r.length, h = s.length, u = i.length + n.length + a.length, c = r.length + s.length, d = u * Float32Array.BYTES_PER_ELEMENT + c * Uint32Array.BYTES_PER_ELEMENT, p = u * Float32Array.BYTES_PER_ELEMENT, f = c * Uint32Array.BYTES_PER_ELEMENT, g = Ue._malloc(d), m = new Float32Array(Ue.HEAPF32.buffer, g, u), v = new Uint32Array(Ue.HEAPU32.buffer, g + p, c); m.set(i, 0), m.set(n, i.length), m.set(a, i.length + n.length), v.set(r, 0), v.set(s, r.length); let y; e?.scaleBaked?.some((x) => x !== 1) && (y = new ve().makeScale(...e.scaleBaked)), t && (y ? y.premultiply(t) : (y = t)); let b = y ? Ue.alloc_subdivision_surface2(g, o, g + p, l, g + p + r.length * Uint32Array.BYTES_PER_ELEMENT, h, y.elements) : Ue.alloc_subdivision_surface(g, o, g + p, l, g + p + r.length * Uint32Array.BYTES_PER_ELEMENT, h); return Ue._free(g), b; } static buildLevel(e, t, i, r, s) { let n = s ? Ue.get_mesh_data2(e, t ? Ue.Level.CONTROL : Ue.Level.REFINED, i, s.elements) : Ue.get_mesh_data(e, t ? Ue.Level.CONTROL : Ue.Level.REFINED, i), a = 8, o = Ue.HEAPU32.subarray(n >> 2, (n >> 2) + a), l = o.subarray(4, 4 + 4), h = 0, u = Ue.HEAPU32[o[h] >> 2], c = Ue.HEAPF32.subarray(u >> 2, (u >> 2) + l[h]); h++; let d = Ue.HEAPU32[o[h] >> 2], p = Ue.HEAPF32.subarray(d >> 2, (d >> 2) + l[h]); h++; let f = Ue.HEAPU32[o[h] >> 2], g = Ue.HEAPU32.subarray(f >> 2, (f >> 2) + l[h]); h++; let m = Ue.HEAPU32[o[h] >> 2], v = Ue.HEAPU32.subarray(m >> 2, (m >> 2) + l[h]); if ((h++, r === void 0)) { let y = new Ve(); if ((y.setIndex(new Kl(v, 1)), y.setAttribute('position', new Ce(c, 3)), y.setAttribute('normal', new Ce(p, 3)), t)) { y.setAttribute('faceMap', new Kl(g, 1)); let b = new Float32Array((p.length / 3) * 4).fill(0); y.setAttribute('color', new Xe(b, 4)); } return Ue.free_mesh_data(n), (y.userData.type = 'SubdivGeometry'), y; } r.getAttribute('position').copyArray(c), r.getAttribute('normal').copyArray(p), (r.attributes.position.needsUpdate = !0), (r.attributes.normal.needsUpdate = !0), Ue.free_mesh_data(n); } static freeSubdivPointer(e) { Ue.free_bvh(e), Ue.free_subdivision_surface(e); } static buildControlCageWireframe(e, t, i) { let r = Ue.get_wireframe_data_for_base_level(e), s = 4, n = Ue.HEAPU32.subarray(r >> 2, (r >> 2) + s), a = n.subarray(2, 2 + 2), o = 0, l = Ue.HEAPU32[n[o] >> 2], h = Ue.HEAPF32.subarray(l >> 2, (l >> 2) + a[o]); o++; let u = Ue.HEAPU32[n[o] >> 2], c = Ue.HEAPU32.subarray(u >> 2, (u >> 2) + a[o]); if (t === void 0) { let d = new Ve(); d.setAttribute('position', new Ce(h, 3)); let p = new Float32Array(h.length); for (let f = 0, g = h.length; f < g; ) (p[f++] = i.r), (p[f++] = i.g), (p[f++] = i.b); return d.setAttribute('color', new Xe(p, 3)), d.setIndex(new Kl(c, 1)), Ue.free_wireframe_data_for_base_level(r), d; } t.getAttribute('position').copyArray(h), (t.attributes.position.needsUpdate = !0), Ue.free_wireframe_data_for_base_level(r); } static updateCollabMesh(e, t, i) { let r = t === 0; r || Ue.set_destination_refinement_level(e, t); let s = i ? Ue.get_topological_data2(e, r ? Ue.Level.CONTROL : Ue.Level.REFINED, i.elements) : Ue.get_topological_data(e, r ? Ue.Level.CONTROL : Ue.Level.REFINED), n = 6, a = Ue.HEAPU32.subarray(s >> 2, (s >> 2) + n), o = a.subarray(3, 3 + 3), l = 0, h = Ue.HEAPU32[a[l] >> 2], u = new Float32Array(Ue.HEAPF32.subarray(h >> 2, (h >> 2) + o[l])); l++; let c = Ue.HEAPU32[a[l] >> 2], d = new Uint32Array(Ue.HEAPU32.subarray(c >> 2, (c >> 2) + o[l])); l++; let p = Ue.HEAPU32[a[l] >> 2], f = new Uint8Array(Ue.HEAPU32.subarray(p >> 2, (p >> 2) + o[l])); return Ue.free_topological_data(s), { positions: u, indices: d, verticesPerFace: f }; } }, Rx = ['getX', 'getY', 'getZ']; function ov(e, t) { let i = {}, r = t ? t.count : e.count, s = 0, n = [], a = [], o = 1e4; for (let h = 0; h < r; h++) { let u = t ? t.getX(h) : h, c = ''; for (let d = 0; d < 3; d++) c += `${~~(e[Rx[d]](u) * o)},`; if (c in i) n.push(i[c]); else { for (let d = 0; d < 3; d++) a.push(e[Rx[d]](u)); (i[c] = s), n.push(s), s++; } } let l = []; for (let h = 0; h < n.length; h += 3) n[h] === n[h + 1] || n[h] === n[h + 2] || n[h + 1] === n[h + 2] || l.push(n[h], n[h + 1], n[h + 2]); return { positions: a, triIndices: l }; } var Fc = new E(), tf = new E(), rf = new E(), sf = new E(); function IA(e, t, i, r) { let s = [], n = []; if (i.userData.shape !== void 0 && i.userData.parameters.depth === 0 && i.userData.shape.shapeHoles.length === 0) { let a = i.userData.shape.extractShapePointsToFlatArray([]), o = i.userData.parameters.spikes; if (i.userData.type === 'EllipseGeometry' && o <= 24 && o % 4 === 0 && i.userData.parameters.angle >= 360) { let u = a.length / 2 / o; a = a.filter((c, d) => Math.floor(d / 2) % u === 0); } let l = 0; for (let u = 0; u < a.length; u += 2) l += (a[u] - a[(u === 0 ? a.length : u) - 2]) * (a[u + 1] + a[(u === 0 ? a.length : u) - 1]); e.length = 0; let h = 0; if (l < 0) for (let u = 0; u < a.length; u += 2) e.push(a[u], a[u + 1], 0), s.push(h++); else for (let u = a.length - 2; u >= 0; u -= 2) e.push(a[u], a[u + 1], 0), s.push(h++); return n.push(h), { indices: s, verticesPerFace: n }; } for (let a = 0, o = i.capStartIndex ?? t.length; a < o; ) if ((t[a + 1] === t[a + 3] && t[a + 2] === t[a + 5]) || (t[a + 0] === t[a + 3] && t[a + 2] === t[a + 4])) { Fc.set(e[t[a] * 3], e[t[a] * 3 + 1], e[t[a] * 3 + 2]), tf.set(e[t[a + 1] * 3], e[t[a + 1] * 3 + 1], e[t[a + 1] * 3 + 2]), rf.set(e[t[a + 4] * 3], e[t[a + 4] * 3 + 1], e[t[a + 4] * 3 + 2]), sf.set(e[t[a + 5] * 3], e[t[a + 5] * 3 + 1], e[t[a + 5] * 3 + 2]), tf.sub(Fc).normalize(), rf.sub(Fc).normalize(), sf.sub(Fc).normalize(); let l = tf.cross(rf).dot(sf); Math.abs(l) > 0.005 || (r && r.some((h, u) => (u % 2 === 1 ? !1 : a >= r[u] && a < r[u + 1]))) ? (s.push(t[a], t[a + 1], t[a + 2]), n.push(3), (a += 3)) : (s.push(t[a], t[a + 1], t[a + 4], t[a + 5]), n.push(4), (a += 6)); } else s.push(t[a], t[a + 1], t[a + 2]), n.push(3), (a += 3); if (i.capStartIndex !== void 0) { let a = [], o = [], l = 0, h = new Float32Array([i.userData.parameters.depth])[0]; for (let u = 0, c = 0; u < e.length; u += 3, c++) e[u + 2] === 0 && (a.push(c), l++), e[u + 2] === h && o.push(c); if (i.userData.parameters.extrudeBevelSize === 0) { let u = o[0]; (o[0] = o[1]), (o[1] = u); } a.reverse(), s.push(...a, ...o), n.push(l, l); } return { indices: s, verticesPerFace: n }; } var dn = {}; V2(dn, { calcBoolean: () => N6, calcBooleanTopological: () => z6, freeMeshSet: () => k6, getMeshSet: () => U6, transformMeshSet: () => F6 }); var RA, I6 = new Promise((e) => { RA = e; }), Bx = !1; async function R6() { if (Bx) return; let e = './assets/3d', [t, i] = await Promise.all([import('./boolean.js'), fetch(`${e}/boolean.wasm`).then((n) => n.arrayBuffer())]), r = t.default, s = await r({ wasmBinary: i }); RA(s), (Bx = !0); } var tt, Lo; I6.then((e) => (tt = e)); function B6(e, t, i) { let r, { positions: s, triIndices: n } = ov(e.getAttribute('position'), e.getIndex()), a; if (t && i) { let { indices: o, verticesPerFace: l } = IA(s, n, e); (a = l.length), (r = []); for (let h = 0, u = 0; h < a; h++) { r.push(l[h]); for (let c = 0; c < l[h]; c++) r.push(o[u++]); } } else { let o = n.length; (r = Array(o + o / 3)), (a = 0); for (let l = 0, h = 0; h < r.length; ) (r[h++] = 3), a++, (r[h++] = n[l++]), (r[h++] = n[l++]), (r[h++] = n[l++]); } return { positions: s, faceIndices: r, nFaces: a }; } function BA(e) { let t = e.length, i = t * Uint32Array.BYTES_PER_ELEMENT, r = t * Float32Array.BYTES_PER_ELEMENT, s = Number.isInteger(e[0]) ? i : r, n = tt._malloc(s); return (Number.isInteger(e[0]) ? new Uint32Array(tt.HEAPU32.buffer, n, t) : new Float32Array(tt.HEAPF32.buffer, n, t)).set(e, 0), n; } function zA(e) { switch (e) { case 0: return tt.OP.UNION; case 1: return tt.OP.INTERSECTION; case 2: return tt.OP.A_MINUS_B; case 3: return tt.OP.B_MINUS_A; case 4: return tt.OP.SYMMETRIC_DIFFERENCE; case 5: return tt.OP.ALL; default: throw new Error('Unknown boolean operation ' + e); } } function z6(e, t) { Lo === void 0 && (Lo = tt.init_csg()); let i = BA(e), r = tt.csg_calc_topological(Lo, i, e.length, zA(t)); tt._free(i); let s = 6, n = tt.HEAPU32.subarray(r >> 2, (r >> 2) + s), a = n.subarray(3, 3 + 3), o = 0, l = tt.HEAPU32[n[o] >> 2], h = new Float32Array(tt.HEAPF32.subarray(l >> 2, (l >> 2) + a[o])); o++; let u = tt.HEAPU32[n[o] >> 2], c = new Uint32Array(tt.HEAPU32.subarray(u >> 2, (u >> 2) + a[o])); o++; let d = tt.HEAPU32[n[o] >> 2], p = new Uint8Array(tt.HEAPU32.subarray(d >> 2, (d >> 2) + a[o])); return tt.free_mesh_data(r), { positions: h, indices: c, verticesPerFace: p }; } function N6(e, t, i, r) { Lo === void 0 && (Lo = tt.init_csg()); let s = BA(e), n = tt.csg_calc(Lo, s, e.length, r, zA(t)); tt._free(s); let a = 5, o = tt.HEAPU32.subarray(n >> 2, (n >> 2) + a), l = o.subarray(2, 2 + 3), h = 0, u = tt.HEAPU32[o[h] >> 2], c = tt.HEAPF32.subarray(u >> 2, (u >> 2) + l[h]); h++; let d = tt.HEAPU32[o[h] >> 2], p = tt.HEAPF32.subarray(d >> 2, (d >> 2) + l[h]); h++; let f = l[h]; i.setAttribute('position', new Ce(c, 3)), i.setAttribute('normal', new Ce(p, 3)); let g = tt.HEAPF32.subarray((n >> 2) + 5, (n >> 2) + 5 + 6); return ( i.boundingSphere === null && (i.boundingSphere = new Mr()), i.boundingSphere.center.set(g[0], g[1], g[2]), (i.boundingSphere.radius = (g[3] ** 2 + g[4] ** 2 + g[5] ** 2) ** 0.5), (i.userData.parameters = { width: g[3] * 2, height: g[4] * 2, depth: g[5] * 2 }), tt.free_mesh_data(n), f ); } function U6(e, t, i) { if (tt === void 0) return -1; let r, s, n; if (t && e.userData.positions !== void 0) { let m = e.userData; (n = m.verticesPerFace.length), (r = m.positions), (s = Array(m.verticesPerFace.reduce((v, y) => v + y, 0) + n)); for (let v = 0, y = 0, b = 0; v < m.verticesPerFace.length; v++) { s[b++] = m.verticesPerFace[v]; for (let x = 0; x < m.verticesPerFace[v]; x++) s[b++] = m.indices[y++]; } } else ({ positions: r, faceIndices: s, nFaces: n } = B6(e, t, i)); let a = r.length, o = s.length, l = r.length, h = s.length, u = l * Float32Array.BYTES_PER_ELEMENT + h * Uint32Array.BYTES_PER_ELEMENT, c = l * Float32Array.BYTES_PER_ELEMENT, d = h * Uint32Array.BYTES_PER_ELEMENT, p = tt._malloc(u), f = new Float32Array(tt.HEAPF32.buffer, p, l), g = new Uint32Array(tt.HEAPU32.buffer, p + c, h); return f.set(r, 0), g.set(s, 0), tt.get_csg_mesh(p, a, p + c, o, n); } function F6(e, t) { tt.transform_csg_mesh(e, t.elements); } function k6(e) { tt.free_csg_mesh(e); } var j6 = { ConeGeometry: wF, CubeGeometry: _F, CylinderGeometry: bF, DodecahedronGeometry: SF, EllipseGeometry: sv, HelixGeometry: t6, IcosahedronGeometry: i6, LatheGeometry: r6, NonParametricGeometry: c6, PolygonGeometry: TA, PyramidGeometry: d6, RectangleGeometry: PA, SphereGeometry: f6, PlaneGeometry: m6, BackdropGeometry: g6, StarGeometry: DA, TextFrameGeometry: y6, TorusGeometry: x6, TorusKnotGeometry: w6, TriangleGeometry: _6, PathGeometry: M6, VectorGeometry: Ta }, zx = (e) => j6[e.type].create(e); function Ll(e) { return e !== null && 'booleanOp' in e; } var NA = class extends dA(tr) { constructor() { super(...arguments), (this.booleanMeshSetAddress = -1), (this.booleanWasTransformed = !1), (this.booleanMatrixInvOld = new ve()); } updateVisible() { super.updateVisible(), (this.visible = !Ll(this.parent) && this.visible), Ll(this.parent) && this.parent.invalidateDownstreamBooleanData(); } freeBooleanPointer() { this.booleanMeshSetAddress !== -1 && (dn.freeMeshSet(this.booleanMeshSetAddress), (this.booleanMeshSetAddress = -1)); } invalidateDownstreamBooleanData(e = !1) { return ( e ? (this.booleanWasTransformed = !0) : this.freeBooleanPointer(), Ll(this.parent) ? this.parent.invalidateDownstreamBooleanData() : this ); } invalidateUpstreamBooleanData() { this.freeBooleanPointer(); for (let e of this.children) e instanceof NA && (e.freeBooleanPointer(), Ll(e) && e.invalidateUpstreamBooleanData()); } updateTransformState(e) { let t = super.updateTransformState(e); return t && Ll(this.parent) && this.invalidateDownstreamBooleanData(!0), t; } }, kc = new Kt(); function lv(e, t = 0, i = e.count, r, s) { let n = 1 / 0, a = 1 / 0, o = 1 / 0, l = -1 / 0, h = -1 / 0, u = -1 / 0; for (let c = t; c < i; c++) { let d = e.getX(c), p = e.getY(c), f = e.getZ(c); d < n && (n = d), p < a && (a = p), f < o && (o = f), d > l && (l = d), p > h && (h = p), f > u && (u = f); } kc.min.set(n, a, o), kc.max.set(l, h, u), kc.getCenter(r), kc.getSize(s).multiplyScalar(0.5); } var G6 = new Ve(), V6 = new Ph(), ar = class extends NA { constructor(e, t) { super(G6, V6), this.super_Entity(e, t); } updateState(e, t) { this.updateState_Entity(e, t); } updateEntityBoxSize(e, t) { let i = this.geometry.getAttribute('position'); i !== void 0 ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t) : super.updateEntityBoxSize(e, t); } }, Nx = class { constructor(e) { (e = e ?? {}), (this.name = e.name), (this.type = e.type), (this.node = e.node), (this.size = e.size), (this.needsUpdate = e.needsUpdate); } get value() { return this.node.value; } set value(e) { this.node.value = e; } }, Bn = class { constructor(e) { (this.hashProperties = void 0), (this.isNode = !0), (this.shortcuts = {}), (this.uuid = it.generateUUID()), (this.type = e), (this.name = ''); } analyze(e, t) { (t = t ?? {}), (e.analyzing = !0), this.build(e.addFlow(t.slot, t.cache, t.context), 'v4'), e.clearVertexNodeCode(), e.clearFragmentNodeCode(), e.removeFlow(), (e.analyzing = !1); } analyzeAndFlow(e, t, i) { return (i = i ?? {}), this.analyze(e, i), this.flow(e, t, i); } flow(e, t, i) { (i = i ?? {}), e.addFlow(i.slot, i.cache, i.context); let r = { result: this.build(e, t), code: e.clearNodeCode(), extra: e.context.extra }; return e.removeFlow(), r; } build(e, t, i) { t = t ?? this.getType(e, t); let r = e.getNodeData(i ?? this); return ( e.analyzing && this.appendDepsNode(e, r, t), e.nodes.indexOf(this) === -1 && e.nodes.push(this), this.updateFrame !== void 0 && e.updaters.indexOf(this) === -1 && e.updaters.push(this), this.generate(e, t, i) ); } updateFrame(e) {} generateReadonly(e, t, i, r, s, n) { return ''; } generate(e, t, i, r, s) { return ''; } parse(e, t, i, r) {} appendDepsNode(e, t, i) { t.deps = (t.deps || 0) + 1; let r = e.getTypeLength(i); (r > (t.outputMax || 0) || this.getType(e, i)) && ((t.outputMax = r), (t.output = i)); } setName(e) { this.name = e; } getName() { return this.name; } getType(e, t) { return t === 'sampler2D' || t === 'samplerCube' ? t : this.type; } getHash() { let e = '{', t, i; for (t in this) (i = this[t]), i instanceof Bn && (e += '"' + t + '":' + i.getHash() + ','); if (this.hashProperties) for (let r = 0; r < this.hashProperties.length; r++) (t = this.hashProperties[r]), (i = this[t]), (e += '"' + t + '":"' + String(i) + '",'); return (e += '"id":"' + this.uuid + '"}'), e; } }, H6 = class { constructor() { (this.nodes = {}), (this.keywords = {}); } add(e) { this.nodes[e.name] = e; } addKeyword(e, t, i) { (i = i !== void 0 ? i : !0), (this.keywords[e] = { callback: t, cache: i }); } remove(e) { delete this.nodes[e.name]; } removeKeyword(e) { delete this.keywords[e]; } get(e) { return this.nodes[e]; } getKeyword(e, t) { return this.keywords[e].callback(t); } getKeywordData(e) { return this.keywords[e]; } contains(e) { return this.nodes[e] !== void 0; } containsKeyword(e) { return this.keywords[e] !== void 0; } }, Ni = new H6(), St = class extends Bn { constructor(e, t) { super(e), (this.scope = ''), (t = t ?? {}), (this.shared = t.shared !== void 0 ? t.shared : !0), (this.unique = t.unique !== void 0 ? t.unique : !1); } build(e, t, i, r) { if (((t = t ?? this.getType(e)), this.getShared(e, t))) { let s = this.getUnique(e, t); s && this.uuid === void 0 && (this.uuid = it.generateUUID()), (i = e.getUUID(i ?? this.getUUID(), !s)); let n = e.getNodeData(i), a = n.output || this.getType(e); if (e.analyzing) return (n.deps || 0) > 0 || this.getLabel() ? (this.appendDepsNode(e, n, t), this.generate(e, t, i)) : super.build(e, t, i); if (s) return (n.name = n.name || super.build(e, t, i)), n.name; if (!this.getLabel() && (!this.getShared(e, a) || e.context.ignoreCache || n.deps === 1)) return super.build(e, t, i); i = this.getUUID(!1); let o = this.getTemp(e, i); if (o) return e.format(o, a, t); { o = super.generate(e, t, i, n.output, r); let l = this.generate(e, a, i); return e.addNodeCode(o + ' = ' + l + ';'), e.format(o, a, t); } } return super.build(e, t, i); } getShared(e, t) { return t !== 'sampler2D' && t !== 'samplerCube' && this.shared; } getUnique(e, t) { return this.unique; } setLabel(e) { return (this.label = e), this; } getLabel() { return this.label; } getUUID(e) { let t = this.uuid; return typeof this.scope == 'string' && (t = this.scope + '-' + t), t; } getTemp(e, t) { t = t || this.uuid; let i = e.getVars()[t]; return i ? i.name : void 0; } generate(e, t, i, r, s) { return ( this.getShared(e, t) || console.error('TempNode is not shared'), (i = i ?? this.uuid), e.getTempVar(i, r ?? this.getType(e), s, this.getLabel()).name ); } }, or = class extends St { constructor(e, t) { (t = t ?? {}), (t.shared = t.shared !== void 0 ? t.shared : !1), super(e, t), (this.readonly = !1); } setReadonly(e) { return (this.readonly = e), (this.hashProperties = this.readonly ? ['value'] : void 0), this; } getReadonly() { return this.readonly; } generate(e, t, i, r, s, n) { (i = e.getUUID(i ?? this.getUUID())), (r = r ?? this.getType(e)); let a = e.getNodeData(i); return this.getReadonly() && this.generateReadonly !== void 0 ? this.generateReadonly(e, t, i, r, s, n) : e.isShader('vertex') ? (a.vertex || (a.vertex = e.createVertexUniform(r, this, s, n, this.getLabel())), e.format(a.vertex.name, r, t)) : (a.fragment || (a.fragment = e.createFragmentUniform(r, this, s, n, this.getLabel())), e.format(a.fragment.name, r, t)); } }, vr = class extends or { constructor(e = 0, t) { super('v2'), (this.nodeType = 'Vector2'), (this.value = e instanceof G ? e : new G(e, t)); } get x() { return this.value.x; } set x(e) { this.value.x = e; } get y() { return this.value.y; } set y(e) { this.value.y = e; } generateReadonly(e, t, i, r, s, n) { return e.format('vec2(' + this.value.x + ', ' + this.value.y + ')', r, t); } }, fr = class extends or { constructor(e = 0, t, i) { super('v3'), (this.nodeType = 'Vector3'), (this.value = e instanceof E ? e : new E(e, t, i)); } get x() { return this.value.x; } set x(e) { this.value.x = e; } get y() { return this.value.y; } set y(e) { this.value.y = e; } get z() { return this.value.z; } set z(e) { this.value.z = e; } generateReadonly(e, t, i, r, s, n) { return e.format('vec3(' + this.value.x + ', ' + this.value.y + ', ' + this.value.z + ')', r, t); } }, ji = class extends Ge { constructor(e, t, i, r) { super(e, t, i), (this.isColorA = !0), (this.a = r); } setRGBA(e, t, i, r) { super.setRGB(e, t, i), (this.a = r); } copy(e) { return super.copy(e), (this.a = 'a' in e ? e.a : 1), this; } clone() { return new this.constructor(this.r, this.g, this.b, this.a); } setStyle(e, t = 'srgb') { let i; if (e === 'transparent') return this.setRGBA(0, 0, 0, 0), this; if ((i = /^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e))) { let r, s = i[1], n = i[2]; switch (s) { case 'rgb': case 'rgba': if ((r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))) return (this.a = s === 'rgba' ? parseFloat(r[4]) : 1), super.setStyle(e, t); break; case 'hsl': case 'hsla': if ((r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))) return (this.a = s === 'hsla' ? parseFloat(r[4]) : 1), super.setStyle(e, t); break; } } return super.setStyle(e, t); } get x() { return this.r; } get y() { return this.g; } get z() { return this.b; } get w() { return this.a; } set x(e) { this.r = e; } set y(e) { this.g = e; } set z(e) { this.b = e; } set w(e) { this.a = e; } }, na = class extends or { constructor(e) { super('v4'), (this.nodeType = 'Vector4'), (this.value = e instanceof ji ? e : new ji(e.r, e.g, e.b, e.a)); } generateReadonly(e, t, i, r, s, n) { return e.format('vec4(' + this.value.r + ', ' + this.value.g + ', ' + this.value.b + ', ' + this.value.a + ')', r, t); } }, W6 = /^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i, Ux = /[a-z_0-9]+/gi, Re = class extends St { constructor(e, t, i, r, s) { super(s), (this.src = ''), (this.nodeType = 'Function'), (this.useKeywords = !0), (this.includes = []), (this.extensions = {}), (this.keywords = {}), (this.isMethod = s === void 0), (this.isInterface = !1), this.parse(e, t, i, r); } getShared(e, t) { return !this.isMethod; } getType(e) { return e.getTypeByFormat(this.type); } getInputByName(e) { if (this.inputs) { let t = this.inputs.length; for (; t--; ) if (this.inputs[t].name === e) return this.inputs[t]; } } getIncludeByName(e) { if (this.includes) { let t = this.includes.length; for (; t--; ) if (this.includes[t].name === e) return this.includes[t]; } } generate(e, t, i, r, s) { let n, a = 0, o = this.src; if (this.includes) for (let h = 0; h < this.includes.length; h++) e.include(this.includes[h], this); for (let h in this.extensions) e.extensions[h] = !0; let l = []; for (; (n = Ux.exec(this.src)); ) l.push(n); for (let h = 0; h < l.length; h++) { let u = l[h], c = u[0], d = this.isMethod ? !this.getInputByName(c) : !0, p = c; if (this.keywords[c] || (this.useKeywords && d && Ni.containsKeyword(c))) { let f = this.keywords[c]; if (!f) { let g = Ni.getKeywordData(c); g.cache && (f = e.keywords[c]), (f = f || Ni.getKeyword(c, e)), g.cache && (e.keywords[c] = f); } p = f.build(e); } c !== p && o[u.index + a - 1] !== '.' && ((o = o.substring(0, u.index + a) + p + o.substring(u.index + c.length + a)), (a += p.length - c.length)), this.getIncludeByName(p) === void 0 && Ni.contains(p) && e.include(Ni.get(p)); } return t === 'source' ? o : this.isMethod ? (this.isInterface || e.include(this, void 0, o), this.name) : e.format('( ' + o + ' )', this.getType(e), t); } parse(e, t, i, r) { if (((this.src = e || ''), (this.includes = t ?? []), (this.extensions = i ?? {}), (this.keywords = r ?? {}), this.isMethod)) { let s = W6.exec(this.src); if (((this.inputs = []), s && s.length == 4)) { (this.type = s[1]), (this.name = s[2]); let n = s[3].match(Ux); if (n) { let a = 0; for (; a < n.length; ) { let o = n[a++], l; o === 'in' || o === 'out' || o === 'inout' ? (l = n[a++]) : ((l = o), (o = '')); let h = n[a++]; this.inputs.push({ name: h, type: l, qualifier: o }); } } this.isInterface = this.src.indexOf('{') === -1; } else (this.type = ''), (this.name = ''); } } }, X6 = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i, UA = class extends St { constructor(e = '', t) { super(), (this.src = ''), (this.useDefine = !1), (this.nodeType = 'Const'), this.parse(e || UA.PI, void 0, void 0, void 0, t); } getType(e) { return e.getTypeByFormat(this.type); } parse(e, t, i, r, s) { this.src = e || ''; let n, a, o = '', l = X6.exec(e); (this.useDefine = s ?? this.src.charAt(0) === '#'), l && l.length > 1 ? ((a = l[1]), (n = l[2]), (o = l[3])) : ((n = this.src), (a = 'f')), (this.name = n), (this.type = a), (this.value = o); } build(e, t) { if (t === 'source') { if (this.value) return this.useDefine ? '#define ' + this.name + ' ' + this.value : 'const ' + this.type + ' ' + this.name + ' = ' + this.value + ';'; if (this.useDefine) return this.src; } return e.include(this), e.format(this.name, this.getType(e), t); } generate(e, t, i, r, s) { return e.format(this.name, this.getType(e), t); } }, vt = UA; (vt.PI = 'PI'), (vt.PI2 = 'PI2'), (vt.RECIPROCAL_PI = 'RECIPROCAL_PI'), (vt.RECIPROCAL_PI2 = 'RECIPROCAL_PI2'), (vt.LOG2 = 'LOG2'), (vt.EPSILON = 'EPSILON'); var q6 = new RegExp( `^structs*([a-z_0-9]+)s*{s*((.| )*?)}`, 'gim' ), Y6 = new RegExp('s*(w*?)s*(w*?)(=|;)', 'gim'), FA = class extends St { constructor(e = '') { super(), (this.inputs = []), (this.src = ''), (this.nodeType = 'Struct'), this.parse(e); } getType(e) { return e.getTypeByFormat(this.name); } getInputByName(e) { let t = this.inputs.length; for (; t--; ) if (this.inputs[t].name === e) return this.inputs[t]; } generate(e, t, i, r, s) { return t === 'source' ? this.src + ';' : e.format('( ' + this.src + ' )', this.getType(e), t); } parse(e = '') { (this.src = e), (this.inputs = []); let t = q6.exec(e); if (t) { let i = t[2], r; for (; (r = Y6.exec(i)); ) this.inputs.push({ type: r[1], name: r[2] }); this.name = t[1]; } else this.name = ''; this.type = this.name; } }, hv = class extends St { constructor(e) { super('v2', { shared: !1 }), (this.nodeType = 'UV'), (this.index = e ?? 0); } generate(e, t) { e.requires.uv[this.index] = !0; let i = this.index > 0 ? this.index + 1 : '', r = e.isShader('vertex') ? 'uv' + i : 'vUv' + i; return e.format(r, this.getType(e), t); } }; Ni.addKeyword('uv', function () { return new hv(); }); Ni.addKeyword('uv2', function () { return new hv(1); }); var lo = class extends St { constructor(e, t) { super('v4'), (this.nodeType = 'ColorSpace'), (this.input = e), (this.method = t ?? lo.LINEAR_TO_LINEAR), (this.hashProperties = ['method']); } static getEncodingComponents(e) { switch (e) { case gs: return ['Linear']; case Ke: return ['sRGB']; default: return []; } } generate(e, t) { let i = this.input.build(e, 'v4'), r = this.getType(e), s = lo.Nodes[this.method], n = e.include(s); if (n === lo.LINEAR_TO_LINEAR) return e.format(i, r, t); if (s.inputs?.length === 2) { let a = this.factor.build(e, 'f'); return e.format(n + '( ' + i + ', ' + a + ' )', r, t); } else return e.format(n + '( ' + i + ' )', r, t); } fromEncoding(e) { let t = lo.getEncodingComponents(e); (this.method = 'LinearTo' + t[0]), (this.factor = t[1]); } fromDecoding(e) { let t = lo.getEncodingComponents(e); (this.method = t[0] + 'ToLinear'), (this.factor = t[1]); } }, hs = lo; (hs.Nodes = { LinearToLinear: new Re( ['vec4 LinearToLinear( in vec4 value ) {', '\treturn value;', '}'].join(` `) ), sRGBToLinear: new Re( [ 'vec4 sRGBToLinear( in vec4 value ) {', '\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.w );', '}' ].join(` `) ), LinearTosRGB: new Re( [ 'vec4 LinearTosRGB( in vec4 value ) {', '\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.w );', '}' ].join(` `) ) }), (hs.LINEAR_TO_LINEAR = 'LinearToLinear'), (hs.SRGB_TO_LINEAR = 'sRGBToLinear'), (hs.LINEAR_TO_SRGB = 'LinearTosRGB'); var Pt = class extends Re { constructor(e = '', t, i, r, s) { super(e, s, r, i, t), (this.nodeType = 'Expression'); } }, An = class extends or { constructor(e = new ci(), t, i, r) { super('v4', { shared: !0 }), (this.nodeType = 'Texture'), (this.value = e), (this.uv = t ?? new hv()), (this.bias = i), (this.project = r !== void 0 ? r : !1); } getTexture(e, t) { return super.generate(e, t, this.value.uuid, 't'); } generate(e, t) { if (t === 'sampler2D') return this.getTexture(e, t); let i = this.getTexture(e, t), r = this.uv.build(e, this.project ? 'v4' : 'v2'), s = this.bias ? this.bias.build(e, 'f') : void 0; s === void 0 && e.context.bias && (s = e.context.bias.setTexture(this).build(e, 'f')); let n, a; this.project ? (n = 'texture2DProj') : (n = s ? 'tex2DBias' : 'tex2D'), s ? (a = n + '( ' + i + ', ' + r + ', ' + s + ' )') : (a = n + '( ' + i + ', ' + r + ' )'); let o = { include: e.isShader('vertex'), ignoreCache: !0 }, l = this.getType(e); return ( e.addContext(o), (this.colorSpace = this.colorSpace ?? new hs(new Pt('', l))), this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)), this.colorSpace.input.parse(a), (a = this.colorSpace.build(e, l)), e.removeContext(), e.format(a, l, t) ); } }, Pe = class extends or { constructor(e) { super('f'), (this.nodeType = 'Float'), (this.value = e ?? 0); } generateReadonly(e, t, i, r, s, n) { return e.format(this.value + (this.value % 1 ? '' : '.0'), r, t); } }, Fx = class extends St { constructor(e, t) { super(), (this.inputs = []), (this.nodeType = 'FunctionCall'), (this.value = e), (this.inputs = t ?? []); } getFunction() { return this.value; } getType(e) { return this.value.getType(e); } generate(e, t, i, r, s) { r = this.getType(e); let n = this.value, a = n.build(e, t) + '( ', o = []; if (n.inputs) { for (let l = 0; l < n.inputs.length; l++) { let h = n.inputs[l], u = this.inputs[l] || this.inputs[h.name]; o.push(u.build(e, e.getTypeByFormat(h.type))); } a += o.join(', ') + ' )'; } return e.format(a, r, t); } }, kA = class extends St { constructor(e, t, i = kA.ADD) { super(), (this.nodeType = 'Operator'), (this.type = e.type), (this.a = e), (this.b = t), (this.op = i); } getType(e) { let t = this.a.getType(e), i = this.b.getType(e); return e.isTypeMatrix(t) ? 'v4' : e.getTypeLength(i) > e.getTypeLength(t) ? i : t; } generate(e, t) { let i = this.getType(e); this.type = i; let r = this.a.build(e, i), s = this.b.build(e, i); return e.format('( ' + r + ' ' + this.op + ' ' + s + ' )', i, t); } }, cs = kA; (cs.ADD = '+'), (cs.SUB = '-'), (cs.MUL = '*'), (cs.DIV = '/'); var gt = class extends St { constructor(e, t = gt.ABS, i, r) { super(), (this.nodeType = 'Math'), (this.a = e), typeof t != 'string' ? (this.b = t) : (r = t), typeof i != 'string' ? (this.c = i) : (r = i), (this.method = r), (this.hashProperties = ['method']); } getNumInputs(e) { switch (this.method) { case gt.MIX: case gt.CLAMP: case gt.REFRACT: case gt.SMOOTHSTEP: case gt.FACEFORWARD: return 3; case gt.MIN: case gt.MAX: case gt.MOD: case gt.STEP: case gt.REFLECT: case gt.DISTANCE: case gt.DOT: case gt.CROSS: case gt.POW: return 2; default: return 1; } } getInputType(e) { let t = e.getTypeLength(this.a.getType(e)), i = this.b ? e.getTypeLength(this.b.getType(e)) : 0, r = this.c ? e.getTypeLength(this.c.getType(e)) : 0; return t > i && t > r ? this.a.getType(e) : i > r ? this.b.getType(e) : this.c.getType(e); } getType(e) { switch (this.method) { case gt.LENGTH: case gt.DISTANCE: case gt.DOT: return 'f'; case gt.CROSS: return 'v3'; } return this.getInputType(e); } generate(e, t) { let i, r, s, n = this.a ? e.getTypeLength(this.a.getType(e)) : 0, a = this.b ? e.getTypeLength(this.b.getType(e)) : 0, o = this.c ? e.getTypeLength(this.c.getType(e)) : 0, l = this.getInputType(e), h = this.getType(e); switch (((this.type = h), this.method)) { case gt.NEGATE: return e.format('( -' + this.a.build(e, l) + ' )', l, t); case gt.INVERT: return e.format('( 1.0 - ' + this.a.build(e, l) + ' )', l, t); case gt.CROSS: (i = this.a.build(e, 'v3')), (r = this.b.build(e, 'v3')); break; case gt.STEP: (i = this.a.build(e, n === 1 ? 'f' : l)), (r = this.b.build(e, l)); break; case gt.MIN: case gt.MAX: case gt.MOD: (i = this.a.build(e, l)), (r = this.b.build(e, a === 1 ? 'f' : l)); break; case gt.REFRACT: (i = this.a.build(e, l)), (r = this.b.build(e, l)), (s = this.c.build(e, 'f')); break; case gt.MIX: (i = this.a.build(e, l)), (r = this.b.build(e, l)), (s = this.c.build(e, o === 1 ? 'f' : l)); break; default: (i = this.a.build(e, l)), this.b && (r = this.b.build(e, l)), this.c && (s = this.c.build(e, l)); break; } let u = []; u.push(i), r && u.push(r), s && u.push(s); let c = this.getNumInputs(e); if (u.length !== c) throw Error(`Arguments not match used in "${this.method}". Require ${c}, currently ${u.length}.`); return e.format(this.method + '( ' + u.join(', ') + ' )', h, t); } }, qe = gt; (qe.RAD = 'radians'), (qe.DEG = 'degrees'), (qe.EXP = 'exp'), (qe.EXP2 = 'exp2'), (qe.LOG = 'log'), (qe.LOG2 = 'log2'), (qe.SQRT = 'sqrt'), (qe.INV_SQRT = 'inversesqrt'), (qe.FLOOR = 'floor'), (qe.CEIL = 'ceil'), (qe.NORMALIZE = 'normalize'), (qe.FRACT = 'fract'), (qe.SATURATE = 'saturate'), (qe.SIN = 'sin'), (qe.COS = 'cos'), (qe.TAN = 'tan'), (qe.ASIN = 'asin'), (qe.ACOS = 'acos'), (qe.ARCTAN = 'atan'), (qe.ABS = 'abs'), (qe.SIGN = 'sign'), (qe.LENGTH = 'length'), (qe.NEGATE = 'negate'), (qe.INVERT = 'invert'), (qe.MIN = 'min'), (qe.MAX = 'max'), (qe.MOD = 'mod'), (qe.STEP = 'step'), (qe.REFLECT = 'reflect'), (qe.DISTANCE = 'distance'), (qe.DOT = 'dot'), (qe.CROSS = 'cross'), (qe.POW = 'pow'), (qe.MIX = 'mix'), (qe.CLAMP = 'clamp'), (qe.REFRACT = 'refract'), (qe.SMOOTHSTEP = 'smoothstep'), (qe.FACEFORWARD = 'faceforward'); var Xl = class extends St { constructor(e, t, i) { super('v4'), (this.nodeType = 'TextureCubeUV'), (this.value = e), (this.uv = t), (this.bias = i); } bilinearCubeUV(e, t, i, r) { let s = new Fx(Xl.Nodes.bilinearCubeUV, [t, i, r]); (this.colorSpaceTL = this.colorSpaceTL ?? new hs(new Pt('', 'v4'))), this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)), this.colorSpaceTL.input.parse(s.build(e) + '.tl'), (this.colorSpaceTR = this.colorSpaceTR ?? new hs(new Pt('', 'v4'))), this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)), this.colorSpaceTR.input.parse(s.build(e) + '.tr'), (this.colorSpaceBL = this.colorSpaceBL ?? new hs(new Pt('', 'v4'))), this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)), this.colorSpaceBL.input.parse(s.build(e) + '.bl'), (this.colorSpaceBR = this.colorSpaceBR ?? new hs(new Pt('', 'v4'))), this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)), this.colorSpaceBR.input.parse(s.build(e) + '.br'); let n = { include: e.isShader('vertex'), ignoreCache: !0 }; e.addContext(n), (this.colorSpaceTLExp = new Pt(this.colorSpaceTL.build(e, 'v4'), 'v4')), (this.colorSpaceTRExp = new Pt(this.colorSpaceTR.build(e, 'v4'), 'v4')), (this.colorSpaceBLExp = new Pt(this.colorSpaceBL.build(e, 'v4'), 'v4')), (this.colorSpaceBRExp = new Pt(this.colorSpaceBR.build(e, 'v4'), 'v4')), e.removeContext(); let a = new Pt('mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )', 'v4'); return ( (a.keywords.cubeUV_TL = this.colorSpaceTLExp), (a.keywords.cubeUV_TR = this.colorSpaceTRExp), (a.keywords.cubeUV_BL = this.colorSpaceBLExp), (a.keywords.cubeUV_BR = this.colorSpaceBRExp), (a.keywords.cubeUV = s), a ); } generate(e, t) { if (e.isShader('fragment')) { let i = this.uv, r = this.bias || e.context.roughness, s = new Fx(Xl.Nodes.roughnessToMip, [r]), n = new qe(s, Xl.Nodes.m0, Xl.Nodes.cubeUV_maxMipLevel, qe.CLAMP), a = new qe(n, qe.FLOOR), o = new qe(n, qe.FRACT), l = this.bilinearCubeUV(e, this.value, i, a), h = this.bilinearCubeUV(e, this.value, i, new cs(a, new Pe(1).setReadonly(!0), cs.ADD)), u = new qe(l, h, o, qe.MIX); return e.format(u.build(e), 'v4', t); } else return ( console.warn('TextureCubeUVNode is not compatible with ' + e.shader + ' shader.'), e.format('vec4( 0.0 )', this.getType(e), t) ); } }, Fm = Xl; Fm.Nodes = (function () { let e = new FA(`struct TextureCubeUVData { vec4 tl; vec4 tr; vec4 br; vec4 bl; vec2 f; }`), t = new vt('float cubeUV_maxMipLevel 8.0', !0), i = new vt('float cubeUV_minMipLevel 4.0', !0), r = new vt('float cubeUV_maxTileSize 256.0', !0), s = new vt('float cubeUV_minTileSize 16.0', !0), n = new Re(`float getFace(vec3 direction) { vec3 absDirection = abs(direction); float face = -1.0; if (absDirection.x > absDirection.z) { if (absDirection.x > absDirection.y) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if (absDirection.z > absDirection.y) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; }`); n.useKeywords = !1; let a = new Re(`vec2 getUV(vec3 direction, float face) { vec2 uv; if (face == 0.0) { uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x } else if (face == 1.0) { uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y } else if (face == 2.0) { uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z } else if (face == 3.0) { uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x } else if (face == 4.0) { uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y } else { uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z } return 0.5 * (uv + 1.0); }`); a.useKeywords = !1; let o = new Re( `TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) { float face = getFace(direction); float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0); mipInt = max(mipInt, cubeUV_minMipLevel); float faceSize = exp2(mipInt); float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize); vec2 uv = getUV(direction, face) * (faceSize - 1.0); vec2 f = fract(uv); uv += 0.5 - f; if (face > 2.0) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; if(mipInt < cubeUV_maxMipLevel){ uv.y += 2.0 * cubeUV_maxTileSize; } uv.y += filterInt * 2.0 * cubeUV_minTileSize; uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize); uv *= texelSize; vec4 tl = texture2D(envMap, uv); uv.x += texelSize; vec4 tr = texture2D(envMap, uv); uv.y += texelSize; vec4 br = texture2D(envMap, uv); uv.x -= texelSize; vec4 bl = texture2D(envMap, uv); return TextureCubeUVData( tl, tr, br, bl, f ); }`, [e, n, a, t, i, r, s] ); o.useKeywords = !1; let l = new vt('float r0 1.0', !0), h = new vt('float v0 0.339', !0), u = new vt('float m0 -2.0', !0), c = new vt('float r1 0.8', !0), d = new vt('float v1 0.276', !0), p = new vt('float m1 -1.0', !0), f = new vt('float r4 0.4', !0), g = new vt('float v4 0.046', !0), m = new vt('float m4 2.0', !0), v = new vt('float r5 0.305', !0), y = new vt('float v5 0.016', !0), b = new vt('float m5 3.0', !0), x = new vt('float r6 0.21', !0), w = new vt('float v6 0.0038', !0), A = new vt('float m6 4.0', !0), S = [l, h, u, c, d, p, f, g, m, v, y, b, x, w, A], _ = new Re( `float roughnessToMip(float roughness) { float mip = 0.0; if (roughness >= r1) { mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0; } else if (roughness >= r4) { mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1; } else if (roughness >= r5) { mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4; } else if (roughness >= r6) { mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5; } else { mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25 } return mip; }`, S ); return { bilinearCubeUV: o, roughnessToMip: _, m0: u, cubeUV_maxMipLevel: t }; })(); var ho = class extends St { constructor(e) { super('v3'), (this.nodeType = 'Normal'), (this.scope = e ?? ho.VIEW); } getShared() { return this.scope === ho.WORLD; } build(e, t, i, r) { let s = e.context[this.scope + 'Normal']; return s ? s.build(e, t, i, r) : super.build(e, t, i); } generate(e, t, i, r, s) { let n; switch (this.scope) { case ho.VIEW: e.isShader('vertex') ? (n = 'transformedNormal') : (n = 'geometryNormal'); break; case ho.LOCAL: e.isShader('vertex') ? (n = 'objectNormal') : ((e.requires.normal = !0), (n = 'vObjectNormal')); break; case ho.WORLD: e.isShader('vertex') ? (n = 'inverseTransformDirection( transformedNormal, viewMatrix ).xyz') : ((e.requires.worldNormal = !0), (n = 'vWNormal')); break; } return e.format(n, this.getType(e), t); } }, Ui = ho; (Ui.LOCAL = 'local'), (Ui.WORLD = 'world'), (Ui.VIEW = 'view'), (Ui.NORMAL = 'normal'); Ni.addKeyword('viewNormal', function () { return new Ui(Ui.VIEW); }); Ni.addKeyword('localNormal', function () { return new Ui(Ui.NORMAL); }); Ni.addKeyword('worldNormal', function () { return new Ui(Ui.WORLD); }); var Fs = class extends St { constructor(e) { super('v3'), (this.nodeType = 'Position'), (this.scope = e ?? Fs.LOCAL); } getType() { switch (this.scope) { case Fs.PROJECTION: return 'v4'; } return this.type; } getShader() { switch (this.scope) { case Fs.LOCAL: case Fs.WORLD: return !1; } return !0; } generate(e, t, i, r, s) { let n; switch (this.scope) { case Fs.LOCAL: e.isShader('vertex') ? (n = 'transformed') : ((e.requires.position = !0), (n = 'vPosition')); break; case Fs.WORLD: if (e.isShader('vertex')) return '( modelMatrix * vec4( transformed, 1.0 ) ).xyz'; (e.requires.worldPosition = !0), (n = 'vWPosition'); break; case Fs.VIEW: n = e.isShader('vertex') ? '-mvPosition.xyz' : 'vViewPosition'; break; case Fs.PROJECTION: n = e.isShader('vertex') ? '( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )' : 'vec4( 0.0 )'; break; } return e.format(n, this.getType(), t); } }, jr = Fs; (jr.LOCAL = 'local'), (jr.WORLD = 'world'), (jr.VIEW = 'view'), (jr.PROJECTION = 'projection'); Ni.addKeyword('position', function () { return new jr(); }); Ni.addKeyword('worldPosition', function () { return new jr(jr.WORLD); }); Ni.addKeyword('viewPosition', function () { return new jr(jr.VIEW); }); var is = class extends St { constructor(e) { super('v3'), (this.nodeType = 'Reflect'), (this.scope = e ?? is.CUBE); } getUnique(e) { return !e.context.viewNormal; } getType() { switch (this.scope) { case is.SPHERE: return 'v2'; } return this.type; } generate(e, t) { let i = this.getUnique(e); if (e.isShader('fragment')) { let r; switch (this.scope) { case is.VECTOR: { let s = new Ui(Ui.VIEW), n = e.context.roughness, a = s.build(e, 'v3'), o = new jr(jr.VIEW).build(e, 'v3'), l = n ? n.build(e, 'f') : void 0, h = `reflect( -normalize( ${o} ), ${a} )`; l && (h = `normalize( mix( ${h}, ${a}, ${l} * ${l} ) )`); let u = `inverseTransformDirection( ${h}, viewMatrix )`; i ? (e.addNodeCode(`vec3 reflectVec = ${u};`), (r = 'reflectVec')) : (r = u); break; } case is.CUBE: { let s = new is(is.VECTOR).build(e, 'v3'), n = 'vec3( -' + s + '.x, ' + s + '.yz )'; i ? (e.addNodeCode(`vec3 reflectCubeVec = ${n};`), (r = 'reflectCubeVec')) : (r = n); break; } case is.SPHERE: { let s = 'normalize( ( viewMatrix * vec4( ' + new is(is.VECTOR).build(e, 'v3') + ', 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5'; i ? (e.addNodeCode(`vec2 reflectSphereVec = ${s};`), (r = 'reflectSphereVec')) : (r = s); break; } } return e.format(r, this.getType(), t); } else return console.warn('ReflectNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.type, t); } }, Oo = is; (Oo.CUBE = 'cube'), (Oo.SPHERE = 'sphere'), (Oo.VECTOR = 'vector'); var Q6 = class extends St { constructor(e = new An(), t, i) { super('v4'), (this.nodeType = 'TextureCube'), (this.value = e), (this.radianceNode = new Fm(this.value, t ?? new Oo(Oo.VECTOR), i)), (this.irradianceNode = new Fm(this.value, new Ui(Ui.WORLD), new Pe(1).setReadonly(!0))); } generate(e, t) { return e.isShader('fragment') ? (e.require('irradiance'), e.context.bias && e.context.bias.setTexture(this.value), (e.slot === 'irradiance' ? this.irradianceNode : this.radianceNode).build(e, t)) : (console.warn('TextureCubeNode is not compatible with ' + e.shader + ' shader.'), e.format('vec4( 0.0 )', this.getType(e), t)); } }, Z6 = class extends or { constructor(e = new cg(), t, i) { super('v4', { shared: !0 }), (this.nodeType = 'CubeTexture'), (this.value = e), (this.uv = t ?? new Oo()), (this.bias = i); } getTexture(e, t) { return super.generate(e, t, this.value.uuid, 'tc'); } generate(e, t) { if (t === 'samplerCube') return this.getTexture(e, t); let i = this.getTexture(e, t), r = this.uv?.build(e, 'v3'), s = this.bias ? this.bias.build(e, 'f') : void 0; s === void 0 && e.context.bias && (s = e.context.bias.setTexture(this).build(e, 'f')); let n; s ? (n = 'texCubeBias( ' + i + ', ' + r + ', ' + s + ' )') : (n = 'texCube( ' + i + ', ' + r + ' )'); let a = { include: e.isShader('vertex'), ignoreCache: !0 }, o = this.getType(e); return ( e.addContext(a), (this.colorSpace = this.colorSpace ?? new hs(new Pt('', o))), this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)), this.colorSpace.input.parse(n), (n = this.colorSpace.build(e, o)), e.removeContext(), e.format(n, o, t) ); } }, kx = ['x', 'y', 'z', 'w'], K6 = ['float', 'vec2', 'vec3', 'vec4'], J6 = { float: 'f', vec2: 'v2', vec3: 'v3', vec4: 'v4', mat4: 'v4', int: 'i', bool: 'b', 'float[]': 'f[]', 'vec4[]': 'v4[]' }, $6 = { t: 'sampler2D', tc: 'samplerCube', b: 'bool', i: 'int', f: 'float', c: 'vec3', v2: 'vec2', v3: 'vec3', v4: 'vec4', m3: 'mat3', m4: 'mat4', 'f[]': 'float[]', 'v4[]': 'vec4[]' }, ek = class { constructor() { (this.includes = { consts: {}, functions: {}, structs: {} }), (this.cache = ''), (this.slot = ''), (this.shader = ''), (this.context = {}), (this.getIncludesCode = (function () { function e(t, i) { return t.deps.length - i.deps.length; } return function (t, i) { let r = this.getIncludes(t, i); if (!r) return ''; let s = ''; r = r.sort(e); for (let n = 0; n < r.length; n++) r[n].src && (s += r[n].src + ` `); return s; }; })()), (this.slots = []), (this.caches = []), (this.contexts = []), (this.keywords = {}), (this.nodeData = {}), (this.fragmentVariables = {}), (this.fragmentParsVariables = {}), (this.vertexParsVariables = {}), (this.requires = { uv: [], color: [], transparent: !1, irradiance: !1, position: !1, worldPosition: !1, normal: !1, worldNormal: !1, vWorldViewDir: !1, modelMatrix: !1, viewMatrix: !1, projectionMatrix: !1 }), (this.includes = { consts: [], functions: [], structs: [] }), (this.attributes = {}), (this.prefixCode = [ '#ifdef TEXTURE_LOD_EXT', '\t#define texCube(a, b) textureCube(a, b)', '\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)', '\t#define tex2D(a, b) texture2D(a, b)', '\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)', '#else', '\t#define texCube(a, b) textureCube(a, b)', '\t#define texCubeBias(a, b, c) textureCube(a, b, c)', '\t#define tex2D(a, b) texture2D(a, b)', '\t#define tex2DBias(a, b, c) texture2D(a, b, c)', '#endif', ` // NOTE: Include Spline's blending modes. This could be part of BlendNode #define SPE_BLENDING_NORMAL 0 #define SPE_BLENDING_MULTIPLY 1 #define SPE_BLENDING_SCREEN 2 #define SPE_BLENDING_OVERLAY 3 vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) { return mix( a, b, alpha ); } vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) { return mix( a, a * b, alpha ); } vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) { vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b ); return mix( a, tmp, alpha ); } vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) { vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) ); return clamp( mix( a, tmp, alpha ), 0.0, 1.0 ); } vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) { if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha ); else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha ); else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha ); else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha ); return vec3( 1.0 ); } `, '#include ', '#include ' ].join(` `)), (this.parsCode = { vertex: ['float neighbor_offset = 0.0001;', ''].join(` `), fragment: [ 'float accumAlpha = 0.0;', `void accumulateAlpha(float alpha) { accumAlpha += (1.0 - accumAlpha) * alpha; }`, '' ].join(` `) }), (this.code = { vertex: '', fragment: '' }), (this.nodeCode = { vertex: '', fragment: '' }), (this.resultCode = { vertex: '', fragment: '' }), (this.finalCode = { vertex: '', fragment: '' }), (this.inputs = { uniforms: { list: [], vertex: [], fragment: [] }, arrayUniforms: { list: [], vertex: [], fragment: [] }, vars: { varying: [], vertex: [], fragment: [] } }), (this.defines = {}), (this.uniforms = {}), (this.extensions = { derivatives: !1, fragDepth: !1, drawBuffers: !1, shaderTextureLOD: !1 }), (this.updaters = []), (this.nodes = []), (this.analyzing = !1); } build(e, t) { this.buildShader('vertex', e), this.buildShader('fragment', t); for (let i = 0; i < this.requires.uv.length; i++) if (this.requires.uv[i]) { let r = i > 0 ? i + 1 : ''; this.addVaryCode('varying vec2 vUv' + r + ';'), i > 0 && this.addVertexParsCode('attribute vec2 uv' + r + ';'), this.addVertexFinalCode('vUv' + r + ' = uv' + r + ';'); } return ( this.requires.color[0] && (this.addVaryCode('varying vec4 vColor;'), this.addVertexParsCode('attribute vec4 color;'), this.addVertexFinalCode('vColor = color;')), this.requires.color[1] && (this.addVaryCode('varying vec4 vColor2;'), this.addVertexParsCode('attribute vec4 color2;'), this.addVertexFinalCode('vColor2 = color2;')), this.requires.position && (this.addVaryCode('varying vec3 vPosition;'), this.addVertexFinalCode('vPosition = transformed;')), this.requires.worldPosition, this.requires.normal && (this.addVaryCode('varying vec3 vObjectNormal;'), this.addVertexFinalCode('vObjectNormal = normal;')), this.requires.modelMatrix && this.addFragmentParsCode('uniform mat4 modelMatrix;'), this.requires.viewMatrix && this.addFragmentParsCode('uniform mat4 viewMatrix;'), this.requires.projectionMatrix && this.addFragmentParsCode('uniform mat4 projectionMatrix;'), this.requires.worldNormal && (this.addVaryCode('varying vec3 vWNormal;'), this.addVertexFinalCode('vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;')), this.requires.vWorldViewDir && (this.addVaryCode('varying vec3 vWorldViewDir;'), this.addVertexFinalCode( 'vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );' )), this ); } buildShader(e, t) { this.resultCode[e] = t.build(this.setShader(e), 'v4'); } setMaterial(e, t) { return (this.defines = {}), this; } addFlow(e, t, i) { return this.addSlot(e).addCache(t).addContext(i); } removeFlow() { return this.removeSlot().removeCache().removeContext(); } addCache(e) { return (this.cache = e ?? ''), this.caches.push(this.cache), this; } removeCache() { return this.caches.pop(), (this.cache = this.caches[this.caches.length - 1] || ''), this; } addContext(e) { return ( (this.context = Object.assign({}, this.context, e)), (this.context.extra = this.context.extra || {}), this.contexts.push(this.context), this ); } removeContext() { return this.contexts.pop(), (this.context = this.contexts[this.contexts.length - 1] || {}), this; } addSlot(e) { return (this.slot = e || ''), this.slots.push(this.slot), this; } removeSlot() { return this.slots.pop(), (this.slot = this.slots[this.slots.length - 1] || ''), this; } addFragmentVariable(e, t) { this.fragmentVariables[e] === void 0 && (this.addFragmentCode(`${t} ${e};`), (this.fragmentVariables[e] = '')); } addFragmentParsVariable(e, t) { this.fragmentParsVariables[e] === void 0 && (this.addFragmentParsCode(`${t} ${e};`), (this.fragmentParsVariables[e] = '')); } addVertexParsVariable(e, t) { this.vertexParsVariables[e] === void 0 && (this.addVertexParsCode(`${t} ${e};`), (this.vertexParsVariables[e] = '')); } addVertexCode(e) { this.addCode(e, 'vertex'); } addFragmentCode(e) { this.addCode(e, 'fragment'); } addCode(e, t) { this.code[t ?? this.shader] += e + ` `; } addVertexNodeCode(e) { this.addNodeCode(e, 'vertex'); } addFragmentNodeCode(e) { this.addNodeCode(e, 'fragment'); } addNodeCode(e, t) { this.nodeCode[t ?? this.shader] += e + ` `; } clearNodeCode(e) { e = e ?? this.shader; let t = this.nodeCode[e]; return (this.nodeCode[e] = ''), t; } clearVertexNodeCode() { return this.clearNodeCode('vertex'); } clearFragmentNodeCode() { return this.clearNodeCode('fragment'); } addVertexFinalCode(e) { this.addFinalCode(e, 'vertex'); } addFragmentFinalCode(e) { this.addFinalCode(e, 'fragment'); } addFinalCode(e, t) { this.finalCode[t ?? this.shader] += e + ` `; } addVertexParsCode(e) { this.addParsCode(e, 'vertex'); } addFragmentParsCode(e) { this.addParsCode(e, 'fragment'); } addParsCode(e, t) { this.parsCode[t ?? this.shader] += e + ` `; } addVaryCode(e) { this.addVertexParsCode(e), this.addFragmentParsCode(e); } isCache(e) { return this.caches.indexOf(e) !== -1; } isSlot(e) { return this.slots.indexOf(e) !== -1; } define(e, t) { this.defines[e] = t === void 0 ? 1 : t; } require(e) { this.requires[e] = !0; } isDefined(e) { return this.defines[e] !== void 0; } getVar(e, t, i, r = 'varying', s = 'V', n = '') { let a = this.getVars(r), o = a[e]; if (!o) { let l = a.length; (o = { name: i || 'node' + s + l + (n ? '_' + n : ''), type: t }), a.push(o), (a[e] = o); } return o; } getTempVar(e, t, i, r) { return this.getVar(e, t, i, this.shader, 'T', r); } getAttribute(e, t) { if (!this.attributes[e]) { let i = this.getVar(e, t); this.addVertexParsCode('attribute ' + t + ' ' + e + ';'), this.addVertexFinalCode(i.name + ' = ' + e + ';'), (this.attributes[e] = { varying: i, name: e, type: t }); } return this.attributes[e]; } getCode(e) { return [ this.prefixCode, this.parsCode[e], this.getVarListCode(this.getVars('varying'), 'varying'), this.getVarListCode(this.inputs.uniforms[e], 'uniform'), this.getVarListCode(this.inputs.arrayUniforms[e], 'uniform'), this.getIncludesCode('consts', e), this.getIncludesCode('structs', e), this.getIncludesCode('functions', e), 'void main() {', this.getVarListCode(this.getVars(e)), this.code[e], this.resultCode[e], this.finalCode[e], '}' ].join(` `); } getVarListCode(e, t) { t = t ?? ''; let i = ''; for (let r = 0, s = e.length; r < s; ++r) { let n = e[r], a = n.type, o = n.name, l = n.size, h = this.getFormatByType(a); if (h === void 0) throw new Error('Node pars ' + h + ' not found.'); h.includes('[]') ? (i += t + ' ' + h.substring(0, h.length - 2) + ' ' + o + `[${l}]; `) : (i += t + ' ' + h + ' ' + o + `; `); } return i; } getVars(e) { return this.inputs.vars[e ?? this.shader]; } getNodeData(e) { let t = e instanceof Bn ? e.uuid : e; return (this.nodeData[t] = this.nodeData[t] || {}); } createUniform(e, t, i, r, s, n) { if (t.includes('[]')) { let a = this.inputs.arrayUniforms, o = a.list.length, l = new Nx({ type: t, size: i.size, name: r || 'nodeUA' + o + (n ? '_' + n : ''), node: i, needsUpdate: s }); return a.list.push(l), a[e].push(l), (a[e][l.name] = l), (this.uniforms[l.name] = l), l; } else { let a = this.inputs.uniforms, o = a.list.length, l = new Nx({ type: t, name: r || 'nodeU' + o + (n ? '_' + n : ''), node: i, needsUpdate: s }); return a.list.push(l), a[e].push(l), (a[e][l.name] = l), (this.uniforms[l.name] = l), l; } } createVertexUniform(e, t, i, r, s) { return this.createUniform('vertex', e, t, i, r, s); } createFragmentUniform(e, t, i, r, s) { return this.createUniform('fragment', e, t, i, r, s); } include(e, t, i) { let r; if (((e = typeof e == 'string' ? Ni.get(e) : e), this.context.include === !1)) return e.name; e instanceof Re ? (r = this.includes.functions) : e instanceof vt ? (r = this.includes.consts) : e instanceof FA && (r = this.includes.structs); let s = (r[this.shader] = r[this.shader] || []); if (e) { let n = s[e.name]; if ( (n || ((n = s[e.name] = { node: e, deps: [] }), s.push(n), (n.src = e.build(this, 'source'))), e instanceof Re && t && s[t.name] && s[t.name].deps.indexOf(e) === -1 && (s[t.name].deps.push(e), e.includes?.length)) ) { let a = 0; do { this.include(e.includes[a++], t); } while (a < e.includes.length); } return i && (n.src = i), e.name; } else throw new Error('Include not found.'); } colorToVectorProperties(e) { return e.replace('r', 'x').replace('g', 'y').replace('b', 'z').replace('a', 'w'); } colorToVector(e) { return e.replace(/c/g, 'v3'); } getIncludes(e, t) { return this.includes[e][t || this.shader]; } getConstructorFromLength(e) { return K6[e - 1]; } isTypeMatrix(e) { return /^m/.test(e); } getTypeLength(e) { return e === 'f' ? 1 : parseInt(this.colorToVector(e).substr(1)); } getTypeFromLength(e) { return e === 1 ? 'f' : 'v' + e; } findNode(...e) { for (let t = 0; t < arguments.length; t++) { let i = e[t]; if (i?.isNode) return i; } } resolve(...e) { for (let t = 0; t < arguments.length; t++) { let i = e[t]; if (i !== void 0) { if (i.isNode) return i; if (i.isTexture) switch (i.mapping) { case ya: case xa: return new Z6(i); case Ch: return new Q6(new An(i)); default: return new An(i); } else { if (i.isVector2) return new vr(i); if (i.isVector3) return new fr(i); if (i.isVector4) return new na(i); } } } } format(e, t, i) { switch (this.colorToVector(i + ' <- ' + t)) { case 'f <- v2': return e + '.x'; case 'f <- v3': return e + '.x'; case 'f <- v4': return e + '.x'; case 'f <- i': case 'f <- b': return 'float( ' + e + ' )'; case 'v2 <- f': return 'vec2( ' + e + ' )'; case 'v2 <- v3': return e + '.xy'; case 'v2 <- v4': return e + '.xy'; case 'v2 <- i': case 'v2 <- b': return 'vec2( float( ' + e + ' ) )'; case 'v3 <- f': return 'vec3( ' + e + ' )'; case 'v3 <- v2': return 'vec3( ' + e + ', 0.0 )'; case 'v3 <- v4': return e + '.xyz'; case 'v3 <- i': case 'v3 <- b': return 'vec2( float( ' + e + ' ) )'; case 'v4 <- f': return 'vec4( ' + e + ' )'; case 'v4 <- v2': return 'vec4( ' + e + ', 0.0, 1.0 )'; case 'v4 <- v3': return 'vec4( ' + e + ', 1.0 )'; case 'v4 <- i': case 'v4 <- b': return 'vec4( float( ' + e + ' ) )'; case 'i <- f': case 'i <- b': return 'int( ' + e + ' )'; case 'i <- v2': return 'int( ' + e + '.x )'; case 'i <- v3': return 'int( ' + e + '.x )'; case 'i <- v4': return 'int( ' + e + '.x )'; case 'b <- f': return '( ' + e + ' != 0.0 )'; case 'b <- v2': return '( ' + e + ' != vec2( 0.0 ) )'; case 'b <- v3': return '( ' + e + ' != vec3( 0.0 ) )'; case 'b <- v4': return '( ' + e + ' != vec4( 0.0 ) )'; case 'b <- i': return '( ' + e + ' != 0 )'; } return e; } getTypeByFormat(e) { return J6[e] || e; } getFormatByType(e) { return $6[e] || e; } getUUID(e, t) { return (t = t !== void 0 ? t : !0), t && this.cache && (e = this.cache + '-' + e), e; } getElementByIndex(e) { return kx[e]; } getIndexByElement(e) { return kx.indexOf(e); } isShader(e) { return this.shader === e; } setShader(e) { return (this.shader = e), this; } mergeDefines(e) { for (let t in e) this.defines[t] = e[t]; return this.defines; } mergeUniform(e) { for (let t in e) this.uniforms[t] = e[t]; return this.uniforms; } getTextureEncodingFromMap(e) { let t; return e ? e.isTexture && (t = e.encoding) : (t = gs), t === gs && this.context.gamma && (t = Ke), t; } }, Ut = class extends or { constructor(e = 0, t, i, r) { super('c'), (this.nodeType = 'Color'), (this.value = e instanceof ji ? e : new ji(e || 0, t, i, r)); } setRGBA(e) { this.value.setRGBA(e.r, e.g, e.b, e.a); } generate(e, t, i, r, s, n) { (i = e.getUUID(i ?? this.getUUID())), (r = r ?? this.getType(e)); let a = e.getNodeData(i), o = this.getReadonly() && this.generateReadonly !== void 0; if (this.alpha) { let l = this.alpha.build(e, 'f'); e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`); } return o ? this.generateReadonly(e, t, i, r, s, n) : e.isShader('vertex') ? (a.vertex || (a.vertex = e.createVertexUniform(r, this, s, n, this.getLabel())), e.format(a.vertex.name, r, t)) : (a.fragment || (a.fragment = e.createFragmentUniform(r, this, s, n, this.getLabel())), e.format(a.fragment.name, r, t)); } generateReadonly(e, t, i, r, s, n) { return e.format('vec3(' + this.value.r + ', ' + this.value.g + ', ' + this.value.b + ')', r, t); } }, xt = class extends or { constructor(e) { super('i'), (this.nodeType = 'Int'), (this.value = Math.floor(e ?? 0)); } generateReadonly(e, t, i, r, s, n) { return e.format(this.value.toString(), r, t); } }, jA = class extends Bn { constructor() { super('basic'), (this.nodeType = 'Basic'), (this.color = new Ut(5526619)), (this.shadingAlpha = new Pe(1)), (this.shadingBlend = new xt(0)); } get category() { return 'phong'; } generate(e) { let t; if (e.isShader('vertex')) { let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0; e.mergeUniform(qo.merge([ge.fog])), e.addParsCode( ['varying vec3 vViewPosition;', 'varying vec3 vWPosition;', '#include ', '#include '] .join(` `) ); let r = [ '#include ', ` #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `, '#include ', ` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ ` ]; i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''), r.push( 'transformed = displaced_position;', 'transformedNormal = normalMatrix * displaced_normal;', '#ifndef FLAT_SHADED', '\tvNormal = transformedNormal;', '#endif' ), r.push( '#include ', '#include ', '#include ', '\tvViewPosition = - mvPosition.xyz;', '#include ' ), r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'), (t = r.join(` `)); } else { this.color === void 0 && (this.color = new Ut(5526619)), this.color.analyze(e, { slot: 'color' }), this.alpha && this.alpha.analyze(e), this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }); let i = this.color.flow(e, 'c', { slot: 'color' }), r = this.alpha ? this.alpha.flow(e, 'f') : void 0, s = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0; (e.requires.transparent = r !== void 0), e.addParsCode( [ 'varying vec3 vWPosition;', '#include ', '#include ', 'varying vec3 vViewPosition;', '#include ' ].join(` `) ); let n = ['#include ', i.code]; r && n.push(r.code, '#ifdef ALPHATEST', ' if ( ' + r.result + ' <= ALPHATEST ) discard;', '#endif'), s ? n.push( s.code, `vec3 outgoingLight = ${i.result};`, `vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);` ) : n.push(`vec3 finalColor = ${i.result};`), r ? n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${r.result} );`) : n.push('gl_FragColor = vec4(' + i.result + ', 1.0 );'), n.push('#include ', '#include '), (t = n.join(` `)); } return t; } }, ea = class extends or { constructor(e = 1, t) { super('f[]'), (this.nodeType = 'FloatArray'), (this.size = e), (this.value = Array.isArray(t) ? t : typeof t == 'number' ? new Array(e).fill(t) : new Array(e).fill(0)); } }, Lt = { normalRenderTarget: new An(), normalRenderTargetDepth: new An(), transmissionRenderTarget: new An(), transmissionSize: new vr(2048, 2048), transmissionRenderTargetDepth: new An(), pixelRatioNode: new Pe(1), resolution: new vr(), penumbraSize: new ea(5, 0.5) }; for (let e of Object.values(Lt)) e.isRenderGlobal = !0; var tk = class extends Bn { constructor() { super('lambert'), (this.nodeType = 'Lambert'), (this.color = new Ut(5526619)), (this.emissive = new Ut(0)), (this.emissiveIntensity = new Pe(1)), (this.shadingAlpha = new Pe(1)), (this.shadingBlend = new xt(0)); } get category() { return 'lambert'; } build(e) { let t; if ((e.define('LAMBERT'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) { let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0; e.mergeUniform(qo.merge([ge.fog, ge.lights])), e.addParsCode( [ 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', 'varying vec3 vLightFront;', 'varying vec3 vIndirectFront;', '#ifndef DOUBLE_SIDED', ' #define DOUBLE_SIDED', '#endif', '#ifdef DOUBLE_SIDED', '\tvarying vec3 vLightBack;', '\tvarying vec3 vIndirectBack;', '#endif', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let r = [ '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `, '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif ` ]; i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''), r.push( 'transformed = displaced_position;', 'transformedNormal = normalMatrix * displaced_normal;', '#ifndef FLAT_SHADED', ' vNormal = transformedNormal;', '#endif' ), r.push( '\t#include ', '\t#include ', '\tvViewPosition = - mvPosition.xyz;', '\t#include ', ` vec3 diffuse = vec3( 1.0 ); GeometricContext geometry; geometry.position = mvPosition.xyz; geometry.normal = normalize( transformedNormal ); geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); GeometricContext backGeometry; backGeometry.position = geometry.position; backGeometry.normal = -geometry.normal; backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); #endif IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); #ifdef DOUBLE_SIDED vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); #endif #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { getPointLightInfo( pointLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { getSpotLightInfo( spotLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); dotNL = dot( geometry.normal, directLight.direction ); directLightColor_Diffuse = directLight.color; vLightFront += saturate( dotNL ) * directLightColor_Diffuse; #ifdef DOUBLE_SIDED vLightBack += saturate( -dotNL ) * directLightColor_Diffuse; #endif } #pragma unroll_loop_end #endif #if NUM_HEMI_LIGHTS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); #ifdef DOUBLE_SIDED vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); #endif } #pragma unroll_loop_end #endif `, '\t#include ', '\t#include ' ), r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'), (t = r.join(` `)); } else { e.mergeUniform({ penumbraSize: Lt.penumbraSize }), this.color === void 0 && (this.color = new Ut(5526619)), this.color.analyze(e, { slot: 'color' }), this.shadingAlpha.analyze(e), this.shadingBlend.analyze(e), this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }), this.alpha && this.alpha.analyze(e); let i = this.color.flow(e, 'c', { slot: 'color' }), r = this.emissive.flow(e, 'c', { slot: 'emissive' }), s = this.emissiveIntensity.flow(e, 'f', { slot: 'emissive' }), n = this.shadingAlpha.flow(e, 'f'), a = this.shadingBlend.flow(e, 'i'), o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0, l = this.alpha ? this.alpha.flow(e, 'f') : void 0; (e.requires.transparent = l !== void 0), e.addParsCode( [ `uniform float penumbraSize[${5}];`, 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', 'varying vec3 vLightFront;', 'varying vec3 vIndirectFront;', '#ifndef DOUBLE_SIDED', ' #define DOUBLE_SIDED', '#endif', '#include ', '#ifdef DOUBLE_SIDED', '\tvarying vec3 vLightBack;', '\tvarying vec3 vIndirectBack;', '#endif', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let h = [ '#include ', ` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx, viewdy)); bool isFrontFacing = (dot(normal, faceNormal) >= 0.0); `, '#include ' ]; h.push( i.code, 'vec3 diffuseColor = ' + i.result + ';', 'ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );' ), l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'), h.push( '#ifdef DOUBLE_SIDED', '\treflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;', '#else', '\treflectedLight.indirectDiffuse += vIndirectFront;', '#endif', '#include ', 'reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );', '#ifdef DOUBLE_SIDED', '\treflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;', '#else', '\treflectedLight.directDiffuse = vLightFront;', '#endif', 'reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();' ), r && h.push(r.code, 'reflectedLight.directDiffuse += ' + r.result + ' * ' + s.result + ';'), h.push('vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;'), h.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} ); } `), o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`), l ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`) : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'), h.push('#include ', '#include ', '#include '), (t = h.join(` `)); } return t; } }, ik = class extends Bn { constructor() { super('phong'), (this.nodeType = 'Phong'), (this.color = new Ut(5526619)), (this.specular = new Ut(1118481)), (this.shininess = new Pe(30)), (this.shadingAlpha = new Pe(1)), (this.shadingBlend = new xt(0)); } get category() { return 'phong'; } build(e) { let t; if ((e.define('PHONG'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) { let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0; e.mergeUniform(qo.merge([ge.fog, ge.lights])), e.addParsCode( [ 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let r = [ '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `, '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif ` ]; i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''), r.push( 'transformed = displaced_position;', 'transformedNormal = normalMatrix * displaced_normal;', '#ifndef FLAT_SHADED', ' vNormal = transformedNormal;', '#endif' ), r.push( '\t#include ', '\t#include ', '\tvViewPosition = - mvPosition.xyz;', '\t#include ', '\t#include ', '\t#include ' ), r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'), (t = r.join(` `)); } else { e.mergeUniform({ penumbraSize: Lt.penumbraSize }), this.color === void 0 && (this.color = new Ut(5526619)), this.color.analyze(e, { slot: 'color' }), this.specular.analyze(e), this.shininess.analyze(e), this.shadingAlpha.analyze(e), this.shadingBlend.analyze(e), this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }), this.alpha && this.alpha.analyze(e); let i = this.color.flow(e, 'c', { slot: 'color' }), r = this.specular.flow(e, 'c'), s = this.shininess.flow(e, 'f'), n = this.shadingAlpha.flow(e, 'f'), a = this.shadingBlend.flow(e, 'i'), o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0, l = this.alpha ? this.alpha.flow(e, 'f') : void 0; (e.requires.transparent = l !== void 0), e.addParsCode( [ 'varying vec3 vWPosition;', 'uniform vec3 emissive;', `uniform float penumbraSize[${5}];`, '#include ', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let h = [ '#include ', ` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `, '\tBlinnPhongMaterial material;' ]; h.push( i.code, '\tvec3 diffuseColor = ' + i.result + ';', '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );', '\tvec3 totalEmissiveRadiance = emissive;', r.code, '\tvec3 specular = ' + r.result + ';', s.code, '\tfloat shininess = max( 0.0001, ' + s.result + ' );', '\tfloat specularStrength = 1.0;' ), l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'), h.push('material.diffuseColor = diffuseColor;'), h.push( 'material.specularColor = specular;', 'material.specularShininess = shininess;', 'material.specularStrength = specularStrength;', '#include ', '#include ' ), h.push( 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;' ), h.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} ); } `), o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`), l ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`) : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'), h.push('#include ', '#include ', '#include '), (t = h.join(` `)); } return t; } }, rk = class extends Bn { constructor() { super('standard'), (this.nodeType = 'Standard'), (this.color = new Ut(5526619)), (this.roughness = new Pe(0.3)), (this.metalness = new Pe(0)), (this.reflectivity = new Pe(0.5)), (this.shadingAlpha = new Pe(1)), (this.shadingBlend = new xt(0)); } get category() { return 'physical'; } build(e) { let t; if ( (e.define('STANDARD'), (e.requires.lights = !0), (e.extensions.derivatives = !0), (e.extensions.shaderTextureLOD = !0), e.isShader('vertex')) ) { let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0; e.mergeUniform(qo.merge([ge.fog, ge.lights])), ge.LTC_1 && ((e.uniforms.ltc_1 = { value: void 0 }), (e.uniforms.ltc_2 = { value: void 0 })), e.addParsCode( [ 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let r = [ '#include ', ` #if !defined( USE_LAYER_DISPLACE ) #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #if defined( USE_LAYER_DISPLACE ) vec3 transformed; vec3 transformedNormal; #endif `, '#include ', ` #if !defined( USE_LAYER_DISPLACE ) #include #endif /* !USE_LAYER_DISPLACE */ ` ]; i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''), r.push( 'transformed = displaced_position;', 'transformedNormal = normalMatrix * displaced_normal;', '#ifndef FLAT_SHADED', ' vNormal = transformedNormal;', '#endif' ), r.push( '#include ', '#include ', '#include ', '\tvViewPosition = - mvPosition.xyz;', '#include ', '#include ' ), r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'), (t = r.join(` `)); } else { e.mergeUniform({ penumbraSize: Lt.penumbraSize }); let i = { gamma: !0 }; this.color === void 0 && (this.color = new Ut(5526619)), this.color.analyze(e, { slot: 'color', context: i }), this.roughness.analyze(e), this.metalness.analyze(e), this.shadingAlpha.analyze(e), this.shadingBlend.analyze(e), this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }), this.alpha && this.alpha.analyze(e), this.reflectivity && this.reflectivity.analyze(e); let r = this.color.flow(e, 'c', { slot: 'color', context: i }), s = this.roughness.flow(e, 'f'), n = this.metalness.flow(e, 'f'), a = this.shadingAlpha.flow(e, 'f'), o = this.shadingBlend.flow(e, 'i'), l = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0, h = this.alpha ? this.alpha.flow(e, 'f') : void 0, u = this.reflectivity ? this.reflectivity.flow(e, 'f') : void 0; (e.requires.transparent = h !== void 0), e.addParsCode( [ 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', `uniform float penumbraSize[${5}];`, '#include ', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let c = [ '#include ', '\t#include ', ` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `, '\tPhysicalMaterial material;', '\tmaterial.diffuseColor = vec3( 1.0 );' ]; c.push( r.code, '\tvec3 diffuseColor = ' + r.result + ';', '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );', s.code, '\tfloat roughnessFactor = ' + s.result + ';', n.code, '\tfloat metalnessFactor = ' + n.result + ';' ), h && c.push(h.code, '#ifdef ALPHATEST', '\tif ( ' + h.result + ' <= ALPHATEST ) discard;', '#endif'), c.push( 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );' ), c.push( 'material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );', 'material.roughness = max( roughnessFactor, 0.0525 );', 'material.roughness += geometryRoughness;', 'material.roughness = min( material.roughness, 1.0 );', 'material.roughness = clamp( roughnessFactor, 0.04, 1.0 );' ), u ? c.push(u.code, 'material.specularColor = mix( vec3( 0.16 * pow2( ' + u.result + ' ) ), diffuseColor, metalnessFactor );') : c.push('material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );'), c.push('#include '), c.push('#include '), c.push( 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;' ), c.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${o.result} ); } `), l && c.push(l.code, `outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`), h ? c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`) : c.push('gl_FragColor = vec4( outgoingLight, 1.0 );'), c.push('#include ', '#include ', '#include '), (t = c.join(` `)); } return t; } }, sk = class extends Bn { constructor() { super('toon'), (this.nodeType = 'Toon'), (this.color = new Ut(5526619)), (this.specular = new Ut(1118481)), (this.shininess = new Pe(30)), (this.shadingAlpha = new Pe(1)), (this.shadingBlend = new xt(0)); } get category() { return 'toon'; } build(e) { let t; if ((e.define('TOON'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) { let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0; e.mergeUniform(qo.merge([ge.fog, ge.lights])), e.addParsCode( [ 'varying vec3 vViewPosition;', 'varying vec3 vWPosition;', '#include ', '#include ', '#include ', '#include ' ].join(` `) ); let r = [ '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif vec3 displaced_position = position; vec3 displaced_normal = normal; #ifdef USE_LAYER_DISPLACE vec3 transformed; vec3 transformedNormal; #endif `, '#include ', ` #ifndef USE_LAYER_DISPLACE #include #endif ` ]; i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''), r.push( 'transformed = displaced_position;', 'transformedNormal = normalMatrix * displaced_normal;', '#ifndef FLAT_SHADED', ' vNormal = transformedNormal;', '#endif' ), r.push( '\t#include ', '\t#include ', '\t#include ', '\tvViewPosition = - mvPosition.xyz;', '\t#include ', '\t#include ', '\t#include ' ), r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'), (t = r.join(` `)); } else { e.mergeUniform({ penumbraSize: Lt.penumbraSize }), this.color === void 0 && (this.color = new Ut(5526619)), this.color.analyze(e, { slot: 'color' }), this.specular.analyze(e), this.shininess.analyze(e), this.shadingAlpha.analyze(e), this.shadingBlend.analyze(e), this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }), this.alpha && this.alpha.analyze(e); let i = this.color.flow(e, 'c', { slot: 'color' }), r = this.specular.flow(e, 'c'), s = this.shininess.flow(e, 'f'), n = this.shadingAlpha.flow(e, 'f'), a = this.shadingBlend.flow(e, 'i'), o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0, l = this.alpha ? this.alpha.flow(e, 'f') : void 0; (e.requires.transparent = l !== void 0), e.addParsCode( [ `uniform float penumbraSize[${5}];`, 'varying vec3 vWPosition;', '#include ', '#include ', '#include ', '#include ', '#include ', '#include ', ` varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon #define Material_LightProbeLOD( material ) (0) `, '#include ', '#include ', '#include ' ].join(` `) ); let h = [ '#include ', ` // NOTE: gl_FrontFacing alternative using face normal estimation. vec3 viewdx = dFdx(vViewPosition); vec3 viewdy = dFdy(vViewPosition); vec3 faceNormal = normalize(cross(viewdx,viewdy)); if (dot(normal, faceNormal) < 0.0) { normal *= -1.0; } `, '\tToonMaterial material;' ]; h.push( i.code, '\tvec3 diffuseColor = ' + i.result + ';', '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );', r.code, '\tvec3 specular = ' + r.result + ';', s.code, '\tfloat shininess = max( 0.0001, ' + s.result + ' );', '\tfloat specularStrength = 1.0;' ), l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'), h.push('material.diffuseColor = diffuseColor;'), h.push( 'material.specularColor = specular;', 'material.specularShininess = shininess;', 'material.specularStrength = specularStrength;', '#include ', '#include ' ), h.push('vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;'), h.push(` if (outgoingLight != diffuseColor) { float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu; outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} ); } `), o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`), l ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`) : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'), h.push('#include ', '#include ', '#include '), (t = h.join(` `)); } return t; } }, Ol = class extends or { constructor(e) { super('b'), (this.nodeType = 'Bool'), (this.value = e ?? !1); } generateReadonly(e, t, i, r) { return e.format(this.value ? 'true' : 'false', r, t); } }, GA = class extends or { constructor(e) { super('m3'), (this.nodeType = 'Matrix3'), (this.value = e ?? new Ai()); } generateReadonly(e, t, i, r, s, n) { return e.format('mat3(' + this.value.elements.join(', ') + ')', r, t); } get elements() { return this.value.elements; } set elements(e) { this.value.fromArray(e); } }, ta = class extends or { constructor(e = 1, t) { super('v4[]'), (this.nodeType = 'Vector4Array'), (this.size = e), (this.value = Array.isArray(t) ? t : t instanceof $e ? new Array(e).fill(t) : new Array(e).fill(new $e(0))); } }, cv = ((e) => ( (e.SIMPLEX = 'simplex3d'), (e.SIMPLEX_FRACTAL = 'simplex3dFractal'), (e.ASHIMA = 'simplexAshima'), (e.FBM = 'fbm'), (e.PERLIN = 'perlin'), e ))(cv || {}), wr = (function () { let e = new Re(`vec3 random3(vec3 c) { float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); vec3 r; r.z = fract(512.0*j); j *= .125; r.x = fract(512.0*j); j *= .125; r.y = fract(512.0*j); return r-0.5; }`), t = new Re( `float simplex3d(vec3 p) { vec3 s = floor(p + dot(p, vec3(F3))); vec3 x = p - s + dot(s, vec3(G3)); vec3 e = step(vec3(0.0), x - x.yzx); vec3 i1 = e*(1.0 - e.zxy); vec3 i2 = 1.0 - e.zxy*(1.0 - e); vec3 x1 = x - i1 + G3; vec3 x2 = x - i2 + 2.0*G3; vec3 x3 = x - 1.0 + 3.0*G3; vec4 w, d; w.x = dot(x, x); w.y = dot(x1, x1); w.z = dot(x2, x2); w.w = dot(x3, x3); w = max(0.6 - w, 0.0); d.x = dot(random3(s), x); d.y = dot(random3(s + i1), x1); d.z = dot(random3(s + i2), x2); d.w = dot(random3(s + 1.0), x3); w *= w; w *= w; d *= w; return dot(d, vec4(52.0)); }`, [e] ); (t.keywords.F3 = new vt('float F3 0.3333333')), (t.keywords.G3 = new vt('float G3 0.1666667')); let i = new Re( `float simplex3dFractal(vec3 m) { mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4); mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63); mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56); return 0.5333333 * simplex3d(m * rot1) + 0.2666667 * simplex3d(2.0 * m * rot2) + 0.1333333 * simplex3d(4.0 * m * rot3) + 0.0666667 * simplex3d(8.0 * m); }`, [t] ), r = new Re('vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}'), s = new Re('vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}'), n = new Re( `float simplexAshima(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); vec3 x1 = x0 - i1 + 1.0 * C.xxx; vec3 x2 = x0 - i2 + 2.0 * C.xxx; vec3 x3 = x0 - 1. + 3.0 * C.xxx; i = mod(i, 289.0 ); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); float n_ = 1.0/7.0; // N=7 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); }`, [r, s] ), a = new Re('vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}'), o = new Re('vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}', [a]), l = new Re( `float noise(vec3 p){ vec3 a = floor(p); vec3 d = p - a; d = d * d * (3.0 - 2.0 * d); vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); vec4 k1 = perm(b.xyxy); vec4 k2 = perm(k1.xyxy + b.zzww); vec4 c = k2 + a.zzzz; vec4 k3 = perm(c); vec4 k4 = perm(c + 1.0); vec4 o1 = fract(k3 * (1.0 / 41.0)); vec4 o2 = fract(k4 * (1.0 / 41.0)); vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); return o4.y * d.y + o4.x * (1.0 - d.y); }`, [o] ), h = new Re( `float fbm(vec3 x) { float v = 0.0; float a = 0.5; vec3 shift = vec3(100); for (int i = 0; i < NUM_OCTAVES; ++i) { v += a * noise(x); x = x * 2.0 + shift; a *= 0.5; } return v; }`, [l] ); h.keywords.NUM_OCTAVES = new vt(`int NUM_OCTAVES ${5}`); let u = new Re('vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}'), c = new Re( `float perlin(vec3 P){ vec3 Pi0 = floor(P); vec3 Pi1 = Pi0 + vec3(1.0); Pi0 = mod(Pi0, 289.0); Pi1 = mod(Pi1, 289.0); vec3 Pf0 = fract(P); vec3 Pf1 = Pf0 - vec3(1.0); vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); vec4 iy = vec4(Pi0.yy, Pi1.yy); vec4 iz0 = Pi0.zzzz; vec4 iz1 = Pi1.zzzz; vec4 ixy = permute(permute(ix) + iy); vec4 ixy0 = permute(ixy + iz0); vec4 ixy1 = permute(ixy + iz1); vec4 gx0 = ixy0 / 7.0; vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5; gx0 = fract(gx0); vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0); vec4 sz0 = step(gz0, vec4(0.0)); gx0 -= sz0 * (step(0.0, gx0) - 0.5); gy0 -= sz0 * (step(0.0, gy0) - 0.5); vec4 gx1 = ixy1 / 7.0; vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5; gx1 = fract(gx1); vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1); vec4 sz1 = step(gz1, vec4(0.0)); gx1 -= sz1 * (step(0.0, gx1) - 0.5); gy1 -= sz1 * (step(0.0, gy1) - 0.5); vec3 g000 = vec3(gx0.x,gy0.x,gz0.x); vec3 g100 = vec3(gx0.y,gy0.y,gz0.y); vec3 g010 = vec3(gx0.z,gy0.z,gz0.z); vec3 g110 = vec3(gx0.w,gy0.w,gz0.w); vec3 g001 = vec3(gx1.x,gy1.x,gz1.x); vec3 g101 = vec3(gx1.y,gy1.y,gz1.y); vec3 g011 = vec3(gx1.z,gy1.z,gz1.z); vec3 g111 = vec3(gx1.w,gy1.w,gz1.w); vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); g000 *= norm0.x; g010 *= norm0.y; g100 *= norm0.z; g110 *= norm0.w; vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); g001 *= norm1.x; g011 *= norm1.y; g101 *= norm1.z; g111 *= norm1.w; float n000 = dot(g000, Pf0); float n100 = dot(g100, vec3(Pf1.x, Pf0.yz)); float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)); float n110 = dot(g110, vec3(Pf1.xy, Pf0.z)); float n001 = dot(g001, vec3(Pf0.xy, Pf1.z)); float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)); float n011 = dot(g011, vec3(Pf0.x, Pf1.yz)); float n111 = dot(g111, Pf1); vec3 fade_xyz = fade(Pf0); vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z); vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y); float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); return 2.2 * n_xyz; }`, [r, s, u] ); return { simplex: t, simplexFractal: i, simplexAshima: n, fbm: h, perlin: c }; })(), VA = class extends St { constructor(e, t, i, r, s, n, a, o, l, h, u, c) { super('v3'), (this.nodeType = 'Noise'), (this.scale = e), (this.size = t), (this.move = i), (this.fA = r), (this.fB = s), (this.distortion = n), (this.colorA = a), (this.colorB = o), (this.colorC = l), (this.colorD = h), (this.alpha = u), (this.noiseType = c), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t, i, r, s) { e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float'); let n = Object.values(cv)[this.noiseType.value], a = new Re( `vec3 ${n}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) { vec3 st = position / size; st /= scale; vec3 q = vec3(${n}(st), ${n}(st + vec3(1.0)), ${n}(st + vec3(1.0))); vec3 r = vec3(${n}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move), ${n}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), ${n}(st * q)); float f = ${n}(st + r); vec4 color; color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0)); color = mix(color, colorC, clamp(length(q), 0.0, 1.0)); color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0)); float lalpha = alpha * color.a; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return clamp(color, 0.0, 1.0).rgb; }`, [wr.simplex, wr.simplexFractal, wr.simplexAshima, wr.fbm, wr.perlin] ), o = e.include(a), l = []; return ( l.push(this.scale.build(e, 'f')), l.push(this.size.build(e, 'v3')), l.push(this.move.build(e, 'f')), l.push(this.fA.build(e, 'v2')), l.push(this.fB.build(e, 'v2')), l.push(this.distortion.build(e, 'v2')), l.push(this.colorA.build(e, 'v4')), l.push(this.colorB.build(e, 'v4')), l.push(this.colorC.build(e, 'v4')), l.push(this.colorD.build(e, 'v4')), l.push(this.alpha.build(e, 'f')), l.push(this.calpha), e.format(o + '(' + l.join(',') + ')', this.getType(e), t) ); } }; VA.numOctaves = 5; var HA = class extends St { constructor(e, t, i, r, s, n, a) { super('v3'), (this.nodeType = 'Fresnel'), (this.color = e), (this.bias = t), (this.scale = i), (this.intensity = r), (this.factor = s), (this.alpha = n), (this.mode = a), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if ((e.require('vWorldViewDir'), e.require('worldNormal'), e.isShader('fragment'))) { e.addFragmentVariable(this.calpha, 'float'); let i = e.include(HA.Nodes.fresnel), r = []; return ( r.push(this.color.build(e, 'c')), r.push(this.bias.build(e, 'f')), r.push(this.scale.build(e, 'f')), r.push(this.intensity.build(e, 'f')), r.push(this.factor.build(e, 'f')), r.push(this.alpha.build(e, 'f')), r.push(this.mode.build(e, 'i')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('FresnelNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, WA = HA; WA.Nodes = (function () { return { fresnel: new Re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) { float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity ); float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha; calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0); accumAlpha += (1.0 - accumAlpha) * lalpha; return color; }`) }; })(); var XA = class extends St { constructor(e, t, i, r, s, n, a) { super('v3'), (this.nodeType = 'Rainbow'), (this.filmThickness = e), (this.movement = t), (this.wavelengths = i), (this.noiseStrength = r), (this.noiseScale = s), (this.offset = n), (this.alpha = a), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if ((e.require('vWorldViewDir'), e.require('worldNormal'), e.isShader('fragment'))) { e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float'); let i = e.include(XA.Nodes.rainbow), r = []; return ( r.push(this.filmThickness.build(e, 'f')), r.push(this.movement.build(e, 'f')), r.push(this.wavelengths.build(e, 'v3')), r.push(this.noiseStrength.build(e, 'f')), r.push(this.noiseScale.build(e, 'f')), r.push(this.offset.build(e, 'v3')), r.push(this.alpha.build(e, 'f')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('RainbowNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, qA = XA; qA.Nodes = (function () { let e = new Re( `vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) { vec3 st = position / noiseScale; vec3 q = vec3(simplex3d(st), simplex3d(st + vec3(1.0)), simplex3d(st + vec3(1.0))); vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)), simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)), simplex3d(st * q)); float noise = simplex3d(st + r); return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement); }`, [wr.simplex] ); return { rainbow: new Re( `vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) { vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0); float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0); float lalpha = alpha * rainbowContribution; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return res; }`, [e] ) }; })(); var YA = class extends St { constructor(e, t, i, r, s, n, a, o, l, h, u, c, d, p, f, g) { super('v3'), (this.nodeType = 'Outline'), (this.firstTime = !0), (this.outlineColor = e), (this.contourColor = t), (this.outlineWidth = i), (this.contourWidth = r), (this.contourThreshold = s), (this.outlineThreshold = n), (this.contourFrequency = a), (this.outlineSmoothing = o), (this.contourDirection = l), (this.positionalLines = h), (this.compensation = u), (this.resolution = c), (this.normalMap = d), (this.depthMap = p), (this.pixelRatio = f), (this.alpha = g), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if ((e.require('vWorldViewDir'), e.require('worldNormal'), (e.extensions.derivatives = !0), this.firstTime)) { let i = this.outlineWidth.build(e, 'f'), r = this.resolution.build(e, 'v2'), s = this.compensation.build(e, 'b'), n = this.pixelRatio.build(e, 'f'); e.addVertexParsVariable('randomColor', 'attribute vec3'), e.addVertexParsVariable('extrudeNormal', 'attribute vec3'), e.addVertexParsVariable(i, 'uniform float'), e.addVertexParsVariable(r, 'uniform vec2'), e.addVertexParsVariable(s, 'uniform bool'), e.addVertexParsVariable(n, 'uniform float'), e.addVertexParsVariable('vID', 'flat out float'), e.addFragmentParsVariable('vID', 'flat in float'); let a = `g${this.uuid.toString().replace(/-/g, '')}`; e.addVertexFinalCode(` vID = randomColor.r; if (${s}) { vec4 ${a}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0)); // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the // normals face the camera directly. So we hackily fix this by offsetting the normal // by a tiny amount. vec3 ${a}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001; vec2 ${a}_offset = normalize(${a}_clipNormal.xy) / ${r} * (${i} / 2.0) * ${a}_clipPosition.w * 2.0 * ${n}; ${a}_clipPosition.xy += ${a}_offset; // TODO(MAX): To handle multiple outline layers, we only want to extrude // if this offset is the biggest of all the potential offsets gl_Position = ${a}_clipPosition; } `); } if (e.isShader('fragment')) { e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float'); let i = e.include(YA.Nodes.outline), r = []; return ( r.push(this.outlineColor.build(e, 'c')), r.push(this.contourColor.build(e, 'c')), r.push(this.outlineWidth.build(e, 'f')), r.push(this.contourWidth.build(e, 'f')), r.push(this.contourThreshold.build(e, 'f')), r.push(this.outlineThreshold.build(e, 'f')), r.push(this.contourFrequency.build(e, 'f')), r.push(this.outlineSmoothing.build(e, 'f')), r.push(this.contourDirection.build(e, 'v3')), r.push(this.positionalLines.build(e, 'b')), r.push(this.resolution.build(e, 'v2')), r.push(this.normalMap.getTexture(e, 't')), r.push(this.depthMap.getTexture(e, 't')), r.push(this.pixelRatio.build(e, 'f')), r.push(this.compensation.build(e, 'b')), r.push(this.alpha.build(e, 'f')), r.push(this.calpha), (this.firstTime = !this.firstTime), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('OutlineNode is not compatible with ' + e.shader + ' shader.'), ''; } }, QA = YA; QA.Nodes = (function () { let e = new Re(` float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio) { vec2 texelSize = (vec2(1.0) / resolution) * outlineWidth * pixelRatio; vec2 uvSamples[9]; vec4 normalSamples[9]; uvSamples[0] = uv + vec2( -texelSize.x, -texelSize.y); uvSamples[1] = uv + vec2(0.0, -texelSize.y); uvSamples[2] = uv + vec2( texelSize.x, -texelSize.y); uvSamples[3] = uv + vec2( -texelSize.x, 0.0); uvSamples[4] = uv; uvSamples[5] = uv + vec2( texelSize.x, 0.0); uvSamples[6] = uv + vec2( -texelSize.x, texelSize.y); uvSamples[7] = uv + vec2(0.0, texelSize.y); uvSamples[8] = uv + vec2( texelSize.x, texelSize.y); normalSamples[0] = texture2D(t, uvSamples[0]); normalSamples[1] = texture2D(t, uvSamples[1]); normalSamples[2] = texture2D(t, uvSamples[2]); normalSamples[3] = texture2D(t, uvSamples[3]); normalSamples[4] = texture2D(t, uvSamples[4]); normalSamples[5] = texture2D(t, uvSamples[5]); normalSamples[6] = texture2D(t, uvSamples[6]); normalSamples[7] = texture2D(t, uvSamples[7]); normalSamples[8] = texture2D(t, uvSamples[8]); float depthBias = 0.0001; // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?! if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) { float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias; if (gl_FragCoord.z > depthAtSample) { return 0.0; } } vec4 sobel_edge_h = normalSamples[2] + (2.0*normalSamples[5]) + normalSamples[8] - (normalSamples[0] + (2.0*normalSamples[3]) + normalSamples[6]); vec4 sobel_edge_v = normalSamples[0] + (2.0*normalSamples[1]) + normalSamples[2] - (normalSamples[6] + (2.0*normalSamples[7]) + normalSamples[8]); float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v)); return edgeNormal; } `); return { outline: new Re( `vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float alpha, out float calpha) { vec3 result = outlineColor; float resultAlpha = 0.0; vec3 N = normalize(vWNormal); vec2 nuv = (gl_FragCoord.xy / resolution); float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio); resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample); float t = 1.0 - contourThreshold; if(positionalLines) { vec3 NDir = position * contourDirection; float NT = NDir.x + NDir.y + NDir.z; float f = fract(NT * contourFrequency * 0.01); float df = fwidth(NT * contourFrequency); float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f); if (g < 1.0 && resultAlpha == 0.0) { result = contourColor; resultAlpha = 1.0; } } else { vec3 NDir = N * contourDirection; float NT = NDir.x + NDir.y + NDir.z; float df = fwidth(NT * contourThreshold); float f = sin(NT * 1.0 * contourFrequency); float g = smoothstep(0.0, df * contourWidth, 1.0 - f); if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) { result = contourColor; resultAlpha = 1.0 - g; } } float lalpha = alpha * resultAlpha; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return result; }`, [e] ) }; })(); var ZA = class extends St { constructor(e, t, i, r, s, n, a, o) { super('v3'), (this.nodeType = 'Transmission'), (this.thickness = e), (this.ior = t), (this.roughness = i), (this.transmissionSamplerSize = r), (this.transmissionSamplerMap = s), (this.transmissionDepthMap = n), (this.aspectRatio = a), (this.alpha = o), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if (((e.extensions.shaderTextureLOD = !0), (e.extensions.derivatives = !0), e.isShader('fragment'))) { e.define('NUM_SAMPLES', 30), e.require('worldPosition'), (e.requires.worldNormal = !0), (e.requires.modelMatrix = !0), (e.requires.projectionMatrix = !0), e.addFragmentVariable(this.calpha, 'float'); let i = e.include(ZA.Nodes.transmission), r = []; return ( r.push(this.thickness.build(e, 'f')), r.push(this.ior.build(e, 'f')), r.push(this.roughness.build(e, 'f')), r.push(this.transmissionSamplerSize.build(e, 'v2')), r.push(this.transmissionSamplerMap.getTexture(e, 't')), r.push(this.transmissionDepthMap.getTexture(e, 't')), r.push(this.aspectRatio.build(e, 'v2')), r.push('normal'), r.push(this.alpha.build(e, 'f')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return ( console.warn('TransmissionNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t) ); } }, KA = ZA; KA.Nodes = (function () { let e = new Re(` float gaussian(vec2 i) { const float sigma = float(NUM_SAMPLES) * .25; return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); }`), t = new Re( ` vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) { // Slightly modified version of this: // https://www.shadertoy.com/view/ltScRG const int LOD = 2; const int sLOD = 4; // tile size = 2^LOD vec3 O = vec3(0); float a = 0.0; const int s = NUM_SAMPLES/sLOD; for ( int i = 0; i < s*s; i++ ) { int modulo = (i)-((i)/(s))*(s); vec2 d = vec2(float(modulo), float(i/s))*float(sLOD) - float(NUM_SAMPLES)/2.; vec2 uv = U + (scale * aspectRatio) * d; // What is the depth of the opaque object we're trying to sample float opaqueDepth = unpackRGBAToDepth(texture2D(dm, uv)); if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) { uv = unrefractedU + ((scale * min(lod / 2., 1.)) * aspectRatio) * d; lod = lod > 4.0 ? lod : lod / 2.0; } float gaussian = gaussian(d); #ifdef TEXTURE_LOD_EXT O += gaussian * texture2DLodEXT( sp, uv, lod).rgb; #else O += gaussian * textureLod( sp, uv, lod).rgb; #endif a += gaussian; } return O / a; }`, [e] ), i = new Re(` vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) { // Direction of refracted light. vec3 refractionVector = refract( -v, n, 1.0 / ior ); // Compute rotation-independant scaling of the model matrix. vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); // The thickness is specified in local space. return normalize( refractionVector ) * thickness * modelScale; }`), r = new Re(` float applyIorToRoughness( float roughness, float ior ) { // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and // an IOR of 1.5 results in the default amount of microfacet refraction. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } `), s = new Re( ` vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); float lod = applyIorToRoughness(roughness, ior); return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio); }`, [r, t] ), n = new Re( ` vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 ); vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w; unrefractedCoords += 1.0; unrefractedCoords /= 2.0; // Sample framebuffer to get pixel the refracted ray hits. return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio ); }`, [s, i] ); return { transmission: new Re( ` vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) { vec3 v = vec3(0.); if (isOrthographic) { v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { v = normalize(vWPosition - cameraPosition); } vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio ); float lalpha = alpha; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return transmission; }`, [n] ) }; })(); var ql = class extends St { constructor(e, t, i, r, s, n, a, o, l, h, u) { super('v3'), (this.nodeType = 'Depth'), (this.gradientType = e), (this.smooth = t), (this.near = i), (this.far = r), (this.isVector = s), (this.isWorldSpace = n), (this.origin = a), (this.direction = o), (this.colors = l), (this.steps = h), (this.alpha = u), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { let i = `g${this.uuid.toString().replace(/-/g, '')}`, r = new Re( `vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], float alpha, out float calpha) { vec4 color = colors[0]; #ifdef ${i}_IS_VECTOR #ifdef ${i}_LINEAR #ifdef ${i}_WORLDSPACE float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far); #else float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far); #endif #else #ifdef ${i}_WORLDSPACE float depth = vectorSphericalWorldSpaceDepth(origin, near, far); #else float depth = vectorSphericalObjectSpaceDepth(origin, near, far); #endif #endif #else float dist = length(vWPosition - cameraPosition); float depth = ( dist - near ) / ( far - near ); #endif float p; #ifdef ${i}_SMOOTH for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) { p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } #else for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) { p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0); color = mix(color, colors[i], p); } #endif float lalpha = alpha * color.a; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return color.rgb; }`, [ ql.Nodes.vectorLinearWorldSpaceDepth, ql.Nodes.vectorLinearObjectSpaceDepth, ql.Nodes.vectorSphericalObjectSpaceDepth, ql.Nodes.vectorSphericalWorldSpaceDepth ] ); if (e.isShader('fragment')) { e.define(`${i}_MAX_COLORS`, this.colors.value.length), this.smooth.value && e.define(`${i}_SMOOTH`), this.isVector.value > 0.5 && e.define(`${i}_IS_VECTOR`), this.gradientType.value === 0 && e.define(`${i}_LINEAR`), this.isWorldSpace.value > 0.5 && e.define(`${i}_WORLDSPACE`), e.require('worldPosition'), e.addFragmentVariable(this.calpha, 'float'); let s = e.include(r), n = []; return ( n.push(this.near.build(e, 'f')), n.push(this.far.build(e, 'f')), n.push(this.origin.build(e, 'v3')), n.push(this.direction.build(e, 'v3')), n.push(this.colors.build(e, 'v4[]')), n.push(this.steps.build(e, 'f[]')), n.push(this.alpha.build(e, 'f')), n.push(this.calpha), e.format(s + '(' + n.join(',') + ')', this.getType(e), t) ); } else return console.warn('DepthNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, JA = ql; JA.Nodes = (function () { let e = new Re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) { vec3 n = normalize(direction); float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z)); return ( dist - near ) / ( far - near ); }`), t = new Re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) { vec3 n = normalize(direction); float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z)); return ( dist - near ) / ( far - near ); }`), i = new Re(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) { float dist = length(vWPosition - origin); return ( dist - near ) / ( far - near ); }`), r = new Re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) { float dist = length(position - origin); return ( dist - near ) / ( far - near ); }`); return { vectorLinearWorldSpaceDepth: e, vectorLinearObjectSpaceDepth: t, vectorSphericalWorldSpaceDepth: i, vectorSphericalObjectSpaceDepth: r }; })(); var jx = class extends St { constructor(e, t, i, r) { super('v3'), (this.nodeType = 'Blend'), (this.a = e), (this.b = t), (this.alpha = i), (this.mode = r); } generate(e, t) { if (e.isShader('fragment')) { let i = []; return ( i.push(this.a.build(e, 'c')), i.push(this.b.build(e, 'c')), i.push(this.alpha.build(e, 'f')), i.push(this.mode.build(e, 'i')), e.format('spe_blend(' + i.join(',') + ')', this.getType(e), t) ); } else return console.warn('BlendNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, km = ((e) => ((e.NOISE = 'noise'), (e.MAP = 'map'), e))(km || {}), $A = class extends St { constructor(e, t, i, r, s) { super('v3'), (this.displacementTypeIndex = new xt(0)), (this.nodeType = 'VertexDisplacement'), (this.intensity = e), (this.movementOrTexture = t), Object.values(km)[this.displacementTypeIndex.value] === 'map' && (this.mat = new GA(this.movementOrTexture.value.matrix)), (this.cropOrOffset = i), (this.scale = r), (this.noiseFunctionIndex = s); } generate(e, t) { if (e.isShader('vertex')) { e.define('USE_LAYER_DISPLACE'); let i, r = []; switch ((r.push('displaced_position'), r.push('displaced_normal'), Object.values(km)[this.displacementTypeIndex.value])) { case 'map': { (i = e.include($A.Nodes.map)), r.push(this.movementOrTexture.getTexture(e, 't')), r.push('uv'), r.push(this.cropOrOffset.build(e, 'f')), this.mat && r.push(this.mat.build(e, 'mat3')); break; } case 'noise': { let s = Object.values(cv)[this.noiseFunctionIndex.value], n = new Re(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`), a = new Re( `vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) { return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity; }`, [wr.simplex, wr.simplexFractal, wr.simplexAshima, wr.fbm, wr.perlin] ), o = new Re( `vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) { vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement); vec3 tangent1 = orthogonal(normal); vec3 tangent2 = normalize(cross(normal, tangent1)); // TODO(Max): The distance to the neighbors was originally scaled by 0.1. // This caused some small oval/circular visual artifacts in the lighting. // For now, simply using neighbors further away betters the problem, // but we should figure out the underlying cause when we have some time. // Maybe its related to how we calculate the tangent and bitangent? vec3 nearby1 = position + tangent1; vec3 nearby2 = position + tangent2; vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement); vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement); displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`, [a, n] ); (i = e.include(o)), r.push(this.scale.build(e, 'f')), r.push(this.cropOrOffset.build(e, 'v3')), r.push(this.movementOrTexture.build(e, 'f')); break; } } return r.push(this.intensity.build(e, 'f')), r.push('displaced_normal'), e.format(i + '(' + r.join(',') + ')', this.getType(e), t); } else return ( console.warn('VertexDisplacementNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t) ); } }, eS = $A; eS.Nodes = (function () { let e = new Re(`vec3 orthogonal(vec3 v) { return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y)); }`), t = new Re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) { vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset; vec4 tmp = texture2D(tex, uvs); vec3 col = tmp.rgb; if (crop > 0.5) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { return 0.0; } } return col.r; }`); return { map: new Re( `vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) { vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity; vec3 tangent1 = normalize(orthogonal(normal)); vec3 tangent2 = normalize(cross(normal, tangent1)); vec3 nearby1 = position + tangent1 * 0.1; vec3 nearby2 = position + tangent2 * 0.1; vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity; displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position)); return displaced_position; }`, [e, t] ) }; })(); var tS = class extends St { constructor(e, t, i, r, s, n, a, o) { super('v3'), (this.nodeType = 'Gradient'), (this.gradientType = e), (this.smooth = t), (this.colors = i), (this.steps = r), (this.offset = s), (this.morph = n), (this.angle = a), (this.alpha = o), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if (e.isShader('fragment')) { e.define('GRAD_MAX', 10), e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float'); let i = e.include(tS.Nodes.gradient), r = []; return ( r.push(this.gradientType.build(e, 'i')), r.push(this.smooth.build(e, 'b')), r.push(this.colors.build(e, 'v4[]')), r.push(this.steps.build(e, 'f[]')), r.push(this.offset.build(e, 'v2')), r.push(this.morph.build(e, 'v2')), r.push(this.angle.build(e, 'f')), r.push(this.alpha.build(e, 'f')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('GradientNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, iS = tS; iS.Nodes = (function () { return { gradient: new Re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) { vec4 color = colors[0]; vec2 m = morph / vUv.xy; vec2 rot = vec2( 0.5 + m.x, m.y ); vec2 dt = vec2( cos( angle ) * rot.x - sin( angle ) * rot.y, sin( angle ) * rot.x + cos( angle ) * rot.y ); vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0; float t = dot( pt, dt ) / dot( dt, dt ); if ( gradientType == 1 ) { t = distance ( ( vUv + morph ) * 3.0, ( vUv + offset ) + 1.0 ) + angle; } else if ( gradientType == 2 ) { float polar = atan( vUv.x + morph.x - 0.5 + offset.x, vUv.y + morph.y - 0.5 + offset.y ) * -1.0; t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) ); } float p; if (smoothed) { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } } else { for ( int i = 1; i < GRAD_MAX; i++ ) { p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 ); color = mix(color, colors[i], p); } } float lalpha = alpha * color.a; calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return color.xyz; }`) }; })(); var od = class extends St { constructor(e, t, i, r, s, n, a, o, l, h) { super('v3'), (this.nodeType = 'CustomTexture'), (this.firstTime = !0), (this.texture = e), (this.textureSize = t), (this.crop = i), (this.projection = r), (this.axis = s), (this.side = n), (this.size = a), (this.mat = o), (this.alpha = l), (this.mode = h), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { e.require('position'), e.require('normal'), e.require('uv'), (e.requires.uv = [!0]), (e.extensions.shaderTextureLOD = !0), (e.extensions.derivatives = !0); let i = `g${this.uuid.toString().replace(/-/g, '')}`, r; switch (this.projection.value) { case 3: r = e.include(od.Nodes.cylindrical); break; case 2: r = e.include(od.Nodes.spherical); break; case 1: let n = ['vec3(1.0, 0.0, 0.0)', 'vec3(0.0, 1.0, 0.0)', 'vec3(0.0, 0.0, 1.0)'][this.axis.value], a = new Re(` vec3 ${i}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec2 uvs = ( mat * vec3( (${i}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy; vec4 tmp = texture2D( tex, uvs ); vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; ${this.side.value === 2 ? '' : `lalpha *= step(0.0, ${this.side.value === 1 ? '-1.0 * ' : ''}dot(vObjectNormal, mat * ${n}));`} if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; }`); r = e.include(a); break; default: r = e.include(od.Nodes.uv); break; } if (this.projection.value === 1 && this.firstTime) { e.addVertexParsCode(`varying vec2 ${i}_vCustomUv;`), e.addFragmentParsCode(`varying vec2 ${i}_vCustomUv;`); let n = ['zy', 'xz', 'xy'][this.axis.value]; e.addVertexFinalCode(`${i}_vCustomUv = (1. + (transformed.${n})) / 2.;`); } e.addFragmentVariable(this.calpha, 'float'); let s = []; return ( s.push(this.texture.generate(e, 't')), s.push(this.textureSize.build(e, 'v2')), s.push(this.crop.build(e, 'f')), s.push(this.mat.build(e, 'mat3')), s.push(this.size.build(e, 'v2')), s.push(this.alpha.build(e, 'f')), s.push(this.mode.build(e, 'i')), s.push(this.calpha), (this.firstTime = !this.firstTime), e.format(r + '(' + s.join(',') + ')', this.getType(e), t) ); } }, rS = od; rS.Nodes = (function () { let e = new Re(` vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec3 posN = normalize(position); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float scaledHeight = position.y / (size.y * 0.5); float v = (scaledHeight / 2.) + .5; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; } `), t = new Re(` vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec3 posN = normalize(vPosition); float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415); float v = 0.5 + asin(posN.y) / 3.1415; vec2 calculatedUv = vec2(u,v); vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec2 df = fwidth(uvs); if(df.x > 0.5) df.x = 0.; #ifdef GL_EXT_shader_texture_lod vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #else vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y))); #endif vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; } `), i = new Re(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) { vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy; vec4 tmp = texture2D( tex, uvs ); vec3 col = tmp.rgb; float lalpha = alpha * tmp.a; if ( crop > 0.5 ) { if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) { lalpha = 0.0; } } calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * lalpha; return col; }`); return { cylindrical: e, spherical: t, uv: i }; })(); var sS = class extends St { constructor(e, t) { super('v3'), (this.nodeType = 'CustomNormal'), (this.cnormal = e), (this.alpha = t); } generate(e, t) { if (e.isShader('fragment')) { let i = e.include(sS.Nodes.customNormal), r = []; return ( r.push(this.cnormal.build(e, 'v3')), r.push('normal'), r.push(this.alpha.build(e, 'f')), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return ( console.warn('CustomNormalNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t) ); } }, nS = sS; nS.Nodes = (function () { return { customNormal: new Re(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) { vec3 normal = packNormalToRGB( norm ).rgb; normal *= step( vec3(0.5), cnormal ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return normal; }`) }; })(); function sr(e, t) { return t.color(e); } function nk(e, t) { switch (e.type) { case 'fresnel': return lk(e, t); case 'gradient': return hk(e); case 'depth': return ck(e); case 'normal': return dk(e); case 'noise': return uk(e, t); case 'rainbow': return pk(e); case 'toon': return fk(e, t); case 'outline': return mk(e, t); case 'transmission': return gk(e, t); case 'color': return ok(e, t); } } function ak(e) { return { type: e.type }; } function As(e) { let { alpha: t, mode: i } = e; return { ...ak(e), alpha: t, mode: i }; } function ok(e, t) { return { ...As(e), color: sr(e.color, t) }; } function lk(e, t) { let { bias: i, scale: r, intensity: s, factor: n, color: a } = e; return { ...As(e), color: sr(a, t), bias: i, scale: r, intensity: s, factor: n }; } function hk(e) { let { gradientType: t, smooth: i, colors: r, steps: s, angle: n, offset: a, morph: o } = e; return { ...As(e), gradientType: t, smooth: i, colors: r.map((l) => new $e(l[0], l[1], l[2], l[3])), num: r.length, steps: s, offset: new G(...a), morph: new G(...o), angle: n }; } function ck(e) { let { gradientType: t, near: i, far: r, isVector: s, isWorldSpace: n, origin: a, direction: o, colors: l, steps: h, smooth: u } = e; return { ...As(e), gradientType: t, near: i, far: r, isVector: s, isWorldSpace: n, origin: new E(...a), direction: o ? new E(...o) : new E(1, 0, 0), colors: l.map((c) => (c !== void 0 ? new $e(c[0], c[1], c[2], c[3]) : new $e(0, 0, 0, 0))), steps: h.slice(0, l.length), smooth: u }; } function dk(e) { let { cnormal: t } = e; return { ...As(e), cnormal: new E(t[0], t[1], t[2]) }; } function uk(e, t) { return { ...As(e), scale: e.scale, move: e.move, fA: new G(...e.fA), fB: new G(...e.fB), size: new E(...e.size), distortion: new G(...e.distortion), colorA: sr(e.colorA, t), colorB: sr(e.colorB, t), colorC: sr(e.colorC, t), colorD: sr(e.colorD, t), noiseType: e.noiseType }; } function pk(e) { return { ...As(e), filmThickness: e.filmThickness, movement: e.movement, wavelengths: new E(...e.wavelengths), noiseStrength: e.noiseStrength, noiseScale: e.noiseScale, offset: new E(...e.offset) }; } function fk(e, t) { return { ...As(e), positioning: e.positioning, colors: e.colors.map((i) => new $e(i[0], i[1], i[2], i[3])), num: e.colors.length, steps: e.steps, source: new E(...e.source), isWorldSpace: e.isWorldSpace, noiseStrength: e.noiseStrength, noiseScale: e.noiseScale, shadowColor: sr(e.shadowColor, t), offset: new E(...e.offset) }; } function mk(e, t) { return { ...As(e), outlineColor: sr(e.outlineColor, t), contourColor: sr(e.contourColor, t), outlineWidth: e.outlineWidth, contourWidth: e.contourWidth, outlineThreshold: e.outlineThreshold, contourThreshold: e.contourThreshold, outlineSmoothing: e.outlineSmoothing, contourFrequency: e.contourFrequency, contourDirection: new E(...e.contourDirection), positionalLines: e.positionalLines, compensation: e.compensation }; } function gk(e, t) { return { ...As(e), thickness: e.thickness, ior: e.ior, roughness: e.roughness }; } var Kd = class extends ji {}, vk = class { constructor(e = 1e3 * 10) { (this.timeout = e), (this.cache = new Map()), (this.head = { data: null, time: 0, src: null, next: null, prev: null }), (this.tail = { data: null, time: 1 / 0, src: null, next: null, prev: null }), (this.hasClean = !1), (this.head.next = this.tail), (this.tail.prev = this.head); } log(...e) {} remove(e) { let t = this.cache.get(e); t && (this.dispose(e, t.data), this.cache.delete(e), (t.prev.next = t.next), (t.next.prev = t.prev)); } scheduleCleanup() { this.hasClean || (this.log('scheduled cleanup'), (this.hasClean = !0), setTimeout(() => { (this.hasClean = !1), this.log('cleaning'); let e = Date.now(), t = this.head.next; for (; t.time < e - this.timeout; ) this.dispose(t.src, t.data), this.cache.delete(t.src), (t = t.next), (t.prev = this.head), (this.head.next = t); this.head.next !== this.tail ? this.scheduleCleanup() : this.log('no more cleanup'); }, this.timeout + 1e3)); } has(e) { return this.cache.get(e)?.data; } load(e) { let t = Date.now(), i = this.cache.get(e); return ( i === void 0 ? ((i = { data: this.create(e), src: e, time: t, next: null, prev: null }), this.cache.set(e, i)) : ((i.time = t), (i.prev.next = i.next), (i.next.prev = i.prev)), (i.prev = this.tail.prev), (i.next = this.tail), (this.tail.prev.next = i), (this.tail.prev = i), this.scheduleCleanup(), i.data ); } }, yk = class extends vk { create(e) { return URL.createObjectURL(new Blob([e])); } dispose(e, t) { URL.revokeObjectURL(t); } }, nf; function xk(e) { return typeof e == 'string' ? e : (nf || (nf = new yk()), nf.load(e)); } var bk = class { constructor(e, t) { (this.data = e), (this.cache = t), (this.refCount = 0); } deref() { this.refCount, (this.refCount -= 1), this.refCount === 0 && (this.cache.remove(this), this.dispose()); } dispose() { this.refCount; } }, wk = class { constructor() { this.cache = new Map(); } remove(e) { this.cache.delete(e.data); } load(e) { let t = this.cache.get(e); return t === void 0 && ((t = this.create(e)), this.cache.set(e, t)), (t.refCount += 1), t; } }, aS = class extends bk { constructor(e, t) { super(e, t.imageHolderCache), (this.data = e), (this.shared = t), (this.loaded = !1), (this.isVideo = !1), (this.isVideo = e.type == 'video'), this.updateSrc(e.data); } async updateSrc(e) { if (typeof document > 'u') return; this.disposeTextures(), (this.loaded = !1); let t = () => { this.loaded = !0; let r = [1e3, 1001, 1002]; for (let s of r) { let n = this[s]; n && ((n.image = this.img), (n.needsUpdate = !0)); } this.shared.requestRender(); }; if (this.isVideo) { if ( ((this.img = document.createElement('video')), (this.img.preload = 'auto'), (this.img.playsInline = !0), (this.img.currentTime = 0.01), typeof e != 'string') ) { var i = new FileReader(); i.readAsDataURL(new Blob([e], { type: 'video/mp4' })); let r; await new Promise((s) => { i.onloadend = (n) => { (r = n.target?.result), s(null); }; }), (this.img.src = r); } else this.img.src = e; this.img.onloadeddata = () => { t(); }; } else (this.img = new Image()), (this.img.src = xk(e)), (this.img.onload = t); } getTexture(e) { let t = this[e]; if (t) return t; { let i; return ( this.isVideo ? (i = new tD(this.img, void 0, e, e)) : (i = new ci(this.img, void 0, e, e)), this.loaded && (i.needsUpdate = !0), (this[e] = i), i ); } } disposeTextures() { this[1e3]?.dispose(), (this[1e3] = void 0), this[1001]?.dispose(), (this[1001] = void 0), this[1002]?.dispose(), (this[1002] = void 0); } dispose() { super.dispose(), this.disposeTextures(); } }, ha = class extends aS {}, dv = class extends or {}, oS = { noise: ['noiseType'], texture: ['projection', 'axis', 'side'], video: ['projection', 'axis', 'side'], displace: ['noiseType'], depth: ['smooth', 'isWorldSpace', 'gradientType', 'isVector'] }, lS = { depth: ['colors'] }; function _k(e, t, i) { let r = oS[e.type], s = lS[e.type]; if (s !== void 0) { let n = e.color; if (s.includes(t)) { let a = n[t]?.value?.length; if (a !== void 0 && a !== i.length) return !0; } } return r !== void 0 ? r.includes(t) : !1; } function hS(e, t, i) { let r = i.uniforms[`f${i.id}_texture`]; if (!r) return !1; let s = !1, n = e; if ('image' in n) { let a = n.image, o = t.image(a), l = r; l.image instanceof ha || l.image.deref(), (l.image = o); } if ('video' in n) { let a = n.video, o = t.video(a), l = r; l.image instanceof ha || l.image.deref(), (l.image = o); } if ('wrapping' in n) { let a = r; a.wrap = n.wrapping; } if ('repeat' in n || 'offset' in n) { let a = 'mat', o = i.uniforms[`f${i.id}_${a}`]; 'repeat' in n && (o.repeat = n.repeat), 'offset' in n && (o.offset = n.offset), o.updateMatrix(); } return s; } function Ak(e, t, i, r) { let s = !1; for (let [n, a] of Object.entries(e)) { if (!n || a === void 0) continue; if (mS(n, i, r)) { n === 'visible' && i.type === 'light' && (s = !0); continue; } i.visible = r.visible; let o = i.uniforms[`f${i.id}_${n}`]; if (!!o && !(o instanceof dv)) switch (((s = s || _k(i, n, a)), o.constructor)) { case Ut: if (typeof a == 'string') { let l = t.getColor(a); l && (o.value = l); break; } else { let l = a; o.value instanceof Kd ? (o.value = new ji(l.r, l.g, l.b, l.a)) : o.setRGBA(l); break; } case na: if (typeof a == 'string') { let l = t.getColor(a); l && (o.value = l); break; } else { let l = a; o.value instanceof Kd ? (o.value = new ji(l.r, l.g, l.b, l.a)) : o.value.setRGBA(l.r, l.g, l.b, l.a); break; } case vr: { let l = a; o.value.setX(l[0]), o.value.setY(l[1]); break; } case fr: { let l = a; o.value.setX(l[0]), o.value.setY(l[1]), o.value.setZ(l[2]); break; } case An: { hS(a, t, i); break; } case ta: { o.value = a.map((l) => new $e(...l)); break; } default: { o.value = a; break; } } } return s; } var cS = class extends St { constructor(e, t, i) { super('v3'), (this.nodeType = 'Matcap'), (this.texture = e), (this.alpha = t), (this.mode = i), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if (e.isShader('fragment')) { e.addFragmentVariable(this.calpha, 'float'); let i = e.include(cS.Nodes.matcap); e.require('normal'), (e.requires.normal = !0); let r = []; return ( r.push(this.texture.generate(e, 't')), r.push('normal'), r.push(this.alpha.build(e, 'f')), r.push(this.mode.build(e, 'i')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('MatcapNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, dS = cS; dS.Nodes = (function () { return { matcap: new Re(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) { vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks vec4 matcapColor = texture2D( matcapTex, uv ); calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 ); accumAlpha += ( 1.0 - accumAlpha ) * alpha; return matcapColor.rgb; } `) }; })(); var jm = class extends dv { constructor(e, t) { super('t'), (this.image = e), (this.wrap = t); } get value() { return this.image.getTexture(this.wrap); } }, Sk = class extends dv { constructor(e) { super('v3'), (this.image = e), (this._value = new E()); } get value() { return ( (this._value.x = this.image.isVideo ? (this.image.img.videoWidth ?? 0) : this.image.img.width), (this._value.y = this.image.isVideo ? (this.image.img.videoHeight ?? 0) : this.image.img.height), this._value ); } }, uS = class extends St { constructor(e, t, i, r, s, n, a, o, l, h) { super('v3'), (this.nodeType = 'Toon'), (this.positioning = e), (this.colors = t), (this.steps = i), (this.source = r), (this.isWorldSpace = s), (this.noiseStrength = n), (this.noiseScale = a), (this.shadowColor = o), (this.offset = l), (this.alpha = h), (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`); } generate(e, t) { if ((e.require('worldNormal'), e.require('worldPosition'), e.isShader('fragment'))) { e.define('COLORS_MAX', 10), e.addFragmentVariable(this.calpha, 'float'); let i = e.include(uS.Nodes.toon), r = []; return ( r.push(this.positioning.build(e, 'i')), r.push(this.colors.build(e, 'v4[]')), r.push(this.steps.build(e, 'f[]')), r.push(this.source.build(e, 'v3')), r.push(this.isWorldSpace.build(e, 'b')), r.push(this.noiseStrength.build(e, 'f')), r.push(this.noiseScale.build(e, 'f')), r.push(this.shadowColor.build(e, 'v4')), r.push(this.offset.build(e, 'v3')), r.push(this.alpha.build(e, 'f')), r.push(this.calpha), e.format(i + '(' + r.join(',') + ')', this.getType(e), t) ); } else return console.warn('ToonNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t); } }, pS = uS; pS.Nodes = (function () { let e = new Re(`float rand(float n) { return fract(sin(n) * 43758.5453123); }`), t = new Re(`float hash1(float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }`), i = new Re( `float valueNoise(vec3 x) { const vec3 step = vec3(110, 241, 171); vec3 i = floor(x); vec3 f = fract(x); // For performance, compute the base input to a 1D hash from the integer part of the argument and the // incremental change to the 1D based on the 3D -> 1D wrapping float n = dot(i, step); vec3 u = f * f * (3.0 - 2.0 * f); return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x), mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y), mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x), mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z); }`, [t] ), r = new Re(`vec3 hash3(vec3 x) { x = vec3(dot(x,vec3(127.1, 311.7, 74.7)), dot(x,vec3(269.5, 183.3, 246.1)), dot(x,vec3(113.5, 271.9, 124.6))); return fract(sin(x)*43758.5453123); }`), s = new Re( `vec3 voronoiNoise(in vec3 x) { vec3 p = floor(x); vec3 f = fract(x); float id = 0.0; vec2 res = vec2(100.0); for(int k=-1; k<=1; k++) for(int j=-1; j<=1; j++) for(int i=-1; i<=1; i++) { vec3 b = vec3(float(i), float(j), float(k)); // Comment out the "+ hash(p + b);" part below to get "square" cells vec3 r = vec3(b) - f + hash3(p + b); float d = dot(r, r); if (d < res.x) { id = dot(p + b, vec3(1.0, 57.0, 113.0)); res = vec2(d, res.x); } else if (d < res.y) { res.y = d; } } return vec3(sqrt(res), abs(id)); } `, [r] ); return { toon: new Re( `vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float alpha, out float calpha) { float t = 0.0; float shadow = 1.0; if (positioning == 0) { // Can't do this mode if lighting is "none" #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD)) // Algorithm from Chapter 10 of Graphics Shaders const vec3 weights = vec3(0.2125, 0.7154, 0.0721); vec3 lpos; vec3 l; float dproduct; #if (NUM_POINT_LIGHTS > 0) #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0) PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_POINT_LIGHTS; i++) { // Light positions are in view-space for some reason? lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; l = normalize(lpos - worldPosition); dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; // TODO: we want to use "intensity" but it isn't available in the shader code //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights); t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS) pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getPointShadow( pointShadowMap[UNROLLED_LOOP_INDEX], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[UNROLLED_LOOP_INDEX], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar); #endif } #pragma unroll_loop_end #endif #if NUM_DIR_LIGHTS > 0 #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0) DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_DIR_LIGHTS; i++) { // Use the direction vector for directional lights instead l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz; dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS) directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[UNROLLED_LOOP_INDEX], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]); #endif } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHTS > 0 #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0) SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for (int i = 0; i < NUM_SPOT_LIGHTS; i++) { lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz; l = normalize(lpos - worldPosition); dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5; t = max(t, dproduct); // Accumulate shadow contribution #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS) spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX]; shadow *= getShadow( UNROLLED_LOOP_INDEX, spotShadowMap[UNROLLED_LOOP_INDEX], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[UNROLLED_LOOP_INDEX]); #endif } #pragma unroll_loop_end #endif t = clamp(t, 0.0, 1.0); #endif } else if (positioning == 1) { vec3 origin = mix(position, worldPosition, float(isWorldSpace)); vec3 direction = normalize(source - origin); t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; } else { vec3 origin = worldPosition; vec3 source = cameraPosition - offset; vec3 direction = normalize(source - origin); t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5; } if (noiseStrength > 0.0) { // Distort with noise vec3 st = position / noiseScale; // Voronoi "smooth" noise float noise = 1.0 - voronoiNoise(st).x; // Voronoi cellular noise //float noise = 1.0 - rand(voronoiNoise(st).z); // Position warp noise // vec3 offset = vec3( // simplex3d(st), // simplex3d(st + vec3(111.1, 143.89, 217.19)), // simplex3d(st + vec3(171.1, 247.89, 117.23)) // ); // st += offset; // float noise = valueNoise(st); t += noise * noiseStrength; } t = clamp(t, 0.0, 1.0); // Compute ramp color float p; vec4 color = colors[0]; for (int i = 1; i < COLORS_MAX; i++) { p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0); color = mix(color, colors[i], smoothstep(0.0, 1.0, p)); } // Incorporate custom shadow color if (positioning == 0) { vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a); color.rgb = mix(blendedShadow, color.rgb, shadow); } // Accumulate alpha as usual float lalpha = alpha * color.a; calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0); accumAlpha += (1.0 - accumAlpha) * lalpha; return color.xyz; }`, [wr.simplex, e, i, s] ) }; })(); function Gx(e, t, i) { e.setUvTransform(i[0], i[1], t[0], t[1], 0, 0, 0); } var Mk = class extends GA { constructor(e, t) { super(new Ai()), (this.repeat = e), (this.offset = t), Gx(this.value, e, t); } updateMatrix() { Gx(this.value, this.repeat, this.offset); } }, va = class { constructor(e, t, i, r) { (this.id = e), (this.uuid = t), (this.data = i), (this.uniforms = {}); for (let s in r) this.uniforms[`f${this.id}_${s}`] = r[s]; for (let s in i) mS(s, this, i); } get type() { return this.data.type; } static create(e, t, i, r) { if (i.type === 'light') return yo.createLigherLayer(e, t, i, r); if (i.type === 'texture' || i.type === 'video') { let s = i.type === 'texture' ? r.image(i.texture.image) : r.video(i.texture.video), n = new jm(s, i.texture.wrapping), a = new Sk(s), o = new Mk(i.texture.repeat, i.texture.offset), l = new Pe(i.crop ? 1 : 0), h = new xt(i.projection ?? 0), u = new xt(['x', 'y', 'z'].indexOf(i.axis) ?? 0), c = new xt(i.side ?? 0), d = new vr(i.size ? new G(i.size[0], i.size[1]) : new G(100, 100)), p = new Pe(i.alpha ?? 1), f = new xt(i.mode ?? 0), g = new rS(n, a, l, h, u, c, d, o, p, f), m = new Pt(g.calpha, 'f'); return new pi( e, t, i, { texture: n, textureSize: a, crop: l, projection: h, axis: u, side: c, size: d, mat: o, alpha: p, mode: f }, g, f, m ); } else if (i.type === 'matcap') { let s = r.image(i.texture.image), n = new jm(s, i.texture.wrapping), a = new Pe(i.alpha ?? 1), o = new xt(i.mode ?? 0), l = new dS(n, a, o), h = new Pt(l.calpha, 'f'); return new pi(e, t, i, { texture: n, alpha: a, mode: o }, l, o, h); } else if (i.type === 'displace') if (i.displacementType === 'noise') { let s = new fr(new E(...i.offset)), n = new Pe(i.scale ?? 10), a = new Pe(i.intensity ?? 8), o = new Pe(i.movement ?? 1), l = new xt(i.noiseType ?? 0), h = new eS(a, o, s, n, l); return new fS(e, t, i, { offset: s, scale: n, intensity: a, movement: o, noiseType: l }, h); } else throw new Error(); else return Tk(e, t, i, r); } updateByOp(e, t, i) { let r = e; if (r.path[0] === void 0) { if (r.type === 0) return 'type' in r.props || 'category' in r.props || 'visible' in r.props ? (i.scene?.markNeedsUpdateRendererDirty(), !0) : Ak(r.props, i.shared, this, t); } else if (r.path[0] === 'texture') return 'texture' in t || 'video' in t ? hS(r.props, i.shared, this) : !0; return !1; } dispose() { if (Ek(this)) { let e = this.uniforms[`f${this.id}_texture`]; if (!e) return !1; let t = e; t.image instanceof ha || t.image.deref(); } } hasValueByKey(e) { return this.uniforms[e] !== void 0; } hasValue(e) { return this.hasValueByKey(`f${this.id}_${e}`); } setValue(e, t) { let i = `f${this.id}_${e}`; this.hasValueByKey(i) && t !== void 0 && (this.uniforms[i].value = t); } getNode(e) { let t = `f${this.id}_${e}`; if (this.hasValueByKey(t)) return this.uniforms[t]; } getValue(e) { let t = `f${this.id}_${e}`; if (this.hasValueByKey(t)) return this.uniforms[t].value; } getName(e) { let t = /f\d+_(.*)/.exec(e); if (t && t.length > 1) return t[1]; console.log(`Layer.getName: error ${e}`); } getNames() { let e = []; for (let t in this.uniforms) { let i = this.getName(t); i && e.push(i); } return e; } }, pi = class extends va { constructor(e, t, i, r, s, n, a) { super(e, t, i, r), (this.params = r), (this.color = s), (this.mode = n), (this.alpha = a); } }, fS = class extends va { constructor(e, t, i, r, s) { super(e, t, i, r), (this.position = s); } }, yo = class extends va { constructor(e, t, i, r, s) { super(e, t, i, s), (this.node = r); } static createLigherLayer(e, t, i, r) { let s, n = new Pe(i.alpha), a = new xt(i.mode), o; if (!i.visible) (s = new jA()), (o = {}); else if (i.category === 'lambert') { s = new tk(); let l = new Ut(r.color(i.emissive) ?? 0); (o = { emissive: l }), (s.emissive = l); } else if (i.category === 'toon') { s = new sk(); let l = new Pe(i.shininess ?? 30), h = new Ut(r.color(i.specular) ?? 1118481); (o = { shininess: l, specular: h }), (s.shininess = l), (s.specular = h); } else if (i.category === 'physical') { s = new rk(); let l = new Pe(i.roughness ?? 0.3), h = new Pe(i.metalness ?? 0), u = new Pe(i.reflectivity ?? 0.5); (o = { roughness: l, metalness: h, reflectivity: u }), (s.roughness = l), (s.metalness = h), (s.reflectivity = u); } else { s = new ik(); let l = new Pe(i.shininess ?? 30), h = new Ut(i.specular !== void 0 ? (r.color(i.specular) ?? 1118481) : 1118481); (o = { shininess: l, specular: h }), (s.shininess = l), (s.specular = h); } return ( (s.alpha = new Pe(1)), (s.shadingAlpha = n), (s.shadingBlend = a), (o.alpha = s.shadingAlpha), (o.mode = s.shadingBlend), new yo(e, t, i, s, o) ); } get category() { return this.node.category; } }; function Ek(e) { let t = e instanceof va ? e.type : e; return t === 'texture' || t === 'video' || t === 'displace_map' || t === 'matcap'; } function Ck(e, t, i, r) { switch (e.type) { case 'color': { let s = new Ut(r.color ?? 5526619), n = new Pe(r.alpha ?? 1), a = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f'); a.keywords.alpha = n; let o = new xt(r.mode ?? 0); return (s.alpha = n), new pi(t, i, e, { color: s, alpha: n, mode: o }, s, o, a); } case 'fresnel': { let s = new Ut(r.color ?? 16777215), n = new Pe(r.bias ?? 0.1), a = new Pe(r.scale ?? 1), o = new Pe(r.intensity ?? 2), l = new Pe(r.factor ?? 1), h = new Pe(r.alpha ?? 1), u = new xt(r.mode ?? 0), c = new WA(s, n, a, o, l, h, u), d = new Pt(c.calpha, 'f'); return new pi(t, i, e, { color: s, bias: n, scale: a, intensity: o, factor: l, alpha: h, mode: u }, c, u, d); } case 'rainbow': { let s = new Pe(r.filmThickness ?? 30), n = new Pe(r.movement ?? 0), a = new fr(r.wavelengths ?? new E(0, 0, 0)), o = new Pe(r.noiseStrength ?? 0), l = new Pe(r.noiseScale ?? 1), h = new fr(r.offset ?? new E(0, 0, 0)), u = new Pe(r.alpha ?? 1), c = new qA(s, n, a, o, l, h, u), d = new Pt(c.calpha, 'f'), p = new xt(r.mode ?? 0); return new pi( t, i, e, { filmThickness: s, movement: n, wavelengths: a, noiseStrength: o, noiseScale: l, offset: h, alpha: u, mode: p }, c, p, d ); } case 'transmission': { let s = new Pe(r.thickness ?? 10), n = new Pe(r.ior ?? 1.5), a = new Pe(r.roughness ?? 0.5), o = Lt.transmissionSize, l = Lt.transmissionRenderTarget, h = Lt.transmissionRenderTargetDepth, u = window.innerWidth, c = window.innerHeight, d = u >= c ? new vr(c / u, 1) : new vr(1, u / c), p = new Pe(r.alpha ?? 1), f = new KA(s, n, a, o, l, h, d, p), g = new Pt(f.calpha, 'f'), m = new xt(r.mode ?? 0); return new pi(t, i, e, { thickness: s, ior: n, roughness: a, aspectRatio: d, alpha: p, mode: m }, f, m, g); } case 'toon': { let s = new xt(r.positioning ?? 0), n; r.colors ? (n = new ta(r.colors.length, r.colors)) : ((n = new ta(10, new $e(0, 0, 0, 1))), (n.value[1] = new $e(1, 1, 1, 1))); let a; r.steps ? (a = new ea(r.steps.length, r.steps)) : ((a = new ea(10, 1)), (a.value[0] = 0)); let o = new fr(r.source ?? new E(0, 0, 0)), l = new Ol(r.isWorldSpace ?? !0), h = new Pe(r.noiseStrength ?? 0), u = new Pe(r.noiseScale ?? 1), c = new na(r.shadowColor), d = new fr(r.offset ?? new E(0, 0, 0)), p = new Pe(r.alpha ?? 1), f = new pS(s, n, a, o, l, h, u, c, d, p), g = new Pt(f.calpha, 'f'), m = new xt(r.mode ?? 0); return new pi( t, i, e, { positioning: s, colors: n, steps: a, source: o, isWorldSpace: l, noiseStrength: h, noiseScale: u, shadowColor: c, offset: d, alpha: p, mode: m }, f, m, g ); } case 'outline': { let s = new Ut(r.outlineColor ?? 16777215), n = new Ut(r.contourColor ?? 16777215), a = new Pe(r.outlineWidth ?? 0.1), o = new Pe(r.contourWidth ?? 0.1), l = new Pe(r.outlineThreshold ?? 0.1), h = new Pe(r.contourThreshold ?? 0.1), u = new Pe(r.outlineSmoothing ?? 0.1), c = new Pe(r.contourFrequency ?? 0.1), d = new fr(r.contourDirection ?? new E(0, 1, 0)), p = new Ol(r.positionalLines ?? !1), f = new Ol(r.compensation ?? !0), g = Lt.normalRenderTarget, m = Lt.normalRenderTargetDepth, v = Lt.pixelRatioNode, y = Lt.resolution, b = new Pe(r.alpha ?? 1), x = new QA(s, n, a, o, l, h, u, c, d, p, f, y, g, m, v, b), w = new Pt(x.calpha, 'f'), A = new xt(r.mode ?? 0); return new pi( t, i, e, { outlineColor: s, contourColor: n, outlineWidth: a, contourWidth: o, outlineThreshold: l, contourThreshold: h, outlineSmoothing: u, contourFrequency: c, contourDirection: d, positionalLines: p, compensation: f, alpha: b, mode: A }, x, A, w ); } case 'depth': { let s = new xt(r.gradientType ?? 0), n = new Ol(r.smooth ?? !1), a = new Pe(r.near ?? 50), o = new Pe(r.far ?? 200), l = new Pe(r.isVector ?? 1), h = new Pe(r.isWorldSpace ?? 0), u = new fr(r.origin ?? new E()), c = new fr(r.direction ?? new E()), d; r.colors ? (d = new ta(r.colors.length, r.colors)) : ((d = new ta(2, new $e(0, 0, 0, 1))), (d.value[1] = new $e(1, 1, 1, 1))); let p; r.steps ? (p = new ea(r.steps.length, r.steps)) : ((p = new ea(2, 1)), (p.value[0] = 0)); let f = new Pe(r.alpha ?? 1), g = new xt(r.mode ?? 0), m = new JA(s, n, a, o, l, h, u, c, d, p, f), v = new Pt(m.calpha, 'f'); return new pi( t, i, e, { gradientType: s, smooth: n, near: a, far: o, isVector: l, isWorldSpace: h, origin: u, direction: c, colors: d, steps: p, alpha: f, mode: g }, m, g, v ); } case 'noise': { let s = new Pe(r.scale ?? 1), n = new fr(r.size ?? new E(100, 100, 100)), a = new Pe(r.move ?? 1), o = new vr(r.fA ?? new G(1.7, 9.2)), l = new vr(r.fB ?? new G(8.3, 2.8)), h = new vr(r.distortion ?? new G(1, 1)), u = new na(r.colorA), c = new na(r.colorB), d = new na(r.colorC), p = new na(r.colorD), f = new Pe(r.alpha ?? 1), g = new xt(r.mode ?? 0), m = new xt(r.noiseType ?? 0), v = new VA(s, n, a, o, l, h, u, c, d, p, f, m), y = new Pt(v.calpha, 'f'); return new pi( t, i, e, { scale: s, size: n, move: a, fA: o, fB: l, distortion: h, colorA: u, colorB: c, colorC: d, colorD: p, alpha: f, mode: g, noiseType: m }, v, g, y ); } case 'normal': { let s = new fr(r.cnormal ?? new E(1, 1, 1)), n = new Pe(r.alpha ?? 1), a = new xt(r.mode ?? 0), o = new nS(s, n), l = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f'); return (l.keywords.alpha = n), new pi(t, i, e, { cnormal: s, alpha: n, mode: a }, o, a, l); } case 'gradient': { let s = new xt(r.gradientType ?? 0), n = new Ol(r.smooth ?? !1), a; r.colors ? (a = new ta(r.colors.length, r.colors)) : ((a = new ta(10, new $e(0, 0, 0, 1))), (a.value[1] = new $e(1, 1, 1, 1))); let o; r.steps ? (o = new ea(r.steps.length, r.steps)) : ((o = new ea(10, 1)), (o.value[0] = 0)); let l = new vr(r.offset ?? new G(0, 0)), h = new vr(r.morph ?? new G(0, 0)), u = new Pe(r.angle ?? 0), c = new Pe(r.alpha ?? 1), d = new xt(r.mode ?? 0), p = new iS(s, n, a, o, l, h, u, c), f = new Pt(p.calpha, 'f'); return new pi( t, i, e, { gradientType: s, smooth: n, colors: a, steps: o, offset: l, morph: h, angle: u, alpha: c, mode: d }, p, d, f ); } default: { let s = new Ut(1, 0, 0, 1), n = new Pe(1), a = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f'); a.keywords.alpha = n; let o = new xt(0); return (s.alpha = n), new pi(t, i, e, { color: s, alpha: n, mode: o }, s, o, a); } } } function Tk(e, t, i, r) { let s = nk(i, r); return Ck(i, e, t, s); } function mS(e, t, i) { if (i.type === 'displace' && (e === 'intensity' || e === 'visible')) { let r = t.uniforms[`f${t.id}_intensity`]; return r ? ((r.value = i.intensity * (i.visible ? 1 : 0)), r) : void 0; } if (i.type !== 'displace' && (e === 'alpha' || e === 'visible')) { let r = t.uniforms[`f${t.id}_alpha`]; if (!r) return; if (((r.value = i.alpha * (i.visible ? 1 : 0)), i.type === 'outline' && e === 'visible')) { let s = t.uniforms[`f${t.id}_compensation`]; s && (s.value = i.compensation && i.visible); } return r; } } function Jd(e, t) { let i = 0; for (let r of e.layers) if ( r.data.type !== 'displace' && 'alpha' in r.data && r.data.type !== 'light' && r.data.type !== 'fresnel' && r.data.type !== 'texture' && r.data.type !== 'matcap' && r.data.type !== 'rainbow' && r.data.type !== 'outline' ) { let s = r.data.visible ? r.data.alpha : 0; if ((s === 1 && r.data.type === 'depth') || r.data.type === 'gradient') { for (let n of r.data.colors) if (n[3] < 1) { s = n[3]; break; } } else if (s === 1 && r.data.type === 'noise') { let n = t.color(r.data.colorA).a, a = t.color(r.data.colorB).a, o = t.color(r.data.colorC).a, l = t.color(r.data.colorD).a, h = Math.min(n, Math.min(a, Math.min(o, l))); h < 1 && (s = h); } i += (1 - i) * s; } return i < 1; } var Ln = class extends ri { constructor() { super(void 0), (this.flatShading = !1), (this.cacheKey = ''), (this.fog = !0), (this.dithering = !0), (this.vertexColors = !0), (this.transparent = !0); } customProgramCacheKey() { return this.cacheKey; } }, Pk = class extends Ln { constructor(e, t, i, r) { super(), (this.flatShading = e), (this.side = t), (this.wireframe = i), (this.root = r); } updateAfterBuild() { let e = this.root; (this.lights = e.lights), (this.vertexShader = e.vertexShader), (this.fragmentShader = e.fragmentShader), (this.defines = e.defines), (this.uniforms = e.uniforms), (this.extensions = e.extensions), (this.transparent = e.transparent), (this.cacheKey = e.customProgramCacheKey() + 'flat' + this.flatShading + this.side); } onBeforeCompile(e, t) { this.root.onBeforeCompile(e); } get data() { return this.root.data; } get category() { return this.root.category; } getFlavor(e, t, i) { return this.root.getFlavor(e, t, i); } get layers() { return this.root.layers; } get fragment() { return this.root.fragment; } getLayersOfType(e) { return this.root.getLayersOfType(e); } getLayerByUuid(e) { return this.root.getLayerByUuid(e); } updateByOp(e, t, i) { this.root.updateByOp(e, t, i); } nodeMaterialDispose() { this.root.nodeMaterialDispose(); } }, gS = class extends Ln { constructor(e, t) { super(), (this.data = e), (this.layerIdGen = 0), (this.flavors = []), (this.type = 'NodeMaterial'), (this.updaters = []), this.reset0(e, t); } get nodeMaterial() { return this; } getFlavor(e, t, i) { let r = i ? 6 : (e ? 3 : 0) + t; if (r === 0) return this; this.flavors === void 0 && (this.flavors = []), (r -= 1); let s = this.flavors[r]; return ( s === void 0 && ((s = new Pk(e, t, i, this)), (this.flavors[r] = s), (s.flatShading = e), (s.side = t), s.updateAfterBuild()), s ); } get fragment() { return this.lightLayer.node; } get category() { return this.lightLayer.category; } reset(e, t) { this.data !== e && this.reset0(e, t); } reset0(e, t) { this.data = e; let i = e.layers ?? nr.defaultTwoLayerData('phong').layers; (this.layers = i.map((r) => va.create(this.layerIdGen++, r.id, r.data, t.shared))), this.layers.reverse(), (this.name = e.name ?? 'Untitled Material'), this.onUpdate(), (this.transparent = Jd(e, t.shared)); } getLayersOfType(e) { return this.layers.filter((t) => t.type === e); } getLayerByUuid(e) { return this.layers.find((t) => t.uuid === e); } onUpdate() { (this.cacheKey = this.computeCacheKey()), (this.lightLayer = this.layers.find((e) => e instanceof yo)), this.lightLayer === void 0 && (this.lightLayer = new yo(0, '', { ...xr.defaultData('light', 'phong'), visible: !1 }, new jA(), {})), this.dispose(); for (let e of this.flavors) e && e.dispose(); this.blendColors(), this.blendAfterColors(), this.blendPositions(); } updateByOp(e, t, i) { if ((t !== void 0 ? (this.data = t) : (t = this.data), (this.transparent = Jd(t, i.shared)), e.path[0] === 'layers')) { this.data = t; let r = i.shared, s = e.path[1]; if (s === void 0) { if ((this.layers.reverse(), e.type === 4)) { let n = va.create(this.layerIdGen++, e.id, e.data, i.shared); this.layers.splice(e.localIndex, 0, n), i.scene?.markNeedsUpdateRendererDirty(); } else if (e.type === 5) this.layers.splice(e.localIndex, 1)[0].dispose(), i.scene?.markNeedsUpdateRendererDirty(); else if (e.type === 6) { let n = this.layers.findIndex((o) => o.uuid === e.id), a = this.layers[n]; this.layers.splice(n, 1), this.layers.splice(e.localIndex, 0, a), i.scene?.markNeedsUpdateRendererDirty(); } this.layers.reverse(), this.onUpdate(); } else { let n = this.layers.find((a) => a.uuid === s); if (n) { let a = t.layers.data(s); if (n.updateByOp({ ...e, path: e.path.slice(2) }, a, i)) { let o = va.create(this.layerIdGen++, s, a, r); this.layers.splice( this.layers.findIndex((l) => l.uuid === s), 1, o ), this.onUpdate(); } } } } else this.reset(t, i); } blendColors() { let e = this.layers.findIndex((i) => i instanceof pi), t = this.layers.findIndex((i) => i instanceof yo); if (e !== -1 && e < t) { let i = this.layers[e].color; for (let r = e + 1; r < t; ++r) { let s = this.layers[r]; s instanceof pi && (i = new jx(i, s.color, s.alpha, s.mode)); } this.fragment.color = i; } else this.fragment.color = void 0; } blendAfterColors() { let e = new Pt('outgoingLight', 'f'), t = this.layers.findIndex((i) => i instanceof yo); if (this.layers.length > t + 1) { for (let i = t + 1; i < this.layers.length; ++i) { let r = this.layers[i]; r instanceof pi && (e = new jx(e, r.color, r.alpha, r.mode)); } this.fragment.afterColor = e; } else this.fragment.afterColor = void 0; } blendPositions() { let e = this.layers.filter((t) => t instanceof fS); if (e.length > 0) { let t = e[0].position; for (let i = 1; i < e.length; ++i) e[i] && ((t = new cs(t, e[i].position, cs.ADD)), (t = new cs(t, new Pe(0.5).setReadonly(!0), cs.MUL))); this.fragment.position = t; } else this.fragment.position = void 0; } getDefines() { return this.defines; } getUniforms() { return this.uniforms; } getVertexShader() { return this.vertexShader; } getFragmentShader() { return this.fragmentShader; } onBeforeCompile(e) { this.build(), (e.defines = this.defines), (e.uniforms = this.uniforms), (e.vertexShader = this.vertexShader), (e.fragmentShader = this.fragmentShader), (e.extensionDerivatives = this.extensions.derivatives === !0), (e.extensionFragDepth = this.extensions.fragDepth === !0), (e.extensionDrawBuffers = this.extensions.drawBuffers === !0), (e.extensionShaderTextureLOD = this.extensions.shaderTextureLOD === !0); } clampUniformsForPreview(e, t) { let i = (r, s, n) => Math.min(Math.max(r, s), n); for (let r of this.layers) if (r.type === 'displace') { let s = i(r.uniforms[`f${r.id}_intensity`].value, e, t); r.uniforms[`f${r.id}_intensity`].value = s; } } computeCacheKey() { let e = '['; for (let { data: t } of this.data.layers) if (t.type === 'light') e += `"${t.visible ? t.category.toUpperCase() : 'Basic'}"`; else { let i = (oS[t.type] ?? []).map((n) => t[n]), r = (lS[t.type] ?? []).map((n) => t[n]?.length ?? 0), s = [...i, ...r]; s.length ? (e += `["${t.type}", "${s.join('","')}"],`) : (e += `"${t.type}",`); } return (e = e.slice(0, -1) + ']'), e; } updateFrame(e) { for (let t = 0; t < this.updaters.length; ++t) e.updateNode(this.updaters[t]); } build() { let e = new ek(); (this.lights = this.lightLayer.data.visible), e.build(this.fragment, this.fragment), (this.vertexShader = e.getCode('vertex')), (this.fragmentShader = e.getCode('fragment')), (this.defines = e.defines), (this.uniforms = e.uniforms), (this.extensions = e.extensions), (this.updaters = e.updaters); for (let t of this.flavors) t && t.updateAfterBuild(); return this; } nodeMaterialDispose() { this.layers.forEach((e) => e.dispose()), super.dispose(); for (let e of this.flavors) e && e.dispose(); } assetsLoaded() { for (let e of this.layers) if (e instanceof pi) { let t = e.params.texture; if (t instanceof jm && !t.image.loaded) return !1; } return !0; } getHash() { let e = '{'; return (e += '"fragment":' + this.fragment.getHash()), (e += '}'), e; } }; Object.defineProperties(Ln.prototype, { properties: { get: function () { return this.fragment.properties; } } }); var Gm = class extends gS {}, Dk = Eh(X2()), Vx = new Map(); function Lk(e) { if (typeof e == 'string') return e; let t = Vx.get(e); return t || ((t = { url: URL.createObjectURL(new Blob([e])) }), Vx.set(e, t)), t.url; } var Yl = class { constructor({ src: e, volume: t, delay: i, loop: r }) { (this._volume = 1), (this.delay = 0), (this._loop = 1), (this.loopsRemaining = 0), (this._status = 'stopped'), (this.onEnd = () => { this.loopsRemaining === 1 / 0 ? this.replay() : this.loopsRemaining > 1 ? (this.replay(), this.loopsRemaining--) : ((this._status = 'stopped'), (this.loopsRemaining = this._loop)); }); let s; typeof e == 'string' ? (s = { src: e }) : (s = { src: Lk(e), format: 'wav' }), (this.sound = new Dk.Howl(s)), this.sound.on('end', this.onEnd), (this.src = e), t !== void 0 && (this.volume = t), i !== void 0 && (this.delay = i), r !== void 0 && (this.loop = r); } get status() { return this._status; } get volume() { return this._volume; } set volume(e) { (this._volume = e), this.sound.volume(e); } get loop() { return this._loop; } set loop(e) { (this._loop = e), (this.loopsRemaining = e); } replay() { this.clearDelay(), (this.delayTimerId = window.setTimeout(() => { this.sound.play(), this.clearDelay(); }, this.delay)); } fade(e, t = 1e3) { e ? (this.sound.volume(this._volume), this.clearFade(), (this.fadeTimerId = window.setTimeout(() => { this.sound.fade(this._volume, 0, t), this.clearFade(); }, e))) : this.sound.fade(this._volume, 0, t); } on(e, t, i) { this.sound.on(e, t, i); } off(e, t, i) { this.sound.off(e, t, i); } play() { this._status === 'playing' || this.sound.playing() || (this._status === 'paused' ? (this.sound.seek() === 0 ? this.replay() : this.sound.play(), (this._status = 'playing')) : this._status === 'stopped' && (this.replay(), (this._status = 'playing'))); } pause() { this._status === 'playing' && (this.sound.pause(), this.clearFade(), this.clearDelay(), (this._status = 'paused')); } stop() { this.sound.stop(), (this.loopsRemaining = this._loop), this.clearFade(), this.clearDelay(), (this._status = 'stopped'); } clearFade() { this.fadeTimerId && (clearTimeout(this.fadeTimerId), delete this.fadeTimerId); } clearDelay() { this.delayTimerId && (clearTimeout(this.delayTimerId), delete this.delayTimerId); } dispose(e = !1) { this.off(), this.stop(), this.clearFade(), this.clearDelay(); } }, Ok = class { constructor() { (this.type = 'ShapePath'), (this.color = new Ge()), (this.subPaths = []), (this.currentPath = null); } moveTo(e, t) { return (this.currentPath = new yd()), this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this; } lineTo(e, t) { return this.currentPath?.lineTo(e, t), this; } quadraticCurveTo(e, t, i, r) { return this.currentPath?.quadraticCurveTo(e, t, i, r), this; } bezierCurveTo(e, t, i, r, s, n) { return this.currentPath?.bezierCurveTo(e, t, i, r, s, n), this; } splineThru(e) { return this.currentPath?.splineThru(e), this; } toShapes() { let e = { ORIGIN: 0, DESTINATION: 1, BETWEEN: 2, LEFT: 3, RIGHT: 4, BEHIND: 5, BEYOND: 6 }, t = { loc: e.ORIGIN, t: 0 }; function i(p, f, g, m) { let v = p.x, y = f.x, b = g.x, x = m.x, w = p.y, A = f.y, S = g.y, _ = m.y, M = (x - b) * (w - S) - (_ - S) * (v - b), C = (y - v) * (w - S) - (A - w) * (v - b), T = (_ - S) * (y - v) - (x - b) * (A - w), P = M / T, L = C / T; if ((T === 0 && M !== 0) || P <= 0 || P >= 1 || L < 0 || L > 1) return null; if (M === 0 && T === 0) { for (let D = 0; D < 2; D++) if ((r(D === 0 ? g : m, p, f), t.loc === e.ORIGIN)) { let k = D === 0 ? g : m; return { x: k.x, y: k.y, t: t.t }; } else if (t.loc === e.BETWEEN) { let k = +(v + t.t * (y - v)).toPrecision(10), W = +(w + t.t * (A - w)).toPrecision(10); return { x: k, y: W, t: t.t }; } return null; } else { for (let W = 0; W < 2; W++) if ((r(W === 0 ? g : m, p, f), t.loc === e.ORIGIN)) { let X = W === 0 ? g : m; return { x: X.x, y: X.y, t: t.t }; } let D = +(v + P * (y - v)).toPrecision(10), k = +(w + P * (A - w)).toPrecision(10); return { x: D, y: k, t: P }; } } function r(p, f, g) { let m = g.x - f.x, v = g.y - f.y, y = p.x - f.x, b = p.y - f.y, x = m * b - y * v; if (p.x === f.x && p.y === f.y) { (t.loc = e.ORIGIN), (t.t = 0); return; } if (p.x === g.x && p.y === g.y) { (t.loc = e.DESTINATION), (t.t = 1); return; } if (x < -Number.EPSILON) { t.loc = e.LEFT; return; } if (x > Number.EPSILON) { t.loc = e.RIGHT; return; } if (m * y < 0 || v * b < 0) { t.loc = e.BEHIND; return; } if (Math.sqrt(m * m + v * v) < Math.sqrt(y * y + b * b)) { t.loc = e.BEYOND; return; } let w; m !== 0 ? (w = y / m) : (w = b / v), (t.loc = e.BETWEEN), (t.t = w); } function s(p, f) { let g = [], m = []; for (let v = 1; v < p.length; v++) { let y = p[v - 1], b = p[v]; for (let x = 1; x < f.length; x++) { let w = f[x - 1], A = f[x], S = i(y, b, w, A); S !== null && g.find((_) => _.t <= S.t + Number.EPSILON && _.t >= S.t - Number.EPSILON) === void 0 && (g.push(S), m.push(new G(S.x, S.y))); } } return m; } function n(p, f, g) { let m = new G(); f.getCenter(m); let v = []; return ( g.forEach((y) => { y.boundingBox.containsPoint(m) && s(p, y.points).forEach((b) => { v.push({ identifier: y.identifier, isCW: y.isCW, point: b }); }); }), v.sort((y, b) => y.point.x - b.point.x), v ); } function a(p, f, g, m, v) { (v == null || v === '') && (v = 'nonzero'); let y = new G(); p.boundingBox.getCenter(y); let b = [new G(g, y.y), new G(m, y.y)], x = n(b, p.boundingBox, f); x.sort((C, T) => C.point.x - T.point.x); let w = [], A = []; x.forEach((C) => { C.identifier === p.identifier ? w.push(C) : A.push(C); }); let S = w[0].point.x, _ = [], M = 0; for (; M < A.length && A[M].point.x < S; ) _.length > 0 && _[_.length - 1] === A[M].identifier ? _.pop() : _.push(A[M].identifier), M++; if ((_.push(p.identifier), v === 'evenodd')) { let C = _.length % 2 === 0, T = _[_.length - 2]; return { identifier: p.identifier, isHole: C, for: T }; } else if (v === 'nonzero') { let C = !0, T = null, P = null; for (let L = 0; L < _.length; L++) { let D = _[L]; f[D] && (C ? ((P = f[D].isCW), (C = !1), (T = D)) : P !== f[D].isCW && ((P = f[D].isCW), (C = !0))); } return { identifier: p.identifier, isHole: C, for: T }; } else console.warn('fill-rule: "' + v + '" is currently not implemented.'); } let o = 0, l = 999999999, h = -999999999, u = []; this.subPaths.forEach((p) => { let f = p.getPoints(), g = -999999999, m = 999999999, v = -999999999, y = 999999999; for (let b = 0; b < f.length; b++) { let x = f[b]; x.y > g && (g = x.y), x.y < m && (m = x.y), x.x > v && (v = x.x), x.x < y && (y = x.x); } h <= v && (h = v + 1), l >= y && (l = y - 1), f.length && u.push({ curves: p.curves, points: f, isCW: Rw.isClockWise(f), identifier: o++, boundingBox: new rL(new G(y, m), new G(v, g)) }); }); let c = u.map((p) => a(p, u, l, h, this.userData?.style.fillRule)), d = []; return ( u.forEach((p) => { let f = c[p.identifier]; if (f && !f.isHole) { let g = new xd(); (g.curves = p.curves), c .filter((m) => m?.isHole && m.for === p.identifier) .forEach((m) => { if (m) { let v = u[m.identifier], y = new yd(); (y.curves = v.curves), g.holes.push(y); } }), d.push(g); } }), d ); } }, vS, Hx = new Promise((e) => { vS = e; }), Wx = !1; async function Ik() { if (Wx) return; let e = await import('./opentype.js'); vS(e), (Wx = !0); } var Rk = class { async load(e, t, i = () => {}) { let { load: r } = await Hx; r(e, (s, n) => { s || !n ? i(s ?? 'Something went wrong') : t(n); }); } async parse(e) { let { parse: t, Bidi: i } = await Hx; try { let r = t(e), s = new i(), n = (a) => r.charToGlyphIndex(a.char); return s.registerModifier('glyphIndex', null, n), s.applyFeatures(r, r.defaultRenderOptions.features), { font: r, bidi: s }; } catch (r) { console.error(r); } } }; async function Bk(e) { return await (await fetch(e)).arrayBuffer(); } var zk = new Rk(); async function Xx(e) { let t, i, r = !1; if ((e.url ? ((t = await Bk(e.url)), (i = e.url), (r = e.url.startsWith('/'))) : e.data && (t = e.data.buffer), t)) { let s = await zk.parse(t); if (s) return { font: s.font, url: i, intercepted: r, arr: t, bidi: s.bidi }; } } function Nk(e, t) { return t.state.glyphIndex === e || t.state.fina === e || t.state.medi === e || t.state.init === e; } var Uk = class { constructor(e) { (this._arrayBuffer = new ArrayBuffer(1)), (this._isLoaded = !1), (this._intercepted = !1), (this._isUserFont = e.isUserFont ?? !1), (this._loadingPromise = Xx(e).then((t) => { t && ((this._arrayBuffer = t.arr), (this._url = t.url), (this.font = t.font), (this._intercepted = t.intercepted), (this._isLoaded = !0), (this._bidi = t.bidi)); })); } update(e) { (this._isLoaded = !1), (this._isUserFont = e.isUserFont ?? !1), (this._loadingPromise = Xx(e).then((t) => { t && ((this._arrayBuffer = t.arr), (this._url = t.url), (this.font = t.font), (this._intercepted = t.intercepted), (this._isLoaded = !0), (this._bidi = t.bidi)); })); } get url() { return this._url; } get intercepted() { return this._intercepted; } get isLoaded() { return this._isLoaded; } get loadingPromise() { return this._loadingPromise; } reverseLigaturesTable(e, t, i) { if (!this._bidi) return []; let r = this._bidi; r.getTextGlyphs(t); let s = r.tokenizer.tokens, n = [], a = 0, o = i.length === s.length; for (let l = 0; l < i.length; l++) { let h = i[l].index, u = String.fromCharCode(i[l].unicode), c = s[a]; if (Nk(h, c) || o) n.push({ char: u, index: h, replacements: [c.state.glyphIndex], replacementChars: [c.char] }), a++; else { let d = c.char, p = '', f = [c.state.glyphIndex], g = [], m = !1; for (; !m; ) a++, (p = t.charAt(a)), (d += p), f.push(e.charToGlyphIndex(p)), (g = e.stringToGlyphs(d)), g.length === 1 && g[0].index === h && (m = !0), a > t.length && (m = !0); n.push({ char: u, index: h, replacements: f, replacementChars: Array.from(d) }), a++; } } return n; } generateShapes(e, t) { if (!this._isLoaded) return; let i = this.font, r = t.fontSize / this.unitsPerEm, s = t.fontSize * t.lineHeight, n = e.map((v) => this.getTextWidth(v, t)), a = t.width, o = this.getCharWidth( ` `, t ), l = t.horizontalAlign === 1 ? o : 0, h = this.computeSpaceWidthForLine(e, 0, t), u = this.getLineInitialOffsetX(n[0], a, t.horizontalAlign, e[0], o), c = this.getLineInitialOffsetY(s, e.length, t.height, r, t.verticalAlign), d = [], p = e.map((v) => []), f = e.map((v) => []), g; for (let v = 0; v < e.length; v++) { let y = e[v], b = { features: { liga: !0 } }, x = []; try { x = i.stringToGlyphs(y, b); } catch (A) { console.warn(A); } u = this.getLineInitialOffsetX(n[v], a, t.horizontalAlign, y, o); let w = []; try { w = this.reverseLigaturesTable(i, y, x); } catch (A) { console.warn(A); } h = this.computeSpaceWidthForLine(e, v, t); for (let A = 0; A < x.length; A++) { let S = x[A], _ = S.index === 0 ? ` ` : S.unicode ? String.fromCharCode(S.unicode) : void 0, M = w[A], C = 0, T = 0; A === 0 && t.horizontalAlign === 2 && S.leftSideBearing !== void 0 && (T = -S.leftSideBearing * r), g && (C = i.getKerningValue(S, g) * r), (u += T + C); let P = 0; if ( _ === ` ` ) P = l; else if (_ === ' ') P = h; else { let L = this.createPath(S, r, u, c, t); L && ((P = L.offsetX - (C + T)), d.push(L.path)); } if (M.replacements.length === 1) f[v].push([u, c]), p[v].push(P); else { let L = M.replacements.map((X) => (i.glyphs.get(X).advanceWidth ?? 0) * r), D = L.reduce((X, z) => (X += z), 0), k = L.map((X) => X / D), W = u; for (let X = 0; X < k.length; X++) { let z = P * k[X]; f[v].push([W, c]), p[v].push(z), (W += z); } } (u += P), (g = S); } c -= s; } let m = []; for (let v = 0, y = d.length; v < y; v++) m.push(...d[v].toShapes()); return { shapes: m, charWidths: p, lineWidths: n, charCoords: f }; } get isUserFont() { return this._isUserFont; } get arrayBuffer() { return this._arrayBuffer; } get ascender() { return this.font?.ascender ?? 0; } get descender() { return this.font?.descender ?? 0; } get familyName() { return this.font?.names.fontFamily ?? ''; } get subfamilyName() { return this.font?.names.fontSubfamily ?? ''; } get unitsPerEm() { return this.font?.unitsPerEm ?? 1; } getLineInitialOffsetX(e, t, i, r, s) { return ( (i === 3 || i === 2) && r.indexOf(` `) >= 0 && (e -= s), i === 3 ? t * 0.5 - e * 0.5 : i === 2 ? t - e : 0 ); } getLineInitialOffsetY(e, t, i, r, s) { let n = t * e, a = Math.abs(this.ascender - this.descender) * r, o = e - a, l = -this.ascender * r - o / 2; return s === 3 ? -(i - n - l) : s === 2 ? -(i * 0.5 - n * 0.5 - l) : l; } createPath(e, t, i, r, s) { let n = e.getPath(i, -r, s.fontSize, { kerning: !1, letterSpacing: s.letterSpacing }); if (!n) { console.error('THREE.Font: character "' + e + '" does not exists in font family ' + this.familyName + '.'); return; } let a = new Ok(), o = (e.advanceWidth ?? 1) * t; if (e) for (let l of n.commands) { let h = a.currentPath?.currentPoint; if (!(h && l.type !== 'Z' && h.x === l.x && -h.y === l.y)) switch (l.type) { case 'M': a.moveTo(l.x, -l.y); break; case 'L': a.lineTo(l.x, -l.y); break; case 'Q': a.quadraticCurveTo(l.x1, -l.y1, l.x, -l.y); break; case 'C': a.bezierCurveTo(l.x1, -l.y1, l.x2, -l.y2, l.x, -l.y); break; } } return ( a.subPaths.forEach((l) => { let h = Fk(l.curves); h !== void 0 && l.currentPoint.distanceTo(h) > 0 && l.lineTo(h.x, h.y); }), { offsetX: o + s.fontSize * s.letterSpacing, path: a } ); } getCharWidth(e, t) { return this.font?.getAdvanceWidth(e, t.fontSize, { kerning: !0, letterSpacing: t.letterSpacing }) ?? 0; } getTextWidth(e, t) { return this.font?.getAdvanceWidth(e, t.fontSize, { kerning: !0, letterSpacing: t.letterSpacing }) ?? 0; } computeSpaceWidthForLine(e, t, i) { let r = this.getCharWidth(' ', i), s = e[t]; if (s) { let n = this.countSpaces(s.trimEnd()); if (i.horizontalAlign === 4 && t < e.length - 1 && n) { let a = i.width, o = this.getTextWidth(s, i); return (a - (o - n * r)) / n; } } return r; } countSpaces(e) { return (e.match(/ /g) || []).length; } }; function Fk(e) { if (e.length) { let t = e[0]; if (t instanceof Gr) return t.v1; if (t instanceof Fr || t instanceof Pn) return t.v0; } } var kk = class { constructor() { (this.objects = new Map()), (this.unreachable = new Set()); } getCached(e) { return this.objects.get(e); } get size() { return this.objects.size; } get(e, t) { let i = this.objects.get(e); return i === void 0 ? ((i = this.createObject(e, t)), this.objects.set(e, i)) : (i.isShared = !0), i; } mutateIfUnique(e, t) { let i = this.objects.get(e); if (i && i.isShared !== !0) return this.objects.delete(e), this.objects.set(t, i), i; } startGc() { this.unreachable = new Set(this.objects.keys()); } markAsReachable(e, t) { let i = this.objects.get(e); t === i && this.unreachable.delete(e); } endGc() { this.unreachable.forEach((e) => { this.disposeObject(this.objects.get(e)), this.objects.delete(e); }), this.unreachable.clear(); } dispose() { this.objects.forEach((e) => { this.disposeObject(e); }), this.objects.clear(); } }, qx = class extends kk { constructor(e) { super(), (this.flatShading = e); } disposeObject(e) { e.dispose(); } createObject(e, t) { let i = Zd(e, t, this.flatShading); return i.computeBoundingSphere(), i; } }, jk = { find(e) {}, markNeedsUpdateRendererDirty: function () {}, markGeometryCacheDirty: function () {}, addPendingExpandCloner: function (e) {}, addPendingUpdateCloner(e) {}, addPendingCommand(e) {} }, Gk = class extends wk { constructor(e) { super(), (this.shared = e); } create(e) { return new aS(e, this.shared); } }, Eu = class { constructor(e, t = {}) { if ( ((this.geometryCache = new qx(!0)), (this.geometryCache2 = new qx(!1)), (this.imageHolderCache = new Gk(this)), (this.thisContext = { scene: jk, shared: this }), (this.deletedMaterial = new Gm(nr.defaultTwoLayerData('phong'), this.thisContext)), (this.deletedImage = new ha(Hd.emptyImage, this)), (this.deletedVideo = new ha(Rd.defaultVideo, this)), (this.materials = {}), (this.images = {}), (this.videos = {}), (this.colors = {}), (this.audios = {}), (this.fonts = {}), (this.penumbraSize = []), (this.requestRender = () => { this._requestRender && this._requestRender(); }), t.images) ) for (let [i, r] of Object.entries(t.images)) this.addImage(i, r); if (t.videos) for (let [i, r] of Object.entries(t.videos)) this.addVideo(i, r); if (t.audios) for (let [i, r] of Object.entries(t.audios)) this.addAudio(i, r.data); this.reset(e); } setRequestRender(e) { this._requestRender = e; } reset(e) { for (let [t, i] of Object.entries(e.images)) this.addImage(t, i); for (let [t, i] of Object.entries(e.videos)) this.addVideo(t, i); for (let [t, i] of Object.entries(e.colors)) this.addColor(t, i); for (let [t, i] of Object.entries(e.materials)) this.addMaterial(t, new Gm(i, this.thisContext)); for (let [t, i] of Object.entries(e.audios)) this.addAudio(t, i.data); for (let [t, i] of Object.entries(e.fonts)) this.addFont(t, i); this.penumbraSize = e.penumbraSize; } addMaterial(e, t) { (t.uuid = e), (this.materials[e] = t); } deleteMaterial(e) { this.materials[e] && (this.materials[e].nodeMaterialDispose(), delete this.materials[e]); } getMaterial(e) { return this.materials[e]; } getMaterialOrDeletedPlaceholder(e) { return this.materials[e] ?? this.deletedMaterial; } material(e) { return typeof e == 'string' ? this.getMaterialOrDeletedPlaceholder(e) : new gS(e, this.thisContext); } getMaterials() { return this.materials; } addImage(e, t) { return this.images[e] ? (this.onColorOrImageUpdate && this.onColorOrImageUpdate(), this.images[e].updateSrc(t.data), !0) : ((this.images[e] = new ha(t, this)), !1); } deleteImage(e) { let t = this.images[e]; t && (t.dispose(), delete this.images[e]); } getDefaultImage() { return this.images.image_0; } getImage(e) { return this.images[e] ?? this.deletedImage; } image(e) { return typeof e == 'string' ? this.getImage(e) : this.imageHolderCache.load(e); } addVideo(e, t) { return this.videos[e] ? (this.videos[e].updateSrc(t.data), !0) : ((this.videos[e] = new ha(t, this)), !1); } deleteVideo(e) { let t = this.videos[e]; t && (t.dispose(), delete this.videos[e]); } getVideo(e) { return this.videos[e] ?? this.deletedVideo; } video(e) { return typeof e == 'string' ? this.getVideo(e) : this.imageHolderCache.load(e); } addColor(e, t) { return this.colors[e] ? (this.onColorOrImageUpdate && this.onColorOrImageUpdate(), 'a' in t ? this.colors[e].setRGBA(t.r, t.g, t.b, t.a) : this.colors[e].setRGBA(t.r, t.g, t.b, 1), !0) : ('a' in t ? (this.colors[e] = new Kd(t.r, t.g, t.b, t.a)) : (this.colors[e] = new Kd(t.r, t.g, t.b, 1)), !1); } updateColor(e, t) { if (this.colors[e]) { this.onColorOrImageUpdate && this.onColorOrImageUpdate(); let i = this.colors[e]; return ( (this.colors[e].r = t.r ?? i.r), (this.colors[e].g = t.g ?? i.g), (this.colors[e].b = t.b ?? i.b), (this.colors[e].a = t.a ?? i.a), !0 ); } return !1; } deleteColor(e) { this.colors[e] && delete this.colors[e]; } getColor(e) { return this.colors[e]; } color(e) { let t; if (typeof e == 'string') { let i = this.getColor(e); i ? (t = i) : (console.warn('Tried to create color layer params with a color key that does not exist in the assets manager'), (t = new ji(0, 0, 0, 0))); } else return 'a' in e ? new ji(e.r, e.g, e.b, e.a) : new ji(e.r, e.g, e.b, 1); return t; } addAudio(e, t) { this.audios[e] = t; } getAudio(e) { let t = this.audios[e]; if (t instanceof Yl) return t; { let i = new Yl({ src: t }); return (this.audios[e] = i), i; } } deleteAudio(e) { let t = this.audios[e]; t && (t instanceof Yl && t.dispose(), delete this.audios[e]); } addFont(e, t) { (this.fonts[e] = new Uk(t)), this.fonts[e].loadingPromise.then(() => this.requestRender()); } getFont(e) { return this.fonts[e]; } deleteFont(e) { this.fonts[e] && delete this.fonts[e]; } dispose() { Object.keys(this.materials).forEach((e) => this.deleteMaterial(e)), (this._requestRender = void 0), Object.values(this.audios).forEach((e) => { e instanceof Yl && e.dispose(); }), (this.audios = {}), this.geometryCache.dispose(), this.geometryCache2.dispose(); } }, z9 = new Eu(Wd.emptyData()), Cu = class extends ar { updateByPatchedOp(e, t, i) { if ((super.updateByPatchedOp(e, t, i), LN(e.path, ['materials']) !== null && e.type === 0 && Array.isArray(this.material))) for (let [r, s] of Object.entries(e.props)) { let n = i.shared.material(s); this.material[Number(r)] = n; } else if (pn(e.path, ['material']) && this.material instanceof Ln) 'material' in t && typeof t.material != 'string' && this.material.updateByOp(ir.drop(e, 1), t.material, i); else if (pn(e.path, ['materials', '*']) && Array.isArray(this.material)) { let r = e.path[1]; if ('materials' in t && r < this.material.length) { let s = t.materials[r]; typeof s != 'string' && this.material[r].updateByOp(ir.drop(e, 2), s, i); } } } updateState(e, t) { super.updateState(e, t), e.castShadow !== void 0 && (this.castShadow = e.castShadow), e.receiveShadow !== void 0 && (this.receiveShadow = e.receiveShadow); let i = this.dataPatched; if ( (e.geometry?.type !== 'NonParametricGeometry' && 'material' in e && e.material !== void 0 && (this.disposeMaterial(), (this.material = t.shared.material(e.material).getFlavor(i.flatShading, i.side, i.wireframe)), t.scene?.markNeedsUpdateRendererDirty()), e.geometry?.type === 'NonParametricGeometry' && ('materials' in e && e.materials !== void 0 ? (this.disposeMaterial(), (this.material = e.materials.map((r) => t.shared.material(r).getFlavor(i.flatShading, i.side, i.wireframe))), t.scene?.markNeedsUpdateRendererDirty()) : 'material' in e && e.material !== void 0 && (this.disposeMaterial(), (this.material = [t.shared.material(e.material).getFlavor(i.flatShading, i.side, i.wireframe)]), t.scene?.markNeedsUpdateRendererDirty())), e.flatShading !== void 0 || e.wireframe !== void 0 || e.side !== void 0) ) if (Array.isArray(this.material)) for (let r = 0; r < this.material.length; r++) this.material[r] = this.material[r].getFlavor(i.flatShading, i.side, i.wireframe); else this.material = this.material.getFlavor(i.flatShading, i.side, i.wireframe); } disposeMaterial() { this.material && tA(this.material).forEach((e) => { e instanceof Ln && (e instanceof Gm || e.nodeMaterialDispose()); }); } dispose() { this.disposeMaterial(), super.dispose(); } }, Cr = class extends Cu { constructor(e, t, i) { super(e, t), (this.data = t), (this.localGeometry = void 0); } chooseGeoemtryCache(e) { return e.geometryCache; } markGeometryAsReachable(e) { this.geometryCreateDeleyed instanceof Ve && this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry, this.geometryCreateDeleyed); } get geometry() { if (this.localGeometry !== void 0) return this.localGeometry; if (this.geometryCreateDeleyed instanceof Eu) { let e = this.geometryCreateDeleyed, t = this.chooseGeoemtryCache(e); this.geometryCreateDeleyed = t.get(this.dataPatched.geometry, e); } return this.geometryCreateDeleyed; } set geometry(e) { this.localGeometry = e; } get is2DAndNoDepth() { let e = this.dataPatched.geometry; return Nd.is2DParametricMesh(e.type) && e.depth === 0; } get is2DType() { return Nd.is2DParametricMesh(this.geometry.userData.type); } get isNonParametric() { return this.geometry.userData.type === 'NonParametricGeometry'; } updateByPatchedOp(e, t, i) { super.updateByPatchedOp(e, t, i), pn(e.path, ['geometry']) && this.updateByPatchedOpGeometry(ir.drop(e, 1), t.geometry, i); } removeInteractionGeometry() { this.localGeometry?.dispose(), (this.localGeometry = void 0); } updateGeometryInteractions(e, t) { this.invalidateDownstreamBooleanData(); let i = this.data.geometry.type; if (i === 'NonParametricGeometry' || i === 'SubdivGeometry') { let r = e; if (this.localGeometry === void 0) { let l = { ...this.data.geometry, ...r }; this.localGeometry = Zd(l, t, this.data.flatShading); } let s, n, a; r.scaleBaked ? ([s, n, a] = r.scaleBaked) : ({ width: s, height: n, depth: a } = r); let o = this.localGeometry.userData; o.sxPrev !== void 0 && Um(this.localGeometry.attributes, s / o.sxPrev, n / o.syPrev, a / o.szPrev), (o.sxPrev = s), (o.syPrev = n), (o.szPrev = a); } else { let r = { ...this.data.geometry, ...e }; this.localGeometry?.dispose(), (this.localGeometry = Zd(r, t, this.data.flatShading)); } } refreshAttachedCloners(e) { for (let t of this.attachedSurfaceCloners) e.scene.addPendingUpdateCloner(t.object); } refreshAttachedPaths(e) { for (let t of this.attachedPaths) e.scene.addPendingCommand(() => t.updateShape()); } createGeometryDelayed(e) { (this.geometryCreateDeleyed = e.shared), this.refreshAttachedCloners(e), this.refreshAttachedPaths(e); } updateByPatchedOpGeometry(e, t, i) { let r = !1; e.type === 0 && e.path.length === 0 && jg(['scaleBaked'], Object.keys(e.props)) && this.geometryCreateDeleyed instanceof Oi && this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data, t) === this.geometryCreateDeleyed && ((r = !0), this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t, e.props.scaleBaked), this.refreshAttachedCloners(i), this.refreshAttachedPaths(i)), r || (i.scene?.markGeometryCacheDirty(), this.createGeometryDelayed(i)), this.resetBBoxNeedsUpdate(), this.invalidateDownstreamBooleanData(); } updateGeometryOnStateUpdate(e, t) { this.createGeometryDelayed(t); } updateState(e, t) { e.geometry !== void 0 && this.updateGeometryOnStateUpdate(e.geometry, t), super.updateState(e, t); } updateGeometryGroupsIfNeeded() { Array.isArray(this.material) && this.geometry.groups.length === 0 && this.geometry.addGroup(0, Math.max(this.geometry.getIndex()?.count ?? 0, this.geometry.getAttribute('position').count), 0); } updateEntityBoxSize(e, t) { let i = this.geometry.userData.parameters; this.is2DType ? e.set(0, 0, i.depth * 0.5) : this.isNonParametric ? (e.setScalar(0), this.geometry.boundingSphere && e.copy(this.geometry.boundingSphere.center), t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5)) : e.setScalar(0), t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5); } }; function Vk(e) { if (e.geometry.attributes.extrudeNormal || !e.geometry.attributes.position || !e.geometry.attributes.normal) return; let t = new Map(), i = e.geometry.attributes, r = i.position.array, s = i.normal.array, n = new Float32Array(r.length); for (let a = 0; a < r.length; a += 3) { let o = `${r[a]}_${r[a + 1]}_${r[a + 2]}`, l = new E(s[a], s[a + 1], s[a + 2]); t.has(o) ? t.get(o)?.normals.push(l) : t.set(o, { normals: [l], result: new E() }); } t.forEach((a, o) => { for (let l of a.normals) a.result.add(l); a.result.divideScalar(a.normals.length); }); for (let a = 0; a < r.length; a += 3) { let o = `${r[a]}_${r[a + 1]}_${r[a + 2]}`, l = t.get(o)?.result; l && ((n[a] = l.x), (n[a + 1] = l.y), (n[a + 2] = l.z)); } e.geometry.setAttribute('extrudeNormal', new Ce(n, 3)); } function Hk(e) { if (e.geometry.attributes.extrudeNormals || !e.geometry.attributes.position) return; let t = e.geometry.attributes.position.array, i = new Float32Array(t.length), r = new E(); for (let s = 0; s < t.length; s += 3) r.set(t[s], t[s + 1], t[s + 2]).normalize(), (i[s] = r.x), (i[s + 1] = r.y), (i[s + 2] = r.z); e.geometry.setAttribute('extrudeNormal', new Ce(i, 3)); } function uv(e) { if (Array.isArray(e.material)) { for (let t of e.material) if (t.getLayersOfType('outline').length === 0) return; } else if (!(e.material instanceof Ln) || e.material.getLayersOfType('outline').length === 0) return; e instanceof Cr && e.is2DAndNoDepth ? Hk(e) : Vk(e); } function pv(e) { if (!e.geometry.attributes.position) return; let t = e.geometry.attributes.position.array, i = new Float32Array(t.length), r = parseInt(e.uuid.replace(/\D/g, '')), s = [it.seededRandom(r), it.seededRandom(r + 1e4), it.seededRandom(r + 2e4)]; for (let n = 0; n < t.length; n++) i[n] = s[n % 3]; e.geometry.setAttribute('randomColor', new Xe(i, 3)); } var Wk; av.then((e) => { Wk = e; }); var Kr = new Kt(), Il = new E(); function Xk(e) { let t = !1; return ( e.scene.objects.traverse((i, r) => { r.type === 'Mesh' && r.geometry.type === 'SubdivGeometry' && (t = !0); }), t ); } var Sh = class extends Cr { constructor(e, t, i) { super(e, t, i), (this.data = t), (this.hiddenMatrixOld = new ve()), (this.smoothShading = !0), (this.skipReactionUpdate = !1); } chooseGeoemtryCache(e) { return this.dataPatched.flatShading ? e.geometryCache : e.geometryCache2; } get subdivPointerNew() { return this.localGeometry !== void 0 ? this.subdivPointer : this.geometry.ensureSubdivPointer(); } get originalGeometryNew() { return this.localGeometry !== void 0 ? this.originalGeometry : this.geometry.originalGeometry; } get phongAngle() { return this.data.geometry.phongAngle ?? 45; } updateEntityBoxSize(e, t) { let i = this.geometry.userData.parameters; e.copy(this.originalGeometryNew.boundingSphere.center), t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5); } createGeometryByControls(e) { if (this.skipReactionUpdate === !0) return; let t = this.localGeometry?.uuid, { originalGeometry: i, subdividedGeometry: r, subdivPointer: s } = Oi.build(e, this.subdivPointer, this.smoothShading, this.hasNonUniformScale ? this.shearScale : void 0); (this.subdivPointer = s), i !== void 0 && (this.originalGeometry?.dispose(), (this.originalGeometry = i)), r !== void 0 && (this.subdividedGeometry?.dispose(), (this.subdividedGeometry = r ?? void 0)), (this.localGeometry = this.subdividedGeometry ?? this.originalGeometry), uv(this), pv(this), this.calcBoundingBox(), t && (this.localGeometry.uuid = t); } updateState(e, t) { if ((super.updateState(e, t), e.flatShading !== void 0)) { let i = this.material; (this.material = i.getFlavor(!1, i.side, i.wireframe)), (this.smoothShading = !e.flatShading), this.createGeometryDelayed(t); } } updateMesh(e = !1) { Oi.buildLevel( this.subdivPointer, !0, this.smoothShading ? this.phongAngle : -1, this.originalGeometry, e && this.hasNonUniformScale ? this.shearScaleInv : void 0 ), this.subdividedGeometry && Oi.buildLevel( this.subdivPointer, !1, this.smoothShading ? this.phongAngle : -1, this.subdividedGeometry, e && this.hasNonUniformScale ? this.shearScaleInv : void 0 ); } updateTopology() { this.originalGeometry.dispose(), (this.originalGeometry = Oi.buildLevel(this.subdivPointer, !0, this.smoothShading ? this.phongAngle : -1)), this.subdividedGeometry && (this.subdividedGeometry.dispose(), (this.subdividedGeometry = Oi.buildLevel(this.subdivPointer, !1, this.smoothShading ? this.phongAngle : -1))), (this.localGeometry = this.subdividedGeometry ?? this.originalGeometry); } raycast(e, t) { let i = this.localGeometry; (this.localGeometry = this.originalGeometryNew), ar.prototype.raycast.call(this, e, t), (this.localGeometry = i); } activateSVDCompensation() { !this.hasNonUniformScale || (this.matrix.copy(this.matrixWorldRigid), this.hiddenMatrixOld.copy(this.hiddenMatrix), this.hiddenMatrix.copy(this.parent.matrixWorld).invert()); } deactivateSVDCompensation() { !this.hasNonUniformScale || (this.updateMatrix(), (this.hasNonUniformScale = void 0), this.hiddenMatrix.copy(this.hiddenMatrixOld)); } calcBoundingBox() { let e = this.originalGeometry; e.boundingSphere === null && ((e.boundingSphere = new Mr()), this.subdividedGeometry && (this.subdividedGeometry.boundingSphere = e.boundingSphere)); let t = e.attributes.position, i = e.boundingSphere.center; Kr.setFromBufferAttribute(t), Kr.getCenter(i), (e.boundingSphere.radius = i.distanceTo(Kr.max)), isNaN(e.boundingSphere.radius) && console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ), Kr.getSize(Il), this.hasNonUniformScale && Il.divide(this.scale); let r = { width: Il.x, height: Il.y, depth: Il.z }; return (this.geometry.userData.parameters = r), r; } updateBoundingSphere(e) { let t = this.originalGeometry; Kr.min.set(e[0], e[2], e[4]), Kr.max.set(e[1], e[3], e[5]), this.hasNonUniformScale && (Kr.min.applyMatrix4(this.shearScaleInv), Kr.max.applyMatrix4(this.shearScaleInv)), t.boundingSphere === null && (t.boundingSphere = new Mr()); let i = t.boundingSphere.center; Kr.getCenter(i), (t.boundingSphere.radius = i.distanceTo(Kr.max)); } freeSubdivPointer() { this.subdivPointer && (Oi.freeSubdivPointer(this.subdivPointer), (this.subdivPointer = 0)), (this.localGeometry = void 0), this.originalGeometry?.dispose(), this.subdividedGeometry?.dispose(); } dispose() { super.dispose(), this.freeSubdivPointer(); } updateByPatchedOpGeometry(e, t, i) { super.updateByPatchedOpGeometry(e, t, i), this.localGeometry && this.createGeometryByControls(t); } }, Yx = -1, qk = 1, Yk = { x: [1, 0, 0], '-x': [-1, 0, 0], y: [0, 1, 0], '-y': [0, -1, 0], z: [0, 0, 1], '-z': [0, 0, -1] }, Qk = { polygon_center: 0, edge: 1, vertex: 2 }, jc = (e, t) => (i, r) => (!t || i === 0 || e === 0 ? 0 : (e * r) / 100), Ye = (e, t) => { let i = Math.abs(t), r = i * -1; return ((e - Yx) * (i - r)) / (qk - Yx) + r; }; function Zk(e) { let t = [], i = {}; for (var r = 0, s = e.length; r < s; r++) { var n = JSON.stringify(e[r].pos.map((a) => Math.round(a * 1e4) / 1e4)); i[n] || (t.push(e[r]), (i[n] = !0)); } return t; } var Kk = new E(), Gc = new E(), Jk = new E(), $k = new E(); function Io(e, t) { let i = Jk.fromArray(e), r = $k.fromArray(t); Gc.copy(r).sub(i); let s = Gc.length(); return Gc.normalize().multiplyScalar(s * 0.5), Kk.copy(i).add(Gc).toArray(); } var br = new Bi(), Vc = new E(), $d = new E(), aa = new E(); function e8(e) { let t = []; for (let i = 0; i <= e.index.count; i++) if ( (Vc.fromArray(e.index.array, i * 3), br.setFromAttributeAndIndices(e.attributes.position, Vc.x, Vc.y, Vc.z), br.getNormal($d), br.getMidpoint(aa), !(isNaN(aa.x) || isNaN(aa.y) || isNaN(aa.z))) ) { let { a: r, b: s, c: n } = br, a = r.toArray(), o = s.toArray(), l = n.toArray(), h = r.distanceTo(s), u = s.distanceTo(n), c = n.distanceTo(r), d = Io(a, o), p = Io(o, l), f = Io(l, a), g = [h, u, c], m = Math.max(...g), v = g.filter((x) => Math.round(x) === Math.round(m)).length > 1, y = [], b = br.getMidpoint(aa).toArray(); m === h && !v && ((y = [p, f, f]), (b = d)), m === u && !v && ((y = [d, f, f]), (b = p)), m === c && !v && ((y = [d, p, p]), (b = f)), v && (y = [d, p, f]), t.push({ vertices: [a, o, l], faceCenters: y, midpoint: b, norm: br.getNormal($d).toArray() }); } return t; } function t8(e) { let t = [], { position: i } = e.attributes; for (let r = 0; r < i.count; r++) { br.setFromAttributeAndIndices(i, r * 3, r * 3 + 1, r * 3 + 2), br.getNormal($d), br.getMidpoint(aa); let s = br.a.toArray(), n = br.b.toArray(), a = br.c.toArray(); t.push({ vertices: [s, n, a], faceCenters: [Io(s, n), Io(n, a), Io(a, s)], midpoint: aa.toArray(), norm: $d.toArray() }); } return t; } var i8 = 4, r8 = 0.5, af = (e) => 0.5 * (1 - Math.cos(e * Math.PI)), s8 = class { constructor() { this.perlin = new Array(4095 + 1); } noise(e, t = 0, i = 0) { if (this.perlin == null) { this.perlin = new Array(4095 + 1); for (let m = 0; m < 4095 + 1; m++) this.perlin[m] = Math.random(); } e < 0 && (e = -e), t < 0 && (t = -t), i < 0 && (i = -i); let r = Math.floor(e), s = Math.floor(t), n = Math.floor(i), a = e - r, o = t - s, l = i - n, h, u, c = 0, d = 0.5, p, f, g; for (let m = 0; m < i8; m++) { let v = r + (s << 4) + (n << 8); (h = af(a)), (u = af(o)), (p = this.perlin[v & 4095]), (p += h * (this.perlin[(v + 1) & 4095] - p)), (f = this.perlin[(v + 16) & 4095]), (f += h * (this.perlin[(v + 16 + 1) & 4095] - f)), (p += u * (f - p)), (v += 256), (f = this.perlin[v & 4095]), (f += h * (this.perlin[(v + 1) & 4095] - f)), (g = this.perlin[(v + 16) & 4095]), (g += h * (this.perlin[(v + 16 + 1) & 4095] - g)), (f += u * (g - f)), (p += af(l) * (f - p)), (c += p * d), (d *= r8), (r <<= 1), (a *= 2), (s <<= 1), (o *= 2), (n <<= 1), (l *= 2), a >= 1 && (r++, a--), o >= 1 && (s++, o--), l >= 1 && (n++, l--); } return c; } noiseSeed(e) { let t = (() => { let i, r; return { setSeed(s) { r = i = (s ?? Math.random() * 4294967296) >>> 0; }, getSeed() { return i; }, rand() { return (r = (1664525 * r + 1013904223) % 4294967296), r / 4294967296; } }; })(); t.setSeed(e), (this.perlin = new Array(4095 + 1)); for (let i = 0; i < 4095 + 1; i++) this.perlin[i] = t.rand(); } }, n8 = s8, Qx = new E(), Zx = new ve(), Kx = new Xo(); function Jx(e) { let t = !1; return ( e.scene.objects.traverse((i, r) => { r.type === 'Mesh' && r.geometry.type === 'TextGeometry' && (t = !0); }), t ); } var yS = class extends Cr { constructor(e, t, i) { super(e, t, i), (this.data = t); } get textGeometry() { return this.geometry; } get charWidths() { return this.textGeometry.charWidths; } get charCoords() { return this.textGeometry.charCoords; } get wrappedText() { return this.textGeometry.wrappedText; } get font() { return this.textGeometry.font; } get initialOffsetY() { let e = this.dataPatched; return ( this.font?.getLineInitialOffsetY( this.lineHeight, this.wrappedText.length, e.geometry.height, this.fontScale, e.geometry.verticalAlign ) ?? 0 ); } get fontScale() { let e = this.dataPatched; return this.font ? e.geometry.fontSize / this.font.unitsPerEm : 1; } get AD() { return Math.abs(this.ascender - this.descender); } get ascender() { return (this.font?.ascender ?? 1) * this.fontScale; } get descender() { return (this.font?.descender ?? 1) * this.fontScale; } get lineHeight() { let e = this.dataPatched; return e.geometry.fontSize * e.geometry.lineHeight; } raycast(e, t) { let { matrixWorld: i } = this; if ( !(isNaN(e.ray.origin.x) || this.scale.x === 0 || this.scale.y === 0 || this.scale.z === 0) && (Zx.copy(i).invert(), Kx.copy(e.ray).applyMatrix4(Zx), Kx.intersectBox(this.singleBBox, Qx)) ) { let r = Qx.applyMatrix4(i), s = e.ray.origin.distanceTo(r); t.push({ distance: s, point: r.clone(), object: this }); } } }, Pi = 1e-4, Jr, xS, bS, wS, $x = new E(), eb = new E(); av.then((e) => { (Jr = e), (xS = [Jr.get_face_center, Jr.get_edge_midpoint, Jr.get_vertex_position]), (bS = [Jr.get_face_normal, Jr.get_edge_normal, Jr.get_vertex_normal]), (wS = [Jr.face_count, Jr.edge_count, Jr.vertex_count]); }); var a8 = new ve(), o8 = new ve(), nn = new E(), Qn = new E(), Rl = new E(), of = new E(), l8 = new E(), h8 = new E(), Is = new n8(), eu = class extends $g(bt) { constructor(e, t) { super(), (this.parameters = t), (this.objectForSample = void 0), (this._pendingMediaLoad = !1), (this.object = e); } resetOnMove() { this.removeFromParent(), (this.parent = null); } expandClones(e) { if (this.parent === null) this.updateState(this.parameters, e); else for (let t of this.children) t instanceof la && t.expand(); } invalidateTransform(e) { (this.matrixWorldNeedsUpdate = !0), this.traverse((t) => { t instanceof la && t.object === e && (t.matrixWorldNeedsUpdate = !0); }); } onObjUpdateMatrix() { this.parameters.type !== 'toObject' && (this.matrixWorldNeedsUpdate = !0); } update() { switch ((this._updateCount(), this.parameters.type)) { case 'radial': this._updateRadial(this.parameters); break; case 'linear': this._updateLinear(this.parameters); break; case 'grid': this._updateGrid(this.parameters); break; case 'toObject': this._updateToObject(this.parameters); } for (let e of this.children) e.updateMatrix(), e.hasNonUniformScale && (e.updateMatrixWorld(), e.updateMatrixWorldSVD()); } _updateCount(e) { let t; if ( (e !== void 0 ? (t = e) : (t = this.parameters.type === 'grid' ? Math.round(this.parameters.grid.count[0]) * Math.round(this.parameters.grid.count[1]) * Math.round(this.parameters.grid.count[2]) : this.parameters.count), this.parameters.type === 'toObject' && !this.parameters.toObject.object && (t = 0), this.parameters.type === 'toObject' && this.objectForSample) ) { for (let r = 0, s = this.children.length; r < s; ++r) this.remove(this.children[0]); let i = this.children; if (i.length === t) return; if (i.length < t) for (let r = 0, s = t - i.length; r < s; ++r) { let n = new la(this.object); n.expand(), this.add(n); } else for (let r = 0, s = i.length - t; r < s; ++r) this.remove(i[r]); } else { if (this.children.length === t) return; if (this.children.length < t) for (let i = 0, r = t - this.children.length; i < r; ++i) { let s = new la(this.object); s.expand(), this.add(s); } else for (let i = 0, r = this.children.length - t; i < r; ++i) this.remove(this.children[0]); } } _updateRadial(e) { let t = e.radial, i = t.start * it.DEG2RAD, r = t.end * it.DEG2RAD, s = i - r, n = new _i(t.rotation[0], t.rotation[1], t.rotation[2]), a; switch (t.axis) { case 'z': a = new E(0, 0, 1); break; case 'y': a = new E(0, 1, 0); break; default: case 'x': a = new E(1, 0, 0); break; } let o = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject, l = o.noiseType === 'perlin'; Is.noiseSeed(o.seed); let h = Hp((0, El.default)(o.seed)), u = jc(o.strength, this.parameters.randomness); for (let [c, d] of this.children.entries()) { let p = c * (o.freqScale / 10) + o.movement, f = l ? Is.noise(p) : h(p, p); (d.scale.x = t.scale[0] + u(c, Ye(f, o.scale[0])) || Pi), (d.scale.y = t.scale[1] + u(c, Ye(f, o.scale[1])) || Pi), (d.scale.z = t.scale[2] + u(c, Ye(f, o.scale[2])) || Pi), d.position.setScalar(0); let g = (s / e.count) * c - i; switch (t.axis) { case 'x': d.rotation.set(0, g, 0); break; case 'y': d.rotation.set(0, 0, g); break; case 'z': d.rotation.set(g, 0, 0); break; } d.translateOnAxis(a, t.radius), (d.position.x += t.position[0] + u(c, Ye(f, o.position[0]))), (d.position.y += t.position[1] + u(c, Ye(f, o.position[1]))), (d.position.z += t.position[2] + u(c, Ye(f, o.position[2]))); let m = u(c, Ye(f, o.rotation[0])), v = u(c, Ye(f, o.rotation[1])), y = u(c, Ye(f, o.rotation[2])); t.alignment === !0 ? ((d.rotation.x += n.x + m), (d.rotation.y += n.y + v), (d.rotation.z += n.z + y)) : d.rotation.set(n.x + m, n.y + v, n.z + y); } } _updateLinear(e) { if (e.type !== 'linear') throw new Error(); let t = e.linear, i = new _i(t.rotation[0], t.rotation[1], t.rotation[2]), r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject, s = r.noiseType === 'perlin'; Is.noiseSeed(r.seed); let n = Hp((0, El.default)(r.seed)), a = jc(r.strength, this.parameters.randomness); for (let [o, l] of this.children.entries()) { let h = o * (r.freqScale / 10) + r.movement, u = s ? Is.noise(h) : n(h, h), c = a(o, Ye(u, r.rotation[0])), d = a(o, Ye(u, r.rotation[1])), p = a(o, Ye(u, r.rotation[2])); (l.scale.x = 1 + (t.scale[0] - 1) * o + a(o, Ye(u, r.scale[0])) || Pi), (l.scale.y = 1 + (t.scale[1] - 1) * o + a(o, Ye(u, r.scale[1])) || Pi), (l.scale.z = 1 + (t.scale[2] - 1) * o + a(o, Ye(u, r.scale[2])) || Pi), (l.rotation.x = i.x * o + c), (l.rotation.y = i.y * o + d), (l.rotation.z = i.z * o + p), (l.position.x = t.position[0] * o + a(o, Ye(u, r.position[0]))), (l.position.y = t.position[1] * o + a(o, Ye(u, r.position[1]))), (l.position.z = t.position[2] * o + a(o, Ye(u, r.position[2]))); } } _updateGrid(e) { let t = 0, i = e.grid, r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject, s = jc(r.strength, this.parameters.randomness), n = r.noiseType === 'perlin'; Is.noiseSeed(r.seed); let a = lF((0, El.default)(r.seed)); if (i.useCenter === !0) { let o = { x: i.count[0] % 2 === 0 ? 2 : 1, y: i.count[1] % 2 === 0 ? 2 : 1, z: i.count[2] % 2 === 0 ? 2 : 1 }, l = new E(i.size[0] * (i.count[0] - o.x) * 0.5, i.size[1] * (i.count[1] - o.y) * 0.5, i.size[2] * (i.count[2] - o.z) * 0.5); for (let h = 0; h < i.count[0]; h++) for (let u = 0; u < i.count[1]; u++) for (let c = 0; c < i.count[2]; c++) { let d = [ (h + 1) * (r.freqScale / 10) + r.movement, (u + 1) * (r.freqScale / 10) + r.movement, (c + 1) * (r.freqScale / 10) + r.movement ], p = n ? Is.noise(...d) : a(...d), f = this.children[t++]; (f.scale.x = 1 + s(t, Ye(p, r.scale[0])) || Pi), (f.scale.y = 1 + s(t, Ye(p, r.scale[1])) || Pi), (f.scale.z = 1 + s(t, Ye(p, r.scale[2])) || Pi); let g = s(t, Ye(p, r.rotation[0])), m = s(t, Ye(p, r.rotation[1])), v = s(t, Ye(p, r.rotation[2])); f.rotation.set(g, m, v), (f.position.x = i.size[0] * h - l.x + s(t, Ye(p, r.position[0]))), (f.position.y = i.size[1] * u - l.y + s(t, Ye(p, r.position[1]))), (f.position.z = i.size[2] * c - l.z + s(t, Ye(p, r.position[2]))); } } else for (let o = 0; o < i.count[0]; o++) for (let l = 0; l < i.count[1]; l++) for (let h = 0; h < i.count[2]; h++) { let u = [ (o + 1) * (r.freqScale / 10) + r.movement, (l + 1) * (r.freqScale / 10) + r.movement, (h + 1) * (r.freqScale / 10) + r.movement ], c = n ? Is.noise(...u) : a(...u), d = this.children[t++]; (d.scale.x = 1 + s(t, Ye(c, r.scale[0])) || Pi), (d.scale.y = 1 + s(t, Ye(c, r.scale[1])) || Pi), (d.scale.z = 1 + s(t, Ye(c, r.scale[2])) || Pi); let p = s(t, Ye(c, r.rotation[0])), f = s(t, Ye(c, r.rotation[1])), g = s(t, Ye(c, r.rotation[2])); d.rotation.set(p, f, g), (d.position.x = i.size[0] * o + s(t, Ye(c, r.position[0]))), (d.position.y = -i.size[1] * l + s(t, Ye(c, r.position[1]))), (d.position.z = -i.size[2] * h + s(t, Ye(c, r.position[2]))); } } _updateToObject(e) { if (e.type !== 'toObject') throw new Error(); let { toObject: t } = e, i = new _i(t.rotation[0], t.rotation[1], t.rotation[2]), r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject, s = r.noiseType === 'perlin'; Is.noiseSeed(r.seed); let n = Hp((0, El.default)(r.seed)), a = jc(r.strength, this.parameters.randomness); if (!t.object) { for (let [, g] of this.children.entries()) g.position.set(0, 0, 0), g.scale.setScalar(1), g.rotation.set(0, 0, 0); this.objectForSample = void 0; return; } if (!this.objectForSample) return; if (this.objectForSample instanceof yS) if (!this.objectForSample.font?.isLoaded || this.objectForSample.geometry.attributes.position === void 0) { this._pendingMediaLoad = !0; return; } else this._pendingMediaLoad = !1; if (this.objectForSample.geometry === void 0 && this.objectForSample.isAncestorOf(this.object.uuid)) { console.warn( `Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.` ); return; } let o = this.getSubdivData(), l = [], h = (g) => { let m = g.length, v = g.map((x) => x[0]).reduce((x, w) => x + w, 0), y = g.map((x) => x[1]).reduce((x, w) => x + w, 0), b = g.map((x) => x[2]).reduce((x, w) => x + w, 0); return [v / m, y / m, b / m]; }, u = (g) => Math.round(g * 1e6) / 1e6; o.forEach((g) => { let m = o.filter((v) => u(g.pos[0]) === u(v.pos[0]) && u(g.pos[1]) === u(v.pos[1]) && u(g.pos[2]) === u(v.pos[2])); m.length > 1 ? l.push({ pos: g.pos, norm: h(m.map((v) => v.norm)) }) : l.push(g); }); let c = Zk(l); if (o.length > 0) { let g = Math.round((c.length * t.count) / 100); this._updateCount(g); } this.objectForSample.updateMatrixWorld(); let d = new hF(this.objectForSample).build(), p = Yk[t.axis], f = this.children; d.setRandomGenerator((0, El.default)(this.object.uuid + t.seed)); for (let [g, m] of f.entries()) { let v = g * (r.freqScale / 10) + r.movement, y = s ? Is.noise(v) : n(v, v), b = a(g, Ye(y, r.rotation[0])), x = a(g, Ye(y, r.rotation[1])), w = a(g, Ye(y, r.rotation[2])); t.spreadType === 'random' ? d.sample(Rl, of) : (c.length && (Rl.fromArray(c[g].pos), of.fromArray(c[g].norm)), this.objectForSample instanceof Sh && Rl.applyMatrix4(a8.copy(this.objectForSample.matrixWorld).invert())), Rl.applyMatrix4(this.object.hiddenMatrix.clone().invert()), m.position.copy(Rl), nn.fromArray(p); let A = t.align === 'normal' ? of : this.object.getWorldDirection(h8), S = Qn.fromArray(t.position); (Qn.x += Qn.x + a(g, Ye(y, r.position[0]))), (Qn.y += Qn.y + a(g, Ye(y, r.position[1]))), (Qn.z += Qn.z + a(g, Ye(y, r.position[2]))); let _ = Math.acos(A.dot(nn)), M = l8.crossVectors(nn, A).normalize(), C = o8.makeRotationAxis(M, _), T = A.clone().cross(this.object.up).normalize(), P = T.clone().cross(A).normalize(), L = new ve().makeBasis(T, A, P), D = new E(nn.y, nn.z, nn.x).normalize(), k = D.clone().cross(nn).normalize(), W = new ve().makeBasis(D, nn, k).invert(), X = new ve().multiplyMatrices(L, W); m.rotation.setFromRotationMatrix(X), S.applyMatrix4(C), m.position.add(S), (m.rotation.x = m.rotation.x + i.x + b), (m.rotation.y = m.rotation.y + i.y + x), (m.rotation.z = m.rotation.z + i.z + w), m.scale.setScalar(1), (m.scale.x = m.scale.x + t.scale[0] + a(g, Ye(y, r.scale[0])) || Pi), (m.scale.y = m.scale.y + t.scale[1] + a(g, Ye(y, r.scale[1])) || Pi), (m.scale.z = m.scale.z + t.scale[2] + a(g, Ye(y, r.scale[2])) || Pi), m.scale.multiply(this.object.scale), (m.hiddenMatrix = this.object.hiddenMatrix); } } getSubdivData() { if (!this.objectForSample) return []; let e = this.parameters.toObject.spreadType; if (e === 'random') return []; if (this.objectForSample instanceof Sh) { let t = this.objectForSample, i = Qk[e], r = wS[i], s = xS[i], n = bS[i], a = [], o = r(t.subdivPointerNew); for (let l = 0; l <= o - 1; l++) { let h = s(t.subdivPointerNew, l), u = n(t.subdivPointerNew, l); $x.fromArray(h).applyMatrix4(t.matrixWorld), eb.fromArray(u), a.push({ pos: $x.toArray(), norm: eb.toArray() }); } return a; } else return (this.objectForSample.geometry.index ? e8(this.objectForSample.geometry) : t8(this.objectForSample.geometry)) .map((t, i) => e === 'polygon_center' ? { pos: t.midpoint, norm: t.norm } : e === 'vertex' ? [ { pos: t.vertices[0], norm: t.norm }, { pos: t.vertices[1], norm: t.norm }, { pos: t.vertices[2], norm: t.norm } ] : e === 'edge' ? [ { pos: t.faceCenters[0], norm: t.norm }, { pos: t.faceCenters[1], norm: t.norm }, { pos: t.faceCenters[2], norm: t.norm } ] : [] ) .flat(); } updateState(e, t) { if (((this.parameters = yu(e)), this.parameters.type !== 'toObject')) (this.parent === null || this.parent !== this.object) && (this.removeFromParent(), this.object.parent?.add(this), (this.matrix = this.object.matrix), (this.hiddenMatrix = this.object.hiddenMatrix), (this.matrixWorldNeedsUpdate = !0), (this.matrixAutoUpdate = !1)); else if (this.parent === null || this.parent.uuid !== this.parameters.toObject.object) { this.removeFromParent(); let i = t.find(this.parameters.toObject.object); i instanceof ar ? (this.objectForSample = i) : (this.objectForSample = void 0), (this.matrix = new ve()), (this.hiddenMatrix = new ve()), (this.matrixWorldNeedsUpdate = !0), (this.matrixAutoUpdate = !1), i && i.add(this); } this.update(); } get pendingMediaLoad() { return this._pendingMediaLoad; } }, zh = (e) => { var t; return (t = class extends e {}), (t.geometryHelper = new vs(30, 30, 30)), t; }, Hc = new Xo(), lf = new Mr(), tb = new ve(), Nh = (e, t, i, r, s = !1) => { let n = t, a = e.matrixWorld; if ( (n.boundingSphere === null && n.computeBoundingSphere(), lf.copy(n.boundingSphere), lf.applyMatrix4(a), i.ray.intersectsSphere(lf) === !1 || (tb.copy(a).invert(), Hc.copy(i.ray).applyMatrix4(tb), n.boundingBox !== null && Hc.intersectsBox(n.boundingBox) === !1)) ) return; let o, l, h, u, c = n.index, d = n.attributes.position, p = n.drawRange, f, g; if (s === !1) { let v = Math.max(0, p.start), y = Math.min(c.count, p.start + p.count); for (f = v, g = y; f < g; f += 3) if (((l = c.getX(f)), (h = c.getX(f + 1)), (u = c.getX(f + 2)), (o = m(e, i, Hc, d, l, h, u)), o)) { (o.faceIndex = Math.floor(f / 3)), r.push(o); return; } } else { let v = n.attributes.position, y = new E(), b = new E(), x = new E(), w = new E(), A = 2, S = 1 / ((e.scale.x + e.scale.y + e.scale.z) / 3), _ = S * S, M = Math.max(0, p.start), C = Math.min(v.count, p.start + p.count); for (let T = M, P = C - 1; T < P; T += A) { if ((y.fromBufferAttribute(v, T), b.fromBufferAttribute(v, T + 1), Hc.distanceSqToSegment(y, b, w, x) > _)) continue; w.applyMatrix4(e.matrixWorld); let L = i.ray.origin.distanceTo(w); L < i.near || L > i.far || r.push({ distance: L, point: x.clone().applyMatrix4(e.matrixWorld), object: e }); } } function m(v, y, b, x, w, A, S) { let _ = new E(), M = new E(), C = new E(), T = new E(), P = new E(); if ( (_.fromBufferAttribute(x, w), M.fromBufferAttribute(x, A), C.fromBufferAttribute(x, S), b.intersectTriangle(_, M, C, !1, T) === null) ) return null; P.copy(T), P.applyMatrix4(v.matrixWorld); let L = y.ray.origin.distanceTo(P); return L < y.near || L > y.far ? null : { faceIndex: 1, distance: L, point: P.clone(), object: v }; } }, Wc = new E(), dr = new Yo(), c8 = class extends Dh { constructor(e) { let t = new Ve(), i = new Rn({ color: 16777215, vertexColors: !0, toneMapped: !1 }), r = [], s = [], n = {}, a = new Ge(15711266), o = new Ge(15711266), l = new Ge(2857471); h('n1', 'n2', a), h('n2', 'n4', a), h('n4', 'n3', a), h('n3', 'n1', a), h('f1', 'f2', a), h('f2', 'f4', a), h('f4', 'f3', a), h('f3', 'f1', a), h('n1', 'f1', a), h('n2', 'f2', a), h('n3', 'f3', a), h('n4', 'f4', a), h('p', 'n1', o), h('p', 'n2', o), h('p', 'n3', o), h('p', 'n4', o), h('u1', 'u2', l), h('u2', 'u3', l), h('u3', 'u1', l); function h(c, d, p) { u(c, p), u(d, p); } function u(c, d) { r.push(0, 0, 0), s.push(d.r, d.g, d.b), n[c] === void 0 && (n[c] = []), n[c].push(r.length / 3 - 1); } t.setAttribute('position', new Ce(r, 3)), t.setAttribute('color', new Ce(s, 3)), super(t, i), (this.type = 'CameraHelper'), (this.camera = e), this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(), (this.matrix = e.matrixWorld), (this.matrixAutoUpdate = !1), (this.pointMap = n), this.update(); } update() { let e = this.geometry, t = this.pointMap, i = !0; dr.projectionMatrixInverse.elements = [ 0.5112609807824982, -0, -0, -0, -0, 0.41421356237309503, -0, -0, -0, -0, -0, -0.099999, -0, -0, -1.0000000000000002, 0.100001 ]; let r = 1, s = 1, n = i ? 0.8 : 1e-4; Rr('n1', t, e, dr, -r, -s, n), Rr('n2', t, e, dr, r, -s, n), Rr('n3', t, e, dr, -r, s, n), Rr('n4', t, e, dr, r, s, n); let a = n; Rr('f1', t, e, dr, -r, -s, a), Rr('f2', t, e, dr, r, -s, a), Rr('f3', t, e, dr, -r, s, a), Rr('f4', t, e, dr, r, s, a); let o = a, l = 0.5; Rr('u1', t, e, dr, r * 0.7 * l, s * 1.1, o), Rr('u2', t, e, dr, -r * 0.7 * l, s * 1.1, o), Rr('u3', t, e, dr, 0, s * (1.1 + 0.9 * l), o), (e.getAttribute('position').needsUpdate = !0); } dispose() { this.geometry.dispose(), this.material.dispose(); } }; function Rr(e, t, i, r, s, n, a) { Wc.set(s, n, a).unproject(r); let o = t[e]; if (o !== void 0) { let l = i.getAttribute('position'); for (let h = 0, u = o.length; h < u; h++) l.setXYZ(o[h], Wc.x, Wc.y, Wc.z); } } var d8 = class extends zh(c8) { constructor(e) { super(e), (this.object = e), (this.object = e), (this.name = `CombinedCameraHelper: ${e.uuid}`); } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.updateTarget(); } updateTarget() { let e = this.object.getTarget(); this.updateWorldMatrix(!0, !1), this.worldToLocal(e); } raycast(e, t) { Nh(this.object, this.geometry, e, t, !0); } }, Vm; ((e) => (e.is = (t) => 'objectHelper' in t))(Vm || (Vm = {})); var Tu = (e, t) => class extends dA(e) { constructor() { super(...arguments), (this.objectHelper = new t(this)), (this.gizmos = {}); } get geometryHelper() { return t.geometryHelper; } raycast(i, r) { this.objectHelper.raycast(i, r); } showGizmos() { for (let i in this.gizmos) { let r = this.gizmos[i]; r instanceof wd && (r.visible = !0); } } updateEntityBoxSize(i, r) { this.objectHelper.visible && this.geometryHelper instanceof vs ? (i.setScalar(0), r .set(this.geometryHelper.parameters.width, this.geometryHelper.parameters.height, this.geometryHelper.parameters.height) .multiplyScalar(0.5)) : super.updateEntityBoxSize(i, r); } hideGizmos() { for (let i in this.gizmos) { let r = this.gizmos[i]; r instanceof wd && (r.visible = !1); } } }, hf = 790, $a = new E(), cf = new E(), df = new ct(), uf = new E(), Bl = new E(), pf = new E(), Gi = class extends Tu(Yo, d8) { constructor(e = '', t = { ...Ud.defaultData, name: '' }) { super(), (this._cameraType = 'OrthographicCamera'), (this.targetOffset = xh.DefaultTargetOffset), (this.isUpVectorFlipped = !1), (this.angleOffsetFromUp = 0), (this.wasMovedByUser = !1), this.super_Entity(e, t), (this.matrixAutoUpdate = !0), (this.width = window.innerWidth), (this.height = window.innerHeight); let i = this.width, r = this.height; if (t.orthographic.autoZoom) { let s = t.orthographic.autoZoomFrustumSize ?? hf, n = i / r, a = i > r ? n : 1, o = i > r ? 1 : n; this.orthoCamera = new gd(-s * 0.5 * a, s * 0.5 * a, s * 0.5 * (1 / o), -s * 0.5 * (1 / o), -5e4, 1e4); } else this.orthoCamera = new gd(i * -0.5, i * 0.5, r * 0.5, r * -0.5, -5e4, 1e4); (this.perspCamera = new wi(45, i / r, 50, 1e4)), (this.left = this.orthoCamera.left), (this.right = this.orthoCamera.right), (this.top = this.orthoCamera.top), (this.bottom = this.orthoCamera.bottom), (this.far = this.orthoCamera.far), (this.view = this.orthoCamera.view), (this.aspect = this.perspCamera.aspect), (this.focus = this.perspCamera.focus), (this.filmGauge = this.perspCamera.filmGauge), (this.filmOffset = this.perspCamera.filmOffset), this.objectHelper.update(); } get isPerspectiveCamera() { return this.cameraType === 'PerspectiveCamera'; } get isOrthographicCamera() { return !this.isPerspectiveCamera; } get cameraType() { return this._cameraType; } set fov(e) { this.perspCamera.fov = e; } get fov() { return this.perspCamera.fov; } setNear(e, t) { e === 'PerspectiveCamera' ? (this.perspCamera.near = t) : (this.orthoCamera.near = t); } setZoom(e, t) { t >= 0 && (e === 'PerspectiveCamera' ? (this.perspCamera.zoom = t) : (this.orthoCamera.zoom = t)); } set cameraType(e) { e === 'PerspectiveCamera' ? this.toPerspective() : e === 'OrthographicCamera' && this.toOrthographic(); } get near() { return this._cameraType === 'PerspectiveCamera' ? this.perspCamera.near : this.orthoCamera.near; } set near(e) { this._cameraType === 'PerspectiveCamera' ? (this.perspCamera.near = e) : (this.orthoCamera.near = e); } get zoom() { return this._cameraType === 'PerspectiveCamera' ? this.perspCamera.zoom : this.orthoCamera.zoom; } set zoom(e) { e >= 0 && (this._cameraType === 'PerspectiveCamera' ? (this.perspCamera.zoom = e) : (this.orthoCamera.zoom = e)); } lookAt(e, t, i) { typeof e == 'number' && (e = new E(e, t, i)), super.lookAt(e), this.getWorldPosition($a), (this.targetOffset = $a.distanceTo(e)); } getTarget(e = new E()) { return this.getWorldDirection(cf), this.getWorldPosition($a), cf.multiplyScalar(this.targetOffset), e.copy($a).add(cf), e; } getDistanceToTarget() { let e = this.getTarget(); return this.getWorldPosition($a), $a.distanceTo(e); } updateUp() { this.getWorldQuaternion(df), uf.set(0, 0, 1).applyQuaternion(df), Bl.copy(bt.DEFAULT_UP), this.isUpVectorFlipped && Bl.negate(), Bl.applyQuaternion(df), pf.copy(bt.DEFAULT_UP).projectOnPlane(uf), (this.angleOffsetFromUp = pf.angleTo(Bl)), (this.angleOffsetFromUp *= pf.cross(Bl).dot(uf) >= 0 ? 1 : -1); } updateTransformState(e) { let t = super.updateTransformState(e); return e.isUpVectorFlipped !== void 0 && (this.isUpVectorFlipped = e.isUpVectorFlipped), this.updateUp(), t; } getViewFrontToObject(e) { let t = e.getWorldPosition(new E()), i = e.getWorldDirection(new E()).multiplyScalar(this.targetOffset); return { position: t.clone().add(i), target: t }; } getViewToObject(e) { let t = e.getWorldPosition(new E()), i = this.getWorldDirection(new E()).multiplyScalar(this.targetOffset); return { position: t.clone().sub(i), target: t }; } setViewplaneSize(e, t) { if (((this.aspect = e / t), this.data.type === 'OrthographicCamera' && this.data.orthographic.autoZoom)) { let i = this.data.orthographic.autoZoomFrustumSize ?? hf, r = e > t ? this.aspect : 1, s = e > t ? 1 : this.aspect; (this.left = -i * 0.5 * r), (this.right = i * 0.5 * r), (this.top = i * 0.5 * (1 / s)), (this.bottom = -i * 0.5 * (1 / s)); } else (this.left = -e * 0.5), (this.right = e * 0.5), (this.top = t * 0.5), (this.bottom = -t * 0.5); this.updateProjectionMatrix(); } toOrthographic() { (this.orthoCamera.left = this.left), (this.orthoCamera.right = this.right), (this.orthoCamera.top = this.top), (this.orthoCamera.bottom = this.bottom), (this.orthoCamera.view = this.view), (this.orthoCamera.far = this.far), this.orthoCamera.updateProjectionMatrix(), (this.projectionMatrix = this.orthoCamera.projectionMatrix), (this.projectionMatrixInverse = this.orthoCamera.projectionMatrixInverse), (this._cameraType = 'OrthographicCamera'), this.objectHelper && this.objectHelper.update(); } toPerspective() { (this.perspCamera.aspect = this.aspect), (this.perspCamera.fov = this.fov), (this.perspCamera.view = this.view), (this.perspCamera.far = this.far), this.perspCamera.updateProjectionMatrix(), (this.projectionMatrix = this.perspCamera.projectionMatrix), (this.projectionMatrixInverse = this.perspCamera.projectionMatrixInverse), (this._cameraType = 'PerspectiveCamera'), this.objectHelper && this.objectHelper.update(); } setFocalLength(e) { this.perspCamera.setFocalLength(e), this.toPerspective(); } getFocalLength() { return this.perspCamera.getFocalLength(); } getEffectiveFOV() { return this.perspCamera.getEffectiveFOV(); } getFilmWidth() { return this.perspCamera.getFilmWidth(); } getFilmHeight() { return this.perspCamera.getFilmHeight(); } setViewOffset(e, t, i, r, s, n) { this._cameraType === 'PerspectiveCamera' ? this.perspCamera.setViewOffset(e, t, i, r, s, n) : this.orthoCamera.setViewOffset(e, t, i, r, s, n); } clearViewOffset() { this._cameraType === 'PerspectiveCamera' ? (this.perspCamera.clearViewOffset(), this.toPerspective()) : (this.orthoCamera.clearViewOffset(), this.toOrthographic()); } updateProjectionMatrix() { this._cameraType === 'PerspectiveCamera' ? this.toPerspective() : this._cameraType === 'OrthographicCamera' && this.toOrthographic(); } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } updateWorldMatrix(e, t) { super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert(); } copy(e, t) { return ( super.copy(e, t), this.orthoCamera.copy(e.orthoCamera), this.perspCamera.copy(e.perspCamera), (this.left = e.left), (this.right = e.right), (this.top = e.top), (this.bottom = e.bottom), (this.far = e.far), (this.view = e.view === null ? null : Object.assign({}, e.view)), (this._cameraType = e._cameraType), (this.aspect = e.aspect), (this.fov = e.fov), (this.focus = e.focus), (this.filmGauge = e.filmGauge), (this.filmOffset = e.filmOffset), (this.targetOffset = e.targetOffset), this.updateProjectionMatrix(), this ); } toCameraState(e = []) { let t = { type: this.cameraType, far: this.far, orthographic: { near: this.orthoCamera.near, zoom: this.orthoCamera.zoom, autoZoom: !0, autoZoomFrustumSize: hf }, perspective: { near: this.perspCamera.near, fov: this.perspCamera.fov, zoom: this.perspCamera.zoom }, up: this.up.toArray(), targetOffset: this.targetOffset, isUpVectorFlipped: this.isUpVectorFlipped }; return tm(t, e); } updateCameraSubtype(e, t) { let i = e === 'perspective' ? 'PerspectiveCamera' : 'OrthographicCamera'; t.zoom !== void 0 && this.setZoom(i, t.zoom), t.near !== void 0 && this.setNear(i, t.near), t.fov !== void 0 && i === 'PerspectiveCamera' && (this.fov = t.fov); } updateState(e, t) { this.updateCameraState(e, t); } updateCameraState(e, t) { this.updateState_Entity(e, t), e.far !== void 0 && (this.far = e.far), e.orthographic !== void 0 && this.updateCameraSubtype('orthographic', e.orthographic), e.perspective !== void 0 && this.updateCameraSubtype('perspective', e.perspective), e.type !== void 0 && (this.cameraType = e.type), e.up !== void 0 && this.up.fromArray(e.up), e.targetOffset !== void 0 && (this.targetOffset = e.targetOffset), e.isUpVectorFlipped !== void 0 && (this.isUpVectorFlipped = e.isUpVectorFlipped), this.updateProjectionMatrix(); } updateByPatchedOp(e, t, i) { super.updateByPatchedOp(e, t, i), e.path.length === 1 && e.type === 0 && this.updateCameraSubtype(e.path[0], e.props); } toState(e) { return { ...super.toState(e), ...this.toCameraState(e), type: this.cameraType }; } }, ib = new ve(); function rb(e) { let t = !1; return ( e.scene.objects.traverse((i, r) => { r.geometry?.type === 'BooleanGeometry' && (t = !0); }), t ); } var Ho = class extends Cu { constructor(e, t, i) { super(e, t), (this.data = t), (this.meshSetAddresses = []), (this.needsTransformForDownstream = !1), (this.geometry = new Ve()), (this.geometry.userData.parameters = { width: 0, height: 0, depth: 0 }); } get booleanOp() { return this.data.geometry.operation; } get phongAngle() { return this.data.geometry.phongAngle ?? 45; } get isLOD() { return this.recomputeBoolean(), !1; } updateByPatchedOp(e, t, i) { super.updateByPatchedOp(e, t, i), e.path.length === 1 && e.path[0] === 'geometry' && e.type === 0 && e.props.operation !== void 0 && (this.freeBooleanPointer(), this.resetBBoxNeedsUpdate()); } freeBooleanPointer() { super.freeBooleanPointer(), this.geometry.dispose(); } recomputeBoolean(e, t = !0) { if (this.booleanMeshSetAddress !== -1 && !e) return; for (let r = 0; r < this.children.length; r++) { let s = this.children[r]; s instanceof Ho && s.recomputeBoolean(e === !0, t); } this.meshSetAddresses = []; for (let r = 0; r < this.children.length; r++) { let s = this.children[r]; if ( s instanceof ar && s.dataPatched.visible === !0 && s.geometry.attributes.position?.count > 0 && s.geometry.drawRange.count > 0 ) { if (s.booleanMeshSetAddress === -1) { if ( ((s.geometry.index ?? s.geometry.getAttribute('position')).count / 3 < 15e5 && (s.booleanMeshSetAddress = dn.getMeshSet(s.geometry, e === !0, t)), s.booleanMeshSetAddress === -1) ) return; dn.transformMeshSet(s.booleanMeshSetAddress, s.matrix), s.booleanMatrixInvOld.copy(s.matrix).invert(), (s.booleanWasTransformed = !1); } else s instanceof Ho && s.needsTransformForDownstream === !0 ? (dn.transformMeshSet(s.booleanMeshSetAddress, s.matrix), (s.needsTransformForDownstream = !1)) : s.booleanWasTransformed === !0 && (ib.multiplyMatrices(s.matrix, s.booleanMatrixInvOld), dn.transformMeshSet(s.booleanMeshSetAddress, ib), s.booleanMatrixInvOld.copy(s.matrix).invert(), (s.booleanWasTransformed = !1)); this.meshSetAddresses.push(s.booleanMeshSetAddress); } } if (this.meshSetAddresses.length === 0) { this.geometry.setAttribute('position', new uE([], 0)), this.geometry.setDrawRange(0, 0); return; } if (e === !0) return dn.calcBooleanTopological(this.meshSetAddresses, this.booleanOp); let i = this.geometry; i.dispose(), (this.geometry = new Ve()), (this.geometry.userData = i.userData), (this.geometry.boundingSphere = i.boundingSphere); try { this.booleanMeshSetAddress = dn.calcBoolean(this.meshSetAddresses, this.booleanOp, this.geometry, this.phongAngle); } catch (r) { (this.booleanMeshSetAddress = 0), console.error(r); } this.booleanMatrixInvOld.copy(this.matrix).invert(), (this.needsTransformForDownstream = !0), uv(this), pv(this); } dispose() { super.dispose(), this.geometry.dispose(); } }, Hm; ((e) => { function t(i) { return Ct.is(i) && i instanceof Ih; } e.is = t; })(Hm || (Hm = {})); var fv = (e, t) => class extends Tu(e, t) { updateState_Light(i, r) { this.updateState_Entity(i, r), i.color !== void 0 && (this.color = r.shared.color(i.color)), i.intensity !== void 0 && (this.intensity = i.intensity), i.depth !== void 0 && ((this.shadow.camera.far = i.depth), (this.shadow.needsUpdate = !0)), i.shadows !== void 0 && (this.castShadow = i.shadows); } }, js = (e) => e instanceof ar, Sn = (e) => e !== null && e instanceof Ho, u8 = (e) => e instanceof Gi, p8 = (e) => Hm.is(e), f8 = (e) => Vm.is(e), mv = class extends zh(oL) { constructor(e, t = 15) { super(t), (this.object = e), this.object.updateMatrixWorld(), (this.name = `EmptyObjectHelper: ${e.uuid}`), (this.matrix = e.matrixWorld), (this.matrixAutoUpdate = !1); } raycast(e, t) { Nh(this.object, mv.geometryHelper, e, t); } update() {} }, Wm = class extends Tu(po, mv) { constructor(e, t) { super(), this.super_Entity(e, t), this.objectHelper.update(); } updateState(e, t) { this.updateState_Entity(e, t); } }, _S = class extends zh(aL) { constructor(e, t = 15, i = 10066329) { super(e, t, i), (this.object = e), (this.added = !1), (this.name = `DirectionalLightHelper: ${e.uuid}`); } raycast(e, t) { Nh(this.object, _S.geometryHelper, e, t); } }, AS = class extends zh(nL) { constructor(e, t = 15, i = 6710886) { super(e, t, i), (this.object = e), (this.name = `PointLightHelper: ${e.uuid}`); } raycast(e, t) { Nh(this.object, AS.geometryHelper, e, t); } }, Xm = class extends zh(sL) { constructor(e, t = 6710886) { super(e, t), (this.object = e), (this.name = `SpotLightHelper: ${e.uuid}`); } raycast(e, t) { Nh(this.object, Xm.geometryHelper, e, t); } update() { if (this.object !== void 0) { let e = Xm._vector, t = this.object.distance ? this.object.distance : 1e3, i = t * Math.tan(this.object.angle); this.cone.scale.set(i, i, t), e.setFromMatrixPosition(this.object.target.matrixWorld), this.cone.lookAt(e); let r = this.color !== void 0 ? this.color : this.light.color; if (this.cone.material instanceof Array) for (let s = 0, n = this.cone.material.length; s < n; s++) this.cone.material[s].color.set(r); else this.cone.material.color.set(r); } } }, SS = Xm; SS._vector = new E(); function m8(e, t) { (e.shadow.camera.right = t / 2), (e.shadow.camera.left = -t / 2), (e.shadow.camera.top = t / 2), (e.shadow.camera.bottom = -t / 2), (e.shadow.needsUpdate = !0); } var g8 = class extends fv(WD, _S) { constructor(e, t, i) { super(), this.super_Entity(e, t), (this.castShadow = !0), (this.shadow.mapSize.width = 2048), (this.shadow.mapSize.height = 2048), (this.shadow.normalBias = 1), this.layers.enable(3); let r = this.shadow.camera; (r.top = 1250), (r.bottom = -1250), (r.right = 1250), (r.left = -1250), (r.near = -1e4), (r.far = 2500); let s = new bd(this.shadow.camera); (s.visible = !1), (this.gizmos.shadowmap = s); } update() { this.shadow.camera.updateProjectionMatrix(); for (let e in this.gizmos) { let t = this.gizmos[e]; t instanceof bd && t.update(); } } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.objectHelper && this.objectHelper.update(); } updateState(e, t) { this.updateState_Light(e, t); let i = (e.depth !== void 0 && e.depth !== this.shadow.camera.far) || (e.size !== void 0 && e.size / 2 !== this.shadow.camera.right); e.size !== void 0 && m8(this, e.size), e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius), e.shadowResolution !== void 0 && (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution), this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null))), i && this.update(); } }, v8 = class extends fv(VD, AS) { constructor(e, t, i) { super(), this.super_Entity(e, t), (this.castShadow = !0), (this.shadow.mapSize.width = 1024), (this.shadow.mapSize.height = 1024), (this.shadow.normalBias = 1), this.layers.enable(3); let r = this.shadow.camera; (r.fov = 90), (r.aspect = 1), (r.near = 100), (r.far = 2500); let s = new E(-r.far + this.position.x, -r.far + this.position.y, -r.far + this.position.z), n = new E(r.far + this.position.x, r.far + this.position.y, r.far + this.position.z), a = new Kt(s, n), o = new wd(a, new Ge(16755200)); (o.visible = !1), (this.gizmos.shadowmap = o), this.update(); } update() { if (this.shadow && (this.shadow.camera.updateProjectionMatrix(), this.gizmos)) for (let e in this.gizmos) { let t = this.gizmos[e]; if (t instanceof wd) { let i = this.shadow.camera, r = new E(-i.far + this.position.x, -i.far + this.position.y, -i.far + this.position.z), s = new E(i.far + this.position.x, i.far + this.position.y, i.far + this.position.z); t.box.set(r, s), t.updateMatrixWorld(!0); } } } updateMatrixWorld(e) { super.updateMatrixWorld(e), this.objectHelper && this.objectHelper.update(); } updateState(e, t) { this.updateState_Light(e, t), e.distance !== void 0 && (this.distance = e.distance), e.decay !== void 0 && (this.decay = e.decay), e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius), e.shadowResolution !== void 0 && (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution), this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null))); } }, sb = new E(), nb = new E(), ab = new ct(), y8 = class extends fv(jD, SS) { constructor(e, t, i) { super(), this.super_Entity(e, t), (this.castShadow = !0), (this.shadow.mapSize.width = 1024), (this.shadow.mapSize.height = 1024), (this.shadow.normalBias = 1), this.layers.enable(3); let r = this.shadow.camera; (r.fov = it.RAD2DEG * 2 * this.angle), (r.aspect = 1), (r.near = 100), (r.far = 2500); let s = new bd(this.shadow.camera); (s.visible = !1), (this.gizmos.shadowmap = s), this.update(); } update() { this.shadow.camera.updateProjectionMatrix(); for (let e in this.gizmos) { let t = this.gizmos[e]; t instanceof bd && t.update(); } } updateMatrixWorld(e) { super.updateMatrixWorld(e), nb.setFromMatrixPosition(this.matrixWorld), ab.setFromRotationMatrix(this.matrixWorld), sb.copy(this.up).applyQuaternion(ab).negate().multiplyScalar(this.distance), this.target.position.copy(nb).add(sb), this.target.updateMatrixWorld(), this.objectHelper && this.objectHelper.update(); } updateState(e, t) { this.updateState_Light(e, t), e.distance !== void 0 && (this.distance = e.distance), e.decay !== void 0 && (this.decay = e.decay), e.angle !== void 0 && (this.angle = e.angle), e.penumbra !== void 0 && (this.penumbra = e.penumbra), e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius), e.shadowResolution !== void 0 && (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution), this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null))); } }, x8 = class extends Cr { get forceComputeSize() { return !0; } get shape() { return this.geometry.userData.shape; } updateEntityBoxSize(e, t) { let i = this.geometry.getAttribute('position'); i !== void 0 ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t) : super.updateEntityBoxSize(e, t); } }, gv = class extends Cr { constructor(e, t, i) { super(e, t, i), (this._shapeId = null), (this._context = i); } updateState(e, t) { super.updateState(e, t), this.updateShape(); } updateShape() { let e = this.data.geometry.extrusion.shape, t; if (e.type === 'Custom') { let r = e.shapeId; if ((r !== this._shapeId && this.detachShape(), r)) { this._shapeId = r; let s = this._context.scene.find(r); s?.data && (s.attachedPaths.add(this), (t = s.geometry.userData?.shape)), t || this._context.scene.addPendingCommand(() => this.updateShape()); } } else { let r; switch (e.type) { case 'Rectangle': r = PA; break; case 'Ellipse': r = sv; break; case 'Polygon': r = TA; break; case 'Star': r = DA; break; default: throw new Error(`Unknown shape type: ${e.type}`); } t = r.create({ parameters: e }).userData.shape; } let i = this.geometry; t && i.inputs && ((i.inputs.shapeData = t), i.build(), this.attachedSurfaceCloners.forEach((r) => r.update())); } detachShape() { this._shapeId !== null && this._context.scene.find(this._shapeId)?.attachedPaths.delete(this); } createGeometryDelayed(e) { (this.geometryCreateDeleyed = e.shared), this.updateShape(), this.refreshAttachedPaths(e); } updateTransformState(e) { return super.updateTransformState(e); } updateGeometryInteractions(e, t) { super.updateGeometryInteractions(e, t), this.updateShape(); } updateEntityBoxSize(e, t) { let i = this.geometry.getAttribute('position'); i !== void 0 ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t) : super.updateEntityBoxSize(e, t); } }, Ro = class extends Tu(po, mv) { constructor(e, t, i) { super(), t.type === 'Instance' && typeof e == 'string' && (t = this.transformAssignData(t, i)), this.super_Entity(e, t), this.objectHelper.update(); } get isComponentRoot() { return this.data.type === 'Component' && typeof this.identity == 'string'; } get isInstanceRoot() { return this.data.type === 'Instance' && typeof this.identity == 'string'; } transformAssignData(e, t) { let i = t.scene.data.objects.get(e.component); if (i) { let r, s; for (let n of Go.rootOverrideProps) e[n] === void 0 ? (r === void 0 && (r = { ...e }), (r[n] = i.data[n])) : (s === void 0 && (s = {}), (s[n] = e[n])); return (this.overrideData = s), r ?? e; } return e; } updateByOp(e, t, i, r) { let s; if (this.isInstanceRoot && !r && ((t = this.transformAssignData(t, i)), e.type === 0 && e.path.length === 0 && this.component)) for (let n of Go.rootOverrideProps) n in e.props && e.props[n] === void 0 && (s === void 0 && (s = { ...e, props: { ...e.props } }), (s.props[n] = this.component.data[n])); super.updateByOp(s ?? e, t, i, r); } updateState(e, t) { this.updateState_Entity(e, t); } expandInstanceChildren(e) { let t = this.data; if (this.component === void 0) { this.component = e.scene.find(t.component) ?? null; let i = !1; if (this.component !== this.oldComponent) { if (this.oldComponent) { let r = 0; for (let s of this.children) if (Ct.is(s)) e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s), vv(s), (r += 1); else break; this.children.splice(0, r); } i = !0; } this.component && MS(e, [this.uuid], t.overrides, this, this.component, this.component, 0, i), (this.oldComponent = this.component); } } }; function vv(e) { if (e.component) { let t = e.component.instances.indexOf(e); t >= 0 && e.component.instances.splice(t, 1); for (let i of e.children) Ct.is(i) && vv(i); } } function ob(e, t, i, r) { return e.component === t && jg(e.identity, r) ? (e.overrideData === i ? 2 : 1) : 0; } function MS(e, t, i, r, s, n, a, o) { if (a > 50) return !1; if (r.component !== s) { if (r.component) { let h = r.component.instances.indexOf(r); h >= 0 && r.component.instances.splice(h, 1); } s.instances.push(r), (r.component = s); } s instanceof Ro && s.isInstanceRoot && s.expandInstanceChildren(e); let l = 0; for (let h of s.children) if (Ct.is(h)) { let u = [...t, ...(typeof h.identity == 'string' ? [h.identity] : h.identity)], c = Fd.resolve(i, u, 1), d = null, p; if (!o) { let f = r.children[l]; if (((d = Ct.is(f) ? f : null), d !== null)) { let g = ob(d, h, c, u); (p = g >= 1 ? d.stateSelection : void 0), g !== 2 && (d = null); } if (d === null && ((d = e.scene.findInstance(u) ?? null), d !== null)) { let g = ob(d, h, c, u); if (((p = g >= 1 ? d.stateSelection : void 0), g !== 2)) d = null; else { let m = d.parent.children.indexOf(d); d.parent.children.splice(m, 1), r.children.splice(l, 0, d), d.parent === r ? m <= l && console.error('not possible') : ((d.parent = r), (d.matrixWorldNeedsUpdate = !0), d.resetBBoxNeedsUpdate(), d.updateVisible(), e.pendingDeletes.delete(d)); } } } if (d === null) { let f = c ? fa.apply(h.data, c) : h.data; _a.is(f.type) && (f = { ...f, type: 'Empty' }), (d = wn.createEntity(u, f, e)), (d.overrideData = c), r.add(d), r.children.splice(r.children.length - 1, 1), r.children.splice(l, 0, d), d.updateState(d.data, e), p && d.changeSelectedState(p, e), e.scene.registerInstanceAndSetUuid(d); } (l += 1), MS(e, t, i, d, h, n, a + 1, o); } if (!o) { let h = l; for (;;) { let u = r.children[l]; if (Ct.is(u)) e.pendingDeletes.add(u); else break; l += 1; } r.children.splice(h, l - h); } return !0; } function b8(e, t, i) { let r; return t.geometry.type === 'TextGeometry' ? new yS(e, t, i) : (t.geometry.type === 'SubdivGeometry' ? (r = new Sh(e, t, i)) : t.geometry.type === 'PathGeometry' ? (r = new gv(e, t, i)) : t.geometry.type === 'VectorGeometry' ? (r = new x8(e, t, i)) : t.geometry.type === 'BooleanGeometry' ? (r = new Ho(e, t, i)) : (r = new Cr(e, t, i)), r); } function yv(e, t, i) { return t.type === 'Mesh' ? b8(e, t, i) : t.type === 'Empty' ? new Wm(e, t) : t.type === 'PointLight' ? new v8(e, t, i) : t.type === 'SpotLight' ? new y8(e, t, i) : t.type === 'DirectionalLight' ? new g8(e, t, i) : t.type === 'Component' || t.type === 'Instance' ? new Ro(e, t, i) : _a.is(t.type) ? new Gi(e, t) : (console.error(t), new Wm(e, t)); } wn.createEntity = yv; function w8(e, t, i) { let r = yv(e.identity, t, i), s = e.children, n = e.attachedPaths, a = e.parent, o = e.component, l = e.instances, h = e.overrideData, u = e.uuid, c = e.stateSelection; e.dispose(); for (let d of Object.keys(e)) delete e[d]; Object.setPrototypeOf(e, Object.getPrototypeOf(r)); for (let d of Object.keys(r)) e[d] = r[d]; (e.children = [...e.children, ...s]), (e.attachedPaths = n), (e.parent = a), (e.component = o), (e.instances = l), (e.uuid = u), (e.overrideData = h), e.updateState(e.data, i), c && e.changeSelectedState(c, i), e.resetBBoxNeedsUpdate(); } wn.changeEntityProptotype = w8; wn.Cloner = eu; function _8(e, t, i, r) { e.updateByOp(t, i, r, !1); } function lb(e, t) { let i = !1, r = t.getLayersOfType('transmission'), s = t.getLayersOfType('outline'); return ( s.length > 0 && (e.layers.set(8), r.length > 0 && e.layers.enable(3), (i = !0), pv(e), uv(e)), r.length === 0 && s.length === 0 && e.layers.set(0), i ); } function hb(e, t) { if (!t.layers) return !1; let i = !1, r = t.getLayersOfType('transmission').filter((n) => n.data.visible), s = t.getLayersOfType('outline').filter((n) => n.data.visible); return ( r.length > 0 && (e.layers.set(3), s.length > 0 && e.layers.enable(8), (i = !0)), r.length === 0 && s.length === 0 && e.layers.set(0), i ); } function A8(e) { let t = !1; return ( e.traverseEntity((i) => { if (i instanceof Cu) if (Array.isArray(i.material)) for (let r = 0; r < i.material.length; r++) lb(i, i.material[r]) && (t = !0); else lb(i, i.material) && (t = !0); }), t ); } function S8(e) { let t = !1; return ( e.traverseEntity((i) => { if (i instanceof Cu) if (Array.isArray(i.material)) for (let r = 0; r < i.material.length; r++) hb(i, i.material[r]) && (t = !0); else hb(i, i.material) && (t = !0); }), t ); } var M8 = new kw(), E8 = new ve(), C8 = new Xo(); function T8(e, t, i) { let r = e.cloner; if (r) for (let s of r.children) { let n = E8.copy(s.matrixWorld).invert(), a = C8.copy(t.ray).applyMatrix4(n), o = e.matrixWorld; a.applyMatrix4(o); let l = M8; l.set(a.origin, a.direction), (l.near = t.near), (l.far = t.far), l.intersectObject(e, !1).length > 0 && i.push({ object: e }); } } var P8 = (e) => ` // PCSS implementation based on: // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/ // NOTE: This number affects how big the shadow blur can // possibly get. Bigger number == bigger blur, but less precise results const float gPenumbraFilterSize = 80.0; const int gPenumbraSamples = ${e}; const int gShadowSamples = ${e}; const float gShadowSamplesRpc = 1.0f / float(gShadowSamples); vec2 vogelDiskSample(int sample_index, int sample_count, float angle) { const float goldenAngle = 2.399963f; // radians float r = sqrt(float(sample_index) + 0.5f) / sqrt(float(sample_count)); float theta = float(sample_index) * goldenAngle + angle; float sine = sin(theta); float cosine = cos(theta); return vec2(cosine, sine) * r; } // NOTE: For now we aren't using this screen-space noise. But we should enable // it again once we do some sort of temporal AA. Then we could potentially lower // the number of samples needed and still get a pretty smooth result. // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso float getNoiseInterleavedGradient(vec2 screenPos) { vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f); return fract(magic.z * fract(dot(screenPos, magic.xy))); } #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif /* #if NUM_RECT_AREA_LIGHTS > 0 // TODO (abelnation): create uniforms for area light shadows #endif */ float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius) { float penumbra = 1.0; float blockerDepthAvg = 0.0; float blockerCount = 0.0; #pragma unroll_loop_start for(int i = 0; i < gPenumbraSamples; i ++) { vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar; float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ); if(depth < compare + 0.0001) { blockerDepthAvg += depth; blockerCount++; } } #pragma unroll_loop_end if (blockerCount > 0.0) { blockerDepthAvg /= blockerCount; // Compute penumbra penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg); penumbra *= penumbra; penumbra *= 200.0 * penumbraSize[min(index, ${5} - 1)]; // Magic number that affects how quickly the penumbra grows return clamp(penumbra, 0.00, 1.0); } return 0.0; } vec4 shadowmod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;} vec4 shadowperm(vec4 x){return shadowmod289(((x * 34.0) + 1.0) * x);} float shadowNoise(vec3 p){ vec3 a = floor(p); vec3 d = p - a; d = d * d * (3.0 - 2.0 * d); vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0); vec4 k1 = shadowperm(b.xyxy); vec4 k2 = shadowperm(k1.xyxy + b.zzww); vec4 c = k2 + a.zzzz; vec4 k3 = shadowperm(c); vec4 k4 = shadowperm(c + 1.0); vec4 o1 = fract(k3 * (1.0 / 41.0)); vec4 o2 = fract(k4 * (1.0 / 41.0)); vec4 o3 = o2 * d.z + o1 * (1.0 - d.z); vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); return o4.y * d.y + o4.x * (1.0 - d.y); } float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius) { float shadow = 0.0f; float temporalOffset = shadowNoise(floor(vWPosition * 10.)); // NOTE: When using TAA, we should use screen space interleaved gradient noise //float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy); float temporalAngle = temporalOffset * PI2; float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.); float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius); if (penumbra == -1.0) { return 1.0; } #pragma unroll_loop_start for (int i = 0; i < gShadowSamples; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec2 offset = vogelSample * (shadowRadius * 2.); // Penumbra offset offset += vogelSample * (penumbra * texelScalar); shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) ); } #pragma unroll_loop_end return shadow * gShadowSamplesRpc; } float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); // Hard Shadow if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; // if ( something && something ) breaks ATI OpenGL shader compiler // if ( all( something, something ) ) using this instead bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); bool inFrustum = all( inFrustumVec ); bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); bool frustumTest = all( frustumTestVec ); if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else // no percentage-closer filtering: shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D // vector suitable for 2D texture mapping. This code uses the following layout for the // 2D texture: // // xzXZ // y Y // // Y - Positive y direction // y - Negative y direction // X - Positive x direction // x - Negative x direction // Z - Positive z direction // z - Negative z direction // // Source and test bed: // https://gist.github.com/tschw/da10c43c467ce8afd0c4 vec2 cubeToUV( vec3 v, float texelSizeY ) { // Number of texels to avoid at the edge of each square vec3 absV = abs( v ); // Intersect unit cube float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; // Apply scale to avoid seams // two texels less per square (one texel will do for NEAREST) v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); // Unwrap // space: -1 ... 1 range for each square // // #X## dim := ( 4 , 2 ) // # # center := ( 1 , 1 ) vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } // Transform to UV space // scale := 0.5 / dim // translate := ( center + 0.5 ) / dim return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); // for point lights, the uniform @vShadowCoord is re-purposed to hold // the vector from the light to the world-space position of the fragment. vec3 lightToPosition = shadowCoord.xyz; // dp = normalized distance from light to fragment position float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp? compare += shadowBias; // bd3D = base direction 3D vec3 bd3D = normalize( lightToPosition ); float temporalOffset = shadowNoise(floor(vWPosition * 10.)); float temporalAngle = temporalOffset * PI2; #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM ) for (int i = 0; i < gShadowSamples; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); // NOTE: Removed for now // Penumbra offset //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize); shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); } return shadow * gShadowSamplesRpc; #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) for (int i = 0; i < 16; i++) { vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize; // Overall blurring offset vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.); shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare ); } return shadow * (1.0 / 16.0); #else // no percentage-closer filtering return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare ); #endif } #endif `, D8 = Ze.lights_fragment_begin, L8 = Ze.shadowmask_pars_fragment, cb = !1, O8 = (e) => { switch (e) { case 'low': return 8; case 'medium': return 16; case 'high': return 32; default: return 16; } }, I8 = (e = 'medium') => { if (cb) return; cb = !0; let t = O8(e); Ze.shadowmap_pars_fragment = P8(t); let i = D8.slice(); (i = i.replace('getShadow( spotShadowMap[ i ]', `getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`)), (i = i.replace('getShadow( directionalShadowMap[ i ]', 'getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]')), (Ze.lights_fragment_begin = i); let r = L8.slice(); (r = r.replaceAll('getShadow(', 'getShadow( UNROLLED_LOOP_INDEX, ')), (Ze.shadowmask_pars_fragment = r); }, R8 = ` attribute vec3 randomColor; varying vec3 vNormal; flat out vec3 vColor; void main() { vNormal = normal; vColor = randomColor; gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0)); } `, B8 = ` uniform float depthContrast; varying vec3 vNormal; flat in vec3 vColor; void main() { vec3 normal = (normalize(vNormal)).rgb; float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5; vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4); gl_FragColor = vec4(resultColor, vColor.r); } `, ff = new ri({ vertexShader: R8, fragmentShader: B8, uniforms: { depthContrast: { value: 1 } } }), z8 = class { constructor() { this._constraints = new Map(); } setConstraint(e, t) { t === null ? this._constraints.delete(e) : this._constraints.set(e, t); } removeDependencies(e) { this._constraints.delete(e); } applyConstraints(e) { let t = new Set(); this._constraints.forEach((i, r) => { let s = [r, i], n = i; for (; this._constraints.has(n); ) (n = this._constraints.get(n)), t.has(n) || s.push(n); for (let a = s.length - 2; a >= 0; a--) if (!t.has(s[a])) { let o = e.find(s[a]); o ? o.applyPathSnapping(e) : console.warn(`missing entity ${s[a]}`), t.add(s[a]); } }); } findDependency(e, t) { let i = e; for (; this._constraints.has(i); ) if (((i = this._constraints.get(i)), i === t)) return !0; return !1; } }, qm = new Ph(); qm.wireframe = !0; var db = new E(), ES = class extends pa { constructor(e, t) { super(), (this.data = e), (this.backupFog = new Mw(16777215, 0.1, 2e3)), (this.fogUseBGColor = !1), (this.enableHelpers = !1), (this.wireframeState = !1), (this.needsTransmissionDirty = !0), (this.needsNormalDirty = !0), (this._needsTransmission = !1), (this._needsNormal = !1), (this.geometryCacheChanged = !1), (this.bgColor = new ji(1, 1, 1, 1)), (this.entityByUuid = {}), (this.entityIdentityToEntity = {}), (this.toExpandCloner = new Set()), (this.toUpdateCloner = new Set()), (this.pendingCommands = []), (this.pathConstraints = new z8()), (this.needsRecomputeInstances = !1), (this.ambientLight = new FD(13882323, 8553090, 0.75)), (this.ambientLight.name = 'Default Ambient Light'), this.ambientLight.layers.enable(3), (this.personalCamera = this.createPersonalCamera()), (this.activeCamera = this.personalCamera), (this.postprocessing = e.postprocessing), this.init(e, t), (this.matrixAutoUpdate = !1); } markGeometryCacheDirty() { this.geometryCacheChanged = !0; } markNeedsUpdateRendererDirty() { (this.needsTransmissionDirty = !0), (this.needsNormalDirty = !0); } needsTransmission() { return ( this.needsTransmissionDirty && ((this._needsTransmission = S8(this)), (this.needsTransmissionDirty = !1)), this._needsTransmission ); } needsNormal() { return this.needsNormalDirty && ((this._needsNormal = A8(this)), (this.needsNormalDirty = !1)), this._needsNormal; } registerInstanceAndSetUuid(e) { let t = e.identity.join('-'), i = this.entityIdentityToEntity[t]; i && (e.uuid = i.uuid), (this.entityIdentityToEntity[t] = e), (this.entityByUuid[e.uuid] = e); } findInstance(e) { return this.entityIdentityToEntity[e.join('-')]; } getWithSortKey(e) { let t = this.find(e); if (t === void 0) return; let i = [], r = t; for (; r !== this; ) { let s = r; r = r.parent; let n = r.children.indexOf(s); i.splice(0, 0, n); } return { entity: t, sortKey: i }; } getAllSorted(e) { let t = []; for (let i of e) { let r = this.getWithSortKey(i.id); r !== void 0 && t.push(r); } return t.sort((i, r) => eU(i.sortKey, r.sortKey)), t.map((i) => i.entity); } nonExistOrDescendantOf(e, t) { let i = this.find(e); if (i === void 0) return !0; for (; i; ) { if (i.uuid === t) return !0; i = i.parent; } return !1; } find(e) { if (e === '' || e === void 0) return; let t = this.entityByUuid[e]; return t === void 0 ? this.getObjectByProperty('uuid', e) : t; } debugEnsureEntity(e) { let t = this.find(e); if (t) { if (Array.isArray(t.identity) && this.findInstance(t.identity) === void 0) { console.error('not found instance'); debugger; } } else { console.error('not found'); debugger; } } addPendingExpandCloner(e) { this.toExpandCloner.add(e); } addPendingUpdateCloner(e) { this.toUpdateCloner.add(e); } markToExpandCloner(e) { this.toExpandCloner.add(e), e.traverseEntityAncestors((t) => { this.toExpandCloner.add(t); }); } doPendingExpandCloner() { this.toExpandCloner.forEach((e) => { e.expandCloner(this); }), this.toExpandCloner.clear(); } doPendingUpdateCloner() { this.toUpdateCloner.forEach((e) => { e.cloner?.update(); }), this.toUpdateCloner.clear(); } doPendingUpdates() { this.doPendingExpandCloner(), this.doPendingUpdateCloner(), this.applyPendingCommands(); } addPendingCommand(e) { this.pendingCommands.push(e); } applyPendingCommands() { this.pendingCommands.forEach((e) => e()), (this.pendingCommands.length = 0); } updateTreeByOp(e, t) { if (e.path.length === 0 && e.type === 7) { let i = e.parent === null ? this : this.find(e.parent); if (i === void 0) throw new Error('unexpected'); let r = this.createObject(e.id, e.data, e.children, i, e.localIndex, t); r.updateVisible(), r.resetBBoxNeedsUpdate(), js(r) && Sn(r.parent) && (r.invalidateUpstreamBooleanData(), r.parent.invalidateDownstreamBooleanData().recomputeBoolean()), this.markNeedsRecomputeInstancesForAncessors(i), this.markNeedsRecomputeInstancesForChildren(r), this.markToExpandCloner(r); } else if (e.path.length === 0 && e.type === 8) { let i = this.find(e.id); if (i === void 0) throw new Error('unexpected'); this.markToExpandCloner(i), i.resetBBoxNeedsUpdate(), this.unregisterObject(i); let r = i.parent; this.markNeedsRecomputeInstancesForAncessors(r), this.markNeedsRecomputeInstancesForChildren(i), i.parent.remove(i), Sn(i.parent) && (i.parent.invalidateUpstreamBooleanData(), i.parent.invalidateDownstreamBooleanData().recomputeBoolean()), js(i) && (i.freeBooleanPointer(), r instanceof Ho && r.invalidateDownstreamBooleanData().recomputeBoolean()), i instanceof gv && i.detachShape(), this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i), this.pathConstraints.removeDependencies(i.uuid); } else if (e.path.length === 0 && e.type === 9) { let i = this.find(e.id); if (i === void 0) throw new Error('unexpected'); this.markNeedsRecomputeInstancesForChildren(i); let r = i.parent; this.markNeedsRecomputeInstancesForAncessors(r), i.cloner?.resetOnMove(), this.markToExpandCloner(i); let s = e.parent === null ? this : this.find(e.parent); if (s === void 0) throw new Error('unexpected'); s.add(i), this.markNeedsRecomputeInstancesForAncessors(s), this.markToExpandCloner(i), i.invalidateClonerTransform(i), i.updateVisible(), i.resetBBoxNeedsUpdate(); let n = e.localIndex; s.children.splice(n, 0, s.children.pop()), js(i) && (i.invalidateUpstreamBooleanData(), Sn(i.parent) ? i.parent.invalidateDownstreamBooleanData().recomputeBoolean() : r instanceof Ho && r.invalidateDownstreamBooleanData().recomputeBoolean()); } this.markNeedsUpdateRendererDirty(), this.markGeometryCacheDirty(); } updateEntityByOp(e, t, i, r) { if (t.type === 0) { if ( (('overrides' in t.props || 'component' in t.props) && this.markNeedsRecomputeInstances(), t.path.includes('overrides') && 'states' in t.props) ) { let { states: n, rest: a } = t.props; (t = { ...t, props: a }), this.markNeedsRecomputeInstances(); } t.path[0] === 'pathSnapping' && t.props.pathId !== void 0 && this.pathConstraints.setConstraint(e, t.props.pathId); } let s = this.find(e); if (s) try { _8(s, t, i, { scene: this, shared: r }), s instanceof Cr && s.updateGeometryGroupsIfNeeded(); } catch (n) { console.error(n); } } get enableFog() { return this.fog !== null; } set enableFog(e) { this.fog = e === !0 ? this.backupFog : null; } init(e, t) { if ( (this.createChildrenObjects(e.objects, this, t), this.personalCamera.removeFromParent(), this.add(this.personalCamera), this.ambientLight.removeFromParent(), this.add(this.ambientLight), this.setBackgroundColor(sr(e.backgroundColor, t)), this.updateFog(e.fog, t), this.updateAmbientLight(e.environment.ambientLight, t), (this.activeCamera = this.personalCamera), e.publish.playCamera !== null) ) { let i = this.find(e.publish.playCamera); i instanceof Gi && this.switchActiveCamera(i); } this.expandInstances(t, !0), this.traverseEntity((i) => { Sn(i) && i.recomputeBoolean(), i instanceof Gi && i.updateUp(); }), this.doPendingExpandCloner(), this.applyPendingCommands(); } markNeedsRecomputeInstances() { this.needsRecomputeInstances = !0; } markNeedsRecomputeInstancesForChildren(e) { e.traverseEntity((t) => { (t.data.type === 'Component' || t.data.type === 'Instance') && this.markNeedsRecomputeInstances(); }); } markNeedsRecomputeInstancesForAncessors(e) { Ct.is(e) && (e.data.type === 'Component' && this.markNeedsRecomputeInstances(), e.traverseAncestors((t) => { Ct.is(t) && t.data.type === 'Component' && this.markNeedsRecomputeInstances(); })); } relativeizeInner(e, t, i, r, s, n, a) { e && e !== r.uuid && r.find(e) && s.forInstancesRec((o) => { o.isInstanceRoot || (o.data = Pd(o.data, (l) => { let h = l.events.data(a.id), u = o.goUp(n); if (u) { let c = [...tA(u.identity), e].join('-'), d = this.entityIdentityToEntity[c]; if (d) { let p = d.uuid; fs.zoom(h, t)[i] = p; } else console.warn('cannot find instance'); } }).data); }); } rewriteEventsBeforeGoToPlayMode() { this.traverseEntity((e) => { if (e instanceof Ro && typeof e.identity == 'string' && e.data.type === 'Component') return ( e.traverseEntity((t, i) => { t.data.events.forEach((r) => { r.data.type === 'GameControl' ? t.forInstancesRec((s) => { s.isInstanceRoot || (s.data = Pd(s.data, (n) => { n.events.delete(r.id); }).data); }) : r.data.type === 'Conditional' ? (r.data.condition.type === 'Distance' ? (this.relativeizeInner(r.data.condition.fromObject, ['condition'], 'fromObject', e, t, i, r), this.relativeizeInner(r.data.condition.toObject, ['condition'], 'toObject', e, t, i, r)) : r.data.condition.type === 'State' ? this.relativeizeInner(r.data.condition.object, ['condition'], 'object', e, t, i, r) : r.data.condition.type === 'Comparison' && (r.data.condition.lOperand.type === 'Property' && this.relativeizeInner(r.data.condition.lOperand.value[0], ['condition', 'lOperand', 'value'], 0, e, t, i, r), r.data.condition.rOperand.type === 'Property' && this.relativeizeInner(r.data.condition.rOperand.value[0], ['condition', 'rOperand', 'value'], 0, e, t, i, r)), r.data.inActions.forEach((s) => { s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['inActions', s.id], 'object', e, t, i, r); }), r.data.outActions.forEach((s) => { s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['outActions', s.id], 'object', e, t, i, r); })) : 'actions' in r.data && r.data.actions.forEach((s) => { s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['actions', s.id], 'object', e, t, i, r); }); }); }), !0 ); }); } expandInstances(e, t) { let i = new Set(); this.traverseEntity((r) => { if (r instanceof Ro && r.isInstanceRoot) return r.expandInstanceChildren({ scene: this, shared: e, pendingDeletes: i }), t || r.resetBBoxNeedsUpdate(), !0; }); for (let r of i) this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r), vv(r); } recomputeInstances(e) { this.needsRecomputeInstances && ((this.needsRecomputeInstances = !1), this.traverseEntity((t) => { t instanceof Ro && t.isInstanceRoot && (t.component = void 0); }), this.expandInstances(e, !1)); } disposeAndUnregisterEntityRecursivelyIfNotReregistered(e) { e.traverseEntity((t) => { let i = typeof t.identity == 'string' ? t.identity : t.identity.join('-'); this.entityIdentityToEntity[i] === t && (delete this.entityByUuid[t.uuid], delete this.entityIdentityToEntity[i]), t.dispose(); }); } clearScene() { for (let e of this.children) Ct.is(e) && e.disposeRecursively(); this.children.length = 0; } resetAfterClear(e, t) { this.init(e, t); } createPersonalCamera() { let e = new Gi(ES.PERSONAL_CAMERA_ID, { ...Ud.defaultData, name: 'Personal Camera' }); return (e.objectHelper.visible = !1), this.registerObjectCreatedInLegacy(e), e; } raycast(e) { let t = [], i = (r) => { for (let s of r.children) { let n = s.cloner; Ct.is(s) && !s.raycastLock && (s.visible || n?.object.data.visible) && ((js(s) || (f8(s) && this.enableHelpers && s.objectHelper.visible)) && (e.intersectObject(s, !1, t), T8(s, e, t)), i(s)); } }; return i(this), t; } forEachEntity(e) { for (let t of this.children) Ct.is(t) && e(t); } traverseEntity(e) { for (let t of this.children) Ct.is(t) && t.traverseEntity(e); } traverseObject(e) { for (let t of this.children) Yd.is(t) && t.traverseObject(e); } traverseVisibleEntity(e) { for (let t of this.children) Ct.is(t) && t.visible && t.traverseVisibleEntity(e); } updateFog(e, t) { (this.enableFog = e.enabled), (this.fogUseBGColor = e.useBackgroundColor), e.useBackgroundColor ? this.backupFog.color.set(this.bgColor) : (this.backupFog.color = sr(e.color, t)), (this.backupFog.near = e.near), (this.backupFog.far = e.far); } dispose() { this.clearScene(); } updateAmbientLight(e, t) { e.color !== void 0 && (this.ambientLight.color = sr(e.color, t)), e.intensity !== void 0 && (this.ambientLight.intensity = e.intensity), e.groundColor !== void 0 && (this.ambientLight.groundColor = sr(e.groundColor, t)), e.enabled !== void 0 && (this.ambientLight.visible = e.enabled); } switchActiveCamera(e) { this.activeCamera !== this.personalCamera && (this.activeCamera.objectHelper.visible = !0), (this.activeCamera = e), (e.objectHelper.visible = !1); } setBackgroundColor(e) { (this.bgColor = e), this.fogUseBGColor === !0 && (this.backupFog.color = e); } createChildrenObjects(e, t, i) { let r = 0; for (let s of e) this.createObject(s.id, s.data, s.children, t, r, i), (r += 1); } registerObjectCreatedInLegacy(e) { this.entityByUuid[e.uuid] = e; } unregisterObject(e) { delete this.entityByUuid[e.uuid]; for (let t of e.children) this.unregisterObject(t); } createObject(e, t, i, r, s, n) { let a = { scene: this, shared: n }, o = yv(e, t, a); return ( o && ((this.entityByUuid[e] = o), r.add(o), r.children.splice(s, 0, r.children.pop()), i.length > 0 && (o.isInstanceRoot ? console.error('instance should not have children!') : this.createChildrenObjects(i, o, n)), o.updateState(t, a), o instanceof Cr && o.updateGeometryGroupsIfNeeded(), o.updateVisible(), o.cloner && this.toExpandCloner.add(o), t.pathSnapping?.pathId && this.pathConstraints.setConstraint(e, t.pathSnapping.pathId)), o ); } getCenter(e) { let t = []; for (let r = 0, s = e.length; r < s; ++r) { let { id: n, recursive: a } = e[r], o = this.find(n), l = a ? o.recursiveBBox : o.singleBBox; t.push(...l.vertices); } let i = new Kt(); return i.setFromPoints(t), i.getCenter(db), db; } copyMatrixWorld(e, t) { if (e === null) { t.identity(); return; } let i = this.find(e); i ? t.copy(i.matrixWorld) : t.identity(); } copyParentMatrixWorld(e, t) { if (e === null) { t.identity(); return; } let i = this.find(e)?.parent; i ? t.copy(i.matrixWorld) : t.identity(); } traverseMaterial(e) { this.traverseEntity((t) => { if (t instanceof ar) if (Array.isArray(t.material)) for (let i = 0; i < t.material.length; i++) t.material[i] instanceof Ln && e(t.material[i]); else t.material instanceof Ln && e(t.material); }); } updateCanvasSize(e, t) { this.activeCamera.setViewplaneSize(e, t); let i, r; e >= t ? ((i = t / e), (r = 1)) : ((i = 1), (r = e / t)), this.traverseMaterial((s) => { s.getLayersOfType('transmission').forEach((n) => { (n.uniforms[`f${n.id}_aspectRatio`].value.x = i), (n.uniforms[`f${n.id}_aspectRatio`].value.y = r); }); }); } }, sl = ES; sl.PERSONAL_CAMERA_ID = 'f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera'; var ld = (e, t) => { let i = t.x - e.x, r = t.y - e.y; return Math.sqrt(i * i + r * r); }, N8 = (e, t) => { let i = t.x - e.x, r = t.y - e.y; return F8(Math.atan2(r, i)); }, U8 = (e, t, i) => { let r = { x: 0, y: 0 }; return (i = Ym(i)), (r.x = e.x - t * Math.cos(i)), (r.y = e.y - t * Math.sin(i)), r; }, Ym = (e) => e * (Math.PI / 180), F8 = (e) => e * (180 / Math.PI), k8 = (e) => (isNaN(e.buttons) ? e.pressure !== 0 : e.buttons !== 0), mf = new Map(), ub = (e) => { mf.has(e) && clearTimeout(mf.get(e)), mf.set(e, setTimeout(e, 100)); }, tu = (e, t, i) => { let r = t.split(/[ ,]+/g), s; for (let n = 0; n < r.length; n += 1) (s = r[n]), e.addEventListener ? e.addEventListener(s, i, !1) : e.attachEvent && e.attachEvent(s, i); }, pb = (e, t, i) => { let r = t.split(/[ ,]+/g), s; for (let n = 0; n < r.length; n += 1) (s = r[n]), e.removeEventListener ? e.removeEventListener(s, i) : e.detachEvent && e.detachEvent(s, i); }, CS = (e) => (e.preventDefault(), e.type.match(/^touch/) ? e.changedTouches : e), fb = () => { if (typeof window > 'u') return; let e = window.pageXOffset !== void 0 ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft, t = window.pageYOffset !== void 0 ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; return { x: e, y: t }; }, Qm = (e, t) => { t.top || t.right || t.bottom || t.left ? ((e.style.top = t.top), (e.style.right = t.right), (e.style.bottom = t.bottom), (e.style.left = t.left)) : ((e.style.left = t.x + 'px'), (e.style.top = t.y + 'px')); }, xv = (e, t, i) => { let r = TS(e); for (let s in r) if (r.hasOwnProperty(s)) if (typeof t == 'string') r[s] = t + ' ' + i; else { let n = ''; for (let a = 0, o = t.length; a < o; a += 1) n += t[a] + ' ' + i + ', '; r[s] = n.slice(0, -2); } return r; }, j8 = (e, t) => { let i = TS(e); for (let r in i) i.hasOwnProperty(r) && (i[r] = t); return i; }, TS = (e) => { let t = {}; return ( (t[e] = ''), ['webkit', 'Moz', 'o'].forEach(function (i) { t[i + e.charAt(0).toUpperCase() + e.slice(1)] = ''; }), t ); }, gf = (e, t) => { for (let i in t) t.hasOwnProperty(i) && (e[i] = t[i]); return e; }, G8 = (e, t) => { let i = {}; for (let r in e) e.hasOwnProperty(r) && t.hasOwnProperty(r) ? (i[r] = t[r]) : e.hasOwnProperty(r) && (i[r] = e[r]); return i; }, Zm = (e, t) => { if (e.length) for (let i = 0, r = e.length; i < r; i += 1) t(e[i]); else t(e); }, V8 = (e, t, i) => ({ x: Math.min(Math.max(e.x, t.x - i), t.x + i), y: Math.min(Math.max(e.y, t.y - i), t.y + i) }); typeof window < 'u' && ((PS = 'ontouchstart' in window), (DS = !!window.PointerEvent), (LS = !!window.MSPointerEvent)); var PS, DS, LS, zl = { touch: { start: 'touchstart', move: 'touchmove', end: 'touchend, touchcancel' }, mouse: { start: 'mousedown', move: 'mousemove', end: 'mouseup' }, pointer: { start: 'pointerdown', move: 'pointermove', end: 'pointerup, pointercancel' }, MSPointer: { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' } }, xo, Mh = {}; DS ? (xo = zl.pointer) : LS ? (xo = zl.MSPointer) : PS ? ((xo = zl.touch), (Mh = zl.mouse)) : (xo = zl.mouse); function Pa() {} Pa.prototype.on = function (e, t) { var i = this, r = e.split(/[ ,]+/g), s; i._handlers_ = i._handlers_ || {}; for (var n = 0; n < r.length; n += 1) (s = r[n]), (i._handlers_[s] = i._handlers_[s] || []), i._handlers_[s].push(t); return i; }; Pa.prototype.off = function (e, t) { var i = this; return ( (i._handlers_ = i._handlers_ || {}), e === void 0 ? (i._handlers_ = {}) : t === void 0 ? (i._handlers_[e] = null) : i._handlers_[e] && i._handlers_[e].indexOf(t) >= 0 && i._handlers_[e].splice(i._handlers_[e].indexOf(t), 1), i ); }; Pa.prototype.trigger = function (e, t) { var i = this, r = e.split(/[ ,]+/g), s; i._handlers_ = i._handlers_ || {}; for (var n = 0; n < r.length; n += 1) (s = r[n]), i._handlers_[s] && i._handlers_[s].length && i._handlers_[s].forEach(function (a) { a.call(i, { type: s, target: i }, t); }); }; Pa.prototype.config = function (e) { var t = this; (t.options = t.defaults || {}), e && (t.options = G8(t.options, e)); }; Pa.prototype.bindEvt = function (e, t) { var i = this; return ( (i._domHandlers_ = i._domHandlers_ || {}), (i._domHandlers_[t] = function () { typeof i['on' + t] == 'function' ? i['on' + t].apply(i, arguments) : console.warn('[WARNING] : Missing "on' + t + '" handler.'); }), tu(e, xo[t], i._domHandlers_[t]), Mh[t] && tu(e, Mh[t], i._domHandlers_[t]), i ); }; Pa.prototype.unbindEvt = function (e, t) { var i = this; return ( (i._domHandlers_ = i._domHandlers_ || {}), pb(e, xo[t], i._domHandlers_[t]), Mh[t] && pb(e, Mh[t], i._domHandlers_[t]), delete i._domHandlers_[t], this ); }; var bv = Pa; function ai(e, t) { return ( (this.identifier = t.identifier), (this.position = t.position), (this.frontPosition = t.frontPosition), (this.collection = e), (this.defaults = { size: 100, threshold: 0.1, color: 'white', fadeTime: 250, dataOnly: !1, restJoystick: !0, restOpacity: 1, mode: 'dynamic', zone: document.body, lockX: !1, lockY: !1, shape: 'circle' }), this.config(t), this.options.mode === 'dynamic' && (this.options.restOpacity = 0), (this.id = ai.id), (ai.id += 1), this.buildEl().stylize(), (this.instance = { el: this.ui.el, on: this.on.bind(this), off: this.off.bind(this), show: this.show.bind(this), hide: this.hide.bind(this), add: this.addToDom.bind(this), remove: this.removeFromDom.bind(this), destroy: this.destroy.bind(this), setPosition: this.setPosition.bind(this), resetDirection: this.resetDirection.bind(this), computeDirection: this.computeDirection.bind(this), trigger: this.trigger.bind(this), position: this.position, frontPosition: this.frontPosition, ui: this.ui, identifier: this.identifier, id: this.id, options: this.options }), this.instance ); } ai.prototype = new bv(); ai.constructor = ai; ai.id = 0; ai.prototype.buildEl = function (e) { return ( (this.ui = {}), this.options.dataOnly ? this : ((this.ui.el = document.createElement('div')), (this.ui.back = document.createElement('div')), (this.ui.front = document.createElement('div')), (this.ui.el.className = 'nipple collection_' + this.collection.id), (this.ui.back.className = 'back'), (this.ui.front.className = 'front'), this.ui.el.setAttribute('id', 'nipple_' + this.collection.id + '_' + this.id), this.ui.el.appendChild(this.ui.back), this.ui.el.appendChild(this.ui.front), this) ); }; ai.prototype.stylize = function () { if (this.options.dataOnly) return this; var e = this.options.fadeTime + 'ms', t = j8('borderRadius', '50%'), i = xv('transition', 'opacity', e), r = {}; return ( (r.el = { position: 'absolute', opacity: this.options.restOpacity, display: 'block', zIndex: 999 }), (r.back = { position: 'absolute', display: 'block', width: this.options.size + 'px', height: this.options.size + 'px', marginLeft: -this.options.size / 2 + 'px', marginTop: -this.options.size / 2 + 'px', background: 'rgba(255, 255, 255, .4)', border: 'solid 2px rgba(0, 0, 0, .1)' }), (r.front = { width: this.options.size / 2 + 'px', height: this.options.size / 2 + 'px', position: 'absolute', display: 'block', marginLeft: -this.options.size / 4 + 'px', marginTop: -this.options.size / 4 + 'px', background: 'rgba(255, 255, 255, .8)', border: 'solid 2px rgba(0, 0, 0, .1)' }), gf(r.el, i), this.options.shape === 'circle' && gf(r.back, t), gf(r.front, t), this.applyStyles(r), this ); }; ai.prototype.applyStyles = function (e) { for (var t in this.ui) if (this.ui.hasOwnProperty(t)) for (var i in e[t]) this.ui[t].style[i] = e[t][i]; return this; }; ai.prototype.addToDom = function () { return this.options.dataOnly || document.body.contains(this.ui.el) ? this : (this.options.zone.appendChild(this.ui.el), this); }; ai.prototype.removeFromDom = function () { return this.options.dataOnly || !document.body.contains(this.ui.el) ? this : (this.options.zone.removeChild(this.ui.el), this); }; ai.prototype.destroy = function () { clearTimeout(this.removeTimeout), clearTimeout(this.showTimeout), clearTimeout(this.restTimeout), this.trigger('destroyed', this.instance), this.removeFromDom(), this.off(); }; ai.prototype.show = function (e) { var t = this; return ( t.options.dataOnly || (clearTimeout(t.removeTimeout), clearTimeout(t.showTimeout), clearTimeout(t.restTimeout), t.addToDom(), t.restCallback(), setTimeout(function () { t.ui.el.style.opacity = 1; }, 0), (t.showTimeout = setTimeout(function () { t.trigger('shown', t.instance), typeof e == 'function' && e.call(this); }, t.options.fadeTime))), t ); }; ai.prototype.hide = function (e) { var t = this; if (t.options.dataOnly) return t; if ( ((t.ui.el.style.opacity = t.options.restOpacity), clearTimeout(t.removeTimeout), clearTimeout(t.showTimeout), clearTimeout(t.restTimeout), (t.removeTimeout = setTimeout(function () { var i = t.options.mode === 'dynamic' ? 'none' : 'block'; (t.ui.el.style.display = i), typeof e == 'function' && e.call(t), t.trigger('hidden', t.instance); }, t.options.fadeTime)), t.options.restJoystick) ) { let i = t.options.restJoystick, r = {}; (r.x = i === !0 || i.x !== !1 ? 0 : t.instance.frontPosition.x), (r.y = i === !0 || i.y !== !1 ? 0 : t.instance.frontPosition.y), t.setPosition(e, r); } return t; }; ai.prototype.setPosition = function (e, t) { var i = this; i.frontPosition = { x: t.x, y: t.y }; var r = i.options.fadeTime + 'ms', s = {}; s.front = xv('transition', ['top', 'left'], r); var n = { front: {} }; (n.front = { left: i.frontPosition.x + 'px', top: i.frontPosition.y + 'px' }), i.applyStyles(s), i.applyStyles(n), (i.restTimeout = setTimeout(function () { typeof e == 'function' && e.call(i), i.restCallback(); }, i.options.fadeTime)); }; ai.prototype.restCallback = function () { var e = this, t = {}; (t.front = xv('transition', 'none', '')), e.applyStyles(t), e.trigger('rested', e.instance); }; ai.prototype.resetDirection = function () { this.direction = { x: !1, y: !1, angle: !1 }; }; ai.prototype.computeDirection = function (e) { var t = e.angle.radian, i = Math.PI / 4, r = Math.PI / 2, s, n, a; if ( (t > i && t < i * 3 && !e.lockX ? (s = 'up') : t > -i && t <= i && !e.lockY ? (s = 'left') : t > -i * 3 && t <= -i && !e.lockX ? (s = 'down') : e.lockY || (s = 'right'), e.lockY || (t > -r && t < r ? (n = 'left') : (n = 'right')), e.lockX || (t > 0 ? (a = 'up') : (a = 'down')), e.force > this.options.threshold) ) { var o = {}, l; for (l in this.direction) this.direction.hasOwnProperty(l) && (o[l] = this.direction[l]); var h = {}; (this.direction = { x: n, y: a, angle: s }), (e.direction = this.direction); for (l in o) o[l] === this.direction[l] && (h[l] = !0); if (h.x && h.y && h.angle) return e; (!h.x || !h.y) && this.trigger('plain', e), h.x || this.trigger('plain:' + n, e), h.y || this.trigger('plain:' + a, e), h.angle || this.trigger('dir dir:' + s, e); } else this.resetDirection(); return e; }; var H8 = ai; function Ht(e, t) { var i = this; (i.nipples = []), (i.idles = []), (i.actives = []), (i.ids = []), (i.pressureIntervals = {}), (i.manager = e), (i.id = Ht.id), (Ht.id += 1), (i.defaults = { zone: document.body, multitouch: !1, maxNumberOfNipples: 10, mode: 'dynamic', position: { top: 0, left: 0 }, catchDistance: 200, size: 100, threshold: 0.1, color: 'white', fadeTime: 250, dataOnly: !1, restJoystick: !0, restOpacity: 1, lockX: !1, lockY: !1, shape: 'circle', dynamicPage: !1, follow: !1 }), i.config(t), (i.options.mode === 'static' || i.options.mode === 'semi') && (i.options.multitouch = !1), i.options.multitouch || (i.options.maxNumberOfNipples = 1); let r = getComputedStyle(i.options.zone.parentElement); return r && r.display === 'flex' && (i.parentIsFlex = !0), i.updateBox(), i.prepareNipples(), i.bindings(), i.begin(), i.nipples; } Ht.prototype = new bv(); Ht.constructor = Ht; Ht.id = 0; Ht.prototype.prepareNipples = function () { var e = this, t = e.nipples; (t.on = e.on.bind(e)), (t.off = e.off.bind(e)), (t.options = e.options), (t.destroy = e.destroy.bind(e)), (t.ids = e.ids), (t.id = e.id), (t.processOnMove = e.processOnMove.bind(e)), (t.processOnEnd = e.processOnEnd.bind(e)), (t.get = function (i) { if (i === void 0) return t[0]; for (var r = 0, s = t.length; r < s; r += 1) if (t[r].identifier === i) return t[r]; return !1; }); }; Ht.prototype.bindings = function () { var e = this; e.bindEvt(e.options.zone, 'start'), (e.options.zone.style.touchAction = 'none'), (e.options.zone.style.msTouchAction = 'none'); }; Ht.prototype.begin = function () { var e = this, t = e.options; if (t.mode === 'static') { var i = e.createNipple(t.position, e.manager.getIdentifier()); i.add(), e.idles.push(i); } }; Ht.prototype.createNipple = function (e, t) { var i = this, r = i.manager.scroll, s = {}, n = i.options, a = { x: i.parentIsFlex ? r.x : r.x + i.box.left, y: i.parentIsFlex ? r.y : r.y + i.box.top }; if (e.x && e.y) s = { x: e.x - a.x, y: e.y - a.y }; else if (e.top || e.right || e.bottom || e.left) { var o = document.createElement('DIV'); (o.style.display = 'hidden'), (o.style.top = e.top), (o.style.right = e.right), (o.style.bottom = e.bottom), (o.style.left = e.left), (o.style.position = 'absolute'), n.zone.appendChild(o); var l = o.getBoundingClientRect(); n.zone.removeChild(o), (s = e), (e = { x: l.left + r.x, y: l.top + r.y }); } var h = new H8(i, { color: n.color, size: n.size, threshold: n.threshold, fadeTime: n.fadeTime, dataOnly: n.dataOnly, restJoystick: n.restJoystick, restOpacity: n.restOpacity, mode: n.mode, identifier: t, position: e, zone: n.zone, frontPosition: { x: 0, y: 0 }, shape: n.shape }); return ( n.dataOnly || (Qm(h.ui.el, s), Qm(h.ui.front, h.frontPosition)), i.nipples.push(h), i.trigger('added ' + h.identifier + ':added', h), i.manager.trigger('added ' + h.identifier + ':added', h), i.bindNipple(h), h ); }; Ht.prototype.updateBox = function () { var e = this; e.box = e.options.zone.getBoundingClientRect(); }; Ht.prototype.bindNipple = function (e) { var t = this, i, r = function (s, n) { (i = s.type + ' ' + n.id + ':' + s.type), t.trigger(i, n); }; e.on('destroyed', t.onDestroyed.bind(t)), e.on('shown hidden rested dir plain', r), e.on('dir:up dir:right dir:down dir:left', r), e.on('plain:up plain:right plain:down plain:left', r); }; Ht.prototype.pressureFn = function (e, t, i) { var r = this, s = 0; clearInterval(r.pressureIntervals[i]), (r.pressureIntervals[i] = setInterval( function () { var n = e.force || e.pressure || e.webkitForce || 0; n !== s && (t.trigger('pressure', n), r.trigger('pressure ' + t.identifier + ':pressure', n), (s = n)); }.bind(r), 100 )); }; Ht.prototype.onstart = function (e) { var t = this, i = t.options, r = e; (e = CS(e)), t.updateBox(); var s = function (n) { t.actives.length < i.maxNumberOfNipples ? t.processOnStart(n) : r.type.match(/^touch/) && (Object.keys(t.manager.ids).forEach(function (a) { if ( Object.values(r.touches).findIndex(function (l) { return l.identifier === a; }) < 0 ) { var o = [e[0]]; (o.identifier = a), t.processOnEnd(o); } }), t.actives.length < i.maxNumberOfNipples && t.processOnStart(n)); }; return Zm(e, s), t.manager.bindDocument(), !1; }; Ht.prototype.processOnStart = function (e) { var t = this, i = t.options, r, s = t.manager.getIdentifier(e), n = e.force || e.pressure || e.webkitForce || 0, a = { x: e.pageX, y: e.pageY }, o = t.getOrCreate(s, a); o.identifier !== s && t.manager.removeIdentifier(o.identifier), (o.identifier = s); var l = function (u) { u.trigger('start', u), t.trigger('start ' + u.id + ':start', u), u.show(), n > 0 && t.pressureFn(e, u, u.identifier), t.processOnMove(e); }; if (((r = t.idles.indexOf(o)) >= 0 && t.idles.splice(r, 1), t.actives.push(o), t.ids.push(o.identifier), i.mode !== 'semi')) l(o); else { var h = ld(a, o.position); if (h <= i.catchDistance) l(o); else { o.destroy(), t.processOnStart(e); return; } } return o; }; Ht.prototype.getOrCreate = function (e, t) { var i = this, r = i.options, s; return /(semi|static)/.test(r.mode) ? ((s = i.idles[0]), s ? (i.idles.splice(0, 1), s) : r.mode === 'semi' ? i.createNipple(t, e) : (console.warn("Coudln't find the needed nipple."), !1)) : ((s = i.createNipple(t, e)), s); }; Ht.prototype.processOnMove = function (e) { var t = this, i = t.options, r = t.manager.getIdentifier(e), s = t.nipples.get(r), n = t.manager.scroll; if (!k8(e)) { this.processOnEnd(e); return; } if (!s) { console.error('Found zombie joystick with ID ' + r), t.manager.removeIdentifier(r); return; } if (i.dynamicPage) { var a = s.el.getBoundingClientRect(); s.position = { x: n.x + a.left, y: n.y + a.top }; } s.identifier = r; var o = s.options.size / 2, l = { x: e.pageX, y: e.pageY }; i.lockX && (l.y = s.position.y), i.lockY && (l.x = s.position.x); var h = ld(l, s.position), u = N8(l, s.position), c = Ym(u), d = h / o, p = { distance: h, position: l }, f, g; if ( (s.options.shape === 'circle' ? ((f = Math.min(h, o)), (g = U8(s.position, f, u))) : ((g = V8(l, s.position, o)), (f = ld(g, s.position))), i.follow) ) { if (h > o) { let b = l.x - g.x, x = l.y - g.y; (s.position.x += b), (s.position.y += x), (s.el.style.top = s.position.y - (t.box.top + n.y) + 'px'), (s.el.style.left = s.position.x - (t.box.left + n.x) + 'px'), (h = ld(l, s.position)); } } else (l = g), (h = f); var m = l.x - s.position.x, v = l.y - s.position.y; (s.frontPosition = { x: m, y: v }), i.dataOnly || Qm(s.ui.front, s.frontPosition); var y = { identifier: s.identifier, position: l, force: d, pressure: e.force || e.pressure || e.webkitForce || 0, distance: h, angle: { radian: c, degree: u }, vector: { x: m / o, y: -v / o }, raw: p, instance: s, lockX: i.lockX, lockY: i.lockY }; (y = s.computeDirection(y)), (y.angle = { radian: Ym(180 - u), degree: 180 - u }), s.trigger('move', y), t.trigger('move ' + s.id + ':move', y); }; Ht.prototype.processOnEnd = function (e) { var t = this, i = t.options, r = t.manager.getIdentifier(e), s = t.nipples.get(r), n = t.manager.removeIdentifier(s.identifier); !s || (i.dataOnly || s.hide(function () { i.mode === 'dynamic' && (s.trigger('removed', s), t.trigger('removed ' + s.id + ':removed', s), t.manager.trigger('removed ' + s.id + ':removed', s), s.destroy()); }), clearInterval(t.pressureIntervals[s.identifier]), s.resetDirection(), s.trigger('end', s), t.trigger('end ' + s.id + ':end', s), t.ids.indexOf(s.identifier) >= 0 && t.ids.splice(t.ids.indexOf(s.identifier), 1), t.actives.indexOf(s) >= 0 && t.actives.splice(t.actives.indexOf(s), 1), /(semi|static)/.test(i.mode) ? t.idles.push(s) : t.nipples.indexOf(s) >= 0 && t.nipples.splice(t.nipples.indexOf(s), 1), t.manager.unbindDocument(), /(semi|static)/.test(i.mode) && (t.manager.ids[n.id] = n.identifier)); }; Ht.prototype.onDestroyed = function (e, t) { var i = this; i.nipples.indexOf(t) >= 0 && i.nipples.splice(i.nipples.indexOf(t), 1), i.actives.indexOf(t) >= 0 && i.actives.splice(i.actives.indexOf(t), 1), i.idles.indexOf(t) >= 0 && i.idles.splice(i.idles.indexOf(t), 1), i.ids.indexOf(t.identifier) >= 0 && i.ids.splice(i.ids.indexOf(t.identifier), 1), i.manager.removeIdentifier(t.identifier), i.manager.unbindDocument(); }; Ht.prototype.destroy = function () { var e = this; e.unbindEvt(e.options.zone, 'start'), e.nipples.forEach(function (i) { i.destroy(); }); for (var t in e.pressureIntervals) e.pressureIntervals.hasOwnProperty(t) && clearInterval(e.pressureIntervals[t]); e.trigger('destroyed', e.nipples), e.manager.unbindDocument(), e.off(); }; var W8 = Ht; function di(e) { var t = this; (t.ids = {}), (t.index = 0), (t.collections = []), (t.scroll = fb()), t.config(e), t.prepareCollections(); var i = function () { var s; t.collections.forEach(function (n) { n.forEach(function (a) { (s = a.el.getBoundingClientRect()), (a.position = { x: t.scroll.x + s.left, y: t.scroll.y + s.top }); }); }); }; if (typeof window > 'u') return t.collections; tu(window, 'resize', function () { ub(i); }); var r = function () { t.scroll = fb(); }; return ( tu(window, 'scroll', function () { ub(r); }), t.collections ); } di.prototype = new bv(); di.constructor = di; di.prototype.prepareCollections = function () { var e = this; (e.collections.create = e.create.bind(e)), (e.collections.on = e.on.bind(e)), (e.collections.off = e.off.bind(e)), (e.collections.destroy = e.destroy.bind(e)), (e.collections.get = function (t) { var i; return ( e.collections.every(function (r) { return (i = r.get(t)), !i; }), i ); }); }; di.prototype.create = function (e) { return this.createCollection(e); }; di.prototype.createCollection = function (e) { var t = this, i = new W8(t, e); return t.bindCollection(i), t.collections.push(i), i; }; di.prototype.bindCollection = function (e) { var t = this, i, r = function (s, n) { (i = s.type + ' ' + n.id + ':' + s.type), t.trigger(i, n); }; e.on('destroyed', t.onDestroyed.bind(t)), e.on('shown hidden rested dir plain', r), e.on('dir:up dir:right dir:down dir:left', r), e.on('plain:up plain:right plain:down plain:left', r); }; di.prototype.bindDocument = function () { var e = this; e.binded || (e.bindEvt(document, 'move').bindEvt(document, 'end'), (e.binded = !0)); }; di.prototype.unbindDocument = function (e) { var t = this; (!Object.keys(t.ids).length || e === !0) && (t.unbindEvt(document, 'move').unbindEvt(document, 'end'), (t.binded = !1)); }; di.prototype.getIdentifier = function (e) { var t; return ( e ? ((t = e.identifier === void 0 ? e.pointerId : e.identifier), t === void 0 && (t = this.latest || 0)) : (t = this.index), this.ids[t] === void 0 && ((this.ids[t] = this.index), (this.index += 1)), (this.latest = t), this.ids[t] ); }; di.prototype.removeIdentifier = function (e) { var t = {}; for (var i in this.ids) if (this.ids[i] === e) { (t.id = i), (t.identifier = this.ids[i]), delete this.ids[i]; break; } return t; }; di.prototype.onmove = function (e) { var t = this; return t.onAny('move', e), !1; }; di.prototype.onend = function (e) { var t = this; return t.onAny('end', e), !1; }; di.prototype.oncancel = function (e) { var t = this; return t.onAny('end', e), !1; }; di.prototype.onAny = function (e, t) { var i = this, r, s = 'processOn' + e.charAt(0).toUpperCase() + e.slice(1); t = CS(t); var n = function (o, l, h) { h.ids.indexOf(l) >= 0 && (h[s](o), (o._found_ = !0)); }, a = function (o) { (r = i.getIdentifier(o)), Zm(i.collections, n.bind(null, o, r)), o._found_ || i.removeIdentifier(r); }; return Zm(t, a), !1; }; di.prototype.destroy = function () { var e = this; e.unbindDocument(!0), (e.ids = {}), (e.index = 0), e.collections.forEach(function (t) { t.destroy(); }), e.off(); }; di.prototype.onDestroyed = function (e, t) { var i = this; if (i.collections.indexOf(t) < 0) return !1; i.collections.splice(i.collections.indexOf(t), 1); }; var X8 = di, mb = new X8(), q8 = { create: function (e) { return mb.create(e); }, factory: mb }, Y8 = Eh(rw()); function eo(e, t) { let i = new Ve(); if (!e.getAttribute('position')) return i.setAttribute('position', new Ce([], 3)), i.setIndex([]), i; let { positions: r, triIndices: s } = ov(e.getAttribute('position'), e.getIndex()); return i.setAttribute('position', new Ce(r, 3)), i.setIndex(s), t && i.applyMatrix4(t), i; } var Q8 = new ve(), Z8 = new ve(), $r = [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ]; function OS(e) { let t = e.elements; ($r[0][0] = t[0]), ($r[0][1] = t[4]), ($r[0][2] = t[8]), ($r[1][0] = t[1]), ($r[1][1] = t[5]), ($r[1][2] = t[9]), ($r[2][0] = t[2]), ($r[2][1] = t[6]), ($r[2][2] = t[10]); let { u: i, v: r } = (0, Y8.SVD)($r), s = Q8.set(i[0][0], i[0][1], i[0][2], 0, i[1][0], i[1][1], i[1][2], 0, i[2][0], i[2][1], i[2][2], 0, 0, 0, 0, 1), n = Z8.set(r[0][0], r[0][1], r[0][2], 0, r[1][0], r[1][1], r[1][2], 0, r[2][0], r[2][1], r[2][2], 0, 0, 0, 0, 1); return s.multiply(n.transpose()); } var K8 = class extends kw { constructor() { super(), this.layers.enable(3), this.layers.enable(8); } setFromCamera(e, t) { t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, -1).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), (this.camera = t)) : t.isPerspectiveCamera ? (this.ray.origin.set(e.x, e.y, -1).unproject(t), this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(), (this.camera = t)) : console.error('Raycaster: Unsupported camera type.'); } intersectVisibleObjects(e, t = !0, i = []) { return ( e.forEach((r) => { r.visible && this.intersectObject(r, t, i); }), i ); } createRaycastLineHelper() { let e = new Rn({ color: 65280, linewidth: 10 }), t = new E(this.ray.origin.x, this.ray.origin.y, this.ray.origin.z), i = new E(this.ray.direction.x, this.ray.direction.y, this.ray.direction.z), r = this.camera.far - this.camera.near, s = new E().addVectors(t, i.multiplyScalar(r)), n = new Ve(); return n.setFromPoints([t, s]), new vd(n, e); } }, IS = (e) => e instanceof Wm || e instanceof Ro; function J8(e, t) { return e.distance - t.distance; } function RS(e, t, i) { if (!(!mn(t) || !t.visible)) { js(t) && t.raycast(e, i); for (let r of t.children) RS(e, r, i); } } function Km(e, t, i) { if (!i.some((s) => iu(e, s) !== void 0)) return []; let r = []; return t.children.forEach((s) => RS(e, s, r)), r.sort(J8), r; } function Jm(e) { let t = []; if (e.length) { let i = e[0].object; mn(i) && t.push(i); let r = i.parent; for (; r; ) IS(r) && t.push(r), (r = r.parent); } return t; } function iu(e, t) { if (js(t)) { if (t.visible) { let i = []; return t.raycast(e, i), i.length ? i[0] : void 0; } } else if (IS(t)) return BS(e, t); } function BS(e, t) { if (!(!mn(t) || !t.visible)) { if (js(t)) { let i = []; if ((t.raycast(e, i), i.length)) return i[0]; } for (let i of t.children) { let r = BS(e, i); if (r) return r; } } } function $8(e, t, i) { return { x: ((e - (i.left + window.scrollX)) / i.width) * 2 - 1, y: -((t - (i.top + window.scrollY)) / i.height) * 2 + 1 }; } var ej = class { constructor(e, t, i, r, s, n) { (this.isExport = n), (this.raycaster = new K8()), (this.raycasterNeedsUpdate = !0), (this.stopRaycast = !1), (this._useWindowEvents = !1), (this.sharedAssets = new Eu(Wd.emptyData())), (this.scene = new sl({ ...Em.defaultData }, this.sharedAssets)), (this.camera = new Gi()), (this.renderer = e), (this._useWindowEvents = t.data.publish.mouseEventTarget === 'window'), (this.domElement = e.domElement), (this.eventElement = this._useWindowEvents ? window : e.domElement), (this.stopRaycast = s), (this.sharedAssets = r), (this.scene = t), (this.camera = i); } set useWindowEvents(e) { (this._useWindowEvents = e), (this.eventElement = e ? window : this.renderer.domElement); } get useWindowEvents() { return this._useWindowEvents; } updateRaycaster(e) { if (!this.raycasterNeedsUpdate) return; this.raycasterNeedsUpdate = !1; let { pageX: t, pageY: i } = e.touches !== void 0 && e.touches.length > 0 ? e.touches[0] : e, r = this.domElement.getBoundingClientRect(); this.raycaster.setFromCamera($8(t, i, r), this.camera); } }, zS = ((e) => ( (e[(e.keydown = 0)] = 'keydown'), (e[(e.keyup = 1)] = 'keyup'), (e[(e.pointerdown = 2)] = 'pointerdown'), (e[(e.pointerup = 3)] = 'pointerup'), (e[(e.pointermove = 4)] = 'pointermove'), (e[(e.wheel = 5)] = 'wheel'), (e[(e.scroll = 6)] = 'scroll'), e ))(zS || {}), zn = class { constructor(e) { (this.eventContext = e), (this.domEventsNeeded = new Set()), (this.hasVideoAction = !1); } connect() {} disconnect() {} }, NS = new Map(), ih = new Map(), bo = class { constructor(e, t, i, r) { this.data = t; let { audio: s, volume: n, delay: a, loop: o } = t; if (!s) throw new Error('Missing property'); let l = typeof s == 'string' ? r.getAudio(s).src : s.data; (this.audioPlayer = new Yl({ src: l, volume: n, delay: a, loop: o })), ih.has(i.uuid) ? ih.get(i.uuid).push(this) : ih.set(i.uuid, [this]), NS.set(e, this); } playByToggle() { this.data.toggle === 'stop' ? this.audioPlayer.status === 'playing' ? this.audioPlayer.stop() : (this.audioPlayer.stop(), this.audioPlayer.play()) : this.data.toggle === 'pause' ? this.audioPlayer.status === 'playing' ? this.audioPlayer.pause() : this.audioPlayer.play() : (this.audioPlayer.stop(), this.audioPlayer.play()); } dispose() { this.audioPlayer.stop(); } }, $m = class { constructor(e) { this.data = e; } dispatch() { this.data.playAudio ? this.pauseAudio(this.data.playAudio) : this.data.object ? this.pauseAllAudiosFromObject(this.data.object) : this.pauseAllAudios(); } pauseAudio(e) { let t = NS.get(e); !t || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { t.audioPlayer[this.data.interaction](), this.disposeDelay(); }, this.data.delay))) : t.audioPlayer[this.data.interaction]()); } pauseAllAudiosFromObject(e) { let t = ih.get(e); !t?.length || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { t.forEach((i) => i.audioPlayer[this.data.interaction]()), this.disposeDelay(); }, this.data.delay))) : t.forEach((i) => i.audioPlayer[this.data.interaction]())); } pauseAllAudios() { let e = [...ih.values()]; !e.length || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { e.forEach((t) => { t.forEach((i) => { i.audioPlayer[this.data.interaction](); }); }), this.disposeDelay(); }, this.data.delay))) : e.forEach((t) => { t.forEach((i) => { i.audioPlayer[this.data.interaction](); }); })); } disposeDelay() { clearTimeout(this.timeoutId), delete this.timeoutId; } dispose() { clearTimeout(this.timeoutId), delete this.timeoutId; } }, wo = class { constructor(e, t, i, r) { if (((this.data = t), t.interaction === 'play')) this.interaction = new bo(e, t, i, r); else if (t.interaction === 'pause' || t.interaction === 'stop') this.interaction = new $m(t); else throw new Error('Missing property'); } dispatchBasic() { this.interaction instanceof bo ? this.interaction.playByToggle() : this.interaction.dispatch(); } dispatchConditional() { this.interaction instanceof bo ? this.interaction.audioPlayer.play() : this.interaction.dispatch(); } dispatchGameControl(e) { this.interaction instanceof bo && (e === 'start' ? this.interaction.audioPlayer.play() : this.interaction.audioPlayer.stop()); } dispose() { this.interaction.dispose(); } }; function tj(e, t) { let i = e.material.layers.find((r) => r.uuid === t); return i.color.texture.image.img instanceof HTMLVideoElement ? i.color.texture.image.img : void 0; } var US = new Map(), rh = new Map(), sh = class { constructor(e, t, i) { (this.data = t), (this.delay = 0), (this.status = 'stopped'); let { layerId: r, loop: s, volume: n, delay: a } = t; if (((this.object = i), r === void 0)) throw new Error('Missing property'); let o = tj(i, r); if (o) (this.videoElement = o), (this.videoElement.loop = s === 1 / 0), (this.videoElement.autoplay = !0), n !== void 0 && (this.videoElement.volume = n); else throw new Error('Missing property'); a !== void 0 && (this.delay = a), rh.has(i.uuid) ? rh.get(i.uuid).push(this) : rh.set(i.uuid, [this]), US.set(e, this), this.pause(); } mute() { this.videoElement.muted = !0; } unMute() { this.videoElement.muted = !1; } play(e) { let t = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); e ? (this.mute(), (this.delay += 150)) : t ? (this.mute(), window.setTimeout(() => { this.unMute(); }, 100)) : this.unMute(), (this.delayTimerId = window.setTimeout(() => { this.videoElement.play(), this.clearDelay(); }, this.delay)), (this.status = 'playing'); } clearDelay() { this.delayTimerId && (clearTimeout(this.delayTimerId), delete this.delayTimerId); } pause() { this.videoElement.pause(), (this.status = 'paused'); } stop() { this.videoElement.pause(), (this.videoElement.currentTime = 0), (this.status = 'stopped'), this.clearDelay(); } playByToggle() { this.data.toggle === 'stop' ? this.status === 'playing' ? this.stop() : (this.stop(), this.play()) : this.data.toggle === 'pause' ? this.status === 'playing' ? this.pause() : this.play() : (this.stop(), this.play()); } dispose() { this.stop(), (this.videoElement.muted = !0); } }, eg = class { constructor(e) { this.data = e; } dispatch() { this.data.playVideo ? this.pauseVideo(this.data.playVideo) : this.data.object ? this.pauseAllVideosFromObject(this.data.object) : this.pauseAllVideos(); } pauseVideo(e) { let t = US.get(e); !t || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { t[this.data.interaction](), this.disposeDelay(); }, this.data.delay))) : t[this.data.interaction]()); } pauseAllVideosFromObject(e) { let t = rh.get(e); !t?.length || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { t.forEach((i) => i[this.data.interaction]()), this.disposeDelay(); }, this.data.delay))) : t.forEach((i) => i[this.data.interaction]())); } pauseAllVideos() { let e = [...rh.values()]; !e.length || (this.data.delay > 0 ? (this.disposeDelay(), (this.timeoutId = window.setTimeout(() => { e.forEach((t) => { t.forEach((i) => { i[this.data.interaction](); }); }), this.disposeDelay(); }, this.data.delay))) : e.forEach((t) => { t.forEach((i) => { i[this.data.interaction](); }); })); } disposeDelay() { clearTimeout(this.timeoutId), delete this.timeoutId; } dispose() { clearTimeout(this.timeoutId), delete this.timeoutId; } }, ru = class { constructor(e, t, i) { if (((this.data = t), t.interaction === 'play')) this.interaction = new sh(e, t, i); else if (t.interaction === 'pause' || t.interaction === 'stop') this.interaction = new eg(t); else throw new Error('Missing property'); } dispatchBasic() { this.interaction instanceof sh ? this.interaction.playByToggle() : this.interaction.dispatch(); } dispatchConditional() { this.interaction instanceof sh ? this.interaction.play() : this.interaction.dispatch(); } dispose() { this.interaction.dispose(); } }, ij = 'text/plain', rj = 'us-ascii', gb = (e, t) => t.some((i) => (i instanceof RegExp ? i.test(e) : i === e)), sj = (e, { stripHash: t }) => { let i = /^data:(?[^,]*?),(?[^#]*?)(?:#(?.*))?$/.exec(e); if (!i) throw new Error(`Invalid URL: ${e}`); let { type: r, data: s, hash: n } = i.groups, a = r.split(';'); n = t ? '' : n; let o = !1; a[a.length - 1] === 'base64' && (a.pop(), (o = !0)); let l = (a.shift() || '').toLowerCase(), h = [ ...a .map((u) => { let [c, d = ''] = u.split('=').map((p) => p.trim()); return c === 'charset' && ((d = d.toLowerCase()), d === rj) ? '' : `${c}${d ? `=${d}` : ''}`; }) .filter(Boolean) ]; return ( o && h.push('base64'), (h.length > 0 || (l && l !== ij)) && h.unshift(l), `data:${h.join(';')},${o ? s.trim() : s}${n ? `#${n}` : ''}` ); }; function nj(e, t) { if ( ((t = { defaultProtocol: 'http:', normalizeProtocol: !0, forceHttp: !1, forceHttps: !1, stripAuthentication: !0, stripHash: !1, stripTextFragment: !0, stripWWW: !0, removeQueryParameters: [/^utm_\w+/i], removeTrailingSlash: !0, removeSingleSlash: !0, removeDirectoryIndex: !1, sortQueryParameters: !0, ...t }), (e = e.trim()), /^data:/i.test(e)) ) return sj(e, t); if (/^view-source:/i.test(e)) throw new Error('`view-source:` is not supported as it is a non-standard protocol'); let i = e.startsWith('//'); (!i && /^\.*\//.test(e)) || (e = e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, t.defaultProtocol)); let r = new URL(e); if (t.forceHttp && t.forceHttps) throw new Error('The `forceHttp` and `forceHttps` options cannot be used together'); if ( (t.forceHttp && r.protocol === 'https:' && (r.protocol = 'http:'), t.forceHttps && r.protocol === 'http:' && (r.protocol = 'https:'), t.stripAuthentication && ((r.username = ''), (r.password = '')), t.stripHash ? (r.hash = '') : t.stripTextFragment && (r.hash = r.hash.replace(/#?:~:text.*?$/i, '')), r.pathname) ) { let n = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g, a = 0, o = ''; for (;;) { let h = n.exec(r.pathname); if (!h) break; let u = h[0], c = h.index, d = r.pathname.slice(a, c); (o += d.replace(/\/{2,}/g, '/')), (o += u), (a = c + u.length); } let l = r.pathname.slice(a, r.pathname.length); (o += l.replace(/\/{2,}/g, '/')), (r.pathname = o); } if (r.pathname) try { r.pathname = decodeURI(r.pathname); } catch {} if ( (t.removeDirectoryIndex === !0 && (t.removeDirectoryIndex = [/^index\.[a-z]+$/]), Array.isArray(t.removeDirectoryIndex) && t.removeDirectoryIndex.length > 0) ) { let n = r.pathname.split('/'), a = n[n.length - 1]; gb(a, t.removeDirectoryIndex) && ((n = n.slice(0, -1)), (r.pathname = n.slice(1).join('/') + '/')); } if ( (r.hostname && ((r.hostname = r.hostname.replace(/\.$/, '')), t.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname) && (r.hostname = r.hostname.replace(/^www\./, ''))), Array.isArray(t.removeQueryParameters)) ) for (let n of [...r.searchParams.keys()]) gb(n, t.removeQueryParameters) && r.searchParams.delete(n); if ((t.removeQueryParameters === !0 && (r.search = ''), t.sortQueryParameters)) { r.searchParams.sort(); try { r.search = decodeURIComponent(r.search); } catch {} } t.removeTrailingSlash && (r.pathname = r.pathname.replace(/\/$/, '')); let s = e; return ( (e = r.toString()), !t.removeSingleSlash && r.pathname === '/' && !s.endsWith('/') && r.hash === '' && (e = e.replace(/\/$/, '')), (t.removeTrailingSlash || r.pathname === '/') && r.hash === '' && t.removeSingleSlash && (e = e.replace(/\/$/, '')), i && !t.normalizeProtocol && (e = e.replace(/^http:\/\//, '//')), t.stripProtocol && (e = e.replace(/^(?:https?:)?\/\//, '')), e ); } var aj = class { constructor({ url: e, context: t }, i) { if (((this.managers = i), !e)) throw new Error('Missing property'); (this.url = e.startsWith('mailto:') ? e : nj(e, { removeTrailingSlash: !1, removeSingleSlash: !1 })), (this.context = t ?? 'tab'); } dispatch() { Mm ? window.location.assign(this.url) : (this.context === 'tab' ? window.open(this.url, '_blank') : this.context === 'window' ? window.open(this.url, '_blank', `width=${window.innerWidth}, height=${window.innerHeight}`) : window.open(this.url, '_parent'), this.managers.controlsManager.orbitControls?.onPointerUp(Qe[0]), tU()); } }, oj = class { constructor(e, t, i, r) { (this.scene = t), (this.sharedAssets = i), (this.sceneData = e), (this.managers = r); } dispatch() { i2(this.sceneData, this.scene, this.sharedAssets, !0), this.managers.eventManager?.reset(), this.managers.controlsManager.orbitControls?.reset(), this.managers.controlsManager?.gameControls.forEach((e) => e.reset(!0)); } }, FS = { update: null, begin: null, loopBegin: null, changeBegin: null, change: null, changeComplete: null, timelineChangeComplete: null, loopComplete: null, complete: null, loop: 1, direction: 'normal', autoplay: !0, timelineOffset: 0, rewind: !0 }, wv = { duration: 1e3, delay: 0, endDelay: 0, startOnceDelay: 0, pingPongDelayCorrection: 0, easing: 'easeOutElastic(1, .5)', round: 0 }, lj = [ 'translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'perspective', 'matrix', 'matrix3d' ], su = { CSS: {}, springs: {} }; function ds(e, t, i) { return Math.min(Math.max(e, t), i); } function nh(e, t) { return e.indexOf(t) > -1; } function vf(e, t) { return e.apply(null, t); } var je = { arr: function (e) { return Array.isArray(e); }, obj: function (e) { return nh(Object.prototype.toString.call(e), 'Object'); }, pth: function (e) { return je.obj(e) && e.hasOwnProperty('totalLength'); }, svg: function (e) { return e instanceof SVGElement; }, inp: function (e) { return e instanceof HTMLInputElement; }, dom: function (e) { return !('isNode' in e) && (e.nodeType || je.svg(e)); }, str: function (e) { return typeof e == 'string'; }, fnc: function (e) { return typeof e == 'function'; }, und: function (e) { return typeof e > 'u'; }, hex: function (e) { return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e); }, rgb: function (e) { return /^rgb/.test(e); }, hsl: function (e) { return /^hsl/.test(e); }, col: function (e) { return je.hex(e) || je.rgb(e) || je.hsl(e); }, key: function (e) { return !FS.hasOwnProperty(e) && !wv.hasOwnProperty(e) && e !== 'targets' && e !== 'keyframes'; } }; function kS(e) { var t = /\(([^)]+)\)/.exec(e); return t ? t[1].split(',').map(function (i) { return parseFloat(i); }) : []; } function jS(e, t) { var i = kS(e), r = ds(je.und(i[0]) ? 1 : i[0], 0.1, 100), s = ds(je.und(i[1]) ? 100 : i[1], 0.1, 100), n = ds(je.und(i[2]) ? 10 : i[2], 0.1, 100), a = ds(je.und(i[3]) ? 0 : i[3], 0.1, 100), o = Math.sqrt(s / r), l = n / (2 * Math.sqrt(s * r)), h = l < 1 ? o * Math.sqrt(1 - l * l) : 0, u = 1, c = l < 1 ? (l * o + -a) / h : -a + o; function d(f) { var g = t ? (t * f) / 1e3 : f; return ( l < 1 ? (g = Math.exp(-g * l * o) * (u * Math.cos(h * g) + c * Math.sin(h * g))) : (g = (u + c * g) * Math.exp(-g * o)), f === 0 || f === 1 ? f : 1 - g ); } function p() { var f = su.springs[e]; if (f) return f; for (var g = 1 / 6, m = 0, v = 0; ; ) if (((m += g), d(m) === 1)) { if ((v++, v >= 16)) break; } else v = 0; var y = m * g * 1e3; return (su.springs[e] = y), y; } return t ? d : p; } function hj(e) { return ( e === void 0 && (e = 10), function (t) { return Math.ceil(ds(t, 1e-6, 1) * e) * (1 / e); } ); } var cj = (function () { var e = 11, t = 1 / (e - 1); function i(u, c) { return 1 - 3 * c + 3 * u; } function r(u, c) { return 3 * c - 6 * u; } function s(u) { return 3 * u; } function n(u, c, d) { return ((i(c, d) * u + r(c, d)) * u + s(c)) * u; } function a(u, c, d) { return 3 * i(c, d) * u * u + 2 * r(c, d) * u + s(c); } function o(u, c, d, p, f) { var g, m, v = 0; do { (m = c + (d - c) / 2), (g = n(m, p, f) - u), g > 0 ? (d = m) : (c = m); } while (Math.abs(g) > 1e-7 && ++v < 10); return m; } function l(u, c, d, p) { for (var f = 0; f < 4; ++f) { var g = a(c, d, p); if (g === 0) return c; var m = n(c, d, p) - u; c -= m / g; } return c; } function h(u, c, d, p) { if (!(0 <= u && u <= 1 && 0 <= d && d <= 1)) return; var f = new Float32Array(e); if (u !== c || d !== p) for (var g = 0; g < e; ++g) f[g] = n(g * t, u, d); function m(v) { for (var y = 0, b = 1, x = e - 1; b !== x && f[b] <= v; ++b) y += t; --b; var w = (v - f[b]) / (f[b + 1] - f[b]), A = y + w * t, S = a(A, u, d); return S >= 0.001 ? l(v, A, u, d) : S === 0 ? A : o(v, y, y + t, u, d); } return function (v) { return (u === c && d === p) || v === 0 || v === 1 ? v : n(m(v), c, p); }; } return h; })(), GS = (function () { var e = { linear: function () { return function (r) { return r; }; } }, t = { Sine: function () { return function (r) { return 1 - Math.cos((r * Math.PI) / 2); }; }, Circ: function () { return function (r) { return 1 - Math.sqrt(1 - r * r); }; }, Back: function () { return function (r) { return r * r * (3 * r - 2); }; }, Bounce: function () { return function (r) { for (var s, n = 4; r < ((s = Math.pow(2, --n)) - 1) / 11; ); return 1 / Math.pow(4, 3 - n) - 7.5625 * Math.pow((s * 3 - 2) / 22 - r, 2); }; }, Elastic: function (r, s) { r === void 0 && (r = 1), s === void 0 && (s = 0.5); var n = ds(r, 1, 10), a = ds(s, 0.1, 2); return function (o) { return o === 0 || o === 1 ? o : -n * Math.pow(2, 10 * (o - 1)) * Math.sin(((o - 1 - (a / (Math.PI * 2)) * Math.asin(1 / n)) * (Math.PI * 2)) / a); }; } }, i = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo']; return ( i.forEach(function (r, s) { t[r] = function () { return function (n) { return Math.pow(n, s + 2); }; }; }), Object.keys(t).forEach(function (r) { var s = t[r]; (e['easeIn' + r] = s), (e['easeOut' + r] = function (n, a) { return function (o) { return 1 - s(n, a)(1 - o); }; }), (e['easeInOut' + r] = function (n, a) { return function (o) { return o < 0.5 ? s(n, a)(o * 2) / 2 : 1 - s(n, a)(o * -2 + 2) / 2; }; }); }), e ); })(); function _v(e, t) { if (je.fnc(e)) return e; var i = e.split('(')[0], r = GS[i], s = kS(e); switch (i) { case 'spring': return jS(e, t); case 'cubicBezier': return vf(cj, s); case 'steps': return vf(hj, s); default: return vf(r, s); } } function VS(e) { try { var t = document.querySelectorAll(e); return t; } catch { return; } } function Pu(e, t) { for (var i = e.length, r = arguments.length >= 2 ? arguments[1] : void 0, s = [], n = 0; n < i; n++) if (n in e) { var a = e[n]; t.call(r, a, n, e) && s.push(a); } return s; } function Du(e) { return e.reduce(function (t, i) { return t.concat(je.arr(i) ? Du(i) : i); }, []); } function vb(e) { return je.arr(e) ? e : (je.str(e) && (e = VS(e) || e), e instanceof NodeList || e instanceof HTMLCollection ? [].slice.call(e) : [e]); } function Av(e, t) { return e.some(function (i) { return i === t; }); } function Sv(e) { var t = {}; for (var i in e) t[i] = e[i]; return t; } function tg(e, t) { var i = Sv(e); for (var r in e) i[r] = t.hasOwnProperty(r) ? t[r] : e[r]; return i; } function Lu(e, t) { var i = Sv(e); for (var r in t) i[r] = je.und(e[r]) ? t[r] : e[r]; return i; } function dj(e) { var t = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e); return t ? 'rgba(' + t[1] + ',1)' : e; } function uj(e) { var t = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, i = e.replace(t, function (o, l, h, u) { return l + l + h + h + u + u; }), r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i), s = parseInt(r[1], 16), n = parseInt(r[2], 16), a = parseInt(r[3], 16); return 'rgba(' + s + ',' + n + ',' + a + ',1)'; } function pj(e) { var t = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e), i = parseInt(t[1], 10) / 360, r = parseInt(t[2], 10) / 100, s = parseInt(t[3], 10) / 100, n = t[4] || 1; function a(d, p, f) { return ( f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ? d + (p - d) * 6 * f : f < 1 / 2 ? p : f < 2 / 3 ? d + (p - d) * (2 / 3 - f) * 6 : d ); } var o, l, h; if (r == 0) o = l = h = s; else { var u = s < 0.5 ? s * (1 + r) : s + r - s * r, c = 2 * s - u; (o = a(c, u, i + 1 / 3)), (l = a(c, u, i)), (h = a(c, u, i - 1 / 3)); } return 'rgba(' + o * 255 + ',' + l * 255 + ',' + h * 255 + ',' + n + ')'; } function fj(e) { if (je.rgb(e)) return dj(e); if (je.hex(e)) return uj(e); if (je.hsl(e)) return pj(e); } function Hs(e) { var t = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e); if (t) return t[1]; } function mj(e) { if (nh(e, 'translate') || e === 'perspective') return 'px'; if (nh(e, 'rotate') || nh(e, 'skew')) return 'deg'; } function ig(e, t) { return je.fnc(e) ? e(t.target, t.id, t.total) : e; } function us(e, t) { return e.getAttribute(t); } function Mv(e, t, i) { var r = Hs(t); if (Av([i, 'deg', 'rad', 'turn'], r)) return t; var s = su.CSS[t + i]; if (!je.und(s)) return s; var n = 100, a = document.createElement(e.tagName), o = e.parentNode && e.parentNode !== document ? e.parentNode : document.body; o.appendChild(a), (a.style.position = 'absolute'), (a.style.width = n + i); var l = n / a.offsetWidth; o.removeChild(a); var h = l * parseFloat(t); return (su.CSS[t + i] = h), h; } function HS(e, t, i) { if (t in e.style) { var r = t.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(), s = e.style[t] || getComputedStyle(e).getPropertyValue(r) || '0'; return i ? Mv(e, s, i) : s; } } function Ev(e, t) { if (je.dom(e) && !je.inp(e) && (us(e, t) || (je.svg(e) && e[t]))) return 'attribute'; if (je.dom(e) && Av(lj, t)) return 'transform'; if (je.dom(e) && t !== 'transform' && HS(e, t)) return 'css'; if (e[t] != null) return 'object'; } function WS(e) { if (je.dom(e)) { for (var t = e.style.transform || '', i = /(\w+)\(([^)]*)\)/g, r = new Map(), s; (s = i.exec(t)); ) r.set(s[1], s[2]); return r; } } function gj(e, t, i, r) { var s = nh(t, 'scale') ? 1 : 0 + mj(t), n = WS(e).get(t) || s; return i && (i.transforms.list.set(t, n), (i.transforms.last = t)), r ? Mv(e, n, r) : n; } function Cv(e, t, i, r) { switch (Ev(e, t)) { case 'transform': return gj(e, t, r, i); case 'css': return HS(e, t, i); case 'attribute': return us(e, t); default: return e[t] || 0; } } function Tv(e, t) { var i = /^(\*=|\+=|-=)/.exec(e); if (!i) return e; var r = Hs(e) || 0, s = parseFloat(t), n = parseFloat(e.replace(i[0], '')); switch (i[0][0]) { case '+': return s + n + r; case '-': return s - n + r; case '*': return s * n + r; } } function XS(e, t) { if (je.col(e)) return fj(e); if (/\s/g.test(e)) return e; var i = Hs(e), r = i ? e.substr(0, e.length - i.length) : e; return t ? r + t : r; } function Pv(e, t) { return Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)); } function vj(e) { return Math.PI * 2 * us(e, 'r'); } function yj(e) { return us(e, 'width') * 2 + us(e, 'height') * 2; } function xj(e) { return Pv({ x: us(e, 'x1'), y: us(e, 'y1') }, { x: us(e, 'x2'), y: us(e, 'y2') }); } function qS(e) { for (var t = e.points, i = 0, r, s = 0; s < t.numberOfItems; s++) { var n = t.getItem(s); s > 0 && (i += Pv(r, n)), (r = n); } return i; } function bj(e) { var t = e.points; return qS(e) + Pv(t.getItem(t.numberOfItems - 1), t.getItem(0)); } function YS(e) { if (e.getTotalLength) return e.getTotalLength(); switch (e.tagName.toLowerCase()) { case 'circle': return vj(e); case 'rect': return yj(e); case 'line': return xj(e); case 'polyline': return qS(e); case 'polygon': return bj(e); } } function wj(e) { var t = YS(e); return e.setAttribute('stroke-dasharray', t), t; } function _j(e) { for (var t = e.parentNode; je.svg(t) && je.svg(t.parentNode); ) t = t.parentNode; return t; } function QS(e, t) { var i = t || {}, r = i.el || _j(e), s = r.getBoundingClientRect(), n = us(r, 'viewBox'), a = s.width, o = s.height, l = i.viewBox || (n ? n.split(' ') : [0, 0, a, o]); return { el: r, viewBox: l, x: l[0] / 1, y: l[1] / 1, w: a / l[2], h: o / l[3] }; } function Aj(e, t) { var i = je.str(e) ? VS(e)[0] : e, r = t || 100; return function (s) { return { property: s, el: i, svg: QS(i), totalLength: YS(i) * (r / 100) }; }; } function Sj(e, t) { function i(o) { o === void 0 && (o = 0); var l = t + o >= 1 ? t + o : 0; return e.el.getPointAtLength(l); } var r = QS(e.el, e.svg), s = i(), n = i(-1), a = i(1); switch (e.property) { case 'x': return (s.x - r.x) * r.w; case 'y': return (s.y - r.y) * r.h; case 'angle': return (Math.atan2(a.y - n.y, a.x - n.x) * 180) / Math.PI; } } function yb(e, t) { var i = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g, r = XS(je.pth(e) ? e.totalLength : e, t) + ''; return { original: r, numbers: r.match(i) ? r.match(i).map(Number) : [0], strings: je.str(e) || t ? r.split(i) : [] }; } function ZS(e) { var t = e ? Du(je.arr(e) ? e.map(vb) : vb(e)) : []; return Pu(t, function (i, r, s) { return s.indexOf(i) === r; }); } function KS(e) { var t = ZS(e); return t.map(function (i, r) { return { target: i, id: r, total: t.length, transforms: { list: WS(i) } }; }); } function Mj(e, t) { var i = Sv(t); if ((/^spring/.test(i.easing) && (i.duration = jS(i.easing)), je.arr(e))) { var r = e.length, s = r === 2 && !je.obj(e[0]); s ? (e = { value: e }) : je.fnc(t.duration) || (i.duration = t.duration / r); } var n = je.arr(e) ? e : [e]; return n .map(function (a, o) { var l = je.obj(a) && !je.pth(a) ? a : { value: a }; return je.und(l.delay) && (l.delay = o ? 0 : t.delay), je.und(l.endDelay) && (l.endDelay = o === n.length - 1 ? t.endDelay : 0), l; }) .map(function (a) { return Lu(a, i); }); } function Ej(e) { for ( var t = Pu( Du( e.map(function (n) { return Object.keys(n); }) ), function (n) { return je.key(n); } ).reduce(function (n, a) { return n.indexOf(a) < 0 && n.push(a), n; }, []), i = {}, r = function (n) { var a = t[n]; i[a] = e.map(function (o) { var l = {}; for (var h in o) je.key(h) ? h == a && (l.value = o[h]) : (l[h] = o[h]); return l; }); }, s = 0; s < t.length; s++ ) r(s); return i; } function Cj(e, t) { var i = [], r = t.keyframes; r && (t = Lu(Ej(r), t)); for (var s in t) je.key(s) && i.push({ name: s, tweens: Mj(t[s], e) }); return i; } function Tj(e, t) { var i = {}; for (var r in e) { var s = ig(e[r], t); je.arr(s) && ((s = s.map(function (n) { return ig(n, t); })), s.length === 1 && (s = s[0])), (i[r] = s); } return (i.duration = parseFloat(i.duration)), (i.delay = parseFloat(i.delay)), i; } function Pj(e, t) { var i; return e.tweens.map(function (r) { var s = Tj(r, t), n = s.value, a = je.arr(n) ? n[1] : n, o = Hs(a), l = Cv(t.target, e.name, o, t), h = i ? i.to.original : l, u = je.arr(n) ? n[0] : h, c = Hs(u) || Hs(l), d = o || c; return ( je.und(a) && (a = h), (s.from = yb(u, d)), (s.to = yb(Tv(a, u), d)), (s.start = i ? i.end : 0), (s.end = s.start + s.delay + s.duration + s.endDelay), (s.easing = _v(s.easing, s.duration)), (s.isPath = je.pth(n)), (s.isColor = je.col(s.from.original)), s.isColor && (s.round = 1), (i = s), s ); }); } var JS = { css: function (e, t, i) { return (e.style[t] = i); }, attribute: function (e, t, i) { return e.setAttribute(t, i); }, object: function (e, t, i) { return (e[t] = i); }, transform: function (e, t, i, r, s) { if ((r.list.set(t, i), t === r.last || s)) { var n = ''; r.list.forEach(function (a, o) { n += o + '(' + a + ') '; }), (e.style.transform = n); } } }; function $S(e, t) { var i = KS(e); i.forEach(function (r) { for (var s in t) { var n = ig(t[s], r), a = r.target, o = Hs(n), l = Cv(a, s, o, r), h = o || Hs(l), u = Tv(XS(n, h), l), c = Ev(a, s); JS[c](a, s, u, r.transforms, !0); } }); } function Dj(e, t) { var i = Ev(e.target, t.name); if (i) { var r = Pj(t, e), s = r[r.length - 1]; return { type: i, property: t.name, animatable: e, tweens: r, duration: s.end, delay: r[0].delay, endDelay: s.endDelay }; } } function Lj(e, t) { return Pu( Du( e.map(function (i) { return t.map(function (r) { return Dj(i, r); }); }) ), function (i) { return !je.und(i); } ); } function e2(e, t) { var i = e.length, r = function (n) { return n.timelineOffset ? n.timelineOffset : 0; }, s = {}; return ( (s.duration = i ? Math.max.apply( Math, e.map(function (n) { let a = n.startOnceDelay ?? 0, o = n.pingPongDelayCorrection ?? 0; return r(n) + a + o + n.duration * (n.loop ?? 1); }) ) : t.duration), (s.delay = i ? Math.min.apply( Math, e.map(function (n) { let a = n.startOnceDelay ?? 0, o = n.pingPongDelayCorrection ?? 0; return r(n) + a + o + n.delay; }) ) : t.delay), (s.endDelay = i ? s.duration - Math.max.apply( Math, e.map(function (n) { let a = n.startOnceDelay ?? 0, o = n.pingPongDelayCorrection ?? 0; return r(n) + a + o + n.duration * (n.loop ?? 1) - n.endDelay; }) ) : t.endDelay), s ); } var xb = 0; function Oj(e) { var t = tg(FS, e), i = tg(wv, e), r = Cj(i, e), s = KS(e.targets), n = Lj(s, r), a = e2(n, i), o = xb; return ( xb++, Lu(t, { id: o, children: [], animatables: s, animations: n, duration: a.duration, delay: a.delay, endDelay: a.endDelay, startOnceDelay: i.startOnceDelay, pingPongDelayCorrection: i.pingPongDelayCorrection }) ); } var Sr = [], bb = [], hd, Ij = (function () { function e() { hd = requestAnimationFrame(t); } function t(i) { var r = Sr.length; if (r) { for (var s = 0; s < r; ) { var n = Sr[s]; n.paused ? (Sr.splice(s, 1), (r -= 1)) : (n.tick(i), s++); } e(); } else hd = cancelAnimationFrame(hd); } return e; })(); function Rj(e) { document.hidden ? (Sr.forEach(function (t) { return t.pause(e.timeStamp); }), (bb = Sr.slice(0)), (Vt.running = Sr = [])) : bb.forEach(function (t) { return t.play(e.timeStamp); }); } typeof document < 'u' && document.addEventListener('visibilitychange', Rj); function Vt(e) { e === void 0 && (e = {}); var t = 0, i = 0, r = 0, s, n, a = 0, o = null; function l(x) { var w = window.Promise && new Promise(function (A) { return (o = A); }); return (x.finished = w), w; } var h = Oj(e), u = l(h); function c() { var x = h.direction; x !== 'alternate' && (h.direction = x !== 'normal' ? 'normal' : 'reverse'), (h.reversed = !h.reversed), n.forEach(function (w) { return (w.reversed = h.reversed); }); } function d(x) { return h.reversed ? h.duration - x : x; } function p() { (t = 0), (i = d(h.currentTime) * (1 / Vt.speed)); } function f(x, w) { w && (h.reversed ? w.seek(w.duration * w.loop - (x - w.timelineOffset - w.pingPongDelayCorrection)) : w.seek(x - w.timelineOffset - w.startOnceDelay - w.pingPongDelayCorrection)); } function g(x) { if (h.reversed) for (var w = a; w--; ) f(x, n[w]); else for (var A = 0; A < a; A++) f(x, n[A]); } function m(x) { var w = 0, A = h.animations, S = A.length; for (h.reversePlayback === !0 && h.rewind === !1 && (x = h.duration + h.delay - h.endDelay - x); w < S; ) { var _ = A[w], M = _.animatable, C = _.tweens, T = C.length - 1, P = C[T]; T && (P = Pu(C, function (ee) { return x < ee.end; })[0] || P); for ( var L = ds(x - P.start - P.delay, 0, P.duration) / P.duration, D = isNaN(L) ? 1 : P.easing(L), k = P.to.strings, W = P.round, X = [], z = P.to.numbers.length, j = void 0, U = 0; U < z; U++ ) { var N = void 0; if (h.reversePlayback === !0 && h.rewind === !1) var H = P.to.numbers[U], B = P.from.numbers[U] || 0; else var B = P.to.numbers[U], H = P.from.numbers[U] || 0; P.isPath ? (N = Sj(P.value, D * B)) : (N = H + D * (B - H)), W && ((P.isColor && U > 2) || (N = Math.round(N * W) / W)), X.push(N); } var Q = k.length; if (!Q) j = X[0]; else { j = k[0]; for (var Y = 0; Y < Q; Y++) { var F = k[Y], se = k[Y + 1], V = X[Y]; isNaN(V) || (se ? (j += V + se) : (j += V + ' ')); } } JS[_.type](M.target, _.property, j, M.transforms), (_.currentValue = j), w++; } } function v(x) { h[x] && !h.passThrough && h[x](h); } function y() { h.remaining && h.remaining !== !0 && h.remaining--; } function b(x) { var w = h.duration, A = h.delay, S = w - h.endDelay, _ = d(x); if ( ((h.progress = ds((_ / w) * 100, 0, 100)), (h.reversePlayback = _ < h.currentTime), a && g(_), !h.began && h.currentTime >= 0 && ((h.began = !0), v('begin')), !h.loopBegan && h.currentTime > 0 && ((h.loopBegan = !0), v('loopBegin')), (h.reversed || _ >= 0) && _ <= A && h.currentTime !== 0 && (m(0), v('change')), ((_ >= S && h.currentTime !== w) || !w) && (m(w), v('change')), _ > A && _ < S ? (h.changeBegan || ((h.changeBegan = !0), (h.changeCompleted = !1), v('changeBegin')), m(_), v('change')) : h.changeBegan ? ((h.changeCompleted = !0), (h.changeBegan = !1), v('change'), a && v('timelineChangeComplete')) : h.began && _ > S && v('changeComplete'), (h.currentTime = ds(_, 0, w)), h.began && v('update'), x >= w) ) if ((y(), !h.remaining)) (h.paused = !0), h.completed || ((h.completed = !0), v('loopComplete'), v('complete'), !h.passThrough && 'Promise' in window && (o(), (u = l(h)))); else { a ? (t += h.duration / Vt.speed) : (t += h.duration); for (let M of n) M.setStartTime(0), (M.remaining = M.loop); v('loopComplete'), (h.loopBegan = !1), h.direction === 'alternate' && c(); } } return ( (h.reset = function () { var x = h.direction; (h.passThrough = !1), (h.currentTime = 0), (h.progress = 0), (h.paused = !0), (h.began = !1), (h.loopBegan = !1), (h.changeBegan = !1), (h.completed = !1), (h.changeCompleted = !1), (h.reversePlayback = !1), (h.reversed = x === 'reverse'), (h.remaining = h.loop), (n = h.children), (a = n.length); for (var w = a; w--; ) h.children[w].reset(); ((h.reversed && h.loop !== !0) || (x === 'alternate' && h.loop === 1)) && h.remaining++, m(h.reversed ? h.duration : 0); }), (h.setStartTime = function (x) { t = x; }), (h.set = function (x, w) { return $S(x, w), h; }), (h.tick = function (x) { (r = x), t || (t = r), b((r + (i - t)) * Vt.speed); }), (h.seek = function (x) { b(x - t); }), (h.pause = function (x) { (h.paused = !0), a && (s = x ?? performance.now()); }), (h.play = function (x) { !h.paused || (h.completed && h.reset(), (h.paused = !1), Sr.push(h), a && s !== void 0 && (t += (x ?? performance.now()) - s), hd || Ij()); }), (h.reverse = function () { c(), (h.completed = !h.reversed), p(); }), (h.restart = function () { h.reset(), h.play(); }), h.reset(), h.autoplay && h.play(), h ); } function wb(e, t) { for (var i = t.length; i--; ) Av(e, t[i].animatable.target) && t.splice(i, 1); } function Bj(e) { for (var t = ZS(e), i = Sr.length; i--; ) { var r = Sr[i], s = r.animations, n = r.children; wb(t, s); for (var a = n.length; a--; ) { var o = n[a], l = o.animations; wb(t, l), !l.length && !o.children.length && n.splice(a, 1); } !s.length && !n.length && r.pause(); } } function zj(e, t) { t === void 0 && (t = {}); var i = t.direction || 'normal', r = t.easing ? _v(t.easing) : null, s = t.grid, n = t.axis, a = t.from || 0, o = a === 'first', l = a === 'center', h = a === 'last', u = je.arr(e), c = parseFloat(u ? e[0] : e), d = u ? parseFloat(e[1]) : 0, p = Hs(u ? e[1] : e) || 0, f = t.start || 0 + (u ? c : 0), g = [], m = 0; return function (v, y, b) { if ((o && (a = 0), l && (a = (b - 1) / 2), h && (a = b - 1), !g.length)) { for (var x = 0; x < b; x++) { if (!s) g.push(Math.abs(a - x)); else { var w = l ? (s[0] - 1) / 2 : a % s[0], A = l ? (s[1] - 1) / 2 : Math.floor(a / s[0]), S = x % s[0], _ = Math.floor(x / s[0]), M = w - S, C = A - _, T = Math.sqrt(M * M + C * C); n === 'x' && (T = -M), n === 'y' && (T = -C), g.push(T); } m = Math.max.apply(Math, g); } r && (g = g.map(function (L) { return r(L / m) * m; })), i === 'reverse' && (g = g.map(function (L) { return n ? (L < 0 ? L * -1 : -L) : Math.abs(m - L); })); } var P = u ? (d - c) / m : c; return f + P * (Math.round(g[y] * 100) / 100) + p; }; } function Nj(e) { e === void 0 && (e = {}); var t = Vt(e); return ( (t.duration = 0), (t.add = function (i, r) { var s = Sr.indexOf(t), n = t.children; s > -1 && Sr.splice(s, 1); function a(d) { d.passThrough = !0; } for (var o = 0; o < n.length; o++) a(n[o]); var l = Lu(i, tg(wv, e)); l.targets = l.targets || e.targets; var h = t.duration; (l.autoplay = !1), (l.timelineOffset = je.und(r) ? h : Tv(r, h)), a(t); var u = Vt(l); a(u), n.push(u); var c = e2(n, e); return ( (t.delay = c.delay), (t.endDelay = c.endDelay), (t.duration = c.duration), u.loop === !0 && (t.duration = 1 / 0), t.seek(0), t.reset(), t.autoplay && t.play(), t ); }), t ); } Vt.version = '3.2.0'; Vt.speed = 1; Vt.running = Sr; Vt.remove = Bj; Vt.get = Cv; Vt.set = $S; Vt.convertPx = Mv; Vt.path = Aj; Vt.setDashoffset = wj; Vt.stagger = zj; Vt.timeline = Nj; Vt.easing = _v; Vt.penner = GS; Vt.random = function (e, t) { return Math.floor(Math.random() * (t - e + 1)) + e; }; var Uj = Vt, _b = new E(), Ab = new E(), Sb = new ct(); function Fj(e, t, i, r) { if (r === 0) return i.copy(e); if (r === 1) return i.copy(t); let s = e.w * t.w + e.x * t.x + e.y * t.y + e.z * t.z; if (s >= 1) return i.copy(e); let n = 1 - s * s; if (n <= Number.EPSILON) { let u = 1 - r; return (i.w = u * e.w + r * t.w), (i.x = u * e.x + r * t.x), (i.y = u * e.y + r * t.y), (i.z = u * e.z + r * t.z), i.normalize(), i; } let a = Math.sqrt(n), o = Math.atan2(a, s), l = Math.sin((1 - r) * o) / a, h = Math.sin(r * o) / a; return (i.w = e.w * l + t.w * h), (i.x = e.x * l + t.x * h), (i.y = e.y * l + t.y * h), (i.z = e.z * l + t.z * h), i; } function Sa(e, t, i, r, s) { let n = i[e] ? i[e] : void 0, a = r[e]; if (a == null) return; let o = n ?? t[e], l = a; if (o !== l) return { update: (h) => { let u = it.lerp(o, l, h); s ? (t[e] = Math.trunc(u)) : (t[e] = u); }, start: () => { t[e] = o; }, end: () => { t[e] = l; } }; } function t2(e, t, i, r, s) { let n = i[e] ? i[e] : void 0, a = r[e]; if (!a) return; let o = t[e], l = [...(n ?? o)], h = [...a]; if (!(l.length !== h.length || jg(l, h))) return { update: (u) => { l.forEach((c, d) => { let p = it.lerp(c, h[d], u); t[e][d] = s ? Math.trunc(p) : p; }); }, start: () => { Object.assign(t[e], l); }, end: () => { Object.assign(t[e], h); } }; } function Mb(e, t, i, r) { let s = i[e] ? i[e] : void 0, n = r[e]; if (!n) return; let a = t[e], o = s ? new E().fromArray(s) : a.clone(), l = new E().fromArray(n); if (!o.equals(l)) return { update: (h) => { a.lerpVectors(o, l, h); }, start: () => { a.copy(o); }, end: () => { a.copy(l); } }; } function kj(e, t, i, r) { let s = i[e] ? i[e] : void 0, n = r[e]; if (!n) return; let a = t[e], o = s ? new ve().fromArray(s) : a.clone(), l = new E(), h = new ct(), u = new E(); o.decompose(l, h, u); let c = new ve().fromArray(n), d = new E(), p = new ct(), f = new E(); if ((c.decompose(d, p, f), !o.equals(c))) return { update: (g) => { Sb.slerpQuaternions(h, p, g), _b.lerpVectors(l, d, g), Ab.lerpVectors(u, f, g), a.compose(_b, Sb, Ab); }, start: () => { a.compose(l, h, u); }, end: () => { a.compose(d, p, f); } }; } function jj(e, t, i, r, s) { let n = i[e] ? i[e] : void 0, a = r[e]; if (!a) return; let o = t[e], l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(), h = typeof a == 'string' ? s.getColor(a).clone() : new Ge().setRGB(a.r, a.g, a.b); if (l.equals(h)) return; let u = o.clone(); return ( (t[e] = u), { update: (c) => { u.lerpColors(l, h, c); }, start: () => { u.copy(l); }, end: () => { u.copy(h); } } ); } function Nn(e, t, i, r) { if (typeof t[e] == 'number') return Sa(e, t, i ?? {}, r); if (Array.isArray(t[e])) return t2(e, t, i ?? {}, r); } function Gj(e, t, i) { let r = [], s = e.cameraType === 'OrthographicCamera' ? t.orthographic?.zoom : t.perspective?.zoom, n = e.cameraType === 'OrthographicCamera' ? i.orthographic?.zoom : i.perspective?.zoom; if (n !== void 0) { let a = s ?? e.zoom, o = n; a !== o && r.push({ update: (l) => { (e.zoom = it.lerp(a, o, l)), e.updateProjectionMatrix(); }, start: () => { (e.zoom = a), e.updateProjectionMatrix(); }, end: () => { (e.zoom = o), e.updateProjectionMatrix(); } }); } if (i.targetOffset !== void 0) { let a = Sa('targetOffset', e, t, i); a && r.push(a); } return r; } function Vj(e, t, i, r) { if (i.scaleBaked === void 0) return; let s = t.scaleBaked ?? e.data.geometry.scaleBaked, n = i.scaleBaked; if (ma.isEqual(s, n)) return; let a = []; return ( a.push({ update: (o) => { e.updateGeometryInteractions({ scaleBaked: [it.lerp(s[0], n[0], o), it.lerp(s[1], n[1], o), it.lerp(s[2], n[2], o)] }, r), e.invalidateDownstreamBooleanData(); }, start: () => { e.updateGeometryInteractions({ scaleBaked: s }, r), e.invalidateDownstreamBooleanData(); }, end: () => { e.updateGeometryInteractions({ scaleBaked: n }, r), e.invalidateDownstreamBooleanData(); } }), a ); } function Hj(e, t, i) { if (!i.extrusion) return; let r = e.extrusion, s = t.extrusion ?? {}, n = i.extrusion, a = []; return ( eA.forEach((o) => { let l = Nn(o, r, s, n); l && a.push(l); }), a ); } function Wj(e, t, i, r) { let s = []; if (!('geometry' in i)) return s; let n = e.geometry.userData.parameters, a = 'geometry' in t ? t.geometry : {}, o = i.geometry; if (e instanceof Sh) { let l = Vj(e, a, o, r); l && s.push(...l); } else { let l = {}; if ( (Object.assign(l, gh(n, F1)), F1.forEach((h) => { let u = Nn(h, l, a, o); u && s.push(u); }), e instanceof gv) ) { Object.assign(l, { extrusion: { ...n.extrusion } }); let h = Hj(l, a, o); h && s.push(...h); } s.length && s.push({ update: (h) => { e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded(); }, start: (h) => { e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded(); }, end: (h) => { e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded(); } }); } return s; } function Xj(e, t, i, r) { let s = []; if (i.intensity !== void 0) { let n = Sa('intensity', e, t, i); n && s.push(n); } if (i.color !== void 0) { let n = jj('color', e, t, i, r); n && s.push(n); } return s; } function qj(e, t, i, r) { let s = []; if (Array.isArray(e.material)) { if (!('materials' in i && i.materials)) return s; let n = 'materials' in t && t.materials ? t.materials : [], a = i.materials; e.material.forEach((o, l) => { if (!a[l]) return; let h = n[l] ?? {}, u = a[l]; typeof h == 'string' || typeof u == 'string' || s.push(...Eb(o, h, u, r)); }); } else { if (!('material' in i && i.material)) return s; let n = 'material' in t && t.material ? t.material : {}, a = i.material; if (typeof n == 'string' || typeof a == 'string') return s; s.push(...Eb(e.material, n, a, r)); } return s; } function Eb(e, t, i, r) { let s = [], n = Jd(i, r) || (!!t.layers && Jd(t, r)); s.push(iG(e, n)); for (let a of e.layers) { let o = t.layers?.data(a.uuid), l = i.layers.data(a.uuid); if (!l || !(a.visible ?? !0) || !(l.visible ?? !0)) continue; let h = a.getNames().filter((u) => !K_.some((c) => u.includes(c))); for (let u of h) try { let c = a.getValue(u), d; if (u === 'colors') d = eG(a, o, l, u); else if (Array.isArray(c)) u === 'steps' && (d = $j(a, o, l, u)); else if (typeof c == 'number') d = Yj(a, o, l, u); else { if (typeof c == 'boolean') continue; c instanceof G ? (d = Qj(a, o, l, u)) : c instanceof E ? (d = Zj(a, o, l, u)) : c instanceof ji ? (d = Jj(a, o, l, u, r)) : c instanceof Ge ? (d = Kj(a, o, l, u, r)) : 'isTexture' in c && (d = tG(a, o, l, u)); } d && (Array.isArray(d) ? s.push(...d) : s.push(d)); } catch (c) { console.error(`lerpMaterial: unexpected material layer for ${u}`, c); } } return s; } function Yj(e, t, i, r) { if (!e.hasValue(r) || !(r in i)) return; let s = t ? t[r] : e.getValue(r), n = i[r]; if (s !== n) return { update: (a) => { e.setValue(r, it.lerp(s, n, a)); }, start: () => { e.setValue(r, s); }, end: () => { e.setValue(r, n); } }; } function Qj(e, t, i, r) { if (!e.hasValue(r) || !(r in i)) return; let s = e.getValue(r), n = t ? new G().fromArray(t[r]) : s.clone(), a = new G().fromArray(i[r]); if (!n.equals(a)) return { update: (o) => { s.lerpVectors(n, a, o); }, start: () => { s.copy(n); }, end: () => { s.copy(a); } }; } function Zj(e, t, i, r) { if (!e.hasValue(r) || !(r in i)) return; let s = e.getValue(r), n = t ? new E().fromArray(t[r]) : s.clone(), a = new E().fromArray(i[r]); if (!n.equals(a)) return { update: (o) => { s.lerpVectors(n, a, o); }, start: () => { s.copy(n); }, end: () => { s.copy(a); } }; } function Kj(e, t, i, r, s) { if (!e.hasValue(r) || !(r in i)) return; let n = t ? t[r] : void 0, a = i[r], o = e.getValue(r), l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(), h = typeof a == 'string' ? s.getColor(a).clone() : new Ge().setRGB(a.r, a.g, a.b); if (l.equals(h)) return; let u = o.clone(); return ( e.setValue(r, u), { update: (c) => { u.lerpColors(l, h, c); }, start: () => { u.copy(l); }, end: () => { u.copy(h); } } ); } function Jj(e, t, i, r, s) { if (!e.hasValue(r) || !(r in i)) return; let n = t ? t[r] : void 0, a = i[r], o = e.getValue(r), l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(), h = typeof a == 'string' ? s.getColor(a).clone() : new ji(a.r, a.g, a.b, a.a); if (l.equals(h)) return; let u = o.clone(); return ( e.setValue(r, u), { update: (c) => { u.lerpColors(l, h, c); }, start: () => { u.copy(l); }, end: () => { u.copy(h); } } ); } function $j(e, t, i, r = 'steps') { if (!e.hasValue(r) || !(r in i)) return; let s = [], n = e.getValue(r), a = t ? t[r] : n, o = i[r]; for (let l = 0; l < n.length; ++l) { let h = a[l], u = o[l]; h !== u && s.push({ update: (c) => { n[l] = it.lerp(h, u, c); }, start: () => { n[l] = h; }, end: () => { n[l] = u; } }); } return s.length ? s : void 0; } function eG(e, t, i, r = 'colors') { if (!e.hasValue(r) || !(r in i)) return; let s = [], n = e.getValue(r), a = t ? t[r] : n.map((l) => l.toArray()), o = i[r]; for (let l = 0; l < n.length; ++l) { let h = [...a[l]], u = [...o[l]]; Id.isEqual(h, u) || s.push({ update: (c) => { n[l].fromArray(Id.lerp(h, u, c)); }, start: () => { n[l].fromArray(h); }, end: () => { n[l].fromArray(u); } }); } return s.length ? s : void 0; } function tG(e, t, i, r = 'texture') { if (!e.hasValue(r) || !(r in i)) return; let s = e.getNode('mat'); if (!s) return; let n = t ? t[r] : s, a = i[r], o = [...n.repeat], l = [...n.offset], h = [...a.repeat], u = [...a.offset]; if (!mo.isEqual(o, h) || !mo.isEqual(l, u)) return { update: (c) => { (s.repeat = mo.lerp(o, h, c)), (s.offset = mo.lerp(l, u, c)), s.updateMatrix(); }, start: () => { (s.repeat = [...o]), (s.offset = [...l]), s.updateMatrix(); }, end: () => { (s.repeat = [...h]), (s.offset = [...u]), s.updateMatrix(); } }; } function iG(e, t) { return { update: () => { e.transparent = t; } }; } var yf = new E(), Cb = new _i(); function rG(e, t, i, r) { let s = [], n, a, o, l, h, u, c = { slide: (t.pathSnapping ?? e.dataPatched.pathSnapping).slide, offset: (t.pathSnapping ?? e.dataPatched.pathSnapping).offset }; if ( ((h = Sa('slide', c, t.pathSnapping ?? e.dataPatched.pathSnapping, i.pathSnapping ?? e.dataPatched.pathSnapping)), h && s.push(h), (u = Sa('offset', c, t.pathSnapping ?? e.dataPatched.pathSnapping, i.pathSnapping ?? e.dataPatched.pathSnapping)), u && s.push(u), !h && !u && ((n = Mb('position', e, t, i)), n && s.push(n), (a = Mb('scale', e, t, i)), a && s.push(a), (o = sG(e, t, i, r)), o && s.push(o), (l = kj('hiddenMatrix', e, t, i)), l && s.push(l)), n || a || o || l || h || u) ) { let d = () => { e.updateMatrix(), e.hasNonUniformScale && (e.updateMatrixWorld(), e.updateMatrixWorldSVD()), e.parent?.matrixWorldFusedFalse && (e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse, e.matrix), (e.matrixWorldNeedsUpdate = !1)), js(e) && Sn(e.parent) && e.invalidateDownstreamBooleanData(!0), e.updatePathSnapping(Object.assign({}, t.pathSnapping, c)); }; s.push({ update: d, start: d, end: d }); } return s; } function sG(e, t, i, r) { let s = t?.rotation ? t.rotation : void 0, n = i.rotation; if (!n) return; let a = s ? new E().fromArray(s) : new E().setFromEuler(e.rotation), o = new E().fromArray(n); if (a.equals(o)) return; let l = yf.subVectors(o, a); if (r && l.toArray().every((h) => Math.abs(h) < 2 * Math.PI)) { let h = new ct().setFromEuler(Cb.setFromVector3(a)), u = new ct().setFromEuler(Cb.setFromVector3(o)); return { update: (c) => { Fj(h, u, e.quaternion, c); }, start: () => { e.rotation.setFromVector3(a); }, end: () => { e.rotation.setFromVector3(o); } }; } else return { update: (h) => { yf.lerpVectors(a, o, h), e.rotation.setFromVector3(yf); }, start: () => { e.rotation.setFromVector3(a); }, end: () => { e.rotation.setFromVector3(o); } }; } function nG(e, t, i) { let r = []; if (!('cloner' in i) || !e.cloner) return r; let s = e.cloner, n = 'cloner' in t ? t.cloner : {}, a = i.cloner; W_.forEach((d) => { let p; d === 'count' ? (p = Sa('count', s.parameters, n, a, !0)) : (p = Nn(d, s.parameters, n ?? {}, a)), p && r.push(p); }); let o = aG(s, n, a); o?.length && r.push(...o); let l = oG(s, n, a); l?.length && r.push(...l); let h = lG(s, n, a); h?.length && r.push(...h); let u = hG(s, n, a); u?.length && r.push(...u); let c = cG(s, n, a); return ( c?.length && r.push(...c), r.length && r.push({ update: () => { s.update(); } }), r ); } function aG(e, t, i) { if (e.parameters.type !== 'radial') return; let r = t.radial, s = i.radial; if (!s) return; let n = e.parameters.radial, a = []; return ( X_.forEach((o) => { let l = Nn(o, n, r ?? {}, s); l && a.push(l); }), a ); } function oG(e, t, i) { if (e.parameters.type !== 'linear') return; let r = t.linear, s = i.linear; if (!s) return; let n = [], a = e.parameters.linear; return ( q_.forEach((o) => { let l = Nn(o, a, r ?? {}, s); l && n.push(l); }), n ); } function lG(e, t, i) { if (e.parameters.type !== 'grid') return; let r = t.grid, s = i.grid; if (!s) return; let n = [], a = e.parameters.grid; return ( Y_.forEach((o) => { let l; o === 'count' ? (l = t2(o, a, r ?? {}, s, !0)) : (l = Nn(o, a, r ?? {}, s)), l && n.push(l); }), n ); } function hG(e, t, i) { if (e.parameters.type !== 'toObject') return; let r = t.toObject, s = i.toObject; if (!s) return; let n = [], a = e.parameters.toObject; return ( Q_.forEach((o) => { let l; o === 'count' ? (l = Sa(o, a, r ?? {}, s, !0)) : (l = Nn(o, a, r ?? {}, s)), l && n.push(l); }), n ); } function cG(e, t, i) { if (!e.parameters.randomness) return; let r = t.randomnessObject, s = i.randomnessObject; if (!s) return; let n = [], a = e.parameters.randomnessObject; return ( Z_.forEach((o) => { let l = Nn(o, a, r ?? {}, s); l && n.push(l); }), n ); } function Tb(e, t, i, r, s) { let n = []; return ( e.data.visible && n.push(...rG(e, t, i, s)), e.data.visible && n.push(...nG(e, t, i)), js(e) ? (e instanceof Cr && e.data.visible && n.push(...Wj(e, t, i, r)), e.data.visible && n.push(...qj(e, t, i, r))) : p8(e) ? e.data.visible && n.push(...Xj(e, t, i, r)) : u8(e) && n.push(...Gj(e, t, i)), n.length ? { update: (a) => { n.forEach((o) => o.update(a)); }, start: (a) => { n.forEach((o) => o.start?.(a)); }, end: (a) => { n.forEach((o) => o.end?.(a)); } } : void 0 ); } var Pb = new E(); function i2(e, t, i, r = !1) { let s = []; t.traverseObject((n) => { if ( (r && (n.rigidBody?.setTranslation(n.position0, !0), n.rigidBody?.setRotation(n.rotation0, !0), n.rigidBody?.setLinvel(Pb, !0), n.rigidBody?.setAngvel(Pb, !0)), !Ct.is(n)) ) return; let a = n.uuid, o = n.data; if ((delete n.states, !o.states)) return; let l = !1; s.some((h) => e.objects.isDescendantOf(a, h)) ? (l = !0) : o.physics?.fusedBody === !0 && o.physics.rigidBody === 'dynamic' && s.push(a), (n.data = o), (n.currentState = null), (n.reversibleToState = null), (n.currentTransitionEvent = null); for (let h of o.states) (e.environment.usePhysics === !0 && o.physics && (o.physics.rigidBody === 'dynamic' || l) && (h.data.position !== void 0 || h.data.rotation !== void 0 || h.data.hiddenMatrix !== void 0)) || (n.states || (n.states = {}), (n.states[h.id] = oa.patch(o, h.data))); dG(t, n, null, i, o.events.find((h) => h.data.type === 'Follow' || h.data.type === 'LookAt') !== void 0); }); } function dG(e, t, i, r, s = !1) { t instanceof Cr && t.removeInteractionGeometry(), t.changeSelectedState(i, { scene: e, shared: r }, s), t instanceof Cr && t.updateGeometryGroupsIfNeeded(); } function uG(e) { let t; switch (e.easing) { case 0: t = 'cubicBezier( 0, 0, 1, 1 )'; break; case 1: t = 'cubicBezier( .25, .1, .25, 1 )'; break; case 2: t = 'cubicBezier( .42, 0, 1, 1 )'; break; case 3: t = 'cubicBezier( 0, 0, .58, 1 )'; break; case 4: t = 'cubicBezier( .42, 0, .58, 1 )'; break; case 5: let { control1: i, control2: r } = e; t = `cubicBezier( ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]} )`; break; case 6: let { mass: s, stiffness: n, damping: a, velocity: o } = e; t = `spring( ${s}, ${n}, ${a}, ${o} )`; break; default: t = 'linear'; } return { duration: e.duration, easing: t }; } function r2(e) { let t = { delay: 0, loop: e.repeat === -1 ? !0 : e.repeat + 1 }; if (e.repeat === 0) (t.direction = 'normal'), (t.rewind = e.direction === 'pingpong-rewind'); else switch (e.direction) { case 'pingpong': (t.direction = 'alternate'), (t.rewind = !1); break; case 'pingpong-rewind': (t.direction = 'alternate'), (t.rewind = !0); break; default: (t.direction = 'normal'), (t.rewind = !1); break; } switch (((t.delay = 0), (t.endDelay = 0), (t.startOnceDelay = 0), (t.pingPongDelayCorrection = 0), e.delayDirection)) { case 'start-once': t.startOnceDelay = e.delay; break; case 'start': t.delay = e.delay; break; case 'end': t.endDelay = e.delay; break; case 'start-end': case void 0: (t.delay = e.delay), (t.endDelay = e.delay); break; } return t.direction === 'alternate' && ((t.delay /= 2), (t.endDelay /= 2), t.delay !== 0 && (t.pingPongDelayCorrection = t.delay)), t; } var pG = { type: 'beginState' }, fG = { type: 'completeState', isfromEntity: !1 }, Db = class { constructor(e, t, i, r, s, n) { if ( ((this.object = e), (this.data = r), (this.sharedAssets = s), (this.allowSlerp = n), (this.targets = { t: 0 }), (this.firstLoop = !0), (this._changeBegan = !1), (this._changeCompleted = !0), (this.onChange = () => { this.callback && (this.callback.update(this.targets.t), this.object.dispatchEvent({ type: 'requestRender' })), this.targets.t === 0 || this.targets.t === 1 ? this._changeCompleted || ((this._changeCompleted = !0), (this._changeBegan = !1), this.onChangeComplete()) : (this._changeCompleted && (this._changeCompleted = !1), this._changeBegan || ((this._changeBegan = !0), this.onChangeBegin())); }), (this.onChangeBegin = () => { this.object.reversibleToState = this.to.id; let a = this.targets.t > 0.5 ? this.from.id : this.to.id; this.object.prevState !== this.object.currentState && (this.object.prevState = this.object.currentState), (this.object.currentState = a), this.object.dispatchEvent({ type: 'beginState', state: a }), this.object.traverseEntity((o) => { o !== this.object && o instanceof Gi && o.dispatchEvent(pG); }); }), (this.onChangeComplete = () => { this.firstLoop && (this.onFirstLoop(), (this.firstLoop = !1)), (this.object.reversibleToState = this.to.id); let a = this.targets.t < 0.5 ? this.from.id : this.to.id; this.object.prevState !== this.object.currentState && (this.object.prevState = this.object.currentState), (this.object.currentState = a), this.object.dispatchEvent({ type: 'completeState', state: a }), this.object.traverseEntity((o) => { o !== this.object && o instanceof Gi && o.dispatchEvent(fG); }); }), (this.onFirstLoop = () => { this.useCurrentState && (this.callback = Tb(this.object, this.from.data, this.to.data, this.sharedAssets, this.allowSlerp)); }), t === void 0) ) { let a = cd(this.object, this.object.currentState === i ? this.object.prevState : this.object.currentState); if (!a) throw new Error('Missing property'); this.from = a; } else { let a = cd(this.object, t); if (!a) throw new Error('Missing property'); this.from = a; } if (i === void 0) throw new Error('Missing property'); { let a = cd(this.object, i); if (!a) throw new Error('Missing property'); this.to = a; } (this.useCurrentState = t === void 0 || i === void 0), (this.params = { targets: this.targets, t: 1, autoplay: !1, ...r2(r), ...uG(r), change: this.onChange }), (this.callback = Tb( this.object, t === void 0 ? {} : this.from.data, i === void 0 ? {} : this.to.data, this.sharedAssets, this.allowSlerp )); } get changeBegan() { return this._changeBegan; } get changeCompleted() { return this._changeCompleted; } }, _o = class extends Vi { constructor(e, t, i) { if ( (super(), (this.data = e), (this.scene = t), (this.sharedAssets = i), (this.toggleIsForward = !1), (this.timelineNeedsRebuild = !1), (this.useToggle = !1), (this.onTimelineChangeComplete = () => { this.data.tweens[0].data.direction !== 'normal' && (this.toggleIsForward = !this.toggleIsForward), this.timelineNeedsRebuild !== !1 && (this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward, isRebuild: !0 }), this.timeline.play()); }), !e.object) ) throw new Error('Missing property'); let r = t.find(e.object); if (!r) throw new Error('Missing property'); if (!r.states) throw new Error('Missing property'); if (((this.object = r), e.tweens.length < 2)) throw new Error('Missing property'); (this.tweens = Array(this.data.tweens.length - 1)), (this.startOnceDelay = e.tweens[0].data.delayDirection === 'start-once' ? e.tweens[0].data.delay : 0), this.init(); } get playing() { return this.tweens.some((e) => e.changeBegan) ?? !1; } init() { (this.initialCurrentState = cd(this.object, this.object.currentState).id), (this.toggleIsForward = !1); } get currentState() { return this.useToggle ? this.initialCurrentState : this.object.currentState; } buildTimeline({ isForward: e = !0, isRebuild: t = !1 } = {}) { try { let i = r2(this.data.tweens[0].data), r = i.loop; t && typeof i.loop == 'number' && i.loop--, this.timeline?.pause(), (this.timeline = Uj.timeline({ autoplay: !1, ...i, ...(r === !0 || r > 1 ? { timelineChangeComplete: this.onTimelineChangeComplete } : {}) })); let s = this.tweens.findIndex((n) => n?.changeBegan); if ( ((this.timelineNeedsRebuild = s !== -1 && (r === !0 || r > 1)), i.pingPongDelayCorrection && t === !1 && (this.timelineNeedsRebuild = !0), e) ) { let n = s === -1 ? 0 : s; for (let a = n; a < this.data.tweens.length - 1; a++) { let o = this.data.tweens[a], l = this.data.tweens[a + 1], h; a === n && (this.object.wasMovedByUser === !0 || this.object.previousAction?.playing === !0) ? ((h = void 0), this.object instanceof Gi && (this.object.wasMovedByUser = !1)) : (h = o.data.state === void 0 ? this.currentState : o.data.state); let u = new Db( this.object, h, l.data.state === void 0 ? this.currentState : l.data.state, l.data, this.sharedAssets, this.data.allowSlerp ?? !1 ); s !== -1 && a === n && Object.assign(u.params, { startOnceDelay: 0 }), (this.tweens[a] = u), this.timeline.add( u.params, this.timeline.duration + (a === n ? i.delay : 0) + (a === n && !t ? i.pingPongDelayCorrection : 0) ); } this.timeline.duration += i.endDelay; } else { let n = s === -1 ? this.data.tweens.length - 1 : s + 1; for (let a = n; a > 0; a--) { let o = this.data.tweens[a], l = this.data.tweens[a - 1], h; a === n && (this.object.wasMovedByUser === !0 || this.object.previousAction?.playing === !0) ? ((h = void 0), this.object instanceof Gi && (this.object.wasMovedByUser = !1)) : (h = o.data.state === void 0 ? this.currentState : o.data.state); let u = new Db( this.object, h, l.data.state === void 0 ? this.currentState : l.data.state, o.data, this.sharedAssets, this.data.allowSlerp ?? !1 ); s !== -1 && a === n && Object.assign(u.params, { startOnceDelay: 0 }), (this.tweens[a - 1] = u), this.timeline.add(u.params, this.timeline.duration + (a === n ? i.endDelay : 0)); } this.timeline.duration += i.delay + (t ? 0 : i.pingPongDelayCorrection); } } catch (i) { i instanceof Error && console.error(i.message); } this.object.previousAction?.playing === !0 && this.object.previousAction.pause(), (this.object.previousAction = this); } play() { if (this.playing) return !1; clearTimeout(this.timeoutId), (this.timeoutId = window.setTimeout(() => { try { this.buildTimeline(), this.timeline.play(); } catch (e) { e instanceof Error && console.error(e.message); } }, this.startOnceDelay)); } pause() { this.timeline?.pause(), clearTimeout(this.timeoutId), (this.tweens = Array(this.data.tweens.length - 1)), delete this.timeoutId; } stop() { this.pause(); let e = this.data.tweens[0].data.state === void 0 ? this.initialCurrentState : this.data.tweens[0].data.state; this.object.changeSelectedState(e, { scene: this.scene, shared: this.sharedAssets }), (this.object.currentState = e); } seek(e) { this.timeline === void 0 && this.buildTimeline(), this.timeline?.seek(e * this.timeline.duration); } toggle(e) { (this.useToggle = !0), clearTimeout(this.timeoutId), (this.toggleIsForward = e ?? !this.toggleIsForward), this.playing ? (this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward }), this.timeline.play()) : (this.timeoutId = window.setTimeout(() => { this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward }), this.timeline.play(); }, this.startOnceDelay)); } playFromCurrent() { this.toggle(!0); } reverseFromCurrent() { this.toggle(!1); } dispose() { this.pause(); } }; function cd(e, t) { let i, r; if ((typeof t == 'string' ? ((i = t), (r = e.states?.[i])) : t === null && ((i = null), (r = e.data)), !(i === void 0 || r === void 0))) return { id: i, data: r }; } function On(e, t, i, r, s, n) { let a = { Audio: [], Video: [], Link: [], Reset: [], Transition: [] }; return ( t.forEach(({ id: o, data: l }) => { try { l.type === 'Audio' ? _l[e.type].includes('Audio') && a.Audio.push(new wo(o, l, i, s)) : l.type === 'Video' ? _l[e.type].includes('Video') && a.Video.push(new ru(o, l, i)) : l.type === 'Link' ? _l[e.type].includes('Link') && a.Link.push(new aj(l, n)) : l.type === 'Reset' ? _l[e.type].includes('Reset') && a.Reset.push(new oj(r.data, r, s, n)) : l.type === 'Transition' && _l[e.type].includes('Transition') && a.Transition.push(new _o(l, r, s)); } catch {} }), a ); } function In(e) { Object.values(e).forEach((t) => { t.forEach((i) => { (i instanceof wo || i instanceof ru || i instanceof _o) && i.dispose(); }); }); } var Dv = [ ['start', 'Start'], ['keyDown', 'KeyDown'], ['keyUp', 'KeyUp'], ['mouseDown', 'MouseDown'], ['mouseUp', 'MouseUp'], ['mouseHover', 'MouseHover'], ['collision', 'Collision'], ['lookAt', 'LookAt'], ['follow', 'Follow'], ['scroll', 'Scroll'] ], s2 = (e) => Dv.find(([t, i]) => i === e)?.[0], Uh = (e) => Dv.find(([t]) => t === e)?.[1], mG = (e, t) => { let i = s2(e); if (i) { let r = new CustomEvent(i, { bubbles: !0 }); return Object.defineProperty(r, 'target', { writable: !1, value: t }), r; } }, gG = class extends zn { constructor(e) { super(e), (this.objectsPerEvents = new Map()), (this.splineEvents = {}), (this.onBeginEvent = (i) => { if (!i.eventName || !i.target || i.eventName === 'Scroll') return; let r = this.splineEvents[s2(i.eventName)]?.[i.target.uuid]; if (!r) return; i.eventName === 'Scroll' && i.deltaY !== void 0 && Object.assign(r, { deltaY: i.deltaY }); let { domElement: s } = this.eventContext; s.dispatchEvent(r); }); let { scene: t } = this.eventContext; t.traverseEntity((i) => { if (i.data?.events.length) { for (let [r, s] of Dv) if (i.data.events.some((n) => n.data.type === s && !n.data.disabled)) { this.objectsPerEvents.has(r) ? this.objectsPerEvents.get(r)?.push(i) : this.objectsPerEvents.set(r, [i]); let n = { id: i.uuid, name: i.name }, a = mG(s, n), o = this.splineEvents[r]; o ? (o[i.uuid] = a) : (this.splineEvents[r] = { [i.uuid]: a }); } } }); } connect() { this.objectsPerEvents.forEach((e) => { e.forEach((t) => { t.addEventListener('beginEvent', this.onBeginEvent); }); }); } disconnect() { this.objectsPerEvents.forEach((e) => { e.forEach((t) => { t.removeEventListener('beginEvent', this.onBeginEvent); }); }); } }, vG = class { constructor(e, t, i, r, s, n) { if ( ((this.id = e), (this.data = t), (this.object = i), (this.entered = !1), (this.useToggle = t.toggle), (t.type === 'KeyDown' || t.type === 'KeyUp' || t.type === 'KeyPress') && !t.key) ) throw new Error('Missing property'); this.actions = On(t, t.actions, i, r, s, n); } disconnect() { In(this.actions); } dispatch() { let e = new Set(); this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this ? ((t.object.currentTransitionEvent = this), t.init()) : this.useToggle === !1 && e.add(t); }), this.useToggle ? this.actions.Transition.forEach((t) => { t.toggle(); }) : this.data.type === 'MousePress' || this.data.type === 'KeyPress' ? this.entered || ((this.entered = !0), this.actions.Transition.forEach((t) => t.playFromCurrent())) : this.actions.Transition.some((t) => t.playing) || this.actions.Transition.forEach((t) => { e.has(t) === !1 && t.play(); }), this.actions.Link.forEach((t) => { t.dispatch(); }), this.actions.Reset.forEach((t) => { t.dispatch(); }), this.actions.Audio.forEach((t) => { t.dispatchBasic(); }), this.actions.Video.forEach((t) => { t.dispatchBasic(); }); } dispatchRelease() { this.entered && ((this.entered = !1), this.actions.Transition.forEach((e) => e.reverseFromCurrent())); } dispatchUserEvent(e) { this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init()); }), e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent()), this.actions.Link.forEach((t) => { t.dispatch(); }), this.actions.Reset.forEach((t) => { t.dispatch(); }), this.actions.Audio.forEach((t) => { t.dispatchBasic(); }), this.actions.Video.forEach((t) => { t.dispatchBasic(); }); } }, yG = class extends zn { constructor(e, t, i) { super(e), (this.objectsPerTypes = { MouseDown: [], MouseUp: [], MousePress: [], KeyDown: [], KeyUp: [], KeyPress: [] }), (this.eventsPerObjects = { MouseDown: {}, MouseUp: {}, MousePress: {}, KeyDown: {}, KeyUp: {}, KeyPress: {} }), (this.heldKeys = {}), (this.heldKeysPress = {}), (this._prevObjects = []), (this.onMouseDown = (n) => { Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMouseEvent('MouseDown')); }), (this.onMouseUp = (n) => { Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMouseEvent('MouseUp')); }), (this.onMousePressDown = (n) => { Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMousePressEvent()); }), (this.onMousePressRelease = (n) => { Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMousePressEvent(!0)); }), (this.onKeyDown = (n) => { this.heldKeys[n.key] || this.handleKeyEvent(n, 'KeyDown'), (this.heldKeys[n.key] = !0); }), (this.onKeyUp = (n) => { this.handleKeyEvent(n, 'KeyUp'); }), (this.onKeyPressDown = (n) => { this.heldKeysPress[n.key] || this.handleKeyEvent(n, 'KeyPress'), (this.heldKeysPress[n.key] = !0); }), (this.onKeyPressUp = (n) => { this.handleKeyEvent(n, 'KeyPress', !0); }), (this.releaseHeldKey = (n) => { delete this.heldKeys[n.key]; }), (this.releaseHeldKeyPress = (n) => { delete this.heldKeysPress[n.key]; }), (this._onUserEvent = ({ eventName: n, target: a, reverse: o }) => { if (!n || !a) return; let l = Uh(n); l && (l === 'MouseDown' || l === 'MouseUp' || l === 'MousePress' ? (a.dispatchEvent({ type: 'beginEvent', eventName: l }), this.eventsPerObjects[l]?.[a.uuid]?.forEach((h) => { h.dispatchUserEvent(o); })) : (l === 'KeyDown' || l === 'KeyUp' || l === 'KeyPress') && (a.dispatchEvent({ type: 'beginEvent', eventName: l }), this.eventsPerObjects[l]?.[a.uuid]?.forEach((h) => { h.dispatchUserEvent(); }))); }); let { scene: r, sharedAssets: s } = this.eventContext; r.traverseEntity((n) => { if (!n.data?.events.length) return; let a = n.visible ? ['MouseDown', 'MouseUp', 'MousePress', 'KeyDown', 'KeyUp', 'KeyPress'] : ['KeyDown', 'KeyUp', 'KeyPress']; for (let o of a) { let l = this.eventsPerObjects[o]; n.data.events .filter(({ data: h }) => h.type === o && h.disabled !== !0) .forEach(({ id: h, data: u }) => { try { let c = new vG(h, u, n, r, s, { controlsManager: t, eventManager: i }); c.actions.Video.length && (this.hasVideoAction = !0), l[n.uuid] ? l[n.uuid].push(c) : (l[n.uuid] = [c]); } catch {} }), l[n.uuid]?.length && this.objectsPerTypes[o].push(n); } }); } connect() { let { domElement: e } = this.eventContext; (this.heldKeys = {}), (this.heldKeysPress = {}), this.domEventsNeeded.clear(), this.objectsPerTypes.MouseDown?.length && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseDown)), this.objectsPerTypes.MouseUp?.length && (this.domEventsNeeded.add('pointerup'), e.addEventListener('pointerup', this.onMouseUp)), this.objectsPerTypes.MousePress?.length && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMousePressDown), this.domEventsNeeded.add('pointerup'), e.addEventListener('pointerup', this.onMousePressRelease)), this.objectsPerTypes.KeyDown?.length && (this.domEventsNeeded.add('keydown'), document.addEventListener('keydown', this.onKeyDown), document.addEventListener('keyup', this.releaseHeldKey)), this.objectsPerTypes.KeyUp?.length && (this.domEventsNeeded.add('keyup'), document.addEventListener('keyup', this.onKeyUp)), this.objectsPerTypes.KeyPress?.length && (this.domEventsNeeded.add('keydown'), document.addEventListener('keydown', this.onKeyPressDown), document.addEventListener('keyup', this.releaseHeldKeyPress), this.domEventsNeeded.add('keyup'), document.addEventListener('keyup', this.onKeyPressUp)), Object.entries(this.objectsPerTypes).forEach(([t, i]) => { i.forEach((r) => { r.addEventListener('userEvent', this._onUserEvent); }); }); } disconnect() { let { domElement: e } = this.eventContext; this.domEventsNeeded.clear(), (this.heldKeys = {}), (this.heldKeysPress = {}), e.removeEventListener('pointerdown', this.onMouseDown), e.removeEventListener('pointerdown', this.onMousePressDown), e.removeEventListener('pointerup', this.onMouseUp), e.removeEventListener('pointerup', this.onMousePressRelease), document.removeEventListener('keydown', this.onKeyDown), document.removeEventListener('keyup', this.onKeyUp), document.removeEventListener('keydown', this.onKeyPressDown), document.removeEventListener('keyup', this.onKeyPressUp), document.removeEventListener('keyup', this.releaseHeldKey), Object.values(this.eventsPerObjects).forEach((t) => { Object.values(t).forEach((i) => { i.forEach((r) => { r.disconnect(); }); }); }), Object.entries(this.objectsPerTypes).forEach(([t, i]) => { i.forEach((r) => { r.removeEventListener('userEvent', this._onUserEvent); }); }); } handleMouseEvent(e) { let { stopRaycast: t, raycaster: i, scene: r } = this.eventContext, s = this.objectsPerTypes[e]; if (s.length) if (t) { let n = Km(i, r, s); Jm(n).forEach((a) => { this.eventsPerObjects[e][a.uuid] && this.handleObjectMouseEventDispatch(a, e); }); } else s.forEach((n) => { iu(i, n) && this.handleObjectMouseEventDispatch(n, e); }); } handleMousePressEvent(e = !1) { let t = 'MousePress', i = this.objectsPerTypes[t], r = []; if (i.length) { if (!e) { let { stopRaycast: s, raycaster: n, scene: a } = this.eventContext; if (s) { let o = Km(n, a, i); r = Jm(o); } else i.forEach((o) => { iu(n, o) && r.push(o); }); } this._prevObjects.length && this._prevObjects.forEach((s) => { r.includes(s) || this.handleObjectMouseEventDispatchRelease(s, t); }), r.length && r.forEach((s) => { this.handleObjectMouseEventDispatch(s, t); }), (this._prevObjects = r); } } handleObjectMouseEventDispatch(e, t) { e.dispatchEvent({ type: 'beginEvent', eventName: t }), this.eventsPerObjects[t]?.[e.uuid]?.forEach((i) => { i.dispatch(); }); } handleObjectMouseEventDispatchRelease(e, t) { e.dispatchEvent({ type: 'beginEvent', eventName: t }), this.eventsPerObjects[t]?.[e.uuid]?.forEach((i) => { i.dispatchRelease(); }); } handleKeyEvent(e, t, i = !1) { this.objectsPerTypes[t].forEach((r) => { let s = this.eventsPerObjects[t][r.uuid]; s.some(({ data: n }) => 'key' in n && n.key === e.key) && r.dispatchEvent({ type: 'beginEvent', eventName: t }), s.forEach((n) => { 'key' in n.data && n.data.key === e.key && (i ? n.dispatchRelease() : n.dispatch()); }); }); } }, xG = new E(), bG = new E(), n2 = class { constructor(e, t, i, r) { (this.actionsIn = On(e, e.inActions, t, i, r)), (this.actionsOut = On(e, e.outActions, t, i, r)); } disconnect() { In(this.actionsIn), In(this.actionsOut); } }, wG = class extends n2 { constructor(e, t, i, r, s) { super(t, i, r, s), (this.id = e), (this.data = t), (this.object = i), (this.stage = 'out'), (this.objects = []), (this.onUpdateMatrix = () => { let l = xG.setFromMatrixPosition(this.objects[0].matrixWorld), h = bG.setFromMatrixPosition(this.objects[1].matrixWorld), u = l.distanceTo(h) <= this.distance ? 'in' : 'out'; if (this.stage !== u) { let c = u === 'in' ? this.actionsIn : this.actionsOut; c.Audio.forEach((d) => d.dispatchConditional()), c.Video.forEach((d) => d.dispatchConditional()), c.Transition.forEach((d) => { d.object.currentTransitionEvent !== this && (d.object.currentTransitionEvent = this), d.init(); }), c.Transition.forEach((d) => d.play()), (this.stage = u); } }); let { distance: n, fromObject: a, toObject: o } = t.condition; this.distance = n; for (let l of [a, o]) { if (!l) throw new Error('Missing property'); let h = r.find(l); if (!h) throw new Error('Missing property'); this.objects.push(h); } } connect() { this.objects.forEach((e) => { e.addEventListener('updateMatrix', this.onUpdateMatrix); }), this.onUpdateMatrix(); } disconnect() { super.disconnect(), (this.stage = 'out'), this.objects.forEach((e) => { e.removeEventListener('updateMatrix', this.onUpdateMatrix); }); } }, _G = class extends n2 { constructor(e, t, i, r, s) { super(t, i, r, s), (this.id = e), (this.data = t), (this.object = i), (this.onBegin = ({ target: o, state: l }) => { this.toState !== l && (this.actionsOut.Audio.forEach((h) => h.dispatchConditional()), this.actionsOut.Video.forEach((h) => h.dispatchConditional()), this.actionsIn.Transition.forEach((h) => h.pause()), (this.object.currentTransitionEvent = this), this.actionsOut.Transition.forEach((h) => h.play())); }), (this.onComplete = ({ target: o, state: l }) => { this.toState === l && (this.actionsIn.Audio.forEach((h) => h.dispatchConditional()), this.actionsIn.Video.forEach((h) => h.dispatchConditional()), this.actionsOut.Transition.forEach((h) => h.pause()), (this.object.currentTransitionEvent = this), this.actionsIn.Transition.forEach((h) => h.play())); }); let { condition: n } = t; if (!n.object) throw new Error('Missing property'); let a = r.find(n.object); if (!a) throw new Error('Missing property'); if (((this.toObject = a), n.state && !this.toObject.states?.[n.state])) throw new Error('Missing property'); this.toState = n.state; } connect() { (this.actionsOut.Audio.length || this.actionsOut.Video.length || this.actionsOut.Transition.length) && this.toObject.addEventListener('beginState', this.onBegin), (this.actionsIn.Audio.length || this.actionsIn.Video.length || this.actionsIn.Transition.length) && this.toObject.addEventListener('completeState', this.onComplete); } disconnect() { super.disconnect(), (this.actionsOut.Audio.length || this.actionsOut.Video.length || this.actionsOut.Transition.length) && this.toObject.removeEventListener('beginState', this.onBegin), (this.actionsIn.Audio.length || this.actionsIn.Video.length || this.actionsIn.Transition.length) && this.toObject.removeEventListener('completeState', this.onComplete); } }, AG = class extends zn { constructor(e) { super(e), (this.eventsPerConditions = { Comparison: [], Distance: [], State: [] }), (this.hasVideoAction = !1); let { scene: t, sharedAssets: i } = this.eventContext; t.traverseEntity((r) => { if (r.data?.events.length) { for (let { id: s, data: n } of r.data.events) if (!n.disabled && n.type === 'Conditional') try { let a; n.condition.type === 'Comparison' || (n.condition.type === 'Distance' ? (a = new wG(s, n, r, t, i)) : n.condition.type === 'State' && (a = new _G(s, n, r, t, i))), a && (this.eventsPerConditions[n.condition.type].push(a), (a.actionsIn.Video.length || a.actionsOut.Video.length) && (this.hasVideoAction = !0)); } catch {} } }); } connect() { super.connect(), Object.values(this.eventsPerConditions).forEach((e) => e.forEach((t) => t.connect())); } disconnect() { super.disconnect(), Object.values(this.eventsPerConditions).forEach((e) => e.forEach((t) => t.disconnect())); } }, to = new E(), xf = new E(), Rs = new E(), Bs = new E(), Lb = new yr(), SG = 0.01, MG = { type: 'requestRender' }, EG = (function () { let e = new E(), t = new E(); return (i, r, s) => (s > 0 ? (e.subVectors(i, r), e.length() <= s ? i : t.copy(r).add(e.normalize().multiplyScalar(s))) : r); })(), Ob = (function () { let e = new ve(); return (t, i) => { t.position.copy(i), t.parent !== null && (e.copy(t.parent.matrixWorld).invert(), t.position.applyMatrix4(e)), e.copy(t.hiddenMatrix).invert(), t.position.applyMatrix4(e), t.updateMatrix(), t.hasNonUniformScale && (t.updateMatrixWorld(), t.updateMatrixWorldSVD()), t instanceof ar && Sn(t.parent) && t.invalidateDownstreamBooleanData(!0); }; })(), CG = class { constructor(e, t, i) { (this.data = e), (this.object = t), (this.paused = !1), (this.currentDampingFactor = 1), (this.snapComplete = !1), (this.isReset = !1), (this.worldPosition0 = new E()), (this.timeoutId = null), (this.delayFinished = !0), (this.wasOutside = !1), (this.data = { ...dm.defaultData, ...e, ...(e.resetOnPointerLeave === void 0 && { resetOnPointerLeave: !1 }) }), e.target === void 0 || e.target === 'cursor' || (e.target === 'personal camera' ? (this.target = i.find(sl.PERSONAL_CAMERA_ID)) : (this.target = i.find(e.target))), this.data.dampingFactor && (this.currentDampingFactor = this.data.dampingFactor), (this.resetDampingFactor = 80 / this.data.resetSpeed + 1), this.object.getWorldPosition(this.worldPosition0); } }, TG = class extends zn { constructor(e) { super(e), (this.events = []), (this.pairOfEventListeners = []), (this.onMouseMove = (i) => { if (!(Qe.length > 1)) { this.eventContext.updateRaycaster(i); for (let r of this.events) r.target === void 0 && this.updateSingleEvent(r); } }), (this.onMouseEnter = (i) => { for (let r of this.events) r.target === void 0 && ((r.isReset = !1), (r.currentDampingFactor = r.data.dampingFactor)); }), (this.onMouseLeave = (i) => { for (let r of this.events) r.target === void 0 && (r.data.resetOnPointerLeave && ((r.isReset = !0), (r.currentDampingFactor = r.resetDampingFactor)), this.updateSingleEvent(r)); }), (this.onTargetChange = (i) => () => { this.updateSingleEvent(i); }); let { scene: t } = this.eventContext; t.traverseEntity((i) => { let r = i.data?.events.find((s) => s.data.type === 'Follow' && !s.data.disabled); r && (!t.data.environment.usePhysics || i.dataPatched.physics?.rigidBody !== 'dynamic') && this.events.push(new CG(r.data, i, t)); }); } connect() { if (!this.events.length) return; let { domElement: e, eventElement: t } = this.eventContext; this.domEventsNeeded.clear(), rr && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseMove)), this.domEventsNeeded.add('pointermove'), t.addEventListener('pointermove', this.onMouseMove), this.eventContext.useWindowEvents || (e.addEventListener('pointerenter', this.onMouseEnter), e.addEventListener('pointerleave', this.onMouseLeave)); for (let i of this.events) if (i.target !== void 0) { let r = i.target, s = this.onTargetChange(i); this.pairOfEventListeners.push([r, s]), r.addEventListener('requestRender', s); } } disconnect() { if (!this.events.length) return; let { domElement: e, eventElement: t } = this.eventContext; this.domEventsNeeded.clear(), rr && e.removeEventListener('pointerdown', this.onMouseMove), t.removeEventListener('pointermove', this.onMouseMove), e.removeEventListener('pointerenter', this.onMouseEnter), e.removeEventListener('pointerleave', this.onMouseLeave); for (let [i, r] of this.pairOfEventListeners) i.removeEventListener('requestRender', r); for (let i of this.events) (i.paused = !0), (i.isReset = !1); } onAnimationFrameDamping() { for (let e of this.events) e.paused || this.updateSingleEvent(e); } updateSingleEvent(e) { let { plane: t, limitDistance: i, limitDistanceEnabled: r } = e.data; if ((e.object.getWorldPosition(Rs), e.isReset)) Bs.copy(e.worldPosition0); else if (e.target) e.target.getWorldPosition(Bs); else { let { camera: n, raycaster: a } = this.eventContext; if ( (t === 'custom' ? (n.getWorldDirection(xf), xf.negate(), to.copy(xf)) : t === 'xy' ? to.set(0, 0, 1) : t === 'xz' ? to.set(0, 1, 0) : t === 'yz' && to.set(1, 0, 0), Lb.setFromNormalAndCoplanarPoint(to, Rs), !a.ray.intersectPlane(Lb, Bs)) ) return; } if (!e.isReset) { if (Bs.distanceTo(e.worldPosition0) > i && r && e.target) if ( ((e.snapComplete = !1), e.data.snapDelay && ((e.delayFinished = !1), typeof window < 'u' && e.timeoutId !== null && (window.clearTimeout(e.timeoutId), (e.timeoutId = null))), (e.wasOutside = !0), e.data.resetAfterDistanceLimit) ) Bs.copy(e.worldPosition0), (e.currentDampingFactor = e.resetDampingFactor); else return; else if ( (e.wasOutside && (e.data.snapDelay && typeof window < 'u' && (e.timeoutId = window.setTimeout(() => { (e.delayFinished = !0), (e.paused = !1), this.updateSingleEvent(e); }, e.data.snapDelay * 1e3)), (e.currentDampingFactor = e.data.dampingFactor), (e.wasOutside = !1)), e.delayFinished === !1) ) return; } e.data.enabledTranslation[0] === !1 && (Bs.x = Rs.x), e.data.enabledTranslation[1] === !1 && (Bs.y = Rs.y), e.data.enabledTranslation[2] === !1 && (Bs.z = Rs.z); let s = EG(Rs, Bs, e.wasOutside ? 0 : e.data.maxDelta); if (e.currentDampingFactor > 1) { let n = to.subVectors(s, Rs).divideScalar(e.currentDampingFactor); Rs.add(n), Ob(e.object, Rs), (e.paused = n.length() < SG); } else Ob(e.object, s), (e.paused = !0); e.object?.dispatchEvent({ type: 'beginEvent', eventName: 'Follow' }), e.object.dispatchEvent(MG); } }, Nl = new E(), Xc = new E(), Ul = new ve(), io = new ct(), an = new ct(), Fl = new E(), kl = new E(), Zn = new E(), zs = new E(), bf = new yr(), PG = 1e-6, DG = { type: 'requestRender' }, LG = { type: 'changeRotation' }, Ib = (function () { let e = new ve(); return function (t, i) { t.parent !== null ? e.multiplyMatrices(t.parent.matrixWorld, t.hiddenMatrix) : e.copy(t.hiddenMatrix), i.premultiply(OS(e).invert()), t.rotation.setFromRotationMatrix(i), t.updateMatrix(), t instanceof ar && Sn(t.parent) && t.invalidateDownstreamBooleanData(!0); }; })(), OG = class { constructor(e, t, i) { (this.object = t), (this.paused = !1), (this.currentDampingFactor = 1), (this.isReset = !1), (this.worldQuaternion0 = new ct()), (this.timeoutId = null), (this.delayFinished = !0), (this.wasOutside = !1), (this.data = { ...um.defaultData, ...e, ...(e.resetOnPointerLeave === void 0 && { resetOnPointerLeave: !1 }) }), e.target === void 0 || e.target === 'cursor' || (e.target === 'personal camera' ? (this.target = i.find(sl.PERSONAL_CAMERA_ID)) : (this.target = i.find(e.target))), this.data.dampingFactor && (this.currentDampingFactor = this.data.dampingFactor), this.object.getWorldQuaternion(this.worldQuaternion0), (this.resetDampingFactor = 80 / this.data.resetSpeed + 1); } }, IG = class extends zn { constructor(e) { super(e), (this.events = []), (this.pairOfEventListeners = []), (this.pairOfUserEventListeners = []), (this.onMouseMove = (i) => { if (!(Qe.length > 1)) { (this._lastMouseEvent = i), this.eventContext.updateRaycaster(i); for (let r of this.events) r.target === void 0 && this.updateSingleEvent(r); } }), (this.onMouseEnter = (i) => { for (let r of this.events) r.target === void 0 && ((r.isReset = !1), (r.currentDampingFactor = r.data.dampingFactor)); }), (this.onMouseLeave = (i) => { for (let r of this.events) r.target === void 0 && (r.data.resetOnPointerLeave && ((r.isReset = !0), (r.currentDampingFactor = r.resetDampingFactor)), this.updateSingleEvent(r)); }), (this.onScroll = (i) => { if (this._lastMouseEvent) { let r = new PointerEvent('pointermove', { clientX: this._lastMouseEvent.clientX, clientY: this._lastMouseEvent.clientY, bubbles: !0, cancelable: !0, view: window }); this.eventContext.eventElement.dispatchEvent(r); } }), (this.onTargetChange = (i) => () => { this.updateSingleEvent(i); }), (this.createUserEventListener = (i) => ({ eventName: r, target: s }) => { if (!r || !s) return; let n = Uh(r); n && n === 'LookAt' && this.updateSingleEvent(i); }); let { scene: t } = this.eventContext; t.traverseEntity((i) => { let r = i.data?.events.find((s) => s.data.type === 'LookAt' && !s.data.disabled); r && (!t.data.environment.usePhysics || i.dataPatched.physics?.rigidBody !== 'dynamic') && this.events.push(new OG(r.data, i, t)); }); } connect() { if (!this.events.length) return; let { domElement: e, eventElement: t } = this.eventContext; this.domEventsNeeded.clear(), rr && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseMove)), this.domEventsNeeded.add('pointermove'), t.addEventListener('pointermove', this.onMouseMove), this.eventContext.useWindowEvents ? t.addEventListener('scroll', this.onScroll) : (e.addEventListener('pointerenter', this.onMouseEnter), e.addEventListener('pointerleave', this.onMouseLeave)); for (let i of this.events) { if (i.target !== void 0) { let n = this.onTargetChange(i), a = i.target; this.pairOfEventListeners.push([a, n]), a.addEventListener('requestRender', n); } let r = this.createUserEventListener(i), s = i.object; this.pairOfUserEventListeners.push([s, r]), s.addEventListener('userEvent', r); } } disconnect() { if (!this.events.length) return; let { domElement: e, eventElement: t } = this.eventContext; this.domEventsNeeded.clear(), rr && e.removeEventListener('pointerdown', this.onMouseMove), t.removeEventListener('pointermove', this.onMouseMove), e.removeEventListener('pointerenter', this.onMouseEnter), e.removeEventListener('pointerleave', this.onMouseLeave), t.removeEventListener('scroll', this.onScroll); for (let [i, r] of this.pairOfEventListeners) i.removeEventListener('requestRender', r); for (let [i, r] of this.pairOfUserEventListeners) i.removeEventListener('userEvent', r); for (let i of this.events) (i.paused = !0), (i.isReset = !1); } onAnimationFrameDamping() { for (let e of this.events) e.paused || this.updateSingleEvent(e); } updateSingleEvent(e) { let { tilt: t, axis: i, distance: r, plane: s, limitDistance: n, enabledRotation: a, limitDistanceEnabled: o } = e.data, { camera: l, raycaster: h } = this.eventContext, { object: u, target: c } = e; if ((u.getWorldPosition(Fl), !e.isReset)) if (e.target) e.target.getWorldPosition(kl); else { if ( (s === 'custom' ? (l.getWorldDirection(Xc), Xc.negate(), bf.setFromNormalAndCoplanarPoint(Xc, Fl)) : (s === 'xy' ? Nl.set(0, 0, 1) : s === 'xz' ? Nl.set(0, 1, 0) : s === 'yz' && Nl.set(1, 0, 0), bf.setFromNormalAndCoplanarPoint(Nl, Fl)), !h.ray.intersectPlane(bf, kl)) ) return; r > 0 && (s === 'custom' || s === void 0) && kl.addScaledVector(Xc, r); } if ( (e.isReset || (c ? t === 'target' ? Zn.copy(c.up).applyMatrix4(Ul.extractRotation(c.matrixWorld)).normalize() : a.some((d) => d === !1) ? (i === 'x' ? (zs.set(0, 0, 1), a[2] === !1 && zs.set(0, 1, 0)) : i === 'y' ? (zs.set(1, 0, 0), a[0] === !1 && zs.set(0, 0, 1)) : (zs.set(0, 1, 0), a[1] === !1 && zs.set(1, 0, 0)), Zn.copy(zs).applyQuaternion(e.worldQuaternion0).normalize()) : Zn.set(0, 1, 0) : s === 'custom' ? Zn.set(0, 1, 0) : Zn.copy(Nl)), e.isReset) ) an.copy(e.worldQuaternion0); else if (Fl.distanceTo(kl) > n && o && c) if ( (e.data.snapDelay && ((e.delayFinished = !1), typeof window < 'u' && e.timeoutId !== null && (window.clearTimeout(e.timeoutId), (e.timeoutId = null))), (e.wasOutside = !0), e.data.resetAfterDistanceLimit) ) an.copy(e.worldQuaternion0), (e.currentDampingFactor = e.resetDampingFactor); else return; else { if ( (e.wasOutside && (e.data.snapDelay && typeof window < 'u' && (e.timeoutId = window.setTimeout(() => { (e.delayFinished = !0), (e.paused = !1), this.updateSingleEvent(e); }, e.data.snapDelay * 1e3)), (e.currentDampingFactor = e.data.dampingFactor), (e.wasOutside = !1)), e.delayFinished === !1) ) return; RG(Ul, kl, Fl, Zn, i, zs), an.setFromRotationMatrix(Ul), io.setFromUnitVectors(zs.applyQuaternion(an), Zn), a.some((d) => d === !1) && t !== 'target' && an.premultiply(io).normalize(); } e.currentDampingFactor > 1 ? (u.updateWorldMatrix(!0, !1), io.setFromRotationMatrix(OS(u.matrixWorld)), io.slerp(an, 1 / e.currentDampingFactor), Ib(u, Ul.makeRotationFromQuaternion(io)), (e.paused = 8 * (1 - io.dot(an)) < PG)) : (Ib(u, Ul.makeRotationFromQuaternion(an)), (e.paused = !0)), e.object?.dispatchEvent({ type: 'beginEvent', eventName: 'LookAt' }), u.dispatchEvent(DG), u.dispatchEvent(LG); } }, ur = new E(), ei = new E(), Gt = new E(); function RG(e, t, i, r, s, n) { let a = e.elements; Gt.subVectors(t, i), Gt.lengthSq() === 0 && (Gt.z = 1), Gt.normalize(), ei.crossVectors(r, Gt), ei.lengthSq() === 0 && (Math.abs(r.z) === 1 ? (Gt.x += 1e-4) : (Gt.z += 1e-4), Gt.normalize(), ei.crossVectors(r, Gt)), ei.normalize(), ur.crossVectors(Gt, ei), s === 'x' ? n.z === 1 ? ([ei, ur, Gt] = [Gt, ei, ur]) : (ei.negate(), ([ei, Gt] = [Gt, ei])) : s === 'y' ? n.x === 1 ? ([ei, ur, Gt] = [ur, Gt, ei]) : (ei.negate(), ([ur, Gt] = [Gt, ur])) : n.x === 1 && (ei.negate(), ([ei, ur] = [ur, ei])), (a[0] = ei.x), (a[4] = ur.x), (a[8] = Gt.x), (a[1] = ei.y), (a[5] = ur.y), (a[9] = Gt.y), (a[2] = ei.z), (a[6] = ur.z), (a[10] = Gt.z); } var BG = class { constructor(e, t, i, r, s) { (this.id = e), (this.data = t), (this.object = i), (this.entered = !1), (this.actions = On(t, t.actions, i, r, s)); } disconnect() { In(this.actions); } dispatchEnter() { this.actions.Transition.forEach((e) => { e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init()); }), this.entered || ((this.entered = !0), this.actions.Transition.forEach((e) => e.playFromCurrent())); } dispatchLeave() { this.actions.Transition.forEach((e) => { e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init()); }), this.entered && ((this.entered = !1), this.actions.Transition.forEach((e) => e.reverseFromCurrent())); } dispatchUserEvent(e) { this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init()); }), e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent()); } }, zG = class extends zn { constructor(e) { super(e), (this.eventsPerObjects = {}), (this.objects = []), (this._prevObjects = []), (this.onMouseDown = (r) => { Qe.length > 1 || (this.eventContext.updateRaycaster(r), this.handleMouseHoverEvent()); }), (this.onMouseUp = (r) => { Qe.length > 1 || this.handleMouseHoverEvent(!0); }), (this.onMouseMove = (r) => { Qe.length > 1 || (this.eventContext.updateRaycaster(r), this.handleMouseHoverEvent()); }), (this.onUserEvent = ({ eventName: r, target: s, reverse: n }) => { if (!r || !s) return; let a = Uh(r); a && a === 'MouseHover' && (s.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }), this.eventsPerObjects[s.uuid]?.forEach((o) => o.dispatchUserEvent(n))); }); let { scene: t, sharedAssets: i } = this.eventContext; t.traverseEntity((r) => { if (!(!r.visible || !r.data?.events.length)) { for (let { id: s, data: n } of r.data.events) if (!n.disabled && n.type === 'MouseHover') try { let a = new BG(s, n, r, t, i); this.eventsPerObjects[r.uuid] ? this.eventsPerObjects[r.uuid].push(a) : (this.eventsPerObjects[r.uuid] = [a]); } catch {} this.eventsPerObjects[r.uuid]?.length && this.objects.push(r); } }); } connect() { if (!this.objects.length) return; let { domElement: e } = this.eventContext; this.domEventsNeeded.clear(), rr && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseDown), this.domEventsNeeded.add('pointerup'), e.addEventListener('pointerup', this.onMouseUp)), this.domEventsNeeded.add('pointermove'), e.addEventListener('pointermove', this.onMouseMove), this.objects.forEach((t) => { t.addEventListener('userEvent', this.onUserEvent); }); } disconnect() { if (!this.objects.length) return; let { domElement: e } = this.eventContext; this.domEventsNeeded.clear(), rr && (e.removeEventListener('pointerdown', this.onMouseDown), e.removeEventListener('pointerup', this.onMouseUp)), e.removeEventListener('pointermove', this.onMouseMove), Object.values(this.eventsPerObjects).forEach((t) => { t.forEach((i) => { i.disconnect(); }); }), this.objects.forEach((t) => { t.removeEventListener('userEvent', this.onUserEvent); }); } handleMouseHoverEvent(e = !1) { let t = []; if (!e) { let { stopRaycast: i, raycaster: r, scene: s } = this.eventContext; if (i) { let n = Km(r, s, this.objects); t = Jm(n); } else this.objects.forEach((n) => { iu(r, n) && t.push(n); }); } this._prevObjects.length && this._prevObjects.forEach((i) => { t.includes(i) || (i.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }), this.eventsPerObjects[i.uuid]?.forEach((r) => r.dispatchLeave())); }), t.length && t.forEach((i) => { i.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }), this.eventsPerObjects[i.uuid]?.forEach((r) => r.dispatchEnter()); }), (this._prevObjects = t); } }, NG = class { constructor(e, t, i, r, s) { (this.id = e), (this.data = t), (this.object = i), (this.scrollCounter = 0), (this.actions = On(t, t.actions, i, r, s)); } connect() { this.scrollCounter = 0; } disconnect() { In(this.actions); } dispatch(e) { this.actions.Transition.forEach((r) => { r.object.currentTransitionEvent !== this && ((r.object.currentTransitionEvent = this), r.init()); }); let t = e > 0 ? 1 : -1; (this.scrollCounter += t), (this.scrollCounter = Math.min(Math.max(this.scrollCounter, 0), this.data.steps)); let i = this.scrollCounter / this.data.steps; this.actions.Transition.forEach((r) => r.seek(i)); } dispatchUserEvent(e) { this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init()); }), e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => { t.playFromCurrent(); }); } }, UG = class { constructor(e, t, i, r, s, n) { (this.id = e), (this.data = t), (this.object = i), (this.domElement = n), (this.scrollStart = 0), (this.scrollEnd = 0), (this.actions = On(t, t.actions, i, r, s)); } computeScrollBounds() { let e = this.domElement.getBoundingClientRect(), t = document.body, i = document.documentElement, r = window.pageYOffset || i.scrollTop || t.scrollTop, s = i.clientTop || t.clientTop || 0, n = Math.round(e.top + r - s); if (this.data.startFrom === 'enter') { let a = window.innerHeight, o = e.height, l = this.data.enterAnchor, h = l === 'top' ? a : l === 'bottom' ? a - o : a - o * 0.5; this.scrollStart = n - h; } else this.scrollStart = 0; (this.scrollStart += this.data.startOffset ?? 0), (this.scrollEnd = this.scrollStart + (this.data.endAfter ?? 400)), this.dispatch({ x: window.scrollX, y: window.scrollY }); } connect() { this.computeScrollBounds(); } disconnect() { In(this.actions); } handleResize() { this.computeScrollBounds(); } dispatch({ x: e, y: t }) { this.actions.Transition.forEach((s) => { s.object.currentTransitionEvent !== this && ((s.object.currentTransitionEvent = this), s.init()); }); let i = this.scrollEnd - this.scrollStart, r = Math.min(1, Math.max(0, (t - this.scrollStart) / i)); this.actions.Transition.forEach((s) => s.seek(r)); } dispatchUserEvent(e) { this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init()); }), e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => { t.playFromCurrent(); }); } }, FG = class extends zn { constructor(e) { super(e), (this.wheelEventsPerObject = new Map()), (this.scrollEventsPerObject = new Map()), (this.isInview = !0), (this.handleResize = () => { [...this.scrollEventsPerObject.entries()].forEach(([n, a]) => { a.forEach((o) => o.handleResize()); }); }), (this.onScroll = (n) => { if (!this.isInview) return; let a = { y: window.scrollY, x: window.scrollX }; [...this.scrollEventsPerObject.entries()].forEach(([o, l]) => { o.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll', scroll: a }), l.forEach((h) => h.dispatch(a)); }); }), (this.onWheel = (n) => { !this.isInview || n.ctrlKey || [...this.wheelEventsPerObject.entries()].forEach(([a, o]) => { a.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll', deltaY: n.deltaY }), o.forEach((l) => l.dispatch(n.deltaY)); }); }), (this.onUserEvent = ({ eventName: n, target: a, reverse: o }) => { if (!n || !a) return; let l = Uh(n); l && l === 'Scroll' && (a.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll' }), this.wheelEventsPerObject.get(a)?.forEach((h) => { h.dispatchUserEvent(o); })); }); let { scene: t, sharedAssets: i, domElement: r, isExport: s } = this.eventContext; t.traverseEntity((n) => { if (n.data?.events.length) { for (let { id: a, data: o } of n.data.events) if (!o.disabled && o.type === 'Scroll') if (o.trigger === 'load' || !s) { let l = new NG(a, o, n, t, i); this.wheelEventsPerObject.has(n) ? this.wheelEventsPerObject.get(n)?.push(l) : this.wheelEventsPerObject.set(n, [l]); } else { let l = new UG(a, o, n, t, i, r); this.scrollEventsPerObject.has(n) ? this.scrollEventsPerObject.get(n)?.push(l) : this.scrollEventsPerObject.set(n, [l]); } } }), (this.intersectionObserver = new IntersectionObserver( (n) => { let a = n[0]; a && (this.isInview = a.isIntersecting); }, { root: null } )); } connect() { this.intersectionObserver.observe(this.eventContext.domElement), [...this.wheelEventsPerObject.entries()].forEach(([e, t]) => { t.forEach((i) => i.connect()), e.addEventListener('userEvent', this.onUserEvent); }), [...this.scrollEventsPerObject.entries()].forEach(([e, t]) => { t.forEach((i) => i.connect()), e.addEventListener('userEvent', this.onUserEvent); }), [...this.wheelEventsPerObject.values()].some((e) => e.length) && (this.domEventsNeeded.add('wheel'), window.addEventListener('wheel', this.onWheel)), [...this.scrollEventsPerObject.values()].some((e) => e.length) && (this.domEventsNeeded.add('scroll'), window.addEventListener('scroll', this.onScroll), window.addEventListener('resize', this.handleResize)); } disconnect() { window.removeEventListener('wheel', this.onWheel), window.removeEventListener('scroll', this.onScroll), window.removeEventListener('resize', this.handleResize), this.intersectionObserver.unobserve(this.eventContext.domElement), this.domEventsNeeded.clear(), [...this.wheelEventsPerObject.entries()].forEach(([e, t]) => { t.forEach((i) => i.disconnect()), e.removeEventListener('userEvent', this.onUserEvent); }), [...this.scrollEventsPerObject.entries()].forEach(([e, t]) => { t.forEach((i) => i.disconnect()), e.removeEventListener('userEvent', this.onUserEvent); }); } }, kG = class { constructor(e, t, i, r, s) { (this.id = e), (this.data = t), (this.object = i), (this.actions = On(t, t.actions, i, r, s)); } disconnect() { In(this.actions); } dispatch() { this.actions.Transition.forEach((e) => { e.play(); }); } dispatchAfter(e) { this.actions.Audio.forEach((t) => { (t.interaction.data.triggerAfter ?? 'any') === e && (t.interaction instanceof bo ? t.interaction.audioPlayer.play() : t.interaction instanceof $m && t.interaction.dispatch()); }), this.actions.Video.forEach((t) => { let i = t.interaction.data.triggerAfter ?? 'autoplay'; i === e && (t.interaction instanceof sh ? t.interaction.play(i === 'autoplay') : t.interaction instanceof eg && t.interaction.dispatch()); }); } dispatchUserEvent(e) { this.actions.Transition.forEach((t) => { t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init()); }), e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent()), this.actions.Audio.forEach((t) => { t.interaction instanceof bo ? t.interaction.audioPlayer.play() : t.interaction instanceof $m && t.interaction.dispatch(); }), this.actions.Video.forEach((t) => { t.interaction instanceof sh ? t.interaction.play() : t.interaction instanceof eg && t.interaction.dispatch(); }); } }, jG = class extends zn { constructor(e) { super(e), (this.eventsPerObject = new Map()), (this.eventsAfterPerObject = new Map()), (this.onMouseDown = () => { [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => { r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), s.forEach((n) => { n.dispatchAfter('mouseDown'); }); }); }), (this.onKeyDown = () => { [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => { r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), s.forEach((n) => { n.dispatchAfter('keyDown'); }); }); }), (this.onAny = () => { let { domElement: r, isExport: s } = this.eventContext; (s ? document : r).removeEventListener('pointerdown', this.onAny), document.removeEventListener('keydown', this.onAny), [...this.eventsAfterPerObject.entries()].forEach(([n, a]) => { n.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), a.forEach((o) => { o.dispatchAfter('any'); }); }); }), (this.onPlay = () => { [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => { r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), s.forEach((n) => { n.dispatchAfter('autoplay'); }); }); }), (this.onUserEvent = ({ eventName: r, target: s, reverse: n }) => { if (!r || !s) return; let a = Uh(r); a && a === 'Start' && (s.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), this.eventsPerObject.get(s)?.forEach((o) => { o.dispatchUserEvent(n); }), this.eventsAfterPerObject.get(s)?.forEach((o) => { o.dispatchUserEvent(n); })); }); let { scene: t, sharedAssets: i } = this.eventContext; t.traverseEntity((r) => { if (r.data?.events.length) for (let { id: s, data: n } of r.data.events) { if (n.disabled || n.type !== 'Start') continue; let a = new kG(s, n, r, t, i); a.actions.Transition.length && (this.eventsPerObject.has(r) ? this.eventsPerObject.get(r)?.push(a) : this.eventsPerObject.set(r, [a])), a.actions.Audio.length && (this.eventsAfterPerObject.has(r) ? this.eventsAfterPerObject.get(r)?.push(a) : this.eventsAfterPerObject.set(r, [a])), a.actions.Video.length && ((this.hasVideoAction = !0), this.eventsAfterPerObject.has(r) ? this.eventsAfterPerObject.get(r)?.push(a) : this.eventsAfterPerObject.set(r, [a])); } }); } connect() { if ([...this.eventsAfterPerObject.values()].some((e) => e.length)) { let { domElement: e, isExport: t } = this.eventContext, i = t ? document : e; i.addEventListener('pointerdown', this.onMouseDown, { once: !0 }), document.addEventListener('keydown', this.onKeyDown, { once: !0 }), i.addEventListener('pointerdown', this.onAny), document.addEventListener('keydown', this.onAny), [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => { r.addEventListener('userEvent', this.onUserEvent); }), this.onPlay(); } [...this.eventsPerObject.entries()].forEach(([e, t]) => { e.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }), t.forEach((i) => i.dispatch()), e.addEventListener('userEvent', this.onUserEvent); }); } disconnect() { if ([...this.eventsAfterPerObject.values()].some((e) => e.length)) { let { domElement: e, isExport: t } = this.eventContext, i = t ? document : e; i.removeEventListener('pointerdown', this.onMouseDown), document.removeEventListener('keydown', this.onKeyDown), i.removeEventListener('pointerdown', this.onAny), document.removeEventListener('keydown', this.onAny), [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => { r.removeEventListener('userEvent', this.onUserEvent), s.forEach((n) => n.disconnect()); }); } [...this.eventsPerObject.entries()].forEach(([e, t]) => { e.removeEventListener('userEvent', this.onUserEvent), t.forEach((i) => i.disconnect()); }); } }, GG = class { constructor(e, t, i, r, s) { (this.id = e), (this.data = t), (this.object = i), (this.disabled = !0), (this.actions = On(t, t.actions, i, r, s)), (this.target = t.target), (this.useToggle = t.toggle); } disconnect() { In(this.actions); } dispatch() { this.disabled || (this.actions.Transition.forEach((e) => { e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init()); }), this.object.dispatchEvent({ type: 'beginEvent', eventName: 'Collision' }), this.useToggle ? this.actions.Transition.forEach((e) => { e.toggle(); }) : this.actions.Transition.forEach((e) => { e.play(); }), this.actions.Link.forEach((e) => { e.dispatch(); }), this.actions.Audio.forEach((e) => { e.dispatchBasic(); }), this.actions.Video.forEach((e) => { e.dispatchBasic(); })); } }, Bt; yN.then((e) => (Bt = e)); var Ri = new E(), on = new ct(), Kn = new E(), wf = new _i(0, 0, 0, 'YXZ'), VG = { type: 'updateMatrix' }, a2 = { type: 'beginEvent', eventName: 'Collision' }; function HG(e) { if (e.scene.environment.usePhysics) return !0; let t = !1; return ( e.scene.objects.traverse((i, r) => { for (let s of r.events) if (s.data.disabled !== !0 && s.data.type === 'GameControl' && s.data.collisionEnabled) { t = !0; break; } }), t ); } var Rb = (e) => e.states.some( (t) => t.data.position !== void 0 || t.data.rotation !== void 0 || t.data.hiddenMatrix !== void 0 || t.data.cloner !== void 0 || t.data.pathSnapping !== void 0 ), Bb = (e) => e.events.find((t) => t.data.disabled !== !0 && t.data.type === 'Follow'), WG = class { constructor(e, t, i, r, s, n = !1) { (this.scene = t), (this.sharedAssets = s), (this.isExport = n), (this.orbitControlsNeedsUpdate = !0), (this.gameControls = []), (this.gameControlStates = []), (this.joysticks = []), (this.joystickToGameControls = []), (this.sharedGameControlGlobals = { entitiesWithTransformAnim: [], eventsPerObjects: {}, colliderToEntity: {}, gamePads: [] }), (this.needsCollisionDetection = !1), (this.initializationCounter = -1), (this.rigidBodyToMesh = new Map()), (this.nActiveRigidBodies = 0), (this.collisionEvents = []), (this.processRigidBody = (m) => { if (m.bodyType() !== Bt.RigidBodyType.Dynamic) return; m.isSleeping() || this.nActiveRigidBodies++; let [v, y, b] = this.rigidBodyToMesh.get(m.handle); if ( (Ri.copy(m.translation()).multiplyScalar(this.pixelsPerMeter), on.copy(m.rotation()), v.matrixWorld.compose(Ri, on, y), v.hasNonUniformScale && v.matrixWorld.multiply(v.shearScale), v.dispatchEvent(VG), b) ) { let x = v.cloner; if (x && x.objectForSample === void 0) { x.matrixWorld.copy(v.matrixWorld); for (let w of x.children) w.updateMatrixWorld(!0); } for (let w of v.children) w.updateMatrixWorld(!0); } }), (this.handleCollisionEvents = (m, v, y) => { if (y !== !1) if (this.gameControls.some((b) => b.object === this.sharedGameControlGlobals.colliderToEntity[m])) { let b = this.sharedGameControlGlobals.colliderToEntity[v], x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid]; if (x === void 0) return; for (let w of x) w.data.target === 'character' && this.dispatchCollisionEvent(w, b); } else if (this.gameControls.some((b) => b.object === this.sharedGameControlGlobals.colliderToEntity[v])) { let b = this.sharedGameControlGlobals.colliderToEntity[m], x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid]; if (x === void 0) return; for (let w of x) w.data.target === 'character' && this.dispatchCollisionEvent(w, b); } else { let b = this.sharedGameControlGlobals.colliderToEntity[m], x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid]; if (x !== void 0) for (let S of x) S.data.target === 'scene' && this.dispatchCollisionEvent(S, b); let w = this.sharedGameControlGlobals.colliderToEntity[v], A = this.sharedGameControlGlobals.eventsPerObjects[w?.uuid]; if (A !== void 0) for (let S of A) S.data.target === 'scene' && this.dispatchCollisionEvent(S, w); } }), (this.domElement = i.domElement); let a; e.scene.publish.playCamera === null ? (a = sl.PERSONAL_CAMERA_ID) : (a = e.scene.publish.playCamera); let o = this.scene.find(a), l = !1, h, u = 5, c = 8, d = 9, p = 'drag'; if ( ((this.usePhysics = e.scene.environment.usePhysics ?? Ki.defaultData.usePhysics), (this.pixelsPerMeter = e.scene.environment.pixelsPerMeter ?? Ki.defaultData.pixelsPerMeter), e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach((m) => { m.data.disabled !== !0 && m.data.type === 'GameControl' && ((h = m.data.keyAssignments), (u = m.data.joystickPosLoc), (c = m.data.joystickRotLoc), (d = m.data.jumpTouchButtonLoc), (p = m.data.rotByTouch)); }), this.scene.traverseEntity((m) => { m.dataPatched.events.forEach((v) => { if (v.data.disabled || v.data.type !== 'GameControl') return; let y = m; for (; (y = y.parent)?.parent !== null; ) if (y.dataPatched.physics?.fusedBody) return; v.data.collisionEnabled && (this.needsCollisionDetection = !0), this.gameControlStates.push([m, v.data]); }); }), this.usePhysics && this.initPhysics(e.scene.environment.gravity ?? Ki.defaultData.gravity), this.gameControlStates.forEach(([m, v]) => { l = l || v.camera === o.uuid || m.uuid === o.uuid; let y = new o2( m, i.domElement, { ...v, keyAssignments: h }, e.scene.environment, this.sharedGameControlGlobals, m.uuid !== o.uuid && v.camera === o.uuid, o, this.scene, s ); y.addEventListener('change', r), y.addEventListener('end', r), y.addEventListener('start', r), this.gameControls.push(y), rr && v.touchControl && (this.joystickToGameControls[u] !== void 0 ? this.joystickToGameControls[u].push([y, 'pos']) : (this.joystickToGameControls[u] = [[y, 'pos']]), v.moveMode === 'walk' && (this.joystickToGameControls[d] !== void 0 ? this.joystickToGameControls[d].push([y, 'jmp']) : (this.joystickToGameControls[d] = [[y, 'jmp']])), p === 'joystick' && (this.joystickToGameControls[c] !== void 0 ? this.joystickToGameControls[c].push([y, 'rot']) : (this.joystickToGameControls[c] = [[y, 'rot']]))); }), l === !1) ) { let { enableRotate: m, enablePan: v, enableZoom: y, autoRotate: b, hoverRotatePanMode: x } = e.scene.publish.orbitControls; (m || v || y || b || x !== 0) && ((this.orbitControls = new l2(o, i.domElement, { isExport: this.isExport, isPlayMode: !0 })), this.orbitControls.addEventListener('change', r), this.orbitControls.addEventListener('end', r), this.orbitControls.addEventListener('start', r), this.orbitControls.fromJSON(e.scene.publish.orbitControls, e.scene.publish.mouseEventTarget), (this.orbitControls.useKeyEvents = !1), this.orbitControls.addEventListenersToCamera(), this.orbitControls.connect(), this.orbitControls.update()); } let f = i.domElement.width / i.getPixelRatio(), g = i.domElement.height / i.getPixelRatio(); this.joystickToGameControls.forEach((m, v) => { let y = document.body.appendChild(document.createElement('div')), [b, x, w] = (e.scene.publish.joystickSizeAndXYOffset ?? Vo.defaultData.joystickSizeAndXYOffset)[v], A = (f - 5 * b) / 4 + b, S = {}, _ = m.some((P) => P[1] === 'jmp'), M = _ ? 0 : b; v < 10 ? (v < 5 ? (S.top = M / 2) : (S.bottom = M / 2), (S.left = M / 2 + (v % 5) * A)) : v === 10 ? ((S.left = M / 2), (S.top = g / 2)) : ((S.right = M / 2), (S.top = g / 2)), S.top ? (S.top -= x[1]) : (S.bottom += x[1]), S.left ? (S.left += x[0]) : (S.right -= x[0]); for (let P in S) S[P] += 'px'; if (_) { let P = y.appendChild(document.createElement('div')); Object.assign(P.style, S, { position: 'absolute', width: b + 'px', height: b + 'px', backgroundColor: `rgba(255,255,255,${w === 'show' ? 0.4 : 0})`, zIndex: '9999', borderRadius: b + 'px', border: w === 'show' ? 'solid 2px rgba(0, 0, 0, .1)' : 'none', display: 'flex', alignItems: 'center', justifyContent: 'center', touchAction: 'none' }); let L = (b / 16) * 16 * 0.4; w === 'show' && (P.innerHTML = ` `), P.addEventListener('pointerdown', () => { m.forEach((D) => { D[0].movementState.jump = 1; }), r(); }), P.addEventListener('touchend', (D) => D.preventDefault()), (this.joysticks[v] = [void 0, y]); return; } let C = { zone: y, mode: 'static', position: S, size: b }; w === 'hide' && (C.restOpacity = 0); let T = q8.create(C); T.on('move', (P, L) => { m.forEach((D) => { let k = D[0]; D[1] === 'pos' ? L.force < 0.2 ? (k.moveForce = 0) : ((k.movementState.movePosZ = Math.sin(-L.angle.radian)), (k.movementState.movePosX = Math.cos(-L.angle.radian)), L.force < 0.3 ? (k.moveForce = (L.force - 0.2) / 0.1) : (k.moveForce = 1)) : L.force < 0.2 ? (k.rotForce = 0) : ((k.movementState.rotPosX = L.vector.y), (k.movementState.rotPosY = -L.vector.x), L.force < 0.3 ? (k.rotForce = (L.force - 0.2) / 0.1) : (k.rotForce = 1)); }), r(); }), T.on('end', (P, L) => { m.forEach((D) => { let k = D[0]; D[1] === 'pos' ? ((k.movementState.movePosZ = 0), (k.movementState.movePosX = 0), (k.moveForce = 1)) : ((k.movementState.rotPosX = 0), (k.movementState.rotPosY = 0), (k.rotForce = 1)); }); }), (this.joysticks[v] = [T, y]); }), this.usePhysics === !1 && this.needsCollisionDetection && this.initBVH(), this.initializationCounter++, window.setTimeout(() => this.collisionEvents.forEach((m) => (m.disabled = !1)), 80); } attachVRControllers(e) { e.forEach((t) => { t.addEventListener('connected', (i) => { 'gamepad' in i.data && 'axes' in i.data.gamepad && this.sharedGameControlGlobals.gamePads.push(i.data.gamepad); }); }); } initBVH() { let e = []; if ( (this.scene.traverseObject((t) => { let i; if (t instanceof eu) return; t instanceof la ? (i = t.object) : (i = t); let r = i.dataPatched; if (!r.visible || Bb(r)) return !0; let s = t.geometry; if (Rb(r) || i.dataPatched.events.some((n) => n.data.disabled !== !0 && n.data.type === 'GameControl')) { t.updateMatrixWorldSVD(); let n = []; if ( (s?.getAttribute('position') !== void 0 && n.push(eo(s, t.shearScale)), t.traverseObject(this.gatherChildrenGeom(t, n)), t.children.forEach((a) => a.updateMatrixWorld(!0)), n.length > 0) ) { let a = go(n, !1); (t.boundsTree = new gi(a)), this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t); } return !0; } else s && e.push(eo(s, t.matrixWorld)); }), e.length > 0) ) { let t = go(e, !1); this.sharedGameControlGlobals.staticMeshBVH = new gi(t); } } addCollider(e, t, i, r, s, n = !0) { if (r?.getAttribute('position').count === 0 || r?.getIndex()?.count === 0) return; let a; s !== void 0 ? s.collider.type === 'sphere' ? (a = Bt.ColliderDesc.ball(s.collider.radius / this.pixelsPerMeter)) : s.collider.type === 'capsule' ? (a = Bt.ColliderDesc.capsule( (s.collider.height / 2 - s.collider.radius) / this.pixelsPerMeter, s.collider.radius / this.pixelsPerMeter )) : (a = Bt.ColliderDesc.cuboid( s.collider.width / this.pixelsPerMeter / 2, s.collider.height / this.pixelsPerMeter / 2, s.collider.depth / this.pixelsPerMeter / 2 )) : r && (i.colliderType === 'trimesh' ? (a = Bt.ColliderDesc.trimesh(r.getAttribute('position').array, r.getIndex().array)) : (a = Bt.ColliderDesc.convexMesh(r.getAttribute('position').array, n ? r.getIndex().array : void 0))), a .setFrictionCombineRule(Bt.CoefficientCombineRule.Average) .setRestitutionCombineRule(Bt.CoefficientCombineRule.Average) .setDensity(i.density) .setFriction(i.friction) .setRestitution(i.restitution); let o = this.sharedGameControlGlobals.rapierWorld.createCollider(a, t); if (((this.sharedGameControlGlobals.colliderToEntity[o.handle] = e), s !== void 0)) { Ri.fromArray(s.collider.position).multiply(Kn.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter), o.setTranslationWrtParent(Ri); let l = new ct().setFromEuler(new _i().setFromVector3(new E().fromArray(s.collider.rotation))); o.setRotationWrtParent(l), o.setActiveEvents(Bt.ActiveEvents.COLLISION_EVENTS); } else this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some((l) => l.target === 'scene') && o.setActiveEvents(Bt.ActiveEvents.COLLISION_EVENTS); } gatherChildrenGeom(e, t) { return (i, r) => { if (r === 0) return; r === 1 ? e.hasNonUniformScale ? i.matrixWorld.multiplyMatrices(e.shearScale, i.hiddenMatrix) : i.matrixWorld.copy(i.hiddenMatrix) : i.matrixWorld.multiplyMatrices(i.parent.matrixWorld, i.hiddenMatrix), i.matrixWorld.multiply(i.matrix); let s = i.geometry; s?.getAttribute('position') !== void 0 && t.push(eo(s, i.matrixWorld)); }; } initPhysics(e) { (this.sharedGameControlGlobals.rapierWorld = new Bt.World(new Bt.Vector3(0, e ?? -10, 0))), (this.events = new Bt.EventQueue(!0)); let t = []; if ( (this.scene.traverseObject((a) => { let o; if (a instanceof eu) if (a.objectForSample) { if (a.objectForSample.dataPatched.physics.fusedBody) return; o = a.object; } else return a.object.dataPatched.physics.fusedBody === !0 && a.object.dataPatched.physics.rigidBody === 'dynamic' ? !0 : void 0; else a instanceof la ? (o = a.object) : (o = a); let l = o.dataPatched; if (!l.physics || !l.visible) return !0; a.updateMatrixWorldSVD(); let h = Rb(l), u = Bb(l), c, d = !1; for (let f of l.events) if (f.data.disabled !== !0) { if (f.data.type === 'GameControl') c = f.data; else if (f.data.type === 'Collision') { d = !0; let g = new GG(f.id, f.data, o, this.scene, this.sharedAssets); this.collisionEvents.push(g), this.sharedGameControlGlobals.eventsPerObjects[o.uuid] ? this.sharedGameControlGlobals.eventsPerObjects[o.uuid].push(g) : (this.sharedGameControlGlobals.eventsPerObjects[o.uuid] = [g]); } } l.physics.rigidBody === 'dynamic' && l.physics.fusedBody === !1 && (a.matrixWorldFusedFalse = a.matrixWorld.clone()); let p = a.geometry; if (l.physics.rigidBody === 'dynamic' || h || u || d || c !== void 0) { let f = []; if ((p?.getAttribute('position') !== void 0 && f.push(eo(p, a.shearScale)), l.physics.fusedBody)) { let g = this.gatherChildrenGeom(a, f); a.traverseObject(g), a.children.forEach((v) => v.updateMatrixWorld(!0)); let m = a.cloner; m && m.objectForSample === void 0 && l.physics.rigidBody === 'dynamic' && (m.traverseObject(g), m.children.forEach((v) => v.updateMatrixWorld(!0))); } if (f.length > 0 || c !== void 0) { let g; c !== void 0 ? (g = Bt.RigidBodyDesc.kinematicPositionBased()) : l.physics.rigidBody === 'dynamic' ? ((g = Bt.RigidBodyDesc.dynamic()), g .setLinearDamping(l.physics.damping) .setAdditionalMass(1e-9) .setGravityScale(l.physics.gravityScale) .enabledRotations(...l.physics.enabledRotation) .enabledTranslations(...l.physics.enabledTranslation)) : h || u ? ((g = Bt.RigidBodyDesc.kinematicPositionBased()), this.sharedGameControlGlobals.entitiesWithTransformAnim.push(a)) : (g = Bt.RigidBodyDesc.fixed()); let m; (m = f.length > 0 ? go(f) : void 0), (a.hasNonUniformScale ? a.matrixWorldRigid : a.matrixWorld).decompose(Ri, on, Kn), (a.position0 = Ri.clone().divideScalar(this.pixelsPerMeter)), (a.rotation0 = on.clone()), Ri.divideScalar(this.pixelsPerMeter), g.setTranslation(Ri.x, Ri.y, Ri.z).setRotation(on), p ? m?.scale(1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter) : m?.scale(Kn.x / this.pixelsPerMeter, Kn.y / this.pixelsPerMeter, Kn.z / this.pixelsPerMeter); let v = this.sharedGameControlGlobals.rapierWorld.createRigidBody(g); c === void 0 && l.physics.rigidBody === 'dynamic' && this.rigidBodyToMesh.set(v.handle, [a, Kn.clone(), l.physics.fusedBody]), (a.rigidBody = v); let y = !( l.geometry === void 0 || l.geometry.type === 'SubdivGeometry' || l.geometry.type === 'NonParametricGeometry' || l.geometry.type === 'BooleanGeometry' || l.geometry.type === 'VectorGeometry' || l.geometry.type === 'StarGeometry' || l.geometry.type === 'RectangleGeometry' || l.geometry.type === 'EllipseGeometry' || l.geometry.type === 'TriangleGeometry' || l.geometry.type === 'TorusGeometry' || l.geometry.type === 'HelixGeometry' ); try { this.addCollider(o, v, l.physics, m, c, y); } catch { try { this.addCollider(o, v, l.physics, m, c, !1); } catch (b) { console.error(b); } } } } else p && t.push(eo(p, a.matrixWorld)), l.physics.fusedBody && a.traverse((f) => { !f.geometry || f === a || t.push(eo(f.geometry, f.matrixWorld)); }); if (l.physics?.fusedBody === !0 || c) return !0; }), t.length === 0) ) return; let i = go(t); i.scale(1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter); let r = Bt.RigidBodyDesc.fixed(), s = this.sharedGameControlGlobals.rapierWorld.createRigidBody(r), n = Bt.ColliderDesc.trimesh(i.getAttribute('position').array, i.getIndex().array) .setFrictionCombineRule(Bt.CoefficientCombineRule.Multiply) .setRestitutionCombineRule(Bt.CoefficientCombineRule.Multiply) .setFriction(1) .setRestitution(1); this.sharedGameControlGlobals.rapierWorld.createCollider(n, s); } updatePositions() { return ( (this.nActiveRigidBodies = 0), this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody), this.nActiveRigidBodies > 0 ); } dispose() { this.scene.traverse((e) => { let t = e; t.matrixWorldFusedFalse && (t.matrixWorldFusedFalse = void 0), t.rigidBody && (t.rigidBody = void 0), t.position0 && (t.position0 = void 0), t.rotation0 && (t.rotation0 = void 0); }), this.sharedGameControlGlobals.rapierWorld?.free(), (this.sharedGameControlGlobals.staticMeshBVH = void 0), (this.sharedGameControlGlobals.entitiesWithTransformAnim = []), this.gameControls.forEach((e) => { e.reset(), e.dispose(); }), (this.gameControls = []), this.joysticks.forEach(([e, t]) => { e?.destroy(), t.remove(); }), (this.joystickToGameControls = []), (this.joysticks = []), this.orbitControls && (this.orbitControls.dispose(), (this.orbitControls = void 0)); for (let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects)) e.forEach((t) => t.disconnect()); (this.sharedGameControlGlobals.eventsPerObjects = {}), this.scene.updateMatrixWorld(!0); } update(e, t, i) { let r = !0; if ( (this.orbitControls !== void 0 && this.orbitControls.needsUpdate && (r = !this.orbitControls.update()), this.initializationCounter >= 0 && this.initializationCounter < 2) ) this.initializationCounter++, (r = !1); else if (this.initializationCounter === 2) for (let s of this.gameControls) r = !s.update(e, t, i) && r; if (this.usePhysics) { for (let s of this.sharedGameControlGlobals.entitiesWithTransformAnim) { (s.hasNonUniformScale ? s.matrixWorldRigid : s.matrixWorld).decompose(Ri, on, Kn), wf.setFromQuaternion(on); let n = s; n.prevR === void 0 ? ((n.prevR = wf.clone()), (n.prevT = Ri.clone())) : (n.prevR.copy(wf), n.prevT.copy(Ri)), s.rigidBody.setNextKinematicTranslation(Ri.divideScalar(this.pixelsPerMeter)), s.rigidBody.setNextKinematicRotation(on); } this.sharedGameControlGlobals.rapierWorld.step(this.events), this.events?.drainCollisionEvents(this.handleCollisionEvents), (r = !this.updatePositions() && r); } return r; } dispatchCollisionEvent(e, t) { t.dispatchEvent(a2), e.dispatch(); } updateUseWindowEvents(e) { this.orbitControls?.updateUseWindowEvents(e); } }, _f = { type: 'change' }, XG = { type: 'lock' }, qG = { type: 'unlock' }, N9 = new E(), zb = new E(), Nb = new E(), YG = new E(), Di = new E(), Qi = new E(), ln = new E(), Af = new ve(), Ub = new ve(), QG = new ve(), U9 = new ve(), Br = new ct(), Ns = new ct(), es = new _i(0, 0, 0, 'YXZ'), ZG = new E(1, 0, 0), zr = new E(0, 1, 0), KG = new E(0, 0, 1), Fb = new E(1, 1, 1), JG = 1, $G = 0.025, eV = 16e-6, kb = 12, tV = 20, xi = new _r(), pr = new Kt(), iV = { type: 'requestRender' }, jb = Math.PI / 6, rg = class extends Vi { constructor(e, t, i, r, s, n, a, o, l) { super(), (this.object = e), (this.domElement = t), (this.sharedGameControlGlobals = s), (this.cameraFollow = n), (this.camera = a), (this.scene = o), (this.sharedAssets = l), (this.enableDamping = !0), (this.position0 = new E()), (this.rotation0 = new _i(0, 0, 0, 'XYZ')), (this.scale0 = new E()), (this.hiddenMatrix0 = new ve()), (this.target0 = new E()), (this.zoom0 = 1), (this.rotForce = 1), (this.moveForce = 1), (this.euler0 = new _i(0, 0, 0, 'YXZ')), (this.position0Cam = new E()), (this.quat0Cam = new ct()), (this.scale0Cam = new E()), (this.hiddenMatrix0Cam = new ve()), (this.threshEndTranslate = 0.01), (this.threshEndRotate = 1e-8), (this.threshEndRotVel = 0.005), (this.collider = { type: 'capsule', radius: 40, segment: new _r(new E(0, -40, 0), new E(0, 40, 0)), matrix: new ve(), position: new E(), rotation: new ct() }), (this.euler = new _i(0, 0, 0, 'YXZ')), (this.eulerDelta = new E()), (this.lastPosition = new E()), (this.lastCameraQuaternion = new ct()), (this.lastCameraPosition = new E()), (this.PI_2 = Math.PI / 2), (this.prevMouse = new G()), (this.velocityTarget = new E()), (this.velocity = new E()), (this.directionXZ = new E()), (this.rotVelocityStick = new E()), (this.rotVelocityTarget = new E()), (this.rotVelocity = new E()), (this.rotDirection = new E()), (this.nonColliderRotOffset = new ve()), (this.nonColliderPosOffset = new ve()), (this.firstPointerId = -1), (this.rot = new E()), (this.movementState = { moveNegZ: 0, movePosZ: 0, moveNegX: 0, movePosX: 0, moveNegY: 0, movePosY: 0, rotPosX: 0, rotNegX: 0, rotPosY: 0, rotNegY: 0, jump: 0 }), (this.vrEulerYOffset = 0), (this.onObject = !1), (this.actionState = {}), (this.keyAssignments = [ ['moveNegZ', 'W'], ['moveNegX', 'A'], ['movePosZ', 'S'], ['movePosX', 'D'], ['rotPosX', 'ArrowUp'], ['rotPosY', 'ArrowLeft'], ['rotNegX', 'ArrowDown'], ['rotNegY', 'ArrowRight'], ['jump', ' '] ]), (this.collisionEnabled = !0), (this.offsetMatrix = new ve()), (this.objectToTarget = new E()), (this.objectToTarget0 = new E()), (this.objectToCamXZ = new E()), (this.objectToCamXZ0 = new E()), (this.targetToCamera = new E()), (this.targetToCamera0 = new E()), (this.cameraPolarAxis0 = new E()), (this.targetPos = new E()), (this.targetQuat = new ct()), (this.lerpFactorPos = new E().setScalar(0.3)), (this.lerpFactorPosStart = 0.3), (this.lerpFactorPosEnd = 0.3), (this.lerpFactorRotStart = 0.3), (this.lerpFactorRotEnd = 0.3), (this.lerpFactorPosCamera = 0.3), (this.lerpFactorRotCamera = 0.3), (this.objXZQuat = new ct()), (this.objXZQuatInv = new ct()), (this.objXZRotMat = new ve()), (this.isFirstPerson = !1), (this.actions = {}), (this.didHit = !1), (this.groundVelocity = new E()), (this.pushedVelocity = new E()), (this.groundYRotation = 0), (this.objectRealQuat = new ct()), (this.colliderWorldQuat = new ct()), (this.groundNormal = new E()), (this.groundTilt = new ct()), (this.groundTiltInv = new ct()), (this.lastHitObj = null), (this.isFirstFrame = !0), (this.rotationAccumWhenOrientWithCamera = 0), (this.onPointerDown = (f) => { f.target !== this.domElement || this.firstPointerId !== -1 || ((this.firstPointerId = f.pointerId), this.domElement.ownerDocument.addEventListener('pointermove', this.onPointerMove), this.domElement.ownerDocument.addEventListener('pointerup', this.onPointerUp), this.rotBy !== 'keys' && !rr && (!V1 || H1 >= 15.5) && this.domElement.requestPointerLock(), this.prevMouse.set(f.clientX, f.clientY)); }), (this.onPointerUp = (f) => { (this.firstPointerId = -1), this.domElement.ownerDocument.removeEventListener('pointermove', this.onPointerMove), this.domElement.ownerDocument.removeEventListener('pointerup', this.onPointerUp), f.pointerType === 'mouse' && this.domElement.ownerDocument.exitPointerLock(); }), (this.onPointerMove = (f) => { if (f.pointerId !== this.firstPointerId) return; let g = f.clientX - this.prevMouse.x, m = f.clientY - this.prevMouse.y; this.prevMouse.set(f.clientX, f.clientY), f.pointerType === 'mouse' && this.rotBy !== 'keys' && (V1 && H1 < 15.5 && !rr ? ((this.eulerDelta.y = -g * this.mouseOrbitSensitivity), (this.eulerDelta.x = -m * this.mouseOrbitSensitivity)) : ((this.eulerDelta.y = -f.movementX * this.mouseOrbitSensitivity), (this.eulerDelta.x = -f.movementY * this.mouseOrbitSensitivity))), f.pointerType !== 'mouse' && this.rotByTouch === 'drag' && ((this.eulerDelta.y = -g * this.mouseOrbitSensitivity * 5), (this.eulerDelta.x = -m * this.mouseOrbitSensitivity * 5)), this.dispatchEvent(_f); }), (this.onPointerlockChange = (f) => { this.domElement.ownerDocument.pointerLockElement === this.domElement ? (this.dispatchEvent(XG), (rg.isLocked = !0)) : (this.dispatchEvent(qG), (rg.isLocked = !1)); }), (this.onPointerlockError = () => { console.error('SPE.GameControls: Unable to use Pointer Lock API'); }), (this.onKeyDown = (f) => { !(f.target instanceof HTMLInputElement) && (f.code === 'ArrowLeft' || f.code === 'ArrowUp' || f.code === 'ArrowRight' || f.code === 'ArrowDown' || f.code === 'Space') && f.preventDefault(); for (let g of this.keyAssignments) if (f.key.toUpperCase() === g[1] || f.key === g[1]) { this.movementState[g[0]] = 1; break; } this.dispatchEvent(_f); }), (this.onKeyUp = (f) => { for (let g of this.keyAssignments) if (f.key.toUpperCase() === g[1] || f.key === g[1] || f.code.slice(3, f.code.length).toUpperCase() === g[1]) { this.movementState[g[0]] = 0; break; } }), (this.copyVRGamePadValues = (f, g) => { for (let m = 2; m < 4; m++) { let v = f.axes[m]; g === 0 ? m === 2 ? (this.movementState.movePosX = v) : (this.movementState.movePosZ = v) : (f.buttons[3].pressed ? (this.movementState.jump = 1) : (this.movementState.jump = 0), m === 2 ? (Math.abs(this.movementState.rotPosY) < 0.3 && Math.abs(v) >= 0.3 && (this.vrEulerYOffset += v < 0 ? 1 : -1), (this.movementState.rotPosY = v)) : this.moveMode === 'fly' && (this.movementState.moveNegY = v)); } }), e === a && (this.isFirstPerson = !0), this.position0.copy(this.object.position), this.rotation0.copy(this.object.rotation), this.scale0.copy(this.object.scale), this.hiddenMatrix0.copy(this.object.hiddenMatrix), this.object.parent ? this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert() : this.object.hiddenMatrix.identity(), this.object.matrix.copy(this.object.matrixWorld), this.object.matrix.decompose(this.object.position, this.object.quaternion, this.object.scale), this.object.rotation.reorder('YXZ'), this.euler0.copy(this.object.rotation); let h = this.object.rotation.y; if ( (this.objectRealQuat.copy(this.object.quaternion), (this.object.rotation.y = 0), this.objXZQuat.copy(this.object.quaternion), this.objXZQuatInv.copy(this.objXZQuat).invert(), this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion), this.object.rotation.set(0, h, 0), this.rot.setFromEuler(this.object.rotation), (this.object.matrixAutoUpdate = !1), (this.isFirstPerson || this.cameraFollow === !0) && (this.target0.copy(this.camera.getTarget()), (this.zoom0 = this.camera.zoom)), this.cameraFollow === !0) ) { this.position0Cam.copy(this.camera.position), this.quat0Cam.copy(this.camera.quaternion), this.scale0Cam.copy(this.camera.scale), this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix), this.camera.parent ? (this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld), this.camera.matrix.copy(this.camera.matrixWorld)) : this.camera.hiddenMatrix.identity(), this.camera.matrix.copy(this.camera.matrixWorld), this.camera.matrix.decompose(this.camera.position, this.camera.quaternion, this.camera.scale), (this.camera.matrixAutoUpdate = !1), this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix); let f = new E(0, 0, -1).applyQuaternion(this.camera.quaternion), g = new E().subVectors(this.object.position, this.camera.position); this.objectToCamXZ.copy(g), (this.objectToCamXZ.y = 0), this.objectToCamXZ0.copy(this.objectToCamXZ); let m, v; Math.abs(f.y) < 1e-6 ? ((g.y = 0), (f.y = 0), (v = g.projectOnVector(f))) : g.y / f.y > 0 ? (v = f.multiplyScalar(g.y / f.y)) : (v = f.multiplyScalar(g.length())), this.targetToCamera0.copy(v).negate(), (m = this.camera.position.clone().add(v)), this.objectToTarget0.subVectors(m, this.object.position); let y = new _i().setFromQuaternion(this.camera.quaternion, 'YXZ'); (this.cameraPolarOffset = -y.x), (y.x = 0), (y.z = 0), (y.y -= Math.PI / 2), this.cameraPolarAxis0.set(0, 0, -1).applyEuler(y); } if ( (this.object instanceof Gi && (this.object.matrixAutoUpdate = !1), this.euler.setFromQuaternion(this.object.quaternion, 'YXZ'), this.connect(), (this.rotByTouch = i.rotByTouch ?? 'joystick'), (this.rotBy = i.rotBy ?? 'keys'), (this.rotationMode = i.rotationMode ?? 'normal'), (this.moveMode = i.moveMode ?? 'walk'), (this.collisionEnabled = i.collisionEnabled), (this.speedTranslate = (i.speedTranslate ?? 250) * JG), (this.speedOrbit = (i.speedRotate ?? 100) * $G), (this.mouseOrbitSensitivity = (i.speedRotate ?? 100) * eV), (this.keyAssignments = i.keyAssignments.map((f) => { let g = [f[0], f[1]]; return ( g[1] === '▲' ? (g[1] = 'ArrowUp') : g[1] === '◀' ? (g[1] = 'ArrowLeft') : g[1] === '▼' ? (g[1] = 'ArrowDown') : g[1] === '▶' ? (g[1] = 'ArrowRight') : g[1] === '⇧' ? (g[1] = 'Shift') : g[1] === '↵' ? (g[1] = 'Enter') : g[1] === 'Space' ? (g[1] = ' ') : g[1] === '⌘' ? (g[1] = 'Meta') : g[1] === 'Ctrl' ? (g[1] = 'Control') : g[1] === 'Esc' && (g[1] = 'Escape'), g ); })), i.rotBy === 'mouse') ) { let f; (f = this.keyAssignments.findIndex((g) => g[0] === 'rotNegX')), f !== -1 && (this.keyAssignments[f][1] = ''), (f = this.keyAssignments.findIndex((g) => g[0] === 'rotPosX')), f !== -1 && (this.keyAssignments[f][1] = ''), (f = this.keyAssignments.findIndex((g) => g[0] === 'rotPosY')), f !== -1 && (this.keyAssignments[f][1] = ''), (f = this.keyAssignments.findIndex((g) => g[0] === 'rotNegY')), f !== -1 && (this.keyAssignments[f][1] = ''); } (this.lerpFactorPosStart = 1 - 0.02 ** (1 / ((i.delayPos[0] ?? 0.3) * 60))), (this.lerpFactorPosEnd = 1 - 0.02 ** (1 / ((i.delayPos[1] ?? 0.3) * 60))), this.lerpFactorPos.setScalar(this.lerpFactorPosStart), (this.lerpFactorRotStart = 1 - 0.02 ** (1 / ((i.delayRot[0] ?? 0.3) * 60))), (this.lerpFactorRotEnd = 1 - 0.02 ** (1 / ((i.delayRot[1] ?? 0.3) * 60))), (this.lerpFactorPosCamera = 1 - 0.02 ** (1 / ((i.delayPosCamera ?? 0.3) * 60))), (this.lerpFactorRotCamera = 1 - 0.02 ** (1 / ((i.delayRotCamera ?? 0.3) * 60))), (this.gravity = (r.gravity ?? Ki.defaultData.gravity) * kb), (this.pixelsPerMeter = r.pixelsPerMeter ?? Ki.defaultData.pixelsPerMeter), (this.usePhysics = r.usePhysics ?? Ki.defaultData.usePhysics), (this.jumpPower = i.jumpPower * tV), (this.resetYPosition = this.object.position.y + Math.abs(i.resetYPosition) * (this.gravity > 0 ? 1 : -1)), (this.alignToGround = i.alignToGround ?? !1), (this.orientMode = i.autoOrientMove ? i.orientMode : 'none'), (this.orientWith = i.orientWith ?? Cm.defaultDataThirdPerson.orientWith); let u = r.skinWidthRelative ?? Ki.defaultData.skinWidthRelative, c = r.stepThreshRelative ?? Ki.defaultData.stepThreshRelative; (this.slopeThresh = ((r.slopeThresh ?? Ki.defaultData.slopeThresh) * Math.PI) / 180), i.collider.type === 'capsule' ? ((this.collider.radius = i.collider.radius), (this.collider.segment.start.y = i.collider.height / 2 - i.collider.radius), (this.collider.segment.end.y = -this.collider.segment.start.y), (this.offset = (i.collider.height * u) / this.pixelsPerMeter), (this.stepThresh = (i.collider.height * c) / this.pixelsPerMeter)) : i.collider.type === 'sphere' ? ((this.collider.radius = i.collider.radius), (this.collider.segment.start.y = 0), (this.collider.segment.end.y = 0), (this.offset = (2 * i.collider.radius * u) / this.pixelsPerMeter), (this.stepThresh = (2 * i.collider.radius * c) / this.pixelsPerMeter)) : ((this.offset = (i.collider.height * u) / this.pixelsPerMeter), (this.stepThresh = (i.collider.height * c) / this.pixelsPerMeter)), (this.collider.type = i.collider.type); let d = new E().fromArray(i.collider.position), p = new ct().setFromEuler(new _i().fromArray([...i.collider.rotation, 'XYZ'])); this.collider.position.copy(d).multiply(this.object.scale), this.collider.rotation.copy(p), this.collider.matrix.compose(d, p, Fb), i.cameraXAxis !== void 0 && ((this.cameraXAxis = i.cameraXAxis), (this.cameraYAxis = i.cameraYAxis), (this.minPolarAngle = i.cameraRotXLimits[0]), (this.maxPolarAngle = i.cameraRotXLimits[1]), (this.minAzimuthAngleRel = i.cameraRotYLimits[0]), (this.maxAzimuthAngleRel = i.cameraRotYLimits[1])), i.gameActions !== void 0 && Object.entries(i.gameActions).forEach(([f, g], m) => { g.forEach(({ id: v, data: y }) => { try { this.actions[f] === void 0 && (this.actions[f] = []), y.type === 'Transition' ? this.actions[f].push(new _o(y, o, l)) : y.type === 'Audio' ? this.actions[f].push(new wo(v, y, e, l)) : y.type === 'Video' && this.actions[f].push(new ru(v, y, e)); } catch {} }); }), this.dispatchStopEvent('move'), this.dispatchStopEvent('jump'), this.dispatchStartEvent('idle'); } reset(e = !1) { if ( (this.object.rotation.copy(this.rotation0), this.object.position.copy(this.position0), this.object.scale.copy(this.scale0), this.object.hiddenMatrix.copy(this.hiddenMatrix0), e === !0) ) { this.object.updateMatrix(), this.object.updateMatrixWorld(), this.object.matrix.copy(this.object.matrixWorld), this.object.matrix.decompose(this.object.position, this.object.quaternion, this.object.scale), this.object.parent ? this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert() : this.object.hiddenMatrix.identity(), this.object.rotation.reorder('YXZ'); let t = this.object.rotation.y; (this.object.rotation.y = 0), this.objXZQuat.copy(this.object.quaternion), this.objXZQuatInv.copy(this.objXZQuat).invert(), this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion), this.object.rotation.set(0, t, 0), this.rot.setFromEuler(this.object.rotation), this.euler.setFromQuaternion(this.object.quaternion, 'YXZ'), this.velocityTarget.set(0, 0, 0), this.velocity.set(0, 0, 0); } e === !1 && (this.object instanceof Gi ? (this.object.matrixAutoUpdate = !0) : this.object.updateMatrix()), this.cameraFollow === !0 && (this.camera.quaternion.copy(this.quat0Cam), this.camera.position.copy(this.position0Cam), this.camera.scale.copy(this.scale0Cam), this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam), (this.camera.matrixAutoUpdate = !0)), this.dispatchEvent(_f); } connect() { this.domElement.ownerDocument.addEventListener('pointerdown', this.onPointerDown), this.domElement.ownerDocument.addEventListener('keydown', this.onKeyDown), this.domElement.ownerDocument.addEventListener('keyup', this.onKeyUp), this.domElement.ownerDocument.addEventListener('pointerlockchange', this.onPointerlockChange), this.domElement.ownerDocument.addEventListener('pointerlockerror', this.onPointerlockError); } disconnect() { this.domElement.ownerDocument.removeEventListener('pointerdown', this.onPointerDown), this.domElement.ownerDocument.removeEventListener('keydown', this.onKeyDown), this.domElement.ownerDocument.removeEventListener('keyup', this.onKeyUp), this.domElement.ownerDocument.removeEventListener('pointerlockchange', this.onPointerlockChange), this.domElement.ownerDocument.removeEventListener('pointerlockerror', this.onPointerlockError); } dispose() { this.disconnect(), Object.values(this.actions).forEach((e) => { e.forEach((t) => { (t instanceof _o || t instanceof wo || t instanceof ru) && t.dispose(); }); }); } dispatchStartEvent(e) { this.actions[e] !== void 0 && (this.actionState[e] || ((this.actionState[e] = !0), this.actions[e].forEach((t) => { t instanceof _o ? t.play() : t instanceof wo && t.dispatchGameControl('start'); }))); } dispatchStopEvent(e) { this.actions[e] !== void 0 && (!this.actionState[e] || ((this.actionState[e] = !1), this.actions[e].forEach((t) => { t instanceof _o ? t.stop() : t instanceof wo && t.dispatchGameControl('stop'); }), this.object.traverseEntity((t) => { t.currentState !== null && t.changeSelectedState(null, { scene: this.scene, shared: this.sharedAssets }); }))); } update(e, t, i) { if (this.gravity < 0 ? this.object.position.y < this.resetYPosition : this.object.position.y > this.resetYPosition) return this.reset(!0), !0; this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues); let r = (this.isFirstFrame ? 16.6 : e) / 1e3; this.isFirstFrame && (this.isFirstFrame = !1); let s = r * 60, n = !1; if (this.usePhysics && this.collisionEnabled) { let o = Qi.set( 0, (this.velocity.y === 0 ? this.pixelsPerMeter * Math.max(Math.abs(this.gravity) / (10 * kb), 1) * (this.gravity > 0 ? 1 : -1) : this.velocity.y) * r, 0 ).divideScalar(this.pixelsPerMeter), l = this.sharedGameControlGlobals.rapierWorld.castShape( Di.copy(this.collider.position) .applyQuaternion(this.objectRealQuat) .add(this.object.position) .divideScalar(this.pixelsPerMeter), this.colliderWorldQuat, o, this.object.rigidBody?.collider(0).shape, 1, !1, void 0, void 0, void 0, this.object.rigidBody ); if (l) { (this.onObject = !0), this.groundNormal.set(l.normal2.x, l.normal2.y, l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(), this.alignToGround && this.groundTiltAdjustment(this.groundNormal), Math.acos(this.groundNormal.y) < this.slopeThresh && (n = !0), l.collider.parent()?.bodyType() === 0 && Math.acos(this.groundNormal.y) * (180 / Math.PI) > 45 && (this.onObject = !1); let h = l.collider.parent(); (this.groundYRotation = 0), this.groundVelocity.set(0, 0, 0); for (let u of this.sharedGameControlGlobals.entitiesWithTransformAnim) if (u.rigidBody === h) { (u.hasNonUniformScale ? u.matrixWorldRigid : u.matrixWorld).decompose(Di, Ns, Qi), this.groundVelocity.subVectors(Di, u.prevT), this.object.getWorldPosition(Qi).add(this.collider.position).sub(u.position), (this.groundYRotation = es.setFromQuaternion(Ns).y - u.prevR.y), ln.copy(Qi).applyAxisAngle(zr, this.groundYRotation), this.groundVelocity.add(ln.sub(Qi)).divideScalar(r); break; } } else this.onObject = !1; } this.moveMode === 'walk' && this.collisionEnabled && (this.movementState.jump === 1 && this.onObject && ((this.velocityTarget.y = this.jumpPower), (this.movementState.jump = 0), this.dispatchStopEvent('idle'), this.dispatchStopEvent('move'), this.dispatchStopEvent('jump'), this.dispatchStartEvent('jump'), (this.onObject = !1)), this.onObject ? (this.velocityTarget.y /= 2) : (this.velocityTarget.y += this.gravity * s)), this.moveMode === 'fly' && (this.velocityTarget.y = (this.movementState.movePosY - this.movementState.moveNegY) * this.speedTranslate), (this.directionXZ.z = this.movementState.movePosZ - this.movementState.moveNegZ), (this.directionXZ.x = this.movementState.movePosX - this.movementState.moveNegX), this.directionXZ.normalize(), this.movementState.moveNegZ || this.movementState.movePosZ ? (this.velocityTarget.z = this.directionXZ.z * this.speedTranslate * this.moveForce) : (this.velocityTarget.z = 0), this.movementState.moveNegX || this.movementState.movePosX ? (this.velocityTarget.x = this.directionXZ.x * this.speedTranslate * this.moveForce) : (this.velocityTarget.x = 0), (this.moveMode === 'walk' ? this.velocityTarget.x + this.velocityTarget.z === 0 : this.velocityTarget.manhattanLength() === 0) ? this.lerpFactorPos.setScalar(this.lerpFactorPosEnd) : this.lerpFactorPos.setScalar(this.lerpFactorPosStart), this.moveMode === 'walk' && (this.lerpFactorPos.y = 1), (this.didHit === !1 && this.pushedVelocity.manhattanLength() === 0) || this.usePhysics === !1 ? ((this.velocity.x += (this.velocityTarget.x - this.velocity.x) * (1 - (1 - this.lerpFactorPos.x) ** s)), (this.velocity.y += (this.velocityTarget.y - this.velocity.y) * (1 - (1 - this.lerpFactorPos.y) ** s)), (this.velocity.z += (this.velocityTarget.z - this.velocity.z) * (1 - (1 - this.lerpFactorPos.z) ** s))) : this.velocity.copy(this.velocityTarget), ( this.moveMode === 'walk' ? this.velocity.x ** 2 + this.velocity.z ** 2 < this.speedTranslate : this.velocity.lengthSq() < this.speedTranslate ) ? (this.dispatchStopEvent('move'), this.onObject && (this.dispatchStopEvent('jump'), this.dispatchStartEvent('idle'))) : (this.dispatchStopEvent('idle'), this.onObject && (this.dispatchStopEvent('jump'), this.dispatchStartEvent('move'))); let a = YG.copy(this.velocity); if (this.orientMode !== 'none' && this.isFirstPerson === !1) { let o = Qi.copy(a); (o.y = 0), a.set(0, a.y, o.length() * -1); } if ( (es.setFromVector3(this.rot), this.moveMode === 'walk' && (es.x = 0), a.applyEuler(es), n && (Ns.setFromUnitVectors(zr, this.groundNormal), a.applyQuaternion(Ns)), i) ) { let o = es.set(0, this.vrEulerYOffset * jb, 0); i.applyEuler(o), (a.x += i.x), (a.z += i.z), (this.nonColliderPosOffset.elements[13] += i.y * r); } if (this.usePhysics === !0) { let o = Qi; this.pushedVelocity.set(0, 0, 0); for (let l of this.sharedGameControlGlobals.entitiesWithTransformAnim) { let h = ln.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter), u = l.rigidBody .collider(0) .castCollider(h, this.object.rigidBody.collider(0), Di.copy(a).divideScalar(this.pixelsPerMeter), r, !1); if ((h.multiplyScalar(this.pixelsPerMeter), u !== null)) { this.pushedVelocity.copy(h), o.copy(u.normal1).applyQuaternion(l.quaternion); break; } } if (this.pushedVelocity.manhattanLength() !== 0) { let l = o.dot(a); l < 0 && a.addScaledVector(o, -l), a.add(this.pushedVelocity); } else a.add(this.groundVelocity); } if ( ((this.rotDirection.y = Number(this.movementState.rotPosY) - Number(this.movementState.rotNegY)), (this.rotDirection.x = Number(this.movementState.rotPosX) - Number(this.movementState.rotNegX)), this.rotDirection.normalize(), (this.rotationMode === 'normal' && (this.movementState.rotPosX || this.movementState.rotNegX)) || (this.rotationMode === 'steer' && (this.movementState.rotPosX || this.movementState.rotNegX) && (this.movementState.movePosZ || this.movementState.moveNegZ || this.moveMode === 'walk')) ? (this.rotVelocityStick.x = -this.rotDirection.x * this.speedOrbit * this.rotForce) : (this.rotVelocityStick.x = 0), (this.rotationMode === 'normal' && (this.movementState.rotPosY || this.movementState.rotNegY)) || (this.rotationMode === 'steer' && (this.movementState.rotPosY || this.movementState.rotNegY) && (this.movementState.movePosZ || this.movementState.moveNegZ)) ? (this.rotVelocityStick.y = -this.rotDirection.y * this.speedOrbit * this.rotForce) : (this.rotVelocityStick.y = 0), this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r), this.rotVelocityStick), this.rotVelocityTarget.manhattanLength() === 0 ? this.rotVelocity.lerp(this.rotVelocityTarget, 1 - (1 - this.lerpFactorRotEnd) ** s) : this.rotVelocity.lerp(this.rotVelocityTarget, 1 - (1 - this.lerpFactorRotStart) ** s), (this.euler.x += this.rotVelocity.x * r), (this.euler.y += this.rotVelocity.y * r + this.groundYRotation), this.rotVelocityTarget.y === 0 && this.directionXZ.manhattanLength() === 0 ? (this.rotationAccumWhenOrientWithCamera = 0) : (this.cameraFollow === !1 || this.cameraYAxis === 'Locked') && (this.rotationAccumWhenOrientWithCamera += this.rotVelocity.y * r), this.isFirstPerson === !1 && this.orientMode !== 'none' && this.directionXZ.manhattanLength() > 0) ) { let o = Di, l = Qi.copy(this.directionXZ); (l.x *= -1), this.camera.getWorldDirection(o); let h = ln.copy(zr).multiplyScalar(o.dot(zr)); if ( (o.sub(h), this.orientWith === 'camera' ? (this.rot.y = o.angleTo(l) * (o.cross(l).y > 0 ? -1 : 1) + this.rotationAccumWhenOrientWithCamera) : (this.rot.y = this.euler.y + Math.atan2(-this.directionXZ.z, this.directionXZ.x) - Math.PI / 2), this.orientMode === 'radial') ) { this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(zr, this.euler.y - this.euler0.y); let u = Qi.copy(this.objectToCamXZ).normalize(), c = ln.copy(a).multiplyScalar(r); c.y = 0; let d = c.sub(Di.copy(u).multiplyScalar(c.dot(u))).cross(u).y; this.euler.y -= Math.atan2(d, this.objectToCamXZ.length()); } } else (this.rot.y += this.rotVelocity.y * r + this.groundYRotation), this.rotVelocityTarget.y !== 0 && (this.cameraFollow === !1 || this.cameraYAxis === 'Locked') && (this.euler.y = this.rot.y); if ( (this.cameraFollow === !0 && (this.moveMode === 'walk' ? this.cameraXAxis === 'Limit' ? (this.euler.x = it.clamp( this.euler.x, -this.maxPolarAngle + this.cameraPolarOffset + 1e-6, -this.minPolarAngle + this.cameraPolarOffset - 1e-6 )) : (this.euler.x = it.clamp(this.euler.x, -this.PI_2 + this.cameraPolarOffset, this.PI_2 + this.cameraPolarOffset)) : this.cameraXAxis === 'Limit' && (this.euler.x = it.clamp(this.euler.x, -this.PI_2, this.PI_2))), this.moveMode === 'fly' ? (this.rot.x = this.euler.x) : this.isFirstPerson && (t ? (es.copy(t), (es.y = 0)) : (es.copy(this.euler), (es.y = 0)), this.nonColliderRotOffset.makeRotationFromEuler(es)), t && (this.moveMode === 'walk' ? ((this.rot.y = t.y), (this.rot.x = 0), (this.rot.z = 0)) : this.rot.setFromEuler(t), (this.rot.y += this.vrEulerYOffset * jb)), Br.setFromAxisAngle(ZG, this.rot.x), Ns.setFromAxisAngle(zr, this.rot.y), Ns.multiply(Br), Br.setFromAxisAngle(KG, this.rot.z), Ns.multiply(Br), this.object.quaternion.copy(Ns), this.objectRealQuat.multiplyQuaternions(this.object.quaternion, this.objXZQuat), this.objectRealQuat.multiply(this.objXZQuat), this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation), this.collisionEnabled) ) if (this.usePhysics) { let o = Qi.copy(a).multiplyScalar(r / this.pixelsPerMeter), l = null; this.didHit = !1; let h = new E(); for (let u = 0; u < 5; u++) { let c = o.length(), d = ln.copy(o).normalize(); if ( ((l = this.sharedGameControlGlobals.rapierWorld.castShape( Di.copy(this.collider.position) .applyQuaternion(this.objectRealQuat) .add(this.object.position) .divideScalar(this.pixelsPerMeter) .add(h), this.colliderWorldQuat, d, this.object.rigidBody?.collider(0).shape, c, !1, 8, void 0, void 0, this.object.rigidBody )), l !== null) ) { this.didHit = !0; let p = this.sharedGameControlGlobals.colliderToEntity[l.collider.handle]; if (p !== this.lastHitObj && u === 0) { this.lastHitObj = p; let v = this.sharedGameControlGlobals.eventsPerObjects[p?.uuid]; if (v) for (let y of v) y.data.target === 'character' && (p.dispatchEvent(a2), y.dispatch()); } let f = zb.set(l.normal2.x, l.normal2.y, l.normal2.z).applyQuaternion(this.colliderWorldQuat), g = Nb.copy(d).multiplyScalar(l.toi).dot(f), m = l.toi; if ( (m === 0 && (this.object.position.y += this.offset * this.pixelsPerMeter), g > this.offset && ((m = (l.toi * (g - this.offset)) / g), h.addScaledVector(d, m)), o.copy(d).multiplyScalar(c - m), Math.acos(-f.y) > this.slopeThresh) ) { let v = Di.copy(this.collider.position) .applyQuaternion(this.objectRealQuat) .add(this.object.position) .divideScalar(this.pixelsPerMeter) .add(h), y = ln.copy(l.witness2).applyQuaternion(this.colliderWorldQuat); y.y = 0; let b = v.add(y); b.y += this.stepThresh; let x = this.sharedGameControlGlobals.rapierWorld.castShape( b, this.colliderWorldQuat, o, this.object.rigidBody?.collider(0).shape, 1, !1, 8, void 0, void 0, this.object.rigidBody ); x !== null && x.toi === 0 && ((f.y = 0), f.normalize()); } o.addScaledVector(f, -o.dot(f)); } else { u === 0 && this.directionXZ.manhattanLength() !== 0 && (this.lastHitObj = null), h.add(o); break; } } this.object.position.addScaledVector(h, this.pixelsPerMeter), this.object.rigidBody?.setTranslation(Di.copy(this.object.position).divideScalar(this.pixelsPerMeter), !0), this.object.rigidBody?.setRotation(Br.copy(this.object.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat), !0); } else { let o = this.onObject ? 1 : 5, l = a.multiplyScalar(r / o); for (let h = 0; h < o; h++) this.object.position.add(l), this.collisionAdjustment(r / o); } else this.object.position.addScaledVector(a, r); if ( (this.moveMode === 'walk' && this.onObject && ((this.velocityTarget.y = 0), (this.velocity.y = 0)), this.object.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat), this.object.updateMatrix(), this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset), this.object.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv), this.cameraFollow === !0) ) { this.updateFollowArms(); let o = this.objectToTarget.add(this.object.position), l = this.targetToCamera.add(o); Af.lookAt(l, o, zr).setPosition(l), Af.decompose(this.targetPos, this.targetQuat, Di), this.camera.quaternion.slerp(this.targetQuat, 1 - (1 - this.lerpFactorRotCamera) ** s), this.camera.position.lerp(this.targetPos, 1 - (1 - this.lerpFactorPosCamera) ** s), this.camera.updateMatrix(), this.camera.updateMatrixWorld(), this.cameraYAxis === 'Limit' && this.orientMode === 'cartesian' && (this.euler.y = it.clamp(this.euler.y, this.minAzimuthAngleRel, this.maxAzimuthAngleRel)), (this.euler.x = it.clamp( this.euler.x, -this.PI_2 + (this.cameraPolarOffset < 0 ? this.cameraPolarOffset : 0), this.PI_2 + (this.cameraPolarOffset > 0 ? this.cameraPolarOffset : 0) )); } return ( this.eulerDelta.set(0, 0, 0), this.lastPosition.distanceToSquared(this.object.position) < this.threshEndTranslate && Math.abs(this.rotVelocity.x) < this.threshEndRotVel && Math.abs(this.rotVelocity.y) < this.threshEndRotVel && (this.camera === void 0 || this.isFirstPerson || (this.lastCameraPosition.distanceToSquared(this.camera.position) < this.threshEndTranslate && 8 * (1 - this.lastCameraQuaternion.dot(this.camera.quaternion)) < this.threshEndRotate)) && (this.moveMode === 'fly' || this.onObject === !0 || this.collisionEnabled === !1) ? !1 : (this.camera && (this.lastCameraPosition.copy(this.camera.position), this.lastCameraQuaternion.copy(this.camera.quaternion)), this.lastPosition.copy(this.object.position), this.object.dispatchEvent(iV), !0) ); } updateFollowArms() { this.objectToTarget.copy(this.objectToTarget0), this.targetToCamera.copy(this.targetToCamera0); let e = Br.setFromAxisAngle( zr, this.cameraYAxis === 'Limit' && this.orientMode !== 'radial' ? it.clamp(this.euler.y - this.euler0.y, this.minAzimuthAngleRel, this.maxAzimuthAngleRel) : this.euler.y - this.euler0.y ); (this.cameraYAxis !== 'Locked' || this.orientMode === 'radial') && this.objectToTarget.applyQuaternion(e); let t; this.cameraXAxis === 'Limit' ? (t = it.clamp( this.euler.x, -this.maxPolarAngle + this.cameraPolarOffset + 1e-6, -this.minPolarAngle + this.cameraPolarOffset - 1e-6 )) : (t = it.clamp(this.euler.x, -this.PI_2 + this.cameraPolarOffset + 1e-6, this.PI_2 + this.cameraPolarOffset - 1e-6)); let i = Di.copy(this.cameraPolarAxis0); (this.cameraYAxis !== 'Locked' || this.orientMode === 'radial') && i.applyQuaternion(e); let r = Ns.setFromAxisAngle(i, t); this.cameraYAxis !== 'Locked' && this.targetToCamera.applyQuaternion(e), this.cameraXAxis !== 'Locked' && this.targetToCamera.applyQuaternion(r); } groundTiltAdjustment(e) { (zr.angleTo(e) * 180) / Math.PI < 15 || (zr.angleTo(e) * 180) / Math.PI > 85 ? Br.identity() : Br.setFromUnitVectors(zr, e), this.groundTilt.slerp(Br, 0.06), this.groundTiltInv.copy(this.groundTilt).invert(); } collisionAdjustment(e) { let t = Nb.set(0, 0, 0); this.object.updateMatrix(); let i = Af.multiplyMatrices(this.object.matrix, this.objXZRotMat) .multiply(this.collider.matrix) .decompose(Di, Br, Qi) .compose(Di, Br, Fb); this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach((s) => { if (s === this.object || s.isDescendantOf(this.object)) return; pr.makeEmpty(), s.updateMatrixWorldSVD(); let n = s.matrixWorldRigid, a = Ub.copy(n).invert(), o = QG.copy(Ub).multiply(i); xi.copy(this.collider.segment), xi.start.applyMatrix4(o), xi.end.applyMatrix4(o); let l = zb.copy(this.object.position).applyMatrix4(a); pr.expandByPoint(xi.start), pr.expandByPoint(xi.end), pr.min.addScalar(-this.collider.radius), pr.max.addScalar(this.collider.radius), s.boundsTree.shapecast({ intersectsBounds: (h) => h.intersectsBox(pr), intersectsTriangle: (h) => { let u = Di, c = Qi, d = h.closestPointToSegment(xi, u, c); if (d < this.collider.radius) { let p = this.collider.radius - d, f = c.sub(u).normalize(), g = ln.copy(l); g.addScaledVector(f, p); let m = g.applyMatrix4(n).sub(this.object.position); t.add(m), xi.start.addScaledVector(f, p), xi.end.addScaledVector(f, p); } } }); }), pr.makeEmpty(), xi.copy(this.collider.segment), xi.start.applyMatrix4(i), xi.end.applyMatrix4(i), pr.expandByPoint(xi.start), pr.expandByPoint(xi.end), pr.min.addScalar(-this.collider.radius), pr.max.addScalar(this.collider.radius), this.sharedGameControlGlobals.staticMeshBVH?.shapecast({ intersectsBounds: (s) => s.intersectsBox(pr), intersectsTriangle: (s) => { let n = Di, a = Qi, o = s.closestPointToSegment(xi, n, a); if (o < this.collider.radius) { let l = this.collider.radius - o, h = a.sub(n).normalize(); this.alignToGround && this.groundTiltAdjustment(h), t.addScaledVector(h, l), xi.start.addScaledVector(h, l), xi.end.addScaledVector(h, l); } } }), (this.onObject = Math.abs(t.y) > Math.abs(e * this.velocity.y * 0.25)), this.onObject && this.dispatchStopEvent('jump'); let r = Math.max(0, t.length() - 1e-5); t.normalize().multiplyScalar(r), this.object.position.add(t); } }, o2 = rg; o2.isLocked = !1; var Sf = { type: 'change' }, Gb = { type: 'changeZoom' }, rV = { type: 'changePan' }, ro = { type: 'start' }, so = { type: 'end', changed: !0 }, sV = { type: 'end', changed: !1 }, Mf = new ct(), Vb = new G(), nV = 2 * Math.PI, aV = 1e-8, oV = 0.01, Ef = new E(), qc = new G(), Cf = new E(), Yc = new ct(), Hb = new ve(), lV = { type: 'requestRender' }, l2 = class extends Vi { constructor(e, t, i = { isPlayMode: !1, isExport: !1 }) { super(), (this.object = e), (this.domElement = t), (this.options = i), (this.enabled = !0), (this.useKeyEvents = !0), (this.enableDamping = !1), (this.enableZoom = !0), (this.enableRotate = !0), (this.enablePan = !0), (this.autoRotate = !1), (this.rotationLimitsMode = 0), (this.panLimitsMode = 0), (this.rotationSoftLimit = 2), (this.panSoftLimit = 2), (this.hoverRotatePanMode = 0), (this.zoomLimitsEnabled = !1), (this.mouseButtons = [0, 5]), (this.mouseButtonsPlay = [3, 4, 5]), (this.touches = [null, hr.DOLLY_ROTATE, hr.PAN]), (this.offset = new E()), (this.eye = new E()), (this.lastPosition = new E()), (this.lastQuaternion = new ct()), (this.current = new G()), (this.overShoot = new G()), (this.overRatio = new G()), (this.spherical = new Ey()), (this.sphericalDelta = new Ey()), (this.panOffset = new E()), (this.panLeftV = new E()), (this.panUpV = new E()), (this.panV = new E()), (this.rotateStart = new G()), (this.rotateEnd = new G()), (this.rotateDelta = new G()), (this.panStart = new G()), (this.panEnd = new G()), (this.panDelta = new G()), (this.dollyStart = new G()), (this.dollyEnd = new G()), (this.dollyDelta = new G()), (this.rotationRangeFactor = new G()), (this.panRangeFactor = new G()), (this.state = -1), (this.zoomChanged = !1), (this.isPointerDown = !1), (this.isThetaFlipped = !1), (this.prevScale = 0), (this.scale = 1), (this.gesture = !1), (this.timer = -1), (this.timerHover = -1), (this.minDistance = 0), (this.maxDistance = 1 / 0), (this.minZoom = 0), (this.maxZoom = 1 / 0), (this.minPhi = 0), (this.maxPhi = Math.PI), (this.minTheta = -1 / 0), (this.maxTheta = 1 / 0), (this.minH = 0), (this.maxH = Math.PI), (this.minV = -1 / 0), (this.maxV = 1 / 0), (this.autoRotateClockwise = !0), (this.isPanOverShoot = !1), (this.isRotateOverShoot = !1), (this.resetHoverEffectOnPointerLeave = !1), (this.hasChange = !1), (this.useWindowEvents = !1), (this.isTouchZoom = !0), (this.autoRotateSpeed = 2), (this.dampingFactor = 0.125), (this.zoomSpeed = 2), (this.rotateSpeed = 1), (this.panSpeed = 1), (this.hoverRotatePanStrength = 0.1), (this.thetaIsFree = !1), (this.phiIsFree = !1), (this.needsUpdate = !0), (this.update = () => { this.object.updateWorldMatrix(!0, !1), this.object.matrixWorld.decompose(Cf, Yc, Ef), this.offset.copy(Cf).sub(this.target), this.spherical.setFromVector3(this.offset), this.object.isUpVectorFlipped && ((this.spherical.phi *= -1), (this.spherical.theta -= Math.PI)), this.autoRotate && this.state === -1 && this.rotateLeft((this.autoRotateClockwise === !0 ? 1 : -1) * this.getAutoRotationAngle()), this.rotationLimitsMode !== 0 && this.applyLimits( this.sphericalDelta, this.rotationLimitsMode, this.rotationSoftLimit, this.maxTheta, this.minTheta, this.maxPhi, this.minPhi, this.rotationRangeFactor ), this.rotationLimitsMode !== 2 && (this.spherical.phi += this.sphericalDelta.phi), (this.rotationLimitsMode !== 1 || this.autoRotate === !0) && (this.spherical.theta += this.sphericalDelta.theta), (this.spherical.radius *= this.scale), this.zoomLimitsEnabled && (this.spherical.radius = Math.max(this.minDistance, Math.min(this.maxDistance, this.spherical.radius))), this.panLimitsMode !== 0 && (this.target.applyQuaternion(Mf.copy(Yc).invert()), this.panOffset.applyQuaternion(Mf), this.applyLimits( this.panOffset, this.panLimitsMode, this.panSoftLimit, this.maxH, this.minH, this.maxV, this.minV, this.panRangeFactor ), this.target.applyQuaternion(Yc), this.panOffset.applyQuaternion(Yc)), this.panLimitsMode === 2 && (this.panOffset.y = 0), this.panLimitsMode === 1 && (this.panOffset.x = 0), this.state === -1 && !this.gesture ? (this.panOffset.multiplyScalar(1 - this.dampingFactor), this.target.add(this.panOffset)) : (this.target.add(this.panOffset), this.panOffset.set(0, 0, 0)), this.offset.setFromSpherical(this.spherical), Cf.copy(this.target).add(this.offset), this.object.position.copy(this.target).add(this.offset), this.object.parent && (Hb.copy(this.object.parent.matrixWorld).invert(), this.object.position.applyMatrix4(Hb)); let r = this.spherical.phi % nV; return ( this.eye.copy(this.offset).normalize(), this.object.up.copy(bt.DEFAULT_UP).applyAxisAngle(this.eye, this.object.angleOffsetFromUp), (r > 0 && r > Math.PI) || (r < 0 && r > -Math.PI) ? (this.object.up.negate(), this.object.lookAt(this.target), (this.object.isUpVectorFlipped = !0)) : (this.object.lookAt(this.target), (this.object.isUpVectorFlipped = !1)), this.state === -1 || this.enableDamping === !0 ? ((this.sphericalDelta.theta *= 1 - this.dampingFactor), (this.sphericalDelta.phi *= 1 - this.dampingFactor)) : this.sphericalDelta.set(0, 0, 0), (this.scale = 1), (this.object.wasMovedByUser = !0), this.zoomChanged || this.lastPosition.distanceToSquared(this.object.position) > oV || 8 * (1 - this.lastQuaternion.dot(this.object.quaternion)) > aV ? (this.dispatchEvent(Sf), this.object.dispatchEvent(lV), this.lastPosition.copy(this.object.position), this.lastQuaternion.copy(this.object.quaternion), (this.zoomChanged = !1), !0) : ((this.isPanOverShoot = !1), (this.isRotateOverShoot = !1), this.sphericalDelta.set(0, 0, 0), this.panOffset.set(0, 0, 0), !1) ); }), (this.onPointerDown = (r) => { this.enabled !== !1 && (r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) ? this.onPointerDownTouch(r) : this.onPointerDownMouse(r), this.state !== -1 && ((this.isPointerDown = !0), this.dispatchEvent(ro), this.domElement.addEventListener('pointermove', this.onPointerMove), this.domElement.addEventListener('pointerup', this.onPointerUp), r.stopPropagation(), r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) || this.domElement.setPointerCapture(r.pointerId))); }), (this.onPointerLeave = (r) => { this.resetHoverEffectOnPointerLeave && !this.useWindowEvents ? (this.hoverRotatePanMode === 1 ? ((this.sphericalDelta.theta = -this.spherical.theta), (this.sphericalDelta.phi = -this.spherical.phi), Ef.subVectors(this.position0, this.target0), this.spherical.setFromVector3(Ef), (this.sphericalDelta.theta += this.spherical.theta), (this.sphericalDelta.phi += this.spherical.phi), (this.sphericalDelta.theta /= 8), (this.sphericalDelta.phi /= 8)) : this.hoverRotatePanMode === 2 && this.panOffset.subVectors(this.target0, this.target).divideScalar(8), this.update()) : (this.pointerLeaveEvent = r); }), (this.onPointerEnter = (r) => { this.resetHoverEffectOnPointerLeave || this.pointerLeaveEvent === void 0 ? qc.set(r.clientX - this.domElement.clientWidth / 2, r.clientY - this.domElement.clientHeight / 2) : qc.set(r.clientX - this.pointerLeaveEvent.clientX, r.clientY - this.pointerLeaveEvent.clientY), this.hoverRotatePanMode === 1 ? (this.rotateDelta .copy(qc) .multiplyScalar(this.rotateSpeed * this.hoverRotatePanStrength) .rotateAround(Vb, -this.object.angleOffsetFromUp), this.rotateLeft((2 * Math.PI * this.rotateDelta.x) / this.domElement.clientHeight), this.rotateUp((2 * Math.PI * this.rotateDelta.y) / this.domElement.clientHeight), this.rotateStart.set(r.clientX, r.clientY)) : this.hoverRotatePanMode === 2 && (this.panDelta.copy(qc).multiplyScalar(this.panSpeed * this.hoverRotatePanStrength), this.pan(this.panDelta.x, this.panDelta.y), this.panStart.set(r.clientX, r.clientY)), this.update(); }), (this.onPointerMove = (r) => { this.enabled !== !1 && (r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) ? this.onPointerMoveTouch(r) : this.onPointerMoveMouse(r), r.stopPropagation()); }), (this.onPointerUp = (r) => { (this.isPointerDown = !1), Qe.length === 0 && (this.domElement.removeEventListener('pointermove', this.onPointerMove), this.domElement.removeEventListener('pointerup', this.onPointerUp)), this.hasChange ? this.dispatchEvent(so) : this.dispatchEvent(sV), (this.state = -1), r && (r.stopPropagation(), r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) || this.domElement.releasePointerCapture(r.pointerId)); }), (this.onPointerDownMouse = (r) => { let s; switch ((this.useKeyEvents ? (s = this.mouseButtons[r.button]) : (s = this.mouseButtonsPlay[r.button]), s)) { case 0: if (r.altKey === !0 && !r.shiftKey && !Ac(r)) { if (this.enableRotate === !1) return; this.handleMouseDownRotate(r), (this.state = 0); } else if (this.key === ' ') { if (this.enablePan === !1) return; this.handleMouseDownPan(r), (this.state = 2); } break; case 4: if (this.enablePan === !1) return; this.handleMouseDownPan(r), (this.state = 2); break; case 3: if (Ac(r) || r.shiftKey) { if (this.enablePan === !1) return; this.handleMouseDownPan(r), (this.state = 2); } else { if (this.enableRotate === !1) return; this.handleMouseDownRotate(r), (this.state = 0); } break; case 5: if (Ac(r) || r.shiftKey) { if (this.enableRotate === !1) return; this.handleMouseDownRotate(r), (this.state = 0); } else { if (this.enablePan === !1) return; this.handleMouseDownPan(r), (this.state = 2); } break; default: this.state = -1; } }), (this.onPointerMoveMouse = (r) => { switch (this.state) { case 0: if (this.enableRotate === !1) return; this.handleMouseMoveRotate(r); break; case 1: if (this.enableZoom === !1) return; this.handleMouseMoveDolly(r); break; case 2: if (this.enablePan === !1) return; this.handleMouseMovePan(r); break; } }), (this.onPointerDownTouch = (r) => { switch (this.touches[Qe.length - 1]) { case hr.ROTATE: if (this.enableRotate === !1) { this.state = -1; return; } this.handleTouchStartRotate(), (this.state = 3); break; case hr.PAN: if (this.enablePan === !1) { this.state = -1; return; } this.handleTouchStartPan(), (this.state = 4); break; case hr.DOLLY_PAN: if ((this.enableZoom === !1 && this.enablePan === !1) || this.isTouchZoom === !1) return; this.handleTouchStartDollyPan(), (this.state = 5); break; case hr.DOLLY_ROTATE: if ((this.enableZoom === !1 && this.enableRotate === !1) || this.isTouchZoom === !1) return; this.handleTouchStartDollyRotate(), (this.state = 6); break; default: this.state = -1; } }), (this.onPointerMoveTouch = (r) => { switch (this.state) { case 3: if (this.enableRotate === !1) return; this.handleTouchMoveRotate(r), this.update(); break; case 4: if (this.enablePan === !1) return; this.handleTouchMovePan(r), this.update(); break; case 5: if ((this.enableZoom === !1 && this.enablePan === !1) || this.isTouchZoom === !1) return; this.handleTouchMoveDollyPan(r), this.update(); break; case 6: if ((this.enableZoom === !1 && this.enableRotate === !1) || this.isTouchZoom === !1) return; this.handleTouchMoveDollyRotate(r), this.update(); break; default: this.state = -1; } }), (this.dispatchEndDebounced = __(() => this.dispatchEvent(so), 33)), (this.onMouseWheel = (r) => { this.enabled === !1 || (this.enableZoom === !1 && this.enablePan === !1) || (this.options.isExport === !1 && this.domElement.clientHeight === document.body.clientHeight && this.domElement.clientWidth === document.body.clientWidth && r.preventDefault(), this.dispatchEvent(ro), this.handleMouseWheel(r), this.dispatchEndDebounced()); }), (this.onGesture = (r) => { if (this.enabled !== !1) if ((r.preventDefault(), r.type === 'gesturechange')) { if (this.enableZoom === !1 || this.isTouchZoom === !1) return; this.dispatchEvent(ro), r.scale > this.prevScale ? this.dollyIn(this.getZoomScale()) : r.scale < this.prevScale && this.dollyOut(this.getZoomScale()), (this.prevScale = r.scale), this.update(); } else this.dispatchEvent(so); }), (this.onContextMenu = (r) => { this.enabled !== !1 && r.preventDefault(); }), (this.onTouchEnd = (r) => { r.preventDefault(); }), (this.onKeyDown = (r) => { this.enabled !== !1 && ((this.key = r.key), r.key === ' ' && this.dispatchEvent(ro)); }), (this.onKeyUp = (r) => { this.enabled !== !1 && ((this.key = void 0), this.state !== -1 && this.onPointerUp(Qe[0]), r.key === ' ' && this.dispatchEvent(so)); }), (this.onPointerHover = (r) => { r.pointerType !== 'mouse' || this.enabled === !1 || this.state !== -1 || (this.hoverRotatePanMode === 2 && this.isPanOverShoot) || (this.hoverRotatePanMode === 1 && this.isRotateOverShoot) || ((this.isPointerDown = !0), this.hoverRotatePanMode === 2 ? this.handleMouseMovePan(r, this.hoverRotatePanStrength) : this.hoverRotatePanMode === 1 && this.handleMouseMoveRotate(r, this.hoverRotatePanStrength)); }), (this.onBeginState = () => { (this.enabled = !1), (this.needsUpdate = !1); }), (this.onCompleteState = (r) => { (r.isfromEntity && this.options.isPlayMode) || ((this.enabled = !0), (this.needsUpdate = !0), this.object.updateUp(), this.object.getTarget(this.target)); }), (this.target = this.object.getTarget()), (this.target0 = this.target.clone()), (this.position0 = this.object.position.clone()), (this.zoom0 = this.object.zoom), (this.quat0 = this.object.quaternion.clone()), (this.isUpVectorFlipped0 = this.object.isUpVectorFlipped), this.offset.copy(this.object.position).sub(this.target), this.spherical.setFromVector3(this.offset), this.object.isUpVectorFlipped && ((this.spherical.phi *= -1), (this.spherical.theta -= Math.PI)), this.addEventListenersToCamera(); } dispatchEvent(e) { e.type === 'start' ? (this.hasChange = !1) : (this.hasChange = !0), super.dispatchEvent(e); } addEventListenersToCamera() { this.object.addEventListener('beginState', this.onBeginState), this.object.addEventListener('completeState', this.onCompleteState); } removeEventListenersFromCamera() { this.object.removeEventListener('beginState', this.onBeginState), this.object.removeEventListener('completeState', this.onCompleteState); } reset() { this.object.quaternion.copy(this.quat0), this.target.copy(this.target0), this.object.position.copy(this.position0), (this.object.zoom = this.zoom0), (this.object.isUpVectorFlipped = this.isUpVectorFlipped0), this.object.updateProjectionMatrix(), this.dispatchEvent(Sf), (this.state = -1), (this.pointerLeaveEvent = void 0); } resetTo(e, t, i, r, s = !1) { this.object.quaternion.copy(r), this.target.copy(e), this.object.position.copy(t), (this.object.zoom = i), (this.object.isUpVectorFlipped = s), this.object.updateProjectionMatrix(), this.dispatchEvent(Sf), this.update(), (this.state = -1); } updateUseWindowEvents(e) { if ( (window.removeEventListener('pointermove', this.onPointerHover), this.domElement.removeEventListener('pointermove', this.onPointerHover), (this.useWindowEvents = e), this.hoverRotatePanMode !== 0 && (this.useWindowEvents ? window.addEventListener('pointermove', this.onPointerHover) : this.domElement.addEventListener('pointermove', this.onPointerHover)), this.domElement.removeEventListener('pointerleave', this.onPointerLeave), this.domElement.removeEventListener('pointerenter', this.onPointerEnter), window.removeEventListener('pointerleave', this.onPointerLeave), window.removeEventListener('pointerenter', this.onPointerEnter), this.hoverRotatePanMode !== 0 && !this.useWindowEvents) ) { let t = this.useWindowEvents ? window : this.domElement; t.addEventListener('pointerleave', this.onPointerLeave), t.addEventListener('pointerenter', this.onPointerEnter); } } fromJSON(e, t) { this.setEnableDampingSpeed(e.enableDamping), (this.enablePan = e.enablePan), (this.enableZoom = e.enableZoom), (this.enableRotate = e.enableRotate), (this.rotationLimitsMode = e.rotationLimitsMode), (this.thetaIsFree = e.rotationHorizontalOffset.min === e.rotationHorizontalOffset.max && e.rotationHorizontalOffset.min === Math.PI), (this.phiIsFree = e.rotationVerticalOffset.min === e.rotationVerticalOffset.max && e.rotationVerticalOffset.min === Math.PI), (this.panLimitsMode = e.panLimitsMode), (this.panSoftLimit = e.panSoftLimit), (this.rotationSoftLimit = e.rotationSoftLimit), (this.hoverRotatePanMode = e.hoverRotatePanMode), (this.useWindowEvents = t === 'window'), this.hoverRotatePanMode !== 0 && (this.useWindowEvents ? window.addEventListener('pointermove', this.onPointerHover) : this.domElement.addEventListener('pointermove', this.onPointerHover)); let i = e.hoverRotatePanStrength / 100; (this.hoverRotatePanStrength = i ** 2), (this.zoomLimitsEnabled = e.zoomLimitsEnabled), (this.minZoom = e.zoomLimits.min), (this.maxZoom = Math.max(e.zoomLimits.min, e.zoomLimits.max)), (this.minDistance = 1e3 / e.zoomLimits.max), (this.maxDistance = Math.max(this.minDistance, 1e3 / e.zoomLimits.min)), (this.autoRotate = e.autoRotate), (this.autoRotateSpeed = e.autoRotateSpeed), (this.autoRotateClockwise = e.autoRotateClockwise); let r = this.object.getTarget().applyQuaternion(Mf.copy(this.object.quaternion).invert()); (this.minV = -e.panVerticalOffset.min + r.y), (this.maxV = e.panVerticalOffset.max + r.y), (this.minH = -e.panHorizontalOffset.min + r.x), (this.maxH = e.panHorizontalOffset.max + r.x), this.panRangeFactor.set(this.maxH - this.minH, this.maxV - this.minV).divideScalar(2), this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4), (this.minPhi = ts(this.spherical.phi - e.rotationVerticalOffset.min)), (this.maxPhi = ts(this.spherical.phi + e.rotationVerticalOffset.max)), (this.minTheta = ts(ts(this.spherical.theta) - e.rotationHorizontalOffset.min)), (this.maxTheta = ts(ts(this.spherical.theta) + e.rotationHorizontalOffset.max)), (this.isThetaFlipped = this.minTheta > this.maxTheta), e.orbitTouches === 1 && (this.touches[0] = hr.ROTATE), e.panTouches === 1 && (this.touches[0] = hr.PAN), e.orbitTouches === 2 && (this.touches[1] = hr.DOLLY_ROTATE), e.panTouches === 2 && (this.touches[1] = hr.DOLLY_PAN), e.orbitTouches === 3 && (this.touches[2] = hr.ROTATE), e.panTouches === 3 && (this.touches[2] = hr.PAN), (this.isTouchZoom = e.isTouchZoom), (this.resetHoverEffectOnPointerLeave = e.resetHoverEffectOnPointerLeave ?? !1); } connect() { if ( (this.domElement.addEventListener('contextmenu', this.onContextMenu), this.domElement.addEventListener('pointerdown', this.onPointerDown), this.domElement.addEventListener('wheel', this.onMouseWheel), window.addEventListener('keydown', this.onKeyDown, !1), window.addEventListener('keyup', this.onKeyUp, !1), Mm || (this.domElement.addEventListener('gesturestart', this.onGesture), this.domElement.addEventListener('gesturechange', this.onGesture), this.domElement.addEventListener('gestureend', this.onGesture)), this.domElement.addEventListener('touchend', this.onTouchEnd), this.hoverRotatePanMode !== 0 && !this.useWindowEvents) ) { let e = this.useWindowEvents ? window : this.domElement; e.addEventListener('pointerleave', this.onPointerLeave), e.addEventListener('pointerenter', this.onPointerEnter); } this.pointerLeaveEvent = void 0; } dispose() { this.removeEventListenersFromCamera(), this.domElement.removeEventListener('contextmenu', this.onContextMenu), this.domElement.removeEventListener('pointerdown', this.onPointerDown), this.domElement.removeEventListener('wheel', this.onMouseWheel), window.removeEventListener('keydown', this.onKeyDown, !1), window.removeEventListener('keyup', this.onKeyUp, !1), this.domElement.removeEventListener('pointermove', this.onPointerHover), window.removeEventListener('pointermove', this.onPointerHover), Mm || (this.domElement.removeEventListener('gesturestart', this.onGesture), this.domElement.removeEventListener('gesturechange', this.onGesture), this.domElement.removeEventListener('gestureend', this.onGesture)), this.domElement.removeEventListener('touchend', this.onTouchEnd), this.domElement.removeEventListener('pointerleave', this.onPointerLeave), this.domElement.removeEventListener('pointerenter', this.onPointerEnter), window.removeEventListener('pointerleave', this.onPointerLeave), window.removeEventListener('pointerenter', this.onPointerEnter), this.domElement.removeEventListener('pointermove', this.onPointerMove), this.domElement.removeEventListener('pointerup', this.onPointerUp); } applyLimits(e, t, i, r, s, n, a, o) { this.overShoot.set(0, 0); let l, h, u; e instanceof E ? ((l = e.x), (h = e.y), this.current.set(this.target.x, this.target.y), (u = !0)) : ((l = e.theta), (h = e.phi), this.current.set(ts(this.spherical.theta), ts(this.spherical.phi)), (u = !1)), i === 0 && ((this.current.x += l), (this.current.y += h)), (t === 3 || t === 2) && (!u && this.isThetaFlipped ? this.current.x > r && this.current.x < 0 ? (this.overShoot.x = r - this.current.x) : this.current.x < s && this.current.x > 0 && (this.overShoot.x = s - this.current.x) : this.current.x > r ? (this.overShoot.x = r - this.current.x) : this.current.x < s && (this.overShoot.x = s - this.current.x)), (t === 3 || t === 1) && (this.current.y > n ? (this.overShoot.y = n - this.current.y) : this.current.y < a && (this.overShoot.y = a - this.current.y)), u || ((this.overShoot.x = ts(this.overShoot.x)), (this.overShoot.y = ts(this.overShoot.y))), i !== 0 ? (this.overRatio.copy(this.overShoot).divide(o), (this.overRatio.x = Math.min(Math.abs(this.overRatio.x), 1)), (this.overRatio.y = Math.min(Math.abs(this.overRatio.y), 1)), i === 1 && ((this.overRatio.x = Wb(Math.abs(this.overRatio.x))), (this.overRatio.y = Wb(Math.abs(this.overRatio.y)))), this.isPointerDown || i === 1 ? i === 2 && ((this.overRatio.x > 0.9 && !this.thetaIsFree) || (this.overRatio.y > 0.9 && !this.phiIsFree)) ? (this.isPointerDown = !1) : (l * this.overShoot.x < 0 && !this.thetaIsFree && (l *= 1 - this.overRatio.x), h * this.overShoot.y < 0 && !this.phiIsFree && (h *= 1 - this.overRatio.y)) : i === 2 && ((!u && ((this.overRatio.x > 0.002 && !this.thetaIsFree) || (this.overRatio.y > 0.002 && !this.phiIsFree))) || (u && (Math.abs(this.overShoot.x) > 2 || Math.abs(this.overShoot.y) > 2)) ? (this.thetaIsFree || (l = this.overShoot.x * 0.05), this.phiIsFree || (h = this.overShoot.y * 0.05), u ? (this.isPanOverShoot = !0) : (this.isRotateOverShoot = !0)) : u ? (this.isPanOverShoot = !1) : (this.isRotateOverShoot = !1))) : ((l += this.overShoot.x), (h += this.overShoot.y)), e instanceof E ? ((e.x = l), (e.y = h)) : (this.thetaIsFree || (e.theta = l), this.phiIsFree || (e.phi = h)); } setEnableDampingSpeed(e) { (this.enableDamping = e), (this.rotateSpeed = e === !0 ? 0.2 : 1); } stopDamping() { (this.sphericalDelta.theta = 0), (this.sphericalDelta.phi = 0); } getAutoRotationAngle() { return ((2 * Math.PI) / 60 / 60) * this.autoRotateSpeed; } getZoomScale() { return Math.pow(0.95, this.zoomSpeed); } rotateLeft(e) { this.sphericalDelta.theta -= e; } rotateUp(e) { this.sphericalDelta.phi -= e; } panLeft(e, t) { this.panLeftV.setFromMatrixColumn(t, 0), this.panLeftV.multiplyScalar(-e), this.panOffset.add(this.panLeftV); } panUp(e, t) { this.panUpV.setFromMatrixColumn(t, 1), this.panUpV.multiplyScalar(e), this.panOffset.add(this.panUpV); } pan(e, t) { let i = this.domElement; if (i && this.object.isPerspectiveCamera) { let r = this.object.position; this.panV.copy(r).sub(this.target); let s = this.panV.length(); (s *= Math.tan(((this.object.fov / 2) * Math.PI) / 180)), this.panLeft((2 * e * s) / i.clientHeight, this.object.matrixWorld), this.panUp((2 * t * s) / i.clientHeight, this.object.matrixWorld); } else i && this.object.isOrthographicCamera && (this.panLeft((e * (this.object.right - this.object.left)) / this.object.zoom / i.clientWidth, this.object.matrixWorld), this.panUp((t * (this.object.top - this.object.bottom)) / this.object.zoom / i.clientHeight, this.object.matrixWorld)); this.dispatchEvent(rV); } dollyOut(e) { this.object.isPerspectiveCamera ? (this.scale /= e) : this.object.isOrthographicCamera && ((this.object.zoom *= e), this.zoomLimitsEnabled && (this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom))), this.object.updateProjectionMatrix(), (this.zoomChanged = !0)), this.dispatchEvent(Gb); } dollyIn(e) { this.object.isPerspectiveCamera ? (this.scale *= e) : this.object.isOrthographicCamera && ((this.object.zoom /= e), this.zoomLimitsEnabled && (this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom))), this.object.updateProjectionMatrix(), (this.zoomChanged = !0)), this.dispatchEvent(Gb); } zoomOut(e = this.getZoomScale()) { this.dispatchEvent(ro), this.dollyOut(e), this.dispatchEvent(so); } zoomIn(e = this.getZoomScale()) { this.dispatchEvent(ro), this.dollyIn(e), this.dispatchEvent(so); } handleMouseDownRotate(e) { this.rotateStart.set(e.clientX, e.clientY); } handleMouseDownDolly(e) { this.dollyStart.set(e.clientX, e.clientY); } handleMouseDownPan(e) { this.panStart.set(e.clientX, e.clientY); } handleMouseMoveRotate(e, t = 1) { e.movementX !== void 0 ? this.rotateDelta.set(e.movementX, e.movementY) : (this.rotateEnd.set(e.clientX, e.clientY), this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart), this.rotateStart.copy(this.rotateEnd)), this.rotateDelta.multiplyScalar(this.rotateSpeed * t).rotateAround(Vb, -this.object.angleOffsetFromUp); let i = this.domElement, r = this.useWindowEvents ? window.innerHeight : i.clientHeight, s = (2 * Math.PI * this.rotateDelta.x) / r, n = (2 * Math.PI * this.rotateDelta.y) / r; this.rotateLeft(s), this.rotateUp(n), this.update(); } handleMouseMoveDolly(e) { this.dollyEnd.set(e.clientX, e.clientY), this.dollyDelta.subVectors(this.dollyEnd, this.dollyStart), this.dollyDelta.y > 0 ? this.dollyOut(this.getZoomScale()) : this.dollyDelta.y < 0 && this.dollyIn(this.getZoomScale()), this.dollyStart.copy(this.dollyEnd), this.update(); } handleMouseMovePan(e, t = 1) { e.movementX !== void 0 ? this.panDelta.set(e.movementX, e.movementY) : (this.panEnd.set(e.clientX, e.clientY), this.panDelta.subVectors(this.panEnd, this.panStart), this.panStart.copy(this.panEnd)), this.panDelta.multiplyScalar(this.panSpeed * t), this.pan(this.panDelta.x, this.panDelta.y), this.update(); } handleMouseWheel(e) { if ($N === !1 && Ac(e) === !1 && hV(e) === !0) { if (this.enablePan === !1) return; this.gesture ? (this.panDelta.set(-e.deltaX, -e.deltaY).multiplyScalar(this.panSpeed), (this.panDelta.x = Math.min(Math.abs(this.panDelta.x), 100) * (this.panDelta.x < 0 ? -1 : 1)), (this.panDelta.y = Math.min(Math.abs(this.panDelta.y), 100) * (this.panDelta.y < 0 ? -1 : 1)), e.altKey ? this.pan(0, this.panDelta.y) : e.shiftKey ? this.pan(this.panDelta.x, 0) : this.pan(this.panDelta.x, this.panDelta.y), this.update()) : ((this.gesture = !0), (this.isPointerDown = !0)), window.clearTimeout(this.timer), (this.timer = window.setTimeout(() => { (this.gesture = !1), (this.isPointerDown = !1); }, 30)); } else { if (this.enableZoom === !1) return; e.deltaY === 0 ? e.deltaX < 0 ? this.dollyIn(this.getZoomScale()) : e.deltaX > 0 && this.dollyOut(this.getZoomScale()) : e.deltaY < 0 ? this.dollyIn(this.getZoomScale()) : e.deltaY > 0 && this.dollyOut(this.getZoomScale()), this.update(), (this.gesture = !1), (this.isPointerDown = !1); } } handleTouchStartRotate() { if (Qe.length === 2) { let e = 0.5 * (Qe[0].pageX + Qe[1].pageX), t = 0.5 * (Qe[0].pageY + Qe[1].pageY); this.rotateStart.set(e, t); } else this.rotateStart.set(Qe[0].pageX, Qe[0].pageY); } handleTouchStartPan() { if (Qe.length === 2) { let e = 0.5 * (Qe[0].pageX + Qe[1].pageX), t = 0.5 * (Qe[0].pageY + Qe[1].pageY); this.panStart.set(e, t); } else this.panStart.set(Qe[0].pageX, Qe[0].pageY); } handleTouchStartDolly() { let e = Qe[0].pageX - Qe[1].pageX, t = Qe[0].pageY - Qe[1].pageY, i = Math.sqrt(e * e + t * t); this.dollyStart.set(0, i); } handleTouchStartDollyPan() { this.enableZoom && this.handleTouchStartDolly(), this.enablePan && this.handleTouchStartPan(); } handleTouchStartDollyRotate() { this.enableZoom && this.handleTouchStartDolly(), this.enableRotate && this.handleTouchStartRotate(); } handleTouchMoveRotate(e) { if (Qe.length === 2) { let i = Np(e), r = 0.5 * (e.pageX + i.x), s = 0.5 * (e.pageY + i.y); this.rotateEnd.set(r, s); } else { if (e.pointerId !== Qe[0].pointerId) return; this.rotateEnd.set(e.pageX, e.pageY); } this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed); let t = this.domElement; t && (this.rotateLeft((2 * Math.PI * this.rotateDelta.x) / t.clientHeight), this.rotateUp((2 * Math.PI * this.rotateDelta.y) / t.clientHeight)), this.rotateStart.copy(this.rotateEnd); } handleTouchMovePan(e) { if (Qe.length === 2) { let t = Np(e), i = 0.5 * (e.pageX + t.x), r = 0.5 * (e.pageY + t.y); this.panEnd.set(i, r); } else { if (e.pointerId !== Qe[0].pointerId) return; this.panEnd.set(e.pageX, e.pageY); } this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed), this.pan(this.panDelta.x, this.panDelta.y), this.panStart.copy(this.panEnd); } handleTouchMoveDolly(e) { let t = Np(e), i = e.pageX - t.x, r = e.pageY - t.y, s = Math.sqrt(i * i + r * r); this.dollyEnd.set(0, s), this.dollyDelta.set(0, Math.pow(this.dollyEnd.y / this.dollyStart.y, this.zoomSpeed)), this.dollyOut(this.dollyDelta.y), this.dollyStart.copy(this.dollyEnd); } handleTouchMoveDollyPan(e) { this.enableZoom && this.handleTouchMoveDolly(e), this.enablePan && this.handleTouchMovePan(e); } handleTouchMoveDollyRotate(e) { this.enableZoom && this.handleTouchMoveDolly(e), this.enableRotate && this.handleTouchMoveRotate(e); } }; function ts(e) { let t = Math.PI * 2; for (; e <= -Math.PI; ) e += t; for (; e > Math.PI; ) e -= t; return e; } function Wb(e) { return 1 - Math.pow(1 - e, 4); } function hV(e) { return e.wheelDeltaY === 0 || e.deltaY === 0 ? Su && e.shiftKey && Math.abs(e.wheelDeltaX) >= 120 ? !1 : e.wheelDeltaX ? e.wheelDeltaX === -3 * e.deltaX : e.deltaMode === 0 : e.wheelDeltaY ? e.wheelDeltaY === -3 * e.deltaY : e.deltaMode === 0; } var Tf = new WeakMap(), cV = class extends bg { constructor(e) { super(e), (this.decoderPath = ''), (this.decoderConfig = {}), (this.decoderBinary = null), (this.decoderPending = null), (this.workerLimit = 4), (this.workerPool = []), (this.workerNextTaskID = 1), (this.workerSourceURL = ''), (this.defaultAttributeIDs = { position: 'POSITION', normal: 'NORMAL', color: 'COLOR', uv: 'TEX_COORD' }), (this.defaultAttributeTypes = { position: 'Float32Array', normal: 'Float32Array', color: 'Float32Array', uv: 'Float32Array' }); } setDecoderPath(e) { return (this.decoderPath = e), this; } setDecoderConfig(e) { return (this.decoderConfig = e), this; } setWorkerLimit(e) { return (this.workerLimit = e), this; } load(e, t, i, r) { let s = new Xf(this.manager); s.setPath(this.path), s.setResponseType('arraybuffer'), s.setRequestHeader(this.requestHeader), s.setWithCredentials(this.withCredentials), s.load( e, (n) => { this.decodeDracoFile(n, t).catch(r); }, i, r ); } decodeDracoFile(e, t, i, r) { let s = { attributeIDs: i || this.defaultAttributeIDs, attributeTypes: r || this.defaultAttributeTypes, useUniqueIDs: !!i }; return this.decodeGeometry(e, s).then(t); } decodeGeometry(e, t) { let i = JSON.stringify(t); if (Tf.has(e)) { let o = Tf.get(e); if (o.key === i) return o.promise; if (e.byteLength === 0) throw new Error('THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.'); } let r, s = this.workerNextTaskID++, n = e.byteLength, a = this._getWorker(s, n) .then( (o) => ( (r = o), new Promise((l, h) => { (r._callbacks[s] = { resolve: l, reject: h }), r.postMessage({ type: 'decode', id: s, taskConfig: t, buffer: e }, [e]); }) ) ) .then((o) => this._createGeometry(o.geometry)); return ( a .catch(() => !0) .then(() => { r && s && this._releaseTask(r, s); }), Tf.set(e, { key: i, promise: a }), a ); } _createGeometry(e) { let t = new Ve(); e.index && t.setIndex(new Xe(e.index.array, 1)); for (let i = 0; i < e.attributes.length; i++) { let r = e.attributes[i], s = r.name, n = r.array, a = r.itemSize; t.setAttribute(s, new Xe(n, a)); } return t; } _loadLibrary(e, t) { let i = new Xf(this.manager); return ( i.setPath(this.decoderPath), i.setResponseType(t), i.setWithCredentials(this.withCredentials), new Promise((r, s) => { i.load(e, r, void 0, s); }) ); } preload() { return this._initDecoder(), this; } _initDecoder() { if (this.decoderPending) return this.decoderPending; let e = typeof WebAssembly != 'object' || this.decoderConfig.type === 'js', t = []; return ( e ? t.push(this._loadLibrary('draco_decoder.js', 'text')) : (t.push(this._loadLibrary('draco_wasm_wrapper.js', 'text')), t.push(this._loadLibrary('draco_decoder.wasm', 'arraybuffer'))), (this.decoderPending = Promise.all(t).then((i) => { let r = i[0]; e || (this.decoderConfig.wasmBinary = i[1]); let s = dV.toString(), n = ['/* draco decoder */', r, '', '/* worker */', s.substring(s.indexOf('{') + 1, s.lastIndexOf('}'))].join(` `); this.workerSourceURL = URL.createObjectURL(new Blob([n])); })), this.decoderPending ); } _getWorker(e, t) { return this._initDecoder().then(() => { if (this.workerPool.length < this.workerLimit) { let r = new Worker(this.workerSourceURL); (r._callbacks = {}), (r._taskCosts = {}), (r._taskLoad = 0), r.postMessage({ type: 'init', decoderConfig: this.decoderConfig }), (r.onmessage = function (s) { let n = s.data; switch (n.type) { case 'decode': r._callbacks[n.id].resolve(n); break; case 'error': r._callbacks[n.id].reject(n); break; default: console.error('THREE.DRACOLoader: Unexpected message, "' + n.type + '"'); } }), this.workerPool.push(r); } else this.workerPool.sort(function (r, s) { return r._taskLoad > s._taskLoad ? -1 : 1; }); let i = this.workerPool[this.workerPool.length - 1]; return (i._taskCosts[e] = t), (i._taskLoad += t), i; }); } _releaseTask(e, t) { (e._taskLoad -= e._taskCosts[t]), delete e._callbacks[t], delete e._taskCosts[t]; } debug() { console.log( 'Task load: ', this.workerPool.map((e) => e._taskLoad) ); } dispose() { for (let e = 0; e < this.workerPool.length; ++e) this.workerPool[e].terminate(); return (this.workerPool.length = 0), this.workerSourceURL !== '' && URL.revokeObjectURL(this.workerSourceURL), this; } }; function dV() { let e, t; onmessage = function (a) { let o = a.data; switch (o.type) { case 'init': (e = o.decoderConfig), (t = new Promise(function (u) { (e.onModuleLoaded = function (c) { u({ draco: c }); }), DracoDecoderModule(e); })); break; case 'decode': let l = o.buffer, h = o.taskConfig; t.then((u) => { let c = u.draco, d = new c.Decoder(), p = new c.DecoderBuffer(); p.Init(new Int8Array(l), l.byteLength); try { let f = i(c, d, p, h), g = f.attributes.map((m) => m.array.buffer); f.index && g.push(f.index.array.buffer), self.postMessage({ type: 'decode', id: o.id, geometry: f }, g); } catch (f) { console.error(f), self.postMessage({ type: 'error', id: o.id, error: f.message }); } finally { c.destroy(p), c.destroy(d); } }); break; } }; function i(a, o, l, h) { let u = h.attributeIDs, c = h.attributeTypes, d, p, f = o.GetEncodedGeometryType(l); if (f === a.TRIANGULAR_MESH) (d = new a.Mesh()), (p = o.DecodeBufferToMesh(l, d)); else if (f === a.POINT_CLOUD) (d = new a.PointCloud()), (p = o.DecodeBufferToPointCloud(l, d)); else throw new Error('THREE.DRACOLoader: Unexpected geometry type.'); if (!p.ok() || d.ptr === 0) throw new Error('THREE.DRACOLoader: Decoding failed: ' + p.error_msg()); let g = { index: null, attributes: [] }; for (let m in u) { let v = self[c[m]], y, b; if (h.useUniqueIDs) (b = u[m]), (y = o.GetAttributeByUniqueId(d, b)); else { if (((b = o.GetAttributeId(d, a[u[m]])), b === -1)) continue; y = o.GetAttribute(d, b); } g.attributes.push(s(a, o, d, m, v, y)); } return f === a.TRIANGULAR_MESH && (g.index = r(a, o, d)), a.destroy(d), g; } function r(a, o, l) { let h = l.num_faces() * 3, u = h * 4, c = a._malloc(u); o.GetTrianglesUInt32Array(l, u, c); let d = new Uint32Array(a.HEAPF32.buffer, c, h).slice(); return a._free(c), { array: d, itemSize: 1 }; } function s(a, o, l, h, u, c) { let d = c.num_components(), p = l.num_points() * d, f = p * u.BYTES_PER_ELEMENT, g = n(a, u), m = a._malloc(f); o.GetAttributeDataArrayForAllPoints(l, c, g, f, m); let v = new u(a.HEAPF32.buffer, m, p).slice(); return a._free(m), { name: h, array: v, itemSize: d }; } function n(a, o) { switch (o) { case Float32Array: return a.DT_FLOAT32; case Int8Array: return a.DT_INT8; case Int16Array: return a.DT_INT16; case Int32Array: return a.DT_INT32; case Uint8Array: return a.DT_UINT8; case Uint16Array: return a.DT_UINT16; case Uint32Array: return a.DT_UINT32; } } } var Mn; function uV() { return Mn || ((Mn = new cV()), Mn.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.2/').preload()), Mn.decoderPending; } async function pV(e) { if (Mn) { let t = { attributeIDs: Mn.defaultAttributeIDs, attributeTypes: Mn.defaultAttributeTypes, useUniqueIDs: !1 }, i; try { i = await Mn.decodeGeometry(new Int8Array(e).buffer, t); } catch (r) { console.error(r); } if (i) return { index: i.index ? { array: i.index.array } : void 0, attributes: Object.entries(i.attributes).map(([r, s]) => ({ name: r, itemSize: s.itemSize, array: s.array })) }; } return null; } async function fV(e, t) { let [i, r] = L_(hm.deserialize(new Uint8Array(e))); RU(i); let s = []; i.scene.objects.traverse((n, a) => { a.type === 'Mesh' && a.geometry.type === 'NonParametricGeometry' && a.geometry.data.draco !== void 0 && s.push(a); }), s.length && (await uV()); for (let n of s) { let a = await pV(Si(n.geometry.data.draco)); if (a) { a.index && (n.geometry.data.index = { array: a.index.array, itemSize: 1, normalized: !1, type: 'Uint32Array' }); let o = {}; a.attributes.forEach(({ name: l, array: h, itemSize: u }) => { o[l] = { array: h, itemSize: u, type: 'Float32Array', normalized: !1 }; }), (n.geometry.data.attributes = o), (n.geometry.data.draco = void 0); } } return t && t(i), r.result().data; } var Xb = Object.keys(zS).filter((e) => isNaN(Number(e))), mV = class { constructor(e, t, i, r, s, n, a, o, l, h, u) { (this.preventScroll = s), (this.preventTouchScroll = n), (this.hideCursor = a), (this.requestRender = l), (this.isEnable = !1), (this.onResetRaycaster = () => { this.eventContext.raycasterNeedsUpdate = !0; }), (this.onTouchMovePreventScroll = (c) => { (c.touches.length > 1 || this.preventTouchScroll) && c.preventDefault(); }), (this.onMouseWheelPreventScroll = (c) => { this.preventScroll && c.preventDefault(); }), (this.eventContext = new ej(e, t, i, o, r, u ?? !1)), (this.handlers = { Spline: new gG(this.eventContext), Conditional: new AG(this.eventContext), Start: new jG(this.eventContext), Basic: new yG(this.eventContext, h, this), MouseHover: new zG(this.eventContext), Scroll: new FG(this.eventContext), Follow: new TG(this.eventContext), LookAt: new IG(this.eventContext) }); } activate() { let { scene: e, domElement: t, eventElement: i } = this.eventContext; this.hideCursor && (t.style.cursor = 'none'), (this.isEnable = !0), e.traverseEntity((r) => { r.addEventListener('requestRender', this.requestRender); }), Object.values(this.handlers).forEach((r) => r.connect()), Xb.forEach((r) => { Object.values(this.handlers).some((s) => s.domEventsNeeded.has(r)) && (t.addEventListener(r, this.onResetRaycaster), i.addEventListener(r, this.onResetRaycaster)); }), t.addEventListener('wheel', this.onMouseWheelPreventScroll), t.addEventListener('touchmove', this.onTouchMovePreventScroll); } deactivate() { let { scene: e, domElement: t } = this.eventContext; (this.isEnable = !1), (t.style.cursor = ''), Object.values(this.handlers).forEach((i) => i.disconnect()), e.traverseEntity((i) => { i.removeEventListener('requestRender', this.requestRender); }), Xb.forEach((i) => { t.removeEventListener(i, this.onResetRaycaster); }), t.removeEventListener('touchmove', this.onTouchMovePreventScroll), t.removeEventListener('wheel', this.onMouseWheelPreventScroll); } reset() { this.deactivate(), this.activate(); } updateUseWindowEvents(e) { let t = this.isEnable; t && this.deactivate(), (this.eventContext.useWindowEvents = e), t && this.activate(); } }, gV = class { constructor(e, t, i, r, s) { (this._aspect = 1), (this._renderer = e), (this._camera = t), (this._frameSize = new G().copy(i)), (this._editorSize = new G().copy(r)), (this._aspect = t.aspect), (this._fov = s ?? t.fov); } set frameSize(e) { this._frameSize.copy(e); } updateRenderer() { !this._renderer || this._renderer.setSize(this._frameSize.x, this._frameSize.y); } updateViewport() { if (!this._renderer || !this._camera || this._camera.cameraType !== 'PerspectiveCamera') return; let e = this._frameSize.x, t = this._frameSize.y, i = this._editorSize.y; (this._aspect = e / t), t <= i && (this._camera.zoom *= i / t), this._renderer.setViewport(0, 0, e, t); } updateCamera() { if (this._camera) if (this._camera.cameraType === 'PerspectiveCamera') { let e = this._frameSize.y, t = this._editorSize.y, i = this._fov; if (e > t) { let r = vV(e, 1080, 2160, 1, 15) / 100; (i *= e / t), (i *= 1 - r); } (this._camera.aspect = this._aspect), (this._camera.fov = i), this._camera.updateProjectionMatrix(); } else this._camera.setViewplaneSize(this._frameSize.x, this._frameSize.y); } setCamera(e) { (this._camera = e), (this._aspect = e.aspect), (this._fov = e.fov); } revert() { let e = window.innerWidth, t = window.innerHeight; this._renderer && (this._renderer.setViewport(0, 0, e, t), this._renderer.setSize(e, t)), this._camera && ((this._camera.aspect = e / t), (this._camera.fov = this._fov), this._camera.setViewplaneSize(e, t), this._camera.updateProjectionMatrix()); } }; function vV(e, t, i, r, s) { return ((e - t) / (i - t)) * (s - r) + r; } var h2 = { RED: 0, GREEN: 1, BLUE: 2, ALPHA: 3 }, Fh = 'varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}', yV = `#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale; #if PASS == 1 uniform vec4 kernel64[32]; #else uniform vec4 kernel16[8]; #endif varying vec2 vUv;void main(){ #ifdef FOREGROUND vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale; #else float CoC=texture2D(cocBuffer,vUv).g*scale; #endif if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{ #ifdef FOREGROUND vec2 step=texelSize*max(CoC,CoCNearFar.g*scale); #else vec2 step=texelSize*CoC; #endif #if PASS == 1 vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0; #else vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue; #endif }}`, Qc = class extends ri { constructor(e = !1, t = !1) { super({ name: 'BokehMaterial', defines: { PASS: e ? '2' : '1' }, uniforms: { kernel64: new Oe(null), kernel16: new Oe(null), inputBuffer: new Oe(null), cocBuffer: new Oe(null), texelSize: new Oe(new G()), scale: new Oe(1) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: yV, vertexShader: Fh }), (this.toneMapped = !1), t && (this.defines.FOREGROUND = '1'), this.generateKernel(); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } set cocBuffer(e) { this.uniforms.cocBuffer.value = e; } setCoCBuffer(e) { this.uniforms.cocBuffer.value = e; } get scale() { return this.uniforms.scale.value; } set scale(e) { this.uniforms.scale.value = e; } getScale(e) { return (this.uniforms.scale.value = e); } setScale(e) { this.uniforms.scale.value = e; } generateKernel() { let e = 2.39996323, t = new Float32Array(128), i = new Float32Array(32), r = 0, s = 0; for (let o = 0; o < 80; ++o) { let l = o * e, h = Math.sqrt(o) / Math.sqrt(80), u = h * Math.cos(l), c = h * Math.sin(l); o % 5 === 0 ? ((i[s++] = u), (i[s++] = c)) : ((t[r++] = u), (t[r++] = c)); } let n = [], a = []; for (let o = 0; o < 128; ) n.push(new $e(t[o++], t[o++], t[o++], t[o++])); for (let o = 0; o < 32; ) a.push(new $e(i[o++], i[o++], i[o++], i[o++])); (this.uniforms.kernel64.value = n), (this.uniforms.kernel16.value = a); } setTexelSize(e, t) { this.uniforms.texelSize.value.set(e, t); } setSize(e, t) { this.uniforms.texelSize.value.set(1 / e, 1 / t); } }; function qb(e, t, i) { return e * (t - i) - t; } function sg(e, t, i) { return Math.min(Math.max((e + t) / (t - i), 0), 1); } var xV = `#include #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }void main(){float depth=readDepth(vUv); #ifdef PERSPECTIVE_CAMERA float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar); #else float linearDepth=depth; #endif float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`, bV = class extends ri { constructor(e) { super({ name: 'CircleOfConfusionMaterial', defines: { DEPTH_PACKING: '0' }, uniforms: { depthBuffer: new Oe(null), focusDistance: new Oe(0), focusRange: new Oe(0), cameraNear: new Oe(0.3), cameraFar: new Oe(1e3) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: xV, vertexShader: Fh }), (this.toneMapped = !1), (this.uniforms.focalLength = this.uniforms.focusRange), this.adoptCameraSettings(e); } get near() { return this.uniforms.cameraNear.value; } get far() { return this.uniforms.cameraFar.value; } set depthBuffer(e) { this.uniforms.depthBuffer.value = e; } set depthPacking(e) { (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0); } setDepthBuffer(e, t = qs) { (this.depthBuffer = e), (this.depthPacking = t); } get focusDistance() { return this.uniforms.focusDistance.value; } set focusDistance(e) { this.uniforms.focusDistance.value = e; } get worldFocusDistance() { return -qb(this.focusDistance, this.near, this.far); } set worldFocusDistance(e) { this.focusDistance = sg(-e, this.near, this.far); } getFocusDistance(e) { this.uniforms.focusDistance.value = e; } setFocusDistance(e) { this.uniforms.focusDistance.value = e; } get focalLength() { return this.focusRange; } set focalLength(e) { this.focusRange = e; } get focusRange() { return this.uniforms.focusRange.value; } set focusRange(e) { this.uniforms.focusRange.value = e; } get worldFocusRange() { return -qb(this.focusRange, this.near, this.far); } set worldFocusRange(e) { this.focusRange = sg(-e, this.near, this.far); } getFocalLength(e) { return this.focusRange; } setFocalLength(e) { this.focusRange = e; } adoptCameraSettings(e) { e && ((this.uniforms.cameraNear.value = e.near), (this.uniforms.cameraFar.value = e.far), e instanceof wi ? (this.defines.PERSPECTIVE_CAMERA = '1') : delete this.defines.PERSPECTIVE_CAMERA, (this.needsUpdate = !0)); } }, wV = `#include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include #include }`, _V = 'uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}', Yb = class extends ri { constructor(e = new G()) { super({ name: 'KawaseBlurMaterial', uniforms: { inputBuffer: new Oe(null), texelSize: new Oe(new G()), halfTexelSize: new Oe(new G()), kernel: new Oe(0), scale: new Oe(1) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: wV, vertexShader: _V }), (this.toneMapped = !1), this.setTexelSize(e.x, e.y); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.inputBuffer = e; } get scale() { return this.uniforms.scale.value; } set scale(e) { this.uniforms.scale.value = e; } getScale() { return this.uniforms.scale.value; } setScale(e) { this.uniforms.scale.value = e; } getKernel() { return null; } get kernel() { return this.uniforms.kernel.value; } set kernel(e) { this.uniforms.kernel.value = e; } setKernel(e) { this.kernel = e; } setTexelSize(e, t) { this.uniforms.texelSize.value.set(e, t), this.uniforms.halfTexelSize.value.set(e, t).multiplyScalar(0.5); } setSize(e, t) { let i = this.uniforms; i.texelSize.value.set(1 / e, 1 / t), i.halfTexelSize.value.copy(i.texelSize.value).multiplyScalar(0.5); } }, AV = `#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; #include }`, SV = class extends ri { constructor() { super({ name: 'CopyMaterial', uniforms: { inputBuffer: new Oe(null), opacity: new Oe(1) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: AV, vertexShader: Fh }), (this.toneMapped = !1); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } getOpacity(e) { return this.uniforms.opacity.value; } setOpacity(e) { this.uniforms.opacity.value = e; } }, MV = `varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif #if EDGE_DETECTION_MODE == 1 #include #endif #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1 #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);} #elif PREDICATION_MODE == 2 uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);} #endif #if PREDICATION_MODE != 0 vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);} #endif #if EDGE_DETECTION_MODE != 0 uniform sampler2D inputBuffer; #endif void main(){ #if EDGE_DETECTION_MODE == 0 const vec2 threshold=vec2(DEPTH_THRESHOLD); #elif PREDICATION_MODE != 0 vec2 threshold=calculatePredicatedThreshold(); #else const vec2 threshold=vec2(EDGE_THRESHOLD); #endif #if EDGE_DETECTION_MODE == 0 vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 1 float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #elif EDGE_DETECTION_MODE == 2 vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0); #endif }`, EV = `uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1; #if EDGE_DETECTION_MODE != 0 varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5; #endif void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0); #if EDGE_DETECTION_MODE != 0 vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0); #endif gl_Position=vec4(position.xy,1.0,1.0);}`, Lv = { DEPTH: 0, LUMA: 1, COLOR: 2 }, c2 = { DISABLED: 0, DEPTH: 1, CUSTOM: 2 }, CV = class extends ri { constructor(e = new G(), t = Lv.COLOR) { super({ name: 'EdgeDetectionMaterial', defines: { THREE_REVISION: Wo.replace(/\D+/g, ''), LOCAL_CONTRAST_ADAPTATION_FACTOR: '2.0', EDGE_THRESHOLD: '0.1', DEPTH_THRESHOLD: '0.01', PREDICATION_MODE: '0', PREDICATION_THRESHOLD: '0.01', PREDICATION_SCALE: '2.0', PREDICATION_STRENGTH: '1.0', DEPTH_PACKING: '0' }, uniforms: { inputBuffer: new Oe(null), depthBuffer: new Oe(null), predicationBuffer: new Oe(null), texelSize: new Oe(e) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: MV, vertexShader: EV }), (this.toneMapped = !1), (this.edgeDetectionMode = t); } set depthBuffer(e) { this.uniforms.depthBuffer.value = e; } set depthPacking(e) { (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0); } setDepthBuffer(e, t = qs) { (this.depthBuffer = e), (this.depthPacking = t); } get edgeDetectionMode() { return Number(this.defines.EDGE_DETECTION_MODE); } set edgeDetectionMode(e) { (this.defines.EDGE_DETECTION_MODE = e.toFixed(0)), (this.needsUpdate = !0); } getEdgeDetectionMode() { return this.edgeDetectionMode; } setEdgeDetectionMode(e) { this.edgeDetectionMode = e; } get localContrastAdaptationFactor() { return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR); } set localContrastAdaptationFactor(e) { (this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR = e.toFixed('6')), (this.needsUpdate = !0); } getLocalContrastAdaptationFactor() { return this.localContrastAdaptationFactor; } setLocalContrastAdaptationFactor(e) { this.localContrastAdaptationFactor = e; } get edgeDetectionThreshold() { return Number(this.defines.EDGE_THRESHOLD); } set edgeDetectionThreshold(e) { (this.defines.EDGE_THRESHOLD = e.toFixed('6')), (this.defines.DEPTH_THRESHOLD = (e * 0.1).toFixed('6')), (this.needsUpdate = !0); } getEdgeDetectionThreshold() { return this.edgeDetectionThreshold; } setEdgeDetectionThreshold(e) { this.edgeDetectionThreshold = e; } get predicationMode() { return Number(this.defines.PREDICATION_MODE); } set predicationMode(e) { (this.defines.PREDICATION_MODE = e.toFixed(0)), (this.needsUpdate = !0); } getPredicationMode() { return this.predicationMode; } setPredicationMode(e) { this.predicationMode = e; } set predicationBuffer(e) { this.uniforms.predicationBuffer.value = e; } setPredicationBuffer(e) { this.uniforms.predicationBuffer.value = e; } get predicationThreshold() { return Number(this.defines.PREDICATION_THRESHOLD); } set predicationThreshold(e) { (this.defines.PREDICATION_THRESHOLD = e.toFixed('6')), (this.needsUpdate = !0); } getPredicationThreshold() { return this.predicationThreshold; } setPredicationThreshold(e) { this.predicationThreshold = e; } get predicationScale() { return Number(this.defines.PREDICATION_SCALE); } set predicationScale(e) { (this.defines.PREDICATION_SCALE = e.toFixed('6')), (this.needsUpdate = !0); } getPredicationScale() { return this.predicationScale; } setPredicationScale(e) { this.predicationScale = e; } get predicationStrength() { return Number(this.defines.PREDICATION_STRENGTH); } set predicationStrength(e) { (this.defines.PREDICATION_STRENGTH = e.toFixed('6')), (this.needsUpdate = !0); } getPredicationStrength() { return this.predicationStrength; } setPredicationStrength(e) { this.predicationStrength = e; } setSize(e, t) { this.uniforms.texelSize.value.set(1 / e, 1 / t); } }, TV = `#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv; #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #if THREE_REVISION >= 137 vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);} #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`, PV = 'uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}', Nr = { FRAGMENT_HEAD: 'FRAGMENT_HEAD', FRAGMENT_MAIN_UV: 'FRAGMENT_MAIN_UV', FRAGMENT_MAIN_IMAGE: 'FRAGMENT_MAIN_IMAGE', VERTEX_HEAD: 'VERTEX_HEAD', VERTEX_MAIN_SUPPORT: 'VERTEX_MAIN_SUPPORT' }, ng = class extends ri { constructor(e, t, i, r, s = !1) { super({ name: 'EffectMaterial', defines: { THREE_REVISION: Wo.replace(/\D+/g, ''), DEPTH_PACKING: '0', ENCODE_OUTPUT: '1' }, uniforms: { inputBuffer: new Oe(null), depthBuffer: new Oe(null), resolution: new Oe(new G()), texelSize: new Oe(new G()), cameraNear: new Oe(0.3), cameraFar: new Oe(1e3), aspect: new Oe(1), time: new Oe(0) }, blending: fi, depthWrite: !1, depthTest: !1, dithering: s }), (this.toneMapped = !1), e && this.setShaderParts(e), t && this.setDefines(t), i && this.setUniforms(i), this.adoptCameraSettings(r); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } get depthBuffer() { return this.uniforms.depthBuffer.value; } set depthBuffer(e) { this.uniforms.depthBuffer.value = e; } get depthPacking() { return Number(this.defines.DEPTH_PACKING); } set depthPacking(e) { (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0); } setDepthBuffer(e, t = qs) { (this.depthBuffer = e), (this.depthPacking = t); } setShaderParts(e) { return ( (this.fragmentShader = TV.replace(Nr.FRAGMENT_HEAD, e.get(Nr.FRAGMENT_HEAD)) .replace(Nr.FRAGMENT_MAIN_UV, e.get(Nr.FRAGMENT_MAIN_UV)) .replace(Nr.FRAGMENT_MAIN_IMAGE, e.get(Nr.FRAGMENT_MAIN_IMAGE))), (this.vertexShader = PV.replace(Nr.VERTEX_HEAD, e.get(Nr.VERTEX_HEAD)).replace( Nr.VERTEX_MAIN_SUPPORT, e.get(Nr.VERTEX_MAIN_SUPPORT) )), (this.needsUpdate = !0), this ); } setDefines(e) { for (let t of e.entries()) this.defines[t[0]] = t[1]; return (this.needsUpdate = !0), this; } setUniforms(e) { for (let t of e.entries()) this.uniforms[t[0]] = t[1]; return this; } setExtensions(e) { this.extensions = {}; for (let t of e) this.extensions[t] = !0; return this; } get encodeOutput() { return this.defines.ENCODE_OUTPUT !== void 0; } set encodeOutput(e) { this.encodeOutput !== e && (e ? (this.defines.ENCODE_OUTPUT = '1') : delete this.defines.ENCODE_OUTPUT, (this.needsUpdate = !0)); } isOutputEncodingEnabled(e) { return this.encodeOutput; } setOutputEncodingEnabled(e) { this.encodeOutput = e; } get time() { return this.uniforms.time.value; } set time(e) { this.uniforms.time.value = e; } setDeltaTime(e) { this.uniforms.time.value += e; } adoptCameraSettings(e) { e && ((this.uniforms.cameraNear.value = e.near), (this.uniforms.cameraFar.value = e.far), e instanceof wi ? (this.defines.PERSPECTIVE_CAMERA = '1') : delete this.defines.PERSPECTIVE_CAMERA, (this.needsUpdate = !0)); } setSize(e, t) { let i = this.uniforms; i.resolution.value.set(e, t), i.texelSize.value.set(1 / e, 1 / t), (i.aspect.value = e / t); } static get Section() { return Nr; } }, DV = `#include #if THREE_REVISION < 143 #define luminance(v) linearToRelativeLuminance(v) #endif #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb); #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);l*=low*high; #elif defined(THRESHOLD) l=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=vec4(texel.rgb*l,l); #else gl_FragColor=vec4(l); #endif }`, LV = class extends ri { constructor(e = !1, t = null) { super({ name: 'LuminanceMaterial', defines: { THREE_REVISION: Wo.replace(/\D+/g, '') }, uniforms: { inputBuffer: new Oe(null), threshold: new Oe(0), smoothing: new Oe(1), range: new Oe(null) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: DV, vertexShader: Fh }), (this.toneMapped = !1), (this.colorOutput = e), (this.luminanceRange = t); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } get threshold() { return this.uniforms.threshold.value; } set threshold(e) { this.smoothing > 0 || e > 0 ? (this.defines.THRESHOLD = '1') : delete this.defines.THRESHOLD, (this.uniforms.threshold.value = e); } getThreshold() { return this.threshold; } setThreshold(e) { this.threshold = e; } get smoothing() { return this.uniforms.smoothing.value; } set smoothing(e) { this.threshold > 0 || e > 0 ? (this.defines.THRESHOLD = '1') : delete this.defines.THRESHOLD, (this.uniforms.smoothing.value = e); } getSmoothingFactor() { return this.smoothing; } setSmoothingFactor(e) { this.smoothing = e; } get useThreshold() { return this.threshold > 0 || this.smoothing > 0; } set useThreshold(e) {} get colorOutput() { return this.defines.COLOR !== void 0; } set colorOutput(e) { e ? (this.defines.COLOR = '1') : delete this.defines.COLOR, (this.needsUpdate = !0); } isColorOutputEnabled(e) { return this.colorOutput; } setColorOutputEnabled(e) { this.colorOutput = e; } get useRange() { return this.luminanceRange !== null; } set useRange(e) { this.luminanceRange = null; } get luminanceRange() { return this.uniforms.range.value; } set luminanceRange(e) { e !== null ? (this.defines.RANGE = '1') : delete this.defines.RANGE, (this.uniforms.range.value = e), (this.needsUpdate = !0); } getLuminanceRange() { return this.luminanceRange; } setLuminanceRange(e) { this.luminanceRange = e; } }, OV = `#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef MASK_PRECISION_HIGH uniform mediump sampler2D maskTexture; #else uniform lowp sampler2D maskTexture; #endif #if MASK_FUNCTION != 0 uniform float strength; #endif varying vec2 vUv;void main(){ #if COLOR_CHANNEL == 0 float mask=texture2D(maskTexture,vUv).r; #elif COLOR_CHANNEL == 1 float mask=texture2D(maskTexture,vUv).g; #elif COLOR_CHANNEL == 2 float mask=texture2D(maskTexture,vUv).b; #else float mask=texture2D(maskTexture,vUv).a; #endif #if MASK_FUNCTION == 0 #ifdef INVERTED mask=step(mask,0.0); #else mask=1.0-step(mask,0.0); #endif #else mask=clamp(mask*strength,0.0,1.0); #ifdef INVERTED mask=1.0-mask; #endif #endif #if MASK_FUNCTION == 2 gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask); #else gl_FragColor=mask*texture2D(inputBuffer,vUv); #endif }`, d2 = { DISCARD: 0, MULTIPLY: 1, MULTIPLY_RGB_SET_ALPHA: 2 }, IV = class extends ri { constructor(e = null) { super({ name: 'MaskMaterial', uniforms: { maskTexture: new Oe(e), inputBuffer: new Oe(null), strength: new Oe(1) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: OV, vertexShader: Fh }), (this.toneMapped = !1), this.setColorChannel(h2.RED), this.setMaskFunction(d2.DISCARD); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } set maskTexture(e) { (this.uniforms.maskTexture.value = e), delete this.defines.MASK_PRECISION_HIGH, e.type !== Mi && (this.defines.MASK_PRECISION_HIGH = '1'), (this.needsUpdate = !0); } setMaskTexture(e) { this.maskTexture = e; } set colorChannel(e) { (this.defines.COLOR_CHANNEL = e.toFixed(0)), (this.needsUpdate = !0); } setColorChannel(e) { this.colorChannel = e; } set maskFunction(e) { (this.defines.MASK_FUNCTION = e.toFixed(0)), (this.needsUpdate = !0); } setMaskFunction(e) { this.maskFunction = e; } get inverted() { return this.defines.INVERTED !== void 0; } set inverted(e) { this.inverted && !e ? delete this.defines.INVERTED : e && (this.defines.INVERTED = '1'), (this.needsUpdate = !0); } isInverted() { return this.inverted; } setInverted(e) { this.inverted = e; } get strength() { return this.uniforms.strength.value; } set strength(e) { this.uniforms.strength.value = e; } getStrength() { return this.strength; } setStrength(e) { this.strength = e; } }, RV = `#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize) #if __VERSION__ < 300 #define round(v) floor(v + 0.5) #endif #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;iend&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;iend&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0); #endif }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){ #if !defined(DISABLE_CORNER_DETECTION) vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0); #endif }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){ #if !defined(DISABLE_DIAG_DETECTION) weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){ #endif vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d); #if !defined(DISABLE_DIAG_DETECTION) }else{e.r=0.0;} #endif }if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`, BV = 'uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}', zV = class extends ri { constructor(e = new G(), t = new G()) { super({ name: 'SMAAWeightsMaterial', defines: { MAX_SEARCH_STEPS_INT: '16', MAX_SEARCH_STEPS_FLOAT: '16.0', MAX_SEARCH_STEPS_DIAG_INT: '8', MAX_SEARCH_STEPS_DIAG_FLOAT: '8.0', CORNER_ROUNDING: '25', CORNER_ROUNDING_NORM: '0.25', AREATEX_MAX_DISTANCE: '16.0', AREATEX_MAX_DISTANCE_DIAG: '20.0', AREATEX_PIXEL_SIZE: '(1.0 / vec2(160.0, 560.0))', AREATEX_SUBTEX_SIZE: '(1.0 / 7.0)', SEARCHTEX_SIZE: 'vec2(66.0, 33.0)', SEARCHTEX_PACKED_SIZE: 'vec2(64.0, 16.0)' }, uniforms: { inputBuffer: new Oe(null), searchTexture: new Oe(null), areaTexture: new Oe(null), resolution: new Oe(t), texelSize: new Oe(e) }, blending: fi, depthWrite: !1, depthTest: !1, fragmentShader: RV, vertexShader: BV }), (this.toneMapped = !1); } set inputBuffer(e) { this.uniforms.inputBuffer.value = e; } setInputBuffer(e) { this.uniforms.inputBuffer.value = e; } get searchTexture() { return this.uniforms.searchTexture.value; } set searchTexture(e) { this.uniforms.searchTexture.value = e; } get areaTexture() { return this.uniforms.areaTexture.value; } set areaTexture(e) { this.uniforms.areaTexture.value = e; } setLookupTextures(e, t) { (this.searchTexture = e), (this.areaTexture = t); } get orthogonalSearchSteps() { return Number(this.defines.MAX_SEARCH_STEPS_INT); } set orthogonalSearchSteps(e) { let t = Math.min(Math.max(e, 0), 112); (this.defines.MAX_SEARCH_STEPS_INT = t.toFixed('0')), (this.defines.MAX_SEARCH_STEPS_FLOAT = t.toFixed('1')), (this.needsUpdate = !0); } setOrthogonalSearchSteps(e) { this.orthogonalSearchSteps = e; } get diagonalSearchSteps() { return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT); } set diagonalSearchSteps(e) { let t = Math.min(Math.max(e, 0), 20); (this.defines.MAX_SEARCH_STEPS_DIAG_INT = t.toFixed('0')), (this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT = t.toFixed('1')), (this.needsUpdate = !0); } setDiagonalSearchSteps(e) { this.diagonalSearchSteps = e; } get diagonalDetection() { return this.defines.DISABLE_DIAG_DETECTION === void 0; } set diagonalDetection(e) { e ? delete this.defines.DISABLE_DIAG_DETECTION : (this.defines.DISABLE_DIAG_DETECTION = '1'), (this.needsUpdate = !0); } isDiagonalDetectionEnabled() { return this.diagonalDetection; } setDiagonalDetectionEnabled(e) { this.diagonalDetection = e; } get cornerRounding() { return Number(this.defines.CORNER_ROUNDING); } set cornerRounding(e) { let t = Math.min(Math.max(e, 0), 100); (this.defines.CORNER_ROUNDING = t.toFixed('4')), (this.defines.CORNER_ROUNDING_NORM = (t / 100).toFixed('4')), (this.needsUpdate = !0); } setCornerRounding(e) { this.cornerRounding = e; } get cornerDetection() { return this.defines.DISABLE_CORNER_DETECTION === void 0; } set cornerDetection(e) { e ? delete this.defines.DISABLE_CORNER_DETECTION : (this.defines.DISABLE_CORNER_DETECTION = '1'), (this.needsUpdate = !0); } isCornerRoundingEnabled() { return this.cornerDetection; } setCornerRoundingEnabled(e) { this.cornerDetection = e; } setSize(e, t) { let i = this.uniforms; i.texelSize.value.set(1 / e, 1 / t), i.resolution.value.set(e, t); } }, NV = new Yo(), hn = null; function UV() { if (hn === null) { let e = new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]), t = new Float32Array([0, 0, 2, 0, 0, 2]); (hn = new Ve()), hn.setAttribute !== void 0 ? (hn.setAttribute('position', new Xe(e, 3)), hn.setAttribute('uv', new Xe(t, 2))) : (hn.addAttribute('position', new Xe(e, 3)), hn.addAttribute('uv', new Xe(t, 2))); } return hn; } var Tr = class { constructor(e = 'Pass', t = new pa(), i = NV) { (this.name = e), (this.renderer = null), (this.scene = t), (this.camera = i), (this.screen = null), (this.rtt = !0), (this.needsSwap = !0), (this.needsDepthTexture = !1), (this.enabled = !0); } get renderToScreen() { return !this.rtt; } set renderToScreen(e) { if (this.rtt === e) { let t = this.getFullscreenMaterial(); t !== null && (t.needsUpdate = !0), (this.rtt = !e); } } setRenderer(e) { this.renderer = e; } isEnabled() { return this.enabled; } setEnabled(e) { this.enabled = e; } get fullscreenMaterial() { return this.screen !== null ? this.screen.material : null; } set fullscreenMaterial(e) { let t = this.screen; t !== null ? (t.material = e) : ((t = new tr(UV(), e)), (t.frustumCulled = !1), this.scene === null && (this.scene = new pa()), this.scene.add(t), (this.screen = t)); } getFullscreenMaterial() { return this.fullscreenMaterial; } setFullscreenMaterial(e) { this.fullscreenMaterial = e; } getDepthTexture() { return null; } setDepthTexture(e, t = qs) {} render(e, t, i, r, s) { throw new Error('Render method not implemented!'); } setSize(e, t) {} initialize(e, t, i) {} dispose() { for (let e of Object.keys(this)) { let t = this[e]; if (t !== null && typeof t.dispose == 'function') { if (t instanceof pa || t === this.renderer) continue; this[e].dispose(); } } } }, nu = class extends Tr { constructor(e, t = !0) { super('CopyPass'), (this.fullscreenMaterial = new SV()), (this.needsSwap = !1), (this.renderTarget = e), e === void 0 && ((this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTarget.texture.name = 'CopyPass.Target')), (this.autoResize = t); } get resize() { return this.autoResize; } set resize(e) { this.autoResize = e; } get texture() { return this.renderTarget.texture; } getTexture() { return this.renderTarget.texture; } setAutoResizeEnabled(e) { this.autoResize = e; } render(e, t, i, r, s) { (this.fullscreenMaterial.inputBuffer = t.texture), e.setRenderTarget(this.renderToScreen ? null : this.renderTarget), e.render(this.scene, this.camera); } setSize(e, t) { this.autoResize && this.renderTarget.setSize(e, t); } initialize(e, t, i) { i !== void 0 && ((this.renderTarget.texture.type = i), i !== Mi ? (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1') : e.outputEncoding === Ke && (this.renderTarget.texture.encoding = Ke)); } }, FV = class extends Tr { constructor() { super('ClearMaskPass', null, null), (this.needsSwap = !1); } render(e, t, i, r, s) { let n = e.state.buffers.stencil; n.setLocked(!1), n.setTest(!1); } }, Pf = new Ge(), Ou = class extends Tr { constructor(e = !0, t = !0, i = !1) { super('ClearPass', null, null), (this.needsSwap = !1), (this.color = e), (this.depth = t), (this.stencil = i), (this.overrideClearColor = null), (this.overrideClearAlpha = -1); } setClearFlags(e, t, i) { (this.color = e), (this.depth = t), (this.stencil = i); } getOverrideClearColor() { return this.overrideClearColor; } setOverrideClearColor(e) { this.overrideClearColor = e; } getOverrideClearAlpha() { return this.overrideClearAlpha; } setOverrideClearAlpha(e) { this.overrideClearAlpha = e; } render(e, t, i, r, s) { let n = this.overrideClearColor, a = this.overrideClearAlpha, o = e.getClearAlpha(), l = n !== null, h = a >= 0; l ? (Pf.copy(e.getClearColor(Pf)), e.setClearColor(n, h ? a : o)) : h && e.setClearAlpha(a), e.setRenderTarget(this.renderToScreen ? null : t), e.clear(this.color, this.depth, this.stencil), l ? e.setClearColor(Pf, o) : h && e.setClearAlpha(o); } }, cn = -1, Fi = class extends Vi { constructor(e, t = cn, i = cn, r = 1) { super(), (this.resizable = e), (this.base = new G(1, 1)), (this.preferred = new G(t, i)), (this.target = this.preferred), (this.s = r); } get width() { let { base: e, preferred: t, scale: i } = this, r; return ( t.width !== cn ? (r = t.width) : t.height !== cn ? (r = Math.round(t.height * (e.width / Math.max(e.height, 1)))) : (r = Math.round(e.width * i)), r ); } set width(e) { this.preferredWidth = e; } get height() { let { base: e, preferred: t, scale: i } = this, r; return ( t.height !== cn ? (r = t.height) : t.width !== cn ? (r = Math.round(t.width / Math.max(e.width / Math.max(e.height, 1), 1))) : (r = Math.round(e.height * i)), r ); } set height(e) { this.preferredHeight = e; } getWidth() { return this.width; } getHeight() { return this.height; } get scale() { return this.s; } set scale(e) { this.s !== e && ((this.s = e), this.preferred.setScalar(cn), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } getScale() { return this.scale; } setScale(e) { this.scale = e; } get baseWidth() { return this.base.width; } set baseWidth(e) { this.base.width !== e && ((this.base.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } getBaseWidth() { return this.base.width; } setBaseWidth(e) { this.base.width !== e && ((this.base.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } get baseHeight() { return this.base.height; } set baseHeight(e) { this.base.height !== e && ((this.base.height = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } getBaseHeight() { return this.baseHeight; } setBaseHeight(e) { this.baseHeight = e; } setBaseSize(e, t) { (this.base.width !== e || this.base.height !== t) && (this.base.set(e, t), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } get preferredWidth() { return this.preferred.width; } set preferredWidth(e) { this.preferred.width !== e && ((this.preferred.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } getPreferredWidth() { return this.preferredWidth; } setPreferredWidth(e) { this.preferredWidth = e; } get preferredHeight() { return this.preferred.height; } set preferredHeight(e) { this.preferred.height !== e && ((this.preferred.height = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } getPreferredHeight() { return this.preferredHeight; } setPreferredHeight(e) { this.preferredHeight = e; } setPreferredSize(e, t) { (this.preferred.width !== e || this.preferred.height !== t) && (this.preferred.set(e, t), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height)); } copy(e) { this.base.set(e.getBaseWidth(), e.getBaseHeight()), this.preferred.set(e.getPreferredWidth(), e.getPreferredHeight()), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height); } static get AUTO_SIZE() { return cn; } }, Df = !1, Qb = class { constructor(e = null) { (this.originalMaterials = new Map()), (this.material = null), (this.materials = null), (this.materialsBackSide = null), (this.materialsDoubleSide = null), (this.materialsFlatShaded = null), (this.materialsFlatShadedBackSide = null), (this.materialsFlatShadedDoubleSide = null), this.setMaterial(e), (this.meshCount = 0), (this.replaceMaterial = (t) => { if (t.isMesh) { let i; if (t.material.flatShading) switch (t.material.side) { case er: i = this.materialsFlatShadedDoubleSide; break; case hi: i = this.materialsFlatShadedBackSide; break; default: i = this.materialsFlatShaded; break; } else switch (t.material.side) { case er: i = this.materialsDoubleSide; break; case hi: i = this.materialsBackSide; break; default: i = this.materials; break; } this.originalMaterials.set(t, t.material), t.isSkinnedMesh ? (t.material = i[2]) : t.isInstancedMesh ? (t.material = i[1]) : (t.material = i[0]), ++this.meshCount; } }); } setMaterial(e) { if ((this.disposeMaterials(), (this.material = e), e !== null)) { let t = (this.materials = [e.clone(), e.clone(), e.clone()]); for (let i of t) (i.uniforms = Object.assign({}, e.uniforms)), (i.side = Vr); (t[2].skinning = !0), (this.materialsBackSide = t.map((i) => { let r = i.clone(); return (r.uniforms = Object.assign({}, e.uniforms)), (r.side = hi), r; })), (this.materialsDoubleSide = t.map((i) => { let r = i.clone(); return (r.uniforms = Object.assign({}, e.uniforms)), (r.side = er), r; })), (this.materialsFlatShaded = t.map((i) => { let r = i.clone(); return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), r; })), (this.materialsFlatShadedBackSide = t.map((i) => { let r = i.clone(); return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), (r.side = hi), r; })), (this.materialsFlatShadedDoubleSide = t.map((i) => { let r = i.clone(); return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), (r.side = er), r; })); } } render(e, t, i) { let r = e.shadowMap.enabled; if (((e.shadowMap.enabled = !1), Df)) { let s = this.originalMaterials; (this.meshCount = 0), t.traverse(this.replaceMaterial), e.render(t, i); for (let n of s) n[0].material = n[1]; this.meshCount !== s.size && s.clear(); } else { let s = t.overrideMaterial; (t.overrideMaterial = this.material), e.render(t, i), (t.overrideMaterial = s); } e.shadowMap.enabled = r; } disposeMaterials() { if (this.material !== null) { let e = this.materials .concat(this.materialsBackSide) .concat(this.materialsDoubleSide) .concat(this.materialsFlatShaded) .concat(this.materialsFlatShadedBackSide) .concat(this.materialsFlatShadedDoubleSide); for (let t of e) t.dispose(); } } dispose() { this.originalMaterials.clear(), this.disposeMaterials(); } static get workaroundEnabled() { return Df; } static set workaroundEnabled(e) { Df = e; } }, kV = class extends Tr { constructor(e, t, i = null) { super('RenderPass', e, t), (this.needsSwap = !1), (this.clearPass = new Ou()), (this.overrideMaterialManager = i === null ? null : new Qb(i)), (this.ignoreBackground = !1), (this.skipShadowMapUpdate = !1), (this.selection = null); } get renderToScreen() { return super.renderToScreen; } set renderToScreen(e) { (super.renderToScreen = e), (this.clearPass.renderToScreen = e); } get overrideMaterial() { let e = this.overrideMaterialManager; return e !== null ? e.material : null; } set overrideMaterial(e) { let t = this.overrideMaterialManager; e !== null ? t !== null ? t.setMaterial(e) : (this.overrideMaterialManager = new Qb(e)) : t !== null && (t.dispose(), (this.overrideMaterialManager = null)); } getOverrideMaterial() { return this.overrideMaterial; } setOverrideMaterial(e) { this.overrideMaterial = e; } get clear() { return this.clearPass.enabled; } set clear(e) { this.clearPass.enabled = e; } getSelection() { return this.selection; } setSelection(e) { this.selection = e; } isBackgroundDisabled() { return this.ignoreBackground; } setBackgroundDisabled(e) { this.ignoreBackground = e; } isShadowMapDisabled() { return this.skipShadowMapUpdate; } setShadowMapDisabled(e) { this.skipShadowMapUpdate = e; } getClearPass() { return this.clearPass; } render(e, t, i, r, s) { let n = this.scene, a = this.camera, o = this.selection, l = a.layers.mask, h = n.background, u = e.shadowMap.autoUpdate, c = this.renderToScreen ? null : t; o !== null && a.layers.set(o.getLayer()), this.skipShadowMapUpdate && (e.shadowMap.autoUpdate = !1), (this.ignoreBackground || this.clearPass.overrideClearColor !== null) && (n.background = null), this.clearPass.enabled && this.clearPass.render(e, t), e.setRenderTarget(c), this.overrideMaterialManager !== null ? this.overrideMaterialManager.render(e, n, a) : e.render(n, a), (a.layers.mask = l), (n.background = h), (e.shadowMap.autoUpdate = u); } }, Zb = class extends Tr { constructor(e, t, { resolutionScale: i = 1, width: r = Fi.AUTO_SIZE, height: s = Fi.AUTO_SIZE, renderTarget: n } = {}) { super('DepthPass'), (this.needsSwap = !1), (this.renderPass = new kV(e, t, new Aw({ depthPacking: cw }))); let a = this.renderPass; (a.skipShadowMapUpdate = !0), (a.ignoreBackground = !0); let o = a.getClearPass(); (o.overrideClearColor = new Ge(16777215)), (o.overrideClearAlpha = 1), (this.renderTarget = n), this.renderTarget === void 0 && ((this.renderTarget = new ii(1, 1, { minFilter: Ot, magFilter: Ot, stencilBuffer: !1 })), (this.renderTarget.texture.name = 'DepthPass.Target')); let l = (this.resolution = new Fi(this, r, s, i)); l.addEventListener('change', (h) => this.setSize(l.baseWidth, l.baseHeight)); } get texture() { return this.renderTarget.texture; } getTexture() { return this.renderTarget.texture; } getResolution() { return this.resolution; } getResolutionScale() { return this.resolution.scale; } setResolutionScale(e) { this.resolution.scale = e; } render(e, t, i, r, s) { let n = this.renderToScreen ? null : this.renderTarget; this.renderPass.render(e, n); } setSize(e, t) { let i = this.resolution; i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height); } }, F9 = new Float32Array([255 / 256 / 256 ** 3, 255 / 256 / 256 ** 2, 255 / 256 / 256, 255 / 256]), nt = { SKIP: 0, ADD: 1, ALPHA: 2, AVERAGE: 3, COLOR_BURN: 4, COLOR_DODGE: 5, DARKEN: 6, DIFFERENCE: 7, EXCLUSION: 8, LIGHTEN: 9, MULTIPLY: 10, DIVIDE: 11, NEGATION: 12, NORMAL: 13, OVERLAY: 14, REFLECT: 15, SCREEN: 16, SOFT_LIGHT: 17, SUBTRACT: 18 }, jV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}', GV = 'vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}', VV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}', HV = 'float blend(const in float x,const in float y){return(y==0.0)?y:max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', WV = 'float blend(const in float x,const in float y){return(y==1.0)?y:min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', XV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}', qV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}', YV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}', QV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}', ZV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}', KV = 'float blend(const in float x,const in float y){return(y>0.0)?min(x/y,1.0):1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', JV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}', $V = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}', eH = 'float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', tH = 'float blend(const in float x,const in float y){return(y==1.0)?y:min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', iH = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}', rH = 'float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}', sH = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}', nH = new Map([ [nt.SKIP, null], [nt.ADD, jV], [nt.ALPHA, GV], [nt.AVERAGE, VV], [nt.COLOR_BURN, HV], [nt.COLOR_DODGE, WV], [nt.DARKEN, XV], [nt.DIFFERENCE, qV], [nt.EXCLUSION, YV], [nt.LIGHTEN, QV], [nt.MULTIPLY, ZV], [nt.DIVIDE, KV], [nt.NEGATION, JV], [nt.NORMAL, $V], [nt.OVERLAY, eH], [nt.REFLECT, tH], [nt.SCREEN, iH], [nt.SOFT_LIGHT, rH], [nt.SUBTRACT, sH] ]), aH = class extends Vi { constructor(e, t = 1) { super(), (this.f = e), (this.opacity = new Oe(t)); } getOpacity() { return this.opacity.value; } setOpacity(e) { this.opacity.value = e; } get blendFunction() { return this.f; } set blendFunction(e) { (this.f = e), this.dispatchEvent({ type: 'change' }); } getBlendFunction() { return this.blendFunction; } setBlendFunction(e) { this.blendFunction = e; } getShaderCode() { return nH.get(this.blendFunction); } }, ms = { NONE: 0, DEPTH: 1, CONVOLUTION: 2 }, Ss = class extends Vi { constructor( e, t, { attributes: i = ms.NONE, blendFunction: r = nt.SCREEN, defines: s = new Map(), uniforms: n = new Map(), extensions: a = null, vertexShader: o = null } = {} ) { super(), (this.name = e), (this.renderer = null), (this.attributes = i), (this.fragmentShader = t), (this.vertexShader = o), (this.defines = s), (this.uniforms = n), (this.extensions = a), (this.blendMode = new aH(r)), this.blendMode.addEventListener('change', (l) => this.setChanged()); } getName() { return this.name; } setRenderer(e) { this.renderer = e; } getDefines() { return this.defines; } getUniforms() { return this.uniforms; } getExtensions() { return this.extensions; } getBlendMode() { return this.blendMode; } getAttributes() { return this.attributes; } setAttributes(e) { (this.attributes = e), this.setChanged(); } getFragmentShader() { return this.fragmentShader; } setFragmentShader(e) { (this.fragmentShader = e), this.setChanged(); } getVertexShader() { return this.vertexShader; } setVertexShader(e) { (this.vertexShader = e), this.setChanged(); } setChanged() { this.dispatchEvent({ type: 'change' }); } setDepthTexture(e, t = qs) {} update(e, t, i) {} setSize(e, t) {} initialize(e, t, i) {} dispose() { for (let e of Object.keys(this)) { let t = this[e]; if (t !== null && typeof t.dispose == 'function') { if (t instanceof pa || t === this.renderer) continue; this[e].dispose(); } } } }; function Kb(e, t, i) { for (let r of t) { let s = '$1' + e + r.charAt(0).toUpperCase() + r.slice(1), n = new RegExp('([^\\.])(\\b' + r + '\\b)', 'g'); for (let a of i.entries()) a[1] !== null && i.set(a[0], a[1].replace(n, s)); } } function oH(e, t, i, r, s, n, a) { let o = new Map([ ['fragment', t.getFragmentShader()], ['vertex', t.getVertexShader()] ]), l = o.get('fragment') !== void 0 && /mainImage/.test(o.get('fragment')), h = o.get('fragment') !== void 0 && /mainUv/.test(o.get('fragment')), u = [], c = [], d = !1, p = !1; if (o.get('fragment') === void 0) console.error('Missing fragment shader', t); else if (h && (a & ms.CONVOLUTION) !== 0) console.error('Effects that transform UV coordinates are incompatible with convolution effects', t); else if (!l && !h) console.error('The fragment shader contains neither a mainImage nor a mainUv function', t); else { let f = /(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g, g = ng.Section; if (h) { let v = ` ${e}MainUv(UV); `; i.set(g.FRAGMENT_MAIN_UV, i.get(g.FRAGMENT_MAIN_UV) + v), (d = !0); } if (o.get('vertex') !== null && /mainSupport/.test(o.get('vertex'))) { let v = ` ${e}MainSupport(`; (v += /mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get('vertex')) ? `vUv); ` : `); `), i.set(g.VERTEX_MAIN_SUPPORT, i.get(g.VERTEX_MAIN_SUPPORT) + v), (u = u.concat([...o.get('vertex').matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map((y) => y[1]))), (c = c.concat(u).concat([...o.get('vertex').matchAll(f)].map((y) => y[1]))); } (c = c.concat([...o.get('fragment').matchAll(f)].map((v) => v[1]))), (c = c.concat([...t.defines.keys()].map((v) => v.replace(/\([\w\s,]*\)/g, '')))), (c = c.concat([...t.uniforms.keys()])), t.uniforms.forEach((v, y) => n.set(e + y.charAt(0).toUpperCase() + y.slice(1), v)), t.defines.forEach((v, y) => s.set(e + y.charAt(0).toUpperCase() + y.slice(1), v)), Kb(e, c, s), Kb(e, c, o); let m = t.blendMode; if ((r.set(m.blendFunction, m), l)) { let v = /MainImage *\([\w\s,]*?depth[\w\s,]*?\)/, y = `${e}MainImage(color0, UV, `; (a & ms.DEPTH) !== 0 && v.test(o.get('fragment')) && ((y += 'depth, '), (p = !0)), (y += `color1); `); let b = e + 'BlendOpacity'; n.set(b, m.opacity), (y += `color0 = blend${m.blendFunction}(color0, color1, ${b}); `), i.set(g.FRAGMENT_MAIN_IMAGE, i.get(g.FRAGMENT_MAIN_IMAGE) + y), (y = `uniform float ${b}; `), i.set(g.FRAGMENT_HEAD, i.get(g.FRAGMENT_HEAD) + y); } i.set( g.FRAGMENT_HEAD, i.get(g.FRAGMENT_HEAD) + o.get('fragment') + ` ` ), o.get('vertex') !== null && i.set( g.VERTEX_HEAD, i.get(g.VERTEX_HEAD) + o.get('vertex') + ` ` ); } return { varyings: u, transformedUv: d, readDepth: p }; } var Lf = class extends Tr { constructor(e, ...t) { super('EffectPass'), (this.fullscreenMaterial = new ng(null, null, null, e)), (this.effects = t.sort((i, r) => r.attributes - i.attributes)), (this.skipRendering = !1), (this.uniformCount = 0), (this.varyingCount = 0), (this.minTime = 1), (this.maxTime = Number.POSITIVE_INFINITY); } get encodeOutput() { return this.fullscreenMaterial.encodeOutput; } set encodeOutput(e) { this.fullscreenMaterial.encodeOutput = e; } get dithering() { return this.fullscreenMaterial.dithering; } set dithering(e) { let t = this.fullscreenMaterial; (t.dithering = e), (t.needsUpdate = !0); } verifyResources() { let e = this.renderer.capabilities, t = Math.min(e.maxFragmentUniforms, e.maxVertexUniforms); this.uniformCount > t && console.warn( "The current rendering context doesn't support more than " + t + ' uniforms, but ' + this.uniformCount + ' were defined' ), (t = e.maxVaryings), this.varyingCount > t && console.warn( "The current rendering context doesn't support more than " + t + ' varyings, but ' + this.varyingCount + ' were defined' ); } updateMaterial() { let e = ng.Section, t = new Map([ [e.FRAGMENT_HEAD, ''], [e.FRAGMENT_MAIN_UV, ''], [e.FRAGMENT_MAIN_IMAGE, ''], [e.VERTEX_HEAD, ''], [e.VERTEX_MAIN_SUPPORT, ''] ]), i = new Map(), r = new Map(), s = new Map(), n = new Set(), a = 0, o = 0, l = 0, h = !1, u = !1; for (let d of this.effects) if (d.blendMode.blendFunction === nt.SKIP) l |= d.getAttributes() & ms.DEPTH; else if ((l & d.getAttributes() & ms.CONVOLUTION) !== 0) console.error('Convolution effects cannot be merged', d); else { l |= d.getAttributes(); let p = 'e' + a++, f = oH(p, d, t, i, r, s, l); if (((o += f.varyings.length), (h = h || f.transformedUv), (u = u || f.readDepth), d.extensions !== null)) for (let g of d.extensions) n.add(g); } let c = /\bblend\b/g; for (let d of i.values()) { let p = d.getShaderCode().replace(c, `blend${d.blendFunction}`); t.set( e.FRAGMENT_HEAD, t.get(e.FRAGMENT_HEAD) + p + ` ` ); } if ((l & ms.DEPTH) !== 0) { if (u) { let d = `float depth = readDepth(UV); `; t.set(e.FRAGMENT_MAIN_IMAGE, d + t.get(e.FRAGMENT_MAIN_IMAGE)); } this.needsDepthTexture = this.getDepthTexture() === null; } else this.needsDepthTexture = !1; if (h) { let d = `vec2 transformedUv = vUv; `; t.set(e.FRAGMENT_MAIN_UV, d + t.get(e.FRAGMENT_MAIN_UV)), r.set('UV', 'transformedUv'); } else r.set('UV', 'vUv'); t.forEach((d, p, f) => f.set( p, d.trim().replace( /^#/, ` #` ) ) ), (this.uniformCount = s.size), (this.varyingCount = o), (this.skipRendering = a === 0), (this.needsSwap = !this.skipRendering), this.fullscreenMaterial.setShaderParts(t).setExtensions(n).setUniforms(s).setDefines(r); } recompile() { this.updateMaterial(), this.verifyResources(); } getDepthTexture() { return this.fullscreenMaterial.depthBuffer; } setDepthTexture(e, t = qs) { (this.fullscreenMaterial.depthBuffer = e), (this.fullscreenMaterial.depthPacking = t); for (let i of this.effects) i.setDepthTexture(e, t); } render(e, t, i, r, s) { for (let n of this.effects) n.update(e, t, r); if (!this.skipRendering || this.renderToScreen) { let n = this.fullscreenMaterial; (n.inputBuffer = t.texture), (n.time += r), e.setRenderTarget(this.renderToScreen ? null : i), e.render(this.scene, this.camera); } } setSize(e, t) { this.fullscreenMaterial.setSize(e, t); for (let i of this.effects) i.setSize(e, t); } initialize(e, t, i) { this.renderer = e; for (let r of this.effects) r.initialize(e, t, i), r.addEventListener('change', (s) => this.handleEvent(s)); this.updateMaterial(), this.verifyResources(), i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'); } dispose() { super.dispose(); for (let e of this.effects) e.dispose(); } handleEvent(e) { switch (e.type) { case 'change': this.recompile(); break; } } }, lH = [ new Float32Array([0, 0]), new Float32Array([0, 1, 1]), new Float32Array([0, 1, 1, 2]), new Float32Array([0, 1, 2, 2, 3]), new Float32Array([0, 1, 2, 3, 4, 4, 5]), new Float32Array([0, 1, 2, 3, 4, 5, 7, 8, 9, 10]) ], u2 = class extends Tr { constructor({ resolutionScale: e = 0.5, width: t = Fi.AUTO_SIZE, height: i = Fi.AUTO_SIZE, kernelSize: r = Ov.LARGE } = {}) { super('KawaseBlurPass'), (this.renderTargetA = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTargetA.texture.name = 'Blur.Target.A'), (this.renderTargetB = this.renderTargetA.clone()), (this.renderTargetB.texture.name = 'Blur.Target.B'); let s = (this.resolution = new Fi(this, t, i, e)); s.addEventListener('change', (n) => this.setSize(s.baseWidth, s.baseHeight)), (this.blurMaterial = new Yb()), (this.ditheredBlurMaterial = new Yb()), (this.ditheredBlurMaterial.uniforms.scale = this.blurMaterial.uniforms.scale), (this.ditheredBlurMaterial.dithering = !0), (this.dithering = !1), (this.kernelSize = r); } getResolution() { return this.resolution; } get width() { return this.resolution.width; } set width(e) { this.resolution.preferredWidth = e; } get height() { return this.resolution.height; } set height(e) { this.resolution.preferredHeight = e; } get scale() { return this.blurMaterial.scale; } set scale(e) { this.blurMaterial.scale = e; } getScale() { return this.blurMaterial.scale; } setScale(e) { this.blurMaterial.scale = e; } getKernelSize() { return this.kernelSize; } setKernelSize(e) { this.kernelSize = e; } getResolutionScale() { return this.resolution.scale; } setResolutionScale(e) { this.resolution.scale = e; } render(e, t, i, r, s) { let n = this.scene, a = this.camera, o = this.renderTargetA, l = this.renderTargetB, h = lH[this.kernelSize], u = this.blurMaterial, c = t, d, p; for (this.fullscreenMaterial = u, d = 0, p = h.length - 1; d < p; ++d) { let f = (d & 1) === 0 ? o : l; (u.kernel = h[d]), (u.inputBuffer = c.texture), e.setRenderTarget(f), e.render(n, a), (c = f); } this.dithering && ((u = this.ditheredBlurMaterial), (this.fullscreenMaterial = u)), (u.kernel = h[d]), (u.inputBuffer = c.texture), e.setRenderTarget(this.renderToScreen ? null : i), e.render(n, a); } setSize(e, t) { let i = this.resolution; i.setBaseSize(e, t); let r = i.width, s = i.height; this.renderTargetA.setSize(r, s), this.renderTargetB.setSize(r, s), this.blurMaterial.setSize(r, s), this.ditheredBlurMaterial.setSize(r, s); } initialize(e, t, i) { i !== void 0 && ((this.renderTargetA.texture.type = i), (this.renderTargetB.texture.type = i), i !== Mi ? ((this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'), (this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1')) : e.outputEncoding === Ke && ((this.renderTargetA.texture.encoding = Ke), (this.renderTargetB.texture.encoding = Ke))); } static get AUTO_SIZE() { return Fi.AUTO_SIZE; } }, hH = class extends Tr { constructor({ width: e = Fi.AUTO_SIZE, height: t = Fi.AUTO_SIZE, renderTarget: i, luminanceRange: r, colorOutput: s } = {}) { super('LuminancePass'), (this.fullscreenMaterial = new LV(s, r)), (this.needsSwap = !1), (this.renderTarget = i), this.renderTarget === void 0 && ((this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTarget.texture.name = 'LuminancePass.Target'), (this.renderTarget.texture.generateMipmaps = !1)); let n = (this.resolution = new Fi(this, e, t)); n.addEventListener('change', (a) => this.setSize(n.baseWidth, n.baseHeight)); } get texture() { return this.renderTarget.texture; } getTexture() { return this.renderTarget.texture; } getResolution() { return this.resolution; } render(e, t, i, r, s) { let n = this.fullscreenMaterial; (n.inputBuffer = t.texture), e.setRenderTarget(this.renderToScreen ? null : this.renderTarget), e.render(this.scene, this.camera); } setSize(e, t) { let i = this.resolution; i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height); } initialize(e, t, i) { i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'); } }, cH = class extends Tr { constructor(e, t) { super('MaskPass', e, t), (this.needsSwap = !1), (this.clearPass = new Ou(!1, !1, !0)), (this.inverse = !1); } get inverted() { return this.inverse; } set inverted(e) { this.inverse = e; } get clear() { return this.clearPass.enabled; } set clear(e) { this.clearPass.enabled = e; } getClearPass() { return this.clearPass; } isInverted() { return this.inverted; } setInverted(e) { this.inverted = e; } render(e, t, i, r, s) { let n = e.getContext(), a = e.state.buffers, o = this.scene, l = this.camera, h = this.clearPass, u = this.inverted ? 0 : 1, c = 1 - u; a.color.setMask(!1), a.depth.setMask(!1), a.color.setLocked(!0), a.depth.setLocked(!0), a.stencil.setTest(!0), a.stencil.setOp(n.REPLACE, n.REPLACE, n.REPLACE), a.stencil.setFunc(n.ALWAYS, u, 4294967295), a.stencil.setClear(c), a.stencil.setLocked(!0), this.clearPass.enabled && (this.renderToScreen ? h.render(e, null) : (h.render(e, t), h.render(e, i))), this.renderToScreen ? (e.setRenderTarget(null), e.render(o, l)) : (e.setRenderTarget(t), e.render(o, l), e.setRenderTarget(i), e.render(o, l)), a.color.setLocked(!1), a.depth.setLocked(!1), a.stencil.setLocked(!1), a.stencil.setFunc(n.EQUAL, 1, 4294967295), a.stencil.setOp(n.KEEP, n.KEEP, n.KEEP), a.stencil.setLocked(!0); } }, un = class extends Tr { constructor(e, t = 'inputBuffer') { super('ShaderPass'), (this.fullscreenMaterial = e), (this.inputBufferUniform = null), this.setInput(t); } setInput(e) { if (((this.inputBufferUniform = null), this.fullscreenMaterial !== null)) { let t = this.fullscreenMaterial.uniforms; t !== void 0 && t[e] !== void 0 && (this.inputBufferUniform = t[e]); } } render(e, t, i, r, s) { this.inputBufferUniform !== null && t !== null && (this.inputBufferUniform.value = t.texture), e.setRenderTarget(this.renderToScreen ? null : i), e.render(this.scene, this.camera); } initialize(e, t, i) { i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'); } }, Of = 1 / 1e3, dH = 1e3, uH = class { constructor() { (this.previousTime = 0), (this.currentTime = 0), (this.delta = 0), (this.fixedDelta = 1e3 / 60), (this.elapsed = 0), (this.timescale = 1), (this.fixedDeltaEnabled = !1), (this.autoReset = !1); } setFixedDeltaEnabled(e) { return (this.fixedDeltaEnabled = e), this; } isAutoResetEnabled(e) { return this.autoReset; } setAutoResetEnabled(e) { return ( typeof document < 'u' && document.hidden !== void 0 && (e ? document.addEventListener('visibilitychange', this) : document.removeEventListener('visibilitychange', this), (this.autoReset = e)), this ); } getDelta() { return this.delta * Of; } getFixedDelta() { return this.fixedDelta * Of; } setFixedDelta(e) { return (this.fixedDelta = e * dH), this; } getElapsed() { return this.elapsed * Of; } getTimescale() { return this.timescale; } setTimescale(e) { return (this.timescale = e), this; } update(e) { return ( this.fixedDeltaEnabled ? (this.delta = this.fixedDelta) : ((this.previousTime = this.currentTime), (this.currentTime = e !== void 0 ? e : performance.now()), (this.delta = this.currentTime - this.previousTime)), (this.delta *= this.timescale), (this.elapsed += this.delta), this ); } reset() { return (this.delta = 0), (this.elapsed = 0), (this.currentTime = performance.now()), this; } handleEvent(e) { document.hidden || (this.currentTime = performance.now()); } dispose() { this.setAutoResetEnabled(!1); } }, pH = class { constructor(e = null, { depthBuffer: t = !0, stencilBuffer: i = !1, multisampling: r = 0, frameBufferType: s } = {}) { (this.renderer = null), (this.inputBuffer = this.createBuffer(t, i, s, r)), (this.outputBuffer = this.inputBuffer.clone()), (this.copyPass = new nu()), (this.depthTexture = null), (this.passes = []), (this.timer = new uH()), (this.autoRenderToScreen = !0), this.setRenderer(e); } get multisampling() { return this.inputBuffer.samples || 0; } set multisampling(e) { let t = this.inputBuffer, i = this.multisampling; i > 0 && e > 0 ? ((this.inputBuffer.samples = e), (this.outputBuffer.samples = e), this.inputBuffer.dispose(), this.outputBuffer.dispose()) : i !== e && (this.inputBuffer.dispose(), this.outputBuffer.dispose(), (this.inputBuffer = this.createBuffer(t.depthBuffer, t.stencilBuffer, t.texture.type, e)), (this.inputBuffer.depthTexture = this.depthTexture), (this.outputBuffer = this.inputBuffer.clone())); } getTimer() { return this.timer; } getRenderer() { return this.renderer; } setRenderer(e) { if (((this.renderer = e), e !== null)) { let t = e.getSize(new G()), i = e.getContext().getContextAttributes().alpha, r = this.inputBuffer.texture.type; r === Mi && e.outputEncoding === Ke && ((this.inputBuffer.texture.encoding = Ke), (this.outputBuffer.texture.encoding = Ke), this.inputBuffer.dispose(), this.outputBuffer.dispose()), (e.autoClear = !1), this.setSize(t.width, t.height); for (let s of this.passes) s.initialize(e, i, r); } } replaceRenderer(e, t = !0) { let i = this.renderer, r = i.domElement.parentNode; return this.setRenderer(e), t && r !== null && (r.removeChild(i.domElement), r.appendChild(e.domElement)), i; } createDepthTexture() { let e = (this.depthTexture = new pg()); return ( (this.inputBuffer.depthTexture = e), this.inputBuffer.dispose(), this.inputBuffer.stencilBuffer ? ((e.format = ba), (e.type = ca)) : (e.type = gn), e ); } deleteDepthTexture() { if (this.depthTexture !== null) { this.depthTexture.dispose(), (this.depthTexture = null), (this.inputBuffer.depthTexture = null), this.inputBuffer.dispose(); for (let e of this.passes) e.setDepthTexture(null); } } createBuffer(e, t, i, r) { let s = this.renderer, n = s === null ? new G() : s.getDrawingBufferSize(new G()), a = { minFilter: mt, magFilter: mt, stencilBuffer: t, depthBuffer: e, type: i }, o = new ii(n.width, n.height, a); return ( r > 0 && ((o.ignoreDepthForMultisampleCopy = !1), (o.samples = r)), i === Mi && s !== null && s.outputEncoding === Ke && (o.texture.encoding = Ke), (o.texture.name = 'EffectComposer.Buffer'), (o.texture.generateMipmaps = !1), o ); } addPass(e, t) { let i = this.passes, r = this.renderer, s = r.getDrawingBufferSize(new G()), n = r.getContext().getContextAttributes().alpha, a = this.inputBuffer.texture.type; if ( (e.setRenderer(r), e.setSize(s.width, s.height), e.initialize(r, n, a), this.autoRenderToScreen && (i.length > 0 && (i[i.length - 1].renderToScreen = !1), e.renderToScreen && (this.autoRenderToScreen = !1)), t !== void 0 ? i.splice(t, 0, e) : i.push(e), this.autoRenderToScreen && (i[i.length - 1].renderToScreen = !0), e.needsDepthTexture || this.depthTexture !== null) ) if (this.depthTexture === null) { let o = this.createDepthTexture(); for (e of i) e.setDepthTexture(o); } else e.setDepthTexture(this.depthTexture); } removePass(e) { let t = this.passes, i = t.indexOf(e); if (i !== -1 && t.splice(i, 1).length > 0) { if (this.depthTexture !== null) { let r = (s, n) => s || n.needsDepthTexture; t.reduce(r, !1) || (e.getDepthTexture() === this.depthTexture && e.setDepthTexture(null), this.deleteDepthTexture()); } this.autoRenderToScreen && i === t.length && ((e.renderToScreen = !1), t.length > 0 && (t[t.length - 1].renderToScreen = !0)); } } removeAllPasses() { let e = this.passes; this.deleteDepthTexture(), e.length > 0 && (this.autoRenderToScreen && (e[e.length - 1].renderToScreen = !1), (this.passes = [])); } render(e) { let t = this.renderer, i = this.copyPass, r = this.inputBuffer, s = this.outputBuffer, n = !1, a, o, l; e === void 0 && (e = this.timer.update().getDelta()); for (let h of this.passes) h.enabled && (h.render(t, r, s, e, n), h.needsSwap && (n && ((i.renderToScreen = h.renderToScreen), (a = t.getContext()), (o = t.state.buffers.stencil), o.setFunc(a.NOTEQUAL, 1, 4294967295), i.render(t, r, s, e, n), o.setFunc(a.EQUAL, 1, 4294967295)), (l = r), (r = s), (s = l)), h instanceof cH ? (n = !0) : h instanceof FV && (n = !1)); } setSize(e, t, i) { let r = this.renderer; if (e === void 0 || t === void 0) { let n = r.getSize(new G()); (e = n.width), (t = n.height); } r.setSize(e, t, i); let s = r.getDrawingBufferSize(new G()); this.inputBuffer.setSize(s.width, s.height), this.outputBuffer.setSize(s.width, s.height); for (let n of this.passes) n.setSize(s.width, s.height); } reset() { let e = this.timer.isAutoResetEnabled(); this.dispose(), (this.autoRenderToScreen = !0), this.timer.setAutoResetEnabled(e); } dispose() { for (let e of this.passes) e.dispose(); (this.passes = []), this.inputBuffer !== null && this.inputBuffer.dispose(), this.outputBuffer !== null && this.outputBuffer.dispose(), this.deleteDepthTexture(), this.copyPass.dispose(), this.timer.dispose(); } }, Ov = { VERY_SMALL: 0, SMALL: 1, MEDIUM: 2, LARGE: 3, VERY_LARGE: 4, HUGE: 5 }, fH = `#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D map; #else uniform lowp sampler2D map; #endif uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`, mH = class extends Ss { constructor({ blendFunction: e = nt.SCREEN, luminanceThreshold: t = 0.9, luminanceSmoothing: i = 0.025, resolutionScale: r = 0.5, intensity: s = 1, width: n = Fi.AUTO_SIZE, height: a = Fi.AUTO_SIZE, kernelSize: o = Ov.LARGE } = {}) { super('BloomEffect', fH, { blendFunction: e, uniforms: new Map([ ['map', new Oe(null)], ['intensity', new Oe(s)] ]) }), (this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTarget.texture.name = 'Bloom.Target'), (this.renderTarget.texture.generateMipmaps = !1), (this.uniforms.get('map').value = this.renderTarget.texture), (this.luminancePass = new hH({ renderTarget: this.renderTarget, colorOutput: !0 })), (this.luminanceMaterial.threshold = t), (this.luminanceMaterial.smoothingFactor = i), (this.blurPass = new u2({ resolutionScale: r, width: n, height: a, kernelSize: o })); let l = this.blurPass.getResolution(); l.addEventListener('change', (h) => this.setSize(l.baseWidth, l.baseHeight)); } get texture() { return this.renderTarget.texture; } getTexture() { return this.renderTarget.texture; } get resolution() { return this.blurPass.resolution; } getResolution() { return this.blurPass.resolution; } getBlurPass() { return this.blurPass; } getLuminancePass() { return this.luminancePass; } get luminanceMaterial() { return this.luminancePass.fullscreenMaterial; } getLuminanceMaterial() { return this.luminancePass.fullscreenMaterial; } get width() { return this.resolution.width; } set width(e) { this.resolution.preferredWidth = e; } get height() { return this.resolution.height; } set height(e) { this.resolution.preferredHeight = e; } get dithering() { return this.blurPass.dithering; } set dithering(e) { this.blurPass.dithering = e; } get kernelSize() { return this.blurPass.kernelSize; } set kernelSize(e) { this.blurPass.kernelSize = e; } get distinction() { return console.warn(this.name, 'distinction was removed'), 1; } set distinction(e) { console.warn(this.name, 'distinction was removed'); } get intensity() { return this.uniforms.get('intensity').value; } set intensity(e) { this.uniforms.get('intensity').value = e; } getIntensity() { return this.intensity; } setIntensity(e) { this.intensity = e; } getResolutionScale() { return this.resolution.scale; } setResolutionScale(e) { this.resolution.scale = e; } update(e, t, i) { let r = this.renderTarget; this.luminancePass.enabled ? (this.luminancePass.render(e, t, r), this.blurPass.render(e, r, r)) : this.blurPass.render(e, t, r); } setSize(e, t) { let i = this.resolution; i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height), this.luminancePass.resolution.copy(i); } initialize(e, t, i) { this.blurPass.initialize(e, t, i), i !== void 0 && ((this.renderTarget.texture.type = i), e.outputEncoding === Ke && (this.renderTarget.texture.encoding = Ke)); } }, gH = 'uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}', vH = class extends Ss { constructor({ blendFunction: e = nt.NORMAL, brightness: t = 0, contrast: i = 0 } = {}) { super('BrightnessContrastEffect', gH, { blendFunction: e, uniforms: new Map([ ['brightness', new Oe(t)], ['contrast', new Oe(i)] ]) }); } get brightness() { return this.uniforms.get('brightness').value; } set brightness(e) { this.uniforms.get('brightness').value = e; } getBrightness(e) { return this.brightness; } setBrightness(e) { this.brightness = e; } get contrast() { return this.uniforms.get('contrast').value; } set contrast(e) { this.uniforms.get('contrast').value = e; } getContrast(e) { return this.contrast; } setContrast(e) { this.contrast = e; } }, yH = 'void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}', xH = class extends Ss { constructor(e = nt.NORMAL) { super('ColorAverageEffect', yH, { blendFunction: e }); } }, bH = 'varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}', wH = 'uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vUvR=uv+shift;vUvB=uv-shift;}', _H = class extends Ss { constructor({ blendFunction: e = nt.NORMAL, offset: t = new G(0.001, 5e-4) } = {}) { super('ChromaticAberrationEffect', bH, { vertexShader: wH, blendFunction: e, attributes: ms.CONVOLUTION, uniforms: new Map([['offset', new Oe(t)]]) }); } get offset() { return this.uniforms.get('offset').value; } set offset(e) { this.uniforms.get('offset').value = e; } getOffset() { return this.offset; } setOffset(e) { this.offset = e; } }, AH = `#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer; #else uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer; #endif uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`, SH = class extends Ss { constructor( e, { blendFunction: t = nt.NORMAL, worldFocusDistance: i, worldFocusRange: r, focusDistance: s = 0, focalLength: n = 0.1, focusRange: a = n, bokehScale: o = 1, width: l = Fi.AUTO_SIZE, height: h = Fi.AUTO_SIZE } = {} ) { super('DepthOfFieldEffect', AH, { blendFunction: t, attributes: ms.DEPTH, uniforms: new Map([ ['nearColorBuffer', new Oe(null)], ['farColorBuffer', new Oe(null)], ['nearCoCBuffer', new Oe(null)], ['scale', new Oe(1)] ]) }), (this.camera = e), (this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTarget.texture.name = 'DoF.Intermediate'), (this.renderTarget.texture.generateMipmaps = !1), (this.renderTargetMasked = this.renderTarget.clone()), (this.renderTargetMasked.texture.name = 'DoF.Masked.Far'), (this.renderTargetNear = this.renderTarget.clone()), (this.renderTargetNear.texture.name = 'DoF.Bokeh.Near'), (this.uniforms.get('nearColorBuffer').value = this.renderTargetNear.texture), (this.renderTargetFar = this.renderTarget.clone()), (this.renderTargetFar.texture.name = 'DoF.Bokeh.Far'), (this.uniforms.get('farColorBuffer').value = this.renderTargetFar.texture), (this.renderTargetCoC = this.renderTarget.clone()), (this.renderTargetCoC.texture.name = 'DoF.CoC'), (this.renderTargetCoCBlurred = this.renderTargetCoC.clone()), (this.renderTargetCoCBlurred.texture.name = 'DoF.CoC.Blurred'), (this.uniforms.get('nearCoCBuffer').value = this.renderTargetCoCBlurred.texture), (this.cocPass = new un(new bV(e))); let u = this.cocMaterial; (u.focusDistance = s), (u.focusRange = a), i !== void 0 && (u.worldFocusDistance = i), r !== void 0 && (u.worldFocusRange = r), (this.blurPass = new u2({ kernelSize: Ov.MEDIUM, width: l, height: h })); let c = this.blurPass.getResolution(); c.addEventListener('change', (p) => this.setSize(c.getBaseWidth(), c.getBaseHeight())), (this.maskPass = new un(new IV(this.renderTargetCoC.texture))); let d = this.maskPass.fullscreenMaterial; (d.maskFunction = d2.MULTIPLY), (d.colorChannel = h2.GREEN), (this.bokehNearBasePass = new un(new Qc(!1, !0))), (this.bokehNearBasePass.fullscreenMaterial.cocBuffer = this.renderTargetCoCBlurred.texture), (this.bokehNearFillPass = new un(new Qc(!0, !0))), (this.bokehNearFillPass.fullscreenMaterial.cocBuffer = this.renderTargetCoCBlurred.texture), (this.bokehFarBasePass = new un(new Qc(!1, !1))), (this.bokehFarBasePass.fullscreenMaterial.cocBuffer = this.renderTargetCoC.texture), (this.bokehFarFillPass = new un(new Qc(!0, !1))), (this.bokehFarFillPass.fullscreenMaterial.cocBuffer = this.renderTargetCoC.texture), (this.target = null), (this.bokehScale = o); } get cocTexture() { return this.renderTargetCoC.texture; } get cocMaterial() { return this.cocPass.fullscreenMaterial; } get circleOfConfusionMaterial() { return this.cocMaterial; } getCircleOfConfusionMaterial() { return this.circleOfConfusionMaterial; } getBlurPass() { return this.blurPass; } get resolution() { return this.blurPass.getResolution(); } getResolution() { return this.blurPass.getResolution(); } get bokehScale() { return this.uniforms.get('scale').value; } set bokehScale(e) { let t = [this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass]; for (let i of t) i.fullscreenMaterial.setScale(e); this.maskPass.fullscreenMaterial.setStrength(e), (this.uniforms.get('scale').value = e); } getBokehScale() { return this.bokehScale; } setBokehScale(e) { this.bokehScale = e; } getTarget() { return this.target; } setTarget(e) { this.target = e; } calculateFocusDistance(e) { let t = this.camera, i = t.position.distanceTo(e); return sg(-i, t.near, t.far); } setDepthTexture(e, t = qs) { (this.circleOfConfusionMaterial.depthBuffer = e), (this.circleOfConfusionMaterial.depthPacking = t); } update(e, t, i) { let r = this.renderTarget, s = this.renderTargetCoC, n = this.renderTargetCoCBlurred, a = this.renderTargetMasked; if (this.target !== null) { let o = this.calculateFocusDistance(this.target); this.circleOfConfusionMaterial.focusDistance = o; } this.cocPass.render(e, null, s), this.blurPass.render(e, s, n), this.maskPass.render(e, t, a), this.bokehFarBasePass.render(e, a, r), this.bokehFarFillPass.render(e, r, this.renderTargetFar), this.bokehNearBasePass.render(e, t, r), this.bokehNearFillPass.render(e, r, this.renderTargetNear); } setSize(e, t) { let i = this.resolution; i.setBaseSize(e, t); let r = i.width, s = i.height, n = [ this.cocPass, this.blurPass, this.maskPass, this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass ]; n.push(this.renderTargetCoC, this.renderTargetMasked), n.forEach((a) => a.setSize(e, t)), (n = [this.renderTarget, this.renderTargetNear, this.renderTargetFar, this.renderTargetCoCBlurred]), n.forEach((a) => a.setSize(r, s)), [this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass].forEach((a) => a.fullscreenMaterial.setSize(r, s) ); } initialize(e, t, i) { [this.cocPass, this.maskPass, this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass].forEach( (r) => r.initialize(e, t, i) ), this.blurPass.initialize(e, t, Mi), i !== void 0 && ((this.renderTarget.texture.type = i), (this.renderTargetNear.texture.type = i), (this.renderTargetFar.texture.type = i), (this.renderTargetMasked.texture.type = i), e.outputEncoding === Ke && ((this.renderTarget.texture.encoding = Ke), (this.renderTargetNear.texture.encoding = Ke), (this.renderTargetFar.texture.encoding = Ke), (this.renderTargetMasked.texture.encoding = Ke))); } }, k9 = new E(), j9 = new ve(), MH = 'uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}', EH = class extends Ss { constructor({ blendFunction: e = nt.NORMAL, hue: t = 0, saturation: i = 0 } = {}) { super('HueSaturationEffect', MH, { blendFunction: e, uniforms: new Map([ ['hue', new Oe(new E())], ['saturation', new Oe(i)] ]) }), (this.hue = t); } get saturation() { return this.uniforms.get('saturation').value; } set saturation(e) { this.uniforms.get('saturation').value = e; } getSaturation() { return this.saturation; } setSaturation(e) { this.saturation = e; } get hue() { let e = this.uniforms.get('hue').value; return Math.acos((e.x * 3 - 1) / 2); } set hue(e) { let t = Math.sin(e), i = Math.cos(e); this.uniforms.get('hue').value.set((2 * i + 1) / 3, (-Math.sqrt(3) * t - i + 1) / 3, (Math.sqrt(3) * t - i + 1) / 3); } getHue() { return this.hue; } setHue(e) { this.hue = e; } }, G9 = new Ge(), CH = `void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time)); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`, TH = class extends Ss { constructor({ blendFunction: e = nt.SCREEN, premultiply: t = !1 } = {}) { super('NoiseEffect', CH, { blendFunction: e }), (this.premultiply = t); } get premultiply() { return this.defines.has('PREMULTIPLY'); } set premultiply(e) { this.premultiply !== e && (e ? this.defines.set('PREMULTIPLY', '1') : this.defines.delete('PREMULTIPLY'), this.setChanged()); } isPremultiplied() { return this.premultiply; } setPremultiplied(e) { this.premultiply = e; } }, PH = 'uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}', DH = class extends Ss { constructor(e = 30) { super('PixelationEffect', PH, { uniforms: new Map([ ['active', new Oe(!1)], ['d', new Oe(new G())] ]) }), (this.resolution = new G()), (this.d = 0), (this.granularity = e); } get granularity() { return this.d; } set granularity(e) { let t = Math.floor(e); t % 2 > 0 && (t += 1), (this.d = t), (this.uniforms.get('active').value = t > 0), this.setSize(this.resolution.width, this.resolution.height); } getGranularity() { return this.granularity; } setGranularity(e) { this.granularity = e; } setSize(e, t) { this.resolution.set(e, t), this.uniforms.get('d').value.setScalar(this.d).divide(this.resolution); } }, V9 = Math.PI * 0.5, H9 = new E(), W9 = new E(), Jb = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC', $b = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8AcC2AhRIoDXbsYb48dl5WkVFTE3LGDcC9m4CZCWBuFFgeAZaGAYJQQCRqDHT+McJrVb8zwATUXH02MHYfMHEIGFsAxgjApQqACYQORjtd/B7Axt/z79sC0+cMPgjjlwPwVwHcA+DfAHzTxcVgWBroqMN8+cYBeM71wH0TwKExYHYUWCIAHYRLTlkCYgcIBcAgU/n3qy8GRu4HRgnAOWBkERhddPAJhGJDBxkvw7cqimr+zFM/ZLnZF64cgL8BYD+AWwB8x/dlWuWagHiYL984AJ/0RWBy1AE4AizyM1yxYAcTigW55xMbAkxEiwEdkJ/ZCQxPAiOHgBECcKEC4TBZcKkSv+mTieNcNPNC26mLNsj45QD8LQDTAO4GcJt/7iw2bfoG4WG+vAGwm9ExiEg69zpg/wgwPQLMjgALzn4E4aIzoJjQ9g4024uygkj+pyuAoX0VAIfngOH5NgCHMhAm8Sv2y3XDZeBhNIp8OzJE8OsBzAKYBHAXgDt8/4O+MVT0j4f58o0D8Pxrgf3DwMwIMEPQEYRkNwfgsuuDZLskip0No0gWMD/9HGDoADAkAC4Aw/wsAgZAgs2Z0ABI0GU6IVmKv+f28KDnHxkA/G0A8y6G73N9kOCjXnh/Ebb6OvgwX75xAF5wLTA1VIHPADgMLDj4yIA5AAm6aCUnv4oz46eeDwxNAUMzwJAz4BABSNDFTwSfg7DDKHE23MG5PqIY8A1u/dINs9dBdy8AgnGPM2NfUBrsnw7z5RsH4IXXAAcJviFgluAbygBINnSLWOAjGxJ4pgOKDV0v/OSLKp8iGXBovhLBBOCQM2ACoTOhnYrAdItYbCij5JFzRyIAqRccAnDAQUjg6UNQ7hsMXP0cRQAexss3DsCLCECCLwCQzMcPwUi2MwAScAKbfnY/YRLFQ8DHX+IAJAMSfDkAF13kLvleIjhjQQHxUVS3jjgGpKeeNzYVQEjgUS8k+PghONdhIwAP4+XXBYCHKIJbwJyDTgaIAdCBJx3Q2M8tYAHP9m4df/ylQOsQ0JqtRLCx30K1wtLBggScQOgsKBGcWHAJeOwRC0BSM1mQIKRbhh+Bj98JQP6t4U0APEyXXxcAEnxkQAFwoVUxID9kvQg+c1C7vidRbIDkc24B//hTQGumDcCWA5DgMxASdNIFBUI5pCML8v8API5zfEQx4BudgqiczviSnJhQwCP4BMCGl+wO8+U7AJi/W4O4YS6+pmK/2ciADsAOBhTIIiAJnPB7AvNjP+0AnANaYkAHX2JBAc+tYaJXOqBZv24Vc386XW5dtkHGW+4HFAJonpOe+YYQZAShgKjv3PNvPQaxVoI8zJdfFwASfPzMUwS3Kt1v0UFIlos6oDFdAGFcliMAP/ryAEAGNwQRnDOgLbdlIEwrIs6AZ/QgkMMHQF6ZAKQcJAsSYPwIeAIk9wJgoPK1gi7+PwF4GC/fOAAvIQPSs0URTPBJ/Pp3GSEGRHfBCIQ0xowBtUbcAj7ys5X4Jfu1HIAGQrIgQRXEsAFQIORDFhiDY/rMHmrU4QUgR08AkgUjCAW6CD6CkwBsAIQC4GG6fPMA3OXiNzCg2I9gNCMksmAAoemDzoimFwL48M85AKkiuQVMAAp8CYRRDAt8GQiJ67N6GJODAXAHlsGguscA2AJg1IPGYmxOpBxFWkRN9LsATgIwXnNs/v/5z/9XCf8BO3YAtxbc/46/KDt+5+ea1Yku2VUxHz/z0v24FwMGK1gWsK2OUUxHHdCBeRUB6OxHABr4ZICIBd0QWSF+XRdMTAjgCdTrG9cBNwE4F8CpDkICyYLGsuhFt6zs+gISwUen8zEAjgMw4cfx2H6O/90yAFo84Cbg4ID3/9TfLTt+5+ebnRABkODjx0SwPi5ec/FrYpmqSAxM8Dn60CsqAFI6GfhqAMiDE/gokmvEr0C4PgDkBQm40wE8zMFEUDKEVoxIMLl/KS73mE7H9d+vcKHQQcjwW0Yu9nP8m8sAmOIBuWY6wP2/4s0ezjjg8TuvaR6ABJ70vxUApGrm7EbGE+i472BAB+WHfqHS/eoAaEwY2E9+wLSXTqhI7CXgnB6LCoOJ4BiST+hTnG0HcCwAglCx3ARoZEVFXnBPp/O/A/hXACc7CPs9/i1lAOyIB+RDX+P9/+pbQjjjAMfv/PL6AFDs1wFAgs/9fgKfgdE/ZEpuiQlbwAde6QAMBgiRmsSwA9BY0JfjovGRDBMH4TlcXGhcBOc6HkF0gjPhZgchxTLZMAci/04W/B6Ab3t09EPXcPyflgFwRTwgJ2MN9/8bf5qFM67x+B/aW4XQz42FeL0YrRyikztUFw0704mf9kXgxhOAqc3AAsPyRxxQCs/PdXOFY0W1KHy3QIUGtx+6vdnx1vsB+dsTncm2AogglFgVEAlUWrOMB2RyEmMCGQ/Y7/HvKns6tfGAnJQ+r/9b76oJZ1zD8WdyQjYBh8aBhVEHjELouQ8ukQ7VRSCJAALwkr+sALhnGzDD3JAJYJHg9uhoi4bx8ytkWUtvHT/7+Zc4dw1uZ3612fH2dkQf7yxIEEockwkJQn4IQoq8unhAhmPRKKFx0uv4K8ueTs94wD7u//VX9ghn7OP4c+4G7h8HpseB+dF2AKlFLwuAIZ8jD6NPrOhAffmfA9/ZBuzZCkyRWSeqBCWyoYGQ5yQrBpDbum/ME1HoPo0XEkSD2zlfbna8q6+EUJcTCxKEtHL5EQjP6BEPyIgYAZBvYt3xHyx7OqvGA65y/7/9wVXCGVc5/sl7qxD66dEqiYgRzAqhN1A4CBNAAlDyAFI+iZ9/N3DLJuC+jcDUBmCWyUnOrmTYCMIOkNclLg0B8/RsNLg9+UvNjnd1APLmmQpFHyEBROuWACQT8nN+H/GAvY7/VNnT6SsesMf13/CpahGnZzhjj+PPmwX2MYdDIfQexWyBAwEUOQDrRDN/98p3A7dvAO6fAA5sqHJDBEAyoUVGkwEd6HR12XU4kwzfl6fCXTZzjy57vvnR513X7Hj7AyDvggAUi9EyFgiZqNxPQF6345nOWbD1HQ/Y5fpvuLa/2+82/vNHgAPDFQDnhoF5j2C2qBWCI8bw1eRw5CL5l94L3DEOTI4DB8Y9OWmsEu/zBJ3rgsaybqBob/7A4C7jtWcooRrczr+u2fH2D0AOQgAUCxKEP7aGgLy64+m6KdjWFA9Yc/03/Osa4glrjr+AupqHz1sEs0cxG0BC9HIePLoit9eNkVf9L+DuUWByDJgaq4ybGYLPAWgiXmLedUE7dwC7saL7CqfPKXi4NYdaykCD410bAHlDEsNiwZ9wAPYbkJcfz6T2gm3N8YDZ9d/wHxUA+739fPwXPrSKYGb+BuP3jAFDElFH9HIWwbzCIGkBr/or4J4RYO8oMOW6ZVcAuvi1Cgoha04BCwT5gfMKHm7NoRde2+x41w5A3hQZkADk5+cGiAeMx3+/7AENFA8Yrv/G71cAXFM4Yzj+otOAaQLQA0gZxaIIZtMDFTigKJV8H9Iq6aZ59ZXAvSPAvpEKgBTtBODcSCWCZeRYtpzrmLyeGNCAyFl1v+Hei8qeb370Rdc2O97BAMi7EgB/2QG41nhAHU9LuWAbOB7Qr//GPRUA13r7Gv9FZwIMoVcEswEwfDoimEP0shKKtIphaZQAXv1+YM+wA3DEdcvRKkGJADQQEsQuhi1Tjt95vBsh5nx2IO59SsHDrTmUOStNjndwAAqEry0IyCMICkOyiuIBNwBvPFQQT7gBuPjc9oRYAIHyOEL4vIFEYVNaOou5vCGE/tV/A0wOVcnpzI47NOri3QFIBpSeaSDUdYLOSWvYImSGgftpJDa4MWJbAGxivGUA5MAOc0Be6eVLj7/4Mk+hzCOYPYpZDBiNkLh+G/M3yFyv/ltgL3W3YQfgcFUhgRY2PwY+Z7/EhAR1SFyXCOb57r28QfQBsJQBMn5D4y0HYLPje9Cd7RIC0PM3EiMofF4gVCBp1P840ix/gyz56r+vAMjk9Gl375iB4+CzveuZdLkkEPJ8ZEfX/6R73vOjzT5Si9hucLxHAVg4PwJgRwh9CKOXK8YA4ZEqKZXSQWh5P+5AftXfA/uGKvYjCKn72cctbFrZNECka5L5CPwIPtMH3TVz17MLB5gdLgA2Nd6jACycHwLQxFEUSR5ASvARDB0h9AQb9bXIgCGk6lUfAPYTgEPAITKgg1BObk58srTJgG58WMkWMaAbQQT1nc8rHGANAJsc71EAFs4PAagQestgC1lsBJ4BMCSOK6dDUcwqqaFiQr/0QeAAAdjy+jBiQQeeMSBZT3nCPUDIa9z+/MIB1gCwyfEeBWDh/BCAeQSzgkjFfGLBBD5nxQ4DxN0wv3hVxX5TBGDwL5obxvVA5YqYL5BeMLd66YYxJpRB0gK+96LCAdYAsMnxHgVg4fwIgMrhUPKQ2C+Bz0PmBTqBMQehAbDlIjj4F80KJguSVZ0FuXpjoCOgXawLjALhbT9eOMAuAGxqvEcBWDg/l1IE05Ed0ygZnyHdz0VwCqEPIfNyx0QQvvLDFQCp+8nfZk5und8tXwIgWcHSNX0N2CJmnAl3v6RwgNnhl17T7HiPArBwfghAS7mV/hey2JS9FvM3BLpUUi1YwDRMXvkRYJoAlAh2l0dcZ04s6JUTDIjyBcrl4yDc/dLCAdYAsMnxHgVg4fxwKVwJgGEJNmWtxpQMpX9on2eRhVA+O56AjMfnP+e3Xvf3NwG4xIPTleiY55bpGh6UbafNU0l0z0p+5Jh5HqYJ6b51nP6XP8cx12XNHQVgIQB/bFPVg2OC7Q+WgVFWng/FvtWLI06uWh5oguKEcXVS/9sEAF//VGD7t4ETDgJbF4CNi8CGZWBs2fPL/H6Vwp2KEtVk4fJ+v/EIYPN9wKa5qu+IncfPwXHVZe/aOL3EbwS7xv8A1rQvnO0j8PArTgTGZ4BxFv9mIxhOCGsv+0OPYDRghcLfkWkEuq0+G00x4OtfDGz+d2DbHmDLjL8si8AYP/7CGIAiEEMTG92zXqSbH+d9R2aA0XnvO+JjthiIrOVDHHPOkBrzUQAWAPsZp3oPDpa/Xag6EVkLBK+5rAnJC3/nYk/APD704WiEAV8OTHwX2LQH2DgFbJgFNrBhjd8r79deGoEwsllgNBOzy8CdjweG9wBj08AIAci2D6HafmyAk4/Z7SJ72hGYRwFYAMDLTwOGp4FRFgD3HhzqRGQiyeurqOdG6r0Rm8IEZjzRlkiqCWoEgK8Axm4BJu4HJhyAbFhDxmbDGnZO4j0SgLGDkpibgEq66TJw/1nA0F5gdLpq+zDqFfd5LMeWqu5HNST0uJOIllg+qgMWgI+HPv0xwLA3gWHpW2sC441gCECbmKziaGrnUdMO4aHeh6MxAP4SMHI7ML4HGD8AjHvHJGNAgpDgY/ck3stipRemvVhc+uASMPUEYGh/9dIRgGx8Y+MNbR/00uVtH0wEx94j/v0oAxaA8Ed+GBieAYZZg5kADC0QWGOFzGJlcGPzl1BxNLXD8sk4xftwNAbA/wwM3wGMUmxOOQBnHXzetIYvibonmSiuYTNjriVg7glAiwBk0fNZH6+PmX9P6kfNmCXGpftJ7TgKwBIAnln14BAAYxMYm5C6RjCyCoOyr0qkD/c+HI0B8DXA8N3AyCQwesD1VQKH7EcASm1Q+y4CkN9pUKiVF5nLvy+fBbTUd8QBaH1HvNBROiZvfsNnrF4kcvPwpdsBLBeU18Nf7AB23Dp4ecHC8oBgUlJJecLS+7+WOpE3gbE+HKw+yoevCYkMGKqPJrdEKARutaFYRs1fiEZ0wP8CDN8LDO8FRqYq3W10pgKgfYLaYCzootgA6KXaTA90y374TKB1sBozy77xHFZ536utRgAmEaw6g5kUSFZwSXnA330qsOlfgHMPDlZesLA8IOjoLypPWHj/11EnCiVwkz7kAExtsGraYUWdSDX5TmsagL8KDBGA7Bd30JsW0oWivnEOQNP7yGTSBR101AlZSUtGyfgZDkCWY1HnJdcBVe6325hTvelg2CQjZNDygG/2An0j1wKnL6y9vGBheUC8prQ8YeH9X39OVQSc7Mc6fCaKvAeHdCIVf4yMYCynTpX+nb97NJmlSQb8r8DQHm9YOFUZTKOzoXGhs6AxF0HIexcLBvWBuiHN8s2ne98R3qc6L4Vyb2oBVjfm9MIFHbjDCh6kPOBbQoG+oW8CO5bWVl6wsDwgfr20PGHh/X/1iaEIuDcCTIW/1Q4rFv8OnYiW3c+W2iKwUjKbyjQNwL1uuR6sAEgDgq1brXOmV81PxhNB6DUDBSYzQJwFtz623XcktX1Q1VWKaTF/zZhVazBVYA1tX5MazsGvobwe/jQr0Ne6BTh5uf/ygoXlAfG60vKEhff/rSe1i4DnTWDUACY1guFTDqLYdCBvf6DJYSMYATBfOx1kLfj1v1axH10nQ3Sd0GUkBnTfpemtBJgseIKQAHLQcVxa2TnuMW0Aqui5es8xBIegVdVVE8VhzHnLh65WMB9An+X18K6aAn2tO4ETl6vqbKuVFywsDwhevqg8YeH93/Rk70JE90nowxZbIJjvS3WYNSGUwGHJTpPxwwcbBuBrgRYBeKACn7VtpdUu/c0NJxO9BIxcKu4TTODzbkonPLoaL0vyUQRb2y8HsL1ckfWzMeuFi40Qezqi+yiPhyt7FOjr6/gCFwgP7Xb5vssTFt7/nQRg6MGRWmDRoeyTlpgw68GRTwgZgo1gGmXAX6/8dtaylSKY/koyID9BhzML3q1gAos2AcOrZYSoq/pJp1VtODRm9Z3LS/7WjVkvXOzEtOpKyGrlAT+4SoG+VY8vBGCvy/dVnrDw/vee65NBJiAjBIVcAJQjOm+DkCZEeiGAMw6sAwDZsJrAdhFM9rPGhd4904Co5oVuCZPV6kD40Ec6+9W8dBTBsfdc3nkpvnB82fp2RPcs79dHgb51LA9ofsDV6vut5/3PnxcAmLVBiDqgevDaJLkYrpuQxzcNwN8AWgIgRbB8loEBzXDwl4cGiDGft58SCOWGedgjvOJ+bPvgRkiuA+ZjzhnQQOiFNVbloa7l/fos0LdO5QENgEXlCfs8Qbf7HyMA3QVjYihYhLENgjX9y/qwxQmRU/asfd0ZcLU2CHVGyusJQLKfVi98CS12T5f7iECkHpsMkAhCF8+nshWH2I/jXsOYO144GV/9ApAIrS3vt4YCfetQHtAA2G+/4PW4/2PPbzMgmUMi2NoeSCRxIt2/FvuxWURIWCXg357gfTjEDNIHnTRXRCpH5ugKwGl3HpMBXQc0v6WLYVm/5limj04rG762K2uYY9jBkr9+rI03NL5ZbczS/dJ+LQyoga4o77fGAn0NlwdMAOy3vl/T938KAcj121z8Bn+Y9eWQJRz8Y6kNagDh2ey5EvxjxQD8TWdAuneCCO4An1vw5vdzQMmdktwq7pLZQR+dM34+ZumAxvY1Y04uqOAJ6FsExzeto7zfAAX6GiwPaLWR1lrfr8n7f/Rl3QGzmsis+/uO71V9OFgP2gpPhgr7TGRqRUT6dyvr4aIs/pm/2zVUNbBSv6G8e5pEv0Cvec7Po7+bTtjlBRlkvAMBkDeQyvsNWKCvofKACYBrre/X1P0/oWEAnnFD1YdjhtXxR73mX10FfCHHE9pVWcGAI/S0gKsfA2y+twrFZw6Hxf/F0Pk8Ri/kpGSnMuDx5T0iACgQHioo0NdAecBUHW6QdsV2/cL7v/Cyqr5gnc42CCOcfX1VIZ/V8We9IDmTzVXwPDJiXuKXPxtDBma8+lzP4WAgKkPxCUAPE4v5GzEuMX0PYJPLhB6FJsc7MAMmkVxaYC/K9gG+F1++8AQ7Gwbgk78I7GFpXgIwFiRXOwaJZPUbiR0yCUDRk+cHf+YpwMj9HgfI8ClGPyvsSiH0WSKRuYlitLb/zHM/JOSs5C/YIC9cMQDZr/dwxgOW9gtGYUBi0wA8l304vDQvAchilFbpIBQhZ7Ejq6ZQ0/Yhil8y4j89Axie9DAsD6FX9HOK3QtROTFkviN83kG4felIY8DCeLrSeMDSfsEovAECUFsTjHD+tcB+tkFgcXKvBRir7qtFl9owmO4Xy/1G3bAFfPrZHorFNWBFwHjQAFctIghj2kBarw06If/+MM9ZqTN6DgsDojCerjQesLRfMApvoGkAWh8Ob/tgAPSKWCp8ngNQtadjmTdltvNvn3peFYhgQQgh+iUmEaUAUoXM1yRLmWuFLaE9Z+XIAWBhPF1pPGBpv2AU3kDTALzwmqo6qtVh9kJErAudABia38TC5wJgS2xIhAwBn3yhByL4EhzXfRXxYsDTJ4IvrNN2JFMxZcBzVo4cABbG05XGA5b2C0bhDTQNQLZBYH1AVsQSAAU+imI1obHyblnjG/kJk3U8BHz8xVUQAhnQIl5CyNgKAGp5LKSSCoAySh5Jj79vTagcxUaIBeRNe79g9gq+DXig4wGzy+PONfT7RWFA4noAkGXZVAhcBckJQgNgrLiaNb3paIDo1vHHX+oA9LQBi4DxJcOUPJUnTgU2NJUyROs8irGARxQAC+PpCtsFd40H/AEf0gMQkLgeACT41PiGoLOKqyrJq3K/Ya9mNyr5FusN/uPLPIeDa8Bc+w3rtyl4VFHaMZc3i9RWBM9jjzgAFsbTFbYLRmm/YBTeQNMAtD4cBKDXBTQGdAB2MGBo8SCLmEuS1AFVAJ3A/NhPt0PoCcA8bSDG76XI7aySg6JYuGfKwJHFgH0E5B3ueMCe/Y4L+xVHAOZ+9EHcEgQgwbeiEYx6jwTdz4qfu7EhEJqxGqruf/RnHIAEnxgwBM0aC8aUAYWNBRCmoIll4HTqO122QcZbrgMWxtMVtgvuOx6wa7/jwhtoGoDWh4MBJ16WN4lfr8AqI0TVV1O1fa9BbQzovkAy4Ed+NgCQUSxZCFWvCOaOFREXyUwZOPIA2GdA3uGOB6wPaOz+QPv5S+MA3OXiN9aclghW+d3IgupBF2pPqxcxGenDPxfSRh2ASiKKiVP2PaZScvAKoA0VDc6cOlIB2GdA3uGOB1zR77iwX/F6AFB9ONSOQW0frA50sILVcckWJyIDSgwPAVcJgFbYuZ3FJvAlEHbJ3IsgJLGedeBIA+AAAXmHOx6wo99xYb/i9QKg2iAIfDJEJHqj4SExbEty0gkdhB/6P9oZbBZIGiKYVb9GKaN50lRHBLOvhDxh/5EKwDUG5B3ueMB2QGM/grb7/6wHAPNGMAY+GSGUjC52VX2f2CD4+HO0gqkZfegXKgBaHkcWtS0AWii9xG1ImrLlN5XR8L8fmQD05BVrmEENmpYSP9QX+KHiqj2/82+HqqDWwnbBRfGATdzAegGwru2DpRq7Mzq2fpAf0Nq0Rl2wBXzglZ4yUAPAmDSVWDBPHQjLcgTqOZ6zUvdKHh4ruDCerox/Dnu7YqwXAC1NI/QcEQuK6WK/kdgCTGC0PYAP/KIDMBgglq+hIkrOfsaCviLSofcJgJ5AdM7kkSaCj/HqQKVIGvD4swF8bcBjmzjsaQ2H5D/6acBd9wALB4DFWWB5AVherMp4GKIYEOp7+26UF0aSfT/xYuDG7wDjrIpAERytXf2vajj7ueryQXSFl10K/ON3gIWDwCLvjfGB8Z54O+Ee4ve6513uB2R1yzsqC+twbC8HcNVhfAeaBuDP/TvwtS3A/ePAIfYFVlPq2HHTuyulZCTlhbjhETF5yxTQGgPGhoHhIWC4VSXGD3n0tLkMHXHxu+YyB+MlPwDuZs5K6FlsbCzdVO9DuKfkHM8AEkP7B8fOkwDcD+B7np42+JkGOvKdAL4E4K8P0zvQdET0b14D3DgB3D0B7B8HZka9WzrD88N6sFm+YcUjrn7E1ZDvMtF9DBgeAYaHgSGB0PNHCD4BLwLRsByAyX/ij0/dDUxuqlIG5hix7eFhvLcOVUAtyPSydAFmOQNe6EYGV/9ZESiKgIEgtbaD/gHALQC4ovY5r5KwtjOU/XfTAHzzLuCmIeDuMWDvKHBwpMoN0WQzNtAaYSs0K4ZlOSAjGG9kPjCBRwZ0ABKEBJexYAZEAU3A7Oi1BeDym4EDnjQ1TwCGWMW8MXcKks0YOyZNlQOQjcgYIUHllEzYQ0ktm+r6oz8G4F4AXwXwRd8/kO9A0wB8y65KmPxgGJgcqYJTKYpTv2CCzyddQJRDOjKivn+Deh8BF8BnwBtaCUA+YYEyAU8h+c6Az9gNHHRmrgOgmDA3jHQ+iWupCeUAvNSrA9HNwqx+muk9nJVNg/CTfrmbAPwbgK8D+PcHkIibjob5o13A3XypWsAkG1cPA9PDFQDZM1id0i1KxsWfOrKnAFXlifCFFMMRcASigOcs2MGAIfE9iWXplS6On7UbmPaUUTXQrgsVMzcRj5Folg2V5ayUA5BWYKwOxKUafnosWjcJwk+7W5F2EKvlE3xcXaNYfiCYsGkA/smuqug6hcleAnAImPbO6YwRpMgjCAVAm/yQmKTv5hNsAf/i7SyNBSl2a8Qv/4/M1yF+BZSYlNQCnnVrpbC+mToAACAASURBVJcaI7sOSEY2NpaDXLqpR+vE/OVksDgImgGgghHoYJbTWc7oJtFWc65/cg2AYvh2ALsB3AzgVv95nS/f4QdsIkT9T3cBrGtITWZfC5hqtQHInsEGQn3UDDvEDEY/ICf7SxMOrAg8T+c00JGkvHGd2DABUYZIAONzCUDppCFhSukCBsLQrFtZe/IixYQpSyEoJoqnuPWrVRAubQh83HNlZB23z7j1ywmj6CIIqUPxw2Xeu9bx2jx10wz4Z7sqTYZaDD8EIDuoE3hMVEphWg66JIp90k0sBxBcy+iPIIaT1RtEsHS/yIAqw+VSNPWQfe5tlVEk8auXgVa5BUsEJuT5uoliAbE5AGotmIAjCPnR9xDG3TQernYAUupTdBGEFMf83OkApHG+XlvTAPwfuyrgSZOhas3u6cwTsUBVn2gTwyFMi8wjHZAA1M9fYGHDULJD1m8Cpa8fRxDad+l+Ykf/3XNvd11U+qiL39SxXevSsshdDFvgbI1O2AwAtRZMZzTBRuDFjxe1Xg8QEIB8yyj5yYIUxfQIkfkIRnmHCM712JoG4FsdgHHp3ACoMH2G6jM4lWzoQarSvwQ6MSB/vporVaFkh+mCLlpVR8Z+dqDZLoDOpHSiQeAFDkBjPrlgCHgCUaFifg67H/9uYjn4Ai1vpTERTAASBaoQJBAKeNqHlL6mwPDZYAOROag/EYRkPX34MwHIvzW9rQcA+TLpI22G7EcQKlJGsYIJhC6ClUMiXfBTbFUQAej6nPS/OuAl9pOOqIc2BLzg++3VmWgIEUz82cRuCAtLIHQQm0gO52uOAb22sC3JEWgRfPpZf2sQBQIgLydPEIFGwPEj8MlF2bSbsulghLftqsCXq9HGgHysznrGgi5qzTUTFH8FLhAUn3hIJwCN0HLncw37qaF2zoYvuKNivmQIuUNc7GvWt6sHNs26twA6vhyq8NEMAHlyntFrDCcQehyaPTl+FwAbXDcmAKMRThakEk8Q8kPg8SPL0qzLBl+A9QCgR6uZGs3vfHz8TtBZvkgGQrEPBVAUg2Sij50QAOjiVKI3saADJRm7dSLYWfSFDkCem/dhZeMy9pPY5QvSDYQyUJoDIK8qMezh3wY6fSL49PcGgCAA8pScJLIgAUYQEmz8RPA17StvGoBv39W24eREiBoNQSgWNI1HBkdgxJSw1AI+dFIbgOYmkjimQ1r6XXC3rAbCHycAgytohf8vsB/r2KRaRq7zpZ+D37HMX0s3DDcCUGLYaw53MJ4YUODzusqlGCQAOQCejuxA8UULUkxIwAmMAp8Wa3qkN/R9W+sBwOhIEPjk5SLr8HeKFbTQfb77csPIMHGl/4MPbReslPhNe4+MiTpi9AFGV4nI7MfvagNQLh/pfrYnDAS8aJQ42A2w4em2cAyWQUuJVQTGWLs1uL7DG9J1RjhA+jvYk4t3KXeMqijpzrud4At9z3XtP16yGfjKZmCGooYh1tZzvv8xXPFl4PoJYC97k9FlwZWD+Azi/deMZWeP13eQCGEyoERudChIjbb3mJYwH7V0QIKuCwj/gfMj0asn2I0FXRSHXfL/iRkNgLyeVj8ccMY//J1fyxzTAXT2+xoQViKYD/1hDqLxPiYxTgSvQrphphG97tz4Slqafnj7uk1kIQDZrvWTw8B3jwEW+RLxPgSiCERdPwPR7+wCPg/gulFgfruDkOMQkFc5x84e708JAMmCuRNBXi4TIg5CGRzGiBGE/D4E/C2r2vcAYJoify62i0aJSMhB+2IHoNwu0fkcjQ85pu3ack5nIBREqneYFyWLkAXIJHESe00Cyx5QyeL6F/tyEcDcrOW2n7fX8df0mME+/vQ/PQjhoy3gzo3AISYf80MQaQx1peH9wb7v2mrtmCBkIMMejp3jIJD1MsaxaMZ8v5N/67INAsB3BAYU4JL4DSo1J15AFPAEwuQHZJzkKfUAtOHLJSOQRWndBYQvCQA01cfnNopfsaCJaD2baBn79QjSTiOEP1EcawIpkq2kegBTNgHWEpOKF8Uwq2NRFPM4AqCf46/rA2U9/uVDvurB01zvAJpiiwOl3fEeciCGF+Ij11f+QkbSfMPfIzqw57mEFZ9Dl3Ps5HXWAYByHJAJKV7N+s0cCQQhwSlfm4lGZ0KB8C/rABgZUS6ZHITBSEhCowUYAAksF7cStWREyxRwtuPpOlgw+5s9sq6OaIJIIlUgEhA1edoTgHxa9HVw5jibZNF+j/9yGQA/7pbujZ4bwv2+cWB6tFo0NzYnkxFA+cvEAo43VBoEo2e+48EMXEOmD9F6xhCE8RwZEJ80VblKvDlmzwicfqy93/o+8K8TwB2jVSgW138FrJQTXBNlnJgmrjZwanow9CBP/rL9wF0jwAGWDtFyoN9PHutnIHT05mPXz93dMGQAPniJsjiBXiTbxDZFMF9NLUPQxKR5qezz1Y6/YZDH0D6GkdAkYJIvRalAdHAMmPZoYhb6NhDWvEyf/ma737CXN7R1ZC7hUbPgcFgqt/ZZjADnM1xqEVhYBpb4CUk5UsL7jQvj///5buDrLeCOEeD+YQchYwG9VIfyg1NaZszFiCH6DkRGLze5/dgk8IMWcMCjdCiCzR8od1B8OTwvJM8JEShFut1fzMhi+eRJr6LI7hYP2M/xVLwKNoZjUTwRMAQQmYyhWGQxsSADOflZ4kukj7PhZ75bETjBpkAGahMkcrGgwhsXeCyBHBj1wmOBQwvAwqKzoFeRV8ZaerjKYAuirmPY/o9X7q5Cyr7fAvYMAftCPGAEoYlBiVtFwLjtp2U4irj7yOANbi+crHyrfCbTquJV44O0F1FrwQGIMZFqdQDyP/gGSZ8TC0ZRRsOlVzzgasd/u+zpMByLehAfCgMQCDyGZJHFCCgLZ2f8mgI5qauEcVx9e5vACTgCTwEMWr5TdIpWKJb5MvrnoocDswvAPAG4VLGg6UKeqmi4iuDz4er30oX0FP7u5moMvIf7W8B+jwlUNAzFnlZCIhvGFRCeWzrgXSSIBreXTFZSgVLHAp4UHOFuociEEsn2PJwl/XEk0dzfSojeerFg1IOo5BKAveIBex1P67lgUzgWQaJwLAKRH04i14ItgDKEtGsRnWx49b2Vkk9wUefTGrKCF7R0JxZMqxN8cmPAxWcAcxGABKEAKPA5u9lEaAbCmKMI+sDN1X3z+ro24wEZFc0VEE64ABgT180PF9ZdBcDb6JpqcPtPk+1ACbmKjJnllwyuILunEAWjZHkBsrsRUnfD0qEiC5IJfyisgMhzWhcP2O14Ro4WbASgAMQJ48SJwchmBCDFa8qpyBbSP7OvU4PQ0p2W7+LSnSJUFOrI4V7w5IoBTQQTfJ6oTSYk2mQcpGRyH2syGjIF6EM3V/fM++C1CfwUExhCsmzCaQT43lZC3e1hBpEHh36XEqrB7Scmq5dV0XZxmV8WuDFzAF9iwhow9seAGoBcGtKjqAc+1l9rLb/1igesO55ysmCrC8ei6IxRMAKTWNBi6Xw98xNTFUi0jEcmpYgRAPhddpVi9OIEPP5cYD4CcLkCooHPwaW9kV+iwWrQHT8uA1fd3F7DFvgUHUP2k8jTiogAqLoxFpDgbMj9jXSuN7i9dLIdaxzBp5XVBMIMgFEnFAPKT9qPd6A9BIGI7MfPmf4U+40HzI8nWgq2PBxL4FEkjKJixGRRFyQQPzzd1iAUzCAQas1YOmAEoFjwkecDC/PAwhKw6CxIkCXwOdVJLxTobMjBdyIgfvimNvNJ7Evf4jWtdnRYD1YNGVuG93VWuWs4Jf+mlZCCZxwP/cnJ6mXVKk2+tK8lQQVHRTGc64SDAZB3Ey3JcxyACkToJx4wHl+YwqloGDICmYmTFgMQFBET8yyYzyAG/AfWX8mCGQg0BTRoHwt9KVaPE/HQ890AIfgWK+CRAaMRYnVdxHbhdY8Wslw1V93UDsmPIj9GxgiAioRRMIJNvoti+SW/Ikd0gwAU8+XxJcbGITJPDvI6XdCFREFSknTB83xka40H1PGF9dnycCxFwygkK0bASJQSVAbAYeD98xUAe5U3jKIwBosSgNsuABYogl3/IwgFPrOIg1Xc4ZrpAsSrvruykl2ucykapkMMh4CExD5DwJfWAYAxwk4MKPAJgOIjGSEGwuCakRhemw6Yv0UUwRf7L00L9pnsNx6Qx4feY4O8pDEcixOjsoTKKpMYjSFYYjOC8Eq3Wnnr0YYS+0Tmi2HysrPGLqwASNYzBnT2Mz2QD91laxLB0gs12GAh81cf/o/OcHyJ+qj0S/zxnhUZbSyYWaL8+Rq2S29wowiWkJPan4MvgrDDGAlRe7KIywDIgR3meEDWg9HbJgApNTkXo8o0i7oVgxnEgFr8F7jEdnU5GvqfJQKQKyEOPlsNIQvyvupAGHS/Okv4qv9oh+PHxMLk8ggBCRxvAmEN+AiEzz2iQfQBeNmkh4K52hJBKOaNe/FSLobLRXCz43rQnu2yi9oMSMDxs2jo8303ERz1wsCGZECF4kd3DwEYYwJjhoNlQrgIjlYodbBPrwMAZfEmyzcIv27gs6XDzC/IR1DOgA9a6DRz4wZAsZ+LYXvQYsHoD4ziOFklna6YD3+nnU6dZ7bGDAcBUImIAmEUw/zbJ1i/scGNDJiLXmle3RhQ+l/aq57gUQCWzwwBKPeLsZ/LFrGg/ShRXAe64Ajkv30kALAjF8R11Dy3K7KRwJcsUTaqWScARou3w/INVnCH+A36n8RvM3nB5XP4oD6DATBYwGb5ajlOLOh6X8JaBKRG77+7ygGYp1bn+V25/01AzBnwQ1ypanD7KWfA1QDYC3zJIj7KgOUzc9nFbetX/r+O5biwNhyX5uSEDr5o0xsJwLp8/m4A7GaJUv/j3/5+HQFYJ3oFPPkho/hNeqBcMkcB2BAA6XrxmMBkfFAci/m0JpwzXw0TXvXtzrz+PKc/Ml/ugzM9MDqCAbz/keVjjGcQA/YLvjoguo1mRslRI6RwfsiA5nqhL5D6nscF8gfTdfxpS+/hLzvWfzMQCoB1Fq/8b3VWaPIDZqsRV64DALsZHVHs1gEvsqFAeBSApQC8pHK90Oql4UEAyvCwNeGcBXNLOPMLftgZsI75ouUr9ousp2TEyIJ/sU4AzC1e+WIFshyAHPZREVwItrrD3wGAhibTYBhxVpe/xePyrNBuWaoNp3DgFwC81O+RAepK/a5Lfe51jxr7JwA83nPXYgq1asl0yX5N48+f4VEGLATlK1vAo5YB1gBSRmsM+NFE57lcfPD5pPFWCJImtyvGgGfOAacBYO59zFglgHgPefZsXV6/gPXBYeC0RVgyJNOGYuJjPka9eHWgjL9bWzhWk0/n/wPn+k8bgFNmgYcsVflZnBRmIShtJM/m7JGibGBoOIIez9wKPP4AcNpylfbNlGfdI+9NjBjz8JVzppckZuJ+dBw4aQ44drk6j1LIY9JkPD7P4s2lwVEGLHwJnncscNIh4Nh5YMsSsHm5ndOu1BGFThJ8/K6JrZtoslST2+XHA6ftB05ZAE5crgAups5TfaL6EF+UyIif3gAcOwtsXep82eIYY9JkXpMgMp/AeZQBC2b8OduBYw8C2+aALQvARgJwGZhY7swEzbNa88IRvAVO1qkF91J36DNOBE7eD2yfB45fqphLnevzdGeBKBfL8UX5/CZgyyyweRHYsFwxYHzRNK6oetSBMDLjUQAWTPqPngpsnQK2zgKbCMAlYMMSME4ALrcnR6JYQIwsoUnjpDRstOLy7cBJB4CHUGwuAtuW2nUDVH1EFUhycSwWjGD64mZg0xywcaECoI0z5P3X5P6nWlHdgHgUgAUAfOYOYMtBYNMssHEe2LgITBCADkIzSJZXpCOnIg25uPrhgnupO/TyhwLHHwSOmwW2LVSik2pCrDsQskzNIBGIpBdGI+VfNgMb5oENCxX4yPRjPj4xaJ0+WGeEHRXBDUz2Mx4FbDoIbJypADixUAFwzAFI8KUJChMV2SUaAGc1cE/xFJef3FYRti64nkqWDrqqEhbrsm5zvZCdPCd8nHzJOLZuABRz9hTHZwPL7LnLnoNMIY2VyaKcjtZLHOAbNgNPngKe4BacfGF1pnydD+hphQ/8XV5UiEueLGnDN1tWXj/3/4cTwAUzwGPcRcFJiDpPt3FLmf5vjwE2HAQ2zPrEzDv7OQg5OSM+ScYQy5Xbo8465u/ZfLTJ7fKHAdumKxVh8wKwealSE6inEoSy2MWCdbUHIghv3AqMzwHji9VLZuDzD8cXxxWZs5c7apmW0fMBnIHKn5X7d6I5npvRz94O7LgXuGIReJSb+Xl1tzqflybwRwqf9i97BQRWomWJQ7oZVFtJoqDX/b/oGODsvcBTATB9gsfGqmzdjtVz+G+PAyamgYmZCoDjFE2anCVg1CeJwOMnTRB/DmUINVkkgia3y08BtkwDW+YqAFJFMD1VAAw6XG61R31O9/fdrcDYPDDmY0zjc1UjivBuAMx1QdMB+WAYXU8dhEU16dOSkppbcHFSrng8MHwnsGMPcN5ypURHp2xMIa7zDz2z8Gn/kVe0YomO0wEwBYKujL7v/zHA6C3AxfOVh58g5AsZxx4fZM7sf3h6BcDxWWeGBZ+cMEFiwGEHHRnDzun7ONHs/djkRgBunql0VDOSHIDU3cxSD4aEajhFXS4H4S1bgVGN0V8we7E0Fh9jVDG6Obr1LJMRwn+kOCaTEYT0dsfqZHXl/p7PrLi9wIY7gO0H2yAgCAWCWCowKrYE8nMLn/a7PQn9X7zIJPPkCcK+758y7x7guNsB6l98gZjLLYet3Ay5n0sv4R+fCYxPA2MOwLEAQLIDPyP8uBg2cRYmzFweAYilKkn+OC8/Fdh0CNhEA4nGA40kd6FES13WLO8v1qHKAfh9B+DoYjU2Ak/js/8NAIwg7OUb7LCC+WAfB4CpBJoIiTRNRmS1l13kqWh3Adv2A8cdqqp1MB+aIOSxWv6pq5D2kkIAvt8rF7BLJksN/jMqfa7v+7/Ak4B3A6ceqpasKMq5akAmlLWY37t8ZW97PDB2qALg2BxgAFwANEGcnI5JcrDZRPlkaXL4u1KJUAfAjbTQ59x6dSvdLPXAgGYshZWR6JIRaXB/NwFI8C1WwLMXzMeSwLfcXuKrA2G+wrLCDcN/IIg4ERRn0qvyySAQX6mG1XuA4fuAbTOVwktRRr2MLCoQyvEZ/UY/WwjAj3jtFJZkU79g1ghkgEBf98+0Umb/3A2M3lkBl/fOcdMok2EjkZyv8773LAfgHDDKjwNwxEUw9yailpwdxBAEYhBbAuGzG3aKkQEJwAkCkOCjlb7Y6SYyf2UwlAS+vKYnAXjfNmDEX7DEfA5CjUcsnzvbu1nDtUMmCDkRZEEyGdlAk6G6lQTSa6m0MP6HuY73AxNTlcJLZ6WOJYC5/CNxLpHMgdKIKNl69Qvu6/75AjHOiTU87gKOOViJb748BKCWrnK/maTA+58AjM0Ao7PA6Lx/xBAupoYDC9okBRAmPdBZ47lNA/DhwMRsxX7mPgl+SrmK5EaRNRslXFQ9CKB9DkADn79cZtkHFkysJ103eBbqlh97DpmTQTYgk9VNxu+xYbXKU3lhFoJPOgdFGY+lPkgQxokkgF9Xgj4AvfoFs84eX4Ke9x9fIC+tRfDxvvniif358sSir2LCj5wNjBKAc8CIi2AxxLCzIAGY9L7AhGIKgpATw4l8wToB0JjPrfTkp+SLQbHrOqm5jNyajS6VCMIpApDAWwQ4LrGgXqzIfnq5cv0vN0ZXHTInME5GBNLb1DGdOYQsI7AfGKFjlgqve8wJwG4T+fuFAFytXzCLb+VgWnH/fIGYfc46Hs7iHC8ZkPcdXx4VfVXJw8+cA4wIgM6AHSLKWZCTESfLfg7WsIyRF3ckiRQ+HACXkwHptyP4KHrpJvKVGnOhRF9eBF9wE0mUEogz2wC+WGI/vVxiQQIxAs9+rmHA6E1YFYB8DJwQMZl0OrLZ++i7sfT8zroYHLS9df4RACWKxSZvLXzG/fQLZqk2gqn2/vUCUQ9UZaM9wDaPeSPrC4A5C1KV+NITKwCS/SiCR/jRBDlLmP7nHynsxno1IPwJSyRpbiMADXzuPDYfZfBTEoAmcuVQdiaW0zwXwQsCYDYmMaDA1wG8TBSvaoR0G77EcGSET6hjOvVApfRPAUN0zjr45JzVcSqiTxD+VeGzXku/4Nr7JwDJOkxFIwt6j6+RqUrlkO4bXzp1gCAAv04AzgLDDsBhKugLFUvQUhTwCEKbnKCw14HwJ9cDgGQ9WegRgDI8XEcVEDvAl7lVlglAgi+I4CR+Zf1mLGgMmDFhBGFfDCicRJFERviSABjLS7FC0MFKMU+07wOPE0kGvaoQgGvtF9z1/iODkwn3VWoEXxres5ib9xx1wZufBAwLgAQexbAD0JiQwJOuJBA68/H3Zhk6+3CifqqwWNMKN8wjKgbk6gWJgC+FMaBb5vJVmsUbV2vCqo3cRWZcCIACoax53+ulkqNd7iqOcU1WcC9cxEm5kQBUdZ+sTnSL/jEtTWngi21jhJNJBivZBukXvOL+yYBkcOqxKjJ4AGgxzMrBVwdAMmHrZOAYF2l6y/mwV6xD17zmWo6MbRyeWtOHwxJ91IIhr6rqZS70DPPLXDVUrfBwzHKr1EUp6/h0T/6L/GcCqslt4IhoTcwdAqDSs7I60WQH6R329pHuFyuXDJmEjuOSbdB+wSvuP5bGUjmsA5XoUvcvBXKKAQnApUdXwah0b8jXR2YzJTsC0ZHB33FL+2yiX3h/1YeD1fFZGT81g/H6yqkVa9YEpqMhTADle8erHA6t7Mh6j4ZBXdBGjFyO4CSIm9wGBiBvgqxwIAJQlXIyEJLyI/i0SkAG/FbhaEr6BXfcv+5dLKhCg4z1C1HEBJ8+BODQGZXfk/quAZC6ketAZEQCTWAU8PIJt0fgwHzZvVWNaKqi7JLOmtDWFy42g1FxH/XfqGkII0C+a0tnDkfsGxQjn3VPsk7tXmuy+Xp0JhtoJosAaFcUAJUYKiYJxcqHqKAH9rPlG2cMrmCUbMX9guMLpGTcCMKDlZGhMK8IPnPIn1X5PA2AwegwEEYmDGBMjOI5whGQP3NPBT7VJlRNaKvF4t2IWHbDErtDlSk1p4lJ7/zd246tglGZryIfrFhQ7pU8WCAX0ZENG+57U14Z4YrCeLrSxXdev6TfLwrbxT7znMrfKQXfHLQCnyvmRIv0Q3430ezMmL98P393G3wqz6am1NYzzoGn+svqRmTAU2citctqAX/2EI8F9ACEmLHXLZGoFxtSl2xyK2bAYwrj6Xr12+1noL/jUTCD9vvFrn6u0v1/nvGkaoVBAQi0eummMAuXQHMWJAA7gCixG8U0gFfcXdlBKk4Z6zELgAJfZEKrxpC1xOIl/+Sk7jkcdYlSco90y9+gK6vJrRiADD0piad7RuFo3udNCgft94vCdrGXn+tujgV3QAcHLcFnroelivHkchEL8ue0uQ74S3eubAITS3IQhKkMRjBMokgWG3L//2z3VSnP4VDgQWxUEEUxAZFHL0eR3HDfm3IRbDHkBfF0zy4EIKNhSvr9goGEBdvTz/MIYQLQdVsTwRTFDj5jQmdArRDYJQNDSs961R3tPhx5NXoVgoxleHnarjohgLec3D2HI492yQNvIwvqO9fJm9zKGbAwnu6FhaP5pFuMg/b7tTbpBdvTz68cz/zI8azVj8iAHTqgmFHXDUB89R2dtaC7tUGw4kDOgFb0R2wYRDGZ8g9O8aU4XwPOczhiwGlMjqqLWiFYGu570wADFsbTvaxg8nkow7E8nM/atfKzln6/1mS4YHv6BQ4+Z0BbqHcd0NwwYbVD3+1yWhXJxPBrbq8AqE/XApSqAxiBV2MZ/54DMOZwKE00rnDUWcR5KiV/brjtSAMALIyn+/mCyeehjIYp6fdrvVELth8RAClyHXxmhPi6r1m8FM0ucgk8+y4RHC1kAK/5XgW+2hZYofafWcPq1B5AqDqEYsQ3nepR2gqhV2yiol1COkD0C+aOaoGx4aL7DQCwMJ7uVwomn4fm7VrX2u/XAlELth+5sHPtN+l/Ap6sX2dCsZ/phZkIJgv9l++1wbcq+2WFv2NXIjNKAPzuw7MUAV8DTuynFIEsQy83RgTAhiv+NgBABaQOGE/3mwWTLwAqHnaQfr9GnwUbARgDNBUlkpzQboyYCyYDYdILdf0l4NduW9kGoa4geNdazLElKoA3Prx7DofiETtC6XvE7hGEzJlpcis3Qgrj6d5UOJoYDcMglrX2+y0NPtl5UZUjkfx/Hqbecoe0OZzdF1gHQrln9Bhee4s3f3Zxm4MvAk9VSFdUIw0i+Q2PaBtISiBSSFgCYMjMW00MP7pwvvLDmwFgQTzdHxcOSGvBg/b7ZRZByWYAlOERluKM3Ra9CKWc0q73dTBhMFT4ZwIw9l5Lrpes+HjeBiGCUOKXeuBvPcKTiEIOR0f+RhDBMYi0Lhea4GTaa5NbOQAVDzhgPB1La5RssV3rIP1+7yy5OAADoAchEHBkFbKfGRpiweAPtMs5IFNokyOGk/7rAYC9OhBFwNXVY1at5tftCBHaWVS2AJdEcEinrDNC+Lumiyc1B8AB4+muLARAXTDCWvr93lR4/Z0Xt6ODFQkj8WtumEwHTKDLQejAfN3uds/dfjoQdatGLxb8jQBAYz6/boxiFgAVudzNIc2/s3xLk1szAORoB4yn+2DhaATAGJCtbpkCYq9+v4V+aBgAQ4i66XtaC85YkDog/zdZvzUgfN1N7a633Xqv6fe9msDIHfNaB6Ay2JRE1AHAEDIfI5nzZCLeN4Nbm9yaA+CA8XSsul6yqV0rJ2WQfr+splCyCYBR/HJyKX4phs0PKBZ0lqOYTpvniAiUAmAd+HKjo1cvDjHgr+3wPJQsVCymUZrPMuRsRBDG4AQCsunyJtFGHwAAIABJREFUcc0BUJlxQoH62q8ST8cggpKNAFRGwCD9fkuvbwAkyGgJE3C+Nz1P1q9/T3F1EZBxvZh50s6AEYC5yyUHXt5/Q8zI5/KrAmAIkkipkyGPYwXz1aRT8v5ZO6jJrRyAvKOvNXlLazsXs9bo/ztc29Pohgotp5J49Rcj/pzfIwGS//3OM4CNd1dpntQpFUmjEH4LYIgnyn/OLjL8FeDGhwJbNgFjI8DIEDA8BAy1PFK7FSKf43cNKrvHx+8C/vmxwMgmYHgEaA35J0StpvvzL/nP8RbLAfhyT207TChgDRiu/ZL9DsfWNABvYzbhCDBKoBAk/pEobGWTqp819hzQ1/0k0PoaMDEJbJjxVZFgDad0SaUO5LksWVj+XScDmw5UEUDJ6U4d0nVbC91S3ovfVHp5al64cgC+k7mZAP768KCA0WD3A/ieLz090CDceVmlAuhBljLgrfcAw6PAyDAwPFwBkCAbItM4a/FiNtERjBl76W9ffD2AbwJDdwFj+6syImRXrd5Y2FjIYcnzWPLEqnsfC0zsr6qBMQmfIDR/pyJ6xMhKyMrSDiKD2xja6TADTt0/AGAs1KcAUCFrOLF6tbtiRVFavT/wuMCa7MfVTlH098YBeBcwNAIMEYAUlS4uBULOmK3LCnwOPANlEIOSoF9+C4DvVoWXhvdWZVOYqWgi3vOXDUQhgieB0EElViMYJ08HxqeqnG8D4IIDkAzo51DKQQJvBKUmKACzbM4+5hUivwrgiwC4LzvjmgCh6nBcgiMTcv9Abo0D8E6g5eCjfpUA6AxoQIzgi8ALmWwC4z//DxcPPwBak8DQFDB8yJPpPZHeGCyC0KN5DFCByfh9/+OAsekKgEzCTwD047X0SCPM1IYQjCv2E/MJoGVwUUQoPboq0MdqkWVn7RtDDMahB4g+P6qhXFpjVtkDtRGA2nKjos7IyOyHFUbIrXe0FXsTuzIYfNb4O2M3ATGIYQOmPn6hG6gi3eUkQQAeAIYOAUOzALMVh2pAlESqGFBAXAYOMQVjxll03iO/yYKRAT0FQXkwZkjp1pz51LO2XAT3KtD3AIAwj4Wg05kfiuUHYlsXAJLVnP0INLM0OYFx78AzcRySeTsw2AJueI+Dj2Fne4EWKz5MA0MzDkCCkAByUWqsJzarEanzj2zXwjEGFHuGY+pYsMojzZL1G9EBexXou339IRBrC3lJGmNDuSHX+w7WC4Cm6wWxm8DngLTImgC8pBcGBuTXf/1fXnyTugnFwxTQOgi0CECyIFlsvvJfEnh0mhsYI/s5uxFYi1xZof7oOqSAawwYjRGBzYGXbtWXaCIrlvHUagX6SP/ruMVYCEbEqECXAMjfree2HgA0ESur1/0vtnNwGSsG0RsZME20/+/XWH6Mugk/yngPAGy5GDYALjiIHIgRUIrsZjM7Ax+BSx1S4pfffQVIep8dL7dMDsTGjJB+CvQxTHmdtrw4l0CovFruC2NOe975egDQsCXRK/eK634JhBK90q2C7I1i+Gt0jxF40k1cPJAB7UP2m3MGJAAFQrGei9iUTH9yBUDTHfU3B5+BOIKQ43BWtNtPcWIOzEZE8FoK9K0DCGNxLi3FqaKA9gTgeoFwPQAoI0OulWT11oEwiFz7cwbErzNxWtEYBB+VY76Vh4DWrH8IOoGQ7Ocg1CqMRLPltmxvs1/SHaP4dcAJePYyyUCRIzrTB8tE8FoL9DUMwl61kQQ87Rmy2PS2rgB0a1ci18RudEJH57OsY02y/+83/sZdBKr4FXQTApBvprGgQCg9UEAM+h9F6ugJDkC3gJPBEvRGrYoYCBX9IxEcS5K4i6cZAHIw8oXQ4mLBb35YH5d7OekadtTV1UZSjaEIPH4nQzYNwgjAHNwDuWGYpZc7lzPfX1cQur5oBorfzDf+zi0yVTuSkuxBI2Q+PhQDIUEnMLo1TBCZLufGw/ixbQa0KB8CTODjPohdY78IQmfDjmW7Yo/doAX6GqIiAtDHaYswSmeMubV81kp11L6hy2PdAcgblfslOKC1IiKRmyRxZgV/8++DS8BFrxXi5Hd/U6MeSKdqEsEKhpBRsgRMbAtuG4KU/+9ry5brzP/lPVMv1EPOQegharrVcgZUhVHFxNPcp9VFtlOWkL437C0WABWypFRGsV0sb5Hn2zYBwvUGoKl10v1knDgo0y7XA8Pfv0UACnjaK33Co9gJQAOe64FkNvtZAHQdjz9v2Nz2GSa3jYej2W3KGuZ9ixGdIVSoKT13B2s5AHkGheST6qn0erHv5AIgAAU+LVfw/wq3CEAV7clBKDDGZG9/5oVXx/oyYARczcqH5GyH8eFplTawFvAtrtXLGpNrQDGbejupB3omlIHQGc/ErzOcGSRs8zrhAbbuL1Tco/JfbLlNwHOmi2kIcs3owbdwNpYtynDQhsFcgvuG9/YapGFvYX22zZcAU0/GwA2LJ/4AmGF9mwEbBu98Y3cMF+uAGQCj2HVp3BbPuo3IlqxAy5wHAq4OfARmEBXGfNIBa0BIsG0ecwC67merHgRpZLwocrWaovuTxew/V0txJQ2DWeae3WAGbdhb2DB4+wRw7w5g8Qpv88liyGtoWHzMi4C9fAEHbBi8kwUKu2xNAdBxaGBLbJdZux1LwAGECYAEm6wyfpelJrEgFnRDxESwgyUxIUsVMwjVy5AYO0bG89Auu1/5BF38KqjBHlUAYXsteNCGwTeWNuwtk4JMkrlzGNizA1hm69g1Nix+zDOBW0aBeRZZGqBh8M4emfWNADDT+zqMjQyESdQFHfDbZECCLRgdHeCTe8CBaKJY1rDnBRCIAuGW4TYAZeFG8ZuMkGiQ1IEwGCJtHZBmy1obBsvVMnDD3jIAerti3LEBOMjGcOpa3WfD4ic9t6oveDtLfw7QMHjnH6wPAybW6yaG4+8D4HIQfvtDIVtLejpBFsVvUI7NIBHw3DUjRzL3rDVtsYPOkAScuX3coNDynT2VYJCkn+PjqvUD8hVbS8NgjphGxcANe8sAGNoVY/824BCBtIaGxRe8pLKZdpMkTvXiJ2toGHzSNHDPScAyq3er4qPyGaNc7JCRXWLT2TjwGmCOeQashq6+qSpZmp8vojQpheF58ncdZVjLnjWPHr4VWKTKxrHGUqq97qXu3jp0wPy+eEC/DYNZsZAO6IEb9pY9lNCuGPcNV830ZmkM9dmw+OKfbdcXvJMPdY0Ng0/7GnDXKcDMccBS7MwdKz8KCAKQIgY0MWGCtr4TOHAasMwOkTqf6unyuLykfd254nkb7qsw/iVg7jhgmSX31Vpd9yRHeLx+zRhjEGRbB6wDYT8NdymyubzDzCCGfpMJWfSRYfr9HP/aMgBm7YoxNQHMbQHm+ID6aFh8yS93tAvGQb7da2gYfPoXgbtPAqaPA+a3AEubgGU1RM6B060fgkRoCzj+TcD+04CFE4BldZdRc4/YxlxgjJMewSiwN1zWfsOngdljq3EmY08vm5i/7j5yIMqpvupKyGoNg9lngYosl9wY/0dZdrMzYl8Ne8sAWNOu2MA3zw/F2CoNiy99XbvftrcLriz6PhsGn3U9cM9xMODObQYWCMANwPJ49UliuW6SaqqBn/gGYP8pwPyJwNIxwDK76ahDeN6uXYCuYyABkEza4LbpY5WEWdSLxjF26/dQB0SJ6r4ByAN6NQxmkWcqrnQ00x1DEDJFjR8CcNWGvWVPp6ZdMQ6OVOCb3wAscPJ6NCy+7PerkP5Q3tBY1PrT9tEw+JwbgPu2AlNbgVkCcCOwtAFYcgAuiwWlM/XqDjMEbP9t4MB2YO54YJFMo/5gHIcALV1TRZ17FXOhPtvgtvkqf9H4kvHDlyKK4l6VzvVSBF22uwjOb7pbw+CfcwBSkyeFEHAUx/yw9JTyEbo27C17Ol3aFWNuAlgIn9QxO2tYfNlbK6MvaxeMRYquvL9rTcPgJ30TuH8LcHAzMOugX3QALo21WXBZLEHwRF1OgHS2eOgbgIPHA7PHAezNu7QFWFZ7JnXJ5rnqxHEulvlzwyVNN3+wern5Yovl7SXLGwvn4riLWO4fgMRJXcPd/+pmOymELEhRzBxJAo9gVL4kwVnbsLccgHEpWi3epocCAMeBRU5eTcPiy/6qtl0wpvhA+2gYfO7NwOQm4OBGYGaDs+5ExYDGgqP+ccAkINaVpB8GTv4d4OBxwNw2YGFrxYCmV0YxLNYheCXau7EhV3ga3Lb8g4+R45uoGLADgHWqhsBXA8K1AZADyRvuvtkBSArh+i9DsQhCOtf0UUgW/7aiYW/Z0+nRrhizoxXwFhyAi5y4rGHxU66qAFhT3rDSIVdpGHzencDejcDBDcDsBDBP1uX1CMJRwFiQIBzxieL3KIY1YW5MPOxNwLRb8gs0aghAss1GZ1O+SFHsdRPt0i/PLHu++dFb/x4mXfhcbWxhfCtYMFr/uWvKxfDaAcg7ipPCvFOVpuo3HrCjYW/ZA+rRrti6TS6MVQ+L4NPH2nx698GnXF0BsKa8Iab4dFZpGHz+JLBvApieqAA4J8CPOQuOBBAOV0CUYbIskRkAecrvAdNbXc/aDCxSpyT4CEIyTgRgneiLIp3nP6fs+a4A4N8B8/48CUC+ZGJA29fpuLmxJW+5h5kNFg2jiWHSi0r0Uv4pCoZsxw8DUfnhd4Vk0XGdGvaWPaBV2hVjdjgA0BlpkQ/K9bmn/HOVqtClvKEBqlfD4AtmgP3jDsBxB6DA7tdbcvYzJvQJkii2n4NOeMpbgJktbYPGACiF3wFoEx1ZMNe/4jnPLXu+KwD4t/5SO/iMBcXuesHylyACMBPDgzGg7opM8mEHIGdwrfGA1rC37AH10a64Yr4APvvOSdwEPOVbKxu+K2pdKRTmdI3dqkPPVgbSTBGAY8AsATjWniBdx0QxJylOFCcr6HBiw1P/CDgU3EgEIMW52M8YkLolQRddIN1AyKWiBretf9MJQN6HsaCPxe4rvgDdHOcOxDIAcmDFDXvLnk4f7Yqt63gEIB/Yoj+4p9xaAbBHeUPM8qF2aRh84QQwNQYcGgdmx4C50WqCFngNsgSvQ+Dxu4MuiawhwIAXVk1O+e/A7CZgThY1dcno1nHL2oDIyZULpBsAFTBZ9pjT0QQgn2V6ufRicS8QRgbs5ZYpEsENDejBfpoLrwAOjgIzZMBRZ0AHoUC+SOA56xJwNlEyTFw5FxBPeWvlzpnbANCdQ1eSGTRybMuydgMggVBsKmtYoC6Mt8znZxsZMLzAxoAOvsh+ydDqtXx4FIDl8L/omQ7A0QqA82S/ERdTI22mNfaTuBIIxR4BhKe+y61punQC+MytI/Zz/c9EuvyBeetLAfGZ5WOMZ9j2/gqABB1fMLsHAVBqhfTcyH5d9MByEdzs+B50Z7voGZX+NzNSsd8cwUcG5ASRKYbdHRNYwhhDIHRgGmO0gFP+HJh15jOXjnyKblVT5Cbfoq+yJOszF8P8+VnNPlICkMAzds/YLxlYznrJwIpO6egTPMqA5ZNDAB6iCCYAyYBcBqTRQ0e4630SxZyQJQIvMJ8mSeLrYe+p/GzGfnTpEIBy6US/out+K1wg+brs88rHmDOgAVCMnrEfxxMte1Mt6j7u9zzKgIXzczEBOJIB0BnCJoqgIfDEhM58SWzJEPGJe9hfVH42un/Mfxl9bgSiBySIBWnAJBDGEDAB8QWFA8wO3/a+wH4+rg4RLPYLul8tCI8CsJmJMQAOuwFC9qMI9g9Z0CxhZz65K0wfFBPqu7PEyVdWAOTHVlTcpxhXHZLz1w0ZA6EDLhkCskRf0sw4dRYC0PQ/vVSRAYPo7QCdj7GqVOSMeBSAzUzMxZcDMwLgcKX/zbv45SQlHXDIgagJc+bjZBqAWhUoH/Y+B2D0J7rFa6LYDRmzomsAaOeKqxEvbWacHQB08JkRIteSXiSBLYJOLB+X4xrzAzY7vgfd2S4RAKkDDgPzNEAIxMASSWF38WsgkuXLyXTRSRCe/DduSZMBMwe6ObTd8JBj24Aot07uDObPP9XsIzUGFPs5+JJ/M6oT4buxHv9X7BeY8KgOWDg/Z58GTC9Xq5FxTXOw9c3Cm6k5fPcjgbHbgAlvVG2tH1T3Oavoq6BlniZ+12n5u/2sDbOvasqoFg8x2Lnbcd1GdhSAhXN+7qMrAC4sA8sORJ6yHwD28z+Ft4fdv8UyqUDrDmCEBcpZ39kLS6aq9l4D2rLb/KYsFTPWdfbvh86vQu2s1K/K+zIjTsXIVQ9a59Egs4Y6sZfIA/EcSp/jEXv8BWcAhxaA+SVgSQAkGAMICcwVlNLlqTc9Gbv/HAA7MrL4+f1VlXwrUq7SvCoyGcrrWpGhuur2fNGYwM8YT67hT3s1LaZvqn5MLM0bzmHMmIFSgdFNj/mIBct63NhFZwEzDsBFgpDPeanNgATfCtGsX9TIKwNrg9tuVkhlng7TI/YArX1VkXKrEe1l2SynN1RCsFJsqnQv3UIMxhwIRjU5AGN9QUteVz3BUAvahuNgjC3HxLAND7nBp/cgONXF5wCz8xUDGgCjKPbvevlzcKUHH2ag6cnYzepYBB9Zi2FxDJdjoXJv1WDFiLJ6MKqKZUzoQFTfj2HmwTKcTpVWvcxHKm6kKgoORAEvVclPD6NdzLXpMT8IYNPcLV7yJGB2AVhYrAC4SNA5AxKM9ryDPE5fs6eeVKWGZ2M3S3MQfEyJUKV8L1ZpJXpVJ9pLilmlAxWkVJHKwIhjjD9TtVXVm1HdOy/pJiaMFRWM+bo0rWl4yM1N7oPhTJecC8wRgAttBjQWdBBGESwgSiV0Pb9DRgu0TY19N+M1mRKh8niqFx3rRDsLqjgl9yaGXT80vcL1wnE252PAZCzAHQCoiqoW3yYWFIt664fUpKaREr1NPakH6XkuOQ+YDwy4FMSwgU8GSRSz0UJx3Vx/5vFNbrs/EiLRY+v4ACITww6iJEodQKwBIyBRv9vwhKzUW6z66TUGEwhDS3ezqusAyNxnJn8xa1KRPSFts9YfFB/QDZcAm78CnDBT5U8rCqjfc3yh8Gn/hGd/MsKf1+QzYJ4891Jye13iy1cAE9cDJ+6FpYrEkidxDN3OtXR+FwBGMezoMmxJLOumAuD4J4rxJrfdH/XCoLGFVKiUbw+LAPQqWWaMMLrd6/+JycSIm85w9lOpt1j1MwAwFTiqAWEUxeYH5ENn/jInUVHeMXQ/f/jRePvCa4DhTwLHfBc4frGqqaNJzLPw6iZxV+HTplFGvZrXZT45N39+HW3TujlZv8D6fp8HRq8Dts9XIOR5YtakgBgdrrrt5Qsq8Ssd0BhQ4HMwmVitAWHAY/LbLDQNQDaTVJ8Q6W4qVB51OOqDZDPVB3TLOBepW5jmqaLbec3jGgBGMSxvvemDYkQ9GoKF1ShUCSKCqBeQrvmfVZPC1keBjXcCmw911tTJ8q5XgOLaQgA+x/OdWA2EGZ98gbjleTHdQHQN+2iwls3nK3/Zhj3VeQhovYzdxmArSwQgDRA3QiSCJUrTnjfl4KozRCSCCeYmt90EoJJbVCk/1+FiCwFZxLk4dRfLFia6x8LbYkD9v9cXtLG6+O4AYQRfrgPygVIcqyhTXcWFOJH8fh3rz7EKwnUArq8mcGwK2MCC1i7WY7Zenh56feHT/jE3yliE4TZncd636gPFCKWavGhcRx2J+cvs9MlSw0Ty3cCm+c7n0G0MExdW4BMIbTXE9UCynvyCCX+Ovm4gbByA/xisVgJPpXrzLj4EoRJjJIZrWHArS9iprK+KcefgiyB0XVKGjOmCmW9xhRVMUSyRFnNeFGEdI2q+/HFXclkp9WsAbgTG9wGj08CI64WxRk/OTDcUAvBHXSLQxcVCDMQSWbzv+1e7WVbz+k5w2tJtsbcCYV6WJY7hmAsDA7r1Sz3OgOgoM+KTOJbcjSI5yGIaNE1uuwlAAU/MF+tF5/0sIghVLdVdM2S0bSzHx2Mi+FTxXf8X925NC4BycK8QwfmgVX1LlcFiykEMcL2BndJJ7aQfijKfxLGDwAhByM7aC5U4qwPzNwufNnNuOH4VZaCPlPo2AahqFqoPVFc14ga2m+WEEL0cAz9kdPrOmMu8r1o/rTsXz7f9oswFs+jO6LAqkvC3Ggg5Fg6mwW03CUI6X12h8lyfcz3QHqr3DIl64DbqaQKc9mI87QXACD6vpJqY0EVxz2CEyCI5eMSGX2e7VtI5J4yTRyZhscrvt1nQuivOAaNLlYESwcySgiVbr37Bfd0/u31yEgg2FVaiPCeVOguqAfGov0iR0R9JABJ0bnwk9nMxw+fOh55EbgRhzozrBUA1polN9CLwok5HEEUQBjFMQB7D+j656PW+IrJ8O/bBCo4sGFdGejqiyYCx3mKe9/JtTiBvmI5OFiTisg9LtJFF7gZGDrUbHKs79+hyu5hSaUvh1foFr3r/6vZJCiXgCDwVVFJ7MVmRLsrGltuFCc68yFdACMDAflwR4QM3HPoKgIExt4gz42SuaQb8hBOE2oZmlu+KFlKR3QSssMJxDPWbbjpfLoJrxG8CYT8MKGZSVTCxYFTIb84nkCxCIPLDiby30gXFghaF4c2ReR466Uu2fvoFr3r/fKAEFxvpqMcd9yonIrkuK5LLV7MVCM+/uDJCyIC2J8a0z1iwqyESgMl15Sa33QKgmtPEBnp11mwuXgO70Ud4DHWzfgDYC3zBEOk7HlA6XKyHQzb8HgGoCSQLqsxorIy1Bxie7Wx0rFaf+wr9Xv32C+56/7HbJ5VHtRYT+GJrsehHcya57PyKAQk6+vBkBZPpjPEExlwU59awg3C24W6KBsC6tqHR+MidyVG3i3rdAnAsH2T093XT+zLr197MTA80h3SfsZP2UqpCrPQ46oF317VrpeiKXTJ9MhMLkgGdCacKG/mupV9w1/vnwyGgCDCKWzJe3lqsyzLWZWe6/kc/oKzgKH4jC7oolhdC4jiuzM0WPo+cPQ2AsX1obFCTO5Jzn566PwbReiwnfTWjI4KvDoh1juh+aT+WKSYD3i8Aql2rJk+VsVQly5kkddv2FvHT61icqO7Fr71/IkLNXOi0FQjV0046oBy6wZ922Q95ICqDEaL4XWw3COcf9Mw73DFB9AqE6wZAAS8XuzGQIDKf+oVkqxt00ttAc+YT0PJ9qRFSB8xoye5Xu1ZVeCSgCLbYLVNswoncHxoeLwCzBGjBNki/4BX3z9lXgUCyIIGmhova83cRgO5Te9yLgP3MfmsBS8xs8/U67ePQOqy9umBUruDchqo8sHSd3PMfT5ifo+ack8eFHI6QEcnT5GvdOnVdXof+ptJ+BVPWceiaRHA8Us/nkACo8mzqlqmWrbFDppT5A5UIZm7CPA2Vgm3QfsEd909kKIqB1qJAKCBG8ZstZz3xHOAAiwmpDIdng1maZQAkZzsHZ537YfQrwNyxoQ+HakrnS0h1mUA1C96TdJTmORyhC3oeqdwROi+GDhkFI6bYNrcNDEDeAkXwQizPRpmnIs3OdqZPSaRFUcbchHlgie6agq2kX7Dd/+d8lUJVXuUzk8ERmS+2vfd4uvN2VOV5rSwb0y3JhgIh9wJeN3YMQCIgR78Q+nDEVYBYZUrUpbXFnM7COSdf7N4IPvtDnT2BY/h8Chh10MXQeYGS+7GGjaQiABpuNIFiECnzdWJMIUHcazLptC7YivsF8/7FgLFMqpiQL5TuNbKfA/DC46rqqAbAwIKWK+timRUBEiNGsOQsyQm+Gpjd4n046hbT84KPuYjOmHHyp92gcgDS2OoIuVIeh/xyUkaVwyEWdLrewHE3uBUDcKIwnq40HpDXL+n3CzbaKdguel5VnFJl2awaghLQBTzteZ0cjLq2A2n0M6EPh2pC57Wg41poLzZsAZNso0Hw6eVR/J8bF9YjWGmVCpGKwQLBRCcrbiSxNLgVAxCF8XSl8YDHHFPW7xeFBRwv/rGqOKUBkODzqgdWPYAM53vTASMQu4Bx9J+69OHIF+N71F1O1gUB+AsBfFqKC+4Wi4BWX+CYgOTAU36wdMVNVKka3MoBWBhPxyiuko3xkSX9fvGMkqsDlzzHC1N6SQ4DoINOe7KelWWTheziObeKCdARApD1AdVnRH048gKUAmAEYi6Oh4DJV4VoGDWqjq4XLbO5o1jBoimEPhPJmwu9FvnTLgdgYTwd2wyXbMyRKen3i2eXXB245FlVYUpVxUpGiLtmGBlrTEhVUwV8dEkVKAq3MHJ1uzRbRx+OOgDWFX6MsXJU/36lJoEoA2AKvw8+uwTEDIBbStdOs8ddDsDCeDom7ZdszBIs6fcL9ror2C75US9IxJJsEsHdGFBil4yYuUwknofJgF4XcEUfjrz+X7fKo4EJJ//PkMORO6FrVjQMeL5kJhZMMXzLwNZCt1nzDFgYT8cQwpLt4hDON0i/X7ys5OrAJVe0S/ISgFY7j9ZvnQ7I3+lyqpYaL98CWp/N+nDkZdhi6bW8An1kP3fRTLKVWlwF6RZCH2L4zDDR0k1IqeTNb2OQSYNbOQMWxtMxeqtkY6I+ny9VEz6btfb7xc+XXB249AoXv85+tIBVgJJ6n4lf6oV+mfjdDJNMH0wAVFX90GMk1f5TxlS3Fggh92DyN0IORy5665KIfCktsl+K3VsGtpVOWOMiuDCerlSnjQ2rB+n3C+pIBdulz8wqonrNPLKgwKaC5B3s53qhXVq6oDNg6sOhqvqhEr3V2VNLBjmnSSNdrOLJ1zkAu6VPRjFcFz4fXDJ8i45hG94Gt3IGjOFYA8TTlQZ/qGH1oP1+8ZtlT1MAtHK8mQg25zOZUSCLIliWcbw8wfW5Ln04ssqnHX04euiCk6/3de66MPpuAQVZAEFkw2MKFw6a1wEL4+lSBvmAOMhD8vkOkFX77feLNw14YT/ssmc4A6oOdHBEkwXlgjH2k4Nal6wB4fIuX9LzZjAmorNeHMo5Tc0OewHwDTUh9HXxfGJsYkAbAAAgAElEQVS/uvCpoAcew6zBBrdyBlQwwoDxdLZWXLDFkHyF8xGE/fb7xR8XXByAAVC1oB18HQYIT+8uGfP75SCUs1o64he8v4j6cIQ+IqkPhxrBCHjdjBH6AblQkAeY1ondukSiELmsUPpjbyp7XuvDgAXxdNZVvWCLIfmKg6Bbhrjup98v3lVwcQLw8gqA5v9zC9jErutltg8gMxDWWMBaMVkmANWFyEV6R0uH2I1IzW7ypbkQOTP5f2ch9KsFkwp0kQlDAOmxzHpscGuGAQvi6VD4RgmAg/b7xZVlT5MATNXwqQc6KGwf2U2uGV2uzg3D4ua7fDnPwZcKgIdq9GaIBPZb0YdD7hgyIFWMXiH0eQ5vXS5HcMkc++9lz2t9GLAgns7KxxZsCkgdtN8vWD+vYDMAUpcja7lOR9eLVcIP4tcuob/3AOHCdW02VTX62ApB4Mv1v24gnPy9HiH03fJ366KYHYTHsgBBg1s5AxbG0+HLZaOp65i+ln6/YM5EwdYBwGj1cmUkE7+8THLNdAHhwrUOXtcrO/pwhF4cct2oN68BMDCfmsJM/n6PEPoYPp8bH3kCkbtjji2tJJA962YAWBBPZ0WBCrbYsFoOf9pDAiENk179fkuvf9nTXewKcBSjsn7ldonWbgQpx+26otaLIwAlfi2QQSJY3Yjy5i9dmsFM/oEDMM/Z7Uf0RiYUA7J+ToNbOQC3e0WBBm9qLad6HICG1ZK1XB5PoxnuOOIcxSXe/Of8xHV/P+FpwN47gKUpYHmuSve0pKZgCKSq5wqniWE1WZz/xouBm74KTMwBI17lVBXwtWSs+8/vL45Ff3vhpcAnvwos8d48DZX3M2hx9XIAnu0IIO0chu35AOgLL0yuG/jOmwbg028G/mNz1YWdETbm4I5BrFlov+EtD2wIo7l+Atg8D2xY7iw3V5diEqO54mnj6XdMAYcU+6gon7A3NSO2qFjlyZYDkAX6uD5Iam44YaUfVNDNxaJcLIPXcGGpfi6PnZdVD1wPspQBX/wl4OaNwN6Jqg+xwrxslcVFuYJblehkcYYZGPS3L20BxueBcS8nwg5H5kZkx6TQSbXFZcCQKadx5Cz5mPurAFxrRaa17pAR2PFC+ElSHKQ/0QjQcgCyGyM9v3SnsDBRJgL6msWCf6IfWeUJac8UFlpY8500DcCfvgb43hiwZwyYVhd2D/VSrKGAmIDnBkiafEcN9cprHgKMzgNjS1V7rRjRlceyrqif6KAkMgXIM+6tAnDl+zSL36O9+U8p9jGHQo285/2XA/AnXeNnKAorDXH/AILwbSvLEz6Ql2+cAf/3XcCdw8DkKHBwpOpFbE2wadzIdyh3jjNQirYWEwYq+/zJwMh8pf+xKNSwM6DZMmzNRRbM2K+2Ii6TlFrAWfd5V3i/F7IgT2LBF5LbIdkqxLPWvtzlAGQ3RpU3Y7AiixMxLOUB2t7pKQ8M0qCTnp8HkojJgNqaMEJesQv4AR3Iw8DB4QqAs+6SWRiqgJgY0HVDAdBA4Ba4xN7ndlSFAAjAYX4IPO5dBDMAdS2i+Jx7XTf1eEdTDfgAQnR34p/wQkRmjNAoByDT/ugFphXAmjAEn8qaPQAgZCs0lSckCNmVigEbFMsPBBE3DcBX7gLuawH7hoAD7EM8DMw48AhATrjtQwiXoqkTEwWd7LOneXNCbz6Tiq/TInb2M8ZzIFrTQbGiy92oGz7pXl/7jvdAJnb2470IbB3T77Sai+hyAP5voTqW6sKwFAc/TAdc5+3dvcsTrvPVYSK4SQb8xV3+6IaAqSHg0FDVh3iOIFTIFxtit9orL5Z/LD1Q4s+B8OnHVuXwhhdd5DoLGsgCCJ04q66X/Ju/vSaeAxDPvbdtmdtKDV90gVEPIl/xySkviOhmAEjrlzSkwj40SlQZYZ39I+8JBMx8mZryhOsKwqYB+KpdVSDFvhYwPVR9BD7uyX4SwRS59nNI+bRck/DzJ05v12M0nY8fAk8iWL5BB5qASPGRCi8EVjzv3mqpkC9ACrrwhKukB67GhpqRRowQMqCiYbj8oOoHeUWpdYIBAUj8c8WjrjyhNIJ1unzjDPjqXdUjJAAP8TMEzLYq9uOHICQALe/EwWe+QgddAqCzzD8+vgIgg0qp+5nYjaDzCgjmnCYone0klqP4JSgvvK+6LoFPoFMlkPGh+0rPWta4RHTNJJQz4M8EAGoNTPVU8opS64CC9zoAWTFChcq7lCdch6s3L4J/2QFIEBKA1P9mHIBmhPh3Ai354RyAAmWsR/PRs6vOR8Z8FMPS97yxtIlYgVB/I7jC0rIKSfLXF1EEB+BFFjQ3jCLA49OWsRTTEPzvzQEwry7VrZ5KwzAQAPssT9jw1dcHgCrORQCS/bgn+1HsCYQSveaHkzvGv1scgU/6R55Y1YIxhvOm1EZekQWl8wVDxJgwc88QiJc6AKX/meHDawX9z16M/Em7bO8Q08GBP/jEkAEVjMBoAFWXUjRA3KtNwOBXW3EkAZhrALktpC6lKtTV4OU7RHB+3kHWgv/zrnYZl2kCkF4uF8MGQGc+MqEYUCA0n1tkwxbw4ScHAHr71Q7W4++c8czwcBAmHVB/c7Bcek9b3FuwbdD/kjGWgzJjQ3thGmVA3jhfOyU+RxB6FamOFp8NrhsTgLy8Cpzm5QlVptAU+6CiNgXCaIQ0BcDYV8b0P4pi30vfIxD5+w72C9aliegW8MHzqrmh/meuFhYi0pKbs6D9fsh/n1XFMrYMbPgUByCZz6J+uEknDA9AornWFRb01WZEsACoHhOqyC7wdetT0QAK2KqOb5MCUvPyhLE0oQxzqaYNXL5xBvyVXe12vByLADjXAvgxBvSPGFGMIjCmJbEW8HfntxtQmxT0cmxp9UPAdKAZ1upA6EB7qgDo6oCUxXRtPVSpAwJpnUhuxAqWCCYK1MBExZljY5S8SYr+pxAFAuBayhNG26jw8usCQLX0SAAkwwcAEngyQizaXoziIli+Oe7/9kJvNk1LmBMe9ECO3XRB7aPeF0EYHNVPdT8gj016YBcWtBfBVYJuz7mF7VgGY/pO8f5WdQ1/7U67nIKNS7j0wIbDPFZsyNHHY7od/xdlEHj8CcC3TgCWHgGAPSxiSdt4312u/8SPAl8/Dlh4pDeZW2PD4J1c9+uyDaIDkgEJQKnTfG/N8nUAmu5HUnMW5ARbPfEuIHy/ACjRK7FL5pOR4RaxgTHofKl8r/S1ZWBnAGDKefbn3AFIPRPXB7sFiVQimKVgGdl5ooNwLQ1/1U+DQGSXQ9r5Evy1q9rZbP1lGQDZsPpzI8APHgXgod7qUx11YtBbFzC+/C+BL7SAWwhgdoLkONSLqy5oLogYft3ZI1F7EAC+phsAnekokhP4HIzml/PvthQWmPB9LJ7jxkcSr14jWj4/0wFlgJD5eoDw6fe4DzAYPHokWhHJZ3TFSkn4h7YOSOBwEtiMTv1aY0uktFYTmI2/43EMQmCuAJmUE0gmVD8EFdPpdnxhVhqzDr8F4NMtYM9Jfg98EVTeNu9Q2OFZBX7vr9vtgm/lcezczZ61ZNN8DCvilYCdPXqNDQpAlfGTKm0M6AA0PTAyoMSx64cRfPQHXsniOTI+fEWDFGp+Qb9BeySRBV2kpl0QxxGAlHDmkI56X6z+EP7UDYSdRgh/IouwIZ36lHabBE0GJ0r10Rgb/xA/tt/j/6aMAf+7R4CxzuBXWRGULwBfIrY6UNfpvLae7n0I+LO/reoLMqiVMbW38oUhkNkQIzZO7tIweGePcmWlAFTjAYHPVGwXxWoLYblEDkLuTT8MDPhXLJ4jALpaJB+ggU6xfgJknT7IKXIQXh4Y0FZCog+wxiUTwSkXUbSMV1rB/A31OXWuFpPUda/mRHKi1e6U+hA7Zq7l+A+UAfDtHg/LrptkQpZ727cRWOL9542Pa3rOvuOqagUltgtmJM08j4/PILbIDKz6w5PAHsbraTnMGdZWIwIzxIfeK0rn578J3LAVuH8CODRahV/FFQ/1IumIvXP1QudNfyNT8oVqcHviPcBd48A0g2RDuoDqHdb2SalZAdG9dnfDkAE0gXnH5ijWCDbKCq5/MRiV0QD8HgHQ63jG0hdsLGxA3x9Bw1Asli7hO3BwApgng/Gjvq01IHrXJ7q3Cz7E++YziF2rs1ZLZ+8H9jJsSoECWXj6igmR87aLgfbGq4GvbgLu2gjsHwdmCEIPSI1h+SkCRjpfUC3iNWcpoRrcnrYbuGsUOMBo7QBCxSTG/igxVcBIVGPWM1h1JYQPnyKNExGZMDIJ9b66eEBGxPDY1Y5nv+GCjfGAxD+DDpiawphABWZPjwNzNLAEIH4XCH0M7/5c93bBfI8Yk2cgVAdvdT10ifDkBWC/r9lGH51NhIsnsWHOfPmEUKT94WeAG8eAO8aAfWPAwVEHISNQlKQUglJjJExqC+H6Nq93kOpUg9szbwLuHa66QzFWkaFieXxi6hgVHOMCYGRuJ+5V4jYJIDKI9KlsAvFDq8QDrnb8NWVPh9EwdFkQ79TlSMIsN0Mi5s9MoOGno4U6f3YAvefL7Y7rvdoFLxOANSA8f7xSgWmd0kCQbmZ6mTLEnJ0UqWLhUkxlrBn6n3wWuGkYuGukCsufGq2iojnRFpafsU7MDxErJuZhYCsJosHtWTcBe1oeq+hxigJgXBrMmTBPnJKLrr+VED54ibHYvZos8sO+DNcrHrDX8YVVyglAKud0LtMjFPtNMz6QLDY7VomLJd671AEH4Xu+3g7nWq28ISvX58/hguOBg8vtFQvV/hEzxfqOevuTfpjri8vAWz8L3NYCfjBc6ZYHmBcitnFd06pxyb8W4gPlgonBqffTtdTg9pybqiVNBssyUsdUD7eGO9amnf3sXtxQipl7Wg/sD4A8AwHIyZMYky50Tp/xgN2OL8y051qw2hXzwRCEdT2nmck1RxHG+w5jeO9NFQBpR6ldMIMXlFWgVndqF2dVFsJzuOgRwMElB6DcI6rznemD0RnbwQiSRS3g7Z+tVIl7PC9kahiYZm6IizuLigliT/VoUog+p8P9l3wJ7qGEanB77k3VczroUToWLCsABud4ypaLCUoxf9i/9w9ADiICULrQRWuIB6w7nuZrwaZwLBGwClSqSyz3AhHbaRGEFGOmC44D72UVgjW2C2Z4lIF4ArjodODQcqUGqAxfcpG4mJVuVqcL5tbs2z/veV0tYK/nhTAqesYNHdO5PCJZos+WuzxHJIViuXFyJxupNLg976ZK2lizUKodilGUgzyGhokF8yw5Mf+qRkjdjfuDtwkkm7DTkNaBaQ2ox1q3eMD8+B6O3H6em8Kx1Ccx9ptWl9iYIUAAWrI3I3nHgPdOtsO5eOuxXXBdj0V1vOL/so3Cxef60tlSpYwveKf0pAu6ohfdJ8k4CUqgvr5jV6VGTBKALeCAh+VbZLTnh5gu6D44A6H8cVlkNK95O1WkBrfn31R5HSy+JCwPplAxRegE/2T+AloGncNmbQyogUQx/KwB4gHj8YWNTwRAOW0FIIIndoqNkTAxz/bd09XDGLBdMM6/pLKi5whAX60gCK2ujxzEAqGL2pQ1Jis5AJEAFHvTujYAKjRf+SEugm1d2COQLU/DAwQ44caEw8AtZzSIPgAvuKkdrWMM6M7xCMBoiBn4YpCE2NCfxWAA5MEuwvCCEICwlnhAHV+YORfDsWJGgPpMKwg1b9QpFnzHbD2BK2JGul9s8KkYW17vLALQRTCBpzXZpS4gtCXXMAkduuAy8E7PijPWprXJ5CR38ygw1fJDohh2BlRAgq2OeN7uTWc1D0AFNtmL54ESBsCaJcLkDajxj5ZXRiCIGA0waDwgjy8sk5+HY+X9ppUbJSCp6TnFCMXwny1WAFQ8rUAc2wUrRL6mXTAefWnFfnz3FpbagQKLAqAzoZjAKkkpXkNO5GCEvOMLFXOnnC4xIKOjnQGNdWSM+GqHQGd7JSsxUf+JzQLwhTdV4je1nQvr1MkPGtlf9yP2Dy+gAqZ6rQytfvdHSDxgLwBF8AmAYjHWluEDiKGMiqOVvtejXTBOuRSYJwDJAARgZAGWL9Nk+IM3SzgTydE4eec1nZHbtDaNAf1Dpd/SMx2END6kD0oXtFhBXmcY+OY6AFChnKnzl7NfdMR3qCAae2B+VVMYXASvDs3/X/zHJZcB84vuiqABEo0QPnhnwqQLyRURmZBPytnwHde0M1vN2lR6picoKULaxHDIEdHkW2iWg4/7b5zb7DSQAVd0/griV2JYojfpwRGEYsGBrOBmx/OgP5sAKANkcbFzNWTRnX/GSGImMYH/LYlk+gGvdT+bW+SWH+Ig1GqL5QeTtR2EYj5LVHfjw/ZDwL8yJ6TB7UU3VVoTjTYxYDK+Ivv7dzNAZIxpZSiU8jjKgIWTcykZkBawDBBnQdMr5QeTKI5iWCB09AmEb7+ucnOQ/aTPWn6wuzyS4u+R0Ob6CUGqJpIDA97AdqINbgRgBJ69CG4Jp6q/ckjXqB/RKla4WpkO2ODgHoynigA0JiLwaNiEt95YQKJ4FRC+7brKzRH9jZbN6iJYuSHm9I5iOAOhHNJfZkh+gxsBKPbLu3+JgaWDdojhMO5kkDWSlNTg4B6MpyIAjf3IggJgMD4MCARjFMU9QCgAykhSKnUCYHB9JB0wy5aTRUxmup4h+Q1uAmDs+hpXgFLnB6ULONOn5xACNJqxghsc3IPxVBGAiQG9aLeilWUJW1FvVXEN0TKp1C6At19TMSCBpz1dHtT/JH7N9yaxp6QkF73KBxYIr10nAMproB44qQGTj6sjUrtOFPtLeFQHLES9AdDFrq1E6M13MaxVCTNAXNFThIylLcor40zxtgDAPKuVwDMrOKw+SBTbtR2MND7sZwC7Qvm4wqHa4T/uIrhb+7n0EgbQdTijoyg+agWXT8llDsAFWr/B8qP1K7bT0pvtVwHhW6+t2C/m8svvZlawi2CKe37nhFtapkDnILRqBQA+v04AjMyn79EIkXO/DnzyCBwVweX4wxs9B4rRZgyPVFqykgDd+5JSpBU5r0vHyHz+jsc3ub0KABsZMCyQgeExKyFPVIz3lmcM6OfPAGCADYPE67Jfs6h7G0o+xvi7oyK4cLZfOgpsXwC2Lq9MwuuVERonKn4nSJrcXnQKcM7dwMMXgYcsVxkSebJgzOWPqdB1ad2f3gpsnwK2LXWeR9m3danUIV1lBSCPArBwtp+7DThuBti6UDWDmWA/DvXk8LRptfPtNUlihYZTOPCi04GH3wFsnwGOW6iAs5n3GeJJ+KLoE+9VDClQ8R6vOQHYegDYwuY3S6H/iJ8jb11ck0q9Qhoc9QMWgPBZJwFbpoFN88DGRWBiqQIgWyJY3lPozaGJ1KTEPh36zpTkJrcXPRE44S7g+Cng2DlgyyKwaclfFoIwvCwx9Zn3Q1DmIPx/2/sSaMuusszvjfXq1ZRUElJkKsBEGQyYhJCBSkUqAW1tsBdpuxEVaBzowXZqe1g90G2LotjQdmMjKqtBxQERdAWUAkUlZNBGkQRNyIAEMAkxpFKpqjfUG3t9//m/c/+737njPq9uVeqcte66b7jnnn32/s6///3v//++Tz0dmD0KzC4DM6vAFpd/0L3Gh6yTDgnvLwKzAWDGiH/ThcC2OWDrErB1pRgQisIQhAa+AED+HEEY6uNLyrRnZLSl6tSbrgLOeBQ44yiw8ziwfaV4UGbdegmA5QMTLFlqsfn7XecDW+eAmePAltXiXnkuZSBkRcm4UGXtU2uo3xsAZgz6y54JzMwDWzkgBOAqMMVBCSAUObh8QuN/CiTgcWAuyWhL1amvvBbY+VgxbW477paa7gIBqCnUrbUBiQuhAKDUot13IbBlDtiyBEyvtO5VDxvvVfxW/JkWNFrCeK8NAGsY7BsvKQC4hQCkJNaKy2LRIsg6SJ3IQSe1onKKC2CsOYMeN+0Dtj0ObDsGbFsEZmWp5S74g2Ir2uA22BScAJGA+dJFwPQ8ML0ETAUAkgDTPq9zdK/+sMWpPF19NxYwA4g3PtsHxAE4SQC6FdSgmGWRRIJLZJll8EGKjHiX1jwaN10HzD4BbD0GzC4WrsKMW2pNobZoCu6CLCDfCTqzgg6sr+wFphaAKQfgZHKvpRSYg7HN5XCL2AbAZwPrZGaj6ippXhgn0kqmU1woxnHedg5AATuWHig2FE1uVRwoxoX+Wcbg89S3AqCKPONcCi8oPtVP+9++G3j+oSK2xRBFDElUxbTS+3nvc4FpDsjxllXQoJg8FgdCQoGJJTTicLcQ6vPL6wbg9cDM4cJv27oAzFA5ky9/UOSvmg8oP86n0dICBn25JwjARWDSAUgBHN6vfdbv10AbARh8X91vDM2ss+NvAECKPVLCsHoyUgRqrlbnRwB933OBc+4DXrIC0IEmiLnE75di8HsyAcjzWUVGUi6uICMpVwwJVMXdeOk3XAxc+Hng+vV2esAYw+sWoP31r3eLcLwQBeQUrEHh4Jo2h4vDmJPuAyMLGAeEn7uqbgB+I7DlSWBGCwe31Gb9aL20kGDb/EGRxY6WTz8f2wtM8l4pgL1SgM8esHCvsuylME4nn9cfQLtldg6TZ0kUKorAfij23vAPCmqp3fcCl60XFINid1PlZrf41/dnApB6wSQjutUfIDJR8CGIQOwWEH7DywpKrWc8CFzqRLHkVYrB2jS2FQH5vkuBycXCAlIUUAAkCM2iRBA6+ARCe7DjYmQduLYTleiQ/XTTS4DpI+6nLhZW2nzVCEBaMLd+soIGqjD1ampdugiYWCpeBKA9bBJC9ActAk8LES26SqsftInLZ44dQif4Igdhym5WLrPDyuYH/7HTCNwDnPko8LXrBccjQaioe6BiKad3+QY/MGTH6rS3OBvCnQDuAIyqhiDkQ9RX+29yE3on8IwjxQPI8zkTiApGU3oVkD/4fGDieAuAdMw5MFQjEgg1DYsUku+a3uI0TGBfV7PotwHwaOEmbHEATvuDIutni6UAQoFRIFRYhfe/dhEw7tbe9Of0Si1g8HkrwRcevDajz07gIJ7n05rYyWIpb4ya/7vv8PRdFpj/LXDmkQLAnA4jCCOlTBRN/rFMAJKgkkVHpGUjySSBSFeg7/azqk8EgbSEq8UDRACLKDXSyaQ7Br//DcA4LSCtwnKhTEkQcmAIQhtM+Uaajl0uS9NatITXWzpzfcdNB4DpY+6nBgDaCtanYLN6fCj4u1ay0QIqtML/EYC61wSA9tAJeP6eWsAoDysFpg1eB0HIQRCIIkVeCqQf/05P3WCB+UPA+CPAzvmCaFWDKEuYcl1yMN+Y2dckqGTeHPEvvWDSNhOAfbefX0A6rS8CUw8X9066bFIfdqMHJID++DJgLACQumyc3gyAEYRRKFCLD1eu5ODLF6QvXedx0w3A1BwwxdAJLTXjd8seQnGrZ9bPFxLyA7WIKON63tYtCQBN/sv9QPm6BkLp0vl9t/m6ietR6fbyBA4gnXtORwRRpNnTtPpW6gWLH83lKqcOFTEnDiKtoHwy8RNFhrefyeztbnrBfbWfgttsP+kIyO32ELD1cHHvInrlvWs6TsnB7qAUlg/suFtAWkE55zYQ0QpqcALoNCXTEt7A3KoaDwGQfqoAOEUBa7fUbKctltwCajVbxvSiyvoasM0BaBKwwdKb9fN7NfcqBWGiSWykWXER0umeacUEonQgCKRfIgDFjya5yq8Wfsfs8dYgiuMxgpAg/vnMzu6mF0z6Zj5APdvPQec0TEosnvQosGOhaLuIYvnwEYSithE52F1XFAA0p5yigD4otCqygFKnpHUpLYP0OcKURYv6Mj4MNR433QhM0gL6QongawOg+6rl9CswKoSkEIxPyTsuAPigCYBmAXVfYcVf+n0SRYw6dP1YwNgHsgSajiJP429RrpWOM6cxDiJB6NINM4w7LbUGMQUwB/M9mZ3dSy+YVG0EoBiDBST5ddZ+PkCsAiIlQZDa3LVatJ0WXG2PbL98AB+4omB3oP/HgTUhmGgBfRqWf2TTrUSjExDSP/qWzQDgfAFAWyzR8rkFtDAKX75jo6nUguZxZ8NByHbvvqBQ36T1swcsBaBAGGRg40Ir+rt9WUDhQ5ZAU7Es2e9LLzglqHRxNkbeuW+oQRRls5jaMjnK0a9ecNf2R4LAwO829kQB3LTtEYQPUwzQAWgW0AGo8AQH0ljp/V17pm0KRcEifGuNOnocO1rACQbKPXhs8TtNwVr5uh+n6Zf3wDgu29g2FdMtOc8B6PdpFj08ZFrplw+ZA5FTvAQQ0/BT36FPDkRqBT9Jag7xYlQItY0f88j78sZzCcKPZlrAQfSCK9uvB4h577SCotUiEJ8opq8IQFl/PUBPEoBLxbRE62LSqG4dFB8r5bHcOtiOQSqT5T7RKzYDgJx+BUCCTxZQCwhaQc9oKcEnEBKknj5FsJ1LAPo9xoWWPWDy+6IIoqbeaO0VA+zHB0zxIQDKkn1GgtXiRxMIAx0Vn0Db+lkuFjLRCt5WEwD71Qvu2H5OfekD5FaciQay/GIbFgBXriwAyGmJADR1ck3DwTE3TQ4B0LetzBJErTYAr2BBSI3HTS8tLKBZPo/fWQDZp197Z3scjGb5BDp/L3+njMweB6B83Gj9wj3atOsPWin9WgXCFlVO/3ctf4iD8XkBkH5USlAZlNPZAQqARr5vxu1yjmH0givbX0UQKI63o0Wun/xHuR8E4VnPK5JQLd4VNttTBvK2uoiKOUf/f+GjwMNBh0NMV6J0c0NpcRv7mrYv3kh8/uHxYp+bVpwLp3R7sts2YzouSq3KGa+q7+x7Co4nazAerRKsVlV1QitF59dyyFZaYY0HMu9mWL3gtvZXMbymBIFMZ1ov2h0B+LTLisxgW+Eq5uU92iZ72ud9vvR+4JFp4NjkRh2ONi0OB1/UBCkvEYRhfuNs4OmhhiPKnFQlx6aAjMnSXJUAACAASURBVPjmz1w41nnwO4cCIBvBwZgTAOUHRq3gyDExD4zRGVYEnpm5LqmQc0M5esFt7acFl0SlHiBxuTkYxxdaihUC4QVXFu5FCUD5QtJl85sjGA0ziQxqeu/fem+hw0F2fLLQGxFlYMRvo7v1WmIVtpt1DFkXvOR7LwJ2HSkyoZmEypoVVe8p7b6qEMnidGG/Vl/L2aPOIwuA1pAIQE3DAmFa4j9f7CPaFpCHKujr5xzZesGdHqAqKz5X+FLRAl58le+jui+kTBALMcgZ73CDBkpN2/7+bfcWOhwUyCEAjQTcAVhKdjkPc2RajewKyu/n1//qJcA2uhBMRGXQOcn9U6JIOjXHQqSYOsVoQp1HNgAvz8yny80H5PVz9H6RqVd849WtXQ/zA0Ow2ayGLJ474L0G79vvbulwkJi8BGCg4S01SKqofoNvSIC+5zkhFUupV8rUTpJN06KpaBkFQm5M1HlkA3AyM5/u9Zl38zrk6f0iU6/4hmscgK5ISUtCTowyDqb7UxwsqFJW3fo/vbuIBJEZ1YRgyHwQKNi0KEl1OKTCZJdxtPDn//v8ooaDaVgqFyiTD2IKfcjZS4Fo+7g+HXOPv84jG4DIzKfLzQf8KVfI/FNKrQ6h94tfz+vOA9cGAAbrpylY2SDlVTTt+uCnV3/V3a7DQQAysJAwobZJgUXi78Qayhd812WeiOAZzEyUiAkHMeu5BF5FwZQAWLPwknkLQy9CrPMy8+lIHZFzvN3T+YbV+8X7c64OHHix74V6zIxB+RJ0wQ+UU992tYoFy3fcXcTDxQkoPsCUhFIczKVCegSg5B8A/PILN9ZwxBSxtiKiUAOi7JW0dLTustF8AGbm0/1o3vjjnSGdj+lYlGwdRO8XN+c1wABIoHk6k61yuSCJITq3jDY9Vx0BqK++uwAfX6JkI/hME0SC1EGguiQ+isqcQRLrF6/0jO2w+6FMnZhyZYsQ1W50qOHgPX1NXndtODsfgMwHzMin+0+ZN0S9YOllMzWfLwKQSS396P3iY3kNOLDPM1y065H4gOW3p4uTDkB8zWdb7FgbdDhEgJkCUDRvogTmd/vPv3BVAUBuvylNzAAYi4hisVQnEHoIqWblrxqm4Mx8ujfljT+YjsWBYgIOc0oJPsq1slCpH71fKybJOEoAuuVTRSCnYlmU6P/Z4iSJEcbLv+Yu9/1EAh7JKEXDKxq4ChUiKymRbwjgHdcUWTARgLYXHSr2LOU+BV7MVwzxwOfkOWybYAGZD5iRT0edjpxD6VhcOQ6j94tP51wdOHBdMeXa9OqWRcmWXA1XLUIUH6zyCwlAs3z+YBkfs1u+VIejJEF3ckrjI9T0y/aMA2+/tgAg08VURKT8vbKMUgAMIGzzAcOi5HknHQAz8+l+MW/829KxhtH7tTz+jIMAJPCYMULAWd6fvi+EY9ouoZBM/Kx/4LUBgFLgNC5o16FrE8JJVJgkiFhaQQBv3+dVbMrWVsC8UxFRkjjaVsW2DtRdOJ/vAyohVYK7A+bTvTdj8HlqTMcaRu/XxHkzjgNkIOWuDr8jnYYDKDutgpUhra0uAlAyCCUAK8BXcjBXgLCk/h0D/hcByDxFAdAzoFUqUBYRJTUcMWdPP7ONL6i5bLQeALJRQ+bT/W7G4AuAOXq/lsGdcRgAY+glLkYclJVTsa6ptCX3uQjAKINQstFrAZKIwWxQIhIJuovB/Nx+r2LzFCwlj8Y0evl/MYk0kieVtcvrwGUnHQCVjjVkPl3mItQsIPuElx9G79dOzDgMgGkAWlNyBJn8xKprBRC+zgEo4LWRgcdVcOCjjlNvmx84DrzNAahaFZWLygKWxUNibIhTcPD9BMLLa65bzreAMSGVoXvJ/Cgh1WUfO+XTZS5CDYDs9GH1fnOrIDcAkABTTDCCLYK0Cwi/586WcKJUiEpC8CCBYDsiiSplqUIUmOjf+o2tIiKVUJbgU5uSWl4DWwX4+PcXnrQATBNS+8yny1yEopdcay+930y5YhgAg+9n2OoUeI5TdQer+32fdhmGoOBZanBo+g1yEKU4dYgFSvqB//vZBIBt9RshkTbW8ZZZ2hUgvDL3iU3uux4LSBM0ZD7dPRnTH08VAIfV+2XAOucQAMuVcKfFSD/+IAABsEoGwYAoHZIKEEYxRIHwLS8pUuhjFVs6/ZZhIVWyxVKBBIRXnbQATBNS+8ynI4tBzkEACv+chlUVIKE/5cRGsWmlKfIzudc3APLQSlg3E2OCyVRc1kpU3DgBmKoQsWtlBcswjPu+nfTYtBL+GQdgOf16GCZW6pXlBCqWSgqJypoOAFfXXDifbwFJLvi5HAjlnUsiIe6AjOp4iQNQHRlT2PlgJCUbbc2s+v/hFwFb/q7gm6HlYpBbmTV2sscQyy/qFBj2v0/cAdz/HGD7NDA1AUyOOU+1CwWOewNjKj6/O03F1/WuugW4/XJgfBoYmwDGdH7IxB5kLPIB+I8AfNwZgga5ck2fJbEm8V9zNWPfrasbgMuPAcuseJ8Exsb9FdBhA+7gaQNKB6TfcgCYug+YJT+g89aoBDMmIMScP12uTKj13uDv8zsKig/uJ1uQOsnojm3qB5P5ACRBH3OhPuzzRN9DV88HqQLEWPJnvTy5nm/t/1s4BcuSpRZtGAu4fi+wtBVYEyccrYwn6hF8/FkJp9bKxAKVFsn/d8urgbHPA9NPOEOWl4+2cfoFHhfVrJTZPKHSj5daOtup6JyCpPx8rHWRVQ7WOlrYCMx8AHIzlxkALPD9c0VB+x/A3E/+E2fUYHXdF7KTGwdvTd0AHP9r4PgWYG0KWBdfsBdsMPfPrKKsoL9XAVLAvO2fFylCE4cKliyrDVZNcGS1CqEYhWFiAZV+XntaURdTLmpCEbpchTYLqi6NrkMCzLzt5Xc4HwyJmmkJ+Z73jQOh4NWeDUZiK1K08f0EXt7CMHVawIk7gaVpYJUA9LI1Ao8bzKX1cytoFtFfpdCIWz7rgzHgth8u0oPGDwETc8CEMySUzFaikgtlpW1Ta8JqNba7lVljSRgW+Q6ZP/57WQvj6fydBjXfAjKbgEvMLwWCvhNoipgNpnQshlS4IGFWzIk6ylWwAz93ETLxGWB5ClidLABoIOS7pmGfG+33YAG5mND0G8F4678vkiPJczNOAC4UyQm2N8w94kirFlfIAl7i402d6dbPWWAtrsjOFiuCvAJZOQE0pHTFsckHYDeCvhNgipQNxoAz8/8IPr5nbvH2jd+6AThJAE4AqwTdZKEBLDoDgU4+YVkPHIBoPwareOt/BkDexsMFAFnbzNJYm0IDnVwbt4uyur1kwL7Tp+iZM/08WT9Rc7DHUmuYTr/x+6o4ovvu9fjBbgR9JyA+omwwxvZI5ULg6ZW7y9FPf9QNwKm/CgCcKABovh8ByVy/UCtJq2f+X1yYJPGU27lIZLbuEWDsWBHesZeDz4iURLUWa1TE47LqK12fZmd3OXidFctqm92KatVs1jAEsNv6sdymaa2g8+xUL4I+Pn2beCgbLGWHI/h8G3oTr45iK86POlbBU9yKI/AcfLR+ouQwH9BfmmbLlTHboOnZ/T9+5vaf8FUaAThXsFOQ45mUcgZCWTAxe0UQ+urYMO1/37GtxQmoLCBtRSp30LrDp2SFdzYMgk/R+VNwvwR9mwQDsaspGSfJgYDYNTbp8psCQFJxEIBkQjDrxt8dXCUIY+COH5MVFPi8SOn2n/QYLZ9Gp0cxANIP5IvAkzVzxivRydnKNzBa8fddM84b6AFyAriMF2pajk9kYIeoClXmA3AQgr5NQEHMBqMVFMNaIOayNRL/vhlH3RZwmhbQQUcAasrVVGz4EtjCu/3dfb/ID3PbT7uKAZ/MhcIC0vqRTo4W0IBIEAmEtFwCYqjW03bcmdwBYeoWgetUbrR8snrloiR2drpACf+rD4D9EvTVjIJu7HBV+781X752Czj9lwUZkTEgcPoNPp5Nv4oBRhCG6dd+1DkMz1JIhR1BAHJ7zwqO3fIRRM5tmDK5CoQKsSgOeBYBKFZULTqcB9r6Ni5KYmd3WKDUA0BlhNLM8EbT1QBXBU72aI5ZjUcVOxz7WLkQ8d37vsart/uA6RcPsxNSAtAXHDYNC1AEpf9s01kKwuBwGU7HgVt/1jtD1e60fgQigSe/j5bQp+KYpGB+H62jT7P8/ZypBIC8Dhcx8eY9wF015abhmnoAyJ5WSrKeNgKO9SHxnT/LSasJBim5lRjWBEIVeROInKL1qunybRawLgASdEy74qjaNNzJCgqEEYzBGvK0297mAFSHEIB6ebKDgc8J1ksmV8t29f1en6L5v6cxIK5iK6Xne/5jCTiFcTqVn/r/tWDPWwXnEPTVgIKUHU7ljASawKefIwDpMdRxRB+wFgD+RREDJABpwSzz2c0LfxczVjkVKwaYgtBBezu3SvX08d39P5uO3QKahXMQciourZRAGKZWar/YZ1xXRPe8wQr2AUK7TvbOVTZBXx4MBECRnConUBSFEXT6mf/TK+/qmzAF/0UBOPqBZYF52HrTFCw2LH5G8UCzJEko5nZqmRnPh/uCXmpnVpDTsIPPwKApOaSA2QLDLSHf97iPx0tpISLfz7bl4iFfsUsnj+HZWEeOYDCDnDmCvZkEgedcCjxGseIhBYt3vx049HwMLRh8gA9gh2MoH9ABqKJzxf0McO7XlSAU4HzhYYFq+5D7hwBu/98OQLlIBCKnW39SlXNY+nqeiq2dkQg+gnGPb9/ZpT0lq6MV5D96gLCwgDmCwbdnCvZmCgY/dxy47xxg5SWuUjigYPHFbwA+fyGwfr2rXrMvPB+vp3L3GHCgi9JOHQCkRVPppeUBigXLFymyejYTB4YsgfA20ofRAlYB0FfAlvQqP0/TsX5PLOB5DNu471cmIwiBaRww/F01J+mz2pqChxUMZvpJlmBv3iTocsW4dzewfhkGFix+2febXDAeJO/YEILBB7pU1g8LQFo98QASVGYNQ6DZfEG3fnEqrgLhbf/HV15anbkFNCvohWSl9XPQ2XTM/2s3I4DwPIZwBEDfgitH0Ek6N6x+u/iD7T4g/YdBBYPpWHEaHlqwNw+AQa4Yj54JrJO+aQDB4pt+oCAyYvOPEIQDCgYfeF/9U3AbAMX7ItAlVtAspKZdz5SOlvA2pstxjES3wJ+92NgAGK2gwi78QoVfEhBeQACqNNP1RdoA18kKdgDhxkUI/zKIYDCnqyzB3jwAJnLFOEIW7QEEi1/1Y21ywVglCAcQDD5/Efj7M4CVrZ5AKlkhxeQUaxBI4nvFzxf8IfCVC4HV7cC6ZEX5nen3VX1vAGLZq8ysrvHY+QBwbGfI2E6JpLvdX+ksthpUvQrmX/sVDGZVUJZgb17vJHLFeGQcmCdVb5+Cxd/5xjZ6QzzMLOQBBIOfTV2Ps4HFHQ7CLQUQmUrV0rgKJMsCjsxGAqTn/hzw0EXA4tnAyg5gbTYBorKkUyLnkB9YVhTxu+kT13iccwtwdBewPAus+b2ar9xJAafqfgMQO4dh+J9+BHe5gqZZZzYok1JJUcpaR6bp93P+W/N6p0KuGIemgEWKgPQhWPxdP7NBLhiHKYHUp2DwpZ8rLOD8tmJQVplOLxAqmbRKC6EDYC7/CeCRPcCx3cDSrsISrs04CPm9ArZk55UvKAspYLqPaPdR4/H0g8DRHcDyVr/X6VabLHk2PhjpPVZY7d5xwF6CwS9y/4LbbVyQsEKIufGiKe0p2JvXOx3kinF0GjhOQY+oNRtljji9TQPf/fOV9IZY4Gq4D8Hgy/4W+Oo2YG5bUUy04vUcLCqSJVRWszJbNgxSmMau+q/Ao2cBR88EjtOqbgNWWaTkIFz3YiWrF4nAjtN0nBZrJnU+/8PA3CxwfMYB6LUra3oglL0tps6wlVha5rLiqd9AdDfB4Je6U0s/0BXTDYh80Sr2FOzNA2AXuWIszABL1JaKWq1R+nwGeM17OsoFY5XTVw/B4Cv+Djg0C8xvLYqJCECzgsxmZlq9T8e0XGUyaUizavPtxoFr/zvw2BnA0Z3A8e2FVV3x6c4sqwObckeyhiXAowUSADhD1XhceDMwx37lvU4XxVN2n3rJIocygkr/Vbs7fe+EdBLcfaXXQ3IPWIrpBB6XlnwpR76jYG9e7/SQKzarxM7qJFj8mg8UarMV9IZ4gvNDD8HgKx8HDs8A8zMFAFnPYQPDl0Co2g4fpDZLqKCxT0/7fhJ4fCdwbFvhRiwRgJruCOwUgCpeCvUjZmEFxhfk9W969kW/B8xvKQqnVgg+B6CB0MsI7P70AHgmd2n1NQ0rv7FvALIlVYK73MnQCDLThSGZoDpuP7uCeuX5n8zroB5yxThGnQ0CgyBMxY63Aq/5aBHG6EBviDlOLV0Eg1+0AByZLgbl+HRxnZXJoqqttA4ODovlJZVuSjTQFtq+NwNPbHMAzramdVpVs6wEoPtdNg37wJfvsYiJP9NFqvHY+7vAwjSwxAeNxVO8T6aNVRRRlT6hHrJ0Ovaw0WDJCKng7g86APvNB9wg2JvXO33IFWOBgn8EIf2nRLD4tbe1+AU7yAWbZeskGHwVdd2mgAUCcNKnJgLQrZ/V9/Jnn5JUYmnAE3hCmv3+t8AWQfSzyPK/POOgJgDdsgqA5nfJAvLdLV+bz0kK4RqPZ3wQWJxyAPqDVhZQyQr7gyaXI9axWCFVAGLvRUhV46PgLnUWBs0HbBPszeudPuWKsTRZAJDTo8l8ui/42juL5veQC7ZpsEow+OrZQlqVVuH4FLA8WVyDAOTAmHUQCAWQkOlsQAwDt/9/AE8SgPQpNa07+AhAA6HLXbb5Xr4IaAMfv/eGvP5NzyYA7UGjBWTWjh40v9fSyscHLtaxhJWxFVsNNAXH1khw983+DYPmA5aCvXkdNIBccemfceooAfhAAcA+6A2xLuAGucxrzgKOMexDfV9OwbS2BB/BEoqLSrBoYGgJ3E8qLcIEsP/ngCPuUy7S13L3wb6PU56/m/Xj4Ps0TKCXQA6AXuNeZY3HMz5QANAeND1kwcKXlj6wOZQ+b7R+Pi0PD0DeFAfk590CKg8qncfoFzIRVWVqfFfBhgn25vXOAHLFWCDbvPstBsJZ4LUPt+jdesgFg+qVptWq11bg2gtgfuLiRAAgQeg+oEmsOujsXb5SsAoCIN/3vx04OlNM6Yv0tdx1MKvK7/TFjVmeCD4HQQQhf159eV7/pmc/kwCcKABoeYvR0oept7SEoZQ0Tr1lPuPQFlAtO0nyAcWhpzw/FSjFzGjLx+RGvxzoSeC1hwsA9klvaFN5FAy+9mJgnhaQ0qqagglADo4c9AhCDpJPl5ZommQ8738HcGw6AJBW1VecZv0cePwOY0/wl1lAD/WUCx0mMlDLr8bjmb+Dwp3x4nkDYbD0thIO5aNtfmDi/xGEeRawxhs7Vb/q2huABQJwAlhyy2cC0xoggjAAUCWWAkksOiIY978TmOOqeqqwqAx3WGhHK06n7TDwOcAV/iipPAKjwgrZm2o8nkUA0gKmAHTrp+o9MTrEYvq44o9pZIOtgmu8mafCV72YAKT/RwAy5OPOuVlAAk9Oule6xQRTWUKlWtkU/IvAHAHti5oIwDK841ZPFtCmdr0U8PaC9hVultd4CIC8P2Ztt/m5/qC11TJXlJDGGpfGAmYODgFoCxACkLpuWh3KCgqE8gNVZK4KtxgjJAB/2X1Krao1rfN7CWZf3LSBT4uAEIyWBVpipL7GgwA0AW25GbGENBTRx3rm1M2w39mmrFVwjTd1Kn+VAZALEE5LtIDyMWUBvbLNLGHgd5H/V07BDp7r3uU+Jadgn3ptxekA5MBri0/Wp4wzBjDbCnkMWMqVpE8GJwLQqvfc0pqbkVj5aNk7gbCxgJno30cAjntowtXNaZ1suvSKNhsYTcVKmw9F5xGE+94dfEoP+JYhD/8OC8eIPUsUHokVVKB78XszbzAF4Pvd//PCKVGIpOAr78mn4DZOm8YC1jco+w6EFTDDPJqeCEBZBa5GffVbhmQ8DtZW5TYOvPhXip0GTuu22lTMLSw+aAVl9QhEWjurI/aQiLJkTMLsX9R3r/ymZ73fp1+37OU9hunXSkdl7T3QrhKCtlCM59k2i5CMMSIAGdqxEIwrmptzTsCEut5yilKoJLAcxCq3fe8tLCDBFwO+tKjyuxSCMdYEXoeDrHcHvu0tTwLzmwHA4N/Gh6zNCqqeOSxC2lb8tQSiMwbuqXIqAcjFh2JjBKGJyShQG6ygVbfJegULWBYcMR3rvb6oCRaQwFPgl1M5rR7/JtBZOIZWx/0+s4QeY5z/1/X2tFnAxPpFELaVkdLN8MWGVr4pCBsfMHN8bmTKfCjZ0Ncp456/x58zLzfw6Qf3ABd8pUgEYmqk5bGyek06IQl1bkXScnlN/u8L24Gdx1qVq91KQvrpgwaAAw9p+wnXPw1YjyWMGtDo2ASOFGMU7SIEUzdYD34vMPmXwLbHgdkFYAtlGiim6DpxJtvq9LtlVr/aWKEB8pUXAOOPAFPzwBTZ9r04vdQ9Ts4pAZ3cd+yHxgfMAOH+vcA69/9Uxijmz/AerYpdar1lNSMYzV+vWY/34I8DY58Gph8Bpo8A04vAFEFIknIHohGVR62QhFRSYjQE6qFri2z3iaPAhHNNlxKwArI0Q1IAxwfReacbC5gBPp66/5ICgLKCtqnsrKKlrFZUFPKOr7osMTtdsxzqQRZ93Q1MPARMPllohUxRqkEK6gShOP0S+dY2hlRv99y+ovRi7IiTnTvLqmg6xDPYpqAUgRgsoR7MxgJmgHD/c4E1FXu7FRRbvEgd7evXWlbPpp9EgUjiJpwe6zwOMlvpAWCMVusJYPIYMOlSDZRpoGiNxKzbdIQlXONMWJbGtw4svdgz3El47nzTRvPrrKptAJT6ZrzfintvAJgx4vsvdQvIXK5VYF3sUZxmJUvgA1FOvwF8spKyBtM1y6EepI4LqVMedbEaTp0EIKdPKh5FqYYqSxgo2jgFr13j6XXHnOiSZOeBVSvyC8qC2r05FVvVw9cAMAOA178AWPMp2LJaaekiCPXExwHw660n1oB/niGQazwOkkSepbJ/72I1x4CJ+cJ6lYI1riccrVicUuVSmIW82pkwnHHVOKbFsOozQGkFkwewnBES37ABYMaAX39ZAUCCb82nIlo+40p2gNnvsoKunxH1xGwA/LOzdQOQJPIuHzV2GBg7Cow7AI0l33XfjOsv6oVodes6ISbBsAZMX+kJxU56KY7pkmFVhOciuvTzSt05v0+ryuT/9gDrZNe4wPMsI7VJP3GcP7gUOOdvgL1rRYJ0ZI5IV3hV4/wrGYPPU3/AiRhYusy2K7mU999P+z90ObD7LuBZK0Xdkeq9NSX2+o4HLwfWlopFCC0fgciBMtAFC8CGrYXVoVjnU2G7rTXrzh4kfRzLY1kyGwBoeiGcPiXb5eAzdXWnazPCSScb4j3xfmav8Cx2p50lAMW0VXINitCogl2r9H2dcctWwQxQsn6ZTBbMNtcgdKIbiZj51VcBk38CXPxoQcfCUg8pjcYgZScw/momACnXyr4leBhs5QaBTHpf7X8dMPYJYO8XgAv9e8QJlAZZq8D4xSuANYKPJQn0AR2AHKy1MACKe9nfFI6IEqduEWoHIJ9wlsVKLekoMCa9EAegSTYQeM4TXco2SEMkAHEbBZoj4bbYtdyCVrFqGXgTSxgXYTZeHLi9AMjEQRCVUXP/n4KUaaT8vVTi+Rtg7GPAuYcAWlMCgUVkQfJ2Q12yBvPXMwHImhDWwf81imsTiLSEvHZkr+jY/p9CQRD4p8DOBwteItai05qn31FFdfLlFxYWgCDUIkRkj/TxbCEi/89jfPZ3X2VqYSJQbmUNQY3HQT7hbv2sLoerVwKQHNEEoCsm8R4MhPRjXUGzVEIKIoY7yaEYuY4dgGb5RXruoSgtSCLLarkICQ9f6QNykGjFdjsIBaI4kGlt8W+Rg5g0HJ8qAp47nihAzFpuWtPIMBZJlASILvR6fQ0DCVbJCkJOJCqnk4pGpb99tZ8MopyiKDX7WWDiwYKXiEQOehCrgKh+eJQ+EQHo1Lby/zRlyf8TIbf9XS5ftIb8I92YugH4ay2pLusorl7dAoonWtMwQSTdOFuQSLTGHyIC8kxSIQuA4hwU2WUAoO4/grBcDbsfWElSzg+JCoYDoEGM1ixSkHzgF/wG7y8sIa3J7JPAGWuFJSQIaU01iJHUiYP4e33BrPOHmG/JMaOfTZVYRhwGav87vWKPJ9/rSH4IOGO5sITqg/ggxXs4TOaBAECbeoOsgfl+DrQShFqcEIhyyt0MbMusEkx76iAZXKM8BvXiZAGlF+KaIbaadYpem4aDgpJZQz6YJABV5VcHAJZ0v4FxX6KG5UpYs0KnqjhRuagEVgPglYAl9ciHf8mdUrJh0Qx9vkDBzBywfbkYQIGwahA/kglATsHsDzKA0BATiPyZ4NEDwIeoa/uFYKKXL2f24nQoIgd9R3yQCMTFqwIAfdBWI7+yB5ZLECYLETd85YJl+2YAUNosLIel/xYlu4Jsl6bhNhD6it4WJCvA2Zc4Gxo73RcgJeOqFmGR6rcChLYACyGojmEYdj59KnZ+tIQRhH9IvWA2hiREjDeRI9Cly7fMF3EtWRFawhQIf5IJwE56wdTIYdt7tp9ys1K8JnoJvod9Wn682PNkP4hUy1ndWgstAtBDMLYN5/6PAc5DGNoF4SrZfN+4+IhT8jqwg2Cp8ThIJ5vfSWBXAVCrWN9SMxDK+skaOvhoAc8me654pmUB3f0wyt+E8FyRAGmPlOEoiSD2qgvmAKoOm52fAuiTDHSyIRxx+lI0QxxADubfF5vffMmSajrWlP7nmZ3dSy+4r/ZzAUEHnQ8R70HsXlK+PgJsW68G4XYGZj0EY2EYATCAT6tAhmE0DXcC4faapcwMgAIfLb0kuzT9Qmw5uwAAIABJREFUSi+EfeALkSrpBovbrQDnkm8wAo8/E3i+CCsZ98NCpAp8cUekZyBavI4ET/TnaAk/RQCyAXy6uNSPA0i+wMeB6ePA5HFgZq2wpNGK3FUDAHmv3fSCe7afX8CB4UNEEOolVi/3obastNwJ9cO5BOBKEQMsAcifHWzRAigWWAlCn5K2bQYAOe1KMjTIR2kRUhKVS7IrLia0v+3xwHMZMCbYNP0KfG79zAqK5DxOvyEuWu6VD5KSHy2YAEQAfpaRdl5UkuUctIpBnCIIl4psD03FtIIP1ADAlBuJM47EqqUX3LX9kSBQcuuyftK78xUkHyQ+RLqHZ3Fv1KcgLj5kAQ1s0Qo6IA1nHhNLQzA8ZxvBXuNx8DcS5UYpNnoYxsCnUIqvZo0F3wPTMa7Hv53HOJVbS/l+5bumX7d+5WLE44hxIRJB2NMCqj9ixwuE90svWCaIA6bAp959EKeWChAyA0PTOV2unGMQveCO7bfqHbcS4rJR7Ewqnw5AWhLuImg2uFQAXAVs8RGmntW4+g2hB3P79L/EJ9zGvqrxOPibiVihAOgrWQOf/EBfBcsPNBBqW9Hv6zzGqFzmoXz3B9AePgXiq6bgiv4YOB9QHS8AfpkAFMMjrWAcQA0iO9XJiQyAnos2vV7ESHOOQfWCO7Zf7F40mZFQScRKAYBaSU6vAVcTgN7xXHiUFpDTMK2dFh56912BTiDcvpkATIXzCL4g3WXTZ4jpGfjoF/oihL+fx+0yWUABLwIwtYKKIabgCzHQvi2ggBKn0McEQDaKT5cGkIOo6SuyYzEfjQB0EM5nZgAPoxe8of3sgSqCQM3jkdFLvpRvR13+7UVRuhUFSavNO6otwp88ZZ3+t4M6HLtch6OT9AG/q9cmtf//gV1JDYcnQ2zY6/YakfSrU+Pg1M45NqPt3IEtoM7WFHokyrWKkooglCMWLYjiUXMtK3g8Uzd1WL3gDe3vRRCoUEYCwGtYFxxqgA2E/jI20F5hhmQod98BHNnlxOTig1aGiDanO21yV4DygWuB8YeB6fnC9WEtiKVVKeE0ZGiXWczeJoWMIig5a9V5DA1ANoKDeDylZ9NSXxyAsiKawrQqmCv2HVf5e8aRoxfc1n7xs+khItAUvojvyWryxVcWJZksVSyZoQRA3dcAoHzax4Gj2wtu6FVKM7gMgti02jbV476oUJJs1j/AbA1mQ3Pm8eTRsoZDtR+xZKCiEKmMXTIeXHPGdhYArX8FwG4DGMEnAHIK4yvT58nWC2b73cexaZgWWaEKgU1gjNbPP7PvOYGsUSBkv3hBtmRWNzxjTk9RWktvxp6POj0vARjY9sWkFel8RWxegjIF4RjwAOnZWMPBTGjqvHmszxJOBUD3xyznL2bqROvoP3N3q84jG4C7M/PpcvMBef0cvV9k6hXv+2Yno5QfGArRbaCC0mWv2YtF3ecerNDhkNZIIsXQRv5dlTtGADJSz2gEE1EJQM//026HdIEZLC8B6A0tk0g1Ja8DuzJdphS82QBEZj5dbj7gxZN5er/IZI+67pscgE7QaDOUMyC0Wb8+gXjuR4F5J6YsaXnFhBoAGEVvUhb60jISgCQnoh/OLBgvIrL8v7DdFkEYM5dtNg97tvz5zJqzdfIBmJlPl5sP+DJP5xtW7xffnzeh7H+Z+3+RpkyWT1YxuURJYVtx6T0fCTocouQV85VkHRIGegEuEv/YKpkA/JceVmL8kv6t5/9pu62tfiPWcFQVEa0DZ9WcLJEPwMx8uvfnjT9IgZyj94t/ldeA/S9tMaGa9SNdmsIxbvVscVJ1GScoMt4UPwhAsmMZ0aXzQBsvdGRBjQz0FUpEJRAJQOq4KAnBdz+sfiPJ3bOYn8fsykyVWMfiN3BOzckS+QDMzKe7OW/88aqQzsfE5kH1fvGjeQ0wADodmVGwOeiMsUqHrGOnS4UFy9P/wAEojkEnI+IqOIJQNLgpCXhcmLAtD/D+kgQE235L93tj+YBqgTX9BiCeW/NedT4AmQ+YkU/3sbzxBymQuZhm8g1T+QbV+wWFdjKO/Te2mEFNlCb6gPF708VJ1TXHgKd91GnZpDfi1k/gM2vqU3DUnCuBmNQe3P9vw6pe229KOvB0K1k+ZS+rnrfM2AlA3JMZtah/EZKZT3drxuDz1O/yxAwu9JgJxr3lQfR+8aa8Buy/wdWQZAVl+ZzCrG3q9c/YrkmHy3IRYryAAqAkEBIlopJxNNUbER+fA/H+/+AAdP9PmS9dazicJybm7mlB8nR2dI1HvgVkOlZGPt2nM29GCamcGZjAwlQ+vvrV+8X/zGsAAUiLVPp/wd+zaTMFWw+/kAA0GQQnpCw5mDsAMIrcRB5mC/+MAffTwgfwKY2KfmCZ6ZIkUShrxXxBX4yYaV8Hzmcn13jUA8CMfDqWYeQcSkhVOl8U6uxH7xekrsg49h8oiCENgC5TUG5vKxxT8f2aRtOtcAKQ1s8soPuOVUIwpchNlEEIOyNSIrrvv3hwnckWIZPZsnbcDyzTpvg3lU8mpZQqozyfK74aj3wAKh1LgrsD5tMxiz/nkGD1sHq/YNFOxkEAcuW7oqmXlisuQOT7VV2jwi/kTgj1RkoZhBje8Z83SCAEEJZW0C3gff8tADCt4VASaWIBK0HI9q8BF5yUAMzIp8tNx5Jg9bB6v/jdDPSRns0BWIZeUitIo9IhHmhXTvzCPQddccnZ76U1V/IvC4SBCFyg26DFNg7c++Mhhb6qiCikT7WVUmr6lYn2nRKyrdZ51GMBlZIc07GUBdMjny6XCiUmpA6j94vMZbgBMFo552pu27PXAqXTyAUQcitOQjAm9xX0N9pIwIPmSCmH5QuPqER0L4kDYgp9zOUL6fYxkbZcFceyAreAF3GlV+NRDwAz8uksnT3jiILVSmpWNlhMze+k94vMZfgGAPJeHDjpCrgM01Tdry9OzvmYAzAqLVWIwEShwzbRwwSEn+MqP6bQK5tZlWyhjCCCsC19Xv7gOnBRbgp7cu/5AOyVjqVMmA75dJZ9nHF0yohWNlhMxKnS+0XmMtwAmFq4imnYbrEqNJPc+9kfd62RKh0On8qV9hXZ9askEPgAfI56ziocUgVbzGT28lEtRMoKtg7lBHtznfZNA+CQ+XQWM8k4uglWK/NLYKzS+8U9GReXD0g/Tyvh4Ne17Yb4Zbr6g6y7/aNWcoPpjKRTsJIags5IJwkEAv6en05S6GUBfRWsUExZyVZVQCQwrgN7Wfdd41GPBczIp8ODeXfTSbBa6YYxlY8/p3q/udc3C+jTbtvqt2oadnB2m4oNgMn0W0p+hYWHWbwg9yU/0Kb9EIy+5y2hiCit4UgKyTeAkN8Valk4Le/ldlONRz4AWWBRM6fdIPfHstw/G+SE5rMnVQ/kA5AkLHS0ak7V7reXfhgACaBqDtD3e/nmc5k9kA/A80JReq+U38zGVp3ObJo/BvAOD3dtwiWar9zEHsgHIGlFubqSx7+Jja36anLLcDvvgwA+NDpDfILv+qlzuXwAXuSjrkKemlO2e3U1uWUYnL8dwB/5e2apca9LNv+vsQfyAUheX4VguB+mzIsaG9ntqxhF4Xbe3QD+n7/uHLAW9wQ1tblMRQ/UA0CaHC7plXEh+q4T0OWcfhleYTSHBK0EH/mi+fcRuKQn4I6fWpeoB4AevCz3HOOm9yb3F5mBlZBNclYCj1aRfyfrbgPCTR6AzK+vD4CyglX7jpmN7HY66d1E0ctdIrEEE4wEIMlam+Pk7YF6AMj7EwAVbU82vTerCwhAXopJN9zVI+AYrOeULLZgErY2x8nZA/kAJGWr0naUWdFpy2cT+oCWjpdjLFxE5UzYIBBpEUX5nLnlvAktb76SPVAfAOUHpiAMm96bsVtCAMaKALICMyxDq6cXfycA+b/mOLl6oF4AiqBRIEzBp7/X2Af0+fi1XIioMIlAI+AIPIGPmeROWV3j1Zuvyu2B+gHoFfZiDS2lC0LiY52WUADkQoTTMH1BFSYRdHoRfKSu5v9qrizMHYPT+vx6ARhSuDcAzzmDo5ZGHT1PAKYMwQxME2jiSo/gEwBrrq+u41ZOy++oD4BaCcsXTPiSI3ey8s4KGoG8QwCMFM+0ggQhLR0BF19SXuD/ayakz7uR0/TsMcxg3SjfqWNA0hsrga/ojaq/8WPcC+YIk4Ke4CMSuB2XVht1Oj8zIfXlU8BtU8DhmYRXWdfrdF1fgr3+S8At48CD04DVjXQSDO70PTUnaJ5uOCwsIIFHSSFy1pKPWCDsZxCpw8UVgKSPxLXM937OzxxAljzcPAbcswU4Qh4V3UN8mKoeKm/bu78IfKJQa8VD48CylHQiL3O3/qg5Rf30BKACMtJXjXKQcfBSK8Dfqc3KVCwuN2VFGRnm/yKZtq4Re5ifyQQgM2A+BeB3GHaZBo5MAIue0l7Kt3cC4xhw+5eL7TuCkJk1jBtyerbUfYG5ExjZ/pqrxE5fAOrOq5SmowVIrRp1IyT2R6+fg0bgVYG4CsyZe2UsaiOGKXr4Sfp9k8CxCYAFSKyvXeY1o1BxQux91yMtfsHPutgnnyUuUvhc0ZsgUXib+nVkq6+ZKaABIHsgVZnuwD9sVo66rrR4ImdhLGSQ8zPL/JgBQxeU1ouWkO9PTgDzbgmXxrzMkatl3keivfG5x4r4IRcz5BfkO5vEZ0kgpIfBZ8yKjlL17syy0tMNcOn9dl4Fy6dLFabj1Mpvow9Ify+I4Nlo9Xt+ZqU9VdJpqZh4QDDyxUyYOYJwHDg+DhgI/WUVZl7aSEt93+GO9Ia2iuZKOfA7lhp9JpvAVy61w2mOwO5hmCgMHC1H9O24gu6UD9jP+ZmbtLRaSsei9SL4XDPbAEh/kGQ/pSUcc0lbApFWb67lQUhpVnLBsoKqqZclFMmUtrxPcwxl3X7vOCAtYLSCcugFQmqhdssH7HU+RznjiOlYXA8wqkOfkItTAom+oKygca4ES8jY+N3z7fSG4hfUtp3ihUHruVSsFy1iRvNP+1N7A5BdJACmVpAgZPhGOyCigEjlPLudn7kvFtOxuB4g6OjD8UWLRkCZFRwrLCEXJQQhp2K+37lQeBCRX1A7KPQto1prFEmSYn2mB9EAsO+kYfk8KQhZF8yjVz5gp/MztyOUjiW9bCUhEBhKRCCgSis45uQ/PhX/xfFWMgOnWu2gxB0TF/o0kEZ/kCDM1Ts+3RHYnwVUL6XhDFrAswfIB6w6P1MrTulY0sum1VICglKwCEACqvQFCUK3gHcsFQCM/ILayqP1k9JshVqrncMalOYYvgcGAyCvIwuod8YBJQmZpmGJeyRwkGw4n8jJOJQNw3idLFhMRNB0SgASTJyKoy/4ieXCeFfJBUeV2SoAclFyR0bbm1OHTUiN0/DTAwD7zQeM52dqj8VsGEkVE2jKetG7AEhQ0frJAv6RC0trC1skl+IWlNinGLbSaZg7Mc0xfA8MbgF1LQV1z08A2G8+oM7PVF9Ms2GUE0gQyp+Lwu2yagLgR9ZaYpkSypQ6a6Q2DCqzpkvietXIFdoZfuieGmcOD0DeP0HEbBhNwYPmA/L8zJQsATAKnguEqS+XTqkE4YfWWwCUFZTksYAYwZfIBeN9Tw0cjOwu8gDIZqsoSSvhEeQDiiGYFoyWiSDRypWgi69UP5sc5fIcquSCNeXqe2X9ZAHfM7Khe2pcOB+AT41+aO5iRD3QAHBEHd9ctuiBBoANEkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cvAFgg4GR9kADwJF2f3PxBoANBkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cfOxqYJ2au9RdPtdp/khoEOlglDYT39V1PzQFXLsMXAlgt9PCxJKPbufyf8/KHIPfBPAZABf79Xc5XQ0ZQ1Q7360NbxoHrlsDvs5ZRsgo0une06by6X1mZvtP99PNAp4F4LsBXA5gjw8EGTeqaGF4QhzQF80CX7cAvGIdeDYAfhdZ2sTKUcVrpE7nd31N5gj8e2dIo2osk7NZpMdK0Z19tv+bJ4F9K8D1ACj8yfNSikHeg+5Z969m57Y/8/ZP+dPLKZhP/rcA+AYAF7g1oRUhEMUzFMt6eSJfX78b2DkPfM0i8GIAX+uWlAMppreUUErn8p2gzTl+2flg/sDbTkvIOik+CP20//mzwAXzwDcCuNTPJeFXpEpM6QEjIHm/zTF8D7T5gATYNQCe69aAloRTGulfBESBSYNyxR5g/Bhw7hKwZwl4vk9LnM5JmsBzUyDGAX3B8G23Mz/g9BuUa/0IiutfMkj7zwKmngAuXSvOpUvAWYBtF4BTnspIj/O8zPaf7qdvWITw6eZA0JLQEhKEGgxZhUj/dz3NzSKwbR44exnYvVKcy+mM5Km0JhxInUtrGkmzCPicg3W5LMGkQiZZTm9xS9Z3+4m2o8C5c4X15pTKW2Lb+fCx7WLtjYxzqiql29Icw/dA5SqYf6RTTilg+lYCIXmICKQ4IK9wxfSJY8AZK8CuFWDnanEua9ZTAMsaCog3Dt92O/MvnRGBtGwkqKRmMEkqCaa+2k+0LQDTh4rP88UHj74kF1WaATo9QHQ7mmP4HugYhtEKj4PB6ZQ+FS0hQahpldPya1kXTOqNY8DscgG+HavAttUCvBxInitrkgL4lcO33c7spBdM3kAuSnq2nx9gQfAh4JyVwvrxwel2z3p4aMlzH6DM2z/lT+8aB+Q/OT4EEqckWQSBkGD6EQKQnDCLwBSnYgcf32fXioGUFawC4esyu7CXXnDP9tOCsyD4KLB1rmgvX7zfbu2WG/Jtme0/3U/vKxBNAMoi0KcjkATCN3HOEr3UAjDrwOP71rXixYEkeKMFlSX8ocwR6KUXTJ7AaNE2tF8WfA4Ye7Kw1mwvX/yZn+eKnvcrfzC6IK/ObP/pfnpfAGQnySoISBqUXyAASS1AK0JfagWYcRDOrAF66TxZQU7jBOEbM0egH71gcgXSFZAV54NQtj9YcNIpbONCyh8Ygi8CVospApDuB63g92W2/3Q/vW8AsqM4gLIKBBIH8bcJwMCNMX68BTqBb8s6sGWtsIA6jwDk662ZI9CvXjA5A6NVa2t/IAicnC/aGV+8T74IQPm/AmGuBc+8/VP+9IEAyLslAKMV/LgAyIUInfnjwPQqMOOgI/DstQ5Mr7UAqMF8V2YXDqoXXNl+EQQ6N9v29aKdesUpWJZbAPyPme0/3U8fGIDssDid/pUASCvCaXgJmFguAEfgEXT27gDkuwaUg/nbmSMwjF7whvbLhSDL5TwwvdRqo9oqHzACkCB8U2b7T/fThwIgO01T1IMCoAZxGRhbKoAXQUcQTjkI+a4B5e5FzjGsXvCG9gdqrLGFYrpVG/UuHzBOw2/LaXxzbh43DKeoJwlAHqLndSs4udoCoIBHQE45EPk3DuitmYOQoxdctp8+rFwIWsGFYiFFoLGNchcEQC6e+OJC5J2Z7T/dTx/aApYdJ37AyJK/DIwvFxYvWr0IwEn/H1Opco5sveDUhSAAF4HJpQJkWixp6k2n4IYfMGf0amDHev2I8+l4/UbvNw8Eozw72wJePOJ8und7EkKj9ztKGA1/7WwATo44n45pWI3e7/AAGPWZ2QBkYHCU+XTMfGGQmYIxjd7vqOE0+PXzATjifDrKtTZ6v4MP/MlyRj4AR5xPF+VaqZLJF1UzKdPV6P2eLDDr3I58AI44n07ZMARbo/d78gMubWE+AEecT8e9YOn2Uheu0fs9tUCYD8AR59MpG6bR+z21gKfW1gNAz4geRT5dTEZo9H5PPRDmAzBmRM8BJzqfLiYjSKKr0fs9dYBYDwBHmE9XtRfMsIz04aQZ1+j9npygrA+Akqs8wfl0BCCTWRq935MTYL1aVQ8Ao1zlAnAi8+kEQGZTNXq/vYb75Pt/fQAcUT5dBGCj93vyAaxXi+oDoFLyT3A+3Rcavd9eY3xS/z8fgCQX/LPR3SOzkon55jg1eyAfgD8M4NcAPD6aDmBtB1e4NMDNcer1QD4AbwbwxwDe4UvRE9wHZG1gNSXDLlwLNcep1QP5APxzzwj9IIAPnXhT5ORc5EYCA9HNcWr1QD4AmRH6FQBMTSZZH98ZmD5Bh5g1FopiNns1x6nTA/kAvAfAEwDudnI+EvQxPfkEzYfaCXRSBluQMB7YHKdGD+QDsBNBH/9+AkAobqTADGK7Inw1x8nfA/kA7EXQt8kgrGAGMfBxZ5Cv5ji5eyAfgL0I+r68uR0QmUFoBQU8vfNvzXHy9kA9AORoMw7CdGQCjoUZDwL4kv/+8OZ1gJhBIjGDgMh3vTavBc035/RAPgD7JegjODfhiMwgoqeJwNPPTaB6Ezq/hq+sB4AcXeXEP+ZhGVo9vRimIQD5v5oPAZCupgDI9wg8/qz/1Xz55usyeyAfgMMQ9GU2Op4eAchpOIJQQEz/VuPlm6/K7IH6AMjgGzdl6QtyX5jWjpQFevF3lq3xf6yhrOlIAUgQCojR8gmE+l9Nl2++JrMH6gEgR5UA5KYsc+AZmCbQCDi+IvgEQMob1XBEAHIajgBMLV+0kCdws6aGu3zqfkV9AGTwjftg3JRVVRAtHQEXX/wbAcoXP5d5CID8GoJKvqDAloKOoIz/y7x8c3pmD4zhaqwjRzCYyQg5gr2ZgsFTLweWr8XQgsXjbwLWrnNtMlKgNoLBmZAa7PTCAuYIBlMvlWQswwr2UlUw45jdDSx8HbD+Ctd+HVCwePKbgJV9aASDM8Yg59TWFDysYPBtmYK91IbNOHaPA/M7gUXKXA4hWDz79cA8+W0aweCMURj+1HYfcBjBYO54MMY3tGDv8I3nmWSHOzYOLJ0LLPGXAQWLz3oB8MQUsEa16kYwOG8whjh74yJkUMFgbsNlCfYO0epwissVY34bsHw2sEIRkAEEi/dcU0SP5qhF1ggG5w3GEGdXr4L5134Fg4kAjuDQgr1DtDqcUmZETwArZwAru4BVqsv0KVh8/o3F4v0QXZBGMDhvMIY4u3MYhv95Zh+Cu1xBcxuOU/HfeDIq5cv7FuwdotXhlCBXjOXZAnyrO4BV6in0IVh8wStLuWCsUAyvEQzOG5ABz+4eB+R/ewnu/kOP/3G/l4kJTERlljQtIot2e53/IwO2OPl4FLtcnCqAp9cahT56CBZf+LpSLhhz1N5qBIPzBmTAs/sLRHcTDKbiNHdBGGymOC/3hglEvgjAnoK9A7Y4+XgiV4zVWYDAs/etxaubYPFFP1QkLtCIP8neaASD8wZkwLP7AyC/tJNg8L/xLNBu+YBdBXsHbHEFAINcMVamgdWZAoRrfPdXm8KitLdmgYveWAq+2y7iMqfuRjA4b1AGOLt/APJLqwSD3+y5T1yI0AoSbAxMMzGV1o8/My2ro2DvAK2t+GgiV4zj4+3AIwDXtwBrVJeuECze+9aW4Dut4PxkIhYsdetGMDhvoDqcPRgA+SWp4O4veQ5Uv/mAGwR78+6rQq4Yq9PAOi2fA4/vBkKudKVU7VZw77uKvWFuZbtcMNb5v0YwOG9g+jx7cADyi6Pg7gccgIxlcA5TKhaD01yYKBmVFpBZMfx/m2Bvny3t8LGqoqTliZbVI+gMgHwnMAnCIFi897cLAAZ6QyzFzzSCwXkD1OPs4QDIL5XgLmk5JHk/SD5gKdibd38VcsVYGmuBTaAzEHLHgyCcaokB7/1IkUET5IKxwF5pBIPzBqbPs4cHIC/AaeqvPL9pmHxAE+zts6VdLCD/lcgVY3UyWD0Bj1ZwqgCggXA7sPfWAoAJvaEtZBrB4Lyx6efsPADyCtmCvf00s/NnOsgVY3m8BTRZPZuGBUACdArY+5lWDqGmYbIrLHEx0ggG5w1OH2fnA7CPizQfaXqgUw80AGywMdIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0BxoAjrT7m4s3AGwwMNIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0B8ZYNMbkX+ZekpuIiOQrPar+xs889HJg6jZg5jAwvVZ8B+ll9PlO5/Fc/o+ECjnHfi8zYfkvM5ulmp4qJXVqx5deD4zfAkw/CGxdAZgoHfuh131QkaI5hu8Bs4Ds8B0AWLnIRGCBsFfn87JffDMwdjOw5R5g8giwZa34jnQQUwDo99wBfJ4TM7COiNdlaj2rA/jeV/vfDeATAP4UGH8I2Lrc6gc+SHqY4oMZ74VSKM0xfA+UUzB/oBUUCKMl6zSQ/PsXqZD5KQC/A0w/DEwcAcYXgYnVwppwADuBkefnCim90FmBWXwnK87Uen53BI8sbuwqaz9p5UgnQhBS+ZN1zE8Ak0utviCwq8DI8/nx5hi+Bzb4gJzKZE1SEFZZgS9/2pWR/gTAJ4HJQ8DEMWB8ARhfBsaWCwDquwQKvvNgHXvOcYVbPFJPkw+dDxC/W1Y4tWDpw/Rlgo4lo1T4/KxTihDNpJwj3/UiMLXemprjffC7eWpzDN8DlYsQDiKtVxzEqoHkyX9HRizW+nIgaQnvAiaeBCbmC0s4tgSMu2rMePAR9X252jXklaTFU108K0MHav/nvJ6ZxVVk9OI7GR2IZoGQNc/HgbHgIwqILIVujuF7oOMqWFawCoRxkfEIB5CWgkREBCNf9wMTc8A4QciBWyoGz16rwNgaML5eWKpctYZL3N+TWLX0gvtuP0HHk2n16JDyxXmVhfU0qywbJbr5GSuXKxA/sV5Y9UYWdnjwyS3qKKgarWA69Wg6fjQOIK0HadnIjPVFB+AiME4AuiUkCFnESyCSkmAuU7Cjm15wX+2X2ifBRn9A8mKcW2UFjULVQcgVDl80u40SYh763FfvquhLCxitoBYUsoJfjXKttByMq9CKcHn4sPuCbgXNJwyWkECcz5Q376UX3LNncZyQAAADEklEQVT9fFgIJs6lBBwtn3Tt6FpIz4RWnuQxPh2XIGzm4CwQ9hWIFgBTK0gQHiIAJddKq0ELQh+KL1qUR4MvSEsoENIKrgALHNiMox+94K7tl9qnnMio8MSf6SNwGpYVjCDk/Ju7isq496fCqX0BkDeqlWwKwic1gAQSpzGREnFgREz01eALLvvq2Kfi45m6cf3qBXdsfxRbJMho8dimqOhEK8cXQRr9QVpvPoDNMXQP9A3ACELFxPh+jACkP0fLIKFCCRRqKuPUdqjlC9o07JZwKVNHeBC94DQcZO0XAAkmgotAk9QYrR9f/BvByYfMSATDVMzwTXMM3QMDAVAgVHCZ7/MaQK4QZUHiNCbBQlqUw74YCb7gcmYkelC9YFlwvVv7RRAorTuBkECU9asCID9/x9B935zYzyKkqpfiNHxcA0gLQgvBAaPVkCqm3h2AtC5m/RyEqzw/4xhGL3hD++MmslgqCbgUfLKAcRrmTlBzDN0DA1tAXUlWcDm1IOIIJAjlT/Fd05lbFQFwjdtgGcewesFt7Rc/Gx8iWjUCjGCT1YvWT1MwgUqrf3NG45tTbcu0aximWx9xENcEQHGbcYAEwtSXSqY0gnCdgeuMI0cvuGx/FUGgFhwEYrR80QckWN+X0fjm1DwAWv8RgJFilJZBznz0pQg+AZAAlVWh1GvGka0XzB0cCQi30aSGVa9AF62fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC', LH = 'uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}', OH = 'varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}', co = { LOW: 0, MEDIUM: 1, HIGH: 2, ULTRA: 3 }, IH = class extends Ss { constructor({ preset: e = co.MEDIUM, edgeDetectionMode: t = Lv.COLOR, predicationMode: i = c2.DISABLED } = {}) { super('SMAAEffect', LH, { vertexShader: OH, blendFunction: nt.NORMAL, attributes: ms.CONVOLUTION | ms.DEPTH, uniforms: new Map([['weightMap', new Oe(null)]]) }); let r, s; arguments.length > 1 && ((r = arguments[0]), (s = arguments[1]), arguments.length > 2 && (e = arguments[2]), arguments.length > 3 && (t = arguments[3])), (this.renderTargetEdges = new ii(1, 1, { minFilter: mt, stencilBuffer: !1, depthBuffer: !1 })), (this.renderTargetEdges.texture.name = 'SMAA.Edges'), (this.renderTargetWeights = this.renderTargetEdges.clone()), (this.renderTargetWeights.texture.name = 'SMAA.Weights'), (this.uniforms.get('weightMap').value = this.renderTargetWeights.texture), (this.clearPass = new Ou(!0, !1, !1)), (this.clearPass.overrideClearColor = new Ge(0)), (this.clearPass.overrideClearAlpha = 1), (this.edgeDetectionPass = new un(new CV())), (this.edgeDetectionMaterial.edgeDetectionMode = t), (this.edgeDetectionMaterial.predicationMode = i), (this.weightsPass = new un(new zV())); let n = new Uw(); (n.onLoad = () => { let a = new ci(r); (a.name = 'SMAA.Search'), (a.magFilter = Ot), (a.minFilter = Ot), (a.generateMipmaps = !1), (a.needsUpdate = !0), (a.flipY = !0), (this.weightsMaterial.searchTexture = a); let o = new ci(s); (o.name = 'SMAA.Area'), (o.magFilter = mt), (o.minFilter = mt), (o.generateMipmaps = !1), (o.needsUpdate = !0), (o.flipY = !1), (this.weightsMaterial.areaTexture = o), this.dispatchEvent({ type: 'load' }); }), n.itemStart('search'), n.itemStart('area'), r !== void 0 && s !== void 0 ? (n.itemEnd('search'), n.itemEnd('area')) : typeof Image < 'u' && ((r = new Image()), (s = new Image()), r.addEventListener('load', () => n.itemEnd('search')), s.addEventListener('load', () => n.itemEnd('area')), (r.src = Jb), (s.src = $b)), this.applyPreset(e); } get edgesTexture() { return this.renderTargetEdges.texture; } getEdgesTexture() { return this.edgesTexture; } get weightsTexture() { return this.renderTargetWeights.texture; } getWeightsTexture() { return this.weightsTexture; } get edgeDetectionMaterial() { return this.edgeDetectionPass.fullscreenMaterial; } get colorEdgesMaterial() { return this.edgeDetectionMaterial; } getEdgeDetectionMaterial() { return this.edgeDetectionMaterial; } get weightsMaterial() { return this.weightsPass.fullscreenMaterial; } getWeightsMaterial() { return this.weightsMaterial; } setEdgeDetectionThreshold(e) { this.edgeDetectionMaterial.edgeDetectionThreshold = e; } setOrthogonalSearchSteps(e) { this.weightsMaterial.orthogonalSearchSteps = e; } applyPreset(e) { let t = this.edgeDetectionMaterial, i = this.weightsMaterial; switch (e) { case co.LOW: (t.edgeDetectionThreshold = 0.15), (i.orthogonalSearchSteps = 4), (i.diagonalDetection = !1), (i.cornerDetection = !1); break; case co.MEDIUM: (t.edgeDetectionThreshold = 0.1), (i.orthogonalSearchSteps = 8), (i.diagonalDetection = !1), (i.cornerDetection = !1); break; case co.HIGH: (t.edgeDetectionThreshold = 0.1), (i.orthogonalSearchSteps = 16), (i.diagonalSearchSteps = 8), (i.cornerRounding = 25), (i.diagonalDetection = !0), (i.cornerDetection = !0); break; case co.ULTRA: (t.edgeDetectionThreshold = 0.05), (i.orthogonalSearchSteps = 32), (i.diagonalSearchSteps = 16), (i.cornerRounding = 25), (i.diagonalDetection = !0), (i.cornerDetection = !0); break; } } setDepthTexture(e, t = qs) { (this.edgeDetectionMaterial.depthBuffer = e), (this.edgeDetectionMaterial.depthPacking = t); } update(e, t, i) { this.clearPass.render(e, this.renderTargetEdges), this.edgeDetectionPass.render(e, t, this.renderTargetEdges), this.weightsPass.render(e, this.renderTargetEdges, this.renderTargetWeights); } setSize(e, t) { this.edgeDetectionMaterial.setSize(e, t), this.weightsMaterial.setSize(e, t), this.renderTargetEdges.setSize(e, t), this.renderTargetWeights.setSize(e, t); } dispose() { let { searchTexture: e, areaTexture: t } = this.weightsMaterial; e !== null && t !== null && (e.dispose(), t.dispose()), super.dispose(); } static get searchImageDataURL() { return Jb; } static get areaImageDataURL() { return $b; } }, RH = `uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`, Zc = { DEFAULT: 0, ESKIL: 1 }, BH = class extends Ss { constructor({ blendFunction: e = nt.NORMAL, technique: t = Zc.DEFAULT, eskil: i = !1, offset: r = 0.5, darkness: s = 0.5 } = {}) { super('VignetteEffect', RH, { blendFunction: e, defines: new Map([['VIGNETTE_TECHNIQUE', t.toFixed(0)]]), uniforms: new Map([ ['offset', new Oe(r)], ['darkness', new Oe(s)] ]) }); } get technique() { return Number(this.defines.get('VIGNETTE_TECHNIQUE')); } set technique(e) { this.technique !== e && (this.defines.set('VIGNETTE_TECHNIQUE', e.toFixed(0)), this.setChanged()); } get eskil() { return this.technique === Zc.ESKIL; } set eskil(e) { this.technique = e ? Zc.ESKIL : Zc.DEFAULT; } getTechnique() { return this.technique; } setTechnique(e) { this.technique = e; } get offset() { return this.uniforms.get('offset').value; } set offset(e) { this.uniforms.get('offset').value = e; } getOffset() { return this.offset; } setOffset(e) { this.offset = e; } get darkness() { return this.uniforms.get('darkness').value; } set darkness(e) { this.uniforms.get('darkness').value = e; } getDarkness() { return this.darkness; } setDarkness(e) { this.darkness = e; } }, X9 = [new Float32Array(3), new Float32Array(3)], q9 = [new Float32Array(3), new Float32Array(3), new Float32Array(3), new Float32Array(3)], Y9 = [ [new Float32Array([0, 0, 0]), new Float32Array([1, 0, 0]), new Float32Array([1, 1, 0]), new Float32Array([1, 1, 1])], [new Float32Array([0, 0, 0]), new Float32Array([1, 0, 0]), new Float32Array([1, 0, 1]), new Float32Array([1, 1, 1])], [new Float32Array([0, 0, 0]), new Float32Array([0, 0, 1]), new Float32Array([1, 0, 1]), new Float32Array([1, 1, 1])], [new Float32Array([0, 0, 0]), new Float32Array([0, 1, 0]), new Float32Array([1, 1, 0]), new Float32Array([1, 1, 1])], [new Float32Array([0, 0, 0]), new Float32Array([0, 1, 0]), new Float32Array([0, 1, 1]), new Float32Array([1, 1, 1])], [new Float32Array([0, 0, 0]), new Float32Array([0, 0, 1]), new Float32Array([0, 1, 1]), new Float32Array([1, 1, 1])] ], Q9 = [new Float32Array(2), new Float32Array(2)], Z9 = new Float32Array([0, -0.25, 0.25, -0.125, 0.125, -0.375, 0.375]), K9 = [ new Float32Array([0, 0]), new Float32Array([0.25, -0.25]), new Float32Array([-0.25, 0.25]), new Float32Array([0.125, -0.125]), new Float32Array([-0.125, 0.125]) ], J9 = [ new Uint8Array([0, 0]), new Uint8Array([3, 0]), new Uint8Array([0, 3]), new Uint8Array([3, 3]), new Uint8Array([1, 0]), new Uint8Array([4, 0]), new Uint8Array([1, 3]), new Uint8Array([4, 3]), new Uint8Array([0, 1]), new Uint8Array([3, 1]), new Uint8Array([0, 4]), new Uint8Array([3, 4]), new Uint8Array([1, 1]), new Uint8Array([4, 1]), new Uint8Array([1, 4]), new Uint8Array([4, 4]) ], $9 = [ new Uint8Array([0, 0]), new Uint8Array([1, 0]), new Uint8Array([0, 2]), new Uint8Array([1, 2]), new Uint8Array([2, 0]), new Uint8Array([3, 0]), new Uint8Array([2, 2]), new Uint8Array([3, 2]), new Uint8Array([0, 1]), new Uint8Array([1, 1]), new Uint8Array([0, 3]), new Uint8Array([1, 3]), new Uint8Array([2, 1]), new Uint8Array([3, 1]), new Uint8Array([2, 3]), new Uint8Array([3, 3]) ], e7 = new Map([ [bi(0, 0, 0, 0), new Float32Array([0, 0, 0, 0])], [bi(0, 0, 0, 1), new Float32Array([0, 0, 0, 1])], [bi(0, 0, 1, 0), new Float32Array([0, 0, 1, 0])], [bi(0, 0, 1, 1), new Float32Array([0, 0, 1, 1])], [bi(0, 1, 0, 0), new Float32Array([0, 1, 0, 0])], [bi(0, 1, 0, 1), new Float32Array([0, 1, 0, 1])], [bi(0, 1, 1, 0), new Float32Array([0, 1, 1, 0])], [bi(0, 1, 1, 1), new Float32Array([0, 1, 1, 1])], [bi(1, 0, 0, 0), new Float32Array([1, 0, 0, 0])], [bi(1, 0, 0, 1), new Float32Array([1, 0, 0, 1])], [bi(1, 0, 1, 0), new Float32Array([1, 0, 1, 0])], [bi(1, 0, 1, 1), new Float32Array([1, 0, 1, 1])], [bi(1, 1, 0, 0), new Float32Array([1, 1, 0, 0])], [bi(1, 1, 0, 1), new Float32Array([1, 1, 0, 1])], [bi(1, 1, 1, 0), new Float32Array([1, 1, 1, 0])], [bi(1, 1, 1, 1), new Float32Array([1, 1, 1, 1])] ]); function If(e, t, i) { return e + (t - e) * i; } function bi(e, t, i, r) { let s = If(e, t, 0.75), n = If(i, r, 1 - 0.25); return If(s, n, 1 - 0.125); } var Qs = class { constructor(e, t) { (this.enabled = !1), (this.effect = new e(t)), Object.defineProperty(this, 'opacity', { enumerable: !0, set(i) { this.effect.blendMode.opacity.value = i; }, get() { return this.effect.blendMode.opacity.value; } }), Object.defineProperty(this, 'blendFunction', { enumerable: !0, set(i) { this.effect.blendMode.setBlendFunction(Number(i)); }, get() { return this.effect.blendMode.blendFunction; } }), (this.blendFunction = nt.NORMAL); } }, zH = class extends Qs { constructor() { super(mH), (this.blendFunction = nt.SCREEN); } set intensity(e) { this.effect.intensity = e; } get intensity() { return this.effect.intensity; } set luminanceThreshold(e) { this.effect.luminanceMaterial.threshold = e; } get luminanceThreshold() { return this.effect.luminanceMaterial.threshold; } set luminanceSmoothing(e) { this.effect.luminanceMaterial.smoothing = e; } get luminanceSmoothing() { return this.effect.luminanceMaterial.smoothing; } set blurScale(e) { this.effect.blurPass.scale = e; } get blurScale() { return this.effect.blurPass.scale; } set kernelSize(e) { this.effect.blurPass.kernelSize = e; } get kernelSize() { return this.effect.blurPass.kernelSize; } }, NH = class extends Qs { constructor() { super(vH); } set contrast(e) { this.effect.uniforms.get('contrast').value = e; } get contrast() { return this.effect.uniforms.get('contrast').value; } set brightness(e) { this.effect.uniforms.get('brightness').value = e; } get brightness() { return this.effect.uniforms.get('brightness').value; } }, UH = class extends Qs { constructor() { super(_H), (this.effect.offset = new G(0.01, 0.01)); } set offset(e) { this.effect.offset.set(e[0] / 1e3, e[1] / 1e3); } get offset() { return [this.effect.offset.x * 1e3, this.effect.offset.y * 1e3]; } }, FH = class extends Qs { constructor() { super(xH); } }, kH = class extends Qs { constructor() { super(EH), (this._hue = 0); } set hue(e) { (this._hue = e), this.effect.setHue(e); } get hue() { return this._hue; } set saturation(e) { this.effect.uniforms.get('saturation').value = e; } get saturation() { return this.effect.uniforms.get('saturation').value; } }, jH = class extends Qs { constructor() { super(TH), (this.blendFunction = nt.OVERLAY); } }, GH = class extends Qs { constructor() { super(BH); } get eskil() { return this.effect.eskil; } set eskil(e) { this.effect.eskil = e; } get darkness() { return this.effect.uniforms.get('darkness').value; } set darkness(e) { this.effect.uniforms.get('darkness').value = e; } get offset() { return this.effect.uniforms.get('offset').value; } set offset(e) { this.effect.uniforms.get('offset').value = e; } }, VH = class extends Qs { constructor(e) { super(SH, e); } set focalLength(e) { this.effect.circleOfConfusionMaterial.uniforms.focalLength.value = e; } get focalLength() { return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value; } set focusDistance(e) { this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value = e; } get focusDistance() { return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value; } get bokehScale() { return this.effect.bokehScale; } set bokehScale(e) { this.effect.bokehScale = e; } }, HH = class extends Qs { constructor() { super(DH); } get granularity() { return this.effect.getGranularity(); } set granularity(e) { this.effect.setGranularity(e); } }, WH = class extends Tr { constructor(e, t, i) { super('TransmissionPass', e, t), (this.copyPass = new nu(i.transmissionRenderTarget)), (this.depthPass = new Zb(e, t, { renderTarget: i.transmissionDepthTarget })), (this.needsSwap = !1); } updatePasses(e) { (this.copyPass = new nu(e.transmissionRenderTarget)), (this.depthPass = new Zb(this.scene, this.camera, { renderTarget: e.transmissionDepthTarget })); } setCamera(e) { this.camera = e; } setScene(e) { this.scene = e; } render(e, t, i) { let r = this.camera.layers.mask; this.copyPass.render(e, t, i), this.camera.layers.disable(3), this.depthPass.render(e, t, i), (e.shadowMap.needsUpdate = !1), (e.shadowMap.autoUpdate = !1); let s = this.renderToScreen ? null : t; this.camera.layers.set(3), e.setRenderTarget(s), e.render(this.scene, this.camera), (this.camera.layers.mask = r); } }, ew = new pa(), XH = new ri({ transparent: !0, vertexShader: ` void main() { gl_Position = vec4(0.0); } `, fragmentShader: ` void main() { gl_FragColor = vec4(0.0); } ` }), Rf = class extends Tr { constructor(e, t) { super('OpaquePass', e ?? ew, t), (this.hasTransmissionPass = !1), (this.clear = !0), (this.needsSwap = !1), (this.originalMaterials = new Map()); } setCamera(e) { this.camera = e; } setScene(e) { this.scene = e ?? ew; } getScene() { return this.scene; } render(e, t) { this.originalMaterials.clear(), this.camera.layers.enable(3), this.hasTransmissionPass && this.scene.traverse((r) => { r.layers.isEnabled(3) && r instanceof ar && (this.originalMaterials.set(r.id, r.material), (r.material = XH)); }), this.camera.layers.enable(8), (e.shadowMap.needsUpdate = !0), (e.shadowMap.autoUpdate = !0); let i = this.renderToScreen ? null : t; e.setRenderTarget(i), this.clear && e.clear(), e.render(this.scene, this.camera), this.hasTransmissionPass && this.originalMaterials.forEach((r, s) => { let n = this.scene.getObjectById(s); n && (n.material = r); }); } }; function tw(e, t) { return t && t.enabled && e.push(t.effect), e; } var qH = (e) => (Object.values(nt).includes(e) ? e : nt.NORMAL), YH = class extends Vi { constructor(e) { super(), (this.postprocessingState = bh.defaultData), (this._scene = new pa()), (this._camera = new Gi()), (this.effects = new Map()), (this._renderToScreen = !0), (this.clock = new qD()), (this.renderer = e), (this.debug = !1), this.effects.set('bloom', new zH()), this.effects.set('chromaticAberration', new UH()), this.effects.set('vignette', new GH()), this.effects.set('noise', new jH()), this.effects.set('colorAverage', new FH()), this.effects.set('hueSaturation', new kH()), this.effects.set('brightnessContrast', new NH()), this.effects.set('depthOfField', new VH()), this.effects.set('pixelation', new HH()), (this.effectComposer = new pH(this.renderer)), (this.opaquePass = new Rf(this.scene, this.camera)), (this.transmissionPass = new WH(this.scene, this.camera, this.renderer)), (this.helperPass = new Rf(void 0, this.camera)), (this.helperPass.hasTransmissionPass = !1), (this.helperPass.clear = !1), (this.helperClearPass = new Ou(!1, !0, !1)), (this.helperPassOnTop = new Rf(void 0, this.camera)), (this.helperPassOnTop.hasTransmissionPass = !1), (this.helperPassOnTop.clear = !1), this._initCopyPass(), this._initSmaa(), this._initPasses(); } get scene() { return this._scene; } set scene(e) { (this._scene = e), this.opaquePass.setScene(e), this.transmissionPass.setScene(e); } set sceneHelpers(e) { this.helperPass.setScene(e); } get sceneHelpers() { return this.helperPass.getScene(); } set sceneHelpersOnTop(e) { this.helperPassOnTop.setScene(e); } get sceneHelpersOnTop() { return this.helperPassOnTop.getScene(); } get camera() { return this._camera; } set camera(e) { (this._camera = e), this.opaquePass.setCamera(e), this.transmissionPass.setCamera(e), this.helperPass.setCamera(e), this.helperPassOnTop.setCamera(e); } setTransmissionPassEnabled(e) { (this.transmissionPass.enabled = e), (this.opaquePass.hasTransmissionPass = e); } disableHelpers() { (this.helperPass.enabled = !1), (this.helperClearPass.enabled = !1), (this.helperPassOnTop.enabled = !1); } enableHelpers() { (this.helperPass.enabled = !0), (this.helperClearPass.enabled = !0), (this.helperPassOnTop.enabled = !0); } _initSmaa() { let e = new IH({ preset: co.ULTRA, edgeDetectionMode: Lv.COLOR }), t = () => { e.removeEventListener('load', t), this.dispatchEvent({ type: 'smaaloaded' }); }; e.addEventListener('load', t), (e.edgeDetectionMaterial.predicationMode = c2.DEPTH), (e.edgeDetectionMaterial.edgeDetectionThreshold = 0.05), (e.edgeDetectionMaterial.predicationThreshold = 0.002), (e.edgeDetectionMaterial.predicationScale = 1), (this.smaaPass = new Lf(this.camera, e)); } _initPasses() { if ( (this.uvEffectPass?.dispose(), this.effectPass?.dispose(), this.effectComposer.removeAllPasses(), this.transmissionPass.updatePasses(this.renderer), this.effectComposer.addPass(this.opaquePass), this.effectComposer.addPass(this.transmissionPass), this.postprocessingState.enabled) ) { let e = [this.effects.get('pixelation')].reduce(tw, []); e.length > 0 && ((this.uvEffectPass = new Lf(this.camera, ...e)), this.effectComposer.addPass(this.uvEffectPass)); let t = [ this.effects.get('chromaticAberration'), this.effects.get('bloom'), this.effects.get('colorAverage'), this.effects.get('hueSaturation'), this.effects.get('brightnessContrast'), this.effects.get('vignette'), this.effects.get('noise') ].reduce(tw, []); t.length > 0 && ((this.effectPass = new Lf(this.camera, ...t)), this.effectComposer.addPass(this.effectPass)); } this.effectComposer.addPass(this.helperPass), this.effectComposer.addPass(this.helperClearPass), this.effectComposer.addPass(this.helperPassOnTop), this.effectComposer.addPass(this.smaaPass); } _initCopyPass() { if (this._savePass) return; let e = new G(); this.renderer.getDrawingBufferSize(e), (this._rt = new ii(e.x, e.y, { depthBuffer: !1, stencilBuffer: !1, wrapS: oh, wrapT: oh })), (this._rt.samples = 0), (this._savePass = new nu(this._rt, !1)), (this._savePass.renderToScreen = !1); } get renderToScreen() { return this._renderToScreen; } set renderToScreen(e) { if (this._renderToScreen === e) return; let t = this.effectComposer; !t || (e === !0 ? (t.removePass(this._savePass), (t.passes[t.passes.length - 1].renderToScreen = !0), (t.autoRenderToScreen = !0)) : ((t.autoRenderToScreen = !1), (t.passes[t.passes.length - 1].renderToScreen = !1), (this._savePass.renderToScreen = !1), this.postprocessingState.enabled || (this._savePass.needsDepthTexture = !0), t.addPass(this._savePass)), (this._renderToScreen = e)); } get texture() { return this._rt && this._rt.texture; } get renderTarget() { return this._rt; } updatePostprocessing(e) { let { enabled: t, ...i } = e, r = !1; t !== this.postprocessingState.enabled && (r = !0); for (let s of Object.entries(i)) { let n = s[1], a = this.effects.get(s[0]); if (a) { a.enabled !== n.enabled && (r = !0), (a.enabled = n.enabled); for (let [o, l] of Object.entries(n)) o === 'blendFunction' ? (a.blendFunction = qH(l)) : (a[o] = l); } } (this.postprocessingState = e), r && this._initPasses(); } render() { this.effectComposer.render(this.clock.getDelta()); } setScissor(e, t, i, r) { e instanceof $e ? (this.effectComposer.inputBuffer.scissor.set(e.x, e.y, e.z, e.w), this.effectComposer.outputBuffer.scissor.set(e.x, e.y, e.z, e.w)) : (this.effectComposer.inputBuffer.scissor.set(e, t, i, r), this.effectComposer.outputBuffer.scissor.set(e, t, i, r)); let s = this.renderer.getPixelRatio(); this.effectComposer.inputBuffer.scissor.multiplyScalar(s), this.effectComposer.outputBuffer.scissor.multiplyScalar(s), this.renderer.setScissor(e, t, i, r); } setScissorTest(e) { (this.effectComposer.inputBuffer.scissorTest = e), (this.effectComposer.outputBuffer.scissorTest = e), this.renderer.setScissorTest(e); } setViewport(e, t, i, r) { e instanceof $e ? (this.effectComposer.inputBuffer.viewport.copy(e), this.effectComposer.outputBuffer.viewport.copy(e)) : (this.effectComposer.inputBuffer.viewport.set(e, t, i, r), this.effectComposer.outputBuffer.viewport.set(e, t, i, r)); } resize(e, t, i) { if ((this.effectComposer.setSize(e, t, i), this._rt)) { let r = this.renderer.getPixelRatio(); this._rt.setSize(e * r, t * r); } } dispose() { this.uvEffectPass?.dispose(), this.effectPass?.dispose(), this.effectComposer.dispose(); } }, iw = new ci(), QH = class extends Sw { constructor(e) { super(e), (this._pixelRatio = this.getPixelRatio()), (this.viewportWidth = 1), (this.viewportHeight = 1), (this.resolution = new G()), (this.pipeline = new YH(this)), (this.overrideTransmission = e?.overrideTransmission), (this.autoClear = !1); let t = this.setPixelRatio.bind(this), i = this.setSize.bind(this), r = this.getContext(); if (r && 'drawingBufferColorSpace' in r) try { r.drawingBufferColorSpace = 'display-p3'; } catch (s) { console.warn(s); } (this.setPixelRatio = (s) => { (this._pixelRatio = s), t(s); }), (this.setSize = (s, n, a = !0) => { (this.viewportWidth !== s || this.viewportHeight !== n) && ((this.viewportWidth = s), (this.viewportHeight = n), i(s, n, a), this.normalRenderTarget?.setSize(s * this._pixelRatio, n * this._pixelRatio), this.transmissionRenderTarget?.setSize((s * this._pixelRatio) / 2, (n * this._pixelRatio) / 2), this.transmissionDepthTarget?.setSize((s * this._pixelRatio) / 2, (n * this._pixelRatio) / 2), this.pipeline.resize(s, n, a)); }), (this._superDispose = this.dispose), (this.dispose = this._currentDispose); } createTransmissionRenderTarget() { this.transmissionRenderTarget === void 0 && ((this.transmissionRenderTarget = new ii( (this.viewportWidth * this._pixelRatio) / 2, (this.viewportHeight * this._pixelRatio) / 2, { generateMipmaps: !0, minFilter: Bo, magFilter: mt, wrapS: Ji, wrapT: Ji, depthBuffer: !1 } )), (this.transmissionDepthTarget = new ii((this.viewportWidth * this._pixelRatio) / 2, (this.viewportHeight * this._pixelRatio) / 2, { minFilter: Ot, magFilter: Ot, depthBuffer: !1 }))); } createNormalRenderTarget() { this.normalRenderTarget === void 0 && (this.normalRenderTarget = new ii(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio, { generateMipmaps: !1, minFilter: Ot, magFilter: Ot, type: vn, depthTexture: new pg(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio) })); } renderNormal(e, t) { this.normalRenderTarget && (this.setClearColor(0), t.layers.enable(8), t.layers.disable(0), t.layers.disable(3), this.setRenderTarget(this.normalRenderTarget), this.clear(), t instanceof Gi ? (ff.uniforms.depthContrast.value = (t.far - t.near) / 1e4) : (ff.uniforms.depthContrast.value = 1), (e.overrideMaterial = ff), this.render(e, t), this.setClearColor(e.bgColor, e.bgColor.a), this.setRenderTarget(null), (e.overrideMaterial = e.wireframeState ? qm : null), t.layers.enable(0), t.layers.enable(3)); } renderSplineScene(e, t, i, r, s) { this.setClearColor(e.bgColor, e.bgColor.a), i.penumbraSize.forEach((a, o) => { Lt.penumbraSize.value[o] = a; }), (Lt.pixelRatioNode.value = this.getPixelRatio()), this.resolution.x !== 0 && this.resolution.y !== 0 ? Lt.resolution.value.set(this.resolution.x, this.resolution.y) : Lt.resolution.value.set(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio), this.overrideNormal !== void 0 ? ((Lt.normalRenderTarget.value = this.overrideNormal), (Lt.normalRenderTargetDepth.value = iw)) : e.needsNormal() && (this.createNormalRenderTarget(), (Lt.normalRenderTarget.value = this.normalRenderTarget.texture), (Lt.normalRenderTargetDepth.value = this.normalRenderTarget.depthTexture), this.renderNormal(e, t)); let n = !1; if (this.overrideTransmission !== void 0) (Lt.transmissionRenderTarget.value = this.overrideTransmission), (Lt.transmissionRenderTargetDepth.value = iw), this.pipeline.setTransmissionPassEnabled(!1); else { let a = e.needsTransmission(); a && (this.transmissionRenderTarget === void 0 && (n = !0), this.createTransmissionRenderTarget(), (Lt.transmissionRenderTarget.value = this.transmissionRenderTarget.texture), (Lt.transmissionRenderTargetDepth.value = this.transmissionDepthTarget.texture)), this.pipeline.setTransmissionPassEnabled(a); } t.layers.enable(3), t.layers.enable(8), (this.pipeline.sceneHelpers = r), (this.pipeline.sceneHelpersOnTop = s), (this.pipeline.scene = e), (this.pipeline.camera = t), n && this.pipeline.transmissionPass.updatePasses(this), this.pipeline.postprocessingState !== e.postprocessing && this.pipeline.updatePostprocessing(e.postprocessing), this.clearAlphaOverride !== void 0 && this.setClearAlpha(this.clearAlphaOverride), (e.overrideMaterial = e.wireframeState ? qm : null), this.pipeline.render(); } _currentDispose() { this._superDispose(), this.pipeline.dispose(), this.transmissionRenderTarget?.dispose(), this.transmissionDepthTarget?.dispose(), this.normalRenderTarget?.dispose(), this.normalRenderTarget?.depthTexture?.dispose(); } }, ZH = class { get sharedAssets() { return this.shared; } constructor(e, t = {}) { (this.shared = new Eu(e.shared, t)), (this.scene = new sl(e.scene, this.sharedAssets)), this.scene.switchActiveCamera(this.scene.activeCamera); } reset(e, t) { this.scene.clearScene(), this.sharedAssets.reset(e.shared), this.scene.resetAfterClear(e.scene, this.sharedAssets); } dispose() { this.scene.dispose(), this.shared.dispose(); } gc() { this.shared.geometryCache.startGc(), this.shared.geometryCache2.startGc(), this.scene.traverseEntity((e) => { e instanceof Cr && e.markGeometryAsReachable(this.shared); }), this.shared.geometryCache.endGc(), this.shared.geometryCache2.endGc(); } }, KH = class { constructor({ x: e = 10, y: t = 10 }) { this._startTime = 0; let i = document.getElementById('spe-perfs'); i ? (this.element = i) : ((this.element = document.createElement('div')), document.body.appendChild(this.element), (this.element.style.position = 'absolute'), (this.element.style.zIndex = '10000'), (this.element.style.fontFamily = 'monospace'), (this.element.style.background = 'black'), (this.element.style.color = 'white'), (this.element.style.padding = '10px'), (this.element.style.opacity = '0.5'), (this.element.style.fontSize = '11px'), this.element.setAttribute('id', 'spe-perfs')), (this.element.style.left = `${e}px`), (this.element.style.top = `${t}px`); } dispose() { this.element.parentElement?.removeChild(this.element); } start() { this._startTime = performance.now(); } end() { let e = performance.now() - this._startTime; this.element.innerHTML = e.toFixed(3) + ' ms'; } }; function JH(e) { let t; if (e.index) for (let i = 0; i < e.index.array.length; i += 3) (t = e.index.array[i]), (e.index.array[i] = e.index.array[i + 2]), (e.index.array[i + 2] = t); } function ah(e) { return e instanceof Sh ? 'SubdivObject' : e.geometry.type === 'NonParametricGeometry' ? 'NonParametric' : 'Mesh'; } function $H(e, t) { let i = {}; return ( e.traverseEntity((r) => { if (!r.visible || !(r instanceof ar) || r.type !== 'Mesh' || Array.isArray(r.material) || (r.states && Object.keys(r.states).length)) return; let s = r.parent; for (; s; ) { if (s instanceof ar && r.states && Object.keys(r.states).length) return; s = s.parent; } let n = r.material.uuid, a = t.shared.materials[n]; if (a) { if (!nr.isMergable(a)) return; } else { let l = t.scene.objects.get(r.uuid)?.data; if (l && 'material' in l && typeof l.material != 'string') { if (!nr.isMergable(l.material)) return; n = nr.getHash(l.material); } } i[n] || (i[n] = {}); let o = i[n][ah(r)]; if (o) { if ((o.push(r), r.cloner)) for (let l of r.cloner.children) o.push(l); } else if (((i[n][ah(r)] = [r]), r.cloner)) for (let l of r.cloner.children) i[n][ah(r)].push(l); }), i ); } function e9(e) { let t = 0; return ( Object.values(e).forEach((i) => { Object.values(i).forEach((r) => { let s = r.length; s > t && (t = s); }); }), t ); } function t9(e, t) { let i = $H(t, e), r = e9(i), s = new Array(r), n = 0, a = new Array(r), o = 0, l = new Array(r), h = 0, u = new Array(r), c = 0; for (let [d, p] of Object.entries(i)) for (let f of Object.values(p)) { if ( ((o = 0), (h = 0), f.forEach((m) => { m instanceof ar && ((a[o++] = m.geometry.clone()), (l[h++] = m)); }), h < 2) ) continue; for (let m = 0; m < h; m++) l[m].updateWorldMatrix(!0, !1), a[m].applyMatrix4(l[m].matrixWorld), l[m].matrixWorld.determinant() < 0 && JH(a[m]); let g = go(a.slice(0, o), !1); if (g) { let m; switch (d) { case 'SubdivObject': { console.warn('Turning subdiv object into mesh'), (m = new tr(g, l[0].material)); break; } default: { m = new tr(g, l[0].material); break; } } (m.castShadow = l[0].castShadow), (m.receiveShadow = l[0].receiveShadow), t.add(m); let v = (y) => { c = 0; for (let b of y) b.children && v(b.children), b instanceof ar && (Array.isArray(b.material) || (i[b.material.uuid] && i[b.material.uuid][ah(b)] && i[b.material.uuid][ah(b)].length > 1) || (u[c++] = b)); for (let b = 0; b < c; b++) t.attach(u[b]); }; for (let y = 0; y < h; y++) { let b = l[y]; v(b.children), (s[n++] = b); } } } for (let d = 0; d < n; d++) s[d].removeFromParent(); } var i9 = Eh(q2(), 1), r9 = new G(); function s9(e) { let t = 'The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.'; e.endsWith('.spline') ? console.warn(t + ' The .spline files are only meant to be used by the Editor.') : e.endsWith('.splinecode') || console.warn(t); } var Iv = class { constructor(e, { renderOnDemand: t = !0 } = {}) { (this._viewportMode = 1), (this._viewportWidth = window.innerWidth), (this._viewportHeight = window.innerHeight), (this._proxyObjectCache = new Map()), (this._lastTime = performance.now()), (this.time = performance.now()), (this.dt = 0), (this._skipRender = !1), (this.renderOnDemand = !0), (this.disposed = !1), (this.requestRender = () => { this._skipRender = !1; }), (this.render = (i) => { !this._renderer || ((this._rafId = requestAnimationFrame(this.render)), (this.time = i), (this.dt = this.time - this._lastTime), (this._lastTime = this.time), this._perfs?.start(), !(this.renderOnDemand && this._skipRender) && ((this._skipRender = this._controls?.update(this.dt) ?? !0), this._eventManager && (this._eventManager.isEnable || this._eventManager.activate(), this._eventManager.handlers.Follow.onAnimationFrameDamping(), this._eventManager.handlers.LookAt.onAnimationFrameDamping(), (this._eventManager.handlers.Start.hasVideoAction || this._eventManager.handlers.Basic.hasVideoAction || this._eventManager.handlers.Conditional.hasVideoAction) && (this._skipRender = !1)), this._scene && this._camera && (this._scene.pathConstraints.applyConstraints(this._scene), this._renderer.renderSplineScene(this._scene, this._camera, this._sharedAssetsManager)), this._perfs?.end())); }), (this._resize = __(() => { !this._renderer || (this._viewportMode === 1 && this._frameView && (this._frameView.frameSize = r9.set(this._viewportWidth, this._viewportHeight)), this._renderer.setSize(this._viewportWidth, this._viewportHeight, !1), this._camera && (this._frameView?.updateCamera(), this._camera.cameraType === 'PerspectiveCamera' && (this._camera.aspect = this._viewportWidth / this._viewportHeight), this._camera.updateProjectionMatrix()), this.requestRender()); }, 10)), (this.canvas = e), (this.renderOnDemand = t), window.location.search.includes('perfs') && (this._perfs = new KH({ x: 10, y: 10 })), iU(e); } async load(e, t) { s9(e), (this.disposed = !1); let i = await (await fetch(e, t)).arrayBuffer(); await this.start(i); } async start(e, { interactive: t = !0 } = {}) { if (this.disposed) return; let i = await fV(e); (this._data = i), i.version && (0, i9.default)(i.version, '0.9.297') > 0 && console.warn('Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version.'), await Promise.all([rb(i) && R6(), Xk(i) && L6(), i.scene.environment.usePhysics && xN(), Jx(i) && Ik()].filter(Boolean)), this._eventManager && this._eventManager.deactivate(), this._controls && this._controls.dispose(), this._scene?.dispose(); let r = new ZH(i); if ( ((this._scene = r.scene), (this._sharedAssetsManager = r.sharedAssets), (this._camera = this._scene.activeCamera), window.location.search.includes('merge-geometries')) ) { let s = performance.now(); t9(i, r.scene); let n = performance.now(); console.log('Merged geometries in ', n - s, ' ms'); } if ( (rb(i) && this._scene.traverse((s) => { Sn(s) && s.recomputeBoolean(); }), this._sharedAssetsManager.setRequestRender(() => { this.requestRender(), this._scene?.traverse((s) => { s instanceof eu && s.pendingMediaLoad && s.update(); }); }), Jx(i) && HG(i)) ) { let s = Object.keys(i.shared.fonts) .map((n) => this._sharedAssetsManager.getFont(n)) .map((n) => n.loadingPromise); await Promise.all(s); } if ( (this._scene.rewriteEventsBeforeGoToPlayMode(), i2(i.scene, this._scene, this._sharedAssetsManager), this._renderer || ((this._renderer = new QH({ canvas: this.canvas, antialias: !1, alpha: !0, stencil: !1, depth: !1, powerPreference: 'high-performance' })), this._renderer.setPixelRatio(window.devicePixelRatio), this._renderer.pipeline.addEventListener('smaaloaded', this.requestRender), (this._renderer.shadowMap.enabled = !0), (this._renderer.shadowMap.type = i.scene.environment.ambientLight.softShadows ? og : sw), I8(i.scene.environment.ambientLight.softShadowQuality)), this._frameView) ) this._frameView.setCamera(this._camera); else { let s = Object.values(i.frames)[0]; s.preset === 'fullscreen' ? ((this._viewportMode = 1), this.canvas.parentElement && ((this._viewportWidth = this.canvas.parentElement.clientWidth || 300), (this.canvas.style.width = '100%')), this.canvas.parentElement && ((this._viewportHeight = this.canvas.parentElement.clientHeight || 150), (this.canvas.style.height = '100%'))) : ((this._viewportMode = 2), (this._viewportWidth = s.size[0]), (this._viewportHeight = s.size[1]), (this.canvas.style.width = `${this._viewportWidth}px`), (this.canvas.style.height = `${this._viewportHeight}px`)), this._renderer.setSize(this._viewportWidth, this._viewportHeight, !1), (this._frameView = new gV( this._renderer, this._camera, new G(this._viewportWidth, this._viewportHeight), new G(window.innerWidth, window.innerHeight) )); } if ( (t && (this._scene.updateMatrixWorld(!0), (this._controls = new WG(i, this._scene, this._renderer, this.requestRender, this._sharedAssetsManager, !0)), (this._eventManager = new mV( this._renderer, this._scene, this._camera, i.scene.publish.stopRaycast, i.scene.publish.preventScroll, i.scene.publish.preventTouchScroll, i.scene.publish.hideCursor, this._sharedAssetsManager, this.requestRender, this._controls, !0 ))), this._resize(), !this._resizeObserver && this.canvas.parentElement) ) { let s = !0; (this._resizeObserver = new ResizeObserver(() => { if (s) { s = !1; return; } (this._viewportWidth = this.canvas.clientWidth), (this._viewportHeight = this.canvas.clientHeight), this._resize(); })), this._resizeObserver.observe(this.canvas.parentElement); } this._rafId === void 0 ? this.render(performance.now()) : this.requestRender(); } findObjectById(e) { let t = this._scene?.getObjectByProperty('uuid', e); return this._createProxyObject(t); } findObjectByName(e) { let t = this._scene?.getObjectByName(e); return this._createProxyObject(t); } getSplineEvents() { return (this._eventManager?.handlers.Spline).splineEvents; } emitEvent(e, t) { (this.findObjectById(t) || this.findObjectByName(t))?.emitEvent(e); } emitEventReverse(e, t) { (this.findObjectById(t) || this.findObjectByName(t))?.emitEventReverse(e); } addEventListener(e, t) { this.canvas.addEventListener(e, t); } removeEventListener(e, t) { this.canvas.removeEventListener(e, t); } setZoom(e) { this._controls?.orbitControls instanceof l2 && this._controls?.orbitControls.zoomOut(e); } get eventManager() { return this._eventManager; } get controls() { return this._controls; } setSize(e, t) { (this._viewportWidth = e), (this._viewportHeight = t), (this._viewportMode = 2), this._resize(); } setBackgroundColor(e) { let { r: t, g: i, b: r, a: s } = { r: 0, g: 0, b: 0, a: 1 }, n = new ji(t, i, r, s); try { n.setStyle(e); } catch { console.error('This is not a valid css color', e); } this._scene?.setBackgroundColor(n), this.requestRender(); } dispose() { (this.disposed = !0), this._eventManager?.deactivate(), this._scene?.dispose(), this._sharedAssetsManager?.dispose(), this._rafId && cancelAnimationFrame(this._rafId), this._proxyObjectCache.forEach((e) => { zy.unsubscribe(e); }), this._renderer?.dispose(), this._sharedAssetsManager?.dispose(), this._resizeObserver && (this._resizeObserver.disconnect(), (this._resizeObserver = void 0)), (this.canvas.style.width = ''), (this.canvas.style.height = ''), this.canvas.removeAttribute('width'), this.canvas.removeAttribute('height'), this._frameView && (this._frameView = void 0), this._controls?.dispose(), rU(this.canvas); } get data() { return this._data; } _createProxyObject(e) { if (e == null) return; if (this._proxyObjectCache.has(e.uuid)) return this._proxyObjectCache.get(e.uuid); let t = { name: e.name, uuid: e.uuid, visible: e.visible, intensity: e.intensity, position: e.position, rotation: e.rotation, scale: e.scale, emitEvent(r) { e.dispatchEvent({ type: 'userEvent', eventName: r }); }, emitEventReverse(r) { e.dispatchEvent({ type: 'userEvent', eventName: r, reverse: !0 }); } }, i = zy(t, (r, s) => { typeof e[r] != 'object' && Object.getOwnPropertyDescriptor(e, r)?.writable && (e[r] = s), this.requestRender(), e.updateMatrix(); }); return this._proxyObjectCache.set(e.uuid, i), i; } }; var Iu = window, Ru = Iu.ShadowRoot && (Iu.ShadyCSS === void 0 || Iu.ShadyCSS.nativeShadow) && 'adoptedStyleSheets' in Document.prototype && 'replace' in CSSStyleSheet.prototype, Rv = Symbol(), p2 = new WeakMap(), kh = class { constructor(t, i, r) { if (((this._$cssResult$ = !0), r !== Rv)) throw Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'); (this.cssText = t), (this.t = i); } get styleSheet() { let t = this.o, i = this.t; if (Ru && t === void 0) { let r = i !== void 0 && i.length === 1; r && (t = p2.get(i)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && p2.set(i, t)); } return t; } toString() { return this.cssText; } }, f2 = (e) => new kh(typeof e == 'string' ? e : e + '', void 0, Rv), Bv = (e, ...t) => { let i = e.length === 1 ? e[0] : t.reduce( (r, s, n) => r + ((a) => { if (a._$cssResult$ === !0) return a.cssText; if (typeof a == 'number') return a; throw Error( "Value passed to 'css' function must be a 'css' function result: " + a + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security." ); })(s) + e[n + 1], e[0] ); return new kh(i, e, Rv); }, zv = (e, t) => { Ru ? (e.adoptedStyleSheets = t.map((i) => (i instanceof CSSStyleSheet ? i : i.styleSheet))) : t.forEach((i) => { let r = document.createElement('style'), s = Iu.litNonce; s !== void 0 && r.setAttribute('nonce', s), (r.textContent = i.cssText), e.appendChild(r); }); }, Bu = Ru ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => { let i = ''; for (let r of t.cssRules) i += r.cssText; return f2(i); })(e) : e; var Nv, zu = window, m2 = zu.trustedTypes, n9 = m2 ? m2.emptyScript : '', g2 = zu.reactiveElementPolyfillSupport, Fv = { toAttribute(e, t) { switch (t) { case Boolean: e = e ? n9 : null; break; case Object: case Array: e = e == null ? e : JSON.stringify(e); } return e; }, fromAttribute(e, t) { let i = e; switch (t) { case Boolean: i = e !== null; break; case Number: i = e === null ? null : Number(e); break; case Object: case Array: try { i = JSON.parse(e); } catch { i = null; } } return i; } }, v2 = (e, t) => t !== e && (t == t || e == e), Uv = { attribute: !0, type: String, converter: Fv, reflect: !1, hasChanged: v2 }, Zs = class extends HTMLElement { constructor() { super(), (this._$Ei = new Map()), (this.isUpdatePending = !1), (this.hasUpdated = !1), (this._$El = null), this.u(); } static addInitializer(t) { var i; this.finalize(), ((i = this.h) !== null && i !== void 0 ? i : (this.h = [])).push(t); } static get observedAttributes() { this.finalize(); let t = []; return ( this.elementProperties.forEach((i, r) => { let s = this._$Ep(r, i); s !== void 0 && (this._$Ev.set(s, r), t.push(s)); }), t ); } static createProperty(t, i = Uv) { if ( (i.state && (i.attribute = !1), this.finalize(), this.elementProperties.set(t, i), !i.noAccessor && !this.prototype.hasOwnProperty(t)) ) { let r = typeof t == 'symbol' ? Symbol() : '__' + t, s = this.getPropertyDescriptor(t, r, i); s !== void 0 && Object.defineProperty(this.prototype, t, s); } } static getPropertyDescriptor(t, i, r) { return { get() { return this[i]; }, set(s) { let n = this[t]; (this[i] = s), this.requestUpdate(t, n, r); }, configurable: !0, enumerable: !0 }; } static getPropertyOptions(t) { return this.elementProperties.get(t) || Uv; } static finalize() { if (this.hasOwnProperty('finalized')) return !1; this.finalized = !0; let t = Object.getPrototypeOf(this); if ( (t.finalize(), t.h !== void 0 && (this.h = [...t.h]), (this.elementProperties = new Map(t.elementProperties)), (this._$Ev = new Map()), this.hasOwnProperty('properties')) ) { let i = this.properties, r = [...Object.getOwnPropertyNames(i), ...Object.getOwnPropertySymbols(i)]; for (let s of r) this.createProperty(s, i[s]); } return (this.elementStyles = this.finalizeStyles(this.styles)), !0; } static finalizeStyles(t) { let i = []; if (Array.isArray(t)) { let r = new Set(t.flat(1 / 0).reverse()); for (let s of r) i.unshift(Bu(s)); } else t !== void 0 && i.push(Bu(t)); return i; } static _$Ep(t, i) { let r = i.attribute; return r === !1 ? void 0 : typeof r == 'string' ? r : typeof t == 'string' ? t.toLowerCase() : void 0; } u() { var t; (this._$E_ = new Promise((i) => (this.enableUpdating = i))), (this._$AL = new Map()), this._$Eg(), this.requestUpdate(), (t = this.constructor.h) === null || t === void 0 || t.forEach((i) => i(this)); } addController(t) { var i, r; ((i = this._$ES) !== null && i !== void 0 ? i : (this._$ES = [])).push(t), this.renderRoot !== void 0 && this.isConnected && ((r = t.hostConnected) === null || r === void 0 || r.call(t)); } removeController(t) { var i; (i = this._$ES) === null || i === void 0 || i.splice(this._$ES.indexOf(t) >>> 0, 1); } _$Eg() { this.constructor.elementProperties.forEach((t, i) => { this.hasOwnProperty(i) && (this._$Ei.set(i, this[i]), delete this[i]); }); } createRenderRoot() { var t; let i = (t = this.shadowRoot) !== null && t !== void 0 ? t : this.attachShadow(this.constructor.shadowRootOptions); return zv(i, this.constructor.elementStyles), i; } connectedCallback() { var t; this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$ES) === null || t === void 0 || t.forEach((i) => { var r; return (r = i.hostConnected) === null || r === void 0 ? void 0 : r.call(i); }); } enableUpdating(t) {} disconnectedCallback() { var t; (t = this._$ES) === null || t === void 0 || t.forEach((i) => { var r; return (r = i.hostDisconnected) === null || r === void 0 ? void 0 : r.call(i); }); } attributeChangedCallback(t, i, r) { this._$AK(t, r); } _$EO(t, i, r = Uv) { var s; let n = this.constructor._$Ep(t, r); if (n !== void 0 && r.reflect === !0) { let a = (((s = r.converter) === null || s === void 0 ? void 0 : s.toAttribute) !== void 0 ? r.converter : Fv).toAttribute( i, r.type ); (this._$El = t), a == null ? this.removeAttribute(n) : this.setAttribute(n, a), (this._$El = null); } } _$AK(t, i) { var r; let s = this.constructor, n = s._$Ev.get(t); if (n !== void 0 && this._$El !== n) { let a = s.getPropertyOptions(n), o = typeof a.converter == 'function' ? { fromAttribute: a.converter } : ((r = a.converter) === null || r === void 0 ? void 0 : r.fromAttribute) !== void 0 ? a.converter : Fv; (this._$El = n), (this[n] = o.fromAttribute(i, a.type)), (this._$El = null); } } requestUpdate(t, i, r) { let s = !0; t !== void 0 && (((r = r || this.constructor.getPropertyOptions(t)).hasChanged || v2)(this[t], i) ? (this._$AL.has(t) || this._$AL.set(t, i), r.reflect === !0 && this._$El !== t && (this._$EC === void 0 && (this._$EC = new Map()), this._$EC.set(t, r))) : (s = !1)), !this.isUpdatePending && s && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = !0; try { await this._$E_; } catch (i) { Promise.reject(i); } let t = this.scheduleUpdate(); return t != null && (await t), !this.isUpdatePending; } scheduleUpdate() { return this.performUpdate(); } performUpdate() { var t; if (!this.isUpdatePending) return; this.hasUpdated, this._$Ei && (this._$Ei.forEach((s, n) => (this[n] = s)), (this._$Ei = void 0)); let i = !1, r = this._$AL; try { (i = this.shouldUpdate(r)), i ? (this.willUpdate(r), (t = this._$ES) === null || t === void 0 || t.forEach((s) => { var n; return (n = s.hostUpdate) === null || n === void 0 ? void 0 : n.call(s); }), this.update(r)) : this._$Ek(); } catch (s) { throw ((i = !1), this._$Ek(), s); } i && this._$AE(r); } willUpdate(t) {} _$AE(t) { var i; (i = this._$ES) === null || i === void 0 || i.forEach((r) => { var s; return (s = r.hostUpdated) === null || s === void 0 ? void 0 : s.call(r); }), this.hasUpdated || ((this.hasUpdated = !0), this.firstUpdated(t)), this.updated(t); } _$Ek() { (this._$AL = new Map()), (this.isUpdatePending = !1); } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this._$E_; } shouldUpdate(t) { return !0; } update(t) { this._$EC !== void 0 && (this._$EC.forEach((i, r) => this._$EO(r, this[r], i)), (this._$EC = void 0)), this._$Ek(); } updated(t) {} firstUpdated(t) {} }; (Zs.finalized = !0), (Zs.elementProperties = new Map()), (Zs.elementStyles = []), (Zs.shadowRootOptions = { mode: 'open' }), g2?.({ ReactiveElement: Zs }), ((Nv = zu.reactiveElementVersions) !== null && Nv !== void 0 ? Nv : (zu.reactiveElementVersions = [])).push('1.6.0'); var kv, Nu = window, al = Nu.trustedTypes, y2 = al ? al.createPolicy('lit-html', { createHTML: (e) => e }) : void 0, Un = `lit$${(Math.random() + '').slice(9)}$`, M2 = '?' + Un, a9 = `<${M2}>`, ol = document, Gh = (e = '') => ol.createComment(e), Vh = (e) => e === null || (typeof e != 'object' && typeof e != 'function'), E2 = Array.isArray, o9 = (e) => E2(e) || typeof e?.[Symbol.iterator] == 'function', jh = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, x2 = /-->/g, b2 = />/g, Da = RegExp( `>|[ \f\r](?:([^\\s"'>=/]+)([ \f\r]*=[ \f\r]*(?:[^ \f\r"'\`<>=]|("|')|))|$)`, 'g' ), w2 = /'/g, _2 = /"/g, C2 = /^(?:script|style|textarea|title)$/i, T2 = (e) => (t, ...i) => ({ _$litType$: e, strings: t, values: i }), P2 = T2(1), UK = T2(2), La = Symbol.for('lit-noChange'), ui = Symbol.for('lit-nothing'), A2 = new WeakMap(), nl = ol.createTreeWalker(ol, 129, null, !1), l9 = (e, t) => { let i = e.length - 1, r = [], s, n = t === 2 ? '' : '', a = jh; for (let l = 0; l < i; l++) { let h = e[l], u, c, d = -1, p = 0; for (; p < h.length && ((a.lastIndex = p), (c = a.exec(h)), c !== null); ) (p = a.lastIndex), a === jh ? c[1] === '!--' ? (a = x2) : c[1] !== void 0 ? (a = b2) : c[2] !== void 0 ? (C2.test(c[2]) && (s = RegExp('' ? ((a = s ?? jh), (d = -1)) : c[1] === void 0 ? (d = -2) : ((d = a.lastIndex - c[2].length), (u = c[1]), (a = c[3] === void 0 ? Da : c[3] === '"' ? _2 : w2)) : a === _2 || a === w2 ? (a = Da) : a === x2 || a === b2 ? (a = jh) : ((a = Da), (s = void 0)); let f = a === Da && e[l + 1].startsWith('/>') ? ' ' : ''; n += a === jh ? h + a9 : d >= 0 ? (r.push(u), h.slice(0, d) + '$lit$' + h.slice(d) + Un + f) : h + Un + (d === -2 ? (r.push(void 0), l) : f); } let o = n + (e[i] || '') + (t === 2 ? '' : ''); if (!Array.isArray(e) || !e.hasOwnProperty('raw')) throw Error('invalid template strings array'); return [y2 !== void 0 ? y2.createHTML(o) : o, r]; }, Oa = class { constructor({ strings: t, _$litType$: i }, r) { let s; this.parts = []; let n = 0, a = 0, o = t.length - 1, l = this.parts, [h, u] = l9(t, i); if (((this.el = Oa.createElement(h, r)), (nl.currentNode = this.el.content), i === 2)) { let c = this.el.content, d = c.firstChild; d.remove(), c.append(...d.childNodes); } for (; (s = nl.nextNode()) !== null && l.length < o; ) { if (s.nodeType === 1) { if (s.hasAttributes()) { let c = []; for (let d of s.getAttributeNames()) if (d.endsWith('$lit$') || d.startsWith(Un)) { let p = u[a++]; if ((c.push(d), p !== void 0)) { let f = s.getAttribute(p.toLowerCase() + '$lit$').split(Un), g = /([.?@])?(.*)/.exec(p); l.push({ type: 1, index: n, name: g[2], strings: f, ctor: g[1] === '.' ? Gv : g[1] === '?' ? Vv : g[1] === '@' ? Hv : hl }); } else l.push({ type: 6, index: n }); } for (let d of c) s.removeAttribute(d); } if (C2.test(s.tagName)) { let c = s.textContent.split(Un), d = c.length - 1; if (d > 0) { s.textContent = al ? al.emptyScript : ''; for (let p = 0; p < d; p++) s.append(c[p], Gh()), nl.nextNode(), l.push({ type: 2, index: ++n }); s.append(c[d], Gh()); } } } else if (s.nodeType === 8) if (s.data === M2) l.push({ type: 2, index: n }); else { let c = -1; for (; (c = s.data.indexOf(Un, c + 1)) !== -1; ) l.push({ type: 7, index: n }), (c += Un.length - 1); } n++; } } static createElement(t, i) { let r = ol.createElement('template'); return (r.innerHTML = t), r; } }; function ll(e, t, i = e, r) { var s, n, a, o; if (t === La) return t; let l = r !== void 0 ? ((s = i._$Co) === null || s === void 0 ? void 0 : s[r]) : i._$Cl, h = Vh(t) ? void 0 : t._$litDirective$; return ( l?.constructor !== h && ((n = l?._$AO) === null || n === void 0 || n.call(l, !1), h === void 0 ? (l = void 0) : ((l = new h(e)), l._$AT(e, i, r)), r !== void 0 ? (((a = (o = i)._$Co) !== null && a !== void 0 ? a : (o._$Co = []))[r] = l) : (i._$Cl = l)), l !== void 0 && (t = ll(e, l._$AS(e, t.values), l, r)), t ); } var jv = class { constructor(t, i) { (this.u = []), (this._$AN = void 0), (this._$AD = t), (this._$AM = i); } get parentNode() { return this._$AM.parentNode; } get _$AU() { return this._$AM._$AU; } v(t) { var i; let { el: { content: r }, parts: s } = this._$AD, n = ((i = t?.creationScope) !== null && i !== void 0 ? i : ol).importNode(r, !0); nl.currentNode = n; let a = nl.nextNode(), o = 0, l = 0, h = s[0]; for (; h !== void 0; ) { if (o === h.index) { let u; h.type === 2 ? (u = new Ia(a, a.nextSibling, this, t)) : h.type === 1 ? (u = new h.ctor(a, h.name, h.strings, this, t)) : h.type === 6 && (u = new Wv(a, this, t)), this.u.push(u), (h = s[++l]); } o !== h?.index && ((a = nl.nextNode()), o++); } return n; } p(t) { let i = 0; for (let r of this.u) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, i), (i += r.strings.length - 2)) : r._$AI(t[i])), i++; } }, Ia = class { constructor(t, i, r, s) { var n; (this.type = 2), (this._$AH = ui), (this._$AN = void 0), (this._$AA = t), (this._$AB = i), (this._$AM = r), (this.options = s), (this._$Cm = (n = s?.isConnected) === null || n === void 0 || n); } get _$AU() { var t, i; return (i = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && i !== void 0 ? i : this._$Cm; } get parentNode() { let t = this._$AA.parentNode, i = this._$AM; return i !== void 0 && t.nodeType === 11 && (t = i.parentNode), t; } get startNode() { return this._$AA; } get endNode() { return this._$AB; } _$AI(t, i = this) { (t = ll(this, t, i)), Vh(t) ? t === ui || t == null || t === '' ? (this._$AH !== ui && this._$AR(), (this._$AH = ui)) : t !== this._$AH && t !== La && this.g(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : o9(t) ? this.k(t) : this.g(t); } O(t, i = this._$AB) { return this._$AA.parentNode.insertBefore(t, i); } T(t) { this._$AH !== t && (this._$AR(), (this._$AH = this.O(t))); } g(t) { this._$AH !== ui && Vh(this._$AH) ? (this._$AA.nextSibling.data = t) : this.T(ol.createTextNode(t)), (this._$AH = t); } $(t) { var i; let { values: r, _$litType$: s } = t, n = typeof s == 'number' ? this._$AC(t) : (s.el === void 0 && (s.el = Oa.createElement(s.h, this.options)), s); if (((i = this._$AH) === null || i === void 0 ? void 0 : i._$AD) === n) this._$AH.p(r); else { let a = new jv(n, this), o = a.v(this.options); a.p(r), this.T(o), (this._$AH = a); } } _$AC(t) { let i = A2.get(t.strings); return i === void 0 && A2.set(t.strings, (i = new Oa(t))), i; } k(t) { E2(this._$AH) || ((this._$AH = []), this._$AR()); let i = this._$AH, r, s = 0; for (let n of t) s === i.length ? i.push((r = new Ia(this.O(Gh()), this.O(Gh()), this, this.options))) : (r = i[s]), r._$AI(n), s++; s < i.length && (this._$AR(r && r._$AB.nextSibling, s), (i.length = s)); } _$AR(t = this._$AA.nextSibling, i) { var r; for ((r = this._$AP) === null || r === void 0 || r.call(this, !1, !0, i); t && t !== this._$AB; ) { let s = t.nextSibling; t.remove(), (t = s); } } setConnected(t) { var i; this._$AM === void 0 && ((this._$Cm = t), (i = this._$AP) === null || i === void 0 || i.call(this, t)); } }, hl = class { constructor(t, i, r, s, n) { (this.type = 1), (this._$AH = ui), (this._$AN = void 0), (this.element = t), (this.name = i), (this._$AM = s), (this.options = n), r.length > 2 || r[0] !== '' || r[1] !== '' ? ((this._$AH = Array(r.length - 1).fill(new String())), (this.strings = r)) : (this._$AH = ui); } get tagName() { return this.element.tagName; } get _$AU() { return this._$AM._$AU; } _$AI(t, i = this, r, s) { let n = this.strings, a = !1; if (n === void 0) (t = ll(this, t, i, 0)), (a = !Vh(t) || (t !== this._$AH && t !== La)), a && (this._$AH = t); else { let o = t, l, h; for (t = n[0], l = 0; l < n.length - 1; l++) (h = ll(this, o[r + l], i, l)), h === La && (h = this._$AH[l]), a || (a = !Vh(h) || h !== this._$AH[l]), h === ui ? (t = ui) : t !== ui && (t += (h ?? '') + n[l + 1]), (this._$AH[l] = h); } a && !s && this.j(t); } j(t) { t === ui ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ''); } }, Gv = class extends hl { constructor() { super(...arguments), (this.type = 3); } j(t) { this.element[this.name] = t === ui ? void 0 : t; } }, h9 = al ? al.emptyScript : '', Vv = class extends hl { constructor() { super(...arguments), (this.type = 4); } j(t) { t && t !== ui ? this.element.setAttribute(this.name, h9) : this.element.removeAttribute(this.name); } }, Hv = class extends hl { constructor(t, i, r, s, n) { super(t, i, r, s, n), (this.type = 5); } _$AI(t, i = this) { var r; if ((t = (r = ll(this, t, i, 0)) !== null && r !== void 0 ? r : ui) === La) return; let s = this._$AH, n = (t === ui && s !== ui) || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, a = t !== ui && (s === ui || n); n && this.element.removeEventListener(this.name, this, s), a && this.element.addEventListener(this.name, this, t), (this._$AH = t); } handleEvent(t) { var i, r; typeof this._$AH == 'function' ? this._$AH.call((r = (i = this.options) === null || i === void 0 ? void 0 : i.host) !== null && r !== void 0 ? r : this.element, t) : this._$AH.handleEvent(t); } }, Wv = class { constructor(t, i, r) { (this.element = t), (this.type = 6), (this._$AN = void 0), (this._$AM = i), (this.options = r); } get _$AU() { return this._$AM._$AU; } _$AI(t) { ll(this, t); } }; var S2 = Nu.litHtmlPolyfillSupport; S2?.(Oa, Ia), ((kv = Nu.litHtmlVersions) !== null && kv !== void 0 ? kv : (Nu.litHtmlVersions = [])).push('2.6.0'); var Uu = (e, t, i) => { var r, s; let n = (r = i?.renderBefore) !== null && r !== void 0 ? r : t, a = n._$litPart$; if (a === void 0) { let o = (s = i?.renderBefore) !== null && s !== void 0 ? s : null; n._$litPart$ = a = new Ia(t.insertBefore(Gh(), o), o, void 0, i ?? {}); } return a._$AI(e), a; }; var Xv, qv; var Fn = class extends Zs { constructor() { super(...arguments), (this.renderOptions = { host: this }), (this._$Do = void 0); } createRenderRoot() { var t, i; let r = super.createRenderRoot(); return ((t = (i = this.renderOptions).renderBefore) !== null && t !== void 0) || (i.renderBefore = r.firstChild), r; } update(t) { let i = this.render(); this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), (this._$Do = Uu(i, this.renderRoot, this.renderOptions)); } connectedCallback() { var t; super.connectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!0); } disconnectedCallback() { var t; super.disconnectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!1); } render() { return La; } }; (Fn.finalized = !0), (Fn._$litElement$ = !0), (Xv = globalThis.litElementHydrateSupport) === null || Xv === void 0 || Xv.call(globalThis, { LitElement: Fn }); var D2 = globalThis.litElementPolyfillSupport; D2?.({ LitElement: Fn }); ((qv = globalThis.litElementVersions) !== null && qv !== void 0 ? qv : (globalThis.litElementVersions = [])).push('3.2.2'); var L2 = (e) => (t) => typeof t == 'function' ? ((i, r) => (customElements.define(i, r), r))(e, t) : ((i, r) => { let { kind: s, elements: n } = r; return { kind: s, elements: n, finisher(a) { customElements.define(i, a); } }; })(e, t); var c9 = (e, t) => t.kind === 'method' && t.descriptor && !('value' in t.descriptor) ? { ...t, finisher(i) { i.createProperty(t.key, e); } } : { kind: 'field', key: Symbol(), placement: 'own', descriptor: {}, originalKey: t.key, initializer() { typeof t.initializer == 'function' && (this[t.key] = t.initializer.call(this)); }, finisher(i) { i.createProperty(t.key, e); } }; function Wr(e) { return (t, i) => i !== void 0 ? ((r, s, n) => { s.constructor.createProperty(n, r); })(e, t, i) : c9(e, t); } var Yv, dJ = ((Yv = window.HTMLSlotElement) === null || Yv === void 0 ? void 0 : Yv.prototype.assignedElements) != null ? (e, t) => e.assignedElements(t) : (e, t) => e.assignedNodes(t).filter((i) => i.nodeType === Node.ELEMENT_NODE); var Fu = window.IntersectionObserver != null; var d9 = P2` `, Hi = class extends Fn { constructor() { super(); this.url = null; this.width = void 0; this.height = void 0; this.background = void 0; this.loading = 'auto'; this.unloadable = !1; this.eventsTarget = void 0; this.loadingAnim = !1; this._intersectionObserver = null; this._isElementInViewport = !1; this._loaded = !1; this._loadedUrl = null; this._wasContextLost = !1; this._handleContextLost = () => { (this._wasContextLost = !0), (this._loadedUrl = null), this._spline.dispose(), this._isElementInViewport && this.load(), this.dispatchEvent(new CustomEvent('context-loss', { detail: {} })); }; this._handleContextRestored = () => {}; this.onLoaded = () => { (this._loaded = !0), this.eventsTarget !== void 0 && this._spline.eventManager.updateUseWindowEvents(this.eventsTarget === 'global'), this.background !== void 0 && this._spline?.setBackgroundColor(this.background), this._spline?.data.scene.publish.settings.web.logo !== !1 && (this._logo.style.display = 'flex'), this.loadingAnim && (this._preloader.style.display = 'none'), setTimeout(() => { this._canvas.style.visibility = 'visible'; }), this.dispatchEvent(new CustomEvent('load-complete', { detail: { url: this.url } })), (this.hint ?? this._spline.data.scene.publish.settings.web.hint) && (this._canvas.addEventListener('pointerdown', this.onInteract), this._canvas.addEventListener('pointerup', this.onInteract), (this._hintDrag.style.display = 'block')); }; this.onInteract = () => { this._canvas.removeEventListener('pointerdown', this.onInteract), this._canvas.removeEventListener('pointerup', this.onInteract), (this._hintDrag.style.display = 'none'); }; this.attachShadow({ mode: 'open' }); let i = this.shadowRoot; Uu(d9, i), (this._container = i.querySelector('#container')), (this._canvas = i.querySelector('#spline')), (this._logo = i.querySelector('#logo')), (this._hintDrag = i.querySelector('#hint-drag')), (this._preloader = i.querySelector('#preloader')), this._canvas.addEventListener('webglcontextlost', this._handleContextLost), this._canvas.addEventListener('webglcontextrestored', this._handleContextRestored), (this._spline = new Iv(this._canvas)), Fu ? (this._intersectionObserver = new IntersectionObserver( (r) => { for (let s of r) s.target === this && ((this._isElementInViewport = s.isIntersecting), this._isElementInViewport && (!this._loaded || this._wasContextLost) ? this.load() : this.unloadable && !this._isElementInViewport && this._loaded && this.unload(), this.dispatchEvent(new CustomEvent('viewport-intersection', { detail: { intersection: this._isElementInViewport } }))); }, { root: null, rootMargin: '0px', threshold: 1e-5 } )) : (this._isElementInViewport = !0); } unload() { !this._loaded || ((this._loaded = !1), (this._loadedUrl = null), this._spline.dispose(), this.dispatchEvent(new CustomEvent('unload', { detail: {} }))); } recreateCanvas() { let i = this._canvas; i.removeEventListener('pointerdown', this.onInteract), i.removeEventListener('pointerup', this.onInteract), i.removeEventListener('webglcontextlost', this._handleContextLost), i.removeEventListener('webglcontextrestored', this._handleContextRestored); let r = document.createElement('canvas'); this._container.insertBefore(r, this._canvas), this._container.removeChild(this._canvas), r.setAttribute('id', 'spline'), (this._canvas = r), this._canvas.addEventListener('webglcontextlost', this._handleContextLost), this._canvas.addEventListener('webglcontextrestored', this._handleContextRestored), (this._spline = new Iv(this._canvas)); } load() { (this._loaded && !this._wasContextLost) || (!this._isElementInViewport && this.loading !== 'eager') || !this.url || this.url === this._loadedUrl || (this.loadingAnim && (this._preloader.style.display = 'flex'), (this._canvas.style.visibility = 'hidden'), this.dispatchEvent(new CustomEvent('load-start', { detail: { url: this.url } })), this._wasContextLost && this.recreateCanvas(), this._canvas.removeEventListener('pointerdown', this.onInteract), this._canvas.removeEventListener('pointerup', this.onInteract), (this._hintDrag.style.display = 'none'), (this._loadedUrl = this.url), this._spline.load(this.url).then(this.onLoaded)); } updated(i) { super.updated(i), i.has('url') && (this.url == null && this._loaded ? this.unload() : this.url !== this._loadedUrl && this.load()); let r = this.shadowRoot?.querySelector('style:nth-child(1)'), s = this.shadowRoot?.querySelector('style:nth-child(2)'); if ( (i.has('width') && this.width !== void 0 && ((this._container.style.width = this.width + 'px'), r?.remove()), i.has('height') && this.height !== void 0 && ((this._container.style.height = this.height + 'px'), s?.remove()), i.has('background') && this.background !== void 0 && this._spline?.setBackgroundColor(this.background), i.has('eventsTarget') && this.eventsTarget !== void 0) ) { let n = this.eventsTarget === 'global'; this._spline?.eventManager?.updateUseWindowEvents(n), this._spline?.controls?.updateUseWindowEvents(n); } } connectedCallback() { super.connectedCallback(), Fu && this._intersectionObserver.observe(this); } disconnectedCallback() { Fu && this._intersectionObserver.unobserve(this), super.disconnectedCallback(); } }; (Hi.styles = Bv` :host { display: block; } #container { width: 100%; height: 100%; position: relative; } #spline { display: block; } #logo { display: none; position: absolute; z-index: 2; bottom: 20px; right: 20px; width: 0px; height: 0px; flex-direction: row; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; background: linear-gradient(180deg, #16181c 0%, #121316 100%); box-shadow: inset 0px -2px 0px -1px #060709, inset 0px 1px 0px rgba(255, 255, 255, 0.04); } #logo span { display: block; width: 20px; height: 20px; background-size: cover; } #logo svg { display: block; margin-right: 2px; } #logo:hover { background: linear-gradient(180deg, #1b1c21 0%, #17181c 100%); } #hints { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; } #hint-drag { animation-duration: 4s; animation-name: slidein; animation-iteration-count: infinite; animation-timing-function: ease-in-out; display: none; } @keyframes slidein { from { transform: translateX(0px); opacity: 0; } 50% { opacity: 0; transform: translateX(0px); } 60% { opacity: 1; } 65% { transform: translateX(-30px); } 85% { transform: translateX(30px); } 90% { opacity: 1; } to { opacity: 0; transform: translateX(0px); } } #preloader { position: absolute; display: none; top: 0; left: 0; align-items: center; justify-content: center; width: 100%; height: 100%; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } #spinner { color: rgba(0, 0, 0, 0.5); animation: spin 1s infinite linear; } `), Pr([Wr({ type: String })], Hi.prototype, 'url', 2), Pr([Wr({ type: Number })], Hi.prototype, 'width', 2), Pr([Wr({ type: Number })], Hi.prototype, 'height', 2), Pr([Wr({ type: String })], Hi.prototype, 'background', 2), Pr([Wr({ type: String })], Hi.prototype, 'loading', 2), Pr([Wr({ type: Boolean })], Hi.prototype, 'unloadable', 2), Pr([Wr({ type: String, attribute: 'events-target' })], Hi.prototype, 'eventsTarget', 2), Pr([Wr({ type: Boolean })], Hi.prototype, 'hint', 2), Pr([Wr({ type: Boolean, attribute: 'loading-anim' })], Hi.prototype, 'loadingAnim', 2), (Hi = Pr([L2('spline-viewer')], Hi)); export { Hi as SplineViewer };