Class QueryPipeline

A pipeline for performing queries on all the colliders of a scene.

To avoid leaking WASM resources, this MUST be freed manually with queryPipeline.free() once you are done using it (and all the rigid-bodies it created).

Hierarchy

  • QueryPipeline

Constructors

  • Parameters

    • Optional raw: RawQueryPipeline

    Returns QueryPipeline

Properties

raw: RawQueryPipeline

Methods

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

    Parameters

    • 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: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns RayColliderHit

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

    This also computes the normal at the hit point.

    Parameters

    • 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: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns RayColliderIntersection

  • 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

    • bodies: RigidBodySet
    • colliders: ColliderSet

      The set of colliders taking part in this pipeline.

    • shapePos: Vector

      The initial position of the shape to cast.

    • shapeRot: Rotation

      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 exist that penetration state.

    • Optional filterFlags: QueryFilterFlags
    • Optional filterGroups: number
    • Optional filterExcludeCollider: number
    • Optional filterExcludeRigidBody: number
    • Optional filterPredicate: ((collider: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns ColliderShapeCastHit

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

    Parameters

    • aabbCenter: Vector

      The center of the AABB to test.

    • aabbHalfExtents: Vector

      The half-extents of the AABB to test.

    • callback: ((handle: number) => boolean)

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

        • (handle: number): boolean
        • Parameters

          • handle: number

          Returns boolean

    Returns void

  • Release the WASM memory occupied by this query pipeline.

    Returns void

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

    Parameters

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

      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: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns number

  • Find all the colliders containing the given point.

    Parameters

    • bodies: RigidBodySet
    • colliders: ColliderSet

      The set of colliders taking part in this pipeline.

    • point: Vector

      The point used for the containment test.

    • callback: ((handle: number) => boolean)

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

        • (handle: number): boolean
        • Parameters

          • handle: number

          Returns boolean

    • Optional filterFlags: QueryFilterFlags
    • Optional filterGroups: number
    • Optional filterExcludeCollider: number
    • Optional filterExcludeRigidBody: number
    • Optional filterPredicate: ((collider: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns void

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

    Parameters

    • 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: RayColliderIntersection) => 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.

    • Optional filterFlags: QueryFilterFlags
    • Optional filterGroups: number
    • Optional filterExcludeCollider: number
    • Optional filterExcludeRigidBody: number
    • Optional filterPredicate: ((collider: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns void

  • Retrieve all the colliders intersecting the given shape.

    Parameters

    • bodies: RigidBodySet
    • colliders: ColliderSet

      The set of colliders taking part in this pipeline.

    • shapePos: Vector

      The position of the shape to test.

    • shapeRot: Rotation

      The orientation of the shape to test.

    • shape: Shape

      The shape to test.

    • callback: ((handle: number) => boolean)

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

        • (handle: number): boolean
        • Parameters

          • handle: number

          Returns boolean

    • Optional filterFlags: QueryFilterFlags
    • Optional filterGroups: number
    • Optional filterExcludeCollider: number
    • Optional filterExcludeRigidBody: number
    • Optional filterPredicate: ((collider: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns void

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

    Parameters

    • 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: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns PointColliderProjection

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

    Parameters

    • 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: number) => boolean)
        • (collider: number): boolean
        • Parameters

          • collider: number

          Returns boolean

    Returns PointColliderProjection

  • Updates the acceleration structure of the query pipeline.

    Parameters

    • bodies: RigidBodySet

      The set of rigid-bodies taking part in this pipeline.

    • colliders: ColliderSet

      The set of colliders taking part in this pipeline.

    Returns void

Generated using TypeDoc