Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adjusted split force layout, added size based on nodecount #2397

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -9,14 +9,14 @@
const { showSelectionGraph } = useGraphStore((s) => s)
const selectedNode = useSelectedNode()

console.log('connection')

Check warning on line 12 in src/components/Universe/Graph/Connections/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

return (
<group name="simulation-3d-group__connections">
{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 @@ -203,7 +203,7 @@

simulationHelpers.simulationRestart()
} catch (error) {
console.log(error)

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement
// eslint-disable-next-line no-debugger
}

Expand Down Expand Up @@ -262,7 +262,12 @@
.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 Expand Up @@ -294,7 +299,7 @@
simulationRestart: () => {
const { simulation } = get()

if (false) {

Check warning on line 302 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected constant condition
runSimulationPhase(simulation)
}

Expand All @@ -302,7 +307,7 @@
},
},
simulationCreate: (nodes, links) => {
console.log('created')

Check warning on line 310 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

const structuredNodes = structuredClone(nodes)
const structuredLinks = structuredClone(links)
Expand Down
Loading