Add fixed custom camera positions

This commit is contained in:
vini 2026-07-19 14:58:47 -03:00
parent 02697dae1f
commit 2bcb973020
2 changed files with 58 additions and 3 deletions

View file

@ -1257,8 +1257,10 @@ if (typeof CONSTELLATIONS !== 'undefined') {
const CAMERA_HOME_AZ = 90; // posição inicial: leste const CAMERA_HOME_AZ = 90; // posição inicial: leste
const CAMERA_TURN_MS = 5 * 60 * 1000; const CAMERA_TURN_MS = 5 * 60 * 1000;
let viewAz = CAMERA_HOME_AZ; let viewAz = CAMERA_HOME_AZ;
let fixedCameraAz = CAMERA_HOME_AZ;
let cameraRotating = false; let cameraRotating = false;
let cameraRotationStartMs = Date.now(); let cameraRotationStartMs = Date.now();
let cameraRotationOriginAz = CAMERA_HOME_AZ;
const FOV_AZ = 140; // largura da tela em graus de azimute const FOV_AZ = 140; // largura da tela em graus de azimute
const ALT_TOP = 75; // altitude no topo da tela const ALT_TOP = 75; // altitude no topo da tela
const HORIZON_F = 0.585; // fração da altura da tela até o horizonte 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; let skyClockSimMs = skyClockRealMs;
function currentCameraAz() { function currentCameraAz() {
if (!cameraRotating) return CAMERA_HOME_AZ; if (!cameraRotating) return fixedCameraAz;
const phase = ((Date.now() - cameraRotationStartMs) % CAMERA_TURN_MS) / const phase = ((Date.now() - cameraRotationStartMs) % CAMERA_TURN_MS) /
CAMERA_TURN_MS; CAMERA_TURN_MS;
return (CAMERA_HOME_AZ + phase * 360) % 360; return (cameraRotationOriginAz + phase * 360) % 360;
} }
function setCameraRotating(on) { function setCameraRotating(on) {
@ -1281,11 +1283,25 @@ function setCameraRotating(on) {
if (on === cameraRotating) return; if (on === cameraRotating) return;
cameraRotating = on; cameraRotating = on;
cameraRotationStartMs = Date.now(); cameraRotationStartMs = Date.now();
viewAz = CAMERA_HOME_AZ; cameraRotationOriginAz = fixedCameraAz;
viewAz = fixedCameraAz;
lastProjMs = -Infinity; lastProjMs = -Infinity;
projectSky(); 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() { function skyNowMs() {
const realNow = Date.now(); const realNow = Date.now();
return skyClockSimMs + (realNow - skyClockRealMs) * skyTimeScale + return skyClockSimMs + (realNow - skyClockRealMs) * skyTimeScale +
@ -1914,6 +1930,21 @@ let skyTimeScaleFileVal = null;
.finally(() => setTimeout(pollSkyTimeScaleFile, 800)); .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. */ /* Giro panorâmico controlado por toggle-camera-rotation.sh. */
let cameraRotationFileVal = null; let cameraRotationFileVal = null;
(function pollCameraRotationFile() { (function pollCameraRotationFile() {

24
set-camera-position.sh Executable file
View file

@ -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"