The Atlas: A procedural Universe Simulation built in Python + ThreeJS

Hey Three.js community! I’ve been working on The Atlas for the past couple years and wanted to share it with you all. It’s a real-time procedural universe that generates infinite cosmic structures without any pre-stored assets, everything comes from… Pure math.

Live Demo | Alternative Demo | GitHub
*Also docker pull bansheetech/atlas:latest

Actual screenshots

12345

What is this about?

So basically, I created this giant deterministic cube of 10M×10M×10M coordinates. Each point in this cube contains a complete galaxy, which means we’re talking about 1 sextillion galaxies in a single seed. To put that in perspective, that’s 133 times more galaxies than there are grains of sand on all Earth’s beaches combined. Each galaxy can contain from 1M to billions of systems, and each system can contain from 1 to 6 planets (I’m still working on this to create more system variation).

The whole thing runs on SHA-256 hashed seeds that get iterated over themselves. No database, no pre-saved data, just pure mathematics. The backend is Python/Flask and Three.js handles all the visual rendering. What’s crazy is that using the same seed guarantees you’ll get identical universes down to individual cloud formations, no matter what device you’re using.

I kind of implemented Einstein’s block universe theory where time is treated as a coordinate and all moments exist simultaneously. This means planets keep orbiting even when you shut everything down for weeks. When you come back, the system calculates exactly where every celestial body should be based on real Kepler orbital mechanics.

The planet generation stuff

I went a bit overboard and built 50+ custom visual effects from scratch. There are 27 different planet types ranging from boring rocky worlds to completely exotic crystalline formations. Each planet can contain up to 119 elements, including this fictional element I called Z-Divinium. Temperature calculations are based on actual orbital distance and gravity is calculated from real mass.

My PlanetLayerSystem can stack up to 15 simultaneous render passes. It starts with base terrain using displacement mapping and triplanar texturing, then adds atmospheric layers with scattering, particle effects for weather, and dynamic lighting that actually changes as planets orbit their stars.

The moon system was probably where I got most carried away. Planets can have complex moon systems with real hydrostatic relaxation physics. Small moons stay all jagged and irregular, but larger ones gradually become spherical over millions of years. The system actually calculates this evolution and shows you how moons would look at different points in cosmic time, without collisions yet.

The synchronization nightmare

The most challenging part was making sure two people looking at the same planet from different devices see exactly the same thing at exactly the same moment. Every single cloud formation, particle effect, and atmospheric animation has to be perfectly synchronized based on universal time.

This was a pain because I had to solve massive scale differences from universe-wide views down to planetary surface details while maintaining identical mathematical precision across all platforms. Floating-point precision became this huge issue when you’re dealing with coordinates spanning 10 million units and time spans going back to what I call the “Bit Bang”, the moment you create the universe, defined by the cosmic_origin_time value.

I actually built two different universe modes. Core Continuum is a shared universe that started on April 17, 1986 (my birth year), so it’s been evolving for almost 40 years now. Everyone who chooses Core Continuum explores the exact same cosmos. Then there’s Design The Multiverse, where you create your own personal universe with a fresh random seed and a cosmic_origin_time set to the moment you hit create. The deterministic math means your universe will evolve uniquely from that point forward.

How it evolved

The project actually started as a Pillow-based image renderer before I realized I needed real-time interaction and migrated everything to Three.js this past August. There’s probably still some legacy code from that first implementation lurking around in the ./pymodules folder.

The scale is honestly mind-bending. A fully evolved universe after 1.9 million years contains about 50 quintillion solar systems and 300 tredecillion planets. Even if you visited one planet per second without stopping, it would take… 300 trillion years to explore 0.001% of a single universe according to ChatGPT calculations :alien:

Stack: Three.js, React, Vite-Fusion, Hypercorn, Flask and Python

Would love to hear from other Three.js developers about the rendering techniques, especially if anyone’s tackled similar scale challenges or deterministic procedural generation. It includes a small gamification system implemented entirely on localStorage, but you can Export / Import data values too.

Also, the QRs from the screenshots actually take you to the location instantly by using Stargate Links, so you can share instantly the view with others.

Thank you for reaching this far! :heart:

6 Likes

Very nice! A suggestion: can you compress the text upward a bit (e.g. move lines up or reduce text size a bit). The first time I used it, I was a bit perplexed for awhile because I didn’t realize that there was additional material below. The goal would be to make the whole screen visible on a typical widescreen PC or laptop. Keep the graphic display the same size, just move the text up.

1 Like

WOW, this all seems pretty incredible!

1 Like

This looks great!

Procedurally generating stuff is the way to go, and seeded randomization helps to have persistent randomization across space and time.

The numbers of possible variations is somewhat pointless once you reach some threshold. For example, from user’s perspective, 1 000 000 000 000 000 variations provide the same variety as 1 000 000 000 000 000 000 000 000 000 000, which in turn is visually indistinguishable from 10 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 (that is 1 googol).

It is nice you generate not only the images of celestial bodies, but also their parameters and even chemical and biological composition. The few solar systems that I visited at random all had almost circular orbits of planets and share the same orbital plane. Do you have systems with extreme planetal eccentricity and different orbital planes?

From a rendering point of view the textures on planets show seams and polar squeezing. For some stars/planets you could try TSL textures (gas giants, planets, stars, Dyson spheres, clouds, karst, rust or even some life forms).

The slit-like canvas deforms the spheres into ellipsoids. See the left side in the snapshot. This is expected behaviour of perspective projection at extreme aspect ratios.

Is there search functionality? For example, I want to search for a binary system with gas giant planet with moons and silicon-based life on one of the moons.

The naming of bodies is fun. Just make sure the generator of planet names does not generate insults or curses by accident.

In case you plan to add multi-user properties (this would require some global storage of data), here is a suggestion:

  • all bodies have some default name (as it is now)
  • the first person to visit a star/planet/moon has the right to name it (this may require moderation) and from now on this is the official name of the body
5 Likes

Thanks for the feedback! I’ll try to condense the text a bit better so more of the information is visible at once, since there’s usually a lot to show

Thank you!! :heart::heart::heart:

Thanks a lot for the honest feedback! You’re totally right that once you reach a certain threshold the number of variations becomes redundant, but it can always be pushed further. I’ll probably leave that for next summer though, otherwise I’m not sure how I’ll make a living since this is just a side project haha

About the orbits, yes, there are circular and also semi-elliptical ones, though they tend to cluster in circular shapes around the star. With moons it’s actually the opposite, or at least it tends to be, mainly because of the old Pillow implementation where all orbits were generated purely in 2D from the backend as blobs. I still need to work on that and improve it since it’s not as faithful as, for example, the moons’ orbits.. Regarding rendering and textures, I honestly don’t have much experience with Three.js, I’m still a bit of a beginner, but I’ll keep learning as I go. That’s also one of the reasons I joined this forum, it’s amazing to see what people can do with it, it’s insanely powerful. I’ll definitely keep your suggestions in mind.

There’s actually a very limited search already, you can use the --observer flag while running it with a few search parameters I originally added for debugging, to quickly look up certain types of planets or features. Names… Yeah, I’ve already seen some funny ones like ‘Tontos’ which in Spanish means ‘Sillys’, and a couple more… Nothing too bad so far, I guess lol

And finally about multiplayer layer yes, at some point I’ll definitely need a central server if I want to turn it into a real game. Right now I’m experimenting with bittorrent nodes for peer discovery and websockets for communication, so that different instances with different seeds can talk to each other and we can basically ‘jump between universes’. It’s quite a complex task though… Not sure if I will be able to get into that point but it’s priority nº1 at this moment for future development.

Again, really appreciate your feedback, it helps a lot!!!

1 Like

You can’t do much with the galaxy page, there are too many systems to show, unless you want to add some kind of scrolling mechanism.

But for each system, you might be able to do something as simple as shorten the title to “Planets in this System” and move it to the left, with the planet panels to the right of that and the “Go Back to Galaxy” to the right.

And if you want a few more lines, you could change the lines at the top. You could move the title up to the same line as “The Atlas” or you could drop the “ The Atlas” down to the same line as the title. You could probably cut the height of the title bar in half.

The drop down bar is nice, but has so few elements, you could simply display them all the time without a drop down bar.

By doing that, I am guessing that you could get at least a couple of lines to make the items at the bottom visible.

I wouldn’t touch the System Visualization or the Details panels since those appear perfect - although the free space to the right of “Details” might be the perfect place to put the contents of the drop bar.

I believe that those small changes would enable you to fit the system info on a single non-scrolling display.

(I have lots of experience at this kind of task because I had to make sure that the technical memos I gave to my pre-boomer bosses weren’t longer than a single page. So I got used to making all kinds of teeny changes, like changing spacing, font sizes, and margins to make it fit.)

1 Like

nice :slight_smile:

The download 4K screenshot is a bit exaggerated, as the planetary spheres then look angular.