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 <noreply@anthropic.com>
This commit is contained in:
parent
f4d7448c9d
commit
87d5e8b1cb
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue