Workers P2: Szene bekommt flush() für die Rückkehr in den Tab

Die Bühne beruhigt die Regie beim Zurückkehren (alles zu Ende gespielt, alle heim, Aufzug und Effekte leer); im Standbild zeichnet flush() ein Bild.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-18 04:20:35 +00:00
1 parent e6bc2d938a
commit 319e731d0e
2 files changed
+53 -3

No files matched your search

+11 -2
View File
@@ -35,7 +35,7 @@ const bindGlobal = (name) => (typeof globalThis[name] === 'function' ? globalThi
function inertHandle() {
const nop = () => {}
return {
destroy: nop, setState: nop, pushEvents: nop, select: nop, setPaused: nop, resize: nop, zoomBy: nop, resetView: nop,
destroy: nop, setState: nop, pushEvents: nop, select: nop, setPaused: nop, flush: nop, resize: nop, zoomBy: nop, resetView: nop,
locate: () => null,
stats: () => ({ frames: 0, avgDrawMs: 0, zoom: 1 }),
debug: () => ({ pending: 0, agents: [], lift: 'idle', fx: 0 }),
@@ -43,12 +43,14 @@ function inertHandle() {
}
/* mountTower(canvas, { onSelect, reducedMotion = false, coarsePointer = false, fontsReady, dpr = 1, raf, caf, now })
→ { destroy(), setState(state), pushEvents(events), select(workerId|null), setPaused(bool), resize(), zoomBy(faktor),
→ { destroy(), setState(state), pushEvents(events), select(workerId|null), setPaused(bool), flush(), resize(), zoomBy(faktor),
resetView(), locate(workerId): { x, y } | null, stats(): { frames, avgDrawMs, zoom }, debug() }
Rasterweite je Bild: k = Canvas-Breite / (320 / zoom). Reihenfolge je Bild: Weiß, Außenwelt, Turm, Räume, Aufzug hinten, Figuren,
Aufzug vorn, Effekte, Pausenschleier. onSelect(id | null) kommt nur bei Klicks des Nutzers, nie bei select().
reducedMotion (und fehlendes raf): keine Schleife; setState, pushEvents, select, resize und die Kamera zeichnen je ein Standbild,
pushEvents spielt die Regie sofort zu Ende. fontsReady (Promise): nach dem Laden der Schrift wird einmal neu gezeichnet.
flush() beruhigt die Regie auf einen Schlag (alles zu Ende gespielt, alle Figuren heim, Aufzug und Effekte leer): die Bühne ruft es
beim Zurückkehren in den Tab, damit nichts aus der Zeit davor nachläuft.
locate liefert die Mitte der Trefferfläche in CSS-Pixeln relativ zur Leinwand (null: unbekannt oder außerhalb der Ansicht).
Nach destroy() ist jeder Aufruf wirkungslos. */
export function mountTower(canvas, options = {}) {
@@ -318,6 +320,13 @@ export function mountTower(canvas, options = {}) {
}
},
flush() {
if (destroyed) return
director.flush()
if (still) calm()
draw()
},
setPaused(value) {
if (destroyed) return
const next = !!value