mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 00:02:25 +00:00
Count a running mission replay as the camera's owner in readiness
A Space Missions replay flies the camera until it ends, so waiting for a still camera after a switch let the replay finish before the scenario looked at it. While a replay runs, readiness no longer asks for enabled inputs or a still pose, as for the cockpit and a followed target.
This commit is contained in:
1 parent
d3433f66c9
commit
087adc6dc9
2 files changed
+17
-4
No files matched your search
@@ -94,14 +94,20 @@ export function waitForSettled(createState, { frames, timeoutMs }) {
|
|||||||
const cockpitActive = Boolean(
|
const cockpitActive = Boolean(
|
||||||
window.__godsEyeView?.styleManager?.getCockpitState?.()?.active,
|
window.__godsEyeView?.styleManager?.getCockpitState?.()?.active,
|
||||||
);
|
);
|
||||||
|
// A running Space Missions replay flies the camera until it ends.
|
||||||
|
const drawn = window.__godsEyeView?.dataManager?.layers
|
||||||
|
?.get('rocket-launches')
|
||||||
|
?.module?.qaDrawn?.();
|
||||||
|
const replaying = Boolean(drawn?.replay?.active && !drawn.paused);
|
||||||
status.observed = {
|
status.observed = {
|
||||||
inputsEnabled: status.conditions.cameraInputsEnabled,
|
inputsEnabled: status.conditions.cameraInputsEnabled,
|
||||||
following,
|
following,
|
||||||
cockpitActive,
|
cockpitActive,
|
||||||
|
replaying,
|
||||||
lastPoseDelta,
|
lastPoseDelta,
|
||||||
};
|
};
|
||||||
// Only a live camera owner excuses motion or held inputs, never a scenario flag.
|
// Only a live camera owner excuses motion or held inputs, never a scenario flag.
|
||||||
if (following || cockpitActive) {
|
if (following || cockpitActive || replaying) {
|
||||||
status.conditions.cameraInputsEnabled = true;
|
status.conditions.cameraInputsEnabled = true;
|
||||||
status.conditions.cameraPoseStable = true;
|
status.conditions.cameraPoseStable = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ import {
|
|||||||
function pageEngine(t) {
|
function pageEngine(t) {
|
||||||
const engine = createFakeEngine();
|
const engine = createFakeEngine();
|
||||||
const previous = globalThis.window;
|
const previous = globalThis.window;
|
||||||
|
const launches = { qaDrawn: () => ({ paused: false, replay: null }) };
|
||||||
const app = {
|
const app = {
|
||||||
engine,
|
engine,
|
||||||
|
launches,
|
||||||
|
dataManager: { layers: new Map([['rocket-launches', { module: launches }]]) },
|
||||||
styleManager: {
|
styleManager: {
|
||||||
initialRestorePromise: Promise.resolve(),
|
initialRestorePromise: Promise.resolve(),
|
||||||
getCockpitState: () => ({ active: false }),
|
getCockpitState: () => ({ active: false }),
|
||||||
@@ -30,14 +33,16 @@ function pageEngine(t) {
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
test('cockpit and follow readiness allow held inputs and moving poses after drawn frames', async (t) => {
|
test('cockpit, follow and replay readiness allow held inputs and moving poses after drawn frames', async (t) => {
|
||||||
for (const owner of ['cockpit', 'follow']) {
|
for (const owner of ['cockpit', 'follow', 'replay']) {
|
||||||
await t.test(owner, async (t) => {
|
await t.test(owner, async (t) => {
|
||||||
const { engine, styleManager } = pageEngine(t);
|
const { engine, styleManager, launches } = pageEngine(t);
|
||||||
engine.input.suspendCameraInputs();
|
engine.input.suspendCameraInputs();
|
||||||
let drawn = 0;
|
let drawn = 0;
|
||||||
if (owner === 'cockpit')
|
if (owner === 'cockpit')
|
||||||
styleManager.getCockpitState = () => ({ active: true });
|
styleManager.getCockpitState = () => ({ active: true });
|
||||||
|
else if (owner === 'replay')
|
||||||
|
launches.qaDrawn = () => ({ paused: false, replay: { active: true } });
|
||||||
else
|
else
|
||||||
engine.camera.follow({
|
engine.camera.follow({
|
||||||
position: () => ({ x: 6378137, y: drawn * 10, z: 0 }),
|
position: () => ({ x: 6378137, y: drawn * 10, z: 0 }),
|
||||||
@@ -58,6 +63,7 @@ test('cockpit and follow readiness allow held inputs and moving poses after draw
|
|||||||
assert.equal(status.observed.inputsEnabled, false);
|
assert.equal(status.observed.inputsEnabled, false);
|
||||||
assert.equal(status.observed.cockpitActive, owner === 'cockpit');
|
assert.equal(status.observed.cockpitActive, owner === 'cockpit');
|
||||||
assert.equal(status.observed.following, owner === 'follow');
|
assert.equal(status.observed.following, owner === 'follow');
|
||||||
|
assert.equal(status.observed.replaying, owner === 'replay');
|
||||||
assert.ok(status.observed.lastPoseDelta.orientation > 0);
|
assert.ok(status.observed.lastPoseDelta.orientation > 0);
|
||||||
assert.equal(engine.frames.postRender.numberOfListeners, 0);
|
assert.equal(engine.frames.postRender.numberOfListeners, 0);
|
||||||
});
|
});
|
||||||
@@ -128,6 +134,7 @@ test('unowned input locks and moving cameras time out with observed state', asyn
|
|||||||
inputsEnabled: moving,
|
inputsEnabled: moving,
|
||||||
following: false,
|
following: false,
|
||||||
cockpitActive: false,
|
cockpitActive: false,
|
||||||
|
replaying: false,
|
||||||
lastPoseDelta: {
|
lastPoseDelta: {
|
||||||
positionM: moving ? 1 : 0,
|
positionM: moving ? 1 : 0,
|
||||||
orientation: 0,
|
orientation: 0,
|
||||||
|
|||||||
Reference in new issue
Block a user