Visualizations
002 / 500

002 · 3D

Tiny Planet

A ray traced village panorama that curls into a tiny planet, a fisheye or a camera view.

A small ray tracer first renders a full 360 degree equirectangular panorama from the middle of a procedural village: gabled houses with windows, a church, a windmill whose sails keep turning, trees, planters, a river with rippled reflections under a bridge, hills, haze and clouds, all made of convex polyhedra and spheres with sun shadows. Rays are culled by longitude bins for the camera and by a sun-aligned grid for shadows, and the panorama is traced progressively over the first seconds. Every screen pixel is then mapped back to a direction through one continuous family of projections: equirectangular, Mercator and stereographic strips share their slope at the horizon, so they blend, and bending the stereographic strip into a ring gives the tiny planet. From there a general perspective projection viewed from distance d behind the sphere slides to an ordinary rectilinear camera (d = 0) or a fisheye (d above 1), with closed form sines and cosines and a polynomial atan keeping the per pixel remap fast.

Try it. Drag sideways to spin the world and down to tilt it: from the tiny planet the view swings up to the horizon, and keeps going into the rabbit hole of sky. Use the slider (or the left and right arrow keys) to morph between Mercator, equirectangular, tiny planet, fisheye and rectilinear. Up and down arrows tilt, U looks straight up and R resets.

  • Ray tracing
  • Equirectangular panorama
  • Stereographic projection
  • General perspective projection
  • Inverse mapping

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a "tiny planet" panorama viewer with JavaScript and the HTML canvas element, where a 360 degree scene curls into a little globe. 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, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window.
- Generate a 1024 x 512 equirectangular panorama in code: each pixel is a direction (longitude across, latitude down). Ray trace a tiny scene from a camera 1.7 units above the ground: a ground plane with a checkered or cobbled pattern, a ring of colored boxes for houses, spheres for trees, and a sky gradient. Add sun shadows by casting one more ray toward the sun.
- Trace it a few rows per frame so the page never freezes, and show the progress.
- Draw the view by inverse mapping: for every screen pixel, work out its direction and look up the panorama. Start with stereographic projection centered straight down: a pixel at distance r from the center looks at angle theta = 2 atan(r / 2f) from the nadir, in the direction of its screen angle. That is the tiny planet.
- Let dragging rotate the sphere before the lookup, so the planet spins and tilts.

Once that works, make it beautiful:
- Add other mappings: the flat equirectangular strip, rectilinear (theta = atan(r / f)) and a fisheye, and a slider that blends between them smoothly.
- Render into a smaller offscreen canvas and scale it up, with bilinear lookups, so it stays at 60 fps.
- Add houses with gabled roofs and windows, a river with reflections and some drifting clouds.

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 animating the strip curling into the planet, adding a rabbit hole view looking straight up, or loading a real photo panorama.
PreviousBlack HoleA glowing accretion disk bent into a halo by gravitational lensing. NextAuroraCurtains of oxygen and nitrogen light on tilted field lines, mirrored in a lake.

Related visualizations

  • Map ProjectionsMath One procedural planet morphing through a dozen map projections, Tissot ellipses and all.
  • PlanetAstronomy A procedurally generated world with oceans, clouds and a glowing atmosphere.
  • Hopf Fibration3D The 3-sphere as linked circles, projected into nested tori of pastel rings.
  • Hidden 3DIllusions A live magic eye picture: a turning 3D sculpture hidden in colorful noise.
  • Interior Mapping3D A night skyline of thousands of furnished, lit rooms, and not one of them has geometry.
  • MandelbulbFractals A 3D fractal, ray marched pixel by pixel on the CPU.
  • Dandelin Spheres3D Two spheres wedged in a sliced cone prove the focus property, with no algebra.
  • Path Tracer3D Photorealistic light, computed by bouncing millions of random rays.
  • Voxel Diorama3D A floating voxel island with baked AO, sun shadows and a waterfall. Click to build.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs