diff --git a/index.html b/index.html
index d9c3a6d..c0abf9a 100644
--- a/index.html
+++ b/index.html
@@ -534,20 +534,19 @@
rpgSunGlow.setAttribute('opacity', isDaytime ? '0.4' : '0.15');
rpgSunCore.setAttribute('opacity', isDaytime ? '1' : '0.35');
- // Moon position - interpolated between moonrise and moonset on the orbit
- var moonPos = getMoonPosition(now, moonTimes);
- if (!moonPos || !moonPos.point || isNaN(moonPos.point.x) || isNaN(moonPos.point.y)) {
- var fallbackP = pointOnCircle(now, MOON_ORBIT_RADIUS);
- rpgMoon.setAttribute('transform', 'translate(' + fallbackP.x + ', ' + fallbackP.y + ')');
- rpgMoon.setAttribute('opacity', '0.6');
- } else {
- rpgMoon.setAttribute('transform', 'translate(' + moonPos.point.x + ', ' + moonPos.point.y + ')');
- rpgMoon.setAttribute('opacity', moonPos.isVisible ? '1' : '0.6');
- }
+ // Moon position - based on current time on the orbit
+ var moonP = pointOnCircle(now, MOON_ORBIT_RADIUS);
+ rpgMoon.setAttribute('transform', 'translate(' + moonP.x + ', ' + moonP.y + ')');
- // TEMP DEBUG: show moon at center
- // rpgMoon.setAttribute('transform', 'translate(100, 100)');
- // rpgMoon.setAttribute('opacity', '1');
+ var moonVisible = false;
+ if (moonTimes.rise && moonTimes.set) {
+ if (moonTimes.rise < moonTimes.set) {
+ moonVisible = (now >= moonTimes.rise && now <= moonTimes.set);
+ } else {
+ moonVisible = (now >= moonTimes.rise || now <= moonTimes.set);
+ }
+ }
+ rpgMoon.setAttribute('opacity', moonVisible ? '1' : '0.6');
// Sun rise/set arrows
var srP = pointOnCircle(sunTimes.sunrise, SUN_ORBIT_RADIUS);
@@ -577,12 +576,6 @@
getMoonPhaseText(moonIllum.phase) + ' ' + Math.round(moonIllum.fraction * 100) + '%';
renderMoonPhaseIcon(moonIllum.phase);
renderRpgMoon(moonIllum.phase);
-
- // DEBUG
- document.title = 'moon: ' + (moonPos.isVisible ? 'visible' : 'hidden') +
- ' rise=' + formatTimeHM(moonTimes.rise) +
- ' set=' + formatTimeHM(moonTimes.set) +
- ' now=' + formatTimeHM(now);
}
var startTime = Date.now();