fix bug + 30fps lock

This commit is contained in:
code002lover 2025-12-08 19:50:19 +01:00
parent 696a9ba9b3
commit aa8fb73c61

View File

@ -226,9 +226,24 @@ export const ShaderBackground: React.FC<ShaderBackgroundProps> = ({
gl!.bindTexture(gl!.TEXTURE_2D, ichannel1_texture); gl!.bindTexture(gl!.TEXTURE_2D, ichannel1_texture);
gl!.uniform1i(final_iChannel1, 1); gl!.uniform1i(final_iChannel1, 1);
let last_update: number = 0;
const compiled_theme = theme;
function update(now: number) { function update(now: number) {
// time in seconds // time in seconds
const time = now / 1000; const time = now / 1000;
if (compiled_theme !== theme) {
return;
}
if (time - last_update < (1 / 30)) {
requestAnimationFrame(update);
return;
};
last_update = time;
gl!.clear(gl!.COLOR_BUFFER_BIT); gl!.clear(gl!.COLOR_BUFFER_BIT);
setTime(finalProgram!, time); setTime(finalProgram!, time);