A procedurally generated world with oceans, clouds and a glowing atmosphere.
Each world is baked once into maps of longitude and latitude: domain-warped 3D fractal noise on the sphere gives height, and height, latitude and moisture pick the biome, from ocean depths and beaches to forests, deserts and snowy peaks. Every pixel of the disk is then mapped back to the sphere, with everything that does not change as it spins precomputed, so a frame is just texture lookups and lighting. Clouds drift and cast shadows, oceans glint, cities glow on the night side and the atmosphere scatters light at the rim. Worlds range from temperate to lava, ice and ringed gas giants.
Try it. Drag to spin and tilt the planet. Click for a new world, or leave it alone and it travels to the next one.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a procedurally generated planet with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window over a dark starfield, stays sharp on high-DPI screens, and resizes with the window.
- Write a small 3D Perlin noise function yourself, plus a fractal (fbm) helper summing 5 or 6 octaves.
- Bake the planet once into an equirectangular texture (for example 512 x 256): for each texel, turn its longitude and latitude into a point on the unit sphere, read fbm noise there as height, and pick a color by height: deep and shallow ocean, beach, grass, forest, rock, snow. Use latitude so the poles freeze.
- Render the planet into a small offscreen ImageData each frame. For every pixel inside the disk, compute the sphere point (x, y, z = sqrt(1 - x² - y²)), convert it to longitude and latitude, add a rotation offset to the longitude, and look up the texture. Light it with a dot product against a fixed sun direction. Scale it up with drawImage.
Once that works, make it beautiful:
- Precompute everything about each pixel that does not change as the planet spins (its longitude, latitude and sun angle), so spinning is just a texture offset.
- Add a cloud layer from a second noise texture that drifts faster than the ground, and darken the ground under it as a cloud shadow.
- Give the oceans a specular glint, put warm city lights on the night side of the land, and add an atmosphere: a bluish haze toward the limb and a glowing rim just outside the disk.
- Click for a new seed, and drag to spin it.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as other kinds of worlds (desert, ice, lava, gas giant), planetary rings with shadows, or an orbiting moon.