Add end cap faces to spline road mesh data, particularly for curb segments

This commit is contained in:
2026-05-13 03:30:49 +02:00
parent a9063726f6
commit dbf0c55e1a

View File

@@ -266,6 +266,24 @@ function buildEdgeProfile(options: {
} }
} }
function addEdgeProfileCaps(options: {
indices: number[];
profileVertexCount: number;
stationCount: number;
}) {
if (options.profileVertexCount < 3 || options.stationCount < 2) {
return;
}
const lastRow = (options.stationCount - 1) * options.profileVertexCount;
for (let index = 1; index < options.profileVertexCount - 1; index += 1) {
// Start cap faces backward along the spline; end cap faces forward.
options.indices.push(0, index + 1, index);
options.indices.push(lastRow, lastRow + index, lastRow + index + 1);
}
}
export function buildSplineRoadMeshData(options: { export function buildSplineRoadMeshData(options: {
path: SplineRoadPathLike; path: SplineRoadPathLike;
terrains?: readonly Terrain[]; terrains?: readonly Terrain[];
@@ -431,6 +449,14 @@ export function buildSplineRoadEdgeMeshData(options: {
} }
} }
if (edge.kind === "curb") {
addEdgeProfileCaps({
indices,
profileVertexCount: profile.length,
stationCount: stations.length
});
}
return { return {
pathId: path.id, pathId: path.id,
side, side,