Broadphase2D

View source

Provides the configured 2D broadphase as a world resource.

The resource delegates storage and query behavior to the implementation supplied by Broadphase2DPlugin. It does not choose an indexing algorithm or maintain a second index. Retrieve it from a world with World#getResource.

Each query receives an optional target array and returns the result provided by the wrapped implementation. When no target is supplied, the facade provides a new array. Matching semantics are defined by Broadphasable2D.

Examples

import { BoundingBox2D } from '@wimaengine/geometry'
import { Broadphase2D } from '@wimaengine/broadphase'

const broadphase = world.getResource(Broadphase2D)
const candidates = broadphase.queryBox(new BoundingBox2D(-1, -1, 1, 1))

Constructor


constructor(broadphasable: Broadphasable2D)

View source

Creates a resource facade over a broadphase implementation.

The implementation is retained by reference and is responsible for the broadphase index and matching behavior.

Parameters

NameDescriptionDefault
broadphasable

Implementation to wrap.

—

Methods


queryBox(bound: BoundingBox2D, target?: EntityHandle[]): EntityHandle[]

View source

Delegates an axis-aligned box query to the configured implementation.

The target defaults to a new array and is passed to the implementation, allowing callers to reuse result storage when supported by that implementation.

Parameters

NameDescriptionDefault
bound

Box region to query.

—
target?

Array to supply for query results.

[]

Returns

The result returned by the implementation.

queryCircle(bound: BoundingCircle, target?: EntityHandle[]): EntityHandle[]

View source

Delegates a circle query to the configured implementation.

The target defaults to a new array and is passed to the implementation, allowing callers to reuse result storage when supported by that implementation.

Parameters

NameDescriptionDefault
bound

Circle region to query.

—
target?

Array to supply for query results.

[]

Returns

The result returned by the implementation.

queryPoint(point: Vector2, target?: EntityHandle[]): EntityHandle[]

View source

Delegates a point query to the configured implementation.

The facade does not apply a point test of its own. Matching behavior, including whether the point is tested, belongs to the implementation.

Parameters

NameDescriptionDefault
point

Point region to query.

—
target?

Array to supply for query results.

[]

Returns

The result returned by the implementation.

clear(): void

View source

Delegates removal of all entries to the configured implementation.

push(entity: EntityHandle, broadphase: BoundingBox2D): void

View source

Delegates insertion of an entity and its broadphase bound.

Parameters

NameDescriptionDefault
entity

Entity represented by the bound.

—
broadphase

Bound to store for the entity.

—