generateIndices method

  1. @override
void generateIndices (Uint16List indices)
override

Implementation

@override
void generateIndices(Uint16List indices) {
  int i = 0;

  // Sides
  int base1 = 0;
  final int base2 = _segments + 1;
  for (int x = 0; x < _segments; ++x) {
    indices[i++] = base1 + x;
    indices[i++] = base1 + x + 1;
    indices[i++] = base2 + x;

    indices[i++] = base1 + x + 1;
    indices[i++] = base2 + x + 1;
    indices[i++] = base2 + x;
  }

  // Top cap
  base1 = (_segments + 1) * 2;
  for (int x = 1; x < _segments - 1; ++x) {
    indices[i++] = base1;
    indices[i++] = base1 + x + 1;
    indices[i++] = base1 + x;
  }

  // Bottom cap
  base1 = (_segments + 1) * 2 + _segments;
  for (int x = 1; x < _segments - 1; ++x) {
    indices[i++] = base1;
    indices[i++] = base1 + x;
    indices[i++] = base1 + x + 1;
  }
}