# Create Photo Grid Ripples

Project a triangular lattice through a depth map, then drive the image distortion and the released nodes from a single expanding wave. The image stays on one rectangular plane. For an existing mesh, use its real surface coordinates instead.

## Register the image

Use a cutout with reliable alpha and an aligned depth map, white toward the viewer. A hand-painted soft dome with raised features works for an initial pass. See [main.js](demo/assets/main.js). Measure the visible image rectangle after object-fit and cropping. Derive pointer UV from that rectangle. Use top-left coordinates for Canvas and invert Y once for WebGL. The demo uses a square plane. For other crops scale horizontal distance by width divided by height before measuring the radius, then undo that scale on displacement.

## Wrap the grid

1. In [ripple.js](demo/assets/ripple.js), offset UV by local depth, compress toward the temples, then calculate `cell = (42x + 21y, 36.4y)`. Use the three lane coordinates `u, v, u − v`. Tune the warp to the new subject’s landmarks.
2. Use [surface-grid.js](demo/assets/surface-grid.js) to divide distance to each lane by its screen derivative. This holds the wires near one backing pixel. Draw round nodes at crossings. Fade toward the eyes and transparent boundary.
3. Ease hover strength in a local radius of 15% of the image height, clamped to 58–135 backing pixels. Blend cool lines and warm dots with overlay math. Sample the red and blue channels about two pixels apart near the pointer. Reject hits in transparent space. Check readability over both hair and bright cheeks.

## Release a wave

- On primary pointer-up, reject cancelled gestures, drags over 9 CSS pixels and alpha below 145/255. Start a new 860 ms clock at the hit. Offer a keyboard-accessible trigger at a known opaque point.
- For normalized time `t` use `radius = .54 * (1 − (1 − t)^1.72)` and `band = .058 + .027t`. Multiply a sine of signed distance to the front by a Gaussian envelope. Fade in over the first 7% and out after 58%. Refract the photograph along the radial slope using an index of 1.46. Sample RGBA together so the silhouette travels with the wave.
- In [particles.js](demo/assets/particles.js), invert the same warp with four short iterations at each lattice intersection. Cache solid points and their neighbors. Push them outward under the front, shorten connecting lines, then settle them to their original positions. Change both projections together when adapting the field.

## Verify

Click a recognizable edge such as the glasses. It should bend as the dots pass and return cleanly. Check off-center clicks, quick repeats, drag scrolling, resizing and empty corners. Disable displacement and scatter for reduced motion. Keep the original photo visible without WebGL. Suspend rendering offscreen.

## Run the example

From this skill folder, run `python3 -m http.server 4173 --bind 127.0.0.1 -d demo` and open [the local demo](http://127.0.0.1:4173/). The demo runs without a build or remote assets. See the [preview](demo/preview.jpg) and [recreation prompts](demo/PROMPT.md).

Adapted from the Stillhertz landing page. Keep the host project's typography, subject and layout. Bring over only the relevant technique. The sample is a single page. For a routed application, cancel animation frames, remove listeners, disconnect observers and dispose GPU resources on unmount.

---

Copyright (c) 2026 Meng To Copyright © 2010-2025 three.js authors

The license files are attached. [MIT](https://knowen.md/f/3c02f208-fea4-4055-a09c-593a4f764a38) · [MIT](https://knowen.md/f/b628076a-0f85-48c1-95d0-f48023f47de0)

The attached ZIP contains the pinned supporting files cleared for import. Applicable license notices are attached or included when cleared.