[213] Kameras als Modell-Elemente und Begehen (WASD) im 3D
Project.cameras (Rust Camera: Standpunkt + Augenhöhe über Geschoss, Ziel, Bildwinkel, Perspektive/ Axonometrie/Parallel, Sonnenstand) auf der neuen Klasse "Kameras" (92). Grundriss-Symbol im Kern (plan/cameras.rs: Gehäuse, Sichtkegel, Ziel, Name, schmale Pick-Bänder), Griffe im Kern (camera.rs, grips.rs: Standpunkt, Ziel, Bildwinkel/Sichtbreite), Auswahl/Entf, Objekt-Info CameraSection, Liste im Panel Ausschnitte, "Kamera aus aktueller Ansicht anlegen", "Kamera öffnen" (auch per Doppelklick auf das Symbol), cameraToView() für das Rendering [211]. Begehen im 3D: Umschalt+F, W/A/S/D/Pfeile, Q/E, Umschalt/Alt, Umschauen um den Augpunkt (viewport/walk.ts). Beispiel: Kamera im Musterhaus komplex.
This commit is contained in:
64 files changed
+2031
-50
No files matched your search
@@ -0,0 +1,75 @@
|
||||
// Gruppe „Kameras" im Ausschnitte-Panel ([213]): die gespeicherten Kameras des Projekts als Liste. Klick wählt die
|
||||
// Kamera (Objekt-Info, Symbol im Grundriss), Doppelklick bzw. „↗" setzt die 3D-Ansicht exakt, „+" legt aus der
|
||||
// aktuellen 3D-Ansicht eine neue an, „✕" löscht. Die Kameras selbst sind Modell-Elemente (`Project.cameras`).
|
||||
|
||||
import { removeItems } from "../core";
|
||||
import { t } from "../i18n";
|
||||
import { createCameraFromView, openCamera } from "../state/cameraActions";
|
||||
import { getState, useStore } from "../state/appStore";
|
||||
import { fromIds } from "../state/selection";
|
||||
|
||||
export function CamerasGroup() {
|
||||
const cameras = useStore((s) => s.project.cameras);
|
||||
const levels = useStore((s) => s.project.drawingLevels);
|
||||
const selected = useStore((s) => s.selection.cameras);
|
||||
const list = cameras ?? [];
|
||||
return (
|
||||
<section className="nav-group" data-testid="cameras-group">
|
||||
<header className="nav-group-head">
|
||||
<span className="nav-group-title">{t("camera.title")}</span>
|
||||
<span className="nav-group-actions">
|
||||
<button className="nav-add" style={{ display: "inline-flex", padding: "1px 5px" }} title={t("camera.createFromView")} data-testid="camera-create" onClick={() => createCameraFromView()}>
|
||||
+
|
||||
</button>
|
||||
</span>
|
||||
</header>
|
||||
{list.length === 0 ? (
|
||||
<div style={{ padding: "10px 10px", fontSize: 12, color: "var(--muted)" }}>{t("camera.empty")}</div>
|
||||
) : (
|
||||
<div className="nav-list">
|
||||
{list.map((c) => (
|
||||
<div
|
||||
key={c.id}
|
||||
className={`nav-row${selected.includes(c.id) ? " active" : ""}`}
|
||||
data-testid={`camera-row-${c.id}`}
|
||||
title={t("camera.rowHint")}
|
||||
onClick={() => getState().setSelection(fromIds("cameras", [c.id]))}
|
||||
onDoubleClick={() => void openCamera(c.id)}
|
||||
style={{ display: "flex", alignItems: "center", gap: 4, paddingLeft: 10 }}
|
||||
>
|
||||
<span className="nav-label" style={{ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
|
||||
{c.name}
|
||||
<span style={{ color: "var(--muted)", marginLeft: 6 }}>{levels.find((l) => l.id === c.floorId)?.name ?? ""}</span>
|
||||
</span>
|
||||
<button
|
||||
className="nav-add"
|
||||
style={{ padding: "1px 5px" }}
|
||||
title={t("camera.open")}
|
||||
data-testid={`camera-open-${c.id}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
void openCamera(c.id);
|
||||
}}
|
||||
>
|
||||
↗
|
||||
</button>
|
||||
<button
|
||||
className="nav-add"
|
||||
style={{ padding: "1px 5px" }}
|
||||
title={t("camera.delete")}
|
||||
disabled={!!c.locked}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
getState().applyChange((p) => removeItems(p, "cameras", [c.id]));
|
||||
getState().setSelection(fromIds("cameras", []));
|
||||
}}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import { ContextObjectProps } from "./ContextObjectProps";
|
||||
import { SunStudySection } from "./SunStudySection";
|
||||
import { SiteRulesSection } from "./SiteRulesSection";
|
||||
import { TreeSection } from "./objectInfo/TreeSection";
|
||||
import { CameraSection } from "./objectInfo/CameraSection";
|
||||
import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks";
|
||||
import { DimensionField, RotateField } from "./objectInfo/fields";
|
||||
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
|
||||
@@ -73,6 +74,7 @@ export function ObjectInfoPanel() {
|
||||
// [137] Lage-Darstellung angeklickt (Schattenfläche / Baurechtslinie): Einstellungen der Quelle.
|
||||
const site = useStore((s) => s.selection.site);
|
||||
const treeSel = useStore((s) => s.selection.trees);
|
||||
const cameraSel = useStore((s) => s.selection.cameras);
|
||||
const ctxObj = sel?.kind === "contextObject" ? (storeProject.context ?? []).find((o) => o.id === sel.id) : undefined;
|
||||
const quantities = useMemo(
|
||||
() => (ctxObj?.type === "excavation" ? excavationQuantities(storeProject) : []),
|
||||
@@ -82,6 +84,8 @@ export function ObjectInfoPanel() {
|
||||
// ── Leerzustand ───────────────────────────────────────────────────────────
|
||||
// [149] Baum gewählt: eigene Felder (Lage, Masse, Form, Bestand).
|
||||
if (sel === null && treeSel.length > 0) return <TreeSection ids={treeSel} />;
|
||||
// [213] Kamera gewählt: Standpunkt, Ziel, Bildwinkel, Projektion, Sonne und „Kamera öffnen".
|
||||
if (sel === null && cameraSel.length > 0) return <CameraSection ids={cameraSel} />;
|
||||
if (sel === null && site[0] === "viewShadows") return <ViewShadowsInfo />;
|
||||
if (sel === null && site.length > 0) {
|
||||
const sun = site[0] === "sunStudy";
|
||||
|
||||
@@ -39,6 +39,7 @@ import { applyToSnapshotOps } from "../state/viewTemplates";
|
||||
import { getState } from "../state/appStore";
|
||||
import { patchItem } from "../core";
|
||||
import { t } from "../i18n";
|
||||
import { CamerasGroup } from "./CamerasGroup";
|
||||
|
||||
// ── Baum-Icons (inline-SVG im Panel-Stil: 14px, stroke currentColor 1.4) ──────
|
||||
|
||||
@@ -518,6 +519,7 @@ export function ViewSnapshotsPanel() {
|
||||
tree.rootFolders.length === 0 && tree.rootSnapshots.length === 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
<section className="nav-group">
|
||||
<header className="nav-group-head">
|
||||
<span className="nav-group-title">{t("viewsnap.title")}</span>
|
||||
@@ -687,6 +689,9 @@ export function ViewSnapshotsPanel() {
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
{/* [213] Kameras des Projekts (öffnen, anlegen, löschen). */}
|
||||
<CamerasGroup />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
// 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 `<input type="datetime-local">` (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 <div className="objinfo-panel"><div className="objinfo-empty">{t("objinfo.empty")}</div></div>;
|
||||
const locked = !!cam.locked;
|
||||
const set = (patch: Partial<Camera>, 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 (
|
||||
<div className="objinfo-panel objinfo-camera" data-testid="camera-section">
|
||||
<div className="objinfo-head">
|
||||
<span className="objinfo-kind">{cams.length > 1 ? t("objinfo.camera.many", { n: cams.length }) : t("objinfo.kind.camera")}</span>
|
||||
</div>
|
||||
<div className="objinfo-section-label">{t("objinfo.camera.section")}</div>
|
||||
<label className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.camera.name")}</span>
|
||||
<input
|
||||
className="objinfo-text"
|
||||
type="text"
|
||||
defaultValue={cam.name}
|
||||
key={`nm-${cam.id}-${cam.name}`}
|
||||
disabled={locked}
|
||||
data-testid="camera-name"
|
||||
onBlur={(e) => {
|
||||
const v = e.target.value.trim();
|
||||
if (v && v !== cam.name) set({ name: v });
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") (e.target as HTMLInputElement).blur();
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.camera.projection")}</span>
|
||||
<Dropdown
|
||||
value={cam.projection}
|
||||
onChange={(v) => 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}
|
||||
/>
|
||||
</div>
|
||||
<div className="objinfo-section-label">{t("objinfo.camera.stand")}</div>
|
||||
<DimensionField label="X" value={cam.position.x} min={-Infinity} onCommit={(v) => set({ position: { x: v, y: cam.position.y } })} />
|
||||
<DimensionField label="Y" value={cam.position.y} min={-Infinity} onCommit={(v) => set({ position: { x: cam.position.x, y: v } })} />
|
||||
<DimensionField label={t("objinfo.camera.eyeHeight")} value={cam.eyeHeight} min={0} onCommit={(v) => set({ eyeHeight: v })} />
|
||||
<div className="objinfo-section-label">{t("objinfo.camera.target")}</div>
|
||||
<DimensionField label="X" value={cam.target.x} min={-Infinity} onCommit={(v) => set({ target: { x: v, y: cam.target.y } })} />
|
||||
<DimensionField label="Y" value={cam.target.y} min={-Infinity} onCommit={(v) => set({ target: { x: cam.target.x, y: v } })} />
|
||||
<DimensionField label={t("objinfo.camera.targetHeight")} value={cam.targetHeight} min={-Infinity} onCommit={(v) => set({ targetHeight: v })} />
|
||||
{parallel ? (
|
||||
<DimensionField label={t("objinfo.camera.orthoHeight")} value={cam.orthoHeight ?? 10} min={0.1} onCommit={(v) => set({ orthoHeight: v })} />
|
||||
) : (
|
||||
<>
|
||||
<DimensionField label={t("objinfo.camera.fov")} value={cam.fovDeg} min={5} unit="°" step={1} digits={1} onCommit={(v) => set({ fovDeg: clampFov(v) })} />
|
||||
<DimensionField
|
||||
label={t("objinfo.camera.focal")}
|
||||
value={focalFromFov(cam.fovDeg)}
|
||||
min={5}
|
||||
unit="mm"
|
||||
step={1}
|
||||
digits={1}
|
||||
onCommit={(v) => set({ fovDeg: clampFov(fovFromFocal(v)) })}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<label className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.camera.sun")}</span>
|
||||
<input
|
||||
className="objinfo-text"
|
||||
type="datetime-local"
|
||||
value={toLocalInput(cam.sunWhen)}
|
||||
disabled={locked}
|
||||
title={t("objinfo.camera.sunHint")}
|
||||
data-testid="camera-sun"
|
||||
onChange={(e) => {
|
||||
const v = e.target.value;
|
||||
if (!v) {
|
||||
set({ sunWhen: undefined });
|
||||
return;
|
||||
}
|
||||
const d = new Date(`${v}:00Z`);
|
||||
if (Number.isFinite(d.getTime())) set({ sunWhen: d.toISOString().replace(".000Z", "Z") });
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.column.floor")}</span>
|
||||
<span className="objinfo-fval">{level?.name ?? cam.floorId}</span>
|
||||
</div>
|
||||
<div className="objinfo-actions">
|
||||
<button type="button" className="btn" data-testid="camera-open" onClick={() => void openCamera(cam.id)}>
|
||||
{t("camera.open")}
|
||||
</button>
|
||||
<button type="button" className="btn" disabled={locked} data-testid="camera-update" onClick={() => updateCameraFromView(cam.id)} title={t("camera.updateHint")}>
|
||||
{t("camera.update")}
|
||||
</button>
|
||||
{parallel && (
|
||||
<button type="button" className="btn" disabled={locked} data-testid="camera-iso" onClick={() => set(isometricAim(project, cam))} title={t("camera.isoHint")}>
|
||||
{t("camera.iso")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{locked && <div className="objinfo-muted">{t("objinfo.camera.locked")}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ const AREA_TITLE = { object: "objsettings.area.object", appearance: "objsettings
|
||||
export function ObjectSettingsPanel() {
|
||||
const host = usePanelHost();
|
||||
const sel = useSelectionInfo();
|
||||
const otherSelected = useStore((s) => s.selection.trees.length + s.selection.site.length > 0);
|
||||
const otherSelected = useStore((s) => s.selection.trees.length + s.selection.cameras.length + s.selection.site.length > 0);
|
||||
const isGrid = useStore((s) => (sel?.kind === "drawing2d" ? s.project.drawings2d.find((d) => d.id === sel.id)?.geom.shape === "grid" : false));
|
||||
const wanted = useSyncExternalStore(subscribeSettingsArea, getSettingsArea, getSettingsArea);
|
||||
|
||||
|
||||
Reference in new issue
Block a user