Jelly Pufferfish Soft-Body Study
By @Bengiyai. Made with Claude Opus 5.5. Watch the original post.
Prompt
Build a single-file interactive three.js (r170, ES module via import map) soft-body study called "Puffer Jelly", No. 059 in a "Material Studies" series. A long-spine porcupinefish cast in two layers of jelly rests on its belly on a pale studio table, fins out, lips pursed. Handled gently, it stays calm. Treat it roughly and it gulps water and inflates into a spiky ball, then slowly lets the air out when left alone. Geometry (signed distance field, two rest poses): - Calm body: a thick teardrop of smooth-unioned ellipsoids. Big blunt forehead, widest just behind the eyes, a soft belly pressed flat on the table, and a fast taper to a short tail stalk. Fleshy pursed lips at the front, eyes on raised bumps high on the head. - Puffed body: almost a sphere, about three times the calm volume, with the eyes, the lips (now a round open "O") and the tail stalk still sticking out. Map every calm rest point onto it along rays from the body centre, so both poses share one mesh and one lattice. The belly fills first. - Fins: a rounded tail fan, small dorsal and anal fins set far back, and two paddle-shaped pectoral fins just behind the eyes. Each is a thin membrane stretched between rays, scalloped between them. - Spines: about 400 sugar thorns with flared tripod roots, spread evenly over the skin (none on the eyes or lips). Calm, they lie flat toward the tail. Puffed, they stand straight out, about 2.5 times longer, rising in a wave from head to tail. - Inside: about 20 small trapped air bubbles that drift apart as the body swells. Simulation: - Hex lattice with 5 tets per cell, boundary nodes snapped to the surface and a node layer exactly on the floor. - CPU XPBD shape matching on a fixed 60 Hz step with 10 substeps. The head and fin bases are firmer than the belly. - Render meshes from surface nets (clear jelly plus a cream core layer), embedded barycentrically in the tets. - Inflation is a muscle made by rewriting rest shapes: every rest length and shape-matching target blends from the calm pose toward the puffed pose, so the body swells through the physics, overshoots and wobbles. Puffed, the jelly is stiffer and bounces like a ball on its spine tips. - Fins are stiff at the base and soft at the tip, so they lag behind the body. The pectorals scull all the time and the eyes turn toward the pointer. Temper: - A stress value from 0 to 100% that slowly decays. A single click adds a little, each quick click in a row adds more than the last, and dragging fast or shaking adds stress too. Slow drags add nothing and calm it faster. - Under 35% it only dents, wobbles and flicks its fins. From 35% the spines half lift and shiver. At 70% it gulps 8 times, about half a second apart, and each gulp inflates it one visible step. - Left alone for 4 seconds while puffed, it exhales over about 4 seconds and folds its spines from tail to head. Rendering (hand-written ShaderMaterials): - Key-light shadow map, a back-face thickness pass, and refraction through the front faces with Beer–Lambert absorption and a scattering tint. - Clear jelly in the fish's natural colours: warm tan #A88553 on the back fading to #C9AE84 on the flanks, soft brown blotches #6E4B27, small white freckles and dark speckles. All marks live in body coordinates, so they stretch apart as it puffs, and each has a subtle bump. - The cream layer #EFE9DC fills the belly up to a soft line low on the flank, and fills the lips. - A soft pink mouth that opens into a round "O" as it puffs. - Eyes are glossy beads: a big black pupil, a flecked gold-brown iris and a dark teal rim. - Fins are clear yellow jelly #E8C640 with darker rays. Spines are ivory sugar, clearer toward the tip. - Khronos PBR Neutral tone mapping and 4× MSAA. Camera: one fixed three-quarter view from about 45° above, with the fish in the middle at about a third of the screen width and plenty of empty table around it. No auto-orbit; drag empty space to orbit. Interaction: - Click to poke. Drag any part to pull the jelly; lift it and let go to drop it. - Buttons: Puff, Calm, Reset. Sliders: Firmness, Internal damping, Temper. Checkboxes: ¼ speed, Show mesh. A Pause button. UI: - Editorial layout on a warm grey backdrop (#e2dfda): an italic serif title "Puffer Jelly.", the caption "Calm under a gentle hand. Too rough, and it gulps water into a spiky ball.", a specimen panel marked "fig. 59", and a status pill "THREE.JS · LIVE". - Live readouts: stress and inflation as bars, length and girth in cm (scale 1 unit ≈ 28 cm), mass in g from enclosed volume at 1.05 g/cm³, pokes, and state (Calm, Alarmed, Puffing, Puffed, Exhaling). - A collapsible "Inside the experiment" notes section. - Responsive stacked layout on phones, a WebGL2 fallback message, prefers-reduced-motion support. English UI throughout.