From 14d6ad8e5442cf345fae00b9c238a41f0afa95d7 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 13 May 2026 13:37:34 +0200 Subject: [PATCH] Add test case for applying spline corridor junction terrain footprints --- tests/domain/path.command.test.ts | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/domain/path.command.test.ts b/tests/domain/path.command.test.ts index 30adee58..c58cb433 100644 --- a/tests/domain/path.command.test.ts +++ b/tests/domain/path.command.test.ts @@ -610,4 +610,105 @@ describe("path commands", () => { expect(store.undo()).toBe(true); expect(store.getState().document.terrains[terrain.id]).toEqual(terrain); }); + + it("applies connected spline corridor junction terrain footprints with the road", () => { + const terrain = createTerrain({ + id: "terrain-road-junction-apply", + position: { x: 0, y: 0, z: 0 }, + sampleCountX: 7, + sampleCountZ: 7, + cellSize: 1, + heights: new Array(49).fill(0), + layers: [{ materialId: "base-material" }], + paintWeights: [] + }); + const pathA = createScenePath({ + id: "path-road-junction-a", + road: { + enabled: true, + width: 1, + shoulderWidth: 0, + heightOffset: 0, + terrainConform: false, + materialId: "road-material" + }, + points: [ + { + id: "path-road-junction-a-start", + position: { x: 1, y: 2, z: 3 } + }, + { + id: "path-road-junction-a-end", + position: { x: 5, y: 2, z: 3 } + } + ] + }); + const pathB = createScenePath({ + id: "path-road-junction-b", + road: { + enabled: true, + width: 1, + shoulderWidth: 0, + heightOffset: 0, + terrainConform: false, + materialId: "road-material" + }, + points: [ + { + id: "path-road-junction-b-start", + position: { x: 3, y: 2, z: 1 } + }, + { + id: "path-road-junction-b-end", + position: { x: 3, y: 2, z: 5 } + } + ] + }); + const junction = createSplineCorridorJunction({ + id: "junction-road-apply", + center: { x: 3, y: 2, z: 3 }, + radius: 1.5, + materialId: "junction-material", + terrainMode: "flattenAndPaint", + connections: [ + { pathId: pathA.id, progress: 0.5, clipDistance: 1.5 }, + { pathId: pathB.id, progress: 0.5, clipDistance: 1.5 } + ] + }); + const store = createEditorStore({ + initialDocument: { + ...createEmptySceneDocument({ + name: "Path Road Junction Apply Scene" + }), + paths: { + [pathA.id]: pathA, + [pathB.id]: pathB + }, + splineCorridorJunctions: { + [junction.id]: junction + }, + terrains: { + [terrain.id]: terrain + } + } + }); + + store.executeCommand( + createApplySplineRoadToTerrainCommand({ + pathId: pathA.id + }) + ); + + const appliedTerrain = store.getState().document.terrains[terrain.id]!; + const centerIndex = 3 + 3 * 7; + + expect(appliedTerrain.layers.map((layer) => layer.materialId)).toContain( + "junction-material" + ); + expect(appliedTerrain.heights[centerIndex]).toBe(2); + expect(appliedTerrain.foliageBlockerMask.values[centerIndex]).toBe(1); + + expect(store.undo()).toBe(true); + expect(store.getState().document.terrains[terrain.id]).toEqual(terrain); + }); });