refactor: controla constelações por script de atalho

This commit is contained in:
vini 2026-07-19 13:52:31 -03:00
parent 740c9b836b
commit bfb8f31952
5 changed files with 26 additions and 12 deletions

View file

@ -1467,6 +1467,22 @@ function setShowConstellations(on) {
projectSky();
}
/* Estado controlado por toggle-constellations.sh. A primeira leitura também
é aplicada, então o modo sobrevive a reloads do WebEngine. */
let constellationsFileVal = null;
(function pollConstellationsFile() {
fetch('file:///tmp/skeledance-constellations?t=' + Date.now())
.then(r => r.text())
.then(t => {
const v = t.trim();
if (v === constellationsFileVal) return;
constellationsFileVal = v;
setShowConstellations(v === '1');
})
.catch(() => {})
.finally(() => setTimeout(pollConstellationsFile, 800));
})();
/* ── Passo de projeção: recalcula posições de tela (a cada 30s o céu gira
~0.125°, imperceptível). Camada estática (Via Láctea + estrelas fracas)
é pré-renderizada em baseCanvas; só as brilhantes cintilam por frame ── */
@ -2332,6 +2348,7 @@ document.addEventListener('keydown', e => {
if (!e.target.matches('input,textarea')) {
if (e.key === 'b' || e.key === 'B') toggleBalada();
if (e.key === 'r' || e.key === 'R') toggleChuva();
if (e.key === 'c' || e.key === 'C') setShowConstellations(!showConstellations);
}
});