From ca50a6a1897980b362c835fe8e10a9b9fbed117f Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 28 Apr 2026 04:09:01 +0200 Subject: [PATCH] Add validation functions for unit intervals and distance fog settings --- src/app/App.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/app/App.tsx b/src/app/App.tsx index 56d795f5..ffaca0ac 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -1041,6 +1041,32 @@ function readPositiveNumberDraft(source: string, label: string): number { return value; } +function readUnitIntervalNumberDraft(source: string, label: string): number { + const value = Number(source); + + if (!Number.isFinite(value) || value < 0 || value > 1) { + throw new Error(`${label} must be a finite number between zero and one.`); + } + + return value; +} + +function assertAdvancedRenderingDistanceFogRange( + distanceFog: AdvancedRenderingDistanceFogSettings +) { + if (distanceFog.farDistance <= distanceFog.nearDistance) { + throw new Error( + "Distance fog far distance must be greater than near distance." + ); + } + + if (distanceFog.renderDistance <= distanceFog.nearDistance) { + throw new Error( + "Distance fog render distance must be greater than near distance." + ); + } +} + function assertProjectTimeSettingsAreOrdered(time: ProjectTimeSettings) { if (time.sunriseTimeOfDayHours >= time.sunsetTimeOfDayHours) { throw new Error("Project sunrise must be earlier than project sunset.");