Skip to content

Commit ff61308

Browse files
authored
Improve aurora overlay logic with K-index check
Refactor aurora visibility score calculation and overlay logic.
1 parent 21092a8 commit ff61308

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

src/weather-overlay-three.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,39 @@ function updateWeather() {
591591

592592
const smogActive = effect !== 'stars' && isEffectEnabled('enable_smog_effect') && isSmogAlertActive();
593593
const moonPosition = effect === 'stars' && isEffectEnabled('enable_moon_glow') ? getMoonPosition() : null;
594-
const auroraVisibilityScore = effect === 'stars' ? getAuroraVisibilityScore() : 0;
595-
const auroraOverlay = effect === 'stars' && auroraVisibilityScore > 0;
594+
595+
596+
let auroraVisibilityScore = 0;
597+
let auroraOverlay = false;
598+
599+
if (effect === 'stars') {
600+
try {
601+
const kIndex = getKIndex();
602+
const calculatedScore = getAuroraVisibilityScore();
603+
604+
// Pobieramy próg z konfiguracji (domyślnie 0.15)
605+
const cfg = window.ForkUWeatherAwareConfig || {};
606+
const minScore = (cfg.aurora_visibility_min != null && !isNaN(parseFloat(cfg.aurora_visibility_min)))
607+
? parseFloat(cfg.aurora_visibility_min)
608+
: 0.15;
609+
610+
// Warunek użytkownika: (K-index >= 4) LUB (wyliczony score spełnia próg)
611+
const isHighKIndex = kIndex != null && kIndex >= 4;
612+
const isHighScore = calculatedScore > 0 && calculatedScore >= minScore;
613+
614+
if (isHighKIndex || isHighScore) {
615+
auroraOverlay = true;
616+
// Jeśli zorza odpala się wyłącznie przez wysoki K-Index, dajemy jej domyślną siłę wizualną (np. 0.8), żeby nie była czarna
617+
auroraVisibilityScore = isHighScore ? calculatedScore : 0.8;
618+
}
619+
} catch (err) {
620+
// Jeśli jakikolwiek sensor rzuci błędem, łapiemy to.
621+
// Zorza się nie narysuje, ale GWIAZDY I KSIĘŻYC BĘDĄ BEZPIECZNE.
622+
console.warn('[Weather Overlay] Błąd odczytów sensorów zorzy, pomijam nakładkę:', err);
623+
}
624+
}
625+
626+
596627
const rainEffects = ['rain', 'rain_storm', 'rain_drizzle', 'snow_storm'];
597628
const precipitationMm = getPrecipitationAmountMm();
598629
const windowDroplets =

0 commit comments

Comments
 (0)