From c7f3ad78f77094fe1b0321f64dc3934f00600612 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 2 May 2026 04:13:56 +0200 Subject: [PATCH] Refactor: Improve type handling and robustness for foliage mask indices and keys in terrain brush stamps. --- src/viewport-three/viewport-host.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 23d3d683..612ee5f3 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -9685,10 +9685,14 @@ export class ViewportHost { private mergeTerrainBrushStampIndices( stroke: ActiveTerrainBrushStroke, - result: Pick< - ReturnType, - "heightSampleIndices" | "paintWeightIndices" | "foliageMaskValueIndices" - > + result: { + heightSampleIndices: readonly number[]; + paintWeightIndices: readonly number[]; + foliageMaskValueIndices?: ReturnType< + typeof applyTerrainBrushStampInPlace + >["foliageMaskValueIndices"]; + foliageMaskValueKeys?: readonly string[]; + } ) { for (const sampleIndex of result.heightSampleIndices) { stroke.heightSampleIndices.add(sampleIndex); @@ -9698,7 +9702,7 @@ export class ViewportHost { stroke.paintWeightIndices.add(paintWeightIndex); } - for (const foliageMaskValueIndex of result.foliageMaskValueIndices) { + for (const foliageMaskValueIndex of result.foliageMaskValueIndices ?? []) { stroke.foliageMaskValueKeys.add( createTerrainFoliageMaskValueKey( foliageMaskValueIndex.layerId, @@ -9706,6 +9710,10 @@ export class ViewportHost { ) ); } + + for (const foliageMaskValueKey of result.foliageMaskValueKeys ?? []) { + stroke.foliageMaskValueKeys.add(foliageMaskValueKey); + } } private beginTerrainBrushStroke(event: PointerEvent): boolean {