Open jokroese opened 2 years ago
Here's my suggestion:
Graph.d3Force("radius", forceRadius(gData.nodes, 300));
function forceRadius(nodes, R = 1) {
return () => {
for (const n of nodes) {
const r = Math.hypot(n.x, n.y, n.z);
const u = Math.pow(r ? Math.sqrt(R / r) : 1, 0.05);
n.x *= u;
n.y *= u;
n.z *= u;
}
}
}
Thanks @Fil, that looks great!
The only unusual thing is that dragging a node seems to remove the force. Do you know why that is? And can you see an obvious way to keep the force applied while dragging?
Dragging does not remove the force, but it pushes alpha up (the "temperature", if you will), making all the other forces stronger. You could change the parameter 0.05 to make it stronger with alpha if you wanted, but it would make the initial convergence less smooth.
I really like this approach! Thanks for sharing. Do you know if there is there any way to "pythonize" this or a similar approach in python? Or a way to import my own adjacency list to this and export the 3D coordinates?
Thanks!
I'm trying to constrain some nodes in 3D to a sphere. I'm using 3d-force-graph and hoping to do the constraining with d3-force-limit.
My current naive approach is here: https://codepen.io/jokroese/pen/ExQMrpj.
The problems are:
Do you have suggestions on next steps for moving forward with this?
Possible options: