From 0609882a1631f7e58b338bdcef1230f71ecc2ce8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 7 Apr 2026 06:53:28 +0200 Subject: [PATCH] Add water reflection mode and foam contact limit handling in scene document JSON tests --- .../serialization/scene-document-json.test.ts | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index 6714e88f..17c8b407 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -150,7 +150,8 @@ describe("scene document JSON", () => { water: { colorHex: "#2f79c4", surfaceOpacity: 0.65, - waveStrength: 0.35 + waveStrength: 0.35, + foamContactLimit: 9 } } }); @@ -254,6 +255,7 @@ describe("scene document JSON", () => { }, fogPath: "quality", waterPath: "performance", + waterReflectionMode: "world", depthOfField: { enabled: true, focusDistance: 12, @@ -265,6 +267,52 @@ describe("scene document JSON", () => { expect(parseSceneDocumentJson(serializeSceneDocument(document))).toEqual(document); }); + it("defaults missing water reflection mode and clamps legacy foam limits during migration", () => { + const migratedDocument = migrateSceneDocument({ + version: SCENE_DOCUMENT_VERSION, + name: "Legacy Water Settings", + world: { + ...createEmptySceneDocument().world, + advancedRendering: { + ...createEmptySceneDocument().world.advancedRendering, + enabled: true, + waterPath: "quality" + } + }, + materials: STARTER_MATERIAL_LIBRARY.reduce>((registry, material) => { + registry[material.id] = material; + return registry; + }, {}), + textures: {}, + assets: {}, + brushes: { + "brush-water-legacy": { + ...createBoxBrush({ id: "brush-water-legacy" }), + volume: { + mode: "water", + water: { + colorHex: "#2f79c4", + surfaceOpacity: 0.65, + waveStrength: 0.35, + foamContactLimit: 999 + } + } + } + }, + modelInstances: {}, + entities: {}, + interactionLinks: {} + } as unknown); + + expect(migratedDocument.world.advancedRendering.waterReflectionMode).toBe("none"); + expect(migratedDocument.brushes["brush-water-legacy"]?.volume).toEqual({ + mode: "water", + water: expect.objectContaining({ + foamContactLimit: 24 + }) + }); + }); + it("migrates legacy documents without advanced rendering settings to defaults", () => { const emptyScene = createEmptySceneDocument({ name: "Legacy Advanced Rendering Scene" }); const { advancedRendering: _advancedRendering, ...legacyWorld } = emptyScene.world;