generateVertexPositions method

  1. @override
void generateVertexPositions(
  1. Vector3List positions,
  2. Uint16List indices
)
override

Implementation

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

  // Top
  for (var x = 0; x <= _segments; ++x) {
    final u = x / _segments;

    positions[i++] = Vector3(_topRadius * math.cos(u * math.pi * 2.0),
        _height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
  }

  // Bottom
  for (var x = 0; x <= _segments; ++x) {
    final u = x / _segments;

    positions[i++] = Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
        _height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
  }

  // Top cap
  for (var x = 0; x < _segments; ++x) {
    final u = x / _segments;

    positions[i++] = Vector3(_topRadius * math.cos(u * math.pi * 2.0),
        _height * 0.5, _topRadius * math.sin(u * math.pi * 2.0));
  }

  // Bottom cap
  for (var x = 0; x < _segments; ++x) {
    final u = x / _segments;

    positions[i++] = Vector3(_bottomRadius * math.cos(u * math.pi * 2.0),
        _height * -0.5, _bottomRadius * math.sin(u * math.pi * 2.0));
  }
}