Show HN: Browser-based interactive 3D Three-Body problem simulator (trisolarchaos.com)

249 points by jgchaos ↗ HN
Features include:

  - Several preset periodic orbits: the classic Figure-8, plus newly discovered 3D solutions from Li and Liao's recent database of 10,000+ orbits (https://arxiv.org/html/2508.08568v1)
  - Full 3D camera controls (rotate/pan/zoom) with body-following mode
  - Force and velocity vector visualization
  - Timeline scrubbing to explore the full orbital period
The 3D presets are particularly interesting. Try "O₂(1.2)" or "Piano O₆(0.6)" from the Load Presets menu to see configurations where bodies weave in and out of the orbital plane. Most browser simulators I've seen have been 2D.

Built with Three.js. Open to suggestions for additional presets or features!

45 comments

[ 2.4 ms ] story [ 67.3 ms ] thread
Nice work!

Were you by any chance inspired to make this because of the three body series by Cixin Liu? Or were you moreso just inspired because the simulation/math/physics are interesting?

This is really lovely work! Simple to use, surprisingly solid, and just a pleasure to poke around with. The fact it runs in the browser is a bit of magic on its own.

One idea for later might be a few preset systems, such as Alpha Centauri or other known three-body systems. It would give people a quick way to drop into something real before they start making chaos of their own.

Anyway, cracking project.

Is this with Gemini 3?
I really enjoyed the book series. This is an amazing work! Thanks for sharing.
No physics expert but isn't this unpredictable (based on what I saw in series) ?

Amd this does seem predictable, I saw this for almost a minute

The math in the 3 body problem was made up.

Computing the trajectory of a 3 body problem is a comparatively simple task.

The two grains of truth are that the solutions for most starting conditions are not analytic, roughly meaning that they can not be expressed in terms of functions. The other being that the numerical solution to an ODE diverges exponentially.

I spent a long time playing with the sim. Nice work.

Most of the random data sets that I ran ended up with a two body system, where the third body was flung far into space never to return. However, some of these were misleading. I had one running for 15 minutes at 5x, and the third body did eventually return.

The 3D presets are the standout here, especially the ones that move in and out of the orbital plane. The interaction feels smooth, and it’s great to see this level of detail running in the browser.
> Open to suggestions for additional presets or features!

Anaglyphic (red/cyan) 3D rendering would be nice. I've created a lot of anaglyphic 3D apps over the years, but they're no longer very popular -- I suspect it's the goofy glasses one must acquire and wear.

But a true 3D view of an orbital simulator like this greatly increases its impact and tutorial value.

I do not currently have a set of those glasses so I can't test it, but three.js has this and it's pretty easy to add. There should be an "Anaglyph 3D" checkbox at the bottom of the configuration settings. Let me know if you are able to test it out.
I recently thought that if life supposedly happened by chance then it should be same for the three-body problem: naturally occurred solutions floating here and there somewhere.
Looks very nice!

I think I found a bug: after pausing, moving a body and unpausing, I cannot move the camera. Changing "follow" to something and back to "none" helps.

How about a perturb button so those special stable orbits can be nudged just enough to destabilize them.
Tried writing an electrostatic particle simulator in Turbo Pascal 7 with BGI as a teen, a handful of particles before it crawled. Then saw a galaxy collision sim on a CD-ROM magazine disc handling thousands of bodies smoothly. Thought it was assembly tricks.. now I'm sure it's algorithmic (avoiding N**2 runtime) but never dug into the specifics. Are charges vs gravity sims essentially the same n-body problem?
EGAVGA.BGI

Oh this brings memories. I have tried to create a little bit of 3D→2D renderer in TP 6.0 but precision was never enough for nodes to not fall apart and 80286 speed was too slow to render anything meaningful except maybe a cube.

There's two ways of doing it, I implemented them both in my PhD and didn't have a ton of fun doing it.

(a) There's a method that works well for monopolar sources (gravitational + electrostatic particles) called the Barnes-Hut method. You effectively divide space up into a quadtree (2D) or octree (3D), and in each cell work out the center of mass / total charge. You make particles in "nearby" cells (using a distance criterion that can be adjusted to speed up/slow down the simulation in a trade off with accuracy) interact directly, and far away cells you just use the center of mass to work out the interaction between any given 'far' particle and the particles in that cell. The method is O(N log N) but in practice, this is 'good enough' for many applications.

(b) uses a more rigorous technique called the Fast Multipole Method which is O(N), where rather than just using the center of mass or sum of charges, you expand the potential from particles out into higher order components which captures the distribution of particles within each cell. This also means you can capture more complex potentials. The downside is that this is a nightmare to implement in comparison to the Barnes-Hut method. Each cell has it's own multipole expansion, and it is 'transferred' to work out the additive contribution to every 'far' cell, calculating a 'local' expansion. Typically people use the most compact representation of these potential expansions which uses Lagrange polynomials, but this is a pain.

Nice! It would be interesting to visualize the total momentum vector, IIRC Verlet being symplectic should be good at preserving symmetries, whereas RK4 is good at conserving energy.
I didn’t realize something until I used this simulation: with three bodies you can eject one body in one direction and the barycentre of the remaining two in another. This means that compared to the original frame of reference you have an orbiting pair that moves.

It’s one of those things that seems so obvious and yet actually seeing it is a really important step in understanding.

There are animations of how the solar system as a whole moves through space. (The solar system isn’t stationary within our galaxy.) The planets therein are forming spirals around the trajectory of the sun in a similar fashion.
Starting out with the stable preset I had no idea how hard it would be to not make a object slingshot out. But it is a really fun sim, I think I will let my kid play with it.
fuck this is so cool. im currently reading deaths end from the three body trilogy and seeing the physical representation is so cool. Makes a certain moment in deaths end seem awesome.
There is also this fun website: https://labs.sense-studios.com/threebody/index.html

Simulating a four-body problem from the point of view of a telluric planet being juggled around by three stars. It's supposed to emulate the evolution of trisolarans from the "Three Body Problem" novel by Liu Cixin.

This is cool thanks for sharing. I hadn't seen this.
nice simulator…

one issue i have always had with the n-body calculations is how can you be sure there is exactly n?

I triggered some bug by pausing the simulation, setting the mass of one of the objects to 29.1, then resuming. The lighter objects bounced into the massive objects a few times, then all three objects were suddenly ejected with a very high velocity.
One thing I'd never really considered before is how frequently bodies get ejected at high speed from the simulation, especially as the number of initial bodies is increased. Suddenly made me realise that the "big bang" which previously seemed a bit of a random and magical theory (obvious question is why would the universe be expanding from a single point when gravity would be immense) now seems a lot more plausible without needing any "magic" to justify it.
Yes, in real world 3-body systems tend to “decay” into a two-body system + one escaping object.
So beautiful, I once had a similar idea, and I'm glad to see someone bring it to life
Excellent work. Is this based on simple Newtonian gravity applied over a uniform time-step, or something more sophisticated?
What you describe is the Euler method, which is well known for being a comparatively bad choice in most situations. The ODE solver can be selected, the default is RK4, which is a Runge–Kutta method of 4th order, it computes the next time step by combining the values at 4 previous time steps.