delegate property
The shape this one reduces to.
Implementation
@override
Shape get delegate {
if (rings < 1) throw ArgumentError('rings must be >= 1, got $rings.');
final halfHeight = height * 0.5;
final profile = <Vector2>[];
final normals = <Vector2>[];
void addHemisphereRow(double phi, double centreY) {
final cosPhi = math.cos(phi);
final sinPhi = math.sin(phi);
profile.add(Vector2(radius * cosPhi, centreY + radius * sinPhi));
// Normals are radial about the corresponding hemisphere centre, which is
// also correct along the cylindrical middle where phi is 0.
normals.add(Vector2(cosPhi, sinPhi));
}
for (var k = 0; k <= rings; k++) {
addHemisphereRow(
-math.pi / 2.0 + (math.pi / 2.0) * (k / rings),
-halfHeight,
);
}
for (var k = 0; k <= rings; k++) {
addHemisphereRow((math.pi / 2.0) * (k / rings), halfHeight);
}
return LatheShape(
profile: profile,
profileNormals: normals,
segments: segments,
name: name,
);
}