export function debounce(func, wait) { let timeout; return function (...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), wait); }; } export function getNormalizedPointer(event, windowWidth, windowHeight) { return { x: (event.clientX / windowWidth) * 2 - 1, y: -(event.clientY / windowHeight) * 2 + 1, }; } export function computeNoiseOffset(index) { const glslRandom = (x, y) => { const dot = x * 12.9898 + y * 78.233; const sin = Math.sin(dot); const val = sin * 43758.5453123; return val - Math.floor(val); }; const instanceNoise = glslRandom(index, 123.456); return (instanceNoise - 0.5) * 0.3; }