Skip to content

feat(globe): add real-time solar day/night terminator and night-side shading - #1

Open
KOUSTAV2409 wants to merge 2 commits into
AksharP5:mainfrom
KOUSTAV2409:feature/solar-terminator
Open

KOUSTAV2409 wants to merge 2 commits into
AksharP5:mainfrom
KOUSTAV2409:feature/solar-terminator

Conversation

@KOUSTAV2409

@KOUSTAV2409 KOUSTAV2409 commented Sep 1, 2026

Copy link
Copy Markdown

Description

This PR introduces a real-time Solar Day/Night Terminator to Radio Atlas, rendering the Earth's natural sunlight and night-side shadow across the 3D globe.

🌟 Features & Mathematical Design

  1. NOAA Solar Position Algorithm in RadioModel.js:

    • subsolarPoint(date): Computes accurate solar declination and subsolar coordinates $ from the current UTC timestamp (accounting for obliquity of the ecliptic, equation of the center, and equation of time).
    • terminatorGeometry(lat, lon, steps): Generates 3D unit vectors along the terminator great circle orthogonal to the sun vector.
    • isNightAt(lat, lon, subsolarLat, subsolarLon): Dot-product calculation to determine day/night status for any coordinate.
  2. Orthographic Projection & Canvas Shading in Globe.qml:

    • paintSolarTerminator(ctx, ...): Projects the terminator great circle into camera space, tracing the semi-ellipse and outer globe rim to create a night shadow mask and twilight line.
    • Preserves station signal visibility so transmitters glow like city lights over the night hemisphere.
    • Dynamic 60-second timer to update solar position as time progresses.
  3. Theming in RadioAtlas.qml:

    • Theme-aware night colors (mapNight and mapTwilight) for both light and dark desktop themes.
  4. Unit Tests:

    • Added automated tests in tests/model.test.mjs verifying solstices, equinoxes, UTC noon/midnight, and orthogonality of terminator geometry.

Summary by CodeRabbit

  • New Features

    • Added real-time solar day/night shading to the globe, including a visible terminator line.
    • Added configurable colors, opacity, and visibility settings for the night-side overlay and terminator.
    • Solar positioning refreshes automatically while the feature is enabled.
    • Added light and dark theme support for night-side globe colors.
  • Documentation

    • Updated feature documentation to mention solar terminator rendering.
  • Tests

    • Added coverage for solar positioning and terminator geometry across key dates and viewing orientations.

@AksharP5

AksharP5 commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution. I tested this locally, and the test suite and QML linting pass. I found a few things to clean up before another review:

  • terminatorGeometry() and isNightAt() are not used by the renderer. Globe.qml calculates the same solar geometry separately. Please use one shared implementation or remove the unused functions and tests.
  • The terminator test says it verifies orthogonality, but it only checks that each point has unit length. Please assert that the dot product between each point and the sun direction is approximately zero.
  • solarTimer continues running while this keep-loaded panel is closed. Please gate it on visibility and showTerminator, then refresh immediately when it starts to avoid showing a stale position.
  • The code names this boundary twilight, but it draws the geometric day/night terminator. Please rename the related properties to terminatorColor and terminatorOpacity, unless the intent is to render an actual twilight band.
  • Please add a short README feature entry describing the new day/night shading.

Once those are addressed, please rerun ./tests/run, qmllint, and plugin validation.

@KOUSTAV2409
KOUSTAV2409 force-pushed the feature/solar-terminator branch from 50f1926 to d6a951f Compare September 10, 2026 21:43
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4c921b93-b2ca-4cf3-b150-4b228eff87e1

📥 Commits

Reviewing files that changed from the base of the PR and between d6a951f and e3d9e84.

📒 Files selected for processing (3)
  • Globe.qml
  • RadioModel.js
  • tests/model.test.mjs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The globe now displays a solar day/night terminator. RadioModel calculates solar geometry, Globe.qml renders and refreshes the overlay, and RadioAtlas.qml provides theme colors. Tests cover solar positions and terminator geometry.

Changes

Solar terminator

Layer / File(s) Summary
Solar position and terminator geometry
RadioModel.js, tests/model.test.mjs
Adds subsolar-point and terminator-geometry calculations. Tests verify seasonal positions, midnight longitude, unit vectors, and orthogonality.
Terminator rendering and theme wiring
Globe.qml, RadioAtlas.qml
Adds terminator properties, night-side shading, terminator stroking, geometry integration, and theme color wiring.
Solar position refresh lifecycle
Globe.qml, README.md
Refreshes the solar position when the visible terminator is enabled, using a 60-second timer. Documents the feature.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: aksharp5

Sequence Diagram(s)

sequenceDiagram
  participant GlobeTimer
  participant Globe
  participant RadioModel
  participant Canvas
  GlobeTimer->>Globe: trigger every 60000 ms
  Globe->>RadioModel: calculate subsolarPoint(current time)
  RadioModel-->>Globe: return latitude and longitude
  Globe->>RadioModel: calculate terminatorGeometry
  RadioModel-->>Globe: return terminator points
  Globe->>Canvas: paint night shading and terminator
Loading

Merge Risk: ⚪ Minimal · up to e3d9e

Day/night shading is wired through the globe renderer with theme colors and periodic refresh, and the geometry tests cover the rendered contract. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding real-time solar day/night terminator rendering and night-side shading to the globe.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds real-time solar day/night visualization to the globe.

  • Computes the current subsolar point and camera-space terminator geometry in RadioModel.js.
  • Draws theme-aware night-side shading and a twilight boundary in Globe.qml, refreshed every 60 seconds.
  • Adds theme integration, documentation, and solar/geometry unit tests.
  • The earlier test-coverage concern is only partly addressed: the geometry is now tested for front-, back-, and side-lit orientations, but the renderer’s rim-arc selection that determines which hemisphere receives the mask remains uncovered.

Confidence Score: 5/5

The PR appears safe to merge, with only a non-blocking gap in focused coverage of the renderer’s night-mask arc selection.

The extracted terminator geometry is now tested for front-, back-, and side-lit orientations and matches the established camera transform. The previous coverage finding is partly fixed because the tests validate generated vectors but still do not exercise the paintSolarTerminator arc-direction logic that decides whether the daylight or night hemisphere is filled.

Files Needing Attention: Globe.qml, tests/model.test.mjs

Important Files Changed

Filename Overview
RadioModel.js Adds solar-position calculation and reusable camera-space terminator geometry consistent with existing projection conventions.
Globe.qml Adds timer-driven night shading and terminator rendering; the mask’s hemisphere-selection path remains without focused rendering coverage.
tests/model.test.mjs Covers seasonal solar positions and terminator-vector geometry, but not the renderer’s arc-direction and mask-closing behavior.
RadioAtlas.qml Connects light- and dark-theme colors to the globe’s night overlay and terminator.
README.md Documents the new real-time solar terminator feature.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Current UTC time] --> B[subsolarPoint]
    B --> C[Subsolar latitude and longitude]
    C --> D[terminatorGeometry]
    E[Globe camera orientation] --> D
    D --> F[Camera-space terminator points]
    F --> G[Canvas projection]
    G --> H[Night-side mask]
    G --> I[Twilight boundary]
    J[60-second timer] --> A
Loading

Reviews (2): Last reviewed commit: "test: cover projected solar terminator g..." | Re-trigger Greptile

Comment thread Globe.qml
Comment on lines +499 to +508
var diff = (angleStartWrapped - angleEndWrapped + Math.PI * 2) % (Math.PI * 2)
var diffSun = (awayFromSun - angleEndWrapped + Math.PI * 2) % (Math.PI * 2)
var anticlockwise = !(diffSun < diff)

ctx.beginPath()
ctx.moveTo(ellipsePoints[0].x, ellipsePoints[0].y)
for (var j = 1; j <= steps; j++) {
ctx.lineTo(ellipsePoints[j].x, ellipsePoints[j].y)
}
ctx.arc(centreX, centreY, globeRadius, angleEndScreen, angleStartScreen, anticlockwise)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Terminator geometry lacks coverage

The new arc-direction logic determines which visible hemisphere receives the night mask, but the added tests only validate solar coordinates. A regression that shades the daylight hemisphere or closes the path along the wrong rim could therefore pass the test suite. Add focused geometry or rendering tests for front-lit, back-lit, and side-lit camera orientations.

Prompt To Fix With AI
This is a comment left during a code review.
Path: Globe.qml
Line: 499-508

Comment:
**Terminator geometry lacks coverage**

The new arc-direction logic determines which visible hemisphere receives the night mask, but the added tests only validate solar coordinates. A regression that shades the daylight hemisphere or closes the path along the wrong rim could therefore pass the test suite. Add focused geometry or rendering tests for front-lit, back-lit, and side-lit camera orientations.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex

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