Update fast_lightmap.js

This commit is contained in:
redbirdly 2024-06-08 08:56:42 +08:00 committed by GitHub
parent 6321f0f58d
commit 35b5475e5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -266,8 +266,19 @@ elements.plasma.tick = function(pixel) {
};
// Wait for loading
// if it loads too soon then width will be undefined
setTimeout(() => { initializeLightmap(width, height); }, 700);
let i = 0;
let interval = setInterval(() => {
if (typeof width !== 'undefined') {
clearInterval(interval);
initializeLightmap(width, height);
}
i += 1;
// if width is not defined for 3 seconds or longer, it's probably broken, so it will just try run the function anyways to see the error
if (i >= 30) {
clearInterval(interval);
initializeLightmap(width, height);
}
}, 100);
// Add code to functions instead of replacing them
let originalTick = tick;