Open RobertAron opened 5 months ago
I had to come back around to this. It seems like the core issue has to do with the bounding sphere. It's not being updated properly. I'm not exactly sure I think maybe this should be called whenever needs update is true?
instancedMeshRef.current.instanceMatrix.needsUpdate = true;
instancedMeshRef.current.computeBoundingSphere();
The above might be slow though.
For now I'm going to fix it in my application by calling the update on an interval...but that's a pretty hacky fix. I'd appreciate a fix/insights if possible! I also wouldn't mind contributing but I think this is a pretty unfriendly first PR type problem 😓
Better sandbox. Look for the commented out code which will fix the problem by calling the compute.
I have some really weird issues with
instancedMesh
on click. I'm pretty sure this is a r3f issue because it involvesonClick
. 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.meshRef.current.count
is initialized at 0In my sandbox there are a few
useState(false)
that have toggle buttons attached to them.onClick
worksuseState(false)
touseState(true)
then toggle that state using the buttons in the html, theonClick
of the instancedMesh doesn't work.Thanks so much for all your hard work <3