Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to implement instancing for edges + nodes #492

Open
roomyrooms opened this issue Feb 15, 2024 · 0 comments
Open

Attempting to implement instancing for edges + nodes #492

roomyrooms opened this issue Feb 15, 2024 · 0 comments

Comments

@roomyrooms
Copy link

roomyrooms commented Feb 15, 2024

Heya! In my force graph, we routinely get up above 400k edges and 100k nodes. Obviously this ends up lagging quite a bit, but we've already stripped out most fancy graphics and etc.

By far and away the largest impact to performance is the extremely high number of draw calls, so I've been trying to implement instanced meshes for these.

Unfortunately, I think this might be impossible without branching out my own version of three-forcegraph. Is that the case?

Here's a very, very rudimentary example of what I've been trying:

const nodeMaterial = new THREE.MeshLambertMaterial({ color: '#FFFFFF', transparent: false });
const nodeGeometry = new THREE.SphereGeometry();
const nodeInstance = new THREE.InstancedMesh(nodeGeometry, nodeMaterial, 100000); // placeholder #
let nodeIndex = 0;
const nodeMatrix = new THREE.Matrix4();
const getNodeComponent = (node: any) => {
	nodeIndex++;
	return [problem]
};

The main issue is that instanced meshes make use of the .setMatrixAt function to actually function. It seems like this is embedded pretty deep in the stack of force graph repos, but would be an otherwise simple change. I'd appreciate any guidance and/or confirmation that this is/isn't possible. Thanks so much, I love the repo & the work you do across all these amazing resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant