23 lines
820 B
JavaScript
23 lines
820 B
JavaScript
export function preparedAlphaTextureFilename(imageName) {
|
|
const name = String(imageName ?? "");
|
|
return /\.png$/iu.test(name) ? name : `${name}.png`;
|
|
}
|
|
|
|
function normalizedRole(role) {
|
|
if (role === "cutout" || role === "mask") return "mask";
|
|
if (role === "blend" || role === "additive") return "blend";
|
|
return role;
|
|
}
|
|
|
|
export function alphaSemanticRolesMatch(expectedRole, actualRole) {
|
|
return normalizedRole(expectedRole) === normalizedRole(actualRole);
|
|
}
|
|
|
|
export function effectiveAlphaMaterialRole(semanticRole, alphaMode) {
|
|
return semanticRole ?? (alphaMode === "OPAQUE" ? "opaque" : "missing");
|
|
}
|
|
|
|
export function alphaMaterialMatches(expectedAlphaMode, expectedRole, actualAlphaMode, actualRole) {
|
|
return expectedAlphaMode === actualAlphaMode && alphaSemanticRolesMatch(expectedRole, actualRole);
|
|
}
|