fix: w阈值0.03实际过滤+前后窗口平滑入口/出口

- w<=0永不触发→改为w<0.03实际过滤
- 添加wins[i+2]平滑进入(t-0.85阈值)
- 添加wins[i-1]平滑退出(0.15-t阈值)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TianXuan Developer
2026-07-25 14:44:36 +08:00
parent 7872e729cb
commit bca6929838
@@ -2784,17 +2784,24 @@ function renderTrafficCrossfade() {
// Each frame: add w0 edges with fade-out, w1 edges with fade-in
const edgeMap = {};
function add(edges, w) {
if (!edges || w <= 0) return;
if (!edges || w < 0.03) 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};
// 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);
add(w1?w1.edges:[], t);
// Also blend in edges that are about to appear (smooth entry)
if (mix.i + 2 < wins.length) {
add(wins[mix.i + 2].edges, Math.max(0, t - 0.85));
}
// Blend out edges from previous window (smooth exit)
if (mix.i > 0) {
add(wins[mix.i - 1].edges, Math.max(0, 0.15 - t));
}
const edges = Object.values(edgeMap);
if (!edges.length) return;