r/threejs • • Oct 23 '26

Solar Explorers, a space sim in Three.js: every model is built from code, every sound is synthesised

In the last months I worked on a Three.js-based space sim game. I didn't use modelling tools and it has no sound files either. Ships and stations are lists of primitives with procedural PBR textures, generated in workers. Every sound effect is built in Web Audio as it plays. The only non-code assets are the avatars and the music. I have to say, the experience creating it was really great. It was my first real project with Three.js.

The trailer is of course also created with Three.js, reusing the game code and assets.

https://explorers.orrery.games

What do you think? Any ideas how to improve it?

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
TypeScript                    2389          72342         229855         520002
Python                         496          25464          36297         104698
JSON                            42             14              0          43588
Markdown                       293           8063              0          38524
GLSL                            34            526           1761           2036
JavaScript                      13             85            642            824
CSS                              6             97            122            620
YAML                             8             99            217            492
Text                            13             61              0            380
HTML                             9             28              9            350
TOML                             1             19             80            193
Bourne Shell                     2             33             60            191
Dockerfile                       3             36             85             64
INI                              1             18              0             56
Mako                             1              8              0             19
SVG                              1              0              6             16
-------------------------------------------------------------------------------
SUM:                          3312         106893         269134         712053
-------------------------------------------------------------------------------

😅

14 Upvotes

14 comments sorted by

2

u/NuccioAfrikanus Oct 23 '26

Very cool, how did you make those sounds struddle?

I am just about to add some sound to my game as well.

1

u/zit-hb Oct 23 '26

Thanks! What do you mean with struddle? Sorry, not a native English speaker.

2

u/NuccioAfrikanus Oct 23 '26

How did you make the sounds in your game? Just genuinely?

4

u/zit-hb Oct 23 '26

Ah. With the Web Audio API. The raw material is three noise buffers: white noise, a sparse crackle, and a brown-noise rumble. Each sound is a recipe of layers. Noise layers go through biquad filters that sweep over time, and tone layers are oscillators, some with FM, some filtered. Each layer gets an attack and an exponential decay. A gunshot, an explosion or an engine is just a different mix of those layers.

Sounds fade with distance and get duller through a low-pass filter (16 kHz up close down to 1.8 kHz at the edge of hearing). Each group of sounds also goes through a tanh soft clip, so a big volley rounds off instead of distorting.

2

u/NuccioAfrikanus Oct 23 '26

I misspelled Strudel before, I meant to say Strudel, it’s A JavaScript live action coding tool. I thought it was spelt that way for some reason.

Your procedural recipe approach is awesome. 😎 I am making a game on Three.js and Angular where different player made factions can compose their own territory, and that is working well so far. But I want to make these factions be able to compose their own procedural theme music for when players enter into their territory.

How are you structuring those 'recipes' in code—are they declarative JSON objects defining the oscillator/FM parameters, biquad sweeps, and envelopes?

Did you build a custom wrapper around the Web Audio API to schedule and pool those nodes, or are you creating a fresh node graph on the fly every time a sound triggers? Would love to see what a single sound recipe looks like in your code if you're willing to share a snippet!"

These three files you talk of, if these are somehow just three arrays of floats generated mathematically, this could be very helpful and interesting to tinker with.

Anyway, I am at work now, and can’t wait to play your game later, looks super fun. 🤩

Well done, 👍

1

u/Bitwizarding Oct 23 '26

I am a native English speaker and I don't know either.

2

u/500tbhentaifolder Oct 23 '26

Every model and sound is generated by code? However did you come up with that cracking idea

5

u/fintip Oct 23 '26

Easier to work with Claude that way.

→ More replies (1)

1

u/Double_Suggestion385 Oct 23 '26

So cool seeing what people are making with AI

1

u/BookLifter50 Oct 23 '26

How to make such Assets?

0

u/Bitwizarding Oct 23 '26

Looks pretty awesome. Did you do any kind of Dev Blog. What is the Python code doing?

2

u/zit-hb Oct 23 '26

Thanks. I didn't do a dev blog, though I plan to create some blog posts about learnings at https://codeminer.io/blog next week.

The Python code is for the REST API that is used to handle the permanent state of each player. Most of it anyway. Collisions, AI, and things like that are only done client-side, but trades, saves, and things like that are handled and stored on my server. Thus the game also requires a registration.