Experiment · Procedural simulation

Ephyra

One autonomous jellyfish in a dark ocean.

Built entirely in the browser, Ephyra uses a seeded simulation to drive the jellyfish’s movement, deformable body, and surrounding water. The animal is always the same individual, but each visit begins with a different simulation state. It is made to be left open, asking nothing of the viewer.

  • Three.js
  • TypeScript
  • GLSL
  • Web Audio
Ephyra running in the browser: a translucent blue jellyfish swims left through dark blue water, with its oral arms and long tentacles streaming behind the bell.
A frame from the live page. Tap or click to disturb the water. M or a long press toggles sound; the mouse wheel or Up and Down keys adjust its level, and F toggles full screen.
Ephyra running in the browser: a translucent blue jellyfish swims left through dark blue water, with its oral arms and long tentacles streaming behind the bell.
A frame from the live page. Tap or click to disturb the water. M or a long press toggles sound; the mouse wheel or Up and Down keys adjust its level, and F toggles full screen.

How it works

Behind the simulation

Procedural body

Ephyra imports no models, textures or audio files. The bell mesh is built at runtime from one formula for its outline, which changes as the bell contracts and reopens. The simulation and the renderer both use that formula, so what is simulated and what is drawn cannot drift apart.

The 24 tentacles and 4 oral arms are chains of points pinned to the bell. Their shape comes from the body’s motion and the water around it. A fixed asymmetry in the bell and differences in the shape and ruffles of the oral arms give the animal its individual character.

A closer frame of Ephyra: the translucent bell seen from the side, with ruffled oral arms and fine tentacles trailing to the left.
A closer frame from the live page.

Rendering

The scene is shaded by custom GLSL materials in Three.js. The bell is drawn as four ordered, transparent layers: the back and front faces of its outer and inner walls, with the arms and tentacles between the walls. There is no refraction pass. Depth comes from that layering and from opacity that rises toward the bell’s outline, where the surface turns away from the viewer.

Canals and other internal structures are procedural and defined on the bell’s surface, so they move with the tissue as it deforms. Subtle relief along the canals bends the shading normal, so the light reveals the structure of the tissue rather than simply colouring it. Bloom is restrained to luminous accents; the lit body stays below the bloom threshold.

Motion

After each stroke, the chance of the next one rises the longer the animal waits. A slowly varying activity level sets how steeply: a calm animal strokes irregularly and sometimes skips a beat, an active one almost rhythmically. Thrust is derived from the same stroke curve that deforms the bell. Changes in activity give the animal periods of drifting, gentle hovering and more determined swimming, without switching between authored animations.

A softly bounded habitat is defined in ocean coordinates, independent of the screen. When the animal strays, it gradually changes its heading and swimming effort to return. The camera is still while the animal is comfortably in view, and otherwise follows with damped translation. It never steers the animal.

Living water

One slowly changing ocean state shapes the strength and evolution of the current, the density of suspended matter, the clarity of the water and the sound. The bell, its trailing parts and the particles share the same divergence-free velocity field, so the water and the animal move coherently as the ocean passes between calm and stirred conditions.

The light follows the visitor’s local time of day and the phase of the moon, both computed on the device from its clock, with no location data or network request. Occasionally, the animal exhibits a brief, unusual luminous expression.

Determinism

The simulation advances only in fixed steps of 1/60 s and takes its randomness from seeded streams. It has no access to the DOM, the wall clock or the viewport, so the same seed and world-space water disturbances at the same simulation steps give the same state in a browser and in Node, independently of the camera or screen shape. Each page load picks a new seed.

That covers the simulation state, not the picture. The renderer interpolates between steps for 90, 120 and 144 Hz displays and adapts its resolution to the device. The camera, renderer and audio read the simulation without writing back to it.

Session seed

Tap or click

Simulation core

Ocean state, water current, motion, stroke rhythm, body shape and touch waves.

Rendering

Interpolates between steps and follows the animal.

Audio

Taps also reach it directly, forming melodic phrases.

Taps enter the simulation as waves and reach the audio directly as notes. Nothing flows back into the simulation.

Interaction and audio

A tap or click starts a pressure wave in the water. The tentacles, oral arms and suspended particles move with it, and the bell is nudged slightly. The animal’s decisions take no input from the visitor.

The ambience is filtered noise synthesized in Web Audio. Its level, filtering and panning follow the simulation, including the strength of the current, the animal’s speed and distance, and each stroke. Each tap also plays a soft note, panned to where the tap landed. A separate seeded, rule-based generator selects pitches from a pentatonic scale, remembering recent notes, intervals and the shape of the phrase. The visitor supplies the rhythm; the generator shapes the melody, favouring small steps, avoiding immediate repeats within a phrase and tending towards resolution. After a long pause, the next tap begins a new phrase.

There is no visible interface. Where supported, the page requests a screen wake lock while visible, so it can be left open on a display.

Verification

Because the core runs in Node, it is tested there. Automated tests check that a seed reproduces bit-identical state, and a batch runner simulates many seeds to measure how the animal behaves over time.

In a desktop batch of 100 seeds, 15 simulated minutes each, the bell stayed in view throughout every run (at least 25% of its projected bounding box inside the frame). The camera was exactly still for about 57% of the time on average. In portrait, part of the bell can briefly sit outside the frame while the camera catches up.

A 119-minute real-time run of the production build with scheduled interaction found no sustained accumulation of audio or rendering resources. That measurement was made in headless Chrome on one laptop. Core browser behaviour was also checked in headless Firefox; performance on weaker devices and compatibility with Safari remain unverified.

Runtime dependencies
Three.js r187 only
Bell mesh
1,537 vertices per wall, rebuilt only when the pose changes
Automated tests
440
Production build
One JavaScript file including Three.js, about 227 KiB gzipped