Mesh onClick work only nearby the origin #1859
-
Good evening! I reintroduce this question as I did not receive any answer. For better understanding, I've made a codesandbox that represent the problem! If you create a component from the navbar, you can try for example the right click that function only near the origin, if you move the object it won't work anymore. Same thing for the click to select an object. Mesh events only work near the origin. This is the link: https://codesandbox.io/s/three-fiber-prova-fpsps Hoping someone can help me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've found the problem. I had been using the clone() function to create a copy of the mesh and then compute the bounding box with the applyMatrix4 on this copy, but it turned out that the clone() function does not copy also geometry and material. So I've created a new mesh instead of a clone and then I've passed to it a clone of the existing geometry and material. Now, compute the bounding box on a real copy of the geometry does not affect the original one and the onClick on the original mesh keeps working. |
Beta Was this translation helpful? Give feedback.
I've found the problem. I had been using the clone() function to create a copy of the mesh and then compute the bounding box with the applyMatrix4 on this copy, but it turned out that the clone() function does not copy also geometry and material. So I've created a new mesh instead of a clone and then I've passed to it a clone of the existing geometry and material. Now, compute the bounding box on a real copy of the geometry does not affect the original one and the onClick on the original mesh keeps working.