worldToScreen method

Offset? worldToScreen(
  1. Vector3 worldPoint,
  2. Size viewSize
)

Maps a world-space point to its position inside a view (logical pixels, origin top-left), the forward counterpart of screenPointToRay.

Returns null when worldPoint is at or behind the camera plane, where it has no on-screen projection. Points outside the view bounds still return a position (negative, or beyond viewSize); callers decide whether to clamp or cull. viewSize is the view's logical size (the constraints SceneView renders into).

Implementation

ui.Offset? worldToScreen(Vector3 worldPoint, ui.Size viewSize) {
  final uv = projectToScreenUv(worldPoint, viewSize);
  if (uv == null) {
    return null;
  }
  return ui.Offset(uv.x * viewSize.width, uv.y * viewSize.height);
}