// Einstellungen eines Gelände-/Umgebungs-Elements (Netzkörper, Gelände, Baugrube) in der Objekt-Info ([137]: // ein angeklicktes Gelände bzw. eine Baugrube zeigt dort ihre Felder). Gelände zusätzlich: Sichtbarkeit seiner // Klasse und Glättung (aus den Höhenlinien neu erzeugt, ein Undo-Schritt); Raster-Gelände (swissALTI3D, ohne // Höhenlinien) additiv nachglätten. [181] Sichtbarkeit nur über die Klasse — kein Einzel-Ausblenden, keine Import-Liste. // // Bezeichner englisch, UI-Text/Kommentare deutsch. Alle sichtbaren Texte über t(...). import { t } from "../i18n"; import { usePanelHost } from "./host"; import { useStore } from "../state/appStore"; import type { ContextObject } from "../model/types"; import { flattenCategories } from "../model/types"; import { resmoothGridTerrain } from "../model/terrain"; import { useEffect, useMemo, useState } from "react"; import type { ExcavationQuantity } from "../core"; /** Zahl-Eingabe für ein Feld eines Kontext-Objekts (leer = Standard, ungültig = keine Änderung). */ export function NumField(props: { label: string; value: number | undefined; step: number; min?: number; placeholder?: string; /** Einheit hinter dem Feld (nicht im Label). */ unit?: string; title?: string; onChange: (v: number | undefined) => void; }) { return ( ); } const fmt1 = (v: number) => v.toLocaleString("de-CH", { maximumFractionDigits: 1, minimumFractionDigits: 1 }); function ExcavationQty({ q }: { q: ExcavationQuantity | undefined }) { if (!q) return
{t("site.excavation.noTerrain")}
; return (
{t("site.excavation.qty", { cut: fmt1(q.cut), fill: fmt1(q.fill), backfill: fmt1(q.backfill) })} {q.workingSpace > 0 && !q.workingSpaceOk && (
{t("site.excavation.workingSpaceWarn", { min: q.workingSpaceMin.toFixed(2), need: q.workingSpace.toFixed(2), n: q.workingSpaceSpots.length })}
)}
); } /** Glättungsstufen der Gelände-Erzeugung (`terrain.rs`, 0 = roh). */ const SMOOTH_LEVELS = [0, 1, 2, 3] as const; /** [137] Zusätzliche Glättungs-Durchgänge für Raster-Gelände. */ const RESMOOTH_PASSES = [1, 2, 4] as const; /** [193] Netzpunkt wählen (Nummer ab 1) und seine Höhe setzen; Zuschneiden des Netzes auf die Parzelle. */ function MeshPointFields({ obj }: { obj: Extract }) { const host = usePanelHost(); const setMeshPointHeight = useStore((s) => s.setMeshPointHeight); const cropMesh = useStore((s) => s.cropMesh); const notify = useStore((s) => s.notify); const parcel = useStore((s) => s.project.siteRules?.parcel); const deleteMeshPoint = useStore((s) => s.deleteMeshPoint); const active = useStore((s) => s.activeMeshPoint); const [nr, setNr] = useState("1"); // Klick auf einen Netzpunkt-Griff im Grundriss wählt den Punkt: Nummer (und damit Höhe) vorausgefüllt. const activeIndex = active?.id === obj.id ? active.index : null; useEffect(() => { if (activeIndex != null) setNr(String(activeIndex + 1)); }, [activeIndex]); const n = Math.floor(obj.positions.length / 3); const i = Math.round(Number(nr)) - 1; const valid = Number.isFinite(i) && i >= 0 && i < n; return ( <>
); } /** [193] Höhenversatz (alle Höhen um dz) und, bei Höhenlinien, die Höhe je Linie. */ function HeightFields({ obj }: { obj: ContextObject }) { const offsetContextHeight = useStore((s) => s.offsetContextHeight); const setContourHeight = useStore((s) => s.setContourHeight); const groundContextObjects = useStore((s) => s.groundContextObjects); const hasTerrain = useStore((s) => s.project.context?.some((c) => c.type === "terrainMesh") ?? false); const notify = useStore((s) => s.notify); const [dz, setDz] = useState(""); if (obj.type === "image") return null; const apply = () => { if (dz.trim() !== "") offsetContextHeight(obj.id, Number(dz.replace(",", "."))); setDz(""); }; return ( <> {obj.type === "importedMesh" && ( // [227] Kontextgebäude auf den tiefsten Geländepunkt unter dem Grundriss setzen.
)} {(obj.type === "terrainMesh" || obj.type === "importedMesh") && } {obj.type === "contourSet" && (
{t("site.contours", { n: obj.contours.length })}
{obj.contours.map((c, i) => ( ))}
)} ); } /** Felder eines Kontext-Objekts; `null` für Arten ohne eigene Einstellungen (Höhenlinien, Luftbild). */ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; quantities: readonly ExcavationQuantity[] }) { return ( <>
); } function KindFields({ obj, quantities }: { obj: ContextObject; quantities: readonly ExcavationQuantity[] }) { const host = usePanelHost(); const project = useStore((s) => s.project); const notify = useStore((s) => s.notify); const regenerateTerrain = useStore((s) => s.regenerateTerrain); const resmoothTerrain = useStore((s) => s.resmoothTerrain); // [137] Raster-Gelände (swissALTI3D) lässt sich ohne Höhenlinien nachglätten; Prüfung nur bei Netz-Wechsel. const terrainPositions = obj.type === "terrainMesh" ? obj.positions : null; const isGrid = useMemo(() => (terrainPositions ? resmoothGridTerrain(terrainPositions, 0) !== null : false), [terrainPositions]); const patch = (field: string) => (v: number | undefined) => host.onPatchContextObject(obj.id, { [field]: v }, `site-${obj.id}-${field}`); if (obj.type === "importedMesh") { // [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°). return (
{obj.smoothShading === true && ( )}
); } if (obj.type === "terrainMesh") { const cat = flattenCategories(project.layers).find((c) => c.code === obj.categoryCode); const hasSource = (project.context ?? []).some((o) => o.type === "contourSet"); return (
{cat && ( )} {hasSource && ( )} {!hasSource && ( )} {/* [212] Material der Oberfläche (Bauteil): Farbe und Bildkarten im 3D, Pathtracer und Blender-Paket. */}
); } if (obj.type === "excavation") { return (
v !== undefined && patch("bottom")(v)} />
{t("site.excavation.shoring")} {obj.outline.map((_, i) => ( ))}
{obj.edgeShoring?.some(Boolean) && ( <> )} x.id === obj.id)} />
); } return null; }