Brings slab, ceiling, and wall onto the unified slot contract the shelf established, so each declares its paintable slots with a declarative default and (slab/ceiling) is painted through the registry capabilities.paint dispatch. - Shared helper packages/nodes/src/shared/slot-paint.ts: a node.slots-based PaintCapability factory (commit/resolve/effective generic; preview injected). Distinct from surface-paint.ts, which writes the legacy inline node.material. - slab: schema slots; def.geometry resolves node.slots.surface -> legacy material -> declared default, tags the mesh userData.slotId; slabPaint + capabilities.slots. Retires DEFAULT_SLAB_MATERIAL in the slab path. - ceiling: schema slots; material builders extracted to ceiling/materials.ts (shared by renderer + paint preview, built BackSide so the hover preview is visible from below); renderer resolves the slot; ceilingPaint + slots. - wall: WALL_SLOT_DEFAULT in core; the viewer's getMaterialsForWall renders an unpainted face with its declared default instead of the themed wall role; capabilities.slots (interior/exterior). wallPaint's inline interior/exterior fields are unchanged (node.slots migration is a later step). - selection-manager + material-paint: drop slab/ceiling from the legacy single-surface arms (now registry-driven). Behavior change (intended, matches the shelf precedent + the phase-5 plan): colored-mode UNPAINTED slab/ceiling/wall surfaces now render their fixed slot default (#e5e5e5 / #f5f5dc / #ffffff) instead of the theme role colour. The textures-off (monochrome) role collapse is unchanged — the escape hatch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import {
|
|
type AnyNode,
|
|
type CeilingNode,
|
|
getMaterialPresetByRef,
|
|
resolveMaterial,
|
|
} from '@pascal-app/core'
|
|
import type { Mesh } from 'three'
|
|
import { createSlotPaintCapability } from '../shared/slot-paint'
|
|
import { getCeilingMaterials } from './materials'
|
|
|
|
/**
|
|
* Ceiling paint on the unified slot model. A ceiling has one paintable surface,
|
|
* so every hit resolves to `surface`; commit writes `node.slots.surface`. The
|
|
* preview swaps the registered underside mesh to the ceiling's own flat-tinted
|
|
* material (built `BackSide`, the way it renders), so the hover preview matches
|
|
* the committed result — a generic PBR preview would be invisible from below.
|
|
*/
|
|
export const ceilingPaint = createSlotPaintCapability({
|
|
resolveRole: () => 'surface',
|
|
applyPreview: ({ material, materialPreset, root }) => {
|
|
const color = materialPreset
|
|
? (getMaterialPresetByRef(materialPreset)?.mapProperties.color ?? null)
|
|
: material
|
|
? (resolveMaterial(material).color ?? null)
|
|
: null
|
|
if (!color) return () => {}
|
|
const mesh = root as Mesh
|
|
if (!mesh.isMesh) return null
|
|
const previous = mesh.material
|
|
mesh.material = getCeilingMaterials(color).bottomMaterial
|
|
return () => {
|
|
mesh.material = previous
|
|
}
|
|
},
|
|
legacyEffective: (node: AnyNode) => {
|
|
const ceiling = node as CeilingNode
|
|
if (ceiling.materialPreset || ceiling.material) {
|
|
return { material: ceiling.material, materialPreset: ceiling.materialPreset }
|
|
}
|
|
return null
|
|
},
|
|
})
|