~/dominik.polzer
~/blog/galaxy-3d-simulation

Galaxy 3D simulation: eight galaxies at their real scale

$ open ./live →

Open the live simulation →

A 3D atlas of eight galaxies you can orbit, zoom into and search. Pick a galaxy from the tabs along the top. Each one is generated in your browser the first time you open it, then kept in memory, so switching back is instant.

Galaxy Shape Width Distance
Milky Way barred spiral ≈ 87,000–100,000 ly you are here
Andromeda (M31) barred spiral with a star-forming ring ≈ 152,000 ly 2.5 million ly
Triangulum (M33) flocculent spiral ≈ 61,000 ly 2.9 million ly
Large Magellanic Cloud Magellanic spiral, off-center bar ≈ 32,000 ly 162,000 ly
Whirlpool (M51) grand-design spiral with companion ≈ 77,000–91,000 ly ≈ 28 million ly
Sombrero (M104) spiral seen nearly edge-on ≈ 95,000 ly 31 million ly
Messier 87 giant elliptical with a jet ≈ 132,000 ly 53.5 million ly
Cartwheel ring galaxy ≈ 150,000 ly (outer ring) ≈ 500 million ly

All eight use the same units, light-years. A dashed “Milky Way to scale” ring is drawn behind the other galaxies, so you can see straight away that Andromeda is about 1.7× wider than our galaxy and the LMC a little over a third as wide. Measured from the generated stars, every galaxy’s width comes out within about 5–15% of its published diameter, and its width relative to the Milky Way within about 10%.

What is real and what is generated

Most of what you see is generated, and the page says so. The parts that come from research:

  • Shapes and sizes. Diameters (mostly the D25 isophote), arm counts and pitch angles, bars, rings, bulge-to-disk balance, and the inclination and position angle each galaxy shows from Earth.

  • Distances and sky positions. Each external galaxy sits at its measured distance and J2000 position. Every object’s RA/Dec is projected from its place in the galaxy, so it points at the right patch of sky.

  • Landmarks, 84 in total. These are the 49 Milky Way landmarks from the first version (the Sun, Betelgeuse, Sgr A*, the Crab Nebula…), and for the other galaxies:

    • Andromeda: M31*, M32, M110, NGC 206, Mayall II, Hubble’s Cepheid V1 and the yearly recurrent nova M31N 2008-12a.
    • Triangulum: NGC 604, NGC 595, M33 X-7 and IC 133.
    • LMC: the Tarantula Nebula, R136, R136a1, SN 1987A, N11, N44, LMC X-1 and LMC X-3.
    • Whirlpool: NGC 5195, three supernovae, and M51-ULS-1 with the first planet candidate found in another galaxy.
    • Messier 87: M87* and the jet knots HST-1 and A.
    • Cartwheel: its companions G1 and G2.

    Their sizes, masses and separations from the galaxy center come from the papers listed below. Where sources disagree, the card says so or gives a range.

What is generated:

  • Every other star, cluster, nebula, pulsar and black hole. There are 6,000–10,000 per galaxy, placed by a seeded random generator along the real structure. Their names are position-based designations (like LGGS J004041.7+405442) that don’t refer to real catalog entries.
  • The roughly 30,000–56,000 unresolved field stars and the glow and dust haze.
  • The motion. Each galaxy rotates as a pattern with small epicycles, which is not real dynamics. Orbits and object sizes are enlarged so you can see them.

For scale: the real catalogs behind this are far larger. Gaia DR3 alone has 1,811,709,771 sources, and Andromeda holds roughly a trillion stars. The simulation is a picture of each galaxy’s structure, not a catalog.

How it’s built

  • One WebGL2 draw call per layer. Each object is 16 floats of orbit parameters. The vertex shader computes every position from those and a few time uniforms, so the CPU never streams geometry. Picking is one CPU pass, and only while the pointer is over the scene.
  • On-demand galaxies. The engine and the Milky Way ship in one ~46 KB (gzipped) module. Each other galaxy is a 2–3 KB chunk that loads the first time its tab is opened. It builds its world in ~35–60 ms, which is hidden behind a short fade, and is uploaded into the same GPU buffers.
  • Same budget everywhere. No galaxy has more than ~10,000 interactive objects and ~65,000 points in total, the same budget as the original Milky Way-only atlas. The adaptive pixel-ratio fallback still kicks in on slow GPUs.
  • Deterministic. Each galaxy has its own seed, so it looks the same on every load, in any tab order.

The page is a plain Astro route with no framework runtime. The code is split into a shape kit (spiral, elliptical, sky projection) and one small module per galaxy.

Sources

Milky Way

Andromeda (M31)

Triangulum (M33)

Large Magellanic Cloud

Whirlpool (M51)

Sombrero (M104)

  • Vlahakis et al. 2008, the dust ring: arXiv:0805.4791
  • Jardel et al. 2011, black hole mass (about 6.6 × 10⁸ M☉; Kormendy et al. 1996 found about 10⁹): arXiv:1107.1238

Messier 87

Cartwheel

Coordinates are from SIMBAD. Diameters and star counts are from the Wikipedia infoboxes of each galaxy, which in turn cite NED and the papers above.

Open the live simulation →