import { useEffect, useRef } from "react";
import { Mesh } from "three";

export const useDisableRaycast = (disable: boolean) => {
  const ref = useRef<Mesh>(null);
  useEffect(() => {
    if (!ref.current) return;
    ref.current.raycast = disable ? () => null : Mesh.prototype.raycast;
  }, [disable]);
  return ref;
};
