From e09ae1d8d20719a08a33b6c448b48946fed41d1e Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Fri, 20 Mar 2026 23:16:45 -0700 Subject: [PATCH] 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 --- modules/rnetwork/components/folk-graph-viewer.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/rnetwork/components/folk-graph-viewer.ts b/modules/rnetwork/components/folk-graph-viewer.ts index a5c12a3..85ab17b 100644 --- a/modules/rnetwork/components/folk-graph-viewer.ts +++ b/modules/rnetwork/components/folk-graph-viewer.ts @@ -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;