Examples
const center = ndcToPx(0, 0, 800, 600)
// center.x === 400 and center.y === 300Function
ndcToPx(x: number, y: number, width?: number, height?: number): Vector2Converts a normalized device coordinate (NDC) to a pixel-space coordinate.
Use this helper to map NDC coordinates into a viewport whose pixel origin is
at the top left. NDC uses the center as (0, 0), X from -1 on the left to
1 on the right, and Y increasing upward. The returned pixel coordinate
uses Y increasing downward. The inverse conversion is
xPx = (x + 1) * width / 2 and yPx = (1 - y) * height / 2.
width and height default to the browser viewport’s innerWidth and
innerHeight. The helper does not mutate its inputs and returns a new
Vector2. Use pxToNdc for the inverse conversion.
const center = ndcToPx(0, 0, 800, 600)
// center.x === 400 and center.y === 300