Skip to content

feat(site): when the sun, its pillar and the moon next show, and refraction - #5

Merged
craig-o-curtis merged 10 commits into
mainfrom
feat/sky-sun-moon-times
Oct 23, 2026
Merged

craig-o-curtis merged 10 commits into
mainfrom
feat/sky-sun-moon-times

Conversation

@craig-o-curtis

Copy link
Copy Markdown
Contributor

The sky panel (the ⓘ button) now says, for each site, when the sun, the solar halo or pillar, and the moon next show in this window. The sky also accounts for atmospheric refraction now.

What it shows

  • Sun, Solar halo / pillar and Moon rows, each with its own icon. The moon icon is drawn in its real phase, with the phase name and how much is lit ("Full moon, 100% lit").
  • Times run start to end in the visitor's own time zone, named in the panel ("in your time zone (Europe/London)"). A body in view now reads "In view now, until 17:40", in cyan.
  • A footer reads "Site runs on @northguild/gmt v1.20.0". It is read from the installed package at build time.

Only what is truly visible

  • A body counts when any part of its disc is inside the frame and above the skyline (mountains, or Helsinki's buildings). The test checks its centre and 16 points round its rim against the skyline, interpolated as the mountains are drawn.
  • The sun counts from half its drawn strength. The halo/pillar row counts the pillar, or the 22° ring only while the sun's disc shows too: the ring alone is drawn too faintly to see.
  • The search runs in the sky worker in slices between frames, about 0.1 s for both sites, and nothing runs on the page. It runs fresh when the panel opens, then again while it is open: when a spell starts or ends, after local midnight, at least hourly, on resize and when the tab returns.

Refraction

Comparing with baldurpan.com (sun over Ísafjörður's mountains) showed the sky drew everything at its true position. Near the horizon the air lifts what you see by up to half a degree, and every sun or moon peek here is low over a ridge. The sun, moon, planets and stars are now lifted with NOAA's formula, the one baldurpan.com uses, which matches astronomy-engine within 0.1′. Eclipse geometry keeps the true directions.

gmt

Also

  • Header and library cards: the glass blur is down from 24px to 4px, so stars and constellation lines show through softened. The lines were already under them.

Checked

  • Predicted times against astronomy-engine.
  • Screenshots before, during and after predicted spells (Ísafjörður sun and moon, Helsinki sun, halo/pillar), using a temporary clock jump that is not in this PR.
  • The panel updating itself as a spell starts.
  • Each commit passes oxfmt --check, oxlint and astro check, and the last one also builds.

For its leap-second table (`taiMinusUtc` in `@northguild/gmt/timescale`),
which the sky uses for terrestrial time.
The glass blur was 24px, which hid the stars and constellation lines
behind the header and library cards entirely. At 4px they show through,
softened. The lines already sit under both (z-index -1).
Terrestrial time was 32.184 s plus a hard-coded 37 leap seconds. It now
reads TAI − UTC from gmt's leap-second table (`taiMinusUtc`), and the
Julian-day conversion takes the length of a day from `totalDuration`, so
the sky has no time constants of its own. Positions are unchanged.
Near the horizon the air lifts what is seen by up to half a degree, and
the sky drew everything at its true (geometric) position. Found by
comparing with baldurpan.com, which computes when the sun clears
Ísafjörður's mountains.

- `refraction()` and `lift()` in aurora.sky.ts use NOAA's formula, the
  same one baldurpan.com uses; it matches astronomy-engine's "normal"
  refraction to within 0.1′ from 0° to 30°.
- The sun and moon are drawn lifted; stars and planets are lifted in the
  star shader. Eclipse geometry keeps the true directions.
- The sun now shows from its upper limb on the horizon as it is seen,
  so the shader's fade-in and the tooltip's threshold move to match.
- Tooltips and constellation lines follow the lifted stars and planets;
  lines run along the true great circle, each point lifted as drawn.
The sky panel now lists, for each site, when the sun, the solar halo or
pillar, and the moon next show in this window, with sun, halo and
phase-drawn moon icons and the moon's phase and how much of it is lit.

- Truly visible only: any part of the disc, in frame and above the
  skyline (mountains, or buildings for Helsinki), tested at the centre and
  16 points round the rim. The skyline is interpolated as the ridge mesh
  is drawn. The sun counts from half its drawn strength.
- Solar halo / pillar counts the pillar (2° of it at least), or a quarter
  of the 22° ring while the disc also shows: the ring alone is drawn too
  faintly to see, and not at all over the aurora.
- aurora.ahead.ts steps ahead a minute at a time near the frame and skips
  ahead while a body is far (nothing moves faster than about 16° an
  hour), then halves each edge to 10 s. About 0.1 s for both sites, in
  slices between frames in the worker; nothing runs on the page.
- Worked out fresh when the panel opens (and from a hover or focus on its
  button), and again while it is open when a spell starts or ends, after
  local midnight, at least hourly, on resize and when the tab returns.
- All time through @northguild/gmt: the clock, `addUnix`, `roundUnix`,
  `endOfUnix`, `areUnixEqualBy`, `totalDuration`, `formatCalendarUnix`
  and `formatUnix` in the visitor's zone, named from `getSystemTimeZone`.
- Checked against astronomy-engine and by screenshots before, during and
  after predicted spells.
A quiet footer under the credits: "Site runs on @northguild/gmt vX.Y.Z",
linking to the GMT docs. The version is read from the installed package
at build time, so it follows every upgrade; gmt does not export its
package.json, so it is imported by path and only the string reaches the
page.

@baldurpan baldurpan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is careful work. The look-ahead's skip-ahead bound holds, every gmt call is right for 1.20.0, and refraction is applied in the right places: true directions for eclipses and the constellation great circles, lifted directions for drawing and picking. CI is green.

Four comments inline:

  1. aurora.worker.ts: the pillar test. This one changes what the panel says. The halo row can report a pillar that the shader draws at a few percent of its strength.
  2. aurora.ahead.ts: locale. The day phrase is in the browser's language, but the sentence around it is in English.
  3. Aurora.astro: focus has no matching blur. After keyboard focus, the search keeps re-running.
  4. aurora.sky.ts: a doc comment on the wrong function. A nit.

Comment thread apps/site/src/scripts/aurora.worker.ts Outdated
Comment thread apps/site/src/scripts/aurora.ahead.ts Outdated
Comment thread apps/site/src/components/Aurora.astro
Comment thread apps/site/src/scripts/aurora.sky.ts Outdated
From review: the pillar test sampled up to 6° above a sun as high as 6°,
where the shader draws the pillar at a few percent, so the halo row could
report a pillar nobody can see. It now matches the sun's half-strength
rule: a sun below y = 0.07 (about 4°, where the shader's
1 - smoothstep(0.03, 0.11, y) is a half) and only the 2° just above it
(exp(-dAlt / 0.05) is a half at 2°), with at least 1° of that showing.
From review: the dates were formatted in the browser's language inside
English sentences, so a German browser got "In view now, until morgen um
02:10". They now use the visitor's first English locale (keeping their 12-
or 24-hour clock), else British English. The time zone is still theirs.
From review: focus on the info button started the sun and moon search,
but only pointerleave stopped it, so a keyboard visitor tabbing past the
button left the worker re-running a year-long search for the rest of the
visit. blur now stops it too, with the same guard, so focus moving into
the open popover keeps it.
From review: the look-ahead helper's doc sat on top of sunRadiusAt's. It
now sits on sunAndMoon and mentions the lifted directions and radii. The
sun's distance moves into sunDistance(), which sunRadiusAt() and sky()
both use, instead of sky() working the radius out again.

@baldurpan baldurpan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at dbc5ae5. All four review points are fixed: the pillar counts only where it is drawn at half strength, the dates are in English in the visitor's time zone, tabbing past the button stops the search, and the doc is on sunAndMoon. CI is green.

@craig-o-curtis
craig-o-curtis merged commit a7c8280 into main Oct 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants