Bounding Box calculation disable onClick events #1823
-
Hi all!
Now at the beginning the onClick events fires as expected, but moving the object around I've a useEffect that compute the bounding box of the mesh geometry and update it in my app's store:
This triggers a rerender after which the onClick event won't work anymore. I've also noticed that tags Hope someone will help me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
the problem with centring geometry like that is that it stacks up. i would avoid mutating geometry like that. perhaps in this case it creates geometry that the raycaster isn't able to pierce any longer. you can center an object without messing with its geometry. see dreis center or bounds components for instance. as for geometry, these are generic threejs objects, threejs docs list all the props. you don't set a function prop, you call it. for instance in a useLayoutEffect. in react setting a function prop just overwrites a function. |
Beta Was this translation helpful? Give feedback.
the problem with centring geometry like that is that it stacks up. i would avoid mutating geometry like that. perhaps in this case it creates geometry that the raycaster isn't able to pierce any longer. you can center an object without messing with its geometry. see dreis center or bounds components for instance.
as for geometry, these are generic threejs objects, threejs docs list all the props. you don't set a function prop, you call it. for instance in a useLayoutEffect. in react setting a function prop just overwrites a function.
<...Geometry computeBoundingBox={...} />
makes little sense, you just destroy that function. instead do: geometry.current.computeBoundingBox() whilegeometry
…