Skip to content

Commit

Permalink
feat: adjusted split force layout, added size based on nodecount
Browse files Browse the repository at this point in the history
  • Loading branch information
Rassl committed Oct 28, 2024
1 parent 18dfac7 commit 7935ac5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Universe/Graph/Connections/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Connections = memo(() => {
{data?.links.map((l: Link) => {
const isSelected = selectedNode?.ref_id === l.source || selectedNode?.ref_id === l.target

const lineWidth = selectedNode ? 0 : 0.5
const lineWidth = selectedNode ? 0 : 1

return (
<LineComponent key={l.ref_id} isSelected={isSelected} lineWidth={lineWidth} visible={!showSelectionGraph} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { Billboard, Instance } from '@react-three/drei'

type Props = {
color: string
scale: number
}

export const Point = ({ color }: Props) => (
export const Point = ({ color, scale }: Props) => (
<>
<Billboard follow lockX={false} lockY={false} lockZ={false}>
<Instance color={color} />
<Instance color={color} scale={scale} />
</Billboard>
</>
)
2 changes: 1 addition & 1 deletion src/components/Universe/Graph/Cubes/NodePoints/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const _NodePoints = () => {
const primaryColor = normalizedSchemasByType[node.node_type]?.primary_color
const color = primaryColor ?? (COLORS_MAP[nodeTypes.indexOf(node.node_type)] || colors.white)

return <Point key={node.ref_id} color={color} />
return <Point key={node.ref_id} color={color} scale={node.edge_count || 1} />
})}
</Instances>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Universe/Graph/Cubes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const Cubes = memo(() => {
const hide = !!selectedNode && (relativeIds.includes(node.ref_id) || selectedNode.ref_id === node.ref_id)

return (
<mesh key={node.ref_id} name="wr2" userData={node}>
<mesh key={node.ref_id} name="wr2" scale={node.edge_count || 1} userData={node}>
<boxGeometry args={[40, 40, 40]} />
<meshStandardMaterial opacity={0} transparent />
<TextNode
Expand Down
2 changes: 1 addition & 1 deletion src/components/Universe/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const Graph = () => {

material.color = new Color(lineColor)
material.transparent = true
material.opacity = 0.2
material.opacity = 1
}
})
}
Expand Down
7 changes: 6 additions & 1 deletion src/stores/useGraphStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ export const useGraphStore = create<GraphStore>()((set, get) => ({
.force(
'y',
forceY()
.y((node: NodeExtended) => nodeTypes.indexOf(node.node_type) * 400)
.y((node: NodeExtended) => {
const index = nodeTypes.indexOf(node.node_type)
const yOffset = Math.floor(index / 2) * 400

return index % 2 === 0 ? yOffset : -yOffset
})
.strength(10),
)
},
Expand Down

0 comments on commit 7935ac5

Please sign in to comment.