Optimize WebGL book texture reveal
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user