Add boundary checks for top edge key collection

This commit is contained in:
2026-05-21 07:58:40 +02:00
parent 5a90ba88cc
commit a60a963a00

View File

@@ -56,11 +56,19 @@ function collectTopEdgeKeys(options: {
options.level.positions[positionOffset + varyingOffset]! /
options.terrain.cellSize;
const roundedVaryingSample = Math.round(varyingSample);
const maxVaryingSample =
options.axis === "x"
? options.terrain.sampleCountZ - 1
: options.terrain.sampleCountX - 1;
if (Math.abs(varyingSample - roundedVaryingSample) > epsilon) {
continue;
}
if (roundedVaryingSample === 0 || roundedVaryingSample === maxVaryingSample) {
continue;
}
const sampleX =
options.axis === "x"
? options.sampleCoordinate