1. @threlte/rapier
  2. About Joints

@threlte/rapier

About Joints

One of the most appealing features of a physics engine is to simulate articulations. Articulations, aka. joints, allow the restriction of the motion of one body relative to another body. For example, one well-known joint is the ball-in-socket joint also known as the spherical joint: it allows one object to rotate freely with regard to the other but not to translate. This is typically used to simulate shoulders of a ragdoll.

To start off, get yourself comfortable with the basic concepts of Joints.

Currently Rapier supports these joints:

Why hooks?

Joints need two rigid bodies which the joint operates on. These two rigid bodies cannot always be infered from a component tree. See the following example:

<script>
	import { RigidBody, Collider } from '@threlte/rapier'
</script>

<!-- A -->
<RigidBody>
	<Collider shape="cuboid" args={[1, 1, 1]} />
</RigidBody>

<!-- B -->
<RigidBody>
	<Collider shape="cuboid" args={[1, 1, 1]} />
</RigidBody>

<!-- C -->
<RigidBody>
	<Collider shape="cuboid" args={[1, 1, 1]} />
</RigidBody>

There's no way to wrap <RigidBody> A and B in an imaginary component <Joint> as well as to wrap A and C in a separate component <Joint> to generate two joints which both act on <RigidBody> A.