I know about event.stopPropagation(), however I would Like to know is there a way to turn off pointer events for a mesh so that the event wont even be triggered? Currently I have multiple Meshes in the same spot, with 1 only being visible at a time. Each of the meshes have onPointerMove handlers. However, even if the visibility is off the hidden mesh responds to the onPointerMove event. Also I notice that there is a slight performance issue when I have the onPointerMove on multiple meshes hence another reason to be able to turn pointer events off. Here is my site https://gregarious-sprite-af3740.netlify.app/, if you hove over the chair you will see 2 different logs in the console log fire.
Something like this should do what you’re aiming for:
const listeners: Record<string, Function> = {};
const meshRef = useRef<THREE.Mesh | null>(null);
if (meshRef.current && meshRef.current.visible) {
listeners.onPointerMove = (event: ThreeEvent<PointerEvent>) => { /* ... */ };
}
return (
<mesh {...listeners} ref={meshRef}>
{/* ... */}
</mesh>
);
Fire thanks very much!