Hours of Daylight
A glowing 3D landscape of daylight hours for every latitude and every day of the year, computed from the real solar geometry. A tilted globe beside it shows the terminator sweeping through the seasons.
Generated automatically by Claude API (automat) with claude-opus-5.5: the automat wrote the page, looked at its screenshots and fixed it where needed. This is not a single-shot result: comparisons on this site show models in one attempt.
Starting prompt
Build "Hours of Daylight": a luminous, real-time 3D data landscape showing how many hours the Sun is above the horizon at every latitude on every day of the year, computed from real solar geometry. Beside it a tilted glass globe shows the day/night terminator sweeping through the seasons. It should look like a polished museum data installation and be beautiful from the first frame. Single self-contained HTML file; Three.js and its addons from a CDN via an import map are fine; Google Fonts are fine; everything else is procedural, with no external models, images or data files.
The science (compute once at startup, never per frame):
- Day of year n = 1…365. Solar declination δ(n) = −23.44° · cos(2π(n + 10)/365).
- Day length at latitude φ includes standard refraction and the solar disc (h0 = −0.833°): cos ω0 = (sin h0 − sin φ sin δ) / (cos φ cos δ). Clamp it to [−1, 1]: −1 means 24 h of midnight sun and +1 means 0 h of polar night. Hours = 2·acos(cos ω0)·(180/π)/15.
- Sample a grid of 365 days × 181 latitudes (−90…+90 in 1° steps) into a Float32Array.
- Check the results: 12.1 h on the equator all year, about 16.6 h at London (51.5°N) at the June solstice, and the Arctic Circle (66.56°) reaching exactly 24 h at the solstice.
The landscape (one unit ≈ one data cell, y up):
- A surface mesh with x = day of year (January to December, about 36 units wide), z = latitude (south at the front, north at the back, about 18 units deep) and height y = hours × 0.35.
- The Arctic summer forms a flat plateau at 24 h and the Antarctic winter a flat valley at 0 h. Mirror images rise and fall across the equator, and a nearly flat ridge runs along the equator at 12 h.
- Colour by hours with a custom ShaderMaterial (fog: false): deep indigo at 0 h, then violet, rose and amber, to pale gold-white at 24 h.
- Thin glowing contour lines at every whole hour, drawn in the shader with fract() and fwidth-style smoothing (enable derivatives through the GLSL3 defaults; do not rely on extensions that r170 removed). The contours at 12 h and 24 h are brighter.
- Faint grid lines mark each month boundary and every 15° of latitude.
- A dark reflective base plane, a thin bevelled frame around the data and small axis labels as canvas-texture sprites: month initials along x, "90°S · 60° · 30° · 0° · 30° · 60° · 90°N" along z and "0 h · 6 · 12 · 18 · 24" on a vertical scale bar at the back left.
- Mark the Arctic and Antarctic Circles and the Tropics with dashed pale lines across the surface.
The playhead:
- A translucent vertical glass slice moves through the year. It marks the current day across all latitudes and traces the day-length curve at that date as a bright white line with an additive glow.
- At the June solstice the line is S-shaped from 0 h to 24 h. At the equinoxes it is almost flat at about 12 h.
- Six latitude pins stand along the slice, each a small glowing bead riding on the curve with a fine label: Tromsø 69.6°N, Reykjavík 64.1°N, London 51.5°N, Singapore 1.3°N, Sydney 33.9°S and Ushuaia 54.8°S.
- Thin vertical ticks mark the solstices (about 21 Jun and 21 Dec) and the equinoxes (about 20 Mar and 22 Sep) at the front edge of the surface.
The globe:
- Placed to the left of the landscape (above it on a phone), about 5 units in radius.
- Axis tilted 23.44° with a thin polar axis rod and a graticule every 15°.
- A glassy dark-blue sphere with fresnel rim light.
- Shading in a ShaderMaterial (fog: false): a soft day hemisphere, a warm twilight band about 6° wide at the terminator, and a deep night side with faint stars reflected on the glass.
- The Sun direction comes from the current declination, so the terminator tilts towards and away from the poles through the year. The polar caps light up or fall dark accordingly.
- The globe spins once every 6 s.
- The same six latitude circles are drawn faintly on it. The current playhead latitude band glows.
The look:
- A near-black blue background with a soft radial glow and very light fog.
- ACES tone mapping at a modest exposure, with UnrealBloom only on the contour lines, the playhead curve and the beads. No washed-out whites.
- Gentle floating dust particles.
The timeline: the year plays in 40 s and loops seamlessly from 31 Dec back to 1 Jan, easing slightly slower through the solstices and equinoxes. The camera follows four slow movements over the year, blended smoothly:
1. Oblique overview from the south-east.
2. Low view along the equator ridge.
3. High view down on the northern plateau around June.
4. Wide view including the globe.
Open the page on about 1 May, so the slice is already moving towards the northern plateau in the first frame.
Interface:
- Top left: the title and the small subtitle "Sun above the horizon, every latitude, every day".
- Bottom left: a caption with the current date in large type ("21 June"), the solar declination ("δ = +23.4°") and a compact list of the six places with their day lengths as "16 h 38 m", updated live.
- Use small, elegant typography (e.g. Inter or IBM Plex Sans) and no clutter.
- A play/pause button and a thin year scrubber that can be dragged.
- Drag to orbit, scroll or pinch to zoom. The camera returns to the film 4 s after the last input.
- Everything starts automatically and is visibly moving from the first frame, without any interaction. On a phone (390×844, portrait) the globe sits above the landscape and the caption is compact.
Engineering rules (the page must work on the first load, with no fixes):
- Use Three.js r170 via this exact import map: <script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"}}</script>. Use only methods that exist in r170.
- Give every custom ShaderMaterial `fog: false`, and declare every uniform, constant and varying its shaders use.
- The page runs in a sandboxed iframe without same-origin access: do not use localStorage, sessionStorage, cookies, alert or window.top. Make no fetches.
- Declare each identifier once. Never reuse one scratch vector for two values needed at the same time. Guard every animated value and every acos input against NaN.
- Cap the pixel ratio at 2, handle resizing and keep it smooth (~60 fps on a laptop). Update the playhead line's geometry in place without reallocating it. No console errors.
- Answer with the complete file exactly once, in a single ```html code block: no drafts, partial snippets or notes.
Keep planning brief and write the code. Aim for roughly 700 to 1,000 lines, compact and well structured.