NarrowPhase2DPlugin

View source

ExtendsPlugin

Installs SAT-based 2D narrowphase collision detection for an App.

The plugin provides Contacts and SATNarrowphase2D resources, configures PhysicsProperties component hooks, and turns broadphase candidate pairs into current SAT collision contacts.

During updates, the plugin reads the CollisionPairs resource, so a broadphase plugin such as Broadphase2DPlugin must also be installed before the app updates. This plugin requires CorePlugin, ReflectPlugin, and MathPlugin; the app validates those dependencies but does not install them automatically.

Examples

import { App } from '@wimaengine/app'
import { Broadphase2DPlugin, NaiveBroadphase2D } from '@wimaengine/broadphase'
import { CorePlugin } from '@wimaengine/core'
import { MathPlugin } from '@wimaengine/math'
import { NarrowPhase2DPlugin } from '@wimaengine/narrowphase'
import { ReflectPlugin } from '@wimaengine/reflect'

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new MathPlugin())
  .registerPlugin(new Broadphase2DPlugin({
    broadphase: new NaiveBroadphase2D()
  }))
  .registerPlugin(new NarrowPhase2DPlugin())
  .run()

Constructor


constructor()

Methods


register(app: App): void

View source

Installs Contacts and SATNarrowphase2D resources and configures PhysicsProperties component behavior.

The PhysicsProperties hook recalculates inverse inertia after the component is added or inserted. The installed resources process candidate pairs supplied by broadphase and expose the resulting collision contacts.

Parameters

NameDescriptionDefault
app

App to configure.

—

requires(): TypeId[]

View source

Returns the plugin IDs required by this narrowphase integration.

The app must already have CorePlugin, ReflectPlugin, and MathPlugin registered. Registering this plugin does not install those dependencies automatically.

Returns

Required plugin TypeId values.