halfPyramid static method
Implementation
static Geometry halfPyramid(
{double startX = 0.25,
double startY = 0.25,
double width = 1.0,
double height = 1.0,
double depth = 1.0,
bool normals = true,
bool uvs = true}) {
// Define vertices for a half pyramid (triangular prism)
// Starting at (startX, startY, 0)
Float32List vertices = Float32List.fromList([
// Base rectangle (bottom face)
startX, startY, 0, // 0: front-left
startX + width, startY, 0, // 1: front-right
startX + width, startY + height, 0, // 2: back-right
startX, startY + height, 0, // 3: back-left
// Top ridge
startX, startY + height, depth, // 4: top ridge start
startX + width, startY + height, depth, // 5: top ridge end
]);
// Define normals if needed
Float32List? _normals = normals
? Float32List.fromList([
// Base rectangle
0, 0, -1, // Bottom face
0, 0, -1,
0, 0, -1,
0, 0, -1,
// Ridge normals (approximate)
0, 0.7071, 0.7071, // Angled toward ridge
0, 0.7071, 0.7071,
])
: null;
// Define UVs if needed
Float32List? _uvs = uvs
? Float32List.fromList([
// Base rectangle UVs
0, 0, // Bottom-left
1, 0, // Bottom-right
1, 1, // Top-right
0, 1, // Top-left
// Ridge UVs
0, 0.5,
1, 0.5,
])
: null;
// Define indices for triangular faces
Uint16List indices = Uint16List.fromList([
// Bottom face (rectangle)
0, 1, 2,
0, 2, 3,
// Front triangular face
0, 1, 5,
0, 5, 4,
// Left rectangular face
0, 4, 3,
// Right rectangular face
1, 2, 5,
// Back rectangular face
2, 3, 4,
2, 4, 5,
]);
return Geometry(vertices, indices, normals: _normals, uvs: _uvs);
}