Examples
// Forward input from a canvas into the world's typed event resources.
setupPointerEvents(world, canvas)Function
setupPointerEvents(world: World, target: HTMLElement): voidAttaches browser pointer and wheel listeners to a DOM target. Each listener
resolves the matching typed Events resource with typeidGeneric,
constructs the corresponding window event from the browser event, and writes
it to that resource.
The listeners map browser event names to window event values:
pointerdown → PointerDown.pointerup → PointerUp.pointermove → PointerMove.pointercancel → PointerCancel.pointerenter → PointerEnter.pointerleave → PointerLeave.wheel → PointerWheel.Wheel defaults are suppressed and the target’s browser context menu is suppressed so a window-backed canvas owns its pointer surface.
The target must provide addEventListener; a HTMLElement such as
a canvas can be used. The World must already contain an
Events resource for each listed event type. Calling this helper
again adds another set of listeners; it does not return a cleanup function.
// Forward input from a canvas into the world's typed event resources.
setupPointerEvents(world, canvas)