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.54k stars 803 forks source link

WebAssembly (WASM) Version #439

Open philworthy opened 3 years ago

philworthy commented 3 years ago

Hi. Love your work on this Vasco! I'm curious if you have considered/tried to implement a WebAssembly version of this and whether that is likely to have significant speed gains when working with very large graphs (many thousands of nodes).

I saw some others have tried similar things for the classic d3-force library Eg. d3-wasm-force

vasturiano commented 3 years ago

Hi @philworthy thanks for reaching out!

I haven't tried to do a WebAssembly version, I think it would be a nice idea to experiment with. I think it probably be more applicable to the d3-force-3d lower level pure JS module, that takes care of the force simulation engine.

I'm thinking that would mostly only help in cases where the bottleneck is in the forces simulation, for scenarios with complex computationally expensive forces. If the bulk of the load is in the rendering section (due to high volume of objects in the scene), that would possibly not make a large difference.

philworthy commented 3 years ago

Thanks @vasturiano yep that makes sense (sorry I should have posted this over in the d3-force-3d repo). We'll definitely have a lot of nodes (many 1000's) in our sim, all with radial and manybody forces... so sounds like this might be something worth us investigating. Hey while I have you on the subject, when you render many nodes using Three.js, are you using instanced meshes? (or are we sending thousands of draw calls to the GPU?)

vasturiano commented 3 years ago

@philworthy you bring up a good question concerning instanced meshes. The lib is not currently using it because:

What you could possibly do is use InstancedMesh in the custom nodeThreeObject method. That would theoretically give you the optimization you're looking for, but I haven't actually tried.

philworthy commented 3 years ago

Thanks @vasturiano Hey would you be interested in consulting with us to create a react component based on this library, but with a few specific additional needs?

vasturiano commented 3 years ago

@philworthy appreciate you reaching out. I would like to help, but not sure I have enough bandwidth at the moment to focus on a specific project. In any case, have you seen react-force-graph?

philworthy commented 3 years ago

Ok, that's a shame :( but I totally understand. Yep, we're using react-force-graph. Just the developer is new to d3-force, and to three.js (and 3D in general in fact) so there's a big learning curve. Thanks anyway. Appreciate you taking to time to respond so quickly.

jesus4497 commented 1 year ago

What you could possibly do is use InstancedMesh in the custom nodeThreeObject method. That would theoretically give you the optimization you're looking for, but I haven't actually tried.

Hi @vasturiano ! Quick question, could you provide an example on how to implement the mentioned above? 🙏 I have been trying to do it but no luck