-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
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) |
There was a problem hiding this comment.
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
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 do you still want me to relocate the math to a function? |
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