Files
gods-eye-view/src/data/spriteOrder.js
T
Sameh Khamis c073064507 Stack sprite layers by draw order, flights on top
Each sprite layer's icon or dot set is now made at a draw order taken
from SPRITE_LAYER_ORDER through the renderer's per-set drawOrder:
flights over military, vessels, directions, transit, bikeshare, FIRMS
and CCTV, whichever layer was turned on first. Picks name the topmost
first. The orders are negative, so selection highlights, route
endpoints, the tracked plane and every other set at the default order
still draw over all sprite layers, as they did before.

The raise-to-top restorer, the sprite registry and the primitive-name
lookups are gone, which takes spriteOrder.js off the viewer-access list.
Before, the restorer raised the layers to the bottom of the scene in the
order they were enabled, so flights usually ended up under the others.
2026-11-09 14:32:50 -08:00

29 lines
1008 B
JavaScript

/** Bottom-to-top order of the sprite layers' icon and dot sets. */
export const SPRITE_LAYER_ORDER = Object.freeze([
'cctv',
'firms',
'bikeshare',
'transit',
'transit-motion',
'directions',
'ais',
'military',
'flights',
]);
/**
* The draw order (`SetSpec.drawOrder`) a sprite layer's set is made with:
* its place in `SPRITE_LAYER_ORDER`, counted back from -1 for flights, so
* flights draw over every other sprite layer and the rest follow the list,
* whichever layer was turned on first. Every set at the default order, 0
* (selection highlights, route endpoints, the tracked plane and the other
* overlays), stays over all of them, as it did when the sprite sets were
* raised to the bottom of the scene. A key not in the list gets 0.
* @param {string} layerId - Stable sprite-order layer key.
* @returns {number}
*/
export function spriteDrawOrder(layerId) {
const index = SPRITE_LAYER_ORDER.indexOf(layerId);
return index < 0 ? 0 : index - SPRITE_LAYER_ORDER.length;
}