← back to Dw War Room
src/showroom/ShowroomMaterials.ts
105 lines
// ShowroomMaterials.ts — PBR material definitions for photorealistic showroom
import * as THREE from 'three';
import {
generateBrickNormalMap,
generateConcreteNormalMap,
generateBrushedAluminumNormalMap,
generateWoodNormalMap,
generateFabricNormalMap,
} from './ProceduralMaps';
export interface MaterialLibrary {
brick: THREE.MeshStandardMaterial;
concrete: THREE.MeshStandardMaterial;
aluminum: THREE.MeshStandardMaterial;
wood: THREE.MeshStandardMaterial;
fabric: THREE.MeshStandardMaterial;
steel: THREE.MeshStandardMaterial;
glass: THREE.MeshStandardMaterial;
trackLight: THREE.MeshStandardMaterial;
}
/**
* Create the full PBR material library for the showroom.
* Each material has proper normal maps for photorealistic surface detail.
*/
export function createMaterialLibrary(): MaterialLibrary {
return {
brick: new THREE.MeshStandardMaterial({
color: 0x8b4513,
metalness: 0.0,
roughness: 0.85,
normalMap: generateBrickNormalMap(),
normalScale: new THREE.Vector2(1.2, 1.2),
}),
concrete: new THREE.MeshStandardMaterial({
color: 0x8a8580,
metalness: 0.15,
roughness: 0.55,
normalMap: generateConcreteNormalMap(),
normalScale: new THREE.Vector2(0.5, 0.5),
}),
aluminum: new THREE.MeshStandardMaterial({
color: 0xc0c0c0,
metalness: 0.7,
roughness: 0.25,
normalMap: generateBrushedAluminumNormalMap(),
normalScale: new THREE.Vector2(0.3, 0.3),
envMapIntensity: 1.5,
}),
wood: new THREE.MeshStandardMaterial({
color: 0x8b6914,
metalness: 0.0,
roughness: 0.65,
normalMap: generateWoodNormalMap(),
normalScale: new THREE.Vector2(0.8, 0.8),
}),
fabric: new THREE.MeshStandardMaterial({
color: 0xf0ebe4,
metalness: 0.0,
roughness: 0.4,
normalMap: generateFabricNormalMap(),
normalScale: new THREE.Vector2(0.2, 0.2),
envMapIntensity: 0.3,
}),
steel: new THREE.MeshStandardMaterial({
color: 0x2a2a2a,
metalness: 0.6,
roughness: 0.3,
envMapIntensity: 1.0,
}),
glass: new THREE.MeshStandardMaterial({
color: 0xffffff,
metalness: 0.0,
roughness: 0.05,
transparent: true,
opacity: 0.15,
envMapIntensity: 2.0,
}),
trackLight: new THREE.MeshStandardMaterial({
color: 0xffffff,
metalness: 0.9,
roughness: 0.1,
emissive: new THREE.Color(0xf5e6d0),
emissiveIntensity: 0.8,
}),
};
}
/**
* Dispose all materials and their textures.
*/
export function disposeMaterialLibrary(lib: MaterialLibrary): void {
Object.values(lib).forEach(mat => {
if (mat.normalMap) mat.normalMap.dispose();
mat.dispose();
});
}