fix(traffic): road lines stack as before: flow lines jam on top, heat-lines slow over jam

The lines were one ground primitive per bucket, added free, slow, jam for
flow lines and jam, slow for heat-lines, so where roads cross the later
bucket drew on top. Through the draw port they were one set in kept order
(jam first), and its glow lines draw after its solid ones, which turned
both stackings over. Flow lines are now set free, slow, jam; slow
heat-lines go in a set made after the jam lines' set.
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:35:56 -08:00
1 parent df0afa82e1
commit 4b665147e1
4 files changed
+72 -3

No files matched your search

+17 -3
View File
@@ -43,7 +43,10 @@ export function createRendering({
/** Take every road line (heat-lines or flow lines) down. */
function removeHeatLines() {
if (layerState._heatLineCount) layerState._heatSet?.clear();
if (layerState._heatLineCount) {
layerState._heatSet?.clear();
layerState._heatOverSet?.clear();
}
layerState._heatJam = [];
layerState._heatLineCount = 0;
parts.animation.syncRenderDemand?.();
@@ -142,7 +145,13 @@ export function createRendering({
bucket === 'jam' ? HEAT_LINE_JAM_WIDTH : HEAT_LINE_SLOW_WIDTH;
}
const items = [];
// Drawn in the order the per-bucket primitives were added: flow lines
// free, slow, then jam on top, in one set (in the order of its items);
// heat-lines jam, then slow over it, in a set of their own made after
// the jam lines' (a set draws its glow lines after its solid ones).
const order = flowLines ? ['free', 'slow', 'jam'] : ['jam', 'slow'];
const byBucket = { jam: [], slow: [], free: [] };
const over = [];
const jam = [];
for (let i = 0; i < kept.length; i++) {
const { road, bucket } = kept[i];
@@ -156,12 +165,17 @@ export function createRendering({
clampTo: flowLines ? 'both' : 'tiles',
style: styleFor(bucket),
};
items.push(item);
if (bucket === 'slow' && !flowLines && layerState._heatOverSet)
over.push(item);
else byBucket[bucket].push(item);
// The steady flow lines never pulse.
if (bucket === 'jam' && !flowLines) jam.push(item);
}
const items = order.flatMap((bucket) => byBucket[bucket]);
if (items.length || layerState._heatLineCount)
layerState._heatSet.set(items);
if (over.length || layerState._heatOverSet?.size())
layerState._heatOverSet.set(over);
layerState._heatJam = jam;
layerState._heatLineCount = kept.length;