Let a view show an aircraft's cockpit view

A view's follow may ask for cockpit view, which the app enters after it
follows the aircraft; links cannot carry it and open the app following.
Applying a view no longer flies the camera when the followed entity is
already there, since the flight ended the follow; it flies only while
waiting for the entity. The panel applies its first view again only
when it asks for cockpit view.
This commit is contained in:
Sameh Khamis committed 2026-10-02 18:29:42 -07:00
1 parent 89a448ee83
commit d4311a9d54
6 files changed
+77 -25

No files matched your search

+29 -18
View File
@@ -185,25 +185,36 @@ export async function applyView(
await act('clear_annotations', {});
if (view.annotations.length)
await act('annotate_map', { annotations: [...view.annotations] });
steps.push({ step: 'camera', ok: await flyTo(viewer, view.camera) });
if (view.follow) {
// The followed entity appears once its layer has data; retry until then.
const args = {
query: view.follow.id,
layerId: FOLLOW_LAYERS[view.follow.kind],
};
let followed = false;
for (let attempt = 0; attempt < FOLLOW_ATTEMPTS && !followed; attempt++) {
if (signal?.aborted) break;
try {
followed = (await run('track_entity', args))?.ok === true;
} catch {
followed = false;
}
if (!followed) await delay(retryMs, signal);
}
steps.push({ step: 'follow', ok: followed });
if (!view.follow) {
steps.push({ step: 'camera', ok: await flyTo(viewer, view.camera) });
return steps;
}
// A followed entity owns the camera, and a camera flight would end the
// follow, so fly to the view only while the entity is not there yet. It
// appears once its layer has data; retry until then.
const layerId = FOLLOW_LAYERS[view.follow.kind];
const follow = async () => {
try {
return (
(await run('track_entity', { query: view.follow.id, layerId }))?.ok ===
true
);
} catch {
return false;
}
};
let followed = await follow();
if (!followed) {
steps.push({ step: 'camera', ok: await flyTo(viewer, view.camera) });
for (let attempt = 1; attempt < FOLLOW_ATTEMPTS && !followed; attempt++) {
if (signal?.aborted) break;
await delay(retryMs, signal);
followed = await follow();
}
}
steps.push({ step: 'follow', ok: followed });
if (followed && view.follow.cockpit)
await act('control_cockpit', { action: 'enter', targetLayer: layerId });
return steps;
}