vasturiano / 3d-force-graph

3D force-directed graph component using ThreeJS/WebGL
https://vasturiano.github.io/3d-force-graph/example/large-graph/
MIT License
4.66k stars 821 forks source link

Make renderer accessible #49

Closed smoes closed 6 years ago

smoes commented 6 years ago

I am trying to animate edges (fading color).

In conjunction with three.js I found GSAP's TweenLite. However, for integrating TweenLite, the renderer must be accessible and on each tick update must be callable.

Is there a way to access the renderer? Is there an easier way to animate edges (e.g. fading color)?

smoes commented 6 years ago

I just noticed that it isn't possible to create a custom link three object. This will make it certainly hard to animate edges at all, right?

vasturiano commented 6 years ago

Hi @smoes. Correct, currently you can't supply a custom link object, at least not the same way that it's possible with nodes. The lib generates either plain line or cylinder objects that you can configure via the props linkColor, linkOpacity, linkWidth, linkResolution, etc. However, if you just wish to animate color, you don't need to supply a custom object, you can simply change the values of linkColor from inside the tween cycle and the graph will react.

Reg your question about accessing the renderer, you may not need it if you follow the route above, but just in case, this issue response may be of help: https://github.com/vasturiano/3d-force-graph/issues/38

smoes commented 6 years ago

Thanks for your fast answer. I now went with downloading the sources for 3d-force-graph and three-forcegraph to access the renderer and to change the link mesh. It was quite tricky since the tweening material must be stored to be re-used in every update cycle. I had some troubles with your kapsule-methodology. It feels a little over-engineered. However, as a mainly functional programmer I begin to like passing around the state object ;)

Good work, keep it up.