ORBITAL EARTH
A physically based, real-time orbital simulation of Earth.
Earth illumination, cloud shading and atmospheric scattering are rendered from Earth imagery and analytic approximations — not baked scene lighting.
THREE.JS · GLSL ES 3.00 · VITE · ~4 000 LINES OF SHADERS & ENGINE
A YASLOGIST engineering showcase
01 / THE SYSTEM
Orbital Earth is a browser-based renderer that paints Earth from orbit using hand-written GLSL.
It is not a 3D model with a light bulb attached: the day/night terminator, the red sunset at the
limb, the glitter on the ocean and the glow around the disc are all computed per pixel, every frame,
from the same physical quantities a real atmosphere would produce.
The scene is assembled from four concentric layers around a unit sphere, plus a starfield and an
independent low-Earth-orbit model:
| Layer |
Radius (Earth = 1) |
Physical meaning |
| Surface |
1.0000 |
land + ocean, shaded per pixel |
| Cloud tops |
1.0020 |
shaped tropospheric clouds (~13 km) |
| Upper cloud veil |
1.0027 |
high anvils / cirrus (~17 km) |
| Atmosphere |
1.0280 |
single-scattering limb (~178 km) |
Everything is authored in a small, dependency-light engine: Three.js for the renderer,
camera and post-processing; hand-written GLSL ES 3.00 for every surface; Vite for the dev
server and bundler; lil-gui for the Studio panel; jpeg-js / pngjs for the offline texture
pipeline. The axial tilt is the real 23.44°.
Simulation, not telemetry. Mission overlays such as the LEO tracker are clearly labelled
simulations. Nothing queries a satellite feed or an external tracking service.
02 / CORE CAPABILITIES
| # |
Capability |
What it actually does |
| 01 |
Four-layer planet |
Surface, shaped cloud deck, high-cloud veil and a ray-marched atmosphere shell, each at its own radius. |
| 02 |
Physical surface shading |
Terrain relief from the SRTM/GEBCO height field; ocean optics with a Cook–Torrance GGX sun glitter; per-pixel sunlight transmitted through the atmosphere so the terminator reddens on its own. |
| 03 |
Night-side city lights |
Black Marble emission with the sensor airglow pedestal removed, cloud occlusion and the underglow clouds catch over a city in real ISS photography. |
| 04 |
Shaped cloud deck |
Advected coverage, gradient-following shading normals and a latitude-aware sunward self-shadowing march; a separate high veil for storm systems. |
| 05 |
Single-scattering atmosphere |
A real transmission march along rays that miss the planet — 20 deterministic squared-distance samples, Rayleigh + aerosol scale heights, and a faint ~95 km O I airglow band on the night limb. |
| 06 |
Deep space |
~9 000 stars with a real spectral-class colour ladder and a power-law magnitude distribution, concentrated toward the galactic plane, plus a procedural Milky Way band. |
| 07 |
Orbital-to-city navigation |
A logarithmic depth buffer (13 380 km down to 50 km), quintactic-eased camera arcs to 12 hubs, live telemetry cards and local times from IANA time zones. |
| 08 |
Simulated LEO tracker |
A deterministic, ISS-class circular orbit at 420 km / 51.6° with a moving marker, ground point, orbital path and a cylindrical Earth-shadow test. |
| 09 |
Rendering budget |
HDR targets, 4× MSAA on eligible buffers, FXAA otherwise, and an adaptive pixel ratio that steps down when measured frame time falls behind the display refresh rate. |
| 10 |
Studio controls |
A code-split control panel (fetched only when opened) exposing solar, atmosphere, ocean, cloud, orbital and post-processing parameters. |
The 12 global hubs
Cairo · Riyadh · Dubai · Tokyo · New York · London · Paris · Singapore · Shanghai ·
Los Angeles · Rio de Janeiro · Cape Town
Each hub carries an emissive beacon, a local time derived from its IANA time zone (including
daylight-saving changes) and a flight target for the camera.
03 / ENGINEERING ARCHITECTURE
The engine is deliberately small and readable — roughly 4 000 lines across 12 modules and 9
shaders. There is no build step between you and the source.
Render core — main.js owns the scene graph, the animation loop, the camera and the render
budget. It composes a PerspectiveCamera (38° FOV, near 0.001, far 1200, logarithmic depth
buffer), an OrbitControls instance with damping, and an EffectComposer chain.
The planet — earth.js builds the four-layer hierarchy. A group carries the axial tilt about
Z; a nested spin group rotates about the tilted polar axis; the surface, cloud decks, cirrus veil
and beacons hang off the spin, while the atmosphere halo sits outside it. Uniform objects are
shared by reference across materials so the surface and the cloud shell read the same advected
cloud coordinate.
Shaders — every surface is a hand-written GLSL ES 3.00 program: earthSurface.frag (PBR
ocean/land), earthClouds.frag (cloud coverage and shading), atmosphereHalo.frag (the
single-scattering march), milkyway.frag and starfield.frag (deep space), and beacon.frag
(emissive hub markers). Shared GLSL libraries — lib/atmosphere.glsl, lib/clouds.glsl,
lib/noise.glsl — are composed in shaderManifest.js so the offline checker validates
byte-for-byte what the app compiles.
Support modules — solar.js computes the subsolar point from a low-precision solar ephemeris
(~0.01° accuracy, 1950–2050); geo.js converts lat/lon to a point on the sphere; cities.js
holds the hub directory; leoTracker.js owns the orbital model; renderBudget.js decides the
device pixel ratio and MSAA eligibility.
Texture pipeline — scripts/fetch-assets.mjs rebuilds any missing 4096×2048 map from source
and repairs the cloud map (5×5 median plus a vertical pass) because the source mosaic carries
salt-and-pepper noise and swath seams visible from 50 km. predev / prebuild verify the maps
and skip the pipeline when they are already valid.
04 / SYSTEM BLUEPRINT
%%{init: {'theme':'base','themeVariables':{'primaryColor':'#0d1622','primaryTextColor':'#e8f0fa','primaryBorderColor':'#2a6f95','lineColor':'#46a6cf','secondaryColor':'#0a1119','tertiaryColor':'#121c28','fontFamily':'ui-monospace,SFMono-Regular,Menlo,monospace'}}}%%
flowchart TB
subgraph Assets["Texture Assets — public/textures"]
direction LR
A1["earth_day.jpg<br/>land + ocean albedo"]
A2["earth_night.jpg<br/>Black Marble emission"]
A3["earth_specular.jpg<br/>ocean mask"]
A4["earth_topology.jpg<br/>height field"]
A5["earth_clouds.jpg<br/>cloud density"]
end
subgraph Core["Render Core"]
M["main.js<br/>scene · loop · adaptive DPR"]
E["earth.js<br/>four-layer planet"]
S["starfield.js<br/>stars + Milky Way"]
B["beacons.js<br/>12 hub beacons"]
L["leoTracker.js<br/>51.6° LEO model"]
SO["solar.js<br/>UTC ephemeris"]
RB["renderBudget.js<br/>DPR · MSAA"]
end
subgraph GLSL["GLSL ES 3.00"]
SU["earthSurface.frag"]
CL["earthClouds.frag"]
HA["atmosphereHalo.frag"]
MW["milkyway.frag"]
BE["beacon.frag"]
end
subgraph Post["Post-Processing"]
C["EffectComposer"]
BL["UnrealBloomPass"]
FX["FXAA · 4× MSAA"]
OU["OutputPass · ACES"]
end
A1 --> E
A2 --> E
A3 --> E
A4 --> E
A5 --> E
E --> SU
E --> CL
E --> HA
S --> MW
B --> BE
M --> E
M --> S
M --> B
M --> L
SO --> M
RB --> M
M --> C
C --> BL
BL --> FX
FX --> OU
Loading
05 / EXECUTION INTELLIGENCE
Startup is a deterministic sequence: load the five texture maps, compile every shader during the
loader (so there is no first-use compilation in the active scene), size the render targets from
the device profile, then hand control to the animation loop. The Studio panel is fetched on demand
and never adds to the initial JavaScript request.
Runtime flow
- Acquire — verify the five texture maps; rebuild anything missing.
- Compile — compose and validate every shader program before the first frame.
- Size — choose the device pixel ratio from the CSS viewport and the render-pixel budget;
reserve 4× float MSAA for small, fine-pointer targets, fall back to FXAA otherwise.
- Frame — advance solar position, spin the planet, advect the clouds, advance the LEO model,
then render through
RenderPass → UnrealBloomPass → (MSAA / FXAA) → OutputPass.
- Adapt — if smoothed frame time falls below 75% of the measured refresh rate for two
consecutive samples, step the pixel ratio down by 0.2; recover toward the cap when headroom
returns. Steps are gated by a dwell timer to avoid oscillation.
The profile HUD (?profile=1) reports RAF FPS/frame time, draw calls and triangles, Three.js
texture/geometry counts, an estimated GPU allocation and CPU render-submit time. GPU memory is
estimated from uncompressed RGBA8 textures and render targets; submit time is a CPU timer, not
a GPU timer.
06 / IGNITION
npm install
npm run dev # http://localhost:5173
The dev server binds 0.0.0.0 and accepts proxied preview hosts.
Textures
public/textures/ ships with five 4096×2048 maps:
| File |
Contents |
earth_day.jpg |
True-colour land albedo + neutral deep-water base |
earth_night.jpg |
Black Marble emission, airglow pedestal removed |
earth_specular.jpg |
Anti-aliased ocean mask |
earth_topology.jpg |
Continuous height field (bathymetry + SRTM) |
earth_clouds.jpg |
Cloud optical density, median-filtered |
npm run fetch-assets # rebuild anything missing
npm run fetch-assets -- --force # rebuild all five
Verification
Runs the full offline suite: shader/compiler and uniform-contract checks, static JavaScript
runtime checks, city-directory/time-zone invariants, LEO orbit geometry, and DPR-aware
post-processing sizing tests. The shader check composes each program the way the app does,
resolves Three.js #include chunks, parses and validates every stage with
naga (the wgpu shader compiler), and cross-checks that every
declared uniform is supplied by JavaScript. It runs without a GPU, so it works in CI.