fix: canonicalize asset families
This commit is contained in:
+14
-4
@@ -1,12 +1,9 @@
|
||||
export const ASSET_FAMILIES = [
|
||||
'baseColor',
|
||||
'color',
|
||||
'diffuse',
|
||||
'roughness',
|
||||
'normal',
|
||||
'normalOpengl',
|
||||
'metallic',
|
||||
'metalness',
|
||||
'occlusionRoughnessMetallic',
|
||||
'height',
|
||||
'opacity',
|
||||
] as const
|
||||
@@ -14,11 +11,24 @@ export const ASSET_FAMILIES = [
|
||||
export type AssetFamily = typeof ASSET_FAMILIES[number]
|
||||
|
||||
const ASSET_FAMILY_BY_KEY = new Map(ASSET_FAMILIES.map((family) => [family.toLowerCase(), family]))
|
||||
const FORBIDDEN_ASSET_FAMILY_ALIASES: ReadonlyMap<string, AssetFamily> = new Map([
|
||||
['basecolor', 'color'],
|
||||
['base_color', 'color'],
|
||||
['normalopengl', 'normal'],
|
||||
['normal_opengl', 'normal'],
|
||||
['metallic', 'metalness'],
|
||||
['occlusionroughnessmetallic', 'roughness'],
|
||||
['occlusion_roughness_metallic', 'roughness'],
|
||||
])
|
||||
|
||||
export function getAssetFamily(value: string): AssetFamily | undefined {
|
||||
return ASSET_FAMILY_BY_KEY.get(value.toLowerCase())
|
||||
}
|
||||
|
||||
export function getForbiddenAssetFamilyAlias(value: string): AssetFamily | undefined {
|
||||
return FORBIDDEN_ASSET_FAMILY_ALIASES.get(value.toLowerCase())
|
||||
}
|
||||
|
||||
export function formatAssetFamilies() {
|
||||
return ASSET_FAMILIES.join(', ')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user