You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experiencing a significant performance drop when using R3F/drei Instances compared to vanilla JavaScript (UPDATE: and pure R3F instancedMesh) for rendering multiple instances of BoxGeometry.
Here's the situation:
When I generate multiple instances of BoxGeometry directly in JavaScript (UPDATE: or in pure R3F), I get a high frame rate and no performance issues.
However, when I implement the identical code as a component using R3F/drei, I observe a drastic FPS drop (as shown in the attached screenshot - high CPU usage!).
Can anyone suggest what might be causing this performance discrepancy?
Is this a normal situation?
Does R3F/drei typically cause such a significant performance overhead?
Any insights or suggestions would be greatly appreciated. If you need any additional information or code snippets, please let me know.
Thank you in advance for your help!
Good performance:
React.useEffect(() => {
const geometry = new THREE.BoxGeometry(1, 1, 0.1);
const material = new THREE.MeshBasicMaterial({ color: 'blue' });
const trees = new THREE.InstancedMesh(geometry, material, visibleSquares.length);
for (let i = 0; i < trees.count; i++) {
const [x, y, z] = visibleSquares[i];
trees.setMatrixAt(i, new THREE.Matrix4().makeRotationX(Math.PI / 2).setPosition(x + 0.5, 0.01, y + 0.5));
}
trees.instanceMatrix.needsUpdate = true;
scene.add(trees);
return () => {
scene.remove(trees);
trees.dispose();
geometry.dispose();
material.dispose();
};
}, [visibleSquares, scene]);
Same code in R3F/drei but very low FPS and high CPU usage:
Thank you for contributing! We’re marking this issue as stale as a gentle reminder to revisit it and give it the attention it needs to move forward.
Any activity, like adding an update or comment, will automatically remove the stale label so it stays on our radar.
Feel free to reach out on Discord if you need support or feedback from the community. This issue will close automatically soon if there’s no further activity. Thank you for understanding and for being part of the project!
I'm experiencing a significant performance drop when using R3F/drei Instances compared to vanilla JavaScript (UPDATE: and pure R3F instancedMesh) for rendering multiple instances of BoxGeometry.
Here's the situation:
When I generate multiple instances of BoxGeometry directly in JavaScript (UPDATE: or in pure R3F), I get a high frame rate and no performance issues.
However, when I implement the identical code as a component using R3F/drei, I observe a drastic FPS drop (as shown in the attached screenshot - high CPU usage!).
Can anyone suggest what might be causing this performance discrepancy?
Is this a normal situation?
Does R3F/drei typically cause such a significant performance overhead?
Any insights or suggestions would be greatly appreciated. If you need any additional information or code snippets, please let me know.
Thank you in advance for your help!
Good performance:
Same code in R3F/drei but very low FPS and high CPU usage:
UPDATE:
pure R3F version - performance ok:
The text was updated successfully, but these errors were encountered: