mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Never fly to a mission while the cockpit holds the camera
Focusing a mission does nothing in the cockpit, so the layer row's arrows select the next mission without moving the camera, as its label and dot already do. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
6c960eb3c9
commit
cdde80f3ad
4 files changed
+33
-6
No files matched your search
@@ -11,7 +11,11 @@ import {
|
||||
toRadians,
|
||||
vec,
|
||||
} from '../../geo/vector.js';
|
||||
import { MISSION_GLOBE_VIEW_RANGE_M, MISSION_FOCUS_RANGE_M } from './policy.js';
|
||||
import {
|
||||
MISSION_GLOBE_VIEW_RANGE_M,
|
||||
MISSION_FOCUS_RANGE_M,
|
||||
cockpitActive,
|
||||
} from './policy.js';
|
||||
import { cameraOf, canvasOf, findCamera } from '../../render/rendererOf.js';
|
||||
|
||||
export function createSelection({
|
||||
@@ -122,6 +126,9 @@ export function createSelection({
|
||||
|
||||
function focusMission(launch) {
|
||||
if (!layerState._viewer || !launch || !layerState._enabled) return;
|
||||
// The cockpit holds the camera: a mission chosen there, by its label,
|
||||
// its dot or the layer row's arrows, is selected without flying to it.
|
||||
if (cockpitActive()) return;
|
||||
stopMissionZoomAnchor();
|
||||
parts.rendering.selectLaunchEntity(launch.id);
|
||||
const camera = cameraOf(layerState._viewer);
|
||||
|
||||
@@ -36,10 +36,12 @@ function scene(t) {
|
||||
],
|
||||
};
|
||||
const viewer = { scene: {} };
|
||||
const flights = [];
|
||||
const { draw, unbind } = bindFakeDraw(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ position: { x: 2e7, y: 0, z: 0 } }),
|
||||
on: () => () => {},
|
||||
flyTo: (...args) => flights.push(args),
|
||||
},
|
||||
});
|
||||
t.after(unbind);
|
||||
@@ -88,7 +90,7 @@ function scene(t) {
|
||||
path: item(`rocket-trajectory:${launch.id}:0`).show,
|
||||
};
|
||||
};
|
||||
return { state, rendering, launch, syncs, shown, draw };
|
||||
return { state, rendering, launch, syncs, shown, draw, parts, flights };
|
||||
}
|
||||
|
||||
test('live shows every launch in the window, lifted off or not', (t) => {
|
||||
@@ -127,3 +129,21 @@ test('the live orbit rings turn at the frame time, not the wall clock', (t) => {
|
||||
);
|
||||
assert.deepEqual(orbits.spec.motionClock, { kind: 'scene' });
|
||||
});
|
||||
|
||||
test('in the cockpit a chosen mission is not flown to', (t) => {
|
||||
const { launch, parts, flights } = scene(t);
|
||||
const previous = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||
Object.defineProperty(globalThis, 'document', {
|
||||
configurable: true,
|
||||
value: {
|
||||
body: { classList: { contains: (name) => name === 'cockpit-mode' } },
|
||||
},
|
||||
});
|
||||
try {
|
||||
parts.selection.focusMission(launch);
|
||||
} finally {
|
||||
if (previous) Object.defineProperty(globalThis, 'document', previous);
|
||||
else delete globalThis.document;
|
||||
}
|
||||
assert.deepEqual(flights, [], 'the cockpit keeps the camera');
|
||||
});
|
||||
Reference in new issue
Block a user