Chladni Plate: Singing Sand
A brass plate sings through a sweep of resonant frequencies, and tens of thousands of grains of sand dance off its vibrating regions to settle along the nodal lines, drawing Chladni's figures live.
Generated automatically by Claude API (automat) with claude-opus-5.5: the automat wrote the page, looked at its screenshots and fixed it where needed. This is not a single-shot result: comparisons on this site show models in one attempt.
Starting prompt
Build "Chladni Plate: Singing Sand": a cinematic, real-time 3D recreation of Ernst Chladni's 1787 experiment. A square brass plate is driven at a sweep of frequencies. Tens of thousands of grains of fine sand bounce off the vibrating regions and gather along the nodal lines, drawing a new symmetric figure at every resonance. The sand must be simulated, not keyframed. Use a single self-contained HTML file. Three.js and its addons from a CDN via an import map are fine. Build everything procedurally (canvas or data textures are fine), with no external models, images or other files.
The physics (1 unit = 1 cm, plate centred at the origin, y up):
- A square brass plate, 24 cm wide and 1 mm thick, bolted at its centre to a mechanical wave driver. The edges are free.
- Mode shapes use Rayleigh's classic approximation for a free square plate, with u = x/L + 0.5 and v = z/L + 0.5:
- w(x,z) = cos(nπu)·cos(mπv) ± cos(mπu)·cos(nπv).
- Write the gradient analytically.
- Use a sequence of eight modes, for example (1,2)−, (1,2)+, (2,3)−, (1,4)+, (3,4)−, (2,5)+, (4,5)−, (3,6)+. Give each a plausible Kirchhoff plate frequency:
- f = C·(n²+m²), with C derived from h/L² · √(E/(ρ(1−ν²))) for brass (E = 100 GPa, ρ = 8,500 kg/m³, ν = 0.34);
- calibrate C so the frequencies fall roughly between 100 Hz and 3 kHz.
- Drive frequency: sweep smoothly from one resonance to the next. The response amplitude follows a Lorentzian resonance curve with a modest Q, so the plate goes almost quiet between modes and then rings strongly. During a crossover, blend the two neighbouring mode shapes by their Lorentzian weights.
- Sand: about 30,000 grains on a phone and 60,000 on a laptop. Each grain has a 2D position on the plate, a hop height and a vertical velocity.
- At each fixed step, a grain sitting on a vibrating point is kicked upward and sideways at random, in proportion to the local |w|·amplitude.
- It also drifts down the gradient of w², so it migrates towards the nodes. Add gravity, small bounces and damping.
- Grains near the nodes stay still. Grains that slide off an edge fall to the table and respawn sprinkled from above near the centre, so the loop never runs dry.
- Update positions in typed arrays on the CPU with an analytic gradient; it must stay fast.
- The plate itself bends by w·amplitude in a vertex shader. Exaggerate this to a few millimetres so it is visible, and add a faint shimmer, blurred with time, at high amplitude.
The look:
- A dark, quiet physics lab at night. Dark walnut table, a warm key light from one side, a cool rim light, soft shadows, ACES tone mapping and a soft vignette.
- Brushed brass plate: a canvas texture with fine linear streaks, metalness and a warm specular sheen, slightly darker oxidised edges, and a small hex nut at the centre.
- The wave driver underneath: a matte black cylinder with a chrome rod.
- Beside it, a small signal generator with a glowing green canvas display showing the live frequency and a little sine trace. No brands.
- Sand: pale quartz grains as Points with a custom ShaderMaterial (fog: false), sized in world units with perspective attenuation. Shade each grain as a tiny sphere with slight colour variation and occasional sparkling glints from the key light. A soft contact darkening under dense ridges.
- Bloom only on the generator display and grain glints, very gentle. The scene must never wash out.
The film: 8 modes × about 9 s ≈ 72 s, then it loops seamlessly back to mode 1, with the sand simply re-forming.
- For each mode:
1. ~2 s of sweep, where the sand scatters into a hissing blur.
2. ~4 s where the resonance builds and the figure crystallises.
3. ~3 s holding the crisp figure.
- The camera flows automatically between:
- a slow high orbit;
- a near top-down view at each crisp figure, so the pattern reads clearly;
- a low grazing close-up where the hopping grains are visible against the light.
- Use smooth eased paths and never pass under the plate.
Interface:
- A small, elegant caption in a Google Font, bottom left:
- the title;
- "Mode (n,m)" and its ± symmetry;
- one line of real fact. Cycle through facts such as: Chladni toured Europe with this demonstration; Napoleon funded a prize for its theory; Sophie Germain won it in 1816; the sand marks where the plate does not move;
- a live readout of the drive frequency in Hz and the relative amplitude as a thin bar.
- A thin progress bar with eight ticks.
- Drag to orbit and pinch or scroll to zoom. The film camera resumes about 3 s after the last input. Tap or click (without dragging) skips to the next mode.
- Everything starts automatically and is visibly moving from the first frame. Grains are already hopping at load, and mode 1 is mid-build. Use a wider field of view in portrait so it works on a phone (390×844) as well as in a ~1150×700 frame.
Engineering rules (the page must work on the first load, with no fixes):
- Use Three.js r170 from this exact import map, and only methods that exist on each of its classes: <script type="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"}}</script>
- Give every custom ShaderMaterial `fog: false`, and declare every uniform, constant and varying its shaders use.
- Declare each identifier once. Inside one calculation, never reuse a shared scratch vector for two values that are both still needed; use local vectors.
- Guard every animated and simulated value against NaN and runaway velocities. Clamp the timestep after tab switches.
- Cap the pixel ratio at 2 and keep it at ~60 fps on a laptop. Update the Points position attribute with needsUpdate on a single preallocated Float32Array.
- The page runs in an iframe with sandbox="allow-scripts": do not use localStorage, sessionStorage, cookies, alert or window.top. No console errors.
- Answer with the complete file exactly once, in a single ```html code block: no drafts, partial snippets or notes.
Keep planning brief and write the code. Aim for roughly 700 to 1,000 lines, compact and well structured.