fix: 交叉淡入淡出可见—权重范围扩大到8%-100%
- alpha: 0.08+0.92*weight (之前0.4+0.6导致不活跃边仍40%可见) - weight<0.05直接跳过(不可见) - 不再Math.max累积权重(每帧重新计算) 效果: t=0时w0边~100%可见+w1边~8%几乎不可见, 真正的淡入淡出 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2781,14 +2781,16 @@ function renderTrafficCrossfade() {
|
||||
const w1 = mix.i + 1 < wins.length ? wins[mix.i + 1] : null;
|
||||
const t = mix.t;
|
||||
|
||||
// Each frame: add w0 edges with fade-out, w1 edges with fade-in
|
||||
const edgeMap = {};
|
||||
function add(edges, w) {
|
||||
if (!edges) return;
|
||||
if (!edges || w <= 0) return;
|
||||
edges.forEach(e => {
|
||||
const k = e.source + '|' + e.target;
|
||||
if (!edgeMap[k]) edgeMap[k] = {source:e.source, target:e.target, weight:0, count:0};
|
||||
edgeMap[k].weight = Math.max(edgeMap[k].weight, w);
|
||||
edgeMap[k].count = Math.max(edgeMap[k].count, e.count||0);
|
||||
// Use the FRESHEST weight (not max accumulation), so old edges fade out
|
||||
if (w > edgeMap[k].weight) edgeMap[k].weight = w;
|
||||
if ((e.count||0) > edgeMap[k].count) edgeMap[k].count = e.count||0;
|
||||
});
|
||||
}
|
||||
add(w0?w0.edges:[], 1-t);
|
||||
@@ -2813,8 +2815,9 @@ function renderTrafficCrossfade() {
|
||||
if (!p1 || !p2) return;
|
||||
const midX = (p1.x + p2.x) / 2;
|
||||
const midY = (p1.y + p2.y) / 2 - Math.abs(p2.x - p1.x) * 0.1;
|
||||
if (e.weight < 0.05) return; // skip near-invisible edges
|
||||
const ratio = Math.min(1, e.count / maxCount);
|
||||
const alpha = 0.4 + 0.6 * e.weight;
|
||||
const alpha = 0.08 + 0.92 * e.weight;
|
||||
|
||||
// Edge trace with src→dst color gradient
|
||||
const grad = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);
|
||||
|
||||
Reference in New Issue
Block a user