From 5e6ac133e523c277359dbc43aa3d954b6f20ad82 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 18 May 2026 16:17:38 +0200 Subject: [PATCH] Test custom material resolution in runtime scene build --- tests/domain/build-runtime-scene.test.ts | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/domain/build-runtime-scene.test.ts b/tests/domain/build-runtime-scene.test.ts index b9a50f3d..1ee5bdc2 100644 --- a/tests/domain/build-runtime-scene.test.ts +++ b/tests/domain/build-runtime-scene.test.ts @@ -1245,6 +1245,76 @@ describe("buildRuntimeSceneFromDocument", () => { }); }); + it("resolves custom whitebox materials with scalar values and texture refs", () => { + const imageAsset: ImageAssetRecord = { + id: "asset-runtime-material-albedo", + kind: "image", + sourceName: "runtime-albedo.png", + mimeType: "image/png", + storageKey: createProjectAssetStorageKey("asset-runtime-material-albedo"), + byteLength: 256, + metadata: { + kind: "image", + width: 8, + height: 8, + hasAlpha: true, + warnings: [] + } + }; + const material = createCustomMaterialDef({ + id: "material-runtime-custom", + name: "Runtime Custom", + albedoColorHex: "#88ccff", + opacity: 0.5, + roughness: 0.25, + metallic: 0.8, + normalStrength: 0.4, + textures: { + albedo: { + assetId: imageAsset.id + }, + normal: null, + roughness: null, + metallic: null + } + }); + const brush = createBoxBrush({ + id: "brush-runtime-custom-material" + }); + + brush.faces.posZ.materialId = material.id; + + const runtimeScene = buildRuntimeSceneFromDocument({ + ...createEmptySceneDocument({ name: "Custom Material Runtime Scene" }), + assets: { + [imageAsset.id]: imageAsset + }, + materials: { + ...createEmptySceneDocument().materials, + [material.id]: material + }, + brushes: { + [brush.id]: brush + } + }); + + expect(runtimeScene.brushes[0].faces.posZ.material).toMatchObject({ + id: material.id, + kind: "custom", + albedoColorHex: "#88ccff", + opacity: 0.5, + roughness: 0.25, + metallic: 0.8, + normalStrength: 0.4, + textures: { + albedo: { + assetId: imageAsset.id + } + } + }); + expect(runtimeScene.brushes[0].faces.posX.material).toBeNull(); + }); + it("carries climbable whitebox face metadata into runtime brush colliders", () => { const brush = createBoxBrush({ id: "brush-climbable-wall"