mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Hide a vessel's detection callout while its own card paints
With Vessels and Detection on, a vessel with an ambient card on the map also got its detection callout next to the bracket. The callout lane paints beneath the cards, so its text showed through the card's plate and covered the speed and course. The callout now gives way only to a card the shared overlay actually paints in the same frame. The overlay paints part of the published cards (shared budget, collisions, UI chrome), so a vessel whose card was dropped keeps its callout. The detection lane paints before the cards publish their paint rects, so getOverlayPaintRect has nothing for the current frame there. The new isOverlayEntryQueued answers from the paint queue that the overlay solves before painting. Vessel detection objects name their card in cardSourceId/cardEntryId.
This commit is contained in:
1 parent
7d8b80db0a
commit
652f3c8ea1
7 files changed
+194
-4
No files matched your search
@@ -19,9 +19,11 @@ import {
|
||||
suspendDetection,
|
||||
} from './detection.js';
|
||||
import {
|
||||
clearOverlaySource,
|
||||
destroyWorldOverlay,
|
||||
initWorldOverlay,
|
||||
setOverlayEntries,
|
||||
setOverlaySourceVisible,
|
||||
} from '../overlays/worldOverlay.js';
|
||||
import { DETECTION_THEME_MAP } from '../overlays/worldOverlayTokens.js';
|
||||
import {
|
||||
@@ -579,6 +581,66 @@ test('every style paints its OWN plate token through the production callout path
|
||||
}
|
||||
});
|
||||
|
||||
test('a callout gives way to its contact\'s own card only while that card paints', () => {
|
||||
// A vessel's ambient card already shows its name, speed and course, and the
|
||||
// callout drawn beneath it shows through the card's plate. The host paints
|
||||
// only part of the published cards (shared budget, collisions, UI chrome),
|
||||
// so a contact whose card was published but not painted keeps its callout.
|
||||
const env = installEnvironment({ width: 900, height: 600, dpr: 1 });
|
||||
try {
|
||||
const ships = [
|
||||
{ x: -0.3, sourceId: 'carded', id: 'SHIP-CARDED', card: 'vessel:carded' },
|
||||
{ x: 0.3, sourceId: 'dropped', id: 'SHIP-DROPPED', card: 'vessel:dropped' },
|
||||
].map(({ x, sourceId, id, card }) => ({
|
||||
position: new Cesium.Cartesian3(x, 0, 6_356_752),
|
||||
sourceId,
|
||||
id,
|
||||
metric: '6 kn',
|
||||
type: 'SEA',
|
||||
cardSourceId: card === 'vessel:carded' ? 'vessel-cards' : 'dropped-cards',
|
||||
cardEntryId: card,
|
||||
}));
|
||||
initWorldOverlay(env.viewer);
|
||||
initDetection(env.viewer, [{ id: 'ais-live-vessels', getDetectableObjects: () => ships }], () => {});
|
||||
const card = (id, title, x) => ({
|
||||
id,
|
||||
position: new Cesium.Cartesian3(x, 0, 6_356_752),
|
||||
variant: 'label',
|
||||
title,
|
||||
selected: true,
|
||||
protected: true,
|
||||
horizonCull: false,
|
||||
edgeFade: 'none',
|
||||
});
|
||||
setOverlayEntries('vessel-cards', [card('vessel:carded', 'CARD-CARDED', -0.3)]);
|
||||
// Published, but the host does not paint it this frame.
|
||||
setOverlayEntries('dropped-cards', [card('vessel:dropped', 'CARD-DROPPED', 0.3)]);
|
||||
setOverlaySourceVisible('dropped-cards', false);
|
||||
setMode('DENSE');
|
||||
settleFrame(env);
|
||||
env.ctx.calls.length = 0;
|
||||
settleFrame(env);
|
||||
|
||||
const painted = (text) => env.ctx.calls.some(([name, value]) => name === 'fillText' && value === text);
|
||||
assert.ok(painted('CARD-CARDED'), 'the fixture card reached the frame');
|
||||
assert.ok(!painted('CARD-DROPPED'), 'the hidden source paints no card');
|
||||
assert.ok(!painted('SHIP-CARDED'), 'no callout under the painted card');
|
||||
assert.ok(painted('SHIP-DROPPED'), 'the contact whose card did not paint keeps its callout');
|
||||
assert.equal(getDetectionDiagnostics().calloutRects.length, 1,
|
||||
'only the callout that painted is reported');
|
||||
|
||||
// The card leaves the host: the callout comes back on the next frame.
|
||||
clearOverlaySource('vessel-cards');
|
||||
env.ctx.calls.length = 0;
|
||||
settleFrame(env);
|
||||
assert.ok(painted('SHIP-CARDED'), 'the callout returns once its card stops painting');
|
||||
} finally {
|
||||
destroyDetection();
|
||||
destroyWorldOverlay();
|
||||
env.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('space-tier callouts take the heavier plate while air contacts keep the light one', () => {
|
||||
// Satellites sit over the high-albedo lit Earth disc far more often than
|
||||
// aircraft do, so the space tier carries the heavier backing. Losing the
|
||||
|
||||
Reference in new issue
Block a user