From f8f40076574dc9664b95cbe5d2114ad54170f6f1 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 12 May 2026 23:52:35 +0200 Subject: [PATCH] Implement reading and validation for scene path road settings --- src/document/migrate-scene-document.ts | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/document/migrate-scene-document.ts b/src/document/migrate-scene-document.ts index 3235235a..e3fb0fc4 100644 --- a/src/document/migrate-scene-document.ts +++ b/src/document/migrate-scene-document.ts @@ -5667,6 +5667,50 @@ function readScenePathPointValue( }); } +function readScenePathRoadSettingsValue( + value: unknown, + label: string +): ScenePathRoadSettings { + if (value === undefined) { + return createScenePathRoadSettings(); + } + + if (!isRecord(value)) { + throw new Error(`${label} must be an object.`); + } + + return createScenePathRoadSettings({ + enabled: readOptionalBoolean(value.enabled, `${label}.enabled`, false), + width: + value.width === undefined + ? undefined + : expectFiniteNumber(value.width, `${label}.width`), + shoulderWidth: + value.shoulderWidth === undefined + ? undefined + : expectFiniteNumber(value.shoulderWidth, `${label}.shoulderWidth`), + falloff: + value.falloff === undefined + ? undefined + : expectFiniteNumber(value.falloff, `${label}.falloff`), + heightOffset: + value.heightOffset === undefined + ? undefined + : expectFiniteNumber(value.heightOffset, `${label}.heightOffset`), + terrainConform: readOptionalBoolean( + value.terrainConform, + `${label}.terrainConform`, + true + ), + materialId: + value.materialId === undefined || value.materialId === null + ? null + : normalizeScenePathRoadMaterialId( + expectString(value.materialId, `${label}.materialId`) + ) + }); +} + function readScenePathValue(value: unknown, label: string): ScenePath { if (!isRecord(value)) { throw new Error(`${label} must be an object.`); @@ -5717,6 +5761,7 @@ function readScenePathValue(value: unknown, label: string): ScenePath { DEFAULT_SCENE_PATH_TERRAIN_OFFSET ) ), + road: readScenePathRoadSettingsValue(value.road, `${label}.road`), points: value.points.map((pointValue, index) => readScenePathPointValue(pointValue, `${label}.points.${index}`) )