# Class BroadPhase

The broad-phase used for coarse collision-detection.

To avoid leaking WASM resources, this MUST be freed manually with `broadPhase.free()` once you are done using it.

- Defined in geometry/broad_phase.d.ts:19

#####
Index

### Constructors

constructor

### Properties

raw

### Methods

castRay
castRayAndGetNormal
castShape
collidersWithAabbIntersectingAabb
free
intersectionWithShape
intersectionsWithPoint
intersectionsWithRay
intersectionsWithShape
projectPoint
projectPointAndGetFeature

## Constructors

### constructor

- new BroadPhase(raw?): BroadPhase

- #### Parameters

  - `Optional` raw: RawBroadPhase

  #### Returns BroadPhase

  - Defined in geometry/broad_phase.d.ts:25

## Properties

### raw

raw: RawBroadPhase

- Defined in geometry/broad_phase.d.ts:20

## Methods

### castRay

- castRay(narrowPhase, bodies, colliders, ray, maxToi, solid, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): RayColliderHit

- Find the closest intersection between a ray and a set of collider.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

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

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns RayColliderHit

  - Defined in geometry/broad_phase.d.ts:39

### castRayAndGetNormal

- castRayAndGetNormal(narrowPhase, bodies, colliders, ray, maxToi, solid, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): RayColliderIntersection

- Find the closest intersection between a ray and a set of collider.

  This also computes the normal at the hit point.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

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

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns RayColliderIntersection

  - Defined in geometry/broad_phase.d.ts:53

### castShape

- castShape(narrowPhase, bodies, colliders, shapePos, shapeRot, shapeVel, shape, targetDistance, maxToi, stopAtPenetration, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): ColliderShapeCastHit

- Casts a shape at a constant linear velocity and retrieve the first collider it hits. This is similar to ray-casting except that we are casting a whole shape instead of just a point (the ray origin).

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

  - shapePos: Vector

    The initial position of the shape to cast.

  - shapeRot: number

    The initial rotation of the shape to cast.

  - shapeVel: Vector

    The constant velocity of the shape to cast (i.e. the cast direction).

  - shape: Shape

    The shape to cast.

  - targetDistance: number

    − If the shape moves closer to this distance from a collider, a hit will be returned.

  - maxToi: number

    The maximum time-of-impact that can be reported by this cast. This effectively limits the distance traveled by the shape to `shapeVel.norm() * maxToi`.

  - stopAtPenetration: boolean

    If set to `false`, the linear shape-cast won’t immediately stop if the shape is penetrating another shape at its starting point and its trajectory is such that it’s on a path to exit that penetration state.

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns ColliderShapeCastHit

  - Defined in geometry/broad_phase.d.ts:134

### collidersWithAabbIntersectingAabb

- collidersWithAabbIntersectingAabb(narrowPhase, bodies, colliders, aabbCenter, aabbHalfExtents, callback): void

- Finds the handles of all the colliders with an AABB intersecting the given AABB.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet
  - aabbCenter: Vector

    The center of the AABB to test.

  - aabbHalfExtents: Vector

    The half-extents of the AABB to test.

  - callback: ((handle) => boolean)

    The callback that will be called with the handles of all the colliders currently intersecting the given AABB.

    - - (handle): boolean

      - #### Parameters

        - handle: number

        #### Returns boolean

  #### Returns void

  - Defined in geometry/broad_phase.d.ts:155

### free

- free(): void

- Release the WASM memory occupied by this broad-phase.

  #### Returns void

  - Defined in geometry/broad_phase.d.ts:24

### intersectionWithShape

- intersectionWithShape(narrowPhase, bodies, colliders, shapePos, shapeRot, shape, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): number

- Gets the handle of up to one collider intersecting the given shape.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

  - shapePos: Vector

    The position of the shape used for the intersection test.

  - shapeRot: number

    The orientation of the shape used for the intersection test.

  - shape: Shape

    The shape used for the intersection test.

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns number

  - Defined in geometry/broad_phase.d.ts:79

### intersectionsWithPoint

- intersectionsWithPoint(narrowPhase, bodies, colliders, point, callback, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): void

- Find all the colliders containing the given point.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

  - point: Vector

    The point used for the containment test.

  - callback: ((handle) => boolean)

    A function called with the handles of each collider with a shape containing the `point`.

    - - (handle): boolean

      - #### Parameters

        - handle: number

        #### Returns boolean

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns void

  - Defined in geometry/broad_phase.d.ts:113

### intersectionsWithRay

- intersectionsWithRay(narrowPhase, bodies, colliders, ray, maxToi, solid, callback, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): void

- Cast a ray and collects all the intersections between a ray and the scene.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

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

  - callback: ((intersect) => boolean)

    The callback called once per hit (in no particular order) between a ray and a collider. If this callback returns `false`, then the cast will stop and no further hits will be detected/reported.

    - - (intersect): boolean

      - #### Parameters

        - intersect: RayColliderIntersection

        #### Returns boolean

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns void

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

### intersectionsWithShape

- intersectionsWithShape(narrowPhase, bodies, colliders, shapePos, shapeRot, shape, callback, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): void

- Retrieve all the colliders intersecting the given shape.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

  - shapePos: Vector

    The position of the shape to test.

  - shapeRot: number

    The orientation of the shape to test.

  - shape: Shape

    The shape to test.

  - callback: ((handle) => boolean)

    A function called with the handles of each collider intersecting the `shape`.

    - - (handle): boolean

      - #### Parameters

        - handle: number

        #### Returns boolean

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns void

  - Defined in geometry/broad_phase.d.ts:146

### projectPoint

- projectPoint(narrowPhase, bodies, colliders, point, solid, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): PointColliderProjection

- Find the projection of a point on the closest collider.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

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

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns PointColliderProjection

  - Defined in geometry/broad_phase.d.ts:93

### projectPointAndGetFeature

- projectPointAndGetFeature(narrowPhase, bodies, colliders, point, filterFlags?, filterGroups?, filterExcludeCollider?, filterExcludeRigidBody?, filterPredicate?): PointColliderProjection

- Find the projection of a point on the closest collider.

  #### Parameters

  - narrowPhase: NarrowPhase
  - bodies: RigidBodySet
  - colliders: ColliderSet

    The set of colliders taking part in this pipeline.

  - point: Vector

    The point to project.

  - `Optional` filterFlags: QueryFilterFlags
  - `Optional` filterGroups: number
  - `Optional` filterExcludeCollider: number
  - `Optional` filterExcludeRigidBody: number
  - `Optional` filterPredicate: ((collider) => boolean)
    - - (collider): boolean

      - #### Parameters

        - collider: number

        #### Returns boolean

  #### Returns PointColliderProjection

  - Defined in geometry/broad_phase.d.ts:102