vasturiano / 3d-force-graph-vr

3D force-directed graph component in VR
https://vasturiano.github.io/3d-force-graph-vr/example/large-graph/
MIT License
223 stars 51 forks source link

How to restart the simulation, is there any way to access the simulation()? #10

Closed thisisvaze closed 5 years ago

thisisvaze commented 5 years ago

I need to restart the simulation at a certain point of time, it would be of great help if anyone could help me with that. Thanks in advance.

vasturiano commented 5 years ago

@aadityavaze to reset the nodes position and restart the simulation over, you just have to pass a fresh data set to .graphData(<new data>). Just make sure you use a fresh array for nodes that have not been annotated with the x, y and z attributes, added by the running simulation.

thisisvaze commented 5 years ago

Thanks for your answer, actually I wanted to ask if I could set alpha=1, basically, I want to restart the custom forces that I've implemented on the same set of nodes.

vasturiano commented 5 years ago

Refeeding the data causes alpha to be reset to 1. So you could simply do this, to preserve the nodes coordinates:

myGraph.graphData(myGraph.graphData())
thisisvaze commented 5 years ago

That's exactly what I was looking for. Thanks a lot.