feat(globe): add real-time solar day/night terminator and night-side shading - #1
KOUSTAV2409 wants to merge 2 commits into
Conversation
|
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:
Once those are addressed, please rerun |
50f1926 to
d6a951f
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe globe now displays a solar day/night terminator. ChangesSolar terminator
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Suggested reviewers: 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
Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
| 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
Reviews (2): Last reviewed commit: "test: cover projected solar terminator g..." | Re-trigger Greptile
| 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) |
There was a problem hiding this 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.
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!
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
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.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.Theming in
RadioAtlas.qml:mapNightandmapTwilight) for both light and dark desktop themes.Unit Tests:
tests/model.test.mjsverifying solstices, equinoxes, UTC noon/midnight, and orthogonality of terminator geometry.Summary by CodeRabbit
New Features
Documentation
Tests