[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:
Claude committed 2026-11-12 18:31:37 +00:00
1 parent b02b9232bd
commit ed475fe64b
64 files changed
+2031 -50

No files matched your search

+6
View File
@@ -153,6 +153,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
drawings: selectedDrawingIds,
site: selectedSite,
trees: selectedTreeIds,
cameras: selectedCameraIds,
} = selection;
const selectedDrawingId = single(selection, "drawings");
// Linke Maustaste liegt beim Werkzeug/der Transformation, wenn App das meldet
@@ -299,6 +300,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickSectionLine,
pickSiteAt,
pickTree,
pickCamera,
pickContextObject,
pickExtrudedSolid,
pickColumn,
@@ -401,6 +403,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickColumn,
pickExtrudedSolid,
pickTree,
pickCamera,
pickStair,
pickRoof,
pickSiteAt,
@@ -437,6 +440,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickRoom,
pickRoof,
pickTree,
pickCamera,
pickSiteAt,
pickContextObject,
pickSectionLine,
@@ -492,6 +496,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickRoom,
onOpenSectionLevel,
pickSectionLine,
pickCamera,
onContextMenu,
view,
viewToModel,
@@ -533,6 +538,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
selectedContextObjectIds,
selectedSite,
selectedTreeIds,
selectedCameraIds,
selectedSectionLineIds,
selectedExtrudedSolidIds,
selectedColumnIds,
+1
View File
@@ -35,6 +35,7 @@ const KIND_FIELD: Record<PickKind, SelectionKind> = {
drawing: "drawings",
solid: "solids",
tree: "trees",
camera: "cameras",
ceiling: "ceilings",
stair: "stairs",
room: "rooms",
+4 -1
View File
@@ -71,7 +71,7 @@ export const GRIP_HIT_PX = 9;
export const LINE_PICK_PX = 6;
export const PICK_ORDER: readonly PickKind[] = [
"section", "opening", "wall", "column", "drawing", "solid", "tree",
"section", "opening", "wall", "column", "drawing", "solid", "tree", "camera",
"ceiling", "stair", "room", "roof", "site", "context",
];
@@ -90,11 +90,14 @@ export const EMPTY_PICK: PickIds = {
contextObjectId: null,
siteId: null,
treeId: null,
cameraId: null,
};
/** Mac: Cmd+Klick; sonst Strg+Klick (Alt+Klick ist die Schere, Ctrl+Klick unter macOS das Kontextmenü). */
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
export const TREE_PICK = "@tree:";
/** [213] Präfix der Kamera-Pick-Id im Feld `contextObjectId` (Kern `camera::CAMERA_PICK_PREFIX`). */
export const CAMERA_PICK = "@camera:";
export const IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
export const cycleModifier = (e: { metaKey: boolean; ctrlKey: boolean }): boolean => (IS_MAC ? e.metaKey : e.ctrlKey);
+4
View File
@@ -156,6 +156,8 @@ export interface PlanSelection {
* Öffnung/Wand/Stütze/2D-Element/Körper getroffen wurde; Vorrang vor Decke, Raum, Dach und Gelände.
*/
treeId?: string | null;
/** [213] Getroffene Kamera (Sichtkegel/Gehäuse, Pick-Id `@camera:<id>` im Feld `contextObjectId`); Vorrang vor allem ausser Öffnung/Wand/Stütze/2D-Element/Körper/Baum. */
cameraId?: string | null;
/**
* War beim Klick Shift gedrückt? Dann ERWEITERT der Aufrufer (App) die
* Auswahl um das getroffene Element (bzw. schaltet es ab/zu), statt sie zu
@@ -185,6 +187,8 @@ export interface MarqueeSelection {
stairIds: string[];
/** [149] Getroffene Bäume (Kronenfläche, gleiche Konvention). */
treeIds?: string[];
/** [213] Getroffene Kameras (Pick-Flächen von Gehäuse und Sichtgrenzen, gleiche Konvention). */
cameraIds?: string[];
/**
* Zieh-Richtung: `false` = links→rechts (positiv Δx) → nur VOLLSTÄNDIG
* eingeschlossene Wände; `true` = rechts→links (negativ Δx) → auch berührte/
+7 -3
View File
@@ -6,7 +6,7 @@ import type { Primitive, OwnerField, PickKind } from "../../../core";
import { useMemo, useEffect } from "react";
import { planPrimAt } from "../../../core";
import { textFrameCorners } from "../../../text/textFrame";
import { TREE_PICK } from "./constants";
import { CAMERA_PICK, TREE_PICK } from "./constants";
import { PlanPickIndex } from "../../../core";
import type { Plan } from "../../../core";
import type { UnderlayGroup } from "../../../core";
@@ -36,6 +36,7 @@ export interface UsePlanHighlightsArgs {
selectedContextObjectIds: string[];
selectedSite: string[];
selectedTreeIds: string[];
selectedCameraIds?: string[];
selectedSectionLineIds: string[];
selectedExtrudedSolidIds: string[];
selectedColumnIds: string[];
@@ -64,6 +65,7 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
selectedContextObjectIds,
selectedSite,
selectedTreeIds,
selectedCameraIds,
selectedSectionLineIds,
selectedExtrudedSolidIds,
selectedColumnIds,
@@ -238,10 +240,11 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
...(selectedContextObjectIds ?? []),
...(selectedSite ?? []).map((s) => "@" + s),
...(selectedTreeIds ?? []).map((s) => TREE_PICK + s),
...(selectedCameraIds ?? []).map((s) => CAMERA_PICK + s),
];
if (!ids.length) return [];
return primsOwnedBy("contextObjectId", ids, (p): p is Extract<Primitive, { kind: "polygon" }> => p.kind === "polygon");
}, [plan, selectedContextObjectIds, selectedSite, selectedTreeIds]);
}, [plan, selectedContextObjectIds, selectedSite, selectedTreeIds, selectedCameraIds]);
// Hervorhebung der selektierten Schnitt-/Ansichtslinie: das (unsichtbare)
// Pick-Band (Polygon mit sectionLineId) mit Akzentkontur überzeichnen.
@@ -280,7 +283,8 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
if (!hoverPick) return [];
if (hoverPick.kind === "site") return primsOwnedBy("contextObjectId", ["@" + hoverPick.id], (_p): _p is Primitive => true);
if (hoverPick.kind === "tree") return primsOwnedBy("contextObjectId", [TREE_PICK + hoverPick.id], (_p): _p is Primitive => true);
const field: Record<Exclude<PickKind, "site" | "tree">, OwnerField> = {
if (hoverPick.kind === "camera") return primsOwnedBy("contextObjectId", [CAMERA_PICK + hoverPick.id], (_p): _p is Primitive => true);
const field: Record<Exclude<PickKind, "site" | "tree" | "camera">, OwnerField> = {
wall: "wallId", drawing: "drawingId", ceiling: "ceilingId", opening: "openingId",
stair: "stairId", room: "roomId", roof: "roofId", context: "contextObjectId",
section: "sectionLineId", solid: "extrudedSolidId", column: "columnId",
+16 -1
View File
@@ -10,7 +10,7 @@ import type { Vec2 } from "../../../model/types";
import type { PlainCycle } from "../pickCycle";
import { selectionHas, plainCycleNext, cycleHint } from "../pickCycle";
import { t } from "../../../i18n";
import { LINE_PICK_PX, TREE_PICK, PICK_ORDER, EMPTY_PICK, MARQUEE_THRESHOLD_PX, cycleModifier } from "./constants";
import { CAMERA_PICK, LINE_PICK_PX, TREE_PICK, PICK_ORDER, EMPTY_PICK, MARQUEE_THRESHOLD_PX, cycleModifier } from "./constants";
import { planPrimAt, drawingsWithinDistance } from "../../../core";
import type { ViewBox__plan_planView_geometry as ViewBox } from "../../../core";
import { PlanPickIndex } from "../../../core";
@@ -47,6 +47,7 @@ export interface UsePlanPickCycleArgs {
pickRoom: (clientX: number, clientY: number) => string | null;
pickRoof: (clientX: number, clientY: number) => string | null;
pickTree: (clientX: number, clientY: number) => string | null;
pickCamera: (clientX: number, clientY: number) => string | null;
pickSiteAt: (clientX: number, clientY: number) => string | null;
pickContextObject: (clientX: number, clientY: number) => string | null;
pickSectionLine: (clientX: number, clientY: number) => string | null;
@@ -99,6 +100,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
pickRoom,
pickRoof,
pickTree,
pickCamera,
pickSiteAt,
pickContextObject,
pickSectionLine,
@@ -256,6 +258,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
add("drawing", dp.drawingId, dp.hitIndex);
add("solid", dp.extrudedSolidId, dp.hitIndex);
add("tree", dp.treeId, dp.hitIndex);
add("camera", dp.cameraId, dp.hitIndex);
add("ceiling", dp.ceilingId, dp.hitIndex);
add("stair", dp.stairId, dp.hitIndex);
add("room", dp.roomId, dp.hitIndex);
@@ -283,6 +286,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
addRest("room", p.roomId, idx);
addRest("roof", p.roofId, idx);
if (p.contextObjectId?.startsWith(TREE_PICK)) addRest("tree", p.contextObjectId.slice(TREE_PICK.length), idx);
else if (p.contextObjectId?.startsWith(CAMERA_PICK)) addRest("camera", p.contextObjectId.slice(CAMERA_PICK.length), idx);
else if (p.contextObjectId?.startsWith("@")) addRest("site", p.contextObjectId.slice(1), idx);
else addRest("context", p.contextObjectId, idx);
addRest("section", p.sectionLineId, idx);
@@ -295,6 +299,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
addRest("room", pickRoom(clientX, clientY), null);
addRest("roof", pickRoof(clientX, clientY), null);
addRest("tree", pickTree(clientX, clientY), null);
addRest("camera", pickCamera(clientX, clientY), null);
addRest("site", pickSiteAt(clientX, clientY), null);
addRest("context", pickContextObject(clientX, clientY), null);
addRest("section", pickSectionLine(clientX, clientY), null);
@@ -333,6 +338,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
contextObjectId: c.kind === "context" ? c.id : null,
siteId: c.kind === "site" ? c.id : null,
treeId: c.kind === "tree" ? c.id : null,
cameraId: c.kind === "camera" ? c.id : null,
});
};
@@ -532,6 +538,15 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
.marquee("contextObjectId", rect, crossing)
.filter((id) => id.startsWith(TREE_PICK))
.map((id) => id.slice(TREE_PICK.length)),
// [213] Kameras: Pick-Flächen (`contextObjectId = "@camera:<id>"`).
cameraIds: [
...new Set(
getPick()
.marquee("contextObjectId", rect, crossing)
.filter((id) => id.startsWith(CAMERA_PICK))
.map((id) => id.slice(CAMERA_PICK.length)),
),
],
crossing,
});
}
+9 -2
View File
@@ -4,7 +4,7 @@
import type { GroupableHit, BodyTarget } from "./types";
import { planPrimAt, nearestInDrawings, marqueeHitUnderlay } from "../../../core";
import { LINE_PICK_PX, TREE_PICK } from "./constants";
import { CAMERA_PICK, LINE_PICK_PX, TREE_PICK } from "./constants";
import type { Primitive, ModelRect } from "../../../core";
import type { Vec2 } from "../../../model/types";
import { useState, useRef, useEffect } from "react";
@@ -257,7 +257,7 @@ export function usePlanPicking(inp: UsePlanPickingArgs) {
// [137] Getroffene Lage-Darstellung: Quelle `"sunStudy"`/`"siteRules"` (Baurechtslinie vor Schatten) oder null.
const pickSiteAt = (clientX: number, clientY: number): string | null => {
const all = contextIdsAt(clientX, clientY).filter((id) => !id.startsWith(TREE_PICK));
const all = contextIdsAt(clientX, clientY).filter((id) => !id.startsWith(TREE_PICK) && !id.startsWith(CAMERA_PICK));
// [193] Liegt ein Kontext-Element (Baugrube, Netz) über der Schattenfläche, gehört der Klick ihm — sonst wäre
// die Baugrube unter dem Schatten des Hauses nicht anzuwählen. Die Baurechtslinie (unsichtbares Band) gewinnt immer.
if (all.includes("@siteRules")) return "siteRules";
@@ -271,6 +271,12 @@ export function usePlanPicking(inp: UsePlanPickingArgs) {
return id ? id.slice(TREE_PICK.length) : null;
};
// [213] Getroffene Kamera (oberste Pickfläche aus Gehäuse und Sichtkegel) oder null.
const pickCamera = (clientX: number, clientY: number): string | null => {
const id = contextIdsAt(clientX, clientY).find((x) => x.startsWith(CAMERA_PICK));
return id ? id.slice(CAMERA_PICK.length) : null;
};
const pickContextObject = (clientX: number, clientY: number): string | null =>
contextIdsAt(clientX, clientY).find((id) => !id.startsWith("@")) ?? null;
@@ -407,6 +413,7 @@ export function usePlanPicking(inp: UsePlanPickingArgs) {
pickSectionLine,
pickSiteAt,
pickTree,
pickCamera,
pickContextObject,
pickExtrudedSolid,
pickColumn,
+12 -6
View File
@@ -76,6 +76,7 @@ export interface UsePlanPointerArgs {
pickColumn: (clientX: number, clientY: number) => string | null;
pickExtrudedSolid: (clientX: number, clientY: number) => string | null;
pickTree: (clientX: number, clientY: number) => string | null;
pickCamera: (clientX: number, clientY: number) => string | null;
pickStair: (clientX: number, clientY: number) => string | null;
pickRoof: (clientX: number, clientY: number) => string | null;
pickSiteAt: (clientX: number, clientY: number) => string | null;
@@ -141,6 +142,7 @@ export function usePlanPointer(inp: UsePlanPointerArgs) {
pickColumn,
pickExtrudedSolid,
pickTree,
pickCamera,
pickStair,
pickRoof,
pickSiteAt,
@@ -616,27 +618,30 @@ export function usePlanPointer(inp: UsePlanPointerArgs) {
// [149] Baum (Kronenfläche) vor Decke, Raum, Dach und Gelände.
const treeId =
openingId || wallId || columnId || drawingId || extrudedSolidId ? null : pickTree(clientX, clientY);
// [213] Kamera (schmale Pickflächen von Gehäuse, Sichtgrenzen und Ziel) wie der Baum vor Decke, Raum, Dach.
const cameraId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId ? null : pickCamera(clientX, clientY);
// Decke nur, wenn weder Öffnung/Wand noch 2D-Element getroffen wurde. Da die
// Decken-Polygone UNTER der Wand-Poché liegen, trifft ein direkter Klick
// auf die Wand zuerst die Wand; freie Deckenfläche trifft die Decke.
const hitCeilingId =
hit && hit.kind === "polygon" ? hit.ceilingId ?? null : null;
const ceilingId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId ? null : hitCeilingId;
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId ? null : hitCeilingId;
// Treppe nur, wenn nichts anderes getroffen wurde (Tritte liegen frei).
const stairId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId || ceilingId
? null
: pickStair(clientX, clientY);
// Raum als vorletzte Priorität: die Raum-Fläche liegt UNTER allem anderen.
const roomId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId || ceilingId || stairId
? null
: pickRoom(clientX, clientY);
// Dach als LETZTE Priorität: die Traufe-Fläche deckt den ganzen Grundriss
// ab, daher erst wählen, wenn wirklich nichts anderes getroffen wurde.
const roofId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId || ceilingId || stairId || roomId
? null
: pickRoof(clientX, clientY);
// Kontext-Objekt (Gebäude/Terrain) als ALLERLETZTE Priorität — seine
@@ -644,11 +649,11 @@ export function usePlanPointer(inp: UsePlanPointerArgs) {
// nichts anderes getroffen wurde.
// [137] Schatten/Baurechtslinien (Lage-Darstellung) über dem Gelände, unter allen Bauteilen.
const siteId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId || roofId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId || ceilingId || stairId || roomId || roofId
? null
: pickSiteAt(clientX, clientY);
const contextObjectId =
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || ceilingId || stairId || roomId || roofId || siteId
openingId || wallId || columnId || drawingId || extrudedSolidId || treeId || cameraId || ceilingId || stairId || roomId || roofId || siteId
? null
: pickContextObject(clientX, clientY);
return {
@@ -666,6 +671,7 @@ export function usePlanPointer(inp: UsePlanPointerArgs) {
contextObjectId,
siteId,
treeId,
cameraId,
};
};
@@ -1,6 +1,7 @@
// Rad-Zoom, Doppelklick und Kontextmenü der Plan-Ansicht ([165] aus `PlanView.tsx`). Im GPU-Pfad zoomt
// das Rad imperativ und schreibt den Ausschnitt nach kurzer Ruhe fest. Aufgerufen einmal von `PlanView`.
import { openCamera } from "../../../state/cameraActions";
import type { ViewBox__plan_planView_geometry as ViewBox } from "../../../core";
import type { Vec2 } from "../../../model/types";
import { clamp } from "../../../core";
@@ -32,6 +33,7 @@ export interface UsePlanZoomInputArgs {
pickRoom: (clientX: number, clientY: number) => string | null;
onOpenSectionLevel: ((levelId: string) => void) | undefined;
pickSectionLine: (clientX: number, clientY: number) => string | null;
pickCamera: (clientX: number, clientY: number) => string | null;
onContextMenu: ((info: { clientX: number; clientY: number; model: Vec2; }) => void) | undefined;
view: ViewBox;
viewToModel: (vbX: number, vbY: number) => Vec2;
@@ -60,6 +62,7 @@ export function usePlanZoomInput(inp: UsePlanZoomInputArgs) {
pickRoom,
onOpenSectionLevel,
pickSectionLine,
pickCamera,
onContextMenu,
view,
viewToModel,
@@ -163,6 +166,12 @@ export function usePlanZoomInput(inp: UsePlanZoomInputArgs) {
return;
}
}
// [213] Doppelklick auf das Symbol einer Kamera → die Kamera im 3D öffnen (Reiter wechseln, Ansicht exakt setzen).
const cid = pickCamera(e.clientX, e.clientY);
if (cid) {
void openCamera(cid);
return;
}
// Doppelklick auf eine Schnittlinie → in deren 2D-Schnittansicht springen.
if (onOpenSectionLevel) {
const sid = pickSectionLine(e.clientX, e.clientY);