DRAWING FUNCTIONS

WorldToScreen

Converts a world position to screen coordinates.

Syntax

local on, sx, sy = ONYX.WorldToScreen(x, y, z)

Parameters

  • x (number) — World X.
  • y (number) — World Y.
  • z (number) — World Z.

Return(s)

on (boolean) — true when the point is in front of the camera; sx, sy (number) — screen pixels.

Behavior

  • Returns on = false when the point is behind the camera or the projection is invalid.
  • Coordinates are not clamped; sx and sy may sit outside the viewport when off-screen.
  • The result is ready for the Draw* helpers.

Example(s)

local on, sx, sy = ONYX.WorldToScreen(250.0, -1340.0, 30.0)
if on then ONYX.DrawCircle(sx, sy, 4, true, 1, 0, 0, 1) end