mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Keep the camera still in the cockpit when a mission's dot is clicked or its orbit arrives
The cockpit holds the camera: the mission dot, like its label, selects the mission there without flying to it, and a mission picked in the cockpit is not flown to when the active satellite lookup returns. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
813c6b23ea
commit
6c960eb3c9
6 files changed
+46
-20
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { MAX_POST_TLE_RETRIES, POST_TLE_RETRY_DELAY_MS } from './policy.js';
|
||||
import {
|
||||
MAX_POST_TLE_RETRIES,
|
||||
POST_TLE_RETRY_DELAY_MS,
|
||||
cockpitActive,
|
||||
} from './policy.js';
|
||||
|
||||
/**
|
||||
* Let pending Satellites work finish, including requests that join it while
|
||||
@@ -264,7 +268,9 @@ export function createIngestion({
|
||||
parts.selection.setSelectedMission(null, false);
|
||||
} else {
|
||||
parts.selection.setSelectedMission(layerState._selectedLaunchId, true);
|
||||
if (layerState._focusAfterActiveLookup) {
|
||||
// The cockpit holds the camera: a mission picked there is not flown
|
||||
// to when its orbit arrives.
|
||||
if (layerState._focusAfterActiveLookup && !cockpitActive()) {
|
||||
parts.selection.focusMission(
|
||||
launches.find(
|
||||
(launch) => launch.id === layerState._selectedLaunchId,
|
||||
|
||||
@@ -196,8 +196,8 @@ test("another layer's label keeps the click above mission geometry", (t) => {
|
||||
assert.deepEqual(r.focused, ['L1']);
|
||||
});
|
||||
|
||||
test('in the cockpit a mission label selects its mission without moving the camera', (t) => {
|
||||
const r = rig(t, { overlayHit: label('launch:L2') });
|
||||
test('in the cockpit a mission label or dot selects its mission without moving the camera', (t) => {
|
||||
const r = rig(t, { overlayHit: label('launch:L2'), geometryLaunchId: 'L1' });
|
||||
const previous = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||
Object.defineProperty(globalThis, 'document', {
|
||||
configurable: true,
|
||||
@@ -213,6 +213,23 @@ test('in the cockpit a mission label selects its mission without moving the came
|
||||
}
|
||||
assert.deepEqual(r.focused, ['L2'], 'the mission is selected');
|
||||
assert.deepEqual(r.moved, [], 'the cockpit keeps the camera');
|
||||
// The dot, with no label over it, does the same.
|
||||
r.setHit(null);
|
||||
Object.defineProperty(globalThis, 'document', {
|
||||
configurable: true,
|
||||
value: {
|
||||
body: { classList: { contains: (name) => name === 'cockpit-mode' } },
|
||||
},
|
||||
});
|
||||
try {
|
||||
r.click();
|
||||
} finally {
|
||||
if (previous) Object.defineProperty(globalThis, 'document', previous);
|
||||
else delete globalThis.document;
|
||||
}
|
||||
assert.deepEqual(r.focused, ['L2', 'L1']);
|
||||
assert.deepEqual(r.moved, []);
|
||||
r.setHit(label('launch:L2'));
|
||||
// Out of the cockpit the same click moves there too.
|
||||
r.click();
|
||||
assert.deepEqual(r.moved, ['L2']);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { worldClock } from '../../time/worldClock.js';
|
||||
import {
|
||||
ROCKET_MISSION_AMBIENT_OVERLAY_SOURCE_ID,
|
||||
ROCKET_MISSION_SELECTED_OVERLAY_SOURCE_ID,
|
||||
cockpitActive,
|
||||
} from './policy.js';
|
||||
|
||||
const HOVER_PICK_INTERVAL_MS = 120;
|
||||
@@ -154,13 +155,6 @@ function restoreCameraView(viewer, view, landedView) {
|
||||
/** The longest name a timeline mark carries, as in the mission index. */
|
||||
const MARK_LABEL_LENGTH = 27;
|
||||
|
||||
/** Whether the cockpit view is on. */
|
||||
function cockpitActive() {
|
||||
return Boolean(
|
||||
globalThis.document?.body?.classList?.contains?.('cockpit-mode'),
|
||||
);
|
||||
}
|
||||
|
||||
function markerLaunchId(hit) {
|
||||
if (
|
||||
hit?.sourceId !== ROCKET_MISSION_AMBIENT_OVERLAY_SOURCE_ID &&
|
||||
@@ -252,8 +246,8 @@ export function createLifecycle({
|
||||
// overlay. An unrelated label keeps the click above mission geometry.
|
||||
overlayClicks.add(event);
|
||||
// The label is the card on top, so every other layer and the cockpit
|
||||
// leave its click alone. In the cockpit, which holds the camera, it
|
||||
// selects the mission without moving there.
|
||||
// leave its click alone. In the cockpit, which holds the camera, the
|
||||
// label and the dot select the mission without moving there.
|
||||
return focusLaunch(markerLaunchId(hit), { move: !cockpitActive() });
|
||||
});
|
||||
const unsubscribeClick = input.onClick((event) => {
|
||||
@@ -269,6 +263,7 @@ export function createLifecycle({
|
||||
parts.rendering.launchIdFromPicks(
|
||||
parts.rendering.missionHitsAt(event.position, 12),
|
||||
),
|
||||
{ move: !cockpitActive() },
|
||||
);
|
||||
});
|
||||
hover = createLaunchHover({
|
||||
|
||||
@@ -103,3 +103,10 @@ export const TRAJECTORY_STAGE_COLORS = [
|
||||
'#ffd166',
|
||||
'#60a5fa',
|
||||
];
|
||||
|
||||
/** Whether the cockpit view is on; it holds the camera while it is. */
|
||||
export function cockpitActive() {
|
||||
return Boolean(
|
||||
globalThis.document?.body?.classList?.contains?.('cockpit-mode'),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user