Skip to main content
100%

Wave Simulation

✓ Published0🌍 Public
CCurran Kelleher
Last edited Oct 9, 2025
Created on Jul 5, 2019

An interactive wave simulation animates a one-dimensional fluid surface using the Canvas 2D API. The animation runs via `requestAnimationFrame`, rendering a filled water silhouette defined by a grid of 150 cells whose heights evolve through neighbor-based velocity updates, dampening, and mass conservation correction. Clicking or dragging the mouse pulls the water surface directly toward the cursor. The underlying physics model uses simple spring-like forces between adjacent cells, with pull strength and dampening factors controlling the motion.

AI-generated description

Interactive simulation of one dimensional fluid waves.

Try clicking & dragging!

The original wave simulation was done in 2012, part of HTML5Examples (source).

I just went through and upgraded the code to be more modern. Fun!

MIT Licensed

Similar vizzes