Aquarius: a 3D aquarium game where every fish, plant and rock is made in code

Hi everyone! I’ve been working on Aquarius, a free 3D aquarium game that runs in the browser:

You build and aquascape your own tanks, stock them with real species and try to keep them alive. Temperature, pH, oxygen and waste change over time, fish grow to their real adult size, and big fish can eat tank mates small enough to fit in their mouth. You can breed new colours and visit the aquariums other players have built. There are 112 species in 232 colours (freshwater and saltwater fish, shrimp, crabs, snails, jellyfish and axolotls), 183 plants, corals, rocks and ornaments, and tanks from a 30 L nano cube up to a 1,000 L ocean exhibit. You can play as a guest, no sign-up needed.

The part I think people here will like: the 3D scene doesn’t load a single model or texture file. Everything is generated in code with three.js (r186):

  • Fish are procedural meshes. Each species has a body profile that gets lofted into a mesh, and the fins are separate surfaces. Rays, seahorses, shrimp, snails, crabs, jellyfish and axolotls have their own builders.
  • Swimming happens in the vertex shader. I patch MeshStandardMaterial and MeshPhysicalMaterial with onBeforeCompile to add the body wave, a tail that lags and flutters, sculling pectoral fins and rippling dorsal fins, with different motion for eels, rays and jellyfish.
  • Skin: stripes, spots, bands, scales and eyes are painted on a canvas for every colour variant. On the higher quality settings the skin also gets a clearcoat, a generated scale normal map and thin-film iridescence for the shine of tetras and koi.
  • Caustics come from a tileable Voronoi texture generated on a canvas. It’s sampled twice with different scrolling, the two samples are combined with min(), and the result is added in the lighting stage of the materials inside the tank.
  • Water fog only covers the part of each view ray that goes through the water (a ray/box intersection in the fragment shader), so the tank looks right from outside the glass and also when you dive in.
  • Scenery: plants, rocks and ornaments are built from small primitives with vertex colours baked in, then merged into one geometry per material, so the whole aquascape shares one small set of materials. Plant sway is a per-vertex weight in the same shader.
  • Behaviour uses a steering model: schooling, feeding, aggression, hiding, sleeping among the plants at night, courtship, and predators that really eat smaller fish.
  • Day and night: each tank’s light runs on a timer that follows the viewer’s local clock. At night there’s only moonlight and the nocturnal fish come out.
  • Landing page: it’s the same engine running full screen behind the page, and scrolling moves the camera from shot to shot.
  • Even the shop icons are rendered on the fly by a small offscreen WebGL context.

Stack: TypeScript, three.js, React for the UI, Vite, and a Node server with WebSockets and SQLite for the multiplayer side. The engine alone is around 35k lines of TypeScript. An Android app built with Capacitor is on the way.

It’s still growing, so any feedback is welcome, especially how it runs on your device and how the fish look and move. Happy to explain how any part of it works.