Examples
import { AppSchedule } from '@wimaengine/core'
import { drawArms } from '@wimaengine/physics'
app.registerSystem({
schedule: AppSchedule.Update,
system: drawArms
})
// Physics2DDebuggerPlugin maps drawCollisionArm to drawArms.Function
drawArms(world: World): voidDraws yellow arms from colliding bodies to their current contact points.
Physics2DDebuggerPlugin registers this exact function directly in the
repeating AppSchedule.Update schedule when its drawCollisionArm option is enabled.
The system reads the current Contacts resource. For every manifold,
it resolves each body’s Position2D with the manifold’s entity
handles, then draws a line from each position to every contact point covered
by CollisionData#contactNo. All lines are stroked together in yellow.
The main-window entity is found through EntityHandle and
MainWindow, and its canvas is resolved through the Windows
resource. The world must provide the Contacts and Windows
resources and a main-window match. A missing canvas or unavailable 2D
context returns without drawing. If either contact body has no
Position2D, the function also returns immediately before stroking
the path, so earlier lines from that invocation are not rendered.
import { AppSchedule } from '@wimaengine/core'
import { drawArms } from '@wimaengine/physics'
app.registerSystem({
schedule: AppSchedule.Update,
system: drawArms
})
// Physics2DDebuggerPlugin maps drawCollisionArm to drawArms.