mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +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
@@ -30,7 +30,7 @@ export function directorSettled(director) {
|
||||
* panel plays it, and reports the scene clock in the shape the Stories
|
||||
* timeline reads. SceneDirector has no pause: pausing seeks to the current
|
||||
* moment (which stops the run and frames it), and playing again starts the
|
||||
* run at the shot that moment is in.
|
||||
* run from that same moment.
|
||||
*
|
||||
* @param {import('../scenes/director.js').SceneDirector} director
|
||||
* @param {object} story A catalog story of kind 'gev'.
|
||||
@@ -124,14 +124,13 @@ export function createGevPlayer(director, story, hooks = {}) {
|
||||
wallMs = 0;
|
||||
shotIndex = 0;
|
||||
}
|
||||
const shots = director.listShots(sceneId);
|
||||
const afterShotId =
|
||||
shotIndex > 0 ? (shots[shotIndex - 1]?.id ?? null) : null;
|
||||
playing = true;
|
||||
tick();
|
||||
// Go on from the exact moment shown: partway into its shot, with the
|
||||
// camera, the hold and the clock carrying on from there.
|
||||
const result = await director.startScene(sceneId, {
|
||||
single: true,
|
||||
afterShotId,
|
||||
fromProgress: durationMs ? wallMs / durationMs : 0,
|
||||
preview: true,
|
||||
});
|
||||
// startScene resolves after the run finishes, not when it starts.
|
||||
|
||||
@@ -34,7 +34,7 @@ function deferredDirector({ running = false } = {}) {
|
||||
|
||||
seekScene: (id, f) => calls.push(`seek ${f}`),
|
||||
startScene: (_id, options) => {
|
||||
director.startAfterShotId = options.afterShotId;
|
||||
director.startOptions = options;
|
||||
calls.push('start');
|
||||
director.running = true;
|
||||
return new Promise((resolve) => {
|
||||
@@ -154,7 +154,11 @@ test('Play from a paused link in the final quarter-second stays in the final sho
|
||||
59800,
|
||||
'the link is not treated as complete',
|
||||
);
|
||||
assert.equal(director.startAfterShotId, 'a', 'resume in the final shot');
|
||||
assert.equal(
|
||||
director.startOptions.fromProgress,
|
||||
59800 / 60000,
|
||||
'resume at the same moment of the final shot',
|
||||
);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
@@ -166,7 +170,7 @@ test('Play after the actual end still starts the scene from shot one', async ()
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(player.state.wallMs, 0);
|
||||
assert.equal(director.startAfterShotId, null);
|
||||
assert.equal(director.startOptions.fromProgress, 0);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
@@ -196,7 +200,11 @@ test('in the director’s order, a paused link near the end resumes in its final
|
||||
assert.equal(player.state.wallMs, 59800, 'not rounded to the end');
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(director.startAfterShotId, 'a', 'resume in the final shot');
|
||||
assert.equal(
|
||||
director.startOptions.fromProgress,
|
||||
59800 / 60000,
|
||||
'resume at the same moment of the final shot',
|
||||
);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
@@ -215,7 +223,61 @@ test('a run that ends on its own is rounded to the end, and Play then starts ove
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(player.state.wallMs, 0);
|
||||
assert.equal(director.startAfterShotId, null, 'from the first shot');
|
||||
assert.equal(director.startOptions.fromProgress, 0, 'from the start');
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
|
||||
test('Play after Pause goes on from the paused moment, not the shot’s start', async () => {
|
||||
const director = deferredDirector();
|
||||
const player = createGevPlayer(director, story);
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
// The run is 42 s in, 12 s into the second shot, when it is paused.
|
||||
director.publish({
|
||||
sceneDurationSec: 60,
|
||||
sceneElapsedSec: 42,
|
||||
shotIndex: 1,
|
||||
running: true,
|
||||
});
|
||||
player.pause();
|
||||
director.finishRun();
|
||||
await playing;
|
||||
assert.equal(player.state.wallMs, 42000);
|
||||
const again = player.play();
|
||||
await turns();
|
||||
assert.equal(director.startOptions.fromProgress, 42000 / 60000);
|
||||
director.finishRun();
|
||||
await again;
|
||||
});
|
||||
|
||||
test('Play after a seek goes on from the time sought', async () => {
|
||||
const director = deferredDirector();
|
||||
const player = createGevPlayer(director, story);
|
||||
player.seek(12345);
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(director.startOptions.fromProgress, 12345 / 60000);
|
||||
assert.equal(director.startOptions.afterShotId, undefined);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
|
||||
test('Play from a paused link goes on from the link’s time', async () => {
|
||||
const director = deferredDirector();
|
||||
const player = createGevPlayer(director, story);
|
||||
// Opening a paused link seeks to its time, and the director reports it.
|
||||
player.seek(17500);
|
||||
director.publish({
|
||||
sceneDurationSec: 60,
|
||||
sceneElapsedSec: 17.5,
|
||||
shotIndex: 0,
|
||||
running: false,
|
||||
seeking: true,
|
||||
});
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(director.startOptions.fromProgress, 17500 / 60000);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
Reference in new issue
Block a user