← 🔭 Space & Astronomy
🌌 Spiral Galaxy · 80 000 particles

🌌 Galaxy



Drag — rotate · Scroll — zoom

🌌 Galaxy — 3D Spiral Simulation

Real-time simulation of a spiral galaxy using GPU-accelerated gravity. Watch stellar orbits stabilise into spiral arms over millions of simulated years, revealing the gravitational choreography that shapes galactic structure.

🔬 What It Demonstrates

Stars are attracted via Newton's inverse-square gravity, approximated with a Barnes-Hut tree. Differential rotation at different orbital radii naturally creates trailing spiral arms — an emergent pattern.

🎮 How to Use

Drag to rotate, scroll to zoom. Use sliders to adjust star count, gravitational softening, and rotation speed. Add a second galaxy and watch them collide and merge over simulated aeons.

💡 Did You Know?

Real galaxy rotation curves do not match Newtonian predictions for visible matter alone — they stay flat far from the centre. This discrepancy is key evidence for Dark Matter making up ~27% of the universe.

About this simulation

This visualisation builds a spiral galaxy from up to 200,000 individual star points rendered in real time with WebGL via Three.js. Each star is placed by a procedural logarithmic-spiral model: its radius is drawn from a power-law distribution, then offset into one of several arms by an angle that increases with distance from the centre. Colour and brightness vary by radius to mimic a hot blue-white core and cooler reddish outer disc, while additive blending and a bloom pass give the dense bulge its glow.

🔬 What it shows

A spiral galaxy's structure recreated geometrically rather than by integrating gravity. Stars are scattered along arms whose winding is set by a twist factor times the fractional radius, with a denser random central bulge, dust lanes following the arms, and an optional nebula cloud. The whole disc is rendered as GPU point sprites and rotated slowly about its axis.

🎮 How to use

Drag to orbit the camera and scroll to zoom. Sliders set Particles (10k–200k stars), Arms (1–8), Twist (how tightly arms coil), Spread (arm thickness), Core (bulge size), Radius (disc extent), Rotation speed and Tilt. "Regenerate" rebuilds the galaxy with the current values, and "Nebula" toggles a colourful gas-cloud layer.

💡 Did you know?

Real spiral arms are not fixed groups of stars but density waves — regions where stars and gas pile up temporarily, like a traffic jam that moves slower than the cars passing through it. This is why arms persist even though a galaxy's inner stars orbit faster than its outer ones.

Frequently asked questions

What does this galaxy simulation actually show?

It shows the visual structure of a spiral galaxy: a bright central bulge, several trailing spiral arms, surrounding dust lanes and an optional nebula. Up to 200,000 star points are positioned by a mathematical spiral formula and rendered with WebGL, so you see a convincing galaxy that you can rotate, zoom and reshape in real time.

How are the stars placed into spiral arms?

Each star gets a radius from a power-law random draw, then is assigned to one of the chosen number of arms. Its angle is the arm's base angle plus the fractional radius multiplied by the Twist value times pi, plus a small random spread. Because the angular offset grows with radius, the points trace out logarithmic spiral arms. Stars near the centre are instead scattered randomly to form the bulge.

What do the sliders and buttons do?

Particles sets the star count (10,000 to 200,000), Arms picks 1 to 8 spiral arms, and Twist controls how tightly they wind. Spread widens the arms, Core sizes the central bulge, and Radius sets the disc's extent. Rotation and Tilt change the spin speed and viewing angle. Regenerate rebuilds everything, and Nebula toggles a coloured gas layer.

Is this a physically accurate gravity simulation?

No. It is a procedural geometric model, not an N-body gravity solver. The stars are placed directly by a spiral formula and then rotated as a rigid disc, so there is no force calculation, no orbital integration and no differential rotation. It reproduces the appearance of a spiral galaxy faithfully but not the underlying dynamics that produce one in nature.

Why are spiral arms so common in galaxies?

Most large galaxies are spirals, and the favoured explanation is density-wave theory: spiral patterns are self-sustaining waves of higher density that compress gas and trigger star formation as material passes through them. The bright young stars formed there make the arms visible. Galactic collisions and tidal interactions can also drive or amplify spiral structure.