auto-git:

[change] tests/unit/world-background-renderer.test.ts
This commit is contained in:
2026-04-22 13:46:20 +02:00
parent 3e48fbd608
commit 76b104fee9

View File

@@ -1,5 +1,5 @@
import { Texture } from "three";
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { createDefaultWorldSettings } from "../../src/document/world-settings";
import { resolveWorldEnvironmentState } from "../../src/rendering/world-background-renderer";
@@ -49,6 +49,66 @@ describe("resolveWorldEnvironmentState", () => {
expect(lateTwilight.intensity).toBeCloseTo(0.7);
});
it("uses a cached blended environment texture during partial image-image twilight blends", () => {
const world = createDefaultWorldSettings();
const dayTexture = new Texture();
const nightTexture = new Texture();
const blendedTexture = new Texture();
const environmentBlendTextureResolver = {
resolveBlendTexture: vi.fn().mockReturnValue(blendedTexture)
};
world.background = {
mode: "image",
assetId: "asset-day-sky",
environmentIntensity: 0.45
};
const twilight = resolveWorldEnvironmentState(
world.background,
dayTexture,
{
texture: nightTexture,
opacity: 0.5,
environmentIntensity: 0.85
},
environmentBlendTextureResolver
);
expect(
environmentBlendTextureResolver.resolveBlendTexture
).toHaveBeenCalledWith(dayTexture, nightTexture, 0.5);
expect(twilight.texture).toBe(blendedTexture);
expect(twilight.intensity).toBeCloseTo(0.65);
});
it("falls back to the existing single-texture environment while a blended bucket is unavailable", () => {
const world = createDefaultWorldSettings();
const dayTexture = new Texture();
const nightTexture = new Texture();
const environmentBlendTextureResolver = {
resolveBlendTexture: vi.fn().mockReturnValue(null)
};
world.background = {
mode: "image",
assetId: "asset-day-sky",
environmentIntensity: 0.45
};
const twilight = resolveWorldEnvironmentState(
world.background,
dayTexture,
{
texture: nightTexture,
opacity: 0.5,
environmentIntensity: 0.85
},
environmentBlendTextureResolver
);
expect(twilight.texture).toBe(dayTexture);
expect(twilight.intensity).toBeCloseTo(0.65);
});
it("fades the night environment in when the authored day background has no image environment", () => {
const world = createDefaultWorldSettings();
const nightTexture = new Texture();