// Ansichtsschraffur am Element ([100]): Drehung und Versatz des Oberflächenmusters je Wand bzw. Dach // (das Muster selbst gehört zum Bauteil der sichtbaren Schicht). Nur sichtbar, wenn ein Bauteil des // Elements ein Muster trägt. import { t } from "../i18n"; import type { usePanelHost } from "./host"; import { useStore } from "../state/appStore"; export function SurfacePatternPlacement({ kind, id, host, }: { kind: "wall" | "roof"; id: string; host: ReturnType; }) { const p = useStore((s) => s.project); const el = kind === "wall" ? p.walls.find((w) => w.id === id) : p.roofs?.find((r) => r.id === id); if (!el || !host.onSetSurfacePatternPlacement) return null; const typeId = kind === "wall" ? (el as { wallTypeId?: string }).wallTypeId : (el as { roofTypeId?: string }).roofTypeId; const types = kind === "wall" ? p.wallTypes : p.roofTypes ?? []; const layers = types.find((tp) => tp.id === typeId)?.layers ?? []; const hasPattern = layers.some((l) => p.components.find((c) => c.id === l.componentId)?.surfacePattern); if (!hasPattern) return null; const angle = el.surfacePatternAngle ?? 0; const off = el.surfacePatternOffset ?? { x: 0, y: 0 }; const set = host.onSetSurfacePatternPlacement; const field = (key: Parameters[0], value: number, step: number, apply: (v: number) => void) => (
{t(key)} { const v = Number(e.target.value); if (Number.isFinite(v)) apply(v); }} />
); return ( <>
{t("objinfo.surfacePattern")}
{field("objinfo.surfacePattern.angle", angle, 1, (v) => set({ surfacePatternAngle: v || undefined }))} {field("objinfo.surfacePattern.offsetX", off.x, 0.01, (x) => set({ surfacePatternOffset: { x, y: off.y } }))} {field("objinfo.surfacePattern.offsetY", off.y, 0.01, (y) => set({ surfacePatternOffset: { x: off.x, y } }))} ); }