From e3d538f63b8b195c27dbce7d928c5a879d4d4935 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 13 May 2026 18:53:57 +0200 Subject: [PATCH] Update spline corridor junction mesh tests, adding seam resolution validation and refining mesh assertions --- .../spline-corridor-junction-mesh.test.ts | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/geometry/spline-corridor-junction-mesh.test.ts b/tests/geometry/spline-corridor-junction-mesh.test.ts index 84fb8e1c..15397f06 100644 --- a/tests/geometry/spline-corridor-junction-mesh.test.ts +++ b/tests/geometry/spline-corridor-junction-mesh.test.ts @@ -9,7 +9,8 @@ import { } from "../../src/geometry/spline-corridor-junction-footprint"; import { buildSplineCorridorJunctionEdgeMeshData, - buildSplineCorridorJunctionMeshGeometry + buildSplineCorridorJunctionMeshGeometry, + resolveSplineCorridorJunctionRoadEdgeSeams } from "../../src/geometry/spline-corridor-junction-mesh"; function createRoadPath( @@ -215,8 +216,8 @@ describe("spline corridor junction mesh generation", () => { expect(roadMouthSegmentCount).toBe(4); expect(meshData?.footprintPointCount).toBe(8); expect(meshData?.profileVertexCount).toBe(4); - expect(meshData?.positions).toHaveLength(16 * 4 * 3); - expect(meshData?.indices).toHaveLength(4 * 3 * 3 * 6); + expect(meshData?.positions).toHaveLength(8 * 4 * 3); + expect(meshData?.indices).toHaveLength(4 * 3 * 6 + 8 * 2 * 3); const firstProfile = Array.from(meshData!.positions.slice(0, 12)); const firstProfileWidth = Math.hypot( firstProfile[6]! - firstProfile[3]!, @@ -227,7 +228,7 @@ describe("spline corridor junction mesh generation", () => { (_, index) => Array.from(meshData!.positions.slice(index * 12, index * 12 + 12)) ); - expect(firstProfileWidth).toBeCloseTo(0.4, 5); + expect(firstProfileWidth).toBeGreaterThan(0.4); expect(profileRows).toEqual( expect.arrayContaining([ [ @@ -237,10 +238,10 @@ describe("spline corridor junction mesh generation", () => { 3, expect.closeTo(0.3, 5), -1, - 3, + expect.closeTo(2.8343145, 5), expect.closeTo(0.3, 5), expect.closeTo(-1.4, 5), - 3, + expect.closeTo(2.8343145, 5), expect.closeTo(0.1, 5), expect.closeTo(-1.4, 5) ], @@ -260,6 +261,35 @@ describe("spline corridor junction mesh generation", () => { ] ]) ); + + const seamsByPath = resolveSplineCorridorJunctionRoadEdgeSeams({ + junctions: [junction], + paths: [pathA, pathB] + }); + const pathASeams = seamsByPath.get(pathA.id) ?? []; + + expect(pathASeams).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + pathId: pathA.id, + side: "left", + distance: 3, + outerOffset: { + x: expect.closeTo(-0.1656854, 5), + z: expect.closeTo(0.4, 5) + } + }), + expect.objectContaining({ + pathId: pathA.id, + side: "right", + distance: 3, + outerOffset: { + x: expect.closeTo(-0.1656854, 5), + z: expect.closeTo(-0.4, 5) + } + }) + ]) + ); }); it("samples full terrain influence inside the connection footprint and falloff outside it", () => {