Map Tsunami
terrae/tsunamiFreeComponent
Animated tsunami wave effect with incoming wave, crashing foam, and debris.
Install it
npx shadcn@latest add https://www.terrae.dev/tsunami.jsonSource
1"use client"23import { useEffect, useId, useMemo, useRef, useState } from "react"4import { useMap } from "./hooks"5import type { MapCoordinates } from "./types"67type FoamParticle = {8 positionX: number9 positionY: number10 radius: number11 opacity: number12 velocityX: number13 velocityY: number14 life: number15 maxLife: number16}1718type DebrisParticle = {19 positionX: number20 positionY: number21 size: number22 rotation: number23 rotationSpeed: number24 opacity: number25 velocityX: number26 velocityY: number27}2829type RgbColor = {30 red: number31 green: number32 blue: number33}3435type TsunamiPhase = "approaching" | "crashing" | "receding" | "idle"3637type TsunamiRenderer = {38 width: number39 height: number40 data: Uint8ClampedArray41 context?: CanvasRenderingContext2D42 foamParticles: FoamParticle[]43 debrisParticles: DebrisParticle[]44 isActive: boolean45 startTime: number46 waveProgress: number47 phase: TsunamiPhase48 restartTimerId: number49 onAdd: () => void50 render: () => boolean51 start: () => void52 stop: () => void53 reset: () => void54}5556type TsunamiControl = {57 start: () => void58 stop: () => void59 reset: () => void60 isActive: boolean61 progress: number62 phase: TsunamiPhase63}6465type MapTsunamiProps = {66 id?: string67 origin: MapCoordinates68 target: MapCoordinates69 size?: number70 waveHeight?: number71 waveWidth?: number72 speed?: number73 waterColor?: string74 foamColor?: string75 particleCount?: number76 autoStart?: boolean77 loop?: boolean78 loopDelay?: number79}8081const DEFAULT_SIZE = 30082const DEFAULT_WAVE_HEIGHT = 0.483const DEFAULT_WAVE_WIDTH = 0.884const DEFAULT_SPEED = 300085const DEFAULT_WATER_COLOR = "#0077be"86const DEFAULT_FOAM_COLOR = "#ffffff"87const DEFAULT_PARTICLE_COUNT = 4088const DEFAULT_LOOP_DELAY = 20008990const PARTICLE_SPREAD_ANGLE = 6091const DEGREES_TO_RADIANS = Math.PI / 18092const HALF_CIRCLE_DEGREES = 18093const FULL_CIRCLE_DEGREES = 36094const CRASH_DURATION_MULTIPLIER = 0.595const WAVE_START_DISTANCE = 0.4596const CRASH_OFFSET = 0.197const TRAIL_LENGTH = 0.598const TRAIL_WIDTH = 0.699const FOAM_HEIGHT_RATIO = 0.8100const WAVE_SEGMENTS = 20101const FOAM_PARTICLE_MIN_RADIUS = 3102const FOAM_PARTICLE_MAX_RADIUS = 8103const FOAM_MIN_OPACITY = 0.6104const FOAM_MAX_OPACITY = 0.4105const FOAM_MIN_LIFE = 30106const FOAM_MAX_LIFE = 30107const DEBRIS_MIN_SIZE = 2108const DEBRIS_MAX_SIZE = 4109const DEBRIS_MIN_OPACITY = 0.4110const DEBRIS_MAX_OPACITY = 0.3111const DEBRIS_COLOR = "101, 67, 33"112const GRAVITY = 0.1113const DEBRIS_GRAVITY = 0.15114const FRICTION = 0.98115// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from terrae
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Map Animated Circleanimated-circle | terrae | Components | Free | 1 dep | |
| Map Animated Footprintanimated-footprint | terrae | Components | Free | 2 deps | |
| Map Animated Polygonanimated-polygon | terrae | Components | Free | 1 dep | |
| Map Animated Pulseanimated-pulse | terrae | Components | Free | 1 dep | |
| Map Arc Animatedarc-animated | terrae | Components | Free | 1 dep | |
| Map Blur Areablur-area | terrae | Components | Free | 1 dep | |
| Map Camera Followcamera-follow | terrae | Components | Free | 1 dep | |
| Map Choroplethchoropleth | terrae | Components | Free | 1 dep |
