// Toggle play/pause function togglePlayPause() { if (isPlaying) { cancelAnimationFrame(animationID); isPlaying = false; } else { isPlaying = true; animationID = requestAnimationFrame(render); } } // Function to refresh the pattern with a new random seed const selectedSeeds = [53, 118, 506]; var seedCount = 2; function refreshPattern(seed) { timeOffset = performance.now(); //randomSeed = Math.floor(Math.random() * 1000,0); randomSeed = seed; gl.uniform1f(seedLocation, randomSeed); if(!isPlaying){ isPlaying = true; animationID = requestAnimationFrame(render); } console.log('seed:', randomSeed); } function startFromZeroTime(){ console.log("Restarting animation from time = 0"); // Cancel current animation if running if (animationID) { cancelAnimationFrame(animationID); } // Set the time offset to the current time // This will be subtracted in the render function timeOffset = performance.now(); // Reset frame counter for FPS calculation frameCount = 0; lastTime = performance.now(); // Make sure all other uniforms are updated updateUniforms(); // Ensure animation is playing isPlaying = true; // Start the animation loop from the beginning animationID = requestAnimationFrame(render); } // Add this function to handle canvas resizing function updateCanvasSize() { // Update canvas dimensions to window size canvas.width = window.innerWidth; canvas.height = window.innerHeight; // Update the WebGL viewport to match gl.viewport(0, 0, canvas.width, canvas.height); // Re-render if not already playing if (!isPlaying) { drawScene(); } // If recording is active, we need to handle that if (recordVideoState) { stopRecording(); startRecording(); } } //intro overlay info screen let musicPlaying = false; let isZenMode = false;