Reset per-game reveal state on new game so reveal animates over cached content
Starting a new game reuses block ids (1,2,3...). The reveal clock's per-block start times (activeRevealBlockStarts in the lab) and the renderer's animation/ revealed sets are keyed by block id and were never cleared on a client reset, so a new game over already-cached content inherited the previous run's start times. beginPageReveal then computed a huge elapsed and the shader treated the reveal as already complete — showing everything at once instead of animating. resetClientPlaybackAndDisplay (run on new game and restore) now emits story:client-reset; the lab clears activeRevealBlockStarts/pending reveal state, the texture renderer clears active animations and revealed-block ids, and the timeline invalidates prepared segments. So each game starts with a clean reveal clock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -657,8 +657,15 @@ class GameLoopModule extends BaseModule {
|
||||
if (inputHandler && typeof inputHandler.clearHistory === 'function') {
|
||||
inputHandler.clearHistory();
|
||||
}
|
||||
|
||||
// Signal a client reset so transient, block-id-keyed reveal/animation state is
|
||||
// cleared. Without this, a new game that reuses block ids over already-cached
|
||||
// content keeps the previous run's reveal start times and skips the animation.
|
||||
document.dispatchEvent(new CustomEvent('story:client-reset', {
|
||||
detail: { reason: 'client-reset' }
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Create the singleton instance
|
||||
|
||||
Reference in New Issue
Block a user