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

Focus on node children #493

Merged
merged 3 commits into from
Oct 16, 2023
Merged

Focus on node children #493

merged 3 commits into from
Oct 16, 2023

Conversation

cosmicpotato137
Copy link
Contributor

This change rotates the camera so that both the selected text and it's children are in view. May need to tweak how far the camera zooms out since right now it depends on how far the children nodes are from the parent.

Closes #473

  • tested on firefox and chrome
  • peer reviewed

@cosmicpotato137 cosmicpotato137 deleted the branch stakwork:master October 16, 2023 13:56
@cosmicpotato137 cosmicpotato137 deleted the master branch October 16, 2023 13:56
@cosmicpotato137 cosmicpotato137 restored the master branch October 16, 2023 13:57
Comment on lines +53 to +72
const children: NodeExtended[] = graphData?.nodes.filter((node) =>
selected.children?.find((str) => str === node.id),
)

// position of node
const spos = new Vector3(selected.x, selected.y, selected.z)
// average positioon of children
let avgDir = new Vector3(0, 0, 0)

children.map((child: NodeExtended) => {
avgDir = avgDir.add(new Vector3(child.x, child.y, child.z).normalize())

return child
})

// offset from node based on children
const sizeOffset = selected.scale ? 1 - 1 / (selected.scale + 10) : 1
const offset = spos.sub(avgDir).multiplyScalar(0.8 * sizeOffset)

pos = spos.add(offset)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be good to have as a function that we can test since there is some mathy stuff involved

@kevkevinpal
Copy link
Collaborator

This change is looking good to me going to merge

tests are failing but I think thats an issue one our side with our gitactions, I can try and fix that

@kevkevinpal kevkevinpal merged commit 544cb20 into stakwork:master Oct 16, 2023
0 of 3 checks passed
@cosmicpotato137
Copy link
Contributor Author

@kevkevinpal do you still want me to relocate the math to a function?

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

Successfully merging this pull request may close these issues.

Zoom level navigation
2 participants