diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 13:11:52 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 13:11:52 +0800 |
| commit | 76a6850bb88546fc21f5f78a53fbda04e77c8b52 (patch) | |
| tree | 45e492b623ef820d452201421b85a0b642d349bd /src/LivingVillage.Desktop.Tests | |
| parent | 000a0b00384806ce85d54dfcd2646cb340a26f01 (diff) | |
| download | living-village-76a6850bb88546fc21f5f78a53fbda04e77c8b52.tar.gz | |
feat(desktop): 确定性昼夜光照过渡与夜灯暖光
新增 lightingBlend 纯函数(黎明明 4:00-6:00、暮色 20:00-22:00 线性过渡,边界与 isNightTick 对齐),天空底色/世界 tint 按混合插值渲染,夜晚灯笼暖光晕强度=LanternGlow(纯叠加矩形、无每帧分配风险);回归测试含锚点/单调斜坡/确定性/光晕开关。
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index 7e4ce5f..d77abd6 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -670,6 +670,41 @@ type PrototypeTests () = Assert.AreEqual<string option>(None, M5Interaction.refreshPrompt world needsView |> fun value -> value.Prompt) [<TestMethod>] + member _.DayPhaseLightingIsPureDeterministicAndTransitionsSmoothly () = + let ticksPerHour = Sim.ticksPerDay / 24L + let atHour hour = M6Presentation.lightingAtTick (int64 hour * ticksPerHour) + + // Anchors: full day at noon, full night at midnight, no drift. + Assert.AreEqual<float32>(0.0f, (atHour 12).Blend) + Assert.AreEqual<float32>(1.0f, (atHour 0).Blend) + Assert.AreEqual<float32>(1.0f, (atHour 2).Blend) + + // Dawn ramp: 4:00 -> 6:00 goes night -> day, monotonic. + let dawnStart = (atHour 4).Blend + let dawnMid = (M6Presentation.lightingAtTick (int64 5 * ticksPerHour)).Blend + let dawnEnd = (atHour 6).Blend + Assert.AreEqual<float32>(1.0f, dawnStart) + Assert.AreEqual<float32>(0.5f, dawnMid) + Assert.AreEqual<float32>(0.0f, dawnEnd) + + // Dusk ramp 20:00 -> 22:00 goes day -> night monotonically. + let duskStart = (atHour 20).Blend + let duskMid = (M6Presentation.lightingAtTick (int64 21 * ticksPerHour)).Blend + let duskEnd = (atHour 22).Blend + Assert.AreEqual<float32>(0.0f, duskStart) + Assert.AreEqual<float32>(0.5f, duskMid) + Assert.AreEqual<float32>(1.0f, duskEnd) + + // Determinism without randomness. + let once = atHour 13 + let twice = atHour 13 + Assert.AreEqual<M6RenderProfile>(once, twice) + + // Lantern glow: warm halo only rises with night blend. + Assert.AreEqual<float32>(0.0f, (atHour 13).LanternGlow) + Assert.AreEqual<float32>(1.0f, (atHour 0).LanternGlow) + + [<TestMethod>] member _.WorldPanelDoesNotRenderA永久KeyList () = let world = Sim.initialWorldN 42UL 0 let lines = M5Interaction.panelLines world M5Interaction.initial |
