mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Stories: Play resumes at the exact paused or sought moment
startScene takes fromProgress and starts partway into a shot: the camera goes on along the rest of the flight, the hold waits only what is left and the scene clock carries on from the same point.
This commit is contained in:
1 parent
fec84dbf78
commit
8734f5e515
11 files changed
+341
-45
No files matched your search
@@ -258,10 +258,15 @@ class PlaybackClock {
|
||||
this._shotProgressTimer = timer;
|
||||
}
|
||||
|
||||
startScene(scene, shot, token) {
|
||||
/** Drive the scene clock through one shot, `offsetSec` into it when resuming. */
|
||||
startScene(scene, shot, token, offsetSec = 0) {
|
||||
this.stopSceneTimer();
|
||||
const generation = this._sceneGeneration;
|
||||
const timing = this.timingForShot(scene, shot);
|
||||
const offset = Math.max(
|
||||
0,
|
||||
Math.min(timing.durationSec, Number(offsetSec) || 0),
|
||||
);
|
||||
if (
|
||||
generation !== this._sceneGeneration ||
|
||||
this._destroyed ||
|
||||
@@ -269,8 +274,8 @@ class PlaybackClock {
|
||||
token.signal?.aborted
|
||||
)
|
||||
return timing;
|
||||
const startedAt = this.now();
|
||||
this.publish(scene, shot, timing.startElapsedSec, {
|
||||
const startedAt = this.now() - offset * 1000;
|
||||
this.publish(scene, shot, timing.startElapsedSec + offset, {
|
||||
running: true,
|
||||
});
|
||||
if (
|
||||
|
||||
@@ -26,7 +26,9 @@ export function buildPlaybackQueue(
|
||||
/**
|
||||
* Run ordered shots through an application-supplied playback adapter.
|
||||
*
|
||||
* Each phase receives {scene, shot, index, total, token}. The adapter owns
|
||||
* Each phase receives {scene, shot, index, total, token, resume}. `resume` is
|
||||
* the queue item's own, opaque to the runner: a queue may start partway into
|
||||
* its first shot, and the adapter decides what that means. The adapter owns
|
||||
* camera/rendering resources and must observe token.signal or token.cancelled
|
||||
* while awaiting work. The runner rechecks both after every phase; it cannot
|
||||
* interrupt an adapter that ignores cancellation. No timers, UI, storage,
|
||||
@@ -68,7 +70,7 @@ export async function playSceneQueue(
|
||||
throw new Error(`Could not leave scene: ${previousScene.title}`);
|
||||
}
|
||||
for (let index = 0; index < queue.length && !cancelled(); index++) {
|
||||
const { scene, shot } = queue[index];
|
||||
const { scene, shot, resume = null } = queue[index];
|
||||
if (activeScene && activeScene.id !== scene.id) {
|
||||
const toRelease = activeScene;
|
||||
activeScene = null;
|
||||
@@ -76,7 +78,14 @@ export async function playSceneQueue(
|
||||
if (cancelled()) break;
|
||||
}
|
||||
activeScene = scene;
|
||||
const context = { scene, shot, index, total: queue.length, token };
|
||||
const context = {
|
||||
scene,
|
||||
shot,
|
||||
index,
|
||||
total: queue.length,
|
||||
token,
|
||||
resume,
|
||||
};
|
||||
for (const phase of SHOT_PHASES) {
|
||||
if (cancelled()) break;
|
||||
await adapter[phase](context);
|
||||
|
||||
Reference in new issue
Block a user