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 getFallbackTerrainLayerTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
return textureLookup(material) ?? getSolidColorTerrainLayerTexture(material.swatchColorHex);
|
return (
|
||||||
|
textureLookup(material) ??
|
||||||
|
getSolidColorTerrainLayerTexture(material.swatchColorHex)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTerrainLayerPreviewColor(
|
export function getTerrainLayerPreviewColor(
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import {
|
|||||||
disposeMaterialTextureSet
|
disposeMaterialTextureSet
|
||||||
} from "../../src/materials/material-rendering";
|
} from "../../src/materials/material-rendering";
|
||||||
import { createCustomMaterialDef } from "../../src/materials/starter-material-library";
|
import { createCustomMaterialDef } from "../../src/materials/starter-material-library";
|
||||||
|
import {
|
||||||
|
getFallbackTerrainLayerTexture,
|
||||||
|
getTerrainLayerTexture
|
||||||
|
} from "../../src/rendering/terrain-layer-material";
|
||||||
|
|
||||||
function createLoadedImageAsset(
|
function createLoadedImageAsset(
|
||||||
assetId: string,
|
assetId: string,
|
||||||
@@ -74,14 +78,10 @@ describe("material rendering", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const textureSet = createMaterialTextureSet(
|
const textureSet = createMaterialTextureSet(material, new TextureLoader(), {
|
||||||
material,
|
[albedoAsset.assetId]: albedoAsset,
|
||||||
new TextureLoader(),
|
[normalAsset.assetId]: normalAsset
|
||||||
{
|
});
|
||||||
[albedoAsset.assetId]: albedoAsset,
|
|
||||||
[normalAsset.assetId]: normalAsset
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(textureSet.baseColor).not.toBeNull();
|
expect(textureSet.baseColor).not.toBeNull();
|
||||||
expect(textureSet.normal).not.toBeNull();
|
expect(textureSet.normal).not.toBeNull();
|
||||||
@@ -96,4 +96,15 @@ describe("material rendering", () => {
|
|||||||
albedoAsset.texture.dispose();
|
albedoAsset.texture.dispose();
|
||||||
normalAsset.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