generateVertexTexCoords method

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

Implementation

@override
void generateVertexTexCoords(
    Vector2List texCoords, Vector3List positions, Uint16List indices) {
  if (_stripTextureCoordinates) {
    final Vector2 v = new Vector2.zero();
    int index = 0;
    for (int i = 0; i <= _segments; i++) {
      final double 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 Vector2 v = new Vector2.zero();
    int index = 0;
    for (int i = 0; i <= _segments; i++) {
      Vector3 position = positions[index];
      double x = (position.x / (_outerRadius + 1.0)) * 0.5;
      double 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);
  }
}