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

BVH never rebuilds #2199

Open
bruceflip opened this issue Nov 13, 2024 · 1 comment
Open

BVH never rebuilds #2199

bruceflip opened this issue Nov 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bruceflip
Copy link

  • three version: 0.161.0
  • @react-three/fiber version: 8.17.10
  • @react-three/drei version: 9.114.3
  • node version: 18.20.3
  • npm (or yarn) version: 10.7.0

Problem description:

Relevant code:

This PR was intended to avoid superfluous recomputation of the BVH. Unfortunately it prevents all recomputation of the BVH.

Not exactly the same, but has the same effect... the useBVH hook suffers from the same issue for a different reason. Here the dependency list uses a ref to the mesh object, which necessarily never changes as long as the mesh exists even if the underlying geometry changes.

Suggested solution:

Rather than using zero dependencies in the dependencies list here we should use a variable that changes if the underlying geometry changes.

Workaround:

For those looking for a workaround for the Bvh component, you can force the BVH to rebuild by using a key that changes if you know the geometry has changed eg `{children}

Also worth noting that ideally the underlying geometry wouldn't change, but in my specific use case it must 😅

@bruceflip bruceflip added the bug Something isn't working label Nov 13, 2024
@bruceflip
Copy link
Author

I believe this would also present a problem if you simply add an object to the children wrapped by the component, those new children would not have computeBoundsTree called on their geometry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant