Physics2DDebuggerPlugin

View source

ExtendsPlugin

Adds optional 2D physics debug overlays to an app’s browser canvas.

Enable overlays for shapes, bounds, positions, velocities, collision arms, or contacts through the plugin options. drawShapes defaults to true; every other overlay defaults to false. The overlays read the current physics state and need the app’s window and physics dependencies to be registered.

Examples

import { App } from '@wimaengine/app'
import { DefaultPlugin } from '@wimaengine/misc'
import { Physics2DDebuggerPlugin } from '@wimaengine/physics'

new App()
  .registerPlugin(new DefaultPlugin())
  .registerPlugin(new Physics2DDebuggerPlugin({
    drawBounds: true,
    drawContacts: true
  }))
  .run()

Constructor


constructor(options?: BodyDebuggerOptions)

View source

Creates a debugger plugin with the selected overlays enabled.

drawShapes defaults to true. drawBounds, drawPosition, drawVelocity, drawCollisionArm, and drawContacts default to false. Set an option to true to enable its overlay.

Parameters

NameDescriptionDefault
options?

Drawing overlays to register.

{}

Properties


Methods


register(app: App): void

View source

Registers each enabled debugger overlay for the app.

Enabled overlays draw the current physics state on the main browser canvas during app updates. If no canvas or 2D drawing context is available, the plugin remains registered but produces no visible overlay.

Parameters

NameDescriptionDefault
app

App receiving the enabled overlays.

—