diff --git a/plugin/contents/ui/dancer.html b/plugin/contents/ui/dancer.html index 83819e7..f4ab1a8 100644 --- a/plugin/contents/ui/dancer.html +++ b/plugin/contents/ui/dancer.html @@ -1257,8 +1257,10 @@ if (typeof CONSTELLATIONS !== 'undefined') { const CAMERA_HOME_AZ = 90; // posição inicial: leste const CAMERA_TURN_MS = 5 * 60 * 1000; let viewAz = CAMERA_HOME_AZ; +let fixedCameraAz = CAMERA_HOME_AZ; let cameraRotating = false; let cameraRotationStartMs = Date.now(); +let cameraRotationOriginAz = CAMERA_HOME_AZ; const FOV_AZ = 140; // largura da tela em graus de azimute const ALT_TOP = 75; // altitude no topo da tela const HORIZON_F = 0.585; // fração da altura da tela até o horizonte @@ -1270,10 +1272,10 @@ let skyClockRealMs = Date.now(); let skyClockSimMs = skyClockRealMs; function currentCameraAz() { - if (!cameraRotating) return CAMERA_HOME_AZ; + if (!cameraRotating) return fixedCameraAz; const phase = ((Date.now() - cameraRotationStartMs) % CAMERA_TURN_MS) / CAMERA_TURN_MS; - return (CAMERA_HOME_AZ + phase * 360) % 360; + return (cameraRotationOriginAz + phase * 360) % 360; } function setCameraRotating(on) { @@ -1281,11 +1283,25 @@ function setCameraRotating(on) { if (on === cameraRotating) return; cameraRotating = on; cameraRotationStartMs = Date.now(); - viewAz = CAMERA_HOME_AZ; + cameraRotationOriginAz = fixedCameraAz; + viewAz = fixedCameraAz; lastProjMs = -Infinity; projectSky(); } +function setFixedCameraAz(azimuth) { + azimuth = Number(azimuth); + if (!Number.isFinite(azimuth)) return; + azimuth = ((azimuth % 360) + 360) % 360; + if (azimuth === fixedCameraAz) return; + fixedCameraAz = azimuth; + if (!cameraRotating) { + viewAz = fixedCameraAz; + lastProjMs = -Infinity; + projectSky(); + } +} + function skyNowMs() { const realNow = Date.now(); return skyClockSimMs + (realNow - skyClockRealMs) * skyTimeScale + @@ -1914,6 +1930,21 @@ let skyTimeScaleFileVal = null; .finally(() => setTimeout(pollSkyTimeScaleFile, 800)); })(); +/* Posição fixa controlada por set-camera-position.sh. */ +let cameraAzimuthFileVal = null; +(function pollCameraAzimuthFile() { + fetch('file:///tmp/skeledance-camera-azimuth?t=' + Date.now()) + .then(r => r.text()) + .then(t => { + const v = t.trim(); + if (v === cameraAzimuthFileVal) return; + cameraAzimuthFileVal = v; + setFixedCameraAz(v); + }) + .catch(() => {}) + .finally(() => setTimeout(pollCameraAzimuthFile, 800)); +})(); + /* Giro panorâmico controlado por toggle-camera-rotation.sh. */ let cameraRotationFileVal = null; (function pollCameraRotationFile() { diff --git a/set-camera-position.sh b/set-camera-position.sh new file mode 100755 index 0000000..ba9ccc4 --- /dev/null +++ b/set-camera-position.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +AZIMUTH_FILE=/tmp/skeledance-camera-azimuth +ROTATION_FILE=/tmp/skeledance-camera-rotation +POSITION=${1:-leste} + +case "$POSITION" in + norte|north) AZIMUTH=0 ;; + leste|east) AZIMUTH=90 ;; + sul|south) AZIMUTH=180 ;; + oeste|west) AZIMUTH=270 ;; + *) + if [[ "$POSITION" =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then + AZIMUTH=$POSITION + else + printf 'Uso: %s norte|leste|sul|oeste|GRAUS\n' "$0" >&2 + exit 2 + fi + ;; +esac + +printf '%s\n' "$AZIMUTH" > "$AZIMUTH_FILE" +printf '0\n' > "$ROTATION_FILE" +printf 'Câmera fixa em %s°\n' "$AZIMUTH"