fix: validate texture asset names server-side
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import { getAssetFamily } from './asset-naming'
|
||||
|
||||
export type AssetCategory = 'color' | 'roughness' | 'normal' | 'metalness' | 'assets'
|
||||
export type AssetCategory = 'color' | 'diffuse' | 'roughness' | 'normal' | 'metalness' | 'opacity' | 'assets'
|
||||
|
||||
export function classifyAssetCategory(filename: string): AssetCategory {
|
||||
const name = filename.replace(/\.[^.]+$/, '')
|
||||
const family = getAssetFamily(name.split('_')[0])
|
||||
|
||||
if (family === 'color' || family === 'diffuse') {
|
||||
if (family === 'color') {
|
||||
return 'color'
|
||||
}
|
||||
|
||||
if (family === 'diffuse') {
|
||||
return 'diffuse'
|
||||
}
|
||||
|
||||
if (family === 'roughness') {
|
||||
return 'roughness'
|
||||
}
|
||||
@@ -22,5 +26,9 @@ export function classifyAssetCategory(filename: string): AssetCategory {
|
||||
return 'metalness'
|
||||
}
|
||||
|
||||
if (family === 'opacity') {
|
||||
return 'opacity'
|
||||
}
|
||||
|
||||
return 'assets'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user