fix(rnetwork): prevent TubeGeometry NaN errors in 3D graph

Links with curved curvature create TubeGeometry that crashes with NaN
positions when force simulation hasn't converged yet. Add linkVisibility
guard to hide links until both endpoints have valid coordinates, and
bump warmupTicks from 50 to 100 for more settling time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-20 23:16:45 -07:00
parent 31fe552755
commit e09ae1d8d2
1 changed files with 10 additions and 1 deletions

View File

@ -983,6 +983,15 @@ class FolkGraphViewer extends HTMLElement {
return link.type === "delegates_to" ? 0.15 : 0;
})
.linkCurveRotation("rotation")
.linkVisibility((link: any) => {
// Hide links whose endpoints haven't been positioned yet
// (prevents TubeGeometry NaN errors during force warmup)
const s = link.source, t = link.target;
if (!s || !t) return false;
const sx = typeof s === "object" ? s.x : undefined;
const tx = typeof t === "object" ? t.x : undefined;
return sx != null && !isNaN(sx) && tx != null && !isNaN(tx);
})
.linkOpacity(0.6)
.linkDirectionalArrowLength((link: GraphEdge) => {
if (link.type === "cross_layer_flow") return 3;
@ -1040,7 +1049,7 @@ class FolkGraphViewer extends HTMLElement {
})
.d3AlphaDecay(0.02)
.d3VelocityDecay(0.3)
.warmupTicks(50)
.warmupTicks(100)
.cooldownTicks(150);
this.graph = graph;