Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1013 Bytes

use-collision-groups.mdx

File metadata and controls

37 lines (29 loc) · 1013 Bytes
order category name sourcePath type
9
@threlte/rapier
useCollisionGroups
packages/rapier/src/lib/hooks/useCollisionGroups.ts
hook

This hook can be used in conjunction with the component <CollisionGroups>. It uses the collision groups provided by a parent <CollisionGroups> component and lets you easily apply them to colliders.

<script>
	import { useRapier, useCollisionGroups } from '@threlte/rapier'

	const { world } = useRapier()
	const { registerColliders, removeColliders } = useCollisionGroups()

	const collider = world.createCollider(…)

	// collider will be assigned the collision groups
	// provided by a parent `<CollisionGroups>` component.
	registerColliders([collider])

	onDestroy(() => {
		removeColliders([collider])
	})
</script>

Types

const {
  registerColliders, // (colliders: RAPIER.Collider[]) => void
  removeColliders // (colliders: RAPIER.Collider[]) => void
} = useCollisionGroups()