From 7a7ae808c7509d7d94c4e050e45181423ebab072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Fri, 25 Oct 2024 13:20:32 +0300 Subject: [PATCH] feat: added support for node without text --- .../Universe/Graph/Cubes/Text/index.tsx | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/components/Universe/Graph/Cubes/Text/index.tsx b/src/components/Universe/Graph/Cubes/Text/index.tsx index 21204f905..1d6e2eedb 100644 --- a/src/components/Universe/Graph/Cubes/Text/index.tsx +++ b/src/components/Universe/Graph/Cubes/Text/index.tsx @@ -67,7 +67,6 @@ function splitStringIntoThreeParts(text: string): string { } export const TextNode = memo(({ node, hide, isHovered }: Props) => { - const ref = useRef(null) const svgRef = useRef(null) const ringRef = useRef(null) const selectedNode = useSelectedNode() @@ -82,7 +81,7 @@ export const TextNode = memo(({ node, hide, isHovered }: Props) => { useFrame(({ camera }) => { const checkDistance = () => { - const nodePosition = nodePositionRef.current.setFromMatrixPosition(ref.current!.matrixWorld) + const nodePosition = nodePositionRef.current.setFromMatrixPosition(ringRef.current!.matrixWorld) if (ringRef.current) { ringRef.current.visible = nodePosition.distanceTo(camera.position) < 2500 @@ -97,6 +96,10 @@ export const TextNode = memo(({ node, hide, isHovered }: Props) => { const nodeTypes = useNodeTypes() const textScale = useMemo(() => { + if (!node.name) { + return 0 + } + let scale = (node.edge_count || 1) * 20 if (showSelectionGraph && isSelected) { @@ -153,18 +156,19 @@ export const TextNode = memo(({ node, hide, isHovered }: Props) => { userData={node} /> - - {splitStringIntoThreeParts(sanitizedNodeName)} - + {node.name && ( + + {splitStringIntoThreeParts(sanitizedNodeName)} + + )} )