Merge remote-tracking branch 'origin/main' into models/three-km-true-size

# Conflicts:
#	docs/CURRENT-STATE.md
This commit is contained in:
Sameh Khamis committed 2026-11-17 15:29:39 -08:00
commit b9cbc42f20
137 files changed
+8267 -688

No files matched your search

+84
View File
@@ -216,3 +216,87 @@ test('back at live, the live poll goes out at once even while a snapshot at a ti
assert.equal(Object.hasOwn(queries[1], 'atMs'), false);
assert.equal(probe.applied.at(-1).rows.length, 1);
});
test('back at live, only the first live vessel rows applied take over; a poll that fails or brings none says so', async () => {
let answer = 'rows';
const probe = ingestion({
async getSnapshot() {
if (answer === 'fail') throw new Error('down');
return {
records:
answer === 'rows'
? [{ id: '111', latitude: 1, longitude: 2, observedAtMs: 5 }]
: [],
observedAtMs: 5,
freshness: 'current',
complete: true,
transportStatus: 'live',
};
},
});
assert.equal(await probe.resumeLive({}), true);
await probe.methods.update();
assert.deepEqual(
probe.applied.map(({ options }) => options),
[{ complete: true, handover: true }, { complete: true }],
);
answer = 'none';
assert.equal(await probe.resumeLive({}), false);
answer = 'fail';
const warn = console.warn;
console.warn = () => {};
try {
assert.equal(await probe.resumeLive({}), false);
} finally {
console.warn = warn;
}
});
test('back at live while a live poll is already out, that poll takes over and its answer is awaited', async () => {
let answer;
const probe = ingestion({
getSnapshot: () =>
new Promise((resolve) => {
answer = () =>
resolve({
records: [
{ id: '111', latitude: 1, longitude: 2, observedAtMs: 5 },
],
observedAtMs: 5,
freshness: 'current',
complete: true,
transportStatus: 'live',
});
}),
});
const poll = probe.methods.update();
const resumed = probe.resumeLive({});
answer();
assert.equal(await resumed, true);
await poll;
assert.deepEqual(
probe.applied.map(({ options }) => options),
[{ complete: true, handover: true }],
);
});
test('without AbortSignal.any a vessel request still gives up after its timeout', async (t) => {
t.mock.timers.enable({ apis: ['setTimeout'] });
const any = AbortSignal.any;
AbortSignal.any = undefined;
try {
const probe = ingestion({
getSnapshot: (_query, { signal }) =>
new Promise((_, reject) =>
signal.addEventListener('abort', () => reject(signal.reason)),
),
});
const resumed = probe.resumeLive({});
await Promise.resolve();
t.mock.timers.tick(10_000);
assert.equal(await resumed, false);
assert.equal(probe.feed.loading, false);
} finally {
AbortSignal.any = any;
}
});
+6 -4
View File
@@ -12,7 +12,10 @@ import { createTesting } from './testing.js';
import { createEvidence } from './evidence.js';
import { createQueries } from './queries.js';
import { followsClock } from './policy.js';
import { createSnapshotTimeline } from '../../time/snapshotTimeline.js';
import {
createSnapshotTimeline,
snapshotAnswer,
} from '../../time/snapshotTimeline.js';
import { worldClock } from '../../time/worldClock.js';
/** Compose one vessel layer with application-owned scene services. */
export function createVesselLayer({ source, services, options = {} } = {}) {
@@ -58,6 +61,7 @@ export function createVesselLayer({ source, services, options = {} } = {}) {
layer.source = source;
},
followsClock: () => followsClock(vesselState),
timedAnswer: snapshotAnswer,
reloadAtClock: () => vesselState.timeline.reload(),
});
// Vessels follow the world clock while the source declares a timeline.
@@ -77,9 +81,7 @@ export function createVesselLayer({ source, services, options = {} } = {}) {
state.feed.count = state.records.all.length;
state.feed.lastUpdate = null;
},
resumeLive: () => {
void parts.ingestion.loadLivePositions(vesselState.state.viewer);
},
resumeLive: () => parts.ingestion.resumeLive(vesselState.state.viewer),
});
Object.assign(
layer,
+81 -16
View File
@@ -1,6 +1,9 @@
import { AIS_FIRST_CONNECT_LABEL } from './recordPolicy.js';
import { viewAreaMovedEnough } from './viewArea.js';
/** Longest a vessel request may take before it is given up. */
const REQUEST_TIMEOUT_MS = 10_000;
// A portable export (package.json): no i18n here. The text stays English data
// and the layer panel shows it translated.
const msg = (text) => text;
@@ -23,14 +26,47 @@ export function createIngestion({
setSourceLabel,
followsClock = () => false,
reloadAtClock = () => {},
timedAnswer = () => true,
}) {
async function loadLivePositions(viewer) {
// The live load in flight: its result, and its request, whose `handover`
// may still be set while it loads (see resumeLive).
let liveLoad = null;
async function loadLivePositions(viewer, { handover = false } = {}) {
// Following the world clock, the layer shows the snapshots loadAt applies.
if (followsClock()) return;
if (followsClock()) return false;
// Back at live, a snapshot at a time still loading no longer applies:
// it would hold the live poll back until the next refresh.
if (feed.loading && feed.loadingAtTime) dropLoad();
await loadPositions(viewer);
// A live load already out answers this one too.
if (feed.loading && liveLoad) {
if (handover) liveLoad.request.handover = true;
return liveLoad.promise;
}
const request = { handover };
const promise = loadPositions(viewer, { request });
const load = { request, promise };
liveLoad = load;
try {
return await promise;
} finally {
if (liveLoad === load) liveLoad = null;
}
}
/**
* Back at live from another time: poll at once (or take the live poll
* already out), and let its snapshot stand in for every vessel. Those it has keep their
* icon and model and move on from where they are; those it lacks go.
* Resolves true once it is applied, else false (it could not be had).
* @param {object} [viewer]
* @returns {Promise<boolean>}
*/
async function resumeLive(viewer) {
const applied = await loadLivePositions(viewer || readViewer(), {
handover: true,
});
return applied === true;
}
/** Let go of the load in flight, so another can start now. */
@@ -44,10 +80,11 @@ export function createIngestion({
/**
* Apply the source's snapshot at world time `atMs` (its timeline says it
* can answer one), in place of every vessel when `replace`. Resolves
* whether it was applied.
* whether it was applied: `{ reachMs }`, the newest fix its records carry,
* when they carry fixes; else true, or false when it was not.
* @param {number} atMs
* @param {{signal?: AbortSignal|null, replace?: boolean}} [options]
* @returns {Promise<boolean>}
* @returns {Promise<boolean|{reachMs: number}>}
*/
async function loadAt(atMs, { signal = null, replace = false } = {}) {
// Whatever polls or loads for another time no longer applies: the
@@ -56,7 +93,10 @@ export function createIngestion({
return loadPositions(readViewer(), { atMs, replace, signal });
}
async function loadPositions(viewer, { atMs, replace = false, signal } = {}) {
async function loadPositions(
viewer,
{ atMs, replace = false, signal, request = null } = {},
) {
const timed = atMs !== undefined;
if (!viewer || feed.loading) return false;
feed.loading = true;
@@ -65,18 +105,35 @@ export function createIngestion({
const requestController = new AbortController();
const requestSessionId = feed.sessionId;
feed.abort = requestController;
let timeout = null;
try {
// Combine the layer's teardown-abort with a hard timeout so a hung upstream
// can't wedge the poll indefinitely (parity with the track fetch + flights).
const requestSignal =
typeof AbortSignal.any === 'function'
? AbortSignal.any([
requestController.signal,
AbortSignal.timeout(10000),
...(signal ? [signal] : []),
])
: requestController.signal;
let requestSignal;
if (typeof AbortSignal.any === 'function')
requestSignal = AbortSignal.any([
requestController.signal,
AbortSignal.timeout(REQUEST_TIMEOUT_MS),
...(signal ? [signal] : []),
]);
else {
// Without it, the request's own controller takes the timeout and
// the caller's abort.
timeout = setTimeout(
() =>
requestController.abort(
new DOMException('Vessel request timed out', 'TimeoutError'),
),
REQUEST_TIMEOUT_MS,
);
signal?.addEventListener(
'abort',
() => requestController.abort(signal.reason),
{ once: true },
);
requestSignal = requestController.signal;
}
// Ask for the vessels in view; a wide view asks for every vessel.
const area = readArea(viewer);
feed.lastArea = area;
@@ -92,9 +149,10 @@ export function createIngestion({
if (signal?.aborted) return false;
// The clock left the live edge while this poll was out.
if (!timed && followsClock()) return false;
const takesOver = !timed && request?.handover === true;
setSourceLabel(snapshot.source);
// Map observations into the existing display store; source fields stop here.
applyAisFeedSnapshot(viewer, {
const applied = applyAisFeedSnapshot(viewer, {
rows: snapshot.records.map(vesselDisplayRow),
observedAtMs: snapshot.observedAtMs,
freshness: snapshot.freshness,
@@ -112,8 +170,12 @@ export function createIngestion({
silentForMs: snapshot.silentForMs,
reconnectAttempt: snapshot.reconnectAttempt,
...(replace && { replace }),
...(takesOver && { handover: true }),
});
return true;
// Back at live, a snapshot that placed no vessel could not take over.
if (takesOver) return applied.reconciled;
// At a time, what the clock's follower is told of it.
return timed ? timedAnswer(snapshot) : true;
} catch (error) {
// A snapshot at a time the source dropped for a newer one is no failure.
if (timed && error?.name === 'AbortError') throw error;
@@ -130,6 +192,7 @@ export function createIngestion({
}
return false;
} finally {
if (timeout !== null) clearTimeout(timeout);
if (
feed.abort === requestController &&
feed.sessionId === requestSessionId
@@ -197,6 +260,7 @@ export function createIngestion({
applyRows(viewer, snapshot.acceptedRows, {
complete: payload?.complete !== false,
...(payload?.replace && { replace: true }),
...(payload?.handover && { handover: true }),
});
feed.count = readCount();
feed.stale =
@@ -266,6 +330,7 @@ export function createIngestion({
return {
loadLivePositions,
resumeLive,
loadAt,
refreshIfMoved,
ownsAisRequest,
+28 -12
View File
@@ -7,6 +7,10 @@ import { createVesselIconBook } from './iconBook.js';
import { liftedForHorizon } from '../../geo/horizon.js';
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
import { fakeDrawPort } from '../../testSupport/fakeDrawPort.mjs';
import { aidSprite, vesselSprite } from '../../data/vesselSprites.js';
import { VESSEL_KIND_STYLES } from '../../data/vesselTypes.js';
import { AID_TO_NAVIGATION_STYLE } from '../../data/vesselLabels.js';
import { cssColor } from '../../render/color.js';
/** A query port with nothing on screen: the viewer doubles have no scene. */
const offscreen = {
@@ -90,7 +94,7 @@ const snapshot = (records, extra = {}) => ({
...extra,
});
test('vessel construction is inert and each instance owns its records, icon cache and clock', () => {
test('vessel construction is inert and each instance owns its records and clock', () => {
let requested = 0;
const source = {
getSnapshot() {
@@ -99,8 +103,7 @@ test('vessel construction is inert and each instance owns its records, icon cach
};
const one = createVesselState({ source, services: services() });
const two = createVesselState({ source, services: services() });
for (const key of ['state', 'shipIconCache'])
assert.notEqual(one[key], two[key]);
assert.notEqual(one.state, two.state);
assert.notEqual(one.state.records.byId, two.state.records.byId);
assert.notEqual(one.state.feed, two.state.feed);
assert.notEqual(one.state.records.all, two.state.records.all);
@@ -557,7 +560,7 @@ test('AIS feed rows stay keyed by their MMSI', async () => {
);
});
test('an aid to navigation is drawn as a disc, a vessel as its chevron', async () => {
test('an aid to navigation is drawn as the upright buoy, a vessel as its kind’s hull turned with course', async () => {
const aid = {
...observation('993672001'),
mmsi: '993672001',
@@ -565,26 +568,39 @@ test('an aid to navigation is drawn as a disc, a vessel as its chevron', async (
speedMps: 0,
};
const ship = { ...observation('366999002'), type: 'Cargo' };
const sailing = { ...observation('366999003'), type: '36' };
const { layer, icons } = setup({
async getSnapshot() {
return snapshot([aid, ship]);
return snapshot([aid, ship, sailing]);
},
});
await layer.update();
const svgOf = (id) => {
const itemOf = (id) => {
assert.ok(icons.has(id), id);
return atob(icons.item(id).image.split(',')[1]);
return icons.item(id);
};
assert.match(svgOf('993672001'), /<circle/);
const buoy = itemOf('993672001');
assert.equal(buoy.image, aidSprite());
assert.equal(buoy.rotationMode, 'screen', 'upright');
assert.equal(buoy.rotation, 0, 'never turned');
assert.deepEqual(buoy.color, cssColor(AID_TO_NAVIGATION_STYLE.css));
// The source's virtual flag reaches the layer's record.
const recordOf = (id) => layer.testing._vesselRecordForTest(id);
assert.equal(recordOf('993672001').virtual, false);
assert.equal(recordOf('366999002').virtual, false);
assert.doesNotMatch(svgOf('993672001'), /<path/);
assert.match(svgOf('366999002'), /<path/);
const cargo = itemOf('366999002');
assert.equal(cargo.image, vesselSprite('cargo'));
assert.equal(cargo.rotationMode, 'course');
assert.deepEqual(cargo.color, cssColor(VESSEL_KIND_STYLES.cargo.css));
const sail = itemOf('366999003');
assert.equal(sail.image, vesselSprite('sailing'));
assert.deepEqual(sail.color, cssColor(VESSEL_KIND_STYLES.sailing.css));
// Every vessel and aid draws the same size before its speed scale.
assert.deepEqual(cargo.size, buoy.size);
assert.deepEqual(sail.size, buoy.size);
});
test('a virtual aid to navigation keeps its disc and its virtual flag', async () => {
test('a virtual aid to navigation keeps its buoy and its virtual flag', async () => {
const aid = {
...observation('993672009'),
mmsi: '993672009',
@@ -599,7 +615,7 @@ test('a virtual aid to navigation keeps its disc and its virtual flag', async ()
await layer.update();
assert.ok(icons.has('993672009'));
assert.equal(layer.testing._vesselRecordForTest('993672009').virtual, true);
assert.match(atob(icons.item('993672009').image.split(',')[1]), /<circle/);
assert.equal(icons.item('993672009').image, aidSprite());
});
test('a feed with no AISStream key reports its key as required, and a live one does not', async () => {
+70 -4
View File
@@ -20,6 +20,7 @@ function harness({ placement = null, following = false } = {}) {
const visuals = [];
const state = { selectedRecord: null, trailId: null };
const records = new VesselRecords({ now: () => 5_000_000 });
const primitives = [];
const rendering = {
ensureCollections() {},
makeOccluder: () => null,
@@ -28,8 +29,12 @@ function harness({ placement = null, following = false } = {}) {
visuals.push(record.id);
return { billboard: null };
},
addRecordPrimitives() {},
removeRecordPrimitives() {},
addRecordPrimitives(record) {
primitives.push(['add', record.id]);
},
removeRecordPrimitives(record) {
primitives.push(['remove', record.id]);
},
shipIcon: () => 'icon',
shipScale: () => 1,
syncRecordIcon() {},
@@ -41,12 +46,15 @@ function harness({ placement = null, following = false } = {}) {
records,
rendering,
tracking: {},
selection: {},
cards: {},
selection: { clearVesselInspection() {} },
cards: { updateSelectedVesselHud() {} },
followsClock: () => following,
});
return {
visuals,
primitives,
state,
records,
reconcile: (rows, options) => renderer.reconcileVessels({}, rows, options),
};
}
@@ -105,3 +113,61 @@ test('following the world clock, or rows at another time, tell the placement not
harness({ placement }).reconcile([row('a')], { replace: true });
assert.deepEqual(told, []);
});
test('back at live, the first live vessel rows keep the vessels they have, drop the rest, and are told to the placement', () => {
const { told, forgotten, placement } = recording();
const probe = harness({ placement });
probe.reconcile([row('a'), row('b')]);
probe.primitives.length = 0;
told.length = 0;
probe.reconcile(
[row('a', { lat: 52, last_position_epoch: 1_060 }), row('c')],
{ handover: true },
);
// The vessel it has keeps its icon; the one it lacks goes; a new one is
// added.
assert.deepEqual(probe.primitives, [
['add', 'c'],
['remove', 'b'],
]);
assert.deepEqual(forgotten, ['b']);
assert.deepEqual(
told.map(([id]) => id),
['a', 'c'],
'live fixes, told to the placement',
);
});
test('back at live, partial vessel rows keep the vessels they lack whose newest fix is recent; complete rows pin the selected one', () => {
const probe = harness();
// The records' clock reads 5 000 s: 'recent' was fixed 100 s before it,
// 'old' and 'picked' over an hour before.
probe.reconcile([
row('recent', { last_position_epoch: 4_900 }),
row('old'),
row('picked'),
]);
probe.state.selectedRecord = probe.records.byId.get('picked');
probe.primitives.length = 0;
probe.reconcile([row('c', { last_position_epoch: 4_990 })], {
complete: false,
handover: true,
});
// Partial rows prove no absence for a recent fix; an old one is gone.
assert.ok(probe.records.byId.has('recent'));
assert.equal(probe.records.byId.get('recent').motion, null);
assert.equal(probe.records.byId.has('old'), false);
const complete = harness();
complete.reconcile([
row('recent', { last_position_epoch: 4_900 }),
row('picked'),
]);
complete.state.selectedRecord = complete.records.byId.get('picked');
complete.reconcile([row('c', { last_position_epoch: 4_990 })], {
handover: true,
});
// Complete rows judge as a refresh does: the selected vessel is pinned for
// a few refreshes, the rest go.
assert.deepEqual([...complete.records.byId.keys()].sort(), ['c', 'picked']);
});
+15 -2
View File
@@ -103,7 +103,12 @@ export class VesselRecords {
* between the two (see motion.js). `replace`: the rows are the world at
* another time (the clock jumped), so they stand in for every vessel: one
* they lack is gone at once, selected or not, and none moves from where it
* was at the time the clock left.
* was at the time the clock left. `handover`: the first live rows after the
* clock came back to live: a vessel they have moves to its live fix, not
* from where it was at the time the clock left; one they lack is judged
* as any live refresh judges it (a partial refresh, the selected vessel),
* by how old its newest fix is rather than when it was loaded, and holds
* at its last position meanwhile.
*/
reconcile(
rows,
@@ -112,6 +117,7 @@ export class VesselRecords {
selectedRecord = null,
cap = Infinity,
replace = false,
handover = false,
follow = false,
},
effects,
@@ -152,7 +158,7 @@ export class VesselRecords {
record.fixReceivedAtMs = next.fixReceivedAtMs;
record.fixFeedEpoch = next.fixFeedEpoch;
}
if (replace) {
if (replace || handover) {
record.motion = null;
record.fixes = next.fixes;
} else if (follow) {
@@ -195,6 +201,13 @@ export class VesselRecords {
}
for (const [id, record] of this.byId) {
if (seen.has(id)) continue;
if (handover) {
record.motion = null;
record.fixes = null;
// Loaded for another time: last seen at its newest fix.
const fixMs = finiteNumber(record.lastPositionEpoch);
if (fixMs !== null) record.receivedAtMs = fixMs * 1000;
}
if (replace) {
effects.remove(record, record === selectedRecord);
this.byId.delete(id);
+48 -35
View File
@@ -43,7 +43,11 @@ import {
vesselModelSpec,
} from '../../data/fleetModels.js';
import { createFleetModelLayer } from '../../data/fleetModelInstances.js';
import { isAidToNavigation } from '../../data/vesselTypes.js';
import { vesselPartState } from '../../data/modelPartDrivers.js';
import { isAidToNavigation, vesselKind } from '../../data/vesselTypes.js';
import { aidSprite, vesselSprite } from '../../data/vesselSprites.js';
import { cssColor } from '../../render/color.js';
import { KNOT_MPS } from '../../data/units.js';
/** A moving vessel's next frame is asked for once it would move this far on
* screen (pixels), so it glides when it moves visibly and the scene idles
@@ -55,11 +59,16 @@ const PLACEMENT_FRAME_MS = 1000;
* ms), so one that comes into view is judged where it is. */
const HIDDEN_FOLLOW_MS = 250;
/** The ship artwork's own raster size (px). */
/** A vessel or aid sprite's drawn size before its scale (CSS px). */
const SHIP_ICON_PX = 32;
/** A selected vessel's or aid's tint. */
const SELECTED_TINT = Object.freeze([1, 1, 1, 1]);
let instances = 0;
/** Tint by CSS colour: a handful of type colours. */
const tints = new Map();
/** How often the vessels near enough for a model are gathered again (wall ms). */
const MODEL_CANDIDATES_MS = 500;
@@ -405,6 +414,7 @@ export function createRendering({
/** The icon item a record draws, as it now is. */
function iconItem(record, visual) {
const selected = record === state.selectedRecord;
const aid = isAidToNavigation(record);
const courseDeg = vesselCourseDeg(record);
// Following the clock, not there yet at the time drawn.
visual.seen = seenYet(record);
@@ -418,11 +428,14 @@ export function createRendering({
// is not there yet.
show: !isCockpitSubject(record) && !visual.modelOwnsVisual && visual.seen,
pos: plan?.pos ?? visual.position,
image: shipIcon(record, selected),
image: shipIcon(record),
size: [SHIP_ICON_PX, SHIP_ICON_PX],
// Selection changes the colour only, never the size.
// Tinted by type; selection changes the colour only, never the size.
color: selected ? SELECTED_TINT : shipTint(record),
scale: shipScale(record),
rotationMode: 'course',
// An aid's buoy stands upright on screen; a vessel turns with course.
rotationMode: aid ? 'screen' : 'course',
rotation: 0,
// Held on course, or along its track on the renderer's clock;
// `course` for renderers without motion segments.
course: courseDeg,
@@ -519,40 +532,33 @@ export function createRendering({
}
/**
* Build (and cache) a chevron/delta-wing SVG data URL tinted for the vessel.
* The shape points north (up) so the row's course maps directly to heading.
* An aid to navigation, which has no heading, is a ringed disc instead.
* One icon is generated per color+variant and shares one atlas slot.
* @param {Object} record - Vessel record (drives per-type tint).
* @param {boolean} selected - True for the white/brighter selected variant.
* The sprite a vessel is drawn as: the white hull of its kind
* (`vesselKind`), bow up so the row's course turns it to its heading, or
* for an aid to navigation the buoy. The layer tints it
* (`shipTint`), so each shape takes one icon-atlas slot.
* @param {Object} record - Vessel record.
* @returns {string} SVG data URL.
*/
function shipIcon(record, selected) {
const aid = isAidToNavigation(record);
const cssColor = selected
? '#ffffff'
: aid
? AID_TO_NAVIGATION_STYLE.css
: vesselTypeCss(record.type);
const key = `${cssColor}:${selected ? 'selected' : 'normal'}:${aid ? 'aid' : 'ship'}`;
if (vesselState.shipIconCache.has(key))
return vesselState.shipIconCache.get(key);
function shipIcon(record) {
return isAidToNavigation(record)
? aidSprite()
: vesselSprite(vesselKind(record.type));
}
const stroke = selected ? 'rgba(6,26,32,0.95)' : 'rgba(4,18,24,0.9)';
const strokeWidth = selected ? 1.1 : 0.7;
const shape = aid
? `<circle r="8" fill="${cssColor}" stroke="${stroke}" stroke-width="${strokeWidth * 2}"/>
<circle r="3" fill="${stroke}"/>`
: `<path d="M0,-14 L11,10 L4,7 L0,14 L-4,7 L-11,10 Z" fill="${cssColor}" stroke="${stroke}" stroke-width="${strokeWidth}" stroke-linejoin="round"/>`;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<g transform="translate(16,16)">
${shape}
</g>
</svg>`;
const icon = 'data:image/svg+xml;base64,' + btoa(svg);
vesselState.shipIconCache.set(key, icon);
return icon;
/**
* A vessel's tint, `[r, g, b, a]`: its type's colour (vesselLabels.js,
* shared with its card), an aid's bone white.
* @param {Object} record - Vessel record.
*/
function shipTint(record) {
const css = isAidToNavigation(record)
? AID_TO_NAVIGATION_STYLE.css
: vesselTypeCss(record.type);
let tint = tints.get(css);
if (!tint) tints.set(css, (tint = Object.freeze(cssColor(css))));
return tint;
}
// Under the DISPLAY rail's 3D toggle, vessels near the camera are drawn as
@@ -578,6 +584,13 @@ export function createRendering({
resolveAsset: fleet.resolveAsset,
// A hull below the waterline would show through a plain globe.
waterline: true,
// Its radar sweeps while it is under way (speed in knots).
partState: (item, table) =>
vesselPartState(table, {
speedMps: Number.isFinite(item.record?.speed)
? item.record.speed * KNOT_MPS
: null,
}),
});
}
+9 -3
View File
@@ -1,4 +1,5 @@
const KNOT_MPS = 1852 / 3600;
import { KNOT_MPS } from '../../data/units.js';
const finiteOrNaN = (value) =>
typeof value === 'number' && Number.isFinite(value) ? value : NaN;
@@ -34,11 +35,15 @@ export function createVesselSnapshotRenderer({
cards,
followsClock = () => false,
}) {
/** `replace`: the rows are the world at another time (see VesselRecords). */
/**
* `replace`: the rows are the world at another time (see VesselRecords).
* `handover`: the first live rows after the clock came back to live (see
* VesselRecords); they are live fixes.
*/
function reconcileVessels(
viewer,
rows,
{ complete = true, replace = false } = {},
{ complete = true, replace = false, handover = false } = {},
) {
rendering.ensureCollections(viewer);
const occluder = rendering.makeOccluder();
@@ -57,6 +62,7 @@ export function createVesselSnapshotRenderer({
selectedRecord: state.selectedRecord,
cap: rendering.renderRowLimit(),
...(replace && { replace }),
...(handover && { handover }),
...(follow && { follow }),
},
{
-4
View File
@@ -53,10 +53,6 @@ export function createVesselState({ source, services }) {
vesselState._geoidReady = false;
/** @type {Map<string, string>} `${cssColor}:${variant}` -> chevron SVG data URL */
vesselState.shipIconCache = new Map();
/** Row ids for unkeyed (no-id) records, which are rebuilt every poll. */
vesselState._unkeyedIconSequence = 0;