Add test case to ensure terrain layers use swatch colors when no texture is found
This commit is contained in:
@@ -100,7 +100,10 @@ export function getTerrainLayerTexture(
|
||||
return getFallbackTerrainLayerTexture();
|
||||
}
|
||||
|
||||
return textureLookup(material) ?? getSolidColorTerrainLayerTexture(material.swatchColorHex);
|
||||
return (
|
||||
textureLookup(material) ??
|
||||
getSolidColorTerrainLayerTexture(material.swatchColorHex)
|
||||
);
|
||||
}
|
||||
|
||||
export function getTerrainLayerPreviewColor(
|
||||
|
||||
@@ -8,6 +8,10 @@ import {
|
||||
disposeMaterialTextureSet
|
||||
} from "../../src/materials/material-rendering";
|
||||
import { createCustomMaterialDef } from "../../src/materials/starter-material-library";
|
||||
import {
|
||||
getFallbackTerrainLayerTexture,
|
||||
getTerrainLayerTexture
|
||||
} from "../../src/rendering/terrain-layer-material";
|
||||
|
||||
function createLoadedImageAsset(
|
||||
assetId: string,
|
||||
@@ -74,14 +78,10 @@ describe("material rendering", () => {
|
||||
}
|
||||
});
|
||||
|
||||
const textureSet = createMaterialTextureSet(
|
||||
material,
|
||||
new TextureLoader(),
|
||||
{
|
||||
[albedoAsset.assetId]: albedoAsset,
|
||||
[normalAsset.assetId]: normalAsset
|
||||
}
|
||||
);
|
||||
const textureSet = createMaterialTextureSet(material, new TextureLoader(), {
|
||||
[albedoAsset.assetId]: albedoAsset,
|
||||
[normalAsset.assetId]: normalAsset
|
||||
});
|
||||
|
||||
expect(textureSet.baseColor).not.toBeNull();
|
||||
expect(textureSet.normal).not.toBeNull();
|
||||
@@ -96,4 +96,15 @@ describe("material rendering", () => {
|
||||
albedoAsset.texture.dispose();
|
||||
normalAsset.texture.dispose();
|
||||
});
|
||||
|
||||
it("uses custom material swatch colors for scalar-only terrain layers", () => {
|
||||
const material = createCustomMaterialDef({
|
||||
id: "material-terrain-swatch",
|
||||
albedoColorHex: "#335577"
|
||||
});
|
||||
const texture = getTerrainLayerTexture(material, () => null);
|
||||
|
||||
expect(texture).not.toBe(getFallbackTerrainLayerTexture());
|
||||
expect(getTerrainLayerTexture(material, () => null)).toBe(texture);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user