generateVertexTexCoords method Null safety

  1. @override
void generateVertexTexCoords(
  1. Vector2List texCoords,
  2. Vector3List positions,
  3. Uint16List indices
)
override

Implementation

@override
void generateVertexTexCoords(
    Vector2List texCoords, Vector3List positions, Uint16List indices) {
  var i = 0;

  // Cylinder top
  for (var x = 0; x <= _segments; ++x) {
    final u = 1.0 - (x / _segments);
    texCoords[i++] = Vector2(u, 0.0);
  }

  // Cylinder bottom
  for (var x = 0; x <= _segments; ++x) {
    final u = 1.0 - (x / _segments);
    texCoords[i++] = Vector2(u, 1.0);
  }

  // Top cap
  for (var x = 0; x < _segments; ++x) {
    final r = (x / _segments) * math.pi * 2.0;
    texCoords[i++] =
        Vector2(math.cos(r) * 0.5 + 0.5, math.sin(r) * 0.5 + 0.5);
  }

  // Bottom cap
  for (var x = 0; x < _segments; ++x) {
    final r = (x / _segments) * math.pi * 2.0;
    texCoords[i++] =
        Vector2(math.cos(r) * 0.5 + 0.5, math.sin(r) * 0.5 + 0.5);
  }
}