Optimize WebGL book texture reveal

This commit is contained in:
2026-06-06 16:44:15 +02:00
parent 1b8c8f8bce
commit 081cfa9902
7 changed files with 183 additions and 77 deletions
+3 -19
View File
@@ -484,28 +484,12 @@ class WebGLBookSceneModule extends BaseModule {
handleProcessState(event) {
const state = event.detail?.state || 'ready';
if (state === 'ready' || state === 'paused' || this.mode !== '3d') {
this.stopAnimatedTextureRefresh();
this.triggerTextureRefresh();
return;
}
this.startAnimatedTextureRefresh();
this.stopAnimatedTextureRefresh();
if (state === 'ready' || state === 'paused' || this.mode !== '3d') this.triggerTextureRefresh();
}
startAnimatedTextureRefresh() {
if (this.textureRefreshAnimationId) return;
const tick = (now) => {
if (this.mode !== '3d') {
this.textureRefreshAnimationId = null;
return;
}
if (now - this.lastAnimatedTextureRefresh > 100) {
this.lastAnimatedTextureRefresh = now;
window.BookLabDebug?.redrawPageTextures?.();
}
this.textureRefreshAnimationId = window.requestAnimationFrame(tick);
};
this.textureRefreshAnimationId = window.requestAnimationFrame(tick);
this.stopAnimatedTextureRefresh();
}
stopAnimatedTextureRefresh() {