MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / NodePoints

Function NodePoints

graph-ui/src/galaxy/NodeCloud.tsx:94–163  ·  view source on GitHub ↗
({
    nodes,
    highlightedIds,
    onHover,
    onClick,
    opacity,
    boost,
}: Required<NodeCloudProps>)

Source from the content-addressed store, hash-verified

92/* Point-sprite mode for very large clouds */
93
94function NodePoints({
95 nodes,
96 highlightedIds,
97 onHover,
98 onClick,
99 opacity,
100 boost,
101}: Required<NodeCloudProps>) {
102 const { raycaster } = useThree();
103
104 /* Widen the raycast threshold while points are on screen */
105 useEffect(() => {
106 const prev = raycaster.params.Points?.threshold ?? 1;
107 raycaster.params.Points = { threshold: 3 };
108 return () => {
109 raycaster.params.Points = { threshold: prev };
110 };
111 }, [raycaster]);
112
113 const { positions, colors } = useMemo(() => {
114 const positions = new Float32Array(nodes.length * 3);
115 const colors = new Float32Array(nodes.length * 3);
116 const tempColor = new THREE.Color();
117 for (let i = 0; i < nodes.length; i++) {
118 const n = nodes[i];
119 positions[i * 3] = n.x;
120 positions[i * 3 + 1] = n.y;
121 positions[i * 3 + 2] = n.z;
122 const [r, g, b] = nodeColor(n, highlightedIds, opacity, boost, tempColor);
123 colors[i * 3] = r;
124 colors[i * 3 + 1] = g;
125 colors[i * 3 + 2] = b;
126 }
127 return { positions, colors };
128 }, [nodes, highlightedIds, opacity, boost]);
129
130 return (
131 <points
132 /* Remount when the buffer size changes so stale attributes never linger */
133 key={nodes.length}
134 onPointerOver={(e) => {
135 e.stopPropagation();
136 if (e.index !== undefined && e.index < nodes.length) {
137 onHover(nodes[e.index]);
138 }
139 }}
140 onPointerOut={() => onHover(null)}
141 onClick={(e) => {
142 e.stopPropagation();
143 if (e.index !== undefined && e.index < nodes.length) {
144 onClick(nodes[e.index]);
145 }
146 }}
147 >
148 <bufferGeometry>
149 <bufferAttribute attach="attributes-position" args={[positions, 3]} />
150 <bufferAttribute attach="attributes-color" args={[colors, 3]} />
151 </bufferGeometry>

Callers

nothing calls this directly

Calls 2

nodeColorFunction · 0.85
getPointSpriteFunction · 0.85

Tested by

no test coverage detected