From 87d5e8b1cbfd8162a2504bff12c25e82f9dbf13c Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 12 Mar 2026 10:30:43 -0700 Subject: [PATCH] fix(rnetwork): pre-load THREE before graph creation nodeThreeObject callback was returning a Promise (from async createNodeObjectAsync) because THREE wasn't cached yet. Pre-load THREE via import("three") before creating the graph so the callback always returns a synchronous Three.js object. Co-Authored-By: Claude Opus 4.6 --- modules/rnetwork/components/folk-graph-viewer.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/rnetwork/components/folk-graph-viewer.ts b/modules/rnetwork/components/folk-graph-viewer.ts index fc1b4fe..b3860ec 100644 --- a/modules/rnetwork/components/folk-graph-viewer.ts +++ b/modules/rnetwork/components/folk-graph-viewer.ts @@ -545,6 +545,13 @@ class FolkGraphViewer extends HTMLElement { const ForceGraph3D = (window as any).ForceGraph3D; if (!ForceGraph3D) throw new Error("ForceGraph3D not loaded — check UMD script tag"); + // Pre-load THREE so nodeThreeObject callback is synchronous. + // Import from the same module the UMD build uses internally + // to avoid "not an instance of THREE.Object3D" errors. + const THREE = await import("three"); + this._threeModule = THREE; + (window as any).__THREE_CACHE__ = THREE; + const graph = ForceGraph3D({ controlType: "orbit" })(container) .backgroundColor("rgba(0,0,0,0)") .showNavInfo(false)