// Abschnitt „Kamera" der Objekt-Info ([213]): Standpunkt und Augenhöhe, Ziel, Bildwinkel/Brennweite, Projektion,
// Sonnenstand und die Aktionen „Kamera öffnen" / „Aus aktueller Ansicht" / „Isometrisch". Jede Änderung ein Undo-Schritt
// (der Kern prüft die Op); bei mehreren gewählten Kameras wirken die Auswahlfelder auf alle.
import type { Camera, CameraProjection } from "../../model/types";
import { useStore } from "../../state/appStore";
import { openCamera, updateCameraFromView } from "../../state/cameraActions";
import { t } from "../../i18n";
import type { TranslationKey } from "../../i18n";
import { patchItem } from "../../core";
import { Dropdown } from "../../ui/Dropdown";
import { clampFov, focalFromFov, fovFromFocal, isometricAim } from "../../viewport/cameraView";
import { DimensionField } from "./fields";
const PROJECTIONS: CameraProjection[] = ["perspective", "axonometric", "parallel"];
/** ISO-UTC-Text → Wert für `` (UTC-Anzeige, ohne Zeitzonen-Überraschung). */
function toLocalInput(iso: string | undefined): string {
if (!iso) return "";
const d = new Date(iso);
return Number.isFinite(d.getTime()) ? d.toISOString().slice(0, 16) : "";
}
export function CameraSection({ ids }: { ids: readonly string[] }) {
const project = useStore((st) => st.project);
const applyChange = useStore((s) => s.applyChange);
const cams = (project.cameras ?? []).filter((x) => ids.includes(x.id));
const cam = cams[0];
if (!cam) return
;
const locked = !!cam.locked;
const set = (patch: Partial, all = false) =>
applyChange((p) => (all ? cams : [cam]).filter((x) => !x.locked).flatMap((x) => patchItem(p, "cameras", x.id, patch)));
const level = project.drawingLevels.find((l) => l.id === cam.floorId);
const parallel = cam.projection !== "perspective";
return (
{cams.length > 1 ? t("objinfo.camera.many", { n: cams.length }) : t("objinfo.kind.camera")}
{t("objinfo.camera.section")}
{t("objinfo.camera.projection")}
set({ projection: v as CameraProjection }, true)}
options={PROJECTIONS.map((v) => ({ value: v, label: t(`objinfo.camera.projection.${v}` as TranslationKey) }))}
title={t("objinfo.camera.projection")}
width={150}
/>
{t("objinfo.camera.stand")}
set({ position: { x: v, y: cam.position.y } })} />
set({ position: { x: cam.position.x, y: v } })} />
set({ eyeHeight: v })} />
{t("objinfo.camera.target")}
set({ target: { x: v, y: cam.target.y } })} />
set({ target: { x: cam.target.x, y: v } })} />
set({ targetHeight: v })} />
{parallel ? (
set({ orthoHeight: v })} />
) : (
<>
set({ fovDeg: clampFov(v) })} />
set({ fovDeg: clampFov(fovFromFocal(v)) })}
/>
>
)}
{t("objinfo.column.floor")}
{level?.name ?? cam.floorId}
{parallel && (
)}
{locked && {t("objinfo.camera.locked")}
}
);
}