constructor(options: Broadphase2DPluginOptions)
View sourceCreates a broadphase plugin using the supplied indexing implementation.
Class
ExtendsPlugin
Installs 2D broadphase resources and candidate generation in an App.
The plugin makes the configured Broadphasable2D implementation
available through Broadphase2D and provides CollisionPairs
for the current broadphase candidates. Entities with PhysicsHitbox
components are indexed, and overlapping hitboxes are reported as potential
collision pairs. The pairs are candidates for downstream collision
processing, not confirmed collisions.
The app must also register CorePlugin, ReflectPlugin, and
MathPlugin. The plugin reports these dependencies through
Broadphase2DPlugin#requires; it does not install them automatically.
import { App } from '@wimaengine/app'
import { Broadphase2DPlugin, NaiveBroadphase2D } from '@wimaengine/broadphase'
import { CorePlugin } from '@wimaengine/core'
import { MathPlugin } from '@wimaengine/math'
import { ReflectPlugin } from '@wimaengine/reflect'
new App()
.registerPlugin(new ReflectPlugin())
.registerPlugin(new CorePlugin())
.registerPlugin(new MathPlugin())
.registerPlugin(new Broadphase2DPlugin({
broadphase: new NaiveBroadphase2D()
}))
.run()constructor(options: Broadphase2DPluginOptions)Creates a broadphase plugin using the supplied indexing implementation.
Configured implementation passed to the installed Broadphase2D
resource.
The constructor retains the supplied object by reference, and
Broadphase2DPlugin#register passes that same object to the
resource.
register(app: App): voidMakes the broadphase resources available and prepares candidate-pair updates.
The app receives a Broadphase2D resource backed by the configured
implementation and a fresh CollisionPairs resource. Each update
refreshes the broadphase from entities with PhysicsHitbox and
rebuilds the pair list from overlapping hitboxes. Pairs are potential
collisions, not confirmed narrowphase results.
requires(): TypeId[]Returns the plugins required by this broadphase integration.