mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Bring launches up as the world time passes them, and play the whole track
Away from live, a launch shows from its lift-off on: its marker, label, paths and orbit stay hidden while the world time is before it, so scrubbing or playing brings the launches up in the order they flew. The selected mission stays whenever it flies, and live shows every launch as before. Play on the timeline runs the whole track in about a minute, from its start when at live, and runs the clock itself past weather's own replay. It goes live when it reaches now, or holds at an end that lies ahead of now. Going live puts the rate back to 1.
This commit is contained in:
1 parent
48093108b1
commit
0aa54dfa97
9 files changed
+326
-25
No files matched your search
@@ -148,3 +148,73 @@ test('the track runs over the time the layers show, to now, and scrubs', async (
|
||||
assert.equal(worldClock.isLive(), false, 'a scrub past now stays there');
|
||||
assert.equal(worldClock.now(), ahead);
|
||||
});
|
||||
|
||||
test('play runs the whole track in a minute, from the start when at live', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start, end: now - 86_400_000 }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
// Weather's replay stepping its own frames does not take the track's play.
|
||||
const stepped = [];
|
||||
const driver = worldClock.attachDriver({
|
||||
play: () => stepped.push('play'),
|
||||
pause: () => stepped.push('pause'),
|
||||
});
|
||||
t.after(() => driver.detach());
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
worldClock.pause();
|
||||
await nextTick();
|
||||
assert.deepEqual(stepped, []);
|
||||
const rate = worldClock.getRate();
|
||||
assert.ok(worldClock.now() - start < rate * 1_000, 'from the start of the track');
|
||||
// The end is now and moves on with it: play outruns it by the track.
|
||||
const length = Date.now() - start;
|
||||
assert.ok(Math.abs(rate - (1 + length / 60_000)) < rate * 0.01, 'a minute end to end');
|
||||
worldClock.play({ continuous: true });
|
||||
|
||||
// Playing on to now goes live.
|
||||
worldClock.seek(Date.now() + 1_000);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.getRate(), 1, 'live plays at the rate of the world');
|
||||
});
|
||||
|
||||
test('play holds at the end of a track that reaches past now', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
// An hour ahead is within the track's share of now, but still ahead of it.
|
||||
const end = now + 3_600_000;
|
||||
const release = worldClock.hold('test-ahead');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-ahead',
|
||||
coverage: () => ({ start: now - 10 * 86_400_000, end }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
// Paused just past now, play plays on rather than from the top.
|
||||
worldClock.seek(Date.now() + 1_000);
|
||||
await nextTick();
|
||||
const from = worldClock.now();
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
worldClock.pause();
|
||||
assert.ok(worldClock.now() >= from, 'plays on from where it was');
|
||||
worldClock.play();
|
||||
worldClock.seek(end + 60_000);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
assert.equal(worldClock.now(), end);
|
||||
});
|
||||
Reference in new issue
Block a user