fix: enforce asset naming convention
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
import { getAssetFamily } from './asset-naming'
|
||||
|
||||
export type AssetCategory = 'color' | 'roughness' | 'normal' | 'metalness' | 'assets'
|
||||
|
||||
export function classifyAssetCategory(filename: string): AssetCategory {
|
||||
const name = filename.toLowerCase().replace(/\.[^.]+$/, '')
|
||||
const name = filename.replace(/\.[^.]+$/, '')
|
||||
const family = getAssetFamily(name.split('_')[0])
|
||||
|
||||
if (name.includes('base_color') || name.includes('_color') || name === 'color') {
|
||||
if (family === 'baseColor' || family === 'color') {
|
||||
return 'color'
|
||||
}
|
||||
|
||||
if (name.includes('roughness')) {
|
||||
if (family === 'roughness' || family === 'occlusionRoughnessMetallic') {
|
||||
return 'roughness'
|
||||
}
|
||||
|
||||
if (name.includes('normal')) {
|
||||
if (family === 'normal' || family === 'normalOpengl') {
|
||||
return 'normal'
|
||||
}
|
||||
|
||||
if (name.includes('metallic') || name.includes('metalness')) {
|
||||
if (family === 'metallic' || family === 'metalness') {
|
||||
return 'metalness'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user