- Add MaterialSchema with 10 presets (white, brick, concrete, wood, glass, metal, plaster, tile, marble, custom) - Add material field to Wall, Slab, Door, Window, Ceiling, Roof, RoofSegment nodes - Create MaterialPicker UI component with preset selection and custom properties - Update all renderers to support material rendering with caching - Add Material section to all node panels (WallPanel, SlabPanel, DoorPanel, WindowPanel, CeilingPanel, RoofPanel, RoofSegmentPanel) - Update AGENTS.md with Material System documentation
24 lines
773 B
TypeScript
24 lines
773 B
TypeScript
import { type SlabNode, useRegistry } from '@pascal-app/core'
|
|
import { useMemo, useRef } from 'react'
|
|
import type { Mesh } from 'three'
|
|
import { useNodeEvents } from '../../../hooks/use-node-events'
|
|
import { createMaterial, DEFAULT_SLAB_MATERIAL } from '../../../lib/materials'
|
|
|
|
export const SlabRenderer = ({ node }: { node: SlabNode }) => {
|
|
const ref = useRef<Mesh>(null!)
|
|
|
|
useRegistry(node.id, 'slab', ref)
|
|
|
|
const handlers = useNodeEvents(node, 'slab')
|
|
|
|
const material = useMemo(() => {
|
|
return node.material ? createMaterial(node.material) : DEFAULT_SLAB_MATERIAL
|
|
}, [node.material])
|
|
|
|
return (
|
|
<mesh castShadow receiveShadow ref={ref} {...handlers} visible={node.visible} material={material}>
|
|
<boxGeometry args={[0, 0, 0]} />
|
|
</mesh>
|
|
)
|
|
}
|