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

Possibility to remove in-built link/node Three.js objects from scene? #314

Open Kert opened 4 years ago

Kert commented 4 years ago

In my project I hid 3d-force-graph links and implemented my own using buffered objects because of performance problems. That includes updating positions through onEngineTicks e.t.c. But I can't seem to remove in-built link three.js objects from the scene no matter what method I use Is there any? Can this be implemented by for e.g. passing -1 to linkThreeObject?

vasturiano commented 4 years ago

@kert thanks for reaching out.

If you set nodeThreeObjectExtend and linkThreeObjectExtend to false (as is by default), the default node/link objects will not be included in the scene, and the lib will rely purely on your implementation of the objects in the nodeThreeObject, linkThreeObject and linkPositionUpdate methods.

Kert commented 4 years ago

@vasturiano The problem here as I said is that the implementation of these objects in my case must be made outside of nodeThreeObject/linkThreeObject because buffered geometry only has one "object", the rest differ by attributes, I can't use these methods in this case because nodeThreeObject/linkThreeObject return a separate object per node/link.

vasturiano commented 4 years ago

@kert if I understand correctly you wish to have a shared single buffer geometry in all of your node/link objects? If that's the case, you can still do that using the nodeThreeObject method. Just create a new Mesh object which references the shared geometry. You can do the same for the mesh material too, to save rendering performance.