Visit the Documentation of the upcoming Threlte 6.
  1. @threlte/rapier
  2. CollisionGroups

@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.

Import

Source

Github View Source Code

Package

NPM View Package

Related Docs


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>

Properties

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

// required

// Provide either …
groups: CollisionGroupsBitMask

// … or …
filter: CollisionGroupsBitMask
memberships: CollisionGroupsBitMask