mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Judge tilts by camera pitch and follow a newer flight at once
- A tilt's angle, limits and "unchanged" check use the camera's own pitch. At regional range the pivot pitch is up to about 8 degrees shallower, so "tilt to 5 degrees" from 900 km ended at -12.9 degrees. The swing now solves for the pivot pitch that gives the camera angle. - A zoom out during a pivoting tilt stops at the 1,000 km pivot limit instead of the orbit's 5,000 km, and a zoom in that reaches the clearance is applied before the pivot ends. - An angle the camera already holds still takes navigation, so it stops a running motion and releases the follow camera. - A motion queued behind a fly-to moves to a newer fly-to as soon as it begins, so a stalled lookup no longer holds it past a flight that landed. Wait listeners are removed when a wait ends, and a lookup that found nothing points straight at the flight that moved. - A fly-to that stops a running motion names it (stoppedMotion). - A tilt left or right is refused, and the pitchDeg description says steps use direction.
This commit is contained in:
1 parent
4c9b27dc20
commit
1c59105a80
8 files changed
+310
-128
No files matched your search
@@ -56,8 +56,8 @@ test('the complete Realtime tool payload pins the manifest-generated layer relea
|
||||
// area scopes and the osm-places layer; natural-region candidates and the
|
||||
// tightened area tool wording follow review.
|
||||
// move_camera tilt takes an optional pitchDeg angle, described as
|
||||
// absolute rather than a step.
|
||||
'1dbdef45a477806046cfe4a74a7766f137d7a2b551fdd0b9595986068a85ee8d',
|
||||
// absolute, with steps sent as a direction.
|
||||
'b192c42d1a1c59bea010da93ed0cfb1ce63d2e3ab5e5685921d3bf66e3f94e26',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
+76
-37
@@ -49,6 +49,7 @@ import {
|
||||
adjustOrbitRange,
|
||||
manualCameraInputCount,
|
||||
moveCameraArgsError,
|
||||
getActiveCameraMotion,
|
||||
} from '../cameraVerbs.js';
|
||||
import * as defaultFloorServices from '../data/groundFloor.js';
|
||||
import { isPickedWorldPosition } from '../data/scenePick.js';
|
||||
@@ -293,6 +294,8 @@ export function createGevActionRunner({
|
||||
// cancelled the flight, or the flight (still geocoding) then replaced the
|
||||
// motion. The wait follows later fly-tos (voiceFlightTarget).
|
||||
let voiceFlight = null;
|
||||
// Waiters to tell when a newer voice flight begins.
|
||||
const voiceFlightWatchers = new Set();
|
||||
let analystEngine;
|
||||
// Area handles live for this runner (the page): resolve_area, the
|
||||
// analyst's region/area/drawn scopes, find_imagery and osm_query all read
|
||||
@@ -1153,6 +1156,25 @@ export function createGevActionRunner({
|
||||
prior,
|
||||
);
|
||||
voiceFlight = flight;
|
||||
for (const notify of [...voiceFlightWatchers]) notify();
|
||||
// A motion already running (one the model sent before this fly-to) is
|
||||
// stopped when the flight takes navigation; the result says so.
|
||||
let stoppedMotion = null;
|
||||
const noteStop =
|
||||
(hook) =>
|
||||
(...hookArgs) => {
|
||||
const before = getActiveCameraMotion();
|
||||
try {
|
||||
return hook(...hookArgs);
|
||||
} finally {
|
||||
if (
|
||||
before &&
|
||||
!stoppedMotion &&
|
||||
getActiveCameraMotion()?.motionId !== before.motionId
|
||||
)
|
||||
stoppedMotion = before.kind;
|
||||
}
|
||||
};
|
||||
const flown = flyToRequestedLocation(viewer, args, {
|
||||
onFlightEnd: flight.settle,
|
||||
onProgress: reportProgress,
|
||||
@@ -1161,26 +1183,28 @@ export function createGevActionRunner({
|
||||
signal: runOptions.signal,
|
||||
runImmediate:
|
||||
typeof styleManager?.runImmediateLocationNavigation === 'function'
|
||||
? (navigate) =>
|
||||
styleManager.runImmediateLocationNavigation(navigate)
|
||||
? noteStop((navigate) =>
|
||||
styleManager.runImmediateLocationNavigation(navigate),
|
||||
)
|
||||
: null,
|
||||
beginDeferred:
|
||||
typeof styleManager?.beginDeferredLocationNavigation === 'function'
|
||||
? () => styleManager.beginDeferredLocationNavigation()
|
||||
? noteStop(() => styleManager.beginDeferredLocationNavigation())
|
||||
: null,
|
||||
reassertDeferred:
|
||||
typeof styleManager?.reassertDeferredLocationNavigation === 'function'
|
||||
? (generation) =>
|
||||
styleManager.reassertDeferredLocationNavigation(generation)
|
||||
? noteStop((generation) =>
|
||||
styleManager.reassertDeferredLocationNavigation(generation),
|
||||
)
|
||||
: null,
|
||||
onStart: () => {
|
||||
onStart: noteStop(() => {
|
||||
if (typeof styleManager?.beginLocationNavigation === 'function') {
|
||||
styleManager.beginLocationNavigation();
|
||||
return;
|
||||
}
|
||||
interruptCameraMotion('nav:fly_to_location');
|
||||
if (viewer.trackedEntity) stopAllTracking(viewer, dataManager);
|
||||
},
|
||||
}),
|
||||
});
|
||||
// No flight started: nothing to wait for. A lookup that was not found,
|
||||
// threw, or was cancelled once a newer voice fly-to had begun (which
|
||||
@@ -1199,7 +1223,11 @@ export function createGevActionRunner({
|
||||
flight.settle('failed');
|
||||
else notStarted();
|
||||
}, notStarted);
|
||||
return flown;
|
||||
return flown.then((result) =>
|
||||
stoppedMotion && result && typeof result === 'object'
|
||||
? { ...result, stoppedMotion }
|
||||
: result,
|
||||
);
|
||||
}
|
||||
|
||||
if (name === 'adjust_camera_zoom') {
|
||||
@@ -1315,35 +1343,31 @@ export function createGevActionRunner({
|
||||
if (argsError) return argsError;
|
||||
const deadline = Date.now() + VOICE_FLIGHT_WAIT_MS;
|
||||
const start = pending;
|
||||
// Act on where the camera lands. Whatever a flight reports, a later
|
||||
// fly-to replaces it, and the wait moves to that one as soon as it
|
||||
// begins (a stalled geocode must not hold the motion past a newer
|
||||
// flight that landed). A geocode that loses navigation reports
|
||||
// failed, and a flight left flying while the next place is looked up
|
||||
// can still land; running there would take navigation and cancel the
|
||||
// newer one. A later lookup that found nothing moved nothing, so the
|
||||
// motion looks past it to the last flight that did move the camera.
|
||||
let flight = start;
|
||||
let status = await waitForVoiceFlight(
|
||||
flight,
|
||||
runOptions.signal,
|
||||
deadline,
|
||||
);
|
||||
// A later fly-to replaces this one: follow it to where the camera
|
||||
// lands, within the same deadline, whatever this flight reported. A
|
||||
// geocode that loses navigation reports failed, and a flight left
|
||||
// flying while the next place is looked up can still land; running
|
||||
// there would take navigation and cancel the newer one. A later
|
||||
// lookup that found nothing moved nothing, so the motion acts on the
|
||||
// last flight it saw that did move the camera.
|
||||
let landed = flight.movedNothing ? null : { flight, status };
|
||||
while (status !== 'aborted' && status !== 'timeout' && current()) {
|
||||
const target = voiceFlightTarget(voiceFlight, start);
|
||||
if (!target || target === flight) break;
|
||||
flight = target;
|
||||
let status;
|
||||
for (;;) {
|
||||
status = await waitForVoiceFlight(
|
||||
flight,
|
||||
runOptions.signal,
|
||||
deadline,
|
||||
voiceFlightWatchers,
|
||||
);
|
||||
if (!flight.movedNothing) landed = { flight, status };
|
||||
if (status === 'aborted' || status === 'timeout' || !current()) break;
|
||||
const target = voiceFlightTarget(voiceFlight, start);
|
||||
if (!target || (target === flight && status !== 'newer')) break;
|
||||
flight = target;
|
||||
}
|
||||
if (flight.movedNothing && landed) ({ flight, status } = landed);
|
||||
if (!current())
|
||||
return { ok: false, action: 'move_camera', cancelled: true };
|
||||
if (status !== 'arrived')
|
||||
if (status !== 'arrived' || flight.movedNothing)
|
||||
return {
|
||||
ok: false,
|
||||
action: 'move_camera',
|
||||
@@ -2973,7 +2997,6 @@ function trackVoiceFlight(
|
||||
inputCount = manualCameraInputCount(),
|
||||
replaced = null,
|
||||
) {
|
||||
let resolve;
|
||||
const flight = {
|
||||
done: false,
|
||||
seq: (voiceFlightCount += 1),
|
||||
@@ -2981,14 +3004,20 @@ function trackVoiceFlight(
|
||||
movedNothing: false,
|
||||
// Manual input after this means the user took the camera mid-flight.
|
||||
inputCount,
|
||||
ended: new Promise((settle) => {
|
||||
resolve = settle;
|
||||
}),
|
||||
status: null,
|
||||
// Waiters to tell when this flight ends.
|
||||
watchers: new Set(),
|
||||
settle: (status) => {
|
||||
if (flight.done) return;
|
||||
flight.done = true;
|
||||
if (!flight.movedNothing) flight.replaced = null;
|
||||
resolve(status);
|
||||
flight.status = status;
|
||||
// Kept only past a lookup that found nothing, and then straight to the
|
||||
// flight that moved, so a run of such lookups holds no chain.
|
||||
flight.replaced = flight.movedNothing
|
||||
? voiceFlightTarget(flight.replaced)
|
||||
: null;
|
||||
for (const notify of [...flight.watchers]) notify(status);
|
||||
flight.watchers.clear();
|
||||
},
|
||||
};
|
||||
return flight;
|
||||
@@ -3027,22 +3056,32 @@ const VOICE_FLIGHT_WAITING_MOTIONS = new Set([
|
||||
'rotate',
|
||||
]);
|
||||
|
||||
/** Wait for a voice flight to end; 'timeout' or 'aborted' if it does not. */
|
||||
function waitForVoiceFlight(flight, signal, deadline) {
|
||||
/**
|
||||
* Wait for a voice flight to end, or for a newer one to begin ('newer'):
|
||||
* 'timeout' or 'aborted' if neither happens. A flight that has ended answers
|
||||
* at once. Every listener is removed when the wait ends, so a flight that
|
||||
* never settles holds nothing.
|
||||
*/
|
||||
function waitForVoiceFlight(flight, signal, deadline, newerWatchers) {
|
||||
if (signal?.aborted) return Promise.resolve('aborted');
|
||||
if (flight.done) return Promise.resolve(flight.status);
|
||||
return new Promise((resolve) => {
|
||||
const finish = (status) => {
|
||||
clearTimeout(timer);
|
||||
signal?.removeEventListener?.('abort', onAbort);
|
||||
flight.watchers.delete(finish);
|
||||
newerWatchers?.delete(onNewer);
|
||||
resolve(status);
|
||||
};
|
||||
const onAbort = () => finish('aborted');
|
||||
const onNewer = () => finish('newer');
|
||||
const timer = setTimeout(
|
||||
() => finish('timeout'),
|
||||
Math.max(0, deadline - Date.now()),
|
||||
);
|
||||
signal?.addEventListener?.('abort', onAbort, { once: true });
|
||||
flight.ended.then(finish);
|
||||
flight.watchers.add(finish);
|
||||
newerWatchers?.add(onNewer);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -895,6 +895,50 @@ test('a motion gives up on a flight that has not landed in 15 s', async (t) => {
|
||||
assert.match(result.error, /did not arrive/);
|
||||
});
|
||||
|
||||
test('a motion follows a newer fly-to that lands while its own lookup stalls', async (t) => {
|
||||
t.after(() => interruptCameraMotion('test-cleanup'));
|
||||
const { viewer, styleManager, flights } = tiltAfterFlightHarness();
|
||||
const runner = createGevActionRunner({
|
||||
viewer,
|
||||
styleManager,
|
||||
dataManager: { layers: new Map(), getAll: () => [] },
|
||||
// Place A's lookup never answers.
|
||||
searchNavigation: () => new Promise(() => {}),
|
||||
});
|
||||
t.mock.timers.enable({ apis: ['setTimeout', 'Date'] });
|
||||
runner('fly_to_location', { query: 'Place A' });
|
||||
const moved = runner('move_camera', { motion: 'orbit' });
|
||||
const movedDone = settledYet(moved);
|
||||
assert.equal((await runner('fly_to_location', { locationId: 'austin' })).ok, true);
|
||||
t.mock.timers.tick(2_000);
|
||||
await Promise.resolve();
|
||||
assert.equal(movedDone(), false, 'the orbit must wait for the newer flight to land');
|
||||
flights[0].complete();
|
||||
for (let i = 0; i < 5 && !movedDone(); i += 1) await Promise.resolve();
|
||||
assert.equal(movedDone(), true, 'the orbit must not wait out A');
|
||||
const result = await moved;
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.motion, 'orbit');
|
||||
});
|
||||
|
||||
test('a fly-to that stops a running motion says so', async (t) => {
|
||||
t.after(() => interruptCameraMotion('test-cleanup'));
|
||||
const { viewer, styleManager } = tiltAfterFlightHarness();
|
||||
const runner = createGevActionRunner({
|
||||
viewer,
|
||||
styleManager,
|
||||
dataManager: { layers: new Map(), getAll: () => [] },
|
||||
});
|
||||
// The model sent the orbit first, so it ran at once.
|
||||
const orbit = await runner('move_camera', { motion: 'orbit', mode: 'continuous' });
|
||||
assert.equal(orbit.ok, true);
|
||||
const fly = await runner('fly_to_location', { locationId: 'austin' });
|
||||
assert.equal(fly.ok, true);
|
||||
assert.equal(fly.stoppedMotion, 'orbit');
|
||||
const again = await runner('fly_to_location', { locationId: 'austin' });
|
||||
assert.equal('stoppedMotion' in again, false);
|
||||
});
|
||||
|
||||
test('bad move_camera arguments are refused without waiting for a flight', async () => {
|
||||
const { viewer, styleManager } = tiltAfterFlightHarness();
|
||||
const runner = createGevActionRunner({
|
||||
|
||||
@@ -350,8 +350,8 @@ test('deixis prompt lint: one short rule, and every sentinel it names exists in
|
||||
// the analyst area scopes) raised the ceiling to 55,500; tightening the
|
||||
// AREAS rule and the area tool descriptions left it at 55,103 as measured
|
||||
// below (every tool, osm_query included); main's Sea Marks and Ski Pistes
|
||||
// layers bring it to 55,210, and the tilt pitchDeg argument to 55,332.
|
||||
// integrationContract's Overpass prompt is the tightest, at 55,492 (8
|
||||
// layers bring it to 55,210, and the tilt pitchDeg argument to 55,335.
|
||||
// integrationContract's Overpass prompt is the tightest, at 55,495 (5
|
||||
// under). A new tool or rule has to fit under this ceiling.
|
||||
const size = instructions.length + JSON.stringify(GEV_REALTIME_TOOLS).length;
|
||||
assert.ok(size <= 55_500, `prompt size ${size}`);
|
||||
|
||||
Reference in new issue
Block a user