({
className,
dpr,
paused = false,
colors = ['#A6C8FF', '#5227FF', '#FF9FFC'],
backgroundColor = '#0A29FF',
speed = 0.5,
streakCount = 2,
streakWidth = 1,
streakLength = 1,
glow = 1,
density = 0.6,
twinkle = 1,
zoom = 3,
backgroundGlow = 0.5,
opacity = 1,
mouseInteraction = true,
mouseStrength = 0.5,
mouseRadius = 1,
mouseDampening = 0.15,
mixBlendMode
})
| 167 | `; |
| 168 | |
| 169 | const Lightfall = ({ |
| 170 | className, |
| 171 | dpr, |
| 172 | paused = false, |
| 173 | colors = ['#A6C8FF', '#5227FF', '#FF9FFC'], |
| 174 | backgroundColor = '#0A29FF', |
| 175 | speed = 0.5, |
| 176 | streakCount = 2, |
| 177 | streakWidth = 1, |
| 178 | streakLength = 1, |
| 179 | glow = 1, |
| 180 | density = 0.6, |
| 181 | twinkle = 1, |
| 182 | zoom = 3, |
| 183 | backgroundGlow = 0.5, |
| 184 | opacity = 1, |
| 185 | mouseInteraction = true, |
| 186 | mouseStrength = 0.5, |
| 187 | mouseRadius = 1, |
| 188 | mouseDampening = 0.15, |
| 189 | mixBlendMode |
| 190 | }) => { |
| 191 | const containerRef = useRef(null); |
| 192 | const rafRef = useRef(null); |
| 193 | const programRef = useRef(null); |
| 194 | const meshRef = useRef(null); |
| 195 | const geometryRef = useRef(null); |
| 196 | const rendererRef = useRef(null); |
| 197 | const mouseTargetRef = useRef([0, 0]); |
| 198 | const lastTimeRef = useRef(0); |
| 199 | |
| 200 | useEffect(() => { |
| 201 | const container = containerRef.current; |
| 202 | if (!container) return; |
| 203 | |
| 204 | const renderer = new Renderer({ |
| 205 | dpr: dpr ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1), |
| 206 | alpha: true, |
| 207 | antialias: true |
| 208 | }); |
| 209 | rendererRef.current = renderer; |
| 210 | const gl = renderer.gl; |
| 211 | const canvas = gl.canvas; |
| 212 | |
| 213 | canvas.style.width = '100%'; |
| 214 | canvas.style.height = '100%'; |
| 215 | canvas.style.display = 'block'; |
| 216 | container.appendChild(canvas); |
| 217 | |
| 218 | const { arr, count, avg } = prepColors(colors); |
| 219 | |
| 220 | const uniforms = { |
| 221 | iResolution: { value: [gl.drawingBufferWidth, gl.drawingBufferHeight, 1] }, |
| 222 | iMouse: { value: [0, 0] }, |
| 223 | iTime: { value: 0 }, |
| 224 | uColor0: { value: arr[0] }, |
| 225 | uColor1: { value: arr[1] }, |
| 226 | uColor2: { value: arr[2] }, |
nothing calls this directly
no test coverage detected