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

Constructors

Properties

_parent: any
_shape: any
colliderSet: any
ensureShapeIsCached: any
handle: number

Accessors

  • get shape(): Shape
  • The shape of this collider.

    Returns Shape

Methods

  • The events active for this collider.

    Returns ActiveEvents

  • Get the physics hooks active for this collider.

    Returns ActiveHooks

  • Parameters

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

    Returns ColliderShapeCastHit

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

  • 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

  • Parameters

    Returns ShapeCastHit

  • 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

  • The collision groups of this collider.

    Returns number

  • 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
    • shift_z: number

    Returns void

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

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

    Returns number

  • 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: Rotation

      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.

  • Sets the contact skin for this collider.

    See the documentation of ColliderDesc.setContactSkin for additional details.

    Returns number

  • Tests if this collider contains a point.

    Parameters

    • point: Vector

      The point to test.

    Returns boolean

  • The density of this collider.

    Returns number

  • Internal

    Parameters

    Returns void

  • The friction coefficient of this collider.

    Returns number

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

    Returns Vector

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

    Returns number

  • 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

  • If this collider has a heightfield shape, this returns the number of columns of its height matrix.

    Returns number

  • If this collider has a heightfield shape, this returns the number of rows of its height matrix.

    Returns number

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

    Returns Vector

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

    Returns Uint32Array

  • 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

  • Parameters

    Returns boolean

  • Is this collider enabled?

    Returns boolean

  • Is this collider a sensor?

    Returns boolean

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

    Returns boolean

  • The mass of this collider.

    Returns number

  • The rigid-body this collider is attached to.

    Returns RigidBody

  • 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

  • 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
    • iz: number
    • shift_x: number
    • shift_y: number
    • shift_z: number

    Returns void

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

    Returns number

  • The restitution coefficient of this collider.

    Returns number

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

    Returns CoefficientCombineRule

  • The world-space orientation of this collider.

    Returns Rotation

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

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

    Returns Rotation

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

    Returns number

  • Set the collision types active for this collider.

    Parameters

    • activeCollisionTypes: ActiveCollisionTypes

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

    Returns 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

  • 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

  • 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

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

    Parameters

    • threshold: number

      The new force threshold.

    Returns 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

  • 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

  • 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

  • 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

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

    Parameters

    Returns void

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

    Parameters

    • newHalfExtents: Vector

      desired half extents.

    Returns 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

  • 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

  • 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

    Returns void

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

    Parameters

    • newRadius: number

      desired radius.

    Returns 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

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

    Parameters

    Returns void

  • Sets the rotation quaternion of this collider.

    This does nothing if a zero quaternion is provided.

    Parameters

    Returns void

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

    This does nothing if a zero quaternion is provided or if this collider isn't attached to a rigid-body.

    Parameters

    Returns 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

  • Sets whether this collider is a sensor.

    Parameters

    • isSensor: boolean

      If true, the collider will be a sensor.

    Returns void

  • Sets the new shape of the collider.

    Parameters

    • shape: Shape

      The collider’s new shape.

    Returns 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

  • Sets the translation of this collider.

    Parameters

    • tra: Vector

      The world-space position of the collider.

    Returns 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

  • 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
    • iz: number
    • filled: boolean

    Returns void

  • The type of the shape of this collider.

    Returns ShapeType

  • The solver groups of this collider.

    Returns number

  • The world-space translation of this collider.

    Returns 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

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

    Returns Float32Array

  • The volume of this collider.

    Returns number