fix bug + 30fps lock
This commit is contained in:
parent
696a9ba9b3
commit
aa8fb73c61
@ -226,9 +226,24 @@ export const ShaderBackground: React.FC<ShaderBackgroundProps> = ({
|
||||
gl!.bindTexture(gl!.TEXTURE_2D, ichannel1_texture);
|
||||
gl!.uniform1i(final_iChannel1, 1);
|
||||
|
||||
let last_update: number = 0;
|
||||
|
||||
const compiled_theme = theme;
|
||||
|
||||
function update(now: number) {
|
||||
// time in seconds
|
||||
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);
|
||||
|
||||
setTime(finalProgram!, time);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user