worldToScreen function

ScreenPoint worldToScreen(
  1. Point3D worldPoint,
  2. Camera3D camera,
  3. Projection3D projection
)

Transform a world 3D point through camera view and projection to screen.

Implementation

ScreenPoint worldToScreen(
  Point3D worldPoint,
  Camera3D camera,
  Projection3D projection,
) {
  // World → View (camera space)
  final viewMatrix = camera.viewMatrix();
  final viewPoint = _transformPoint(viewMatrix, worldPoint);

  // View → Projection (clip space → screen)
  return projection.project(viewPoint);
}