# Class Collider

A geometric entity that can be attached to a body so it can be affected by contacts and proximity queries.

- Defined in geometry/collider.d.ts:65

#####
Index

### Constructors

constructor

### Properties

_parent
_shape
colliderSet
ensureShapeIsCached
handle

### Accessors

shape

### Methods

activeCollisionTypes
activeEvents
activeHooks
castCollider
castRay
castRayAndGetNormal
castShape
clearShapeCache
collisionGroups
combineVoxelStates
contactCollider
contactForceEventThreshold
contactShape
contactSkin
containsPoint
density
finalizeDeserialization
friction
frictionCombineRule
halfExtents
halfHeight
heightfieldHeights
heightfieldScale
indices
intersectsRay
intersectsShape
isEnabled
isSensor
isValid
mass
parent
projectPoint
propagateVoxelChange
radius
restitution
restitutionCombineRule
rotation
rotationWrtParent
roundRadius
setActiveCollisionTypes
setActiveEvents
setActiveHooks
setCollisionGroups
setContactForceEventThreshold
setContactSkin
setDensity
setEnabled
setFriction
setFrictionCombineRule
setHalfExtents
setHalfHeight
setMass
setMassProperties
setRadius
setRestitution
setRestitutionCombineRule
setRotation
setRotationWrtParent
setRoundRadius
setSensor
setShape
setSolverGroups
setTranslation
setTranslationWrtParent
setVoxel
shapeType
solverGroups
translation
translationWrtParent
vertices
volume

## Constructors

### constructor

- new Collider(colliderSet, handle, parent, shape?): Collider

- #### Parameters

  - colliderSet: ColliderSet
  - handle: number
  - parent: RigidBody
  - `Optional` shape: Shape

  #### Returns Collider

  - Defined in geometry/collider.d.ts:70

## Properties

### `Private` _parent

_parent: any

- Defined in geometry/collider.d.ts:69

### `Private` _shape

_shape: any

- Defined in geometry/collider.d.ts:68

### `Private` colliderSet

colliderSet: any

- Defined in geometry/collider.d.ts:66

### `Private` ensureShapeIsCached

ensureShapeIsCached: any

- Defined in geometry/collider.d.ts:73

### `Readonly` handle

handle: number

- Defined in geometry/collider.d.ts:67

## Accessors

### shape

- get shape(): Shape

- The shape of this collider.

  #### Returns Shape

  - Defined in geometry/collider.d.ts:77

## Methods

### activeCollisionTypes

- activeCollisionTypes(): ActiveCollisionTypes

- Gets the collision types active for this collider.

  #### Returns ActiveCollisionTypes

  - Defined in geometry/collider.d.ts:236

### activeEvents

- activeEvents(): ActiveEvents

- The events active for this collider.

  #### Returns ActiveEvents

  - Defined in geometry/collider.d.ts:224

### activeHooks

- activeHooks(): ActiveHooks

- Get the physics hooks active for this collider.

  #### Returns ActiveHooks

  - Defined in geometry/collider.d.ts:212

### castCollider

- castCollider(collider1Vel, collider2, collider2Vel, targetDistance, maxToi, stopAtPenetration): ColliderShapeCastHit

- #### Parameters

  - collider1Vel: Vector
  - collider2: Collider
  - collider2Vel: Vector
  - targetDistance: number
  - maxToi: number
  - stopAtPenetration: boolean

  #### Returns ColliderShapeCastHit

  - Defined in geometry/collider.d.ts:482

### castRay

- castRay(ray, maxToi, solid): number

- Find the closest intersection between a ray and this collider.

  This also computes the normal at the hit point.

  #### Parameters

  - ray: Ray

    The ray to cast.

  - maxToi: number

    The maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to `ray.dir.norm() * maxToi`.

  - solid: boolean

    If `false` then the ray will attempt to hit the boundary of a shape, even if its origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain, whereas `false` implies that all shapes are hollow for this ray-cast.

  #### Returns number

  The time-of-impact between this collider and the ray, or `-1` if there is no intersection.

  - Defined in geometry/collider.d.ts:514

### castRayAndGetNormal

- castRayAndGetNormal(ray, maxToi, solid): RayIntersection

- Find the closest intersection between a ray and this collider.

  This also computes the normal at the hit point.

  #### Parameters

  - ray: Ray

    The ray to cast.

  - maxToi: number

    The maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to `ray.dir.norm() * maxToi`.

  - solid: boolean

    If `false` then the ray will attempt to hit the boundary of a shape, even if its origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain, whereas `false` implies that all shapes are hollow for this ray-cast.

  #### Returns RayIntersection

  - Defined in geometry/collider.d.ts:526

### castShape

- castShape(collider1Vel, shape2, shape2Pos, shape2Rot, shape2Vel, targetDistance, maxToi, stopAtPenetration): ShapeCastHit

- #### Parameters

  - collider1Vel: Vector
  - shape2: Shape
  - shape2Pos: Vector
  - shape2Rot: number
  - shape2Vel: Vector
  - targetDistance: number
  - maxToi: number
  - stopAtPenetration: boolean

  #### Returns ShapeCastHit

  - Defined in geometry/collider.d.ts:481

### clearShapeCache

- clearShapeCache(): void

- Set the internal cached JS shape to null.

  This can be useful if you want to free some memory (assuming you are not holding any other references to the shape object), or in order to force the recalculation of the JS shape (the next time the `shape` getter is accessed) from the WASM source of truth.

  #### Returns void

  - Defined in geometry/collider.d.ts:86

### collisionGroups

- collisionGroups(): number

- The collision groups of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:451

### combineVoxelStates

- combineVoxelStates(voxels2, shift_x, shift_y): void

- If this and `voxels2` are voxel colliders, this will ensure that a moving object transitioning across the boundaries of these colliders won’t suffer from the "internal edges" artifact.

  If the voxels in `voxels2` live in a different coordinate space from `this`, then the `shift_*` argument indicate the distance, in voxel units, between the origin of `this` to the origin of `voxels2`.

  This method is intended to be called once between all pairs of voxels colliders with intersecting domains or shared boundaries.

  If either voxels collider is then modified with `setVoxel`, the `propagateVoxelChange` method must be called to maintain the coupling between the voxels shapes after the modification.

  #### Parameters

  - voxels2: Collider
  - shift_x: number
  - shift_y: number

  #### Returns void

  - Defined in geometry/collider.d.ts:402

### contactCollider

- contactCollider(collider2, prediction): ShapeContact

- Computes one pair of contact points between the collider and the given collider.

  #### Parameters

  - collider2: Collider

    The second collider.

  - prediction: number

    The prediction value, if the shapes are separated by a distance greater than this value, test will fail.

  #### Returns ShapeContact

  `null` if the shapes are separated by a distance greater than prediction, otherwise contact details. The result is given in world-space.

  - Defined in geometry/collider.d.ts:501

### contactForceEventThreshold

- contactForceEventThreshold(): number

- The total force magnitude beyond which a contact force event can be emitted.

  #### Returns number

  - Defined in geometry/collider.d.ts:246

### contactShape

- contactShape(shape2, shape2Pos, shape2Rot, prediction): ShapeContact

- Computes one pair of contact points between the shape owned by this collider and the given shape.

  #### Parameters

  - shape2: Shape

    The second shape.

  - shape2Pos: Vector

    The initial position of the second shape.

  - shape2Rot: number

    The rotation of the second shape.

  - prediction: number

    The prediction value, if the shapes are separated by a distance greater than this value, test will fail.

  #### Returns ShapeContact

  `null` if the shapes are separated by a distance greater than prediction, otherwise contact details. The result is given in world-space.

  - Defined in geometry/collider.d.ts:493

### contactSkin

- contactSkin(): number

- Sets the contact skin for this collider.

  See the documentation of `ColliderDesc.setContactSkin` for additional details.

  #### Returns number

  - Defined in geometry/collider.d.ts:200

### containsPoint

- containsPoint(point): boolean

- Tests if this collider contains a point.

  #### Parameters

  - point: Vector

    The point to test.

  #### Returns boolean

  - Defined in geometry/collider.d.ts:461

### density

- density(): number

- The density of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:439

### finalizeDeserialization

- finalizeDeserialization(bodies): void
- `Internal`

  #### Parameters

  - bodies: RigidBodySet

  #### Returns void

  - Defined in geometry/collider.d.ts:72

### friction

- friction(): number

- The friction coefficient of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:431

### frictionCombineRule

- frictionCombineRule(): CoefficientCombineRule

- Gets the rule used to combine the friction coefficients of two colliders colliders involved in a contact.

  #### Returns CoefficientCombineRule

  - Defined in geometry/collider.d.ts:156

### halfExtents

- halfExtents(): Vector

- The half-extents of this collider if it is a cuboid shape.

  #### Returns Vector

  - Defined in geometry/collider.d.ts:318

### halfHeight

- halfHeight(): number

- The half height of this collider if it is a cylinder, capsule, or cone shape.

  #### Returns number

  - Defined in geometry/collider.d.ts:348

### heightfieldHeights

- heightfieldHeights(): Float32Array

- If this collider has a heightfield shape, this returns the heights buffer of the heightfield. In 3D, the returned height matrix is provided in column-major order.

  #### Returns Float32Array

  - Defined in geometry/collider.d.ts:418

### heightfieldScale

- heightfieldScale(): Vector

- If this collider has a heightfield shape, this returns the scale applied to it.

  #### Returns Vector

  - Defined in geometry/collider.d.ts:423

### indices

- indices(): Uint32Array

- If this collider has a triangle mesh, polyline, or convex polyhedron shape, this returns the index buffer of said shape.

  #### Returns Uint32Array

  - Defined in geometry/collider.d.ts:412

### intersectsRay

- intersectsRay(ray, maxToi): boolean

- Tests if this collider intersects the given ray.

  #### Parameters

  - ray: Ray

    The ray to cast.

  - maxToi: number

    The maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to `ray.dir.norm() * maxToi`.

  #### Returns boolean

  - Defined in geometry/collider.d.ts:480

### intersectsShape

- intersectsShape(shape2, shapePos2, shapeRot2): boolean

- #### Parameters

  - shape2: Shape
  - shapePos2: Vector
  - shapeRot2: number

  #### Returns boolean

  - Defined in geometry/collider.d.ts:483

### isEnabled

- isEnabled(): boolean

- Is this collider enabled?

  #### Returns boolean

  - Defined in geometry/collider.d.ts:135

### isSensor

- isSensor(): boolean

- Is this collider a sensor?

  #### Returns boolean

  - Defined in geometry/collider.d.ts:115

### isValid

- isValid(): boolean

- Checks if this collider is still valid (i.e. that it has not been deleted from the collider set yet).

  #### Returns boolean

  - Defined in geometry/collider.d.ts:91

### mass

- mass(): number

- The mass of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:443

### parent

- parent(): RigidBody

- The rigid-body this collider is attached to.

  #### Returns RigidBody

  - Defined in geometry/collider.d.ts:427

### projectPoint

- projectPoint(point, solid): PointProjection

- Find the projection of a point on this collider.

  #### Parameters

  - point: Vector

    The point to project.

  - solid: boolean

    If this is set to `true` then the collider shapes are considered to be plain (if the point is located inside of a plain shape, its projection is the point itself). If it is set to `false` the collider shapes are considered to be hollow (if the point is located inside of an hollow shape, it is projected on the shape's boundary).

  #### Returns PointProjection

  - Defined in geometry/collider.d.ts:472

### propagateVoxelChange

- propagateVoxelChange(voxels2, ix, iy, shift_x, shift_y): void

- If this and `voxels2` are voxel colliders, and a voxel from `this` was modified with `setVoxel`, this will ensure that a moving object transitioning across the boundaries of these colliders won’t suffer from the "internal edges" artifact.

  The indices `ix, iy, iz` indicate the integer coordinates of the voxel in the local coordinate frame of `this`.

  If the voxels in `voxels2` live in a different coordinate space from `this`, then the `shift_*` argument indicate the distance, in voxel units, between the origin of `this` to the origin of `voxels2`.

  This method is intended to be called between `this` and all the other voxels colliders with a domain intersecting `this` or sharing a domain boundary. This is an incremental maintenance of the effect of `combineVoxelStates`.

  #### Parameters

  - voxels2: Collider
  - ix: number
  - iy: number
  - shift_x: number
  - shift_y: number

  #### Returns void

  - Defined in geometry/collider.d.ts:385

### radius

- radius(): number

- The radius of this collider if it is a ball, cylinder, capsule, or cone shape.

  #### Returns number

  - Defined in geometry/collider.d.ts:328

### restitution

- restitution(): number

- The restitution coefficient of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:435

### restitutionCombineRule

- restitutionCombineRule(): CoefficientCombineRule

- Gets the rule used to combine the restitution coefficients of two colliders colliders involved in a contact.

  #### Returns CoefficientCombineRule

  - Defined in geometry/collider.d.ts:168

### rotation

- rotation(): number

- The world-space orientation of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:105

### rotationWrtParent

- rotationWrtParent(): number

- The orientation of this collider relative to its parent rigid-body.

  Returns `null` if the collider doesn’t have a parent rigid-body.

  #### Returns number

  - Defined in geometry/collider.d.ts:111

### roundRadius

- roundRadius(): number

- The radius of the round edges of this collider if it is a round cylinder.

  #### Returns number

  - Defined in geometry/collider.d.ts:338

### setActiveCollisionTypes

- setActiveCollisionTypes(activeCollisionTypes): void

- Set the collision types active for this collider.

  #### Parameters

  - activeCollisionTypes: ActiveCollisionTypes

    The hooks active for contact/intersection pairs involving this collider.

  #### Returns void

  - Defined in geometry/collider.d.ts:252

### setActiveEvents

- setActiveEvents(activeEvents): void

- Set the events active for this collider.

  Use this to enable contact and/or intersection event reporting for this collider.

  #### Parameters

  - activeEvents: ActiveEvents

    The events active for contact/intersection pairs involving this collider.

  #### Returns void

  - Defined in geometry/collider.d.ts:232

### setActiveHooks

- setActiveHooks(activeHooks): void

- Set the physics hooks active for this collider.

  Use this to enable custom filtering rules for contact/intersecstion pairs involving this collider.

  #### Parameters

  - activeHooks: ActiveHooks

    The hooks active for contact/intersection pairs involving this collider.

  #### Returns void

  - Defined in geometry/collider.d.ts:220

### setCollisionGroups

- setCollisionGroups(groups): void

- Sets the collision groups used by this collider.

  Two colliders will interact iff. their collision groups are compatible. See the documentation of `InteractionGroups` for details on teh used bit pattern.

  #### Parameters

  - groups: number

    The collision groups used for the collider being built.

  #### Returns void

  - Defined in geometry/collider.d.ts:184

### setContactForceEventThreshold

- setContactForceEventThreshold(threshold): void

- Sets the total force magnitude beyond which a contact force event can be emitted.

  #### Parameters

  - threshold: number

    The new force threshold.

  #### Returns void

  - Defined in geometry/collider.d.ts:242

### setContactSkin

- setContactSkin(thickness): void

- Sets the contact skin for this collider.

  See the documentation of `ColliderDesc.setContactSkin` for additional details.

  #### Parameters

  - thickness: number

    The contact skin thickness.

  #### Returns void

  - Defined in geometry/collider.d.ts:208

### setDensity

- setDensity(density): void

- Sets the uniform density of this collider.

  This will override any previous mass-properties set by `this.setDensity`, `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`, `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.

  The mass and angular inertia of this collider will be computed automatically based on its shape.

  #### Parameters

  - density: number

  #### Returns void

  - Defined in geometry/collider.d.ts:263

### setEnabled

- setEnabled(enabled): void

- Sets whether this collider is enabled or not.

  #### Parameters

  - enabled: boolean

    Set to `false` to disable this collider (its parent rigid-body won’t be disabled automatically by this).

  #### Returns void

  - Defined in geometry/collider.d.ts:131

### setFriction

- setFriction(friction): void

- Sets the friction coefficient of the collider to be created.

  #### Parameters

  - friction: number

    The friction coefficient. Must be greater or equal to 0. This is generally smaller than 1. The higher the coefficient, the stronger friction forces will be for contacts with the collider being built.

  #### Returns void

  - Defined in geometry/collider.d.ts:151

### setFrictionCombineRule

- setFrictionCombineRule(rule): void

- Sets the rule used to combine the friction coefficients of two colliders colliders involved in a contact.

  #### Parameters

  - rule: CoefficientCombineRule

    − The combine rule to apply.

  #### Returns void

  - Defined in geometry/collider.d.ts:163

### setHalfExtents

- setHalfExtents(newHalfExtents): void

- Sets the half-extents of this collider if it is a cuboid shape.

  #### Parameters

  - newHalfExtents: Vector

    desired half extents.

  #### Returns void

  - Defined in geometry/collider.d.ts:324

### setHalfHeight

- setHalfHeight(newHalfheight): void

- Sets the half height of this collider if it is a cylinder, capsule, or cone shape.

  #### Parameters

  - newHalfheight: number

    desired half height.

  #### Returns void

  - Defined in geometry/collider.d.ts:354

### setMass

- setMass(mass): void

- Sets the mass of this collider.

  This will override any previous mass-properties set by `this.setDensity`, `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`, `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.

  The angular inertia of this collider will be computed automatically based on its shape and this mass value.

  #### Parameters

  - mass: number

  #### Returns void

  - Defined in geometry/collider.d.ts:274

### setMassProperties

- setMassProperties(mass, centerOfMass, principalAngularInertia): void

- Sets the mass of this collider.

  This will override any previous mass-properties set by `this.setDensity`, `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`, `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.

  #### Parameters

  - mass: number
  - centerOfMass: Vector
  - principalAngularInertia: number

  #### Returns void

  - Defined in geometry/collider.d.ts:282

### setRadius

- setRadius(newRadius): void

- Sets the radius of this collider if it is a ball, cylinder, capsule, or cone shape.

  #### Parameters

  - newRadius: number

    desired radius.

  #### Returns void

  - Defined in geometry/collider.d.ts:334

### setRestitution

- setRestitution(restitution): void

- Sets the restitution coefficient of the collider to be created.

  #### Parameters

  - restitution: number

    The restitution coefficient in `[0, 1]`. A value of 0 (the default) means no bouncing behavior while 1 means perfect bouncing (though energy may still be lost due to numerical errors of the constraints solver).

  #### Returns void

  - Defined in geometry/collider.d.ts:143

### setRestitutionCombineRule

- setRestitutionCombineRule(rule): void

- Sets the rule used to combine the restitution coefficients of two colliders colliders involved in a contact.

  #### Parameters

  - rule: CoefficientCombineRule

    − The combine rule to apply.

  #### Returns void

  - Defined in geometry/collider.d.ts:175

### setRotation

- setRotation(angle): void

- Sets the rotation angle of this collider.

  #### Parameters

  - angle: number

    The rotation angle, in radians.

  #### Returns void

  - Defined in geometry/collider.d.ts:302

### setRotationWrtParent

- setRotationWrtParent(angle): void

- Sets the rotation angle of this collider relative to its parent rigid-body.

  Does nothing if this collider isn't attached to a rigid-body.

  #### Parameters

  - angle: number

    The rotation angle, in radians.

  #### Returns void

  - Defined in geometry/collider.d.ts:310

### setRoundRadius

- setRoundRadius(newBorderRadius): void

- Sets the radius of the round edges of this collider if it has round edges.

  #### Parameters

  - newBorderRadius: number

    desired round edge radius.

  #### Returns void

  - Defined in geometry/collider.d.ts:344

### setSensor

- setSensor(isSensor): void

- Sets whether this collider is a sensor.

  #### Parameters

  - isSensor: boolean

    If `true`, the collider will be a sensor.

  #### Returns void

  - Defined in geometry/collider.d.ts:120

### setShape

- setShape(shape): void

- Sets the new shape of the collider.

  #### Parameters

  - shape: Shape

    The collider’s new shape.

  #### Returns void

  - Defined in geometry/collider.d.ts:125

### setSolverGroups

- setSolverGroups(groups): void

- Sets the solver groups used by this collider.

  Forces between two colliders in contact will be computed iff their solver groups are compatible. See the documentation of `InteractionGroups` for details on the used bit pattern.

  #### Parameters

  - groups: number

    The solver groups used for the collider being built.

  #### Returns void

  - Defined in geometry/collider.d.ts:194

### setTranslation

- setTranslation(tra): void

- Sets the translation of this collider.

  #### Parameters

  - tra: Vector

    The world-space position of the collider.

  #### Returns void

  - Defined in geometry/collider.d.ts:288

### setTranslationWrtParent

- setTranslationWrtParent(tra): void

- Sets the translation of this collider relative to its parent rigid-body.

  Does nothing if this collider isn't attached to a rigid-body.

  #### Parameters

  - tra: Vector

    The new translation of the collider relative to its parent.

  #### Returns void

  - Defined in geometry/collider.d.ts:296

### setVoxel

- setVoxel(ix, iy, filled): void

- If this collider has a Voxels shape, this will mark the voxel at the given grid coordinates as filled or empty (depending on the `filled` argument).

  Each input value is assumed to be an integer.

  The operation is O(1), unless the provided coordinates are out of the bounds of the currently allocated internal grid in which case the grid will be grown automatically.

  #### Parameters

  - ix: number
  - iy: number
  - filled: boolean

  #### Returns void

  - Defined in geometry/collider.d.ts:366

### shapeType

- shapeType(): ShapeType

- The type of the shape of this collider.

  #### Returns ShapeType

  - Defined in geometry/collider.d.ts:314

### solverGroups

- solverGroups(): number

- The solver groups of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:455

### translation

- translation(): Vector

- The world-space translation of this collider.

  #### Returns Vector

  - Defined in geometry/collider.d.ts:95

### translationWrtParent

- translationWrtParent(): Vector

- The translation of this collider relative to its parent rigid-body.

  Returns `null` if the collider doesn’t have a parent rigid-body.

  #### Returns Vector

  - Defined in geometry/collider.d.ts:101

### vertices

- vertices(): Float32Array

- If this collider has a triangle mesh, polyline, convex polygon, or convex polyhedron shape, this returns the vertex buffer of said shape.

  #### Returns Float32Array

  - Defined in geometry/collider.d.ts:407

### volume

- volume(): number

- The volume of this collider.

  #### Returns number

  - Defined in geometry/collider.d.ts:447