trackOutline function

List<Vector2> trackOutline(
  1. TrackSpline track, {
  2. double step = 12.0,
})

The lap as a flat outline, for a map in the corner of the screen.

Returned in world XZ and left unscaled: what a map is drawn at is the map's business, and a helper that decided it would have to know how big the corner of the screen was.

Implementation

List<Vector2> trackOutline(TrackSpline track, {double step = 12.0}) {
  final points = <Vector2>[];
  final at = Vector3.zero();
  for (var s = 0.0; s < track.length; s += step) {
    track.centreAt(s, at);
    points.add(Vector2(at.x, at.z));
  }
  return points;
}