drawVelocity

View sourcedrawVelocity(world: World): void

Draws each entity’s velocity as a cyan vector from its Position2D.

Physics2DDebuggerPlugin registers this exact function directly in the repeating AppSchedule.Update schedule when its drawVelocity option is enabled. The query requires both Position2D and Velocity2D. For each match, the system draws from (position.x, position.y) to that point plus the velocity vector, then strokes the shared path in cyan.

The main-window entity is found through EntityHandle and MainWindow, and its canvas is resolved through the Windows resource. The world must provide that main-window match and resource. If no canvas is registered for the handle, or the canvas has no 2D context, the function returns without drawing.

Examples

import { AppSchedule } from '@wimaengine/core'
import { drawVelocity } from '@wimaengine/physics'

app.registerSystem({
  schedule: AppSchedule.Update,
  system: drawVelocity
})
// Physics2DDebuggerPlugin registers this when drawVelocity is enabled.

Parameters

NameDescriptionDefault
world

World containing Position2D/Velocity2D pairs and the main window.

—