buildVergeMesh function

MeshData buildVergeMesh(
  1. TrackSpline track, {
  2. required int side,
  3. RoadMeshSettings settings = const RoadMeshSettings(),
  4. VertexLayout? layout,
})

The ground either side of the road, out to where the level takes over.

side is -1 for the left of the track and 1 for the right — the same sign as lateral everywhere else.

Implementation

MeshData buildVergeMesh(
  TrackSpline track, {
  required int side,
  RoadMeshSettings settings = const RoadMeshSettings(),
  VertexLayout? layout,
}) {
  final sign = side < 0 ? -1.0 : 1.0;
  return _ribbon(
    track,
    settings,
    layout,
    inner: (double s) => sign * track.widthAt(s) / 2.0,
    outer: (double s) => sign * (track.widthAt(s) / 2.0 + track.shoulder),
    // A verge that tiles at the road's rate looks like more road. This is
    // ground, and ground is bigger.
    tileScale: 2.5,
  );
}