This simulation shows soap bubbles ruled by surface tension — the force that pulls a liquid film into the smallest possible shape. Each bubble drifts, bounces, collides with its neighbours and finally pops into a shower of iridescent particles. The same minimal-surface mathematics that keeps a bubble spherical is used in architecture, foam materials and even in designing efficient tent and roof structures.
P = 4 * gamma / r — Laplace pressure inside a soap bubble, where gamma is the surface tension of the film and r is the bubble radius (smaller bubbles squeeze the air harder). A sphere also minimises surface area A = 4 * pi * r^2 for a fixed volume.
When three soap films meet, they always join at exactly 120 degrees — a rule discovered by Joseph Plateau in the 1800s. This is nature solving a minimisation problem instantly, something mathematicians needed over a century to prove formally.
Iridescent soap bubbles float and collide with realistic thin-film interference colours. Surface tension keeps them spherical while air resistance slows their drift.
Thin-film interference creates rainbow colours as light reflects off the inner and outer surfaces of the soap film, with phase shifts creating constructive and destructive interference.
Click to create new bubbles. Watch them interact, merge or pop. The colour patterns shift as the film thickness changes.
A soap bubble is the minimal surface enclosing a given volume. This is why bubbles are always spherical — a sphere has the least surface area for any volume.
This simulation shows soap bubbles governed by surface tension, the force that pulls a thin liquid film into the smallest possible shape. Each bubble is a 2D circle with position, velocity, hue and a finite lifetime, drawn with a radial gradient and a specular highlight to mimic thin-film iridescence. Every frame, wind and gravity are added to its velocity before air drag is applied, and a pairwise pass separates overlapping bubbles and exchanges momentum.
The Size slider sets the radius of new bubbles, Wind applies a horizontal push (negative left, positive right), and Gravity sets a vertical force where negative values make bubbles float upward. The bubble machine streams bubbles automatically, "Blow all away" clears the screen, and clicking either spawns or pops a bubble. The same minimal-surface mathematics that keeps bubbles spherical guides foams, lightweight roof structures and tensioned-fabric architecture.
What does this simulation show?
It shows soap bubbles that drift, bounce off walls, collide with their neighbours and eventually pop into a shower of coloured particles. Each bubble is rendered with a radial gradient to suggest the iridescent sheen of a real thin soap film.
Why are real soap bubbles always round?
Surface tension pulls the film inward until it reaches the smallest possible surface area for the air trapped inside. A sphere is the unique shape that minimises surface area for a fixed volume, so a free bubble settles into a sphere.
What do the three sliders do?
Size sets the radius of newly created bubbles, Wind applies a horizontal push that blows left for negative values and right for positive ones, and Gravity sets the vertical force. Because soap bubbles are lighter than air, a slightly negative gravity makes them float upward by default.
Click on empty space to spawn a bubble, or click directly on an existing bubble to pop it. The "Bubble machine" button toggles an automatic stream rising from the bottom, while "Blow all away" instantly clears every bubble on screen.
The Laplace pressure inside a soap bubble is P = 4 * gamma / r, where gamma is the surface tension of the film and r is the radius. The factor of four arises because a bubble has two surfaces (inner and outer); a single liquid surface gives P = 2 * gamma / r. Smaller bubbles squeeze the air harder.
Each frame, a pairwise loop checks every pair of living bubbles. When two overlap, they are pushed apart along the line joining their centres, and the component of their relative velocity along that line is partly exchanged. This makes the bubbles jostle and nudge each other rather than passing through.
In reality, light reflects from both the inner and outer surfaces of the soap film; the two reflections interfere, and the colour that survives depends on the film thickness. This thin-film interference produces the shifting iridescence. The simulation approximates the effect using hue-shifted radial gradients rather than computing true optical interference.
It is a stylised, qualitative model rather than a precise simulation. Motion, wind, gravity, drag and elastic-style collisions behave plausibly, but the colours are an artistic approximation and the bubbles never truly merge or form the flat shared walls that real touching bubbles create.
A bubble pops when it reaches the ceiling or exceeds its random maximum age, typically between 300 and 900 frames. Popping spawns an expanding coloured ring and a burst of small particles that fade out under their own gravity, accompanied by a short synthesised "pop" sound.
Minimal surfaces and surface tension appear throughout science and design: in foams and froths, in tensioned-fabric roofs and tents, in the shape of liquid droplets, and in Plateau's laws describing how soap films meet. Joseph Plateau showed that three films always join at exactly 120 degrees, nature solving a minimisation problem instantly.