@threlte/rapier

<CollisionGroups>

The most efficient way of preventing some pairs of colliders from interacting with each other is to use a <CollisionGroups> component.

Each collider that is a child (direct or indirect) of the component <CollisionGroups> is applied a memberships and filters attribute. The shorthand groups sets both properties at once.

For general usage instructions, see the relevant documentation here.

Example

  • Collider A is affected by Collider B and not by Collider C
  • Collider B is affected by Collider A and Collider C
  • Collider C is affected by Collider B and not by Collider A
<!-- Collider A -->
<CollisionGroups
  memberships={[1]}
  filter={[2]}
>
  <RigidBody>
    <AutoColliders shape={'cuboid'}>
      <Mesh
        castShadow
        {geometry}
        {material}
      />
    </AutoColliders>
  </RigidBody>
</CollisionGroups>

<!-- Collider B -->
<CollisionGroups
  memberships={[2]}
  filter={[1, 3]}
>
  <RigidBody>
    <AutoColliders shape={'cuboid'}>
      <Mesh
        castShadow
        {geometry}
        {material}
      />
    </AutoColliders>
  </RigidBody>
</CollisionGroups>

<!-- Collider C -->
<CollisionGroups
  memberships={[3]}
  filter={[2]}
>
  <RigidBody>
    <AutoColliders shape={'cuboid'}>
      <Mesh
        castShadow
        {geometry}
        {material}
      />
    </AutoColliders>
  </RigidBody>
</CollisionGroups>

Component Signature

Provide either the shorthand property groups to set both memberships and filter to the same value or set them up individually.

Props

name
type
required

filter
CollisionGroupsBitMask
yes

groups
CollisionGroupsBitMask
yes

memberships
CollisionGroupsBitMask
yes