generateVertexTexCoords method

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

Implementation

@override
void generateVertexTexCoords(
    Vector2List texCoords, Vector3List positions, Uint16List indices) {
  if (_stripTextureCoordinates) {
    final v = Vector2.zero();
    var index = 0;
    for (var i = 0; i <= _segments; i++) {
      final percent = i / _segments;
      v
        ..x = 0.0
        ..y = percent;
      texCoords[index] = v;
      index++;
      v
        ..x = 1.0
        ..y = percent;
      texCoords[index] = v;
      index++;
    }
  } else {
    final v = Vector2.zero();
    var index = 0;
    for (var i = 0; i <= _segments; i++) {
      var position = positions[index];
      var x = (position.x / (_outerRadius + 1.0)) * 0.5;
      var y = (position.z / (_outerRadius + 1.0)) * 0.5;
      v
        ..x = x + 0.5
        ..y = y + 0.5;
      texCoords[index] = v;
      index++;
      position = positions[index];
      x = (position.x / (_outerRadius + 1.0)) * 0.5;
      y = (position.z / (_outerRadius + 1.0)) * 0.5;
      v
        ..x = x + 0.5
        ..y = y + 0.5;
      texCoords[index] = v;
      index++;
    }
    assert(index == vertexCount);
  }
}