Phase 6 WIP working

This commit is contained in:
Dejvino
2026-08-05 12:20:55 +02:00
parent 968101c532
commit d0f93e5c55
3 changed files with 37 additions and 9 deletions
+16 -4
View File
@@ -95,18 +95,26 @@ document.addEventListener('drop', (e) => {
// ---------------------------------------------------------------- transport
function seekTo(frame) {
function seekTo(frame, options = {}) {
if (!state.show.ready) return;
const clamped = Math.max(0, Math.min(state.show.frameCount - 1, Math.round(frame)));
dom.audio.currentTime = clamped / state.show.fps;
state.show.seek(clamped);
state.show.seek(clamped, options);
strip.setFrame(clamped);
}
function togglePlay() {
if (!state.show.ready) return;
state.playing = !state.playing;
if (state.playing) dom.audio.play(); else dom.audio.pause();
if (state.playing) {
dom.audio.play().catch((err) => {
console.warn('[flow-state] playback failed:', err);
state.playing = false;
dom.play.textContent = '▶';
});
} else {
dom.audio.pause();
}
dom.play.textContent = state.playing ? '❚❚' : '▶';
}
@@ -376,6 +384,7 @@ function resize() {
window.addEventListener('resize', resize);
let lastPanelSection = -1;
let lastRenderedFrame = -1;
function frame(now) {
requestAnimationFrame(frame);
@@ -393,7 +402,10 @@ function frame(now) {
if (dom.audio.ended) { state.playing = false; dom.play.textContent = '▶'; }
}
show.present(show.renderFrame(show.timeline.frame));
if (state.playing || show.timeline.frame !== lastRenderedFrame) {
show.present(show.renderFrame(show.timeline.frame));
lastRenderedFrame = show.timeline.frame;
}
strip.setFrame(show.timeline.frame);
strip.draw();