This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Tsunami

Animated tsunami wave effect with incoming wave from the sea, crashing foam, and debris particles.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://www.terrae.dev/map.json

Then install the tsunami component:

npx shadcn@latest add https://www.terrae.dev/tsunami.json

Origin & Target

The tsunami uses two coordinate props: origin (where the wave starts, in the sea) and target (where the wave crashes, on land). The direction is calculated automatically from origin to target, ensuring the wave always travels from sea to shore.

Speed & Height

Adjust the wave behavior with speed (time in ms for the wave to reach the target) and waveHeight (height as a fraction of size). Faster waves create more dramatic impacts.

Custom Colors

Customize the wave appearance with waterColor (main wave color) and foamColor (foam and spray color). Create dark storm waves, tropical blue waves, or any color variation.

Programmatic Control

Use the useTsunamiControl hook to trigger, stop, and reset the wave animation programmatically. The hook also exposes the current phase (approaching, crashing, receding, idle).

Properties

PropertyTypeDefaultDescription
idstringauto-generatedUnique identifier for programmatic control via useTsunamiControl
origin[number, number]requiredWave starting point in the sea [longitude, latitude]
target[number, number]requiredWave crash point on land [longitude, latitude]
sizenumber300Canvas size in pixels
waveHeightnumber0.4Wave height as fraction of size (0-1)
waveWidthnumber0.8Wave width as fraction of size (0-1)
speednumber3000Time in ms for wave to reach target
waterColorstring#0077beMain wave color (hex)
foamColorstring#ffffffFoam and spray color (hex)
particleCountnumber40Number of foam/debris particles on crash
autoStartbooleantrueStart animation on mount
loopbooleanfalseRepeat the wave animation
loopDelaynumber2000Delay in ms between loops

Use Cases

Tsunami Simulation

Visualize tsunami waves for emergency planning and drills

Coastal Hazards

Show storm surge and coastal flooding risks