Add support for loading screen in project scene migration

This commit is contained in:
2026-04-11 04:14:12 +02:00
parent f439d2a873
commit 3bf7dca99c

View File

@@ -1796,7 +1796,8 @@ function readProjectScene(
value: unknown, value: unknown,
label: string, label: string,
materials: Record<string, MaterialDef>, materials: Record<string, MaterialDef>,
assets: Record<string, ProjectAssetRecord> assets: Record<string, ProjectAssetRecord>,
options: { allowMissingLoadingScreen: boolean }
): ProjectScene { ): ProjectScene {
if (!isRecord(value)) { if (!isRecord(value)) {
throw new Error(`${label} must be an object.`); throw new Error(`${label} must be an object.`);
@@ -1805,6 +1806,9 @@ function readProjectScene(
return { return {
id: expectString(value.id, `${label}.id`), id: expectString(value.id, `${label}.id`),
name: expectString(value.name, `${label}.name`), name: expectString(value.name, `${label}.name`),
loadingScreen: readSceneLoadingScreen(value.loadingScreen, `${label}.loadingScreen`, {
allowMissing: options.allowMissingLoadingScreen
}),
world: readWorldSettings(value.world), world: readWorldSettings(value.world),
brushes: readBrushes(value.brushes, materials, false), brushes: readBrushes(value.brushes, materials, false),
modelInstances: readModelInstances(value.modelInstances, assets), modelInstances: readModelInstances(value.modelInstances, assets),
@@ -1819,19 +1823,25 @@ export function migrateProjectDocument(source: unknown): ProjectDocument {
} }
if ( if (
source.version === MULTI_SCENE_FOUNDATION_SCENE_DOCUMENT_VERSION && (source.version === MULTI_SCENE_FOUNDATION_SCENE_DOCUMENT_VERSION ||
source.version === RUNNER_LOADING_SCREEN_SCENE_DOCUMENT_VERSION) &&
isRecord(source.scenes) isRecord(source.scenes)
) { ) {
const materials = readMaterialRegistry(source.materials, "materials"); const materials = readMaterialRegistry(source.materials, "materials");
const assets = readAssets(source.assets); const assets = readAssets(source.assets);
const scenes: Record<string, ProjectScene> = {}; const scenes: Record<string, ProjectScene> = {};
const allowMissingLoadingScreen =
source.version === MULTI_SCENE_FOUNDATION_SCENE_DOCUMENT_VERSION;
for (const [sceneKey, sceneValue] of Object.entries(source.scenes)) { for (const [sceneKey, sceneValue] of Object.entries(source.scenes)) {
scenes[sceneKey] = readProjectScene( scenes[sceneKey] = readProjectScene(
sceneValue, sceneValue,
`scenes.${sceneKey}`, `scenes.${sceneKey}`,
materials, materials,
assets assets,
{
allowMissingLoadingScreen
}
); );
} }