Skip to main content

Function: resolveCanvasPointerPosition()

resolveCanvasPointerPosition(world, canvas, renderContext, pointerSource): Vector2 | null

Defined in: ui/utilities/resolve-canvas-pointer-position.ts:30

Converts a pointer's current position - canvas pixels, Y-down - into canvas's own UI world space, through its dedicated camera. Two canvases with different cameras (e.g. different verticalWorldUnits) convert the same pointer position differently, which is why this takes a specific canvas rather than publishing one shared "the" UI world position.

Parameters​

world​

EcsWorld

The ECS world canvas's camera entity belongs to.

canvas​

CanvasEcsComponent

The canvas to convert the pointer position for.

renderContext​

RenderContext

The render context the canvas's camera renders through.

pointerSource​

UiPointerSource

The pointer source to read the canvas-space position from.

Returns​

Vector2 | null

The pointer position in canvas's UI world space, or null if the canvas's camera entity is missing its CameraEcsComponent/ PositionEcsComponent.