From a60a963a0060bc5105d77dbcce903d90c835462f Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Thu, 21 May 2026 07:58:40 +0200 Subject: [PATCH] Add boundary checks for top edge key collection --- tests/geometry/terrain-mesh.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/geometry/terrain-mesh.test.ts b/tests/geometry/terrain-mesh.test.ts index e5b28458..d603c739 100644 --- a/tests/geometry/terrain-mesh.test.ts +++ b/tests/geometry/terrain-mesh.test.ts @@ -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