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

Hide some lines from the scene #114

Closed
freitaga opened this issue Sep 3, 2018 · 4 comments
Closed

Hide some lines from the scene #114

freitaga opened this issue Sep 3, 2018 · 4 comments
Assignees

Comments

@freitaga
Copy link

freitaga commented Sep 3, 2018

I'm making an interactive scene out of the graph. On node click, I focus on the node and display only its connections to surrounding nodes along with some color changes. If I replace the links completely, the graph structure/physics take over and warp the graph. I figure I have to hide the other connections to maintain the graph structure. The options on the readme are set across the graph, so I need to chose which specific links to hide, whether it be calling object.visible = false on the 3js object, or setting its opacity to 0. Since the 3js scene is created from the graph function, I assume I have to target lines directly in 3js somehow unless there is an easier way.

@vasturiano
Copy link
Owner

@freitaga you can just use the method linkVisibility. This will only affect the visuals and not the internal physics engine. You can use it, for example onClick events like:

myGraph.onNodeClick(node => {
  myGraph.linkVisibility(link => shouldShowLink(link, node))
})

You should implement the logic in the shouldShowLink. A possible implementation to show only directly connected links would be:

function shouldShowLink(link, baseNode) {
  return link.source === baseNode || link.target === baseNode;
}

Let me know if you can get it working.

@vasturiano vasturiano self-assigned this Sep 3, 2018
@freitaga
Copy link
Author

freitaga commented Sep 3, 2018

This solution worked perfectly! Only had to add in coloring for link type. Thanks again 👍

@vasturiano
Copy link
Owner

Glad to hear. Your nodes look really stunning! Are those images?

@freitaga
Copy link
Author

freitaga commented Sep 4, 2018

They're planets made from a sphere + planet texture. Its live over at http://galactic.vision/planetary_quorum.html# if you want to check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants