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:
@@ -2784,17 +2784,24 @@ function renderTrafficCrossfade() {
|
|||||||
// Each frame: add w0 edges with fade-out, w1 edges with fade-in
|
// Each frame: add w0 edges with fade-out, w1 edges with fade-in
|
||||||
const edgeMap = {};
|
const edgeMap = {};
|
||||||
function add(edges, w) {
|
function add(edges, w) {
|
||||||
if (!edges || w <= 0) return;
|
if (!edges || w < 0.03) return;
|
||||||
edges.forEach(e => {
|
edges.forEach(e => {
|
||||||
const k = e.source + '|' + e.target;
|
const k = e.source + '|' + e.target;
|
||||||
if (!edgeMap[k]) edgeMap[k] = {source:e.source, target:e.target, weight:0, count:0};
|
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 (w > edgeMap[k].weight) edgeMap[k].weight = w;
|
||||||
if ((e.count||0) > edgeMap[k].count) edgeMap[k].count = e.count||0;
|
if ((e.count||0) > edgeMap[k].count) edgeMap[k].count = e.count||0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
add(w0?w0.edges:[], 1-t);
|
add(w0?w0.edges:[], 1-t);
|
||||||
add(w1?w1.edges:[], 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);
|
const edges = Object.values(edgeMap);
|
||||||
if (!edges.length) return;
|
if (!edges.length) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user