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

instancedMesh onClick behavior #3289

Open
RobertAron opened this issue Jun 14, 2024 · 0 comments
Open

instancedMesh onClick behavior #3289

RobertAron opened this issue Jun 14, 2024 · 0 comments

Comments

@RobertAron
Copy link

I have some really weird issues with instancedMesh on click. I'm pretty sure this is a r3f issue because it involves onClick. It's also a degradation - it used to work on older versions.

SANDBOX:
https://codesandbox.io/p/sandbox/instanced-vertex-colors-forked-zyjxkd?file=%2Fsrc%2FApp.js%3A15%2C44

There are a few different conditions where the onClick prop stops functioning correctly.

  • If the position of all of the instances is initialized at the same place
  • If the meshRef.current.count is initialized at 0

In my sandbox there are a few useState(false) that have toggle buttons attached to them.

  • If you run the code as is - the onClick works
  • If you change either of the useState(false) to useState(true) then toggle that state using the buttons in the html, the onClick of the instancedMesh doesn't work.

Thanks so much for all your hard work <3

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