feat(PBR): extract Blender PBR properties and apply in 3D viewer

Extract Base Color, Metallic, Roughness, Transmission, IOR from Blender
asset library materials via catalog_assets.py. Store in catalog JSON and
serve via /api/asset-libraries/pbr-map endpoint. Frontend viewers apply
PBR properties to Three.js MeshStandardMaterial using hex color strings
(avoiding Three.js ColorManagement sRGB/linear issues).

Key fixes:
- RLS bypass for material alias lookup in pbr-map endpoint
- pbrMap empty guard prevents premature grey fallback in viewers
- Cache-Control: no-cache on pbr-map requests to avoid stale data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 10:37:23 +01:00
parent 577dd1ca7e
commit d843162e5f
12 changed files with 764 additions and 351 deletions
+35 -1
View File
@@ -1,7 +1,41 @@
import api from './client'
// ---------------------------------------------------------------------------
// PBR material properties (from Blender Principled BSDF)
// ---------------------------------------------------------------------------
export interface MaterialPBR {
base_color: [number, number, number] // sRGB 0-1
metallic: number // 0-1
roughness: number // 0-1
transmission?: number // 0-1
ior?: number // typically 1.45
}
export type MaterialPBRMap = Record<string, MaterialPBR>
export async function fetchMaterialPBR(): Promise<MaterialPBRMap> {
const { data } = await api.get<MaterialPBRMap>('/asset-libraries/pbr-map', {
headers: { 'Cache-Control': 'no-cache' },
})
return data
}
// ---------------------------------------------------------------------------
// Asset library catalog
// ---------------------------------------------------------------------------
export interface AssetLibraryCatalogMaterial {
name: string
base_color?: number[]
metallic?: number
roughness?: number
transmission?: number
ior?: number
}
export interface AssetLibraryCatalog {
materials: string[]
materials: Array<string | AssetLibraryCatalogMaterial>
node_groups: string[]
}