@threlte/rapier
AutoColliders
The <AutoColliders>
component generates colliders based on its children. Currently these shapes are available:
cuboid
– uses each child mesh bounding box and generates a cuboid colliderball
– uses each child mesh bounding box and generates a ball collidercapsule
– uses each child mesh bounding box and generates a capsule collidertrimesh
– uses each child mesh geometry and generates a polygonal collider which resembles the geometryconvexHull
– uses each child mesh geometry and generates a collider which resembles a convex hull around the geometry
The resulting colliders can be transformed (i.e. positioned, rotated and scaled) as well as given regular collider properties such as mass
or centerOfMass
.
Model: Battle Damaged Sci-fi Helmet by theblueturtle_
Transform Properties
If a <AutoColliders>
component is not a child of a <RigidBody>
component, the transform properties are reactive.
Properties
AutoCollidersDesc
, CoefficientCombineRule
are types imported from '@dimforge/rapier3d-compat'
.
If you don't provide any of the properties density
, mass
or massProperties
, Rapier will figure that out for you.
You can provide either a property density
, mass
or massProperties
.
// optional
shape:
| 'cuboid'
| 'ball'
| 'capsule'
| 'trimesh'
| 'convexHull' = 'convexHull'
position: Position | undefined = undefined
scale: Scale | undefined = undefined
rotation: Rotation | undefined = undefined
lookAt: LookAt | undefined = undefined
density: number | undefined = undefined
mass: number | undefined = undefined
massProperties:
| {
mass: number
centerOfMass: Position
principalAngularInertia: Position
angularInertiaLocalFrame: Rotation
} | undefined = undefined
restitution: number | undefined = undefined
restitutionCombineRule: CoefficientCombineRule | undefined = undefined
friction: number | undefined = undefined
frictionCombineRule: CoefficientCombineRule | undefined = undefined
sensor: boolean | undefined = undefined
contactForceEventThreshold: number | undefined = undefined
Bindings
AutoColliders
is a type imported from '@dimforge/rapier3d-compat'
.
colliders: Colliders[]
Events
RigidBody
, AutoColliders
and TempContactManifold
are types imported from '@dimforge/rapier3d-compat'
collisionenter: CustomEvent<{
targetAutoColliders: AutoColliders
targetRigidBody: RigidBody | null
manifold: TempContactManifold
flipped: boolean
}>
collisionexit: CustomEvent<{
targetAutoColliders: AutoColliders
targetRigidBody: RigidBody | null
}>
sensorenter: CustomEvent<{
targetAutoColliders: AutoColliders
targetRigidBody: RigidBody | null
}>
sensorexit: CustomEvent<{
targetAutoColliders: AutoColliders
targetRigidBody: RigidBody | null
}>
contact: CustomEvent<{
targetCollider: Collider
targetRigidBody: RigidBody | null
manifold: TempContactManifold
flipped: boolean
maxForceDirection: Vector
maxForceMagnitude: number
totalForce: Vector
totalForceMagnitude: number
}>