Skip to content

About

Interactive WebGL globe rendered from Rust and compiled to WebAssembly.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Rust WASM Globe

Interactive WebGL globe rendered from Rust and compiled to WebAssembly.

  • Three orbital bodies.
  • Both sun and moon as light sources with appropriate math.
  • Day night ground map switching.
  • Water map vector overdrawn with drawable water texture.
  • Cloud layers drawn at their real average altitudes provides a first pass on volumetric clouds along with Storms, Precipitation, and Fog.
Screenshot << observations >>
earth from heo I built this fast so I only pulled 4096 res layers and didn't wanna keep pounding the data source servers. I did start thinking of increasing the resolution substantially but doing so entails really large files for each layer and at that point the simulation exceeds the bounds of a typical PC. There's obvious gaps and seams in the data which are readily apparent in the screenshot.
earth from heo The "light map" is the light you actually see from your vantage point which in a graphical environment is basically a 2D plane where we need to do the math on what the light encounters as it hits the atmosphere, refracts and lenses, and then exits the atmosphere to hit your eye ball. In a range of eh 5 ms to 450 ms of exposure.
I tried an atmospheric light map first pass attempt to use actual mapped particulate counts to inform the red/orange/redish atmospheric hue for the atmospheric.

things i might take a crack at.
- try to math out the atmospheric oxygen increasing the blue
- the cloud/storm/precipitation increasing grays
- fake overwhelming our "camera" with too much light and drawing pure white
- aurora
- sodium layer
camera focused on the moon with earth in the background in frame real time orbital mechanics, visible orbital body movement
earth from heo set a home point
earth from heo slight atmosphere even at night

Things you can do

This a baseline. You can pull higher quality localized assets and draw them over your home instead of trying to handle the entire globe all at once.

I've also been considering actual volumetric clouds.

Controls

  • Drag with the mouse to rotate the globe.
  • Use the mouse wheel to zoom in and out.

Build

This project expects the standard browser WASM target and wasm-pack.

rustup target add wasm32-unknown-unknown
cargo install wasm-pack
wasm-pack build --target web
python -m http.server 8080

Then open http://localhost:8080.

index.html loads the generated module from ./pkg/wasm_rust_globe.js.

Integration Check

The repo includes a build-smoke integration check that fails if either the Rust build or the wasm bundle is broken.

./tools/integration_build_check.sh

Or:

make test

Screenshot Smoke Test

The repo also includes a screenshot smoke test that builds the wasm bundle, serves the app locally, opens the real app URL in headless Chromium through Playwright, waits 2 seconds, and captures a globe screenshot.

./tools/smoke_globe_screenshot.sh

Or:

make screenshot-test

By default it targets http://127.0.0.1:8090/ and waits 2 seconds after page load before capture. If nothing is already serving there, it starts a temporary local server on that port. You can override the target with PORT=... or BASE_URL=....

Output:

  • tmp/globe-smoke.png

Iteration Loop

For repeated screenshot-driven iteration, the repo includes an archive/diff loop:

./tools/iterate_globe_screenshots.sh

Or:

make iterate-screenshots

It captures multiple screenshots in sequence, writes per-shot JSON metrics, and saves diff images between successive shots under tmp/globe-iterations/<run-id>/.

Pull MERRA-2 Data

The renderer currently uses baked image assets, so the first MERRA-2 integration step is a fetch-and-rasterize tool rather than live NetCDF loading.

tools/fetch_merra2_texture.py pulls daily MERRA-2 M2T1NXSLV.5.12.4 single-level diagnostics through the GES DISC OPeNDAP endpoint, derives near-surface relative humidity from QV2M, T2M, and PS, and writes renderer-ready PNGs into assets/.

Requirements:

  • python3
  • numpy
  • Pillow
  • either EARTHDATA_TOKEN set, or a working ~/.netrc for Earthdata Login that curl --netrc can use

Example:

EARTHDATA_TOKEN=... python3 tools/fetch_merra2_texture.py --date 2026-04-01

Outputs:

  • assets/merra2-near-surface-relative-humidity-2048.png
  • assets/merra2-2m-temperature-2048.png
  • assets/merra2-surface-pressure-2048.png
  • assets/merra2-2m-specific-humidity-2048.png
  • tmp/merra2-merra2-YYYY-MM-DD.json

Refresh Recent Clouds

tools/fetch_recent_cloud_texture.py pulls official cloud-analysis products and writes back the globe cloud textures.

Each fetch creates a unique pull ID and stores raw upstream files under tmp/cloud-products-raw/<pull-id>/.

The fetch stage now runs asynchronously and spawns concurrent curl child processes, printing progress lines as products are fetched and processed.

The fetcher now stores upstream telemetry provenance in tmp/cloud-products-<pull-id>.json, including:

  • run start/end timestamps
  • total run duration
  • pull ID and pull mode
  • requested remote fetch resolution
  • raw on-disk upstream payload paths
  • native upstream file dimensions
  • per-product source URL
  • per-product download timing and byte size
  • per-product decode timing
  • colormap fetch attempts used to decode numeric products

Example:

python3 tools/fetch_recent_cloud_texture.py --date 2026-04-01

Reprocess an existing raw pull without refetching:

python3 tools/fetch_recent_cloud_texture.py --pull-id 2026-04-01-20260404T220000Z-deadbeef

Highest-resolution fetch while keeping renderer assets at 4096x2048:

python3 tools/fetch_recent_cloud_texture.py --date 2026-04-01 --fetch-width 8192 --fetch-height 4096

Output:

  • assets/cloud-combined-4096.jpg
  • assets/cloud-visible-4096.jpg
  • assets/cloud-confidence-4096.png
  • assets/cloud-top-height-4096.png
  • assets/cloud-optical-depth-4096.png
  • assets/cloud-low-4096.png
  • assets/cloud-medium-4096.png
  • assets/cloud-high-4096.png
  • assets/cloud-storms-4096.png
  • assets/cloud-precipitation-4096.png
  • assets/cloud-fog-4096.png
  • tmp/cloud-products-raw/<pull-id>/*.png
  • tmp/cloud-products-raw/<pull-id>/pull.json
  • tmp/cloud-products-<pull-id>.json

Build Cloud Atlas

The renderer now consumes a packed cloud atlas instead of treating the cloud layer as a single grayscale mask.

tools/fetch_cloud_atlas.py builds assets/cloud-atlas-4096.png from the cloud products, precipitation, aerosol, and land/ocean context.

Channel layout:

  • R: coverage
  • G: cloud type
  • B: cloud-top height
  • A: optical depth

Example:

python3 tools/fetch_cloud_atlas.py --date 2026-04-01

Output:

  • assets/cloud-atlas-4096.png
  • tmp/cloud-atlas-YYYY-MM-DD.json

Recommended refresh order:

python3 tools/fetch_recent_cloud_texture.py --date 2026-04-01
python3 tools/fetch_cloud_atlas.py --date 2026-04-01
wasm-pack build --target web

About

Interactive WebGL globe rendered from Rust and compiled to WebAssembly.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages