MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / Lightfall

Function Lightfall

src/tailwind/Backgrounds/Lightfall/Lightfall.jsx:168–359  ·  view source on GitHub ↗
({
  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
})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

prepColorsFunction · 0.70
hexToRGBFunction · 0.70
resizeFunction · 0.70
callIfFnFunction · 0.70

Tested by

no test coverage detected