Keep each drawn icon's expiry in a shared icon book, for replanning

render/motion/iconBook holds the icon items a layer drew to a draw set, as
the vessels' book did, and now also when each one's motion stops being what
the layer would plan: put(item, {expiresAt}) records it (Infinity: planned,
never due; null drops it; a restyle keeps it), and due(t) lists the ones to
plan afresh. It reads a moving icon's position and course at a time through
the shared evaluator, as the renderer draws it given its capabilities. An
item easing its course by courseBlendMs reads its target course.

This is what a layer with dead-reckoned contacts keeps on the CPU in place
of the GPU set's own row expiry. The vessels' icon book is now this one.
This commit is contained in:
Sameh Khamis committed 2026-11-07 02:36:39 -08:00
1 parent 0349941b71
commit e72382b1aa
4 files changed
+255 -51

No files matched your search

+4 -51
View File
@@ -1,53 +1,6 @@
/**
* The vessel icons the layer draws, as it last drew them: each icon item by
* its row id, and the renderer draw set they go to. The layer reads its own
* icons back from here (focus emphasis, ownership of a pick), never from the
* renderer.
* The vessel icons the layer draws, as it last drew them: the shared icon
* book (`render/motion/iconBook.js`). The layer reads its own icons back from
* there (focus emphasis, ownership of a pick), never from the renderer.
*/
/**
* @param {import('../../render/contract/draw').DrawSet<object>|null} [drawSet]
* Where the icons are drawn; none keeps them only here (tests).
*/
export function createVesselIconBook(drawSet = null) {
const items = new Map();
const book = {
/** The draw set's id, or null. */
setId: drawSet?.id ?? null,
get show() {
return drawSet ? drawSet.show : true;
},
set show(value) {
if (drawSet) drawSet.show = value;
},
/** How many icons are drawn. */
get size() {
return items.size;
},
/** The drawn row ids, in the order first drawn. */
ids: () => [...items.keys()],
/** Whether a row id is drawn. */
has: (id) => items.has(id),
/** The item drawn under a row id, or undefined. */
item: (id) => items.get(id),
/** Draw an item (anew, or as it now is). */
put(item) {
items.set(item.id, item);
drawSet?.upsert([item]);
},
remove(id) {
if (items.delete(id)) drawSet?.remove([id]);
},
/** A row's focus emphasis, 1 when not de-emphasised. */
focus: (id) => items.get(id)?.focus ?? 1,
setFocus(id, factor) {
const item = items.get(id);
if (item) book.put({ ...item, focus: factor });
},
dispose() {
items.clear();
drawSet?.dispose();
},
};
return book;
}
export { createIconBook as createVesselIconBook } from '../../render/motion/iconBook.js';