Custom Nodes
reagraph supports the ability to override the Node shape and pass your own custom node component.
In the GraphCanvas you can pass a callback to the renderNode function
which passes the following attributes:
Using react-three-fiber you can use JSX to create your own WebGL custom node like:
export const Custom3DNode = () => (
<GraphCanvas
nodes={simpleNodes}
edges={simpleEdges}
cameraMode="rotate"
renderNode={({ size, color, opacity }) => (
<group>
<mesh>
<torusKnotGeometry attach="geometry" args={[size, 1.25, 50, 8]} />
<meshBasicMaterial
attach="material"
color={color}
opacity={opacity}
transparent
/>
</mesh>
</group>
)}
/>Last updated on