Add fixed custom camera positions
This commit is contained in:
parent
02697dae1f
commit
2bcb973020
2 changed files with 58 additions and 3 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue