Function useFilterIntersectionPair

  • Registers a callback to filter intersection pairs.

    The callback determines if intersection computation should happen between two colliders (where at least one is a sensor).

    This will only be executed if at least one of the involved colliders contains the ActiveHooks.FILTER_INTERSECTION_PAIR flag in its active hooks.

    Example

    import { useFilterIntersectionPair } from '@react-three/rapier';

    useFilterIntersectionPair((collider1, collider2, body1, body2) => {
    // Block intersections for specific body pairs
    if (body1 === myBodyHandle && body2 === otherBodyHandle) {
    return false;
    }
    // Allow all other intersections
    return true;
    });

    Parameters

    • callback: ((collider1: number, collider2: number, body1: number, body2: number) => boolean)

      Function that returns:

      • true - Allow the intersection to be detected (trigger intersection events)
      • false - Block the intersection (no intersection events will fire)

      When multiple hooks are registered, the first hook that returns false blocks the intersection. If all hooks return true, the intersection is allowed.

        • (collider1: number, collider2: number, body1: number, body2: number): boolean
        • Parameters

          • collider1: number
          • collider2: number
          • body1: number
          • body2: number

          Returns boolean

    Returns void

Generated using TypeDoc