generateVertexTexCoords method
void
generateVertexTexCoords(
- Vector2List texCoords,
- Vector3List positions,
- 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);
}
}