Hello,
I have a problem with the onClick event. When someone spams it, there is some fps drop.
I feel like this event is a bit overkill as I don’t need to know where and on which mesh the player has clicked, everything is managed in a function that is in the callback. So I just need to know if the click has been clicked, nothing more (the user sees the environment in first-person view).
What is the best and most performant way to do that?
function doThings(props) {
// Some codes
const onClick = useCallback((e) => {
const Pos = getIntersections()
hitObject(Pos)
}
})
for (const cellId in data) {
if (updatedCells.includes(cellId)) {
const cellData = data[cellId]
cellsMeshs[cellId] = (
<mesh key={cellId} position={cellData.meshPos} onClick={onClick}>
// Code continues...