[T8] Kollisionen im 3D: rote Hüllquader, Panel mit Klick-Zoom auf die Durchdringung

This commit is contained in:
Claude committed 2026-10-30 08:10:06 +00:00
1 parent ded5aa1332
commit c082c26a3b
12 files changed
+297 -27

No files matched your search

+1 -1
View File
@@ -1358,7 +1358,7 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
- ○ **[T5] Import reparieren** (`put_together_same_attrs`, Healing). · S
- ○ **[T6] Glattes Gelände aus Höhenlinien** + Gelände-Prisma für Aushub (= [68]). · L
- ✅ **[T7] Rotationskörper/Loft im UI** (API besteht). · S–M — 30.10.: Befehle `revolve` (Profil + Achse aus 2 Plan-Punkten + Winkel; Achse waagrecht auf Höhe r_max, Profil auf einer Seite) und `loft` (≥ 2 Profile der Reihe nach, gleichmässig über die Höhe; Punktzahl durch Kantenteilung angeglichen) in `cmd_solid.rs`/`cmds/{revolve,loft}.ts`, Körper als `ExtrudedSolid.brep` (Objekt-Info, STEP, Kennwerte wie die Grundkörper); Kürzel `rev`/`lf`, Werkzeugpalette 3D. Tests Rust (Spezifikation, Ops, truck-Volumen/STEP), vitest (Befehlsablauf). Nicht in der Tauri-App getestet. Offen: Achse senkrecht/beliebig im Raum, Loft mit Führungskurve, Profil-Startpunkt-Ausrichtung beim Loft.
- ○ **[T8] Kollisionsprüfung im 3D zeigen** (heute nur Marker im Grundriss). · S
- ✅ **[T8] Kollisionsprüfung im 3D zeigen** (heute nur Marker im Grundriss). · S — 30.10.: Treffer in Sitzung (`panels/clashSession.ts`), Panel „Kollisionen" (`ClashPanel`: Liste, Klick wählt beide Bauteile und fährt die 3D-Kamera auf die Durchdringung, `cameraBridge.focusCamera`), im 3D rote Hüllquader aller Treffer (`clashHighlightLines` in `viewportContent`); Prüflauf öffnet das Panel, Marker im Grundriss bleiben. Tests vitest (Linien, Auswahl, Kamera-Fokus). Nicht im echten WebGPU-Viewport/Tauri geprüft. Offen: Hüllquader statt exakter Durchdringungsgeometrie, Panel-Name zeigt Ids statt Bauteilnamen, Wiederholung/Ignorieren einzelner Treffer.
---
+3 -18
View File
@@ -66,7 +66,7 @@ import { IfcImportDialog, type IfcImportMode } from "./ui/IfcImportDialog";
import { MeshImportHost } from "./ui/MeshImportDialog";
import { openMeshFileDialog, requestMeshImport, splitMeshFiles } from "./state/meshImportStore";
import { formatMeshReport, isMeshFile } from "./io/meshImport";
import { clashMarkerOps, runClashCheck } from "./analysis/clash";
import { runClashAndStore } from "./panels/clashSession";
import { checkForUpdate } from "./update/checkForUpdate";
import type { PlanViewHandle } from "./views/plan/PlanView";
import type { DisplayResolver } from "./viewport/Viewport3D";
@@ -2375,23 +2375,8 @@ export default function App() {
onImportPointCloud: () => openPointCloudFileDialog(),
onImportMesh: () => openMeshFileDialog(),
onClashCheck: () => {
const p0 = project;
runClashCheck(p0)
.then((clashes) => {
applyChange((p) => clashMarkerOps(p, clashes, activeCategoryCode));
// window.alert ist im Tauri-WKWebView wirkungslos → Toast.
notify(
clashes.length === 0
? t("clash.none")
: `${t("clash.found")}: ${clashes.length} — ` +
clashes
.slice(0, 5)
.map((c, k) => `K${k + 1} ${c.a.kind}↔${c.b.kind}${c.volume !== null ? ` ${c.volume.toFixed(3)} m³` : ""}`)
.join(", "),
clashes.length === 0 ? "info" : "warning",
);
})
.catch((err) => notify(`${t("clash.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error"));
setLayout((l) => revealPanel(l, "clash"));
void runClashAndStore();
},
onKennzahlen: () => {
const k = computeKennzahlen(project);
+19 -2
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { sampleProject } from "../model/sampleProject";
import { candidatePairs, clashItems, clashMarkerOps, CLASH_MARKER_PREFIX } from "./clash";
import { candidatePairs, clashHighlightLines, clashItems, clashMarkerOps, clashSelection, CLASH_MARKER_PREFIX } from "./clash";
import { applyOps } from "../core/ops";
import type { Project } from "../model/types";
import type { Clash } from "./clash";
@@ -22,11 +22,28 @@ describe("Kollisionspruefung", () => {
expect(items.some((i) => i.kind === "wall")).toBe(true);
});
it("Marker ersetzen alte Marker", () => {
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number] };
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number], min: [0.5, 1.5, 0] as [number, number, number], max: [1.5, 2.5, 1] as [number, number, number] };
const p1 = applyClashMarkers(sampleProject, [clash, clash], "A");
const n1 = p1.drawings2d.filter((d) => d.id.startsWith(CLASH_MARKER_PREFIX)).length;
expect(n1).toBe(4);
const p2 = applyClashMarkers(p1, [clash], "A");
expect(p2.drawings2d.filter((d) => d.id.startsWith(CLASH_MARKER_PREFIX)).length).toBe(2);
});
it("3D-Hervorhebung: 12 Kanten je Kollision als Linienpaare im Viewport-Raum (y/z getauscht)", () => {
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number], min: [0.5, 1.5, 0] as [number, number, number], max: [1.5, 2.5, 1] as [number, number, number] };
const lines = clashHighlightLines([clash], [1, 0, 0]);
expect(lines.length).toBe(12 * 2 * 6);
// erster Eckpunkt: Modell (min.x, min.y, min.z) → world (x, Höhe, y), Farbe rot
const verts = [];
for (let k = 0; k < lines.length; k += 6) verts.push([...lines.slice(k, k + 6)]);
expect(verts.every((v) => v[3] === 1 && v[4] === 0 && v[5] === 0)).toBe(true);
expect(verts.every((v) => v[0] >= 0.5 && v[0] <= 1.5 && v[1] >= 0 && v[1] <= 1 && v[2] >= 1.5 && v[2] <= 2.5)).toBe(true);
expect(clashHighlightLines([], [1, 0, 0]).length).toBe(0);
});
it("Auswahl eines Paars je Bauteilart", () => {
const clash = { a: it0("s1", "solid"), b: it0("w1", "wall"), volume: null, center: [0, 0, 0] as [number, number, number], min: [0, 0, 0] as [number, number, number], max: [1, 1, 1] as [number, number, number] };
expect(clashSelection(clash)).toEqual({ wallIds: ["w1"], ceilingIds: [], extrudedSolidIds: ["s1"], contextObjectIds: [] });
const m = { ...clash, a: it0("m1", "mesh"), b: it0("c1", "slab") };
expect(clashSelection(m)).toEqual({ wallIds: [], ceilingIds: ["c1"], extrudedSolidIds: [], contextObjectIds: ["m1"] });
});
});
+53 -5
View File
@@ -30,8 +30,11 @@ export interface Clash {
b: ClashItem;
/** Durchdringungsvolumen (m³), `null` wenn nicht berechenbar. */
volume: number | null;
/** Mittelpunkt der Durchdringungslinien (Welt-Meter). */
/** Mittelpunkt der Durchdringungslinien (Modell-Meter, z = Höhe). */
center: [number, number, number];
/** Hüllquader der Durchdringungslinien (Modell-Meter) — für Hervorhebung und Zoom. */
min: [number, number, number];
max: [number, number, number];
}
/** Prefix der Marker-Ids (ein neuer Lauf ersetzt die alten Marker). */
@@ -127,13 +130,17 @@ export async function runClashCheck(
if (!r.colliding || r.lines.length === 0) continue;
if (r.overlapVolume !== null && r.overlapVolume < MIN_VOLUME) continue;
const c: [number, number, number] = [0, 0, 0];
const min: [number, number, number] = [Infinity, Infinity, Infinity];
const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
for (const l of r.lines) {
c[0] += (l[0] + l[3]) / 2;
c[1] += (l[1] + l[4]) / 2;
c[2] += (l[2] + l[5]) / 2;
for (let k = 0; k < 3; k++) {
c[k] += (l[k] + l[k + 3]) / 2;
min[k] = Math.min(min[k], l[k], l[k + 3]);
max[k] = Math.max(max[k], l[k], l[k + 3]);
}
}
const n = r.lines.length;
const clash: Clash = { a: items[i], b: items[j], volume: r.overlapVolume, center: [c[0] / n, c[1] / n, c[2] / n] };
const clash: Clash = { a: items[i], b: items[j], volume: r.overlapVolume, center: [c[0] / n, c[1] / n, c[2] / n], min, max };
// Mehrere Wandschichten derselben Wand → eine Kollision (grösstes Volumen).
const key = [items[i].id, items[j].id].sort().join("|");
const prev = found.get(key);
@@ -175,3 +182,44 @@ export function clashMarkerOps(project: Project, clashes: Clash[], categoryCode:
...addItems("drawings2d", markers),
];
}
/**
* Rote Hüllquader der Kollisionen als Linienliste für den 3D-Viewport (`set_highlight_lines`):
* `[x, y, z, r, g, b]` je Vertex, 2 Vertices je Kante, 12 Kanten je Kollision. Modell (x, y, Höhe)
* → Viewport-Welt (x, Höhe, y). Mindestkantenlänge 0.1 m, damit hauchdünne Durchdringungen sichtbar bleiben.
*/
export function clashHighlightLines(clashes: Clash[], rgb: readonly [number, number, number]): Float32Array {
const out = new Float32Array(clashes.length * 12 * 2 * 6);
let o = 0;
const vert = (p: readonly number[]) => {
out[o++] = p[0];
out[o++] = p[2];
out[o++] = p[1];
out[o++] = rgb[0];
out[o++] = rgb[1];
out[o++] = rgb[2];
};
for (const c of clashes) {
const lo = [0, 1, 2].map((k) => Math.min(c.min[k], c.center[k] - 0.05));
const hi = [0, 1, 2].map((k) => Math.max(c.max[k], c.center[k] + 0.05));
const corner = (i: number) => [i & 1 ? hi[0] : lo[0], i & 2 ? hi[1] : lo[1], i & 4 ? hi[2] : lo[2]];
for (let i = 0; i < 8; i++) {
for (const bit of [1, 2, 4]) {
if (i & bit) continue;
vert(corner(i));
vert(corner(i | bit));
}
}
}
return out;
}
/** Bauteile einer Kollision je Auswahlkanal (Wand, Decke, Körper, Import). */
export function clashSelection(c: Clash): { wallIds: string[]; ceilingIds: string[]; extrudedSolidIds: string[]; contextObjectIds: string[] } {
const sel = { wallIds: [] as string[], ceilingIds: [] as string[], extrudedSolidIds: [] as string[], contextObjectIds: [] as string[] };
for (const it of [c.a, c.b]) {
const list = it.kind === "wall" ? sel.wallIds : it.kind === "slab" ? sel.ceilingIds : it.kind === "solid" ? sel.extrudedSolidIds : sel.contextObjectIds;
if (!list.includes(it.id)) list.push(it.id);
}
return sel;
}
+9
View File
@@ -2433,6 +2433,15 @@ export const de = {
"siteRules.addLine.hint": "Eine Linie wählen; das Gebäude bleibt auf der Seite der Parzelle.",
"siteRules.clearLines": "Alle Baulinien entfernen",
"clash.none": "Keine Kollisionen gefunden.",
"clash.run": "Prüfung starten",
"clash.running": "Prüfung läuft …",
"clash.clear": "Leeren",
"clash.empty": "Keine Treffer. Die Prüfung vergleicht freie Körper und Importe mit Wänden, Decken und anderen Körpern.",
"clash.kind.wall": "Wand",
"clash.kind.slab": "Decke",
"clash.kind.solid": "Körper",
"clash.kind.mesh": "Import",
"nav.clash": "Kollisionen",
"clash.found": "Kollisionen gefunden",
"clash.failed": "Kollisionsprüfung fehlgeschlagen",
"about.title": "Über dossier",
+9
View File
@@ -2382,6 +2382,15 @@ export const en: Record<TranslationKey, string> = {
"siteRules.addLine": "Building line from selection",
"siteRules.addLine.hint": "Select a line; the building stays on the parcel side.",
"siteRules.clearLines": "Remove all building lines",
"clash.run": "Run check",
"clash.running": "Checking …",
"clash.clear": "Clear",
"clash.empty": "No results. The check compares free solids and imports with walls, slabs and other solids.",
"clash.kind.wall": "Wall",
"clash.kind.slab": "Slab",
"clash.kind.solid": "Solid",
"clash.kind.mesh": "Import",
"nav.clash": "Clashes",
"clash.none": "No clashes found.",
"clash.found": "Clashes found",
"clash.failed": "Clash detection failed",
+58
View File
@@ -0,0 +1,58 @@
// Kollisionen ([T8]): Liste der Treffer der letzten Prüfung. Klick wählt beide beteiligten Bauteile
// (Auswahl-Umriss im 3D) und fährt die 3D-Kamera auf die Durchdringung; im 3D sind alle Treffer als
// rote Hüllquader markiert (`clashHighlightLines`, `views/viewportContent.tsx`).
import { t } from "../i18n";
import { getState } from "../state/appStore";
import { clashSelection, type Clash } from "../analysis/clash";
import { focusCamera, viewportAvailable } from "../viewport/cameraBridge";
import { runClashAndStore, setClashSession, useClashSession } from "./clashSession";
/** Klick auf einen Treffer: Bauteile wählen, Kamera auf die Durchdringung. */
export function focusClash(c: Clash, index: number): void {
const s = getState();
const sel = clashSelection(c);
s.clearSelection();
s.setSelectedWallIds(sel.wallIds);
s.setSelectedCeilingIds(sel.ceilingIds);
s.setSelectedExtrudedSolidIds(sel.extrudedSolidIds);
s.setSelectedContextObjectIds(sel.contextObjectIds);
setClashSession({ selected: index });
const radius = Math.hypot(c.max[0] - c.min[0], c.max[1] - c.min[1], c.max[2] - c.min[2]) / 2;
if (viewportAvailable()) focusCamera(c.center, radius);
}
const itemText = (it: Clash["a"]) => `${t(`clash.kind.${it.kind}`)} ${it.id}`;
export function ClashPanel() {
const session = useClashSession();
return (
<div className="bcf-panel">
<div className="bcf-bar">
<button type="button" className="bcf-btn" disabled={session.running} onClick={() => void runClashAndStore()}>
{session.running ? t("clash.running") : t("clash.run")}
</button>
<button
type="button"
className="bcf-btn"
disabled={session.clashes.length === 0}
onClick={() => setClashSession({ clashes: [], selected: null })}
>
{t("clash.clear")}
</button>
</div>
{session.clashes.length === 0 && <div className="bcf-empty">{t("clash.empty")}</div>}
<ul className="bcf-list">
{session.clashes.map((c, k) => (
<li key={`${c.a.id}|${c.b.id}`}>
<button type="button" className={`bcf-topic${k === session.selected ? " is-active" : ""}`} onClick={() => focusClash(c, k)}>
<span className="bcf-status">{`K${k + 1}`}</span>
<span className="bcf-topic-title">{`${itemText(c.a)} ↔ ${itemText(c.b)}`}</span>
{c.volume !== null && <span className="bcf-count">{`${c.volume.toFixed(3)} m³`}</span>}
</button>
</li>
))}
</ul>
</div>
);
}
+12
View File
@@ -26,6 +26,7 @@ import { ElementTreePanel, ElementsTabIcon } from "./ElementTreePanel";
import { ViewSnapshotsPanel, ViewSnapshotsTabIcon } from "./ViewSnapshotsPanel";
import { LayoutsPanel, LayoutsTabIcon } from "./LayoutsPanel";
import { BcfPanel } from "./BcfPanel";
import { ClashPanel } from "./ClashPanel";
import { HistoryPanel } from "./HistoryPanel";
import {
ToolsTabIcon,
@@ -52,6 +53,7 @@ export const BUILTIN_PANEL_IDS = {
viewSnapshots: "view-snapshots",
layouts: "layouts",
bcf: "bcf",
clash: "clash",
history: "history",
} as const;
@@ -162,6 +164,16 @@ registerPanel({
render: () => <BcfPanel />,
});
// Kollisionen ([T8]) — Treffer der Kollisionsprüfung, Klick zoomt im 3D auf die Durchdringung. Nicht im
// Standard-Layout; öffnet sich beim Prüflauf („Modell > Kollisionsprüfung") bzw. über „Fenster > Panels".
registerPanel({
id: BUILTIN_PANEL_IDS.clash,
title: "nav.clash",
icon: <BcfTabIcon />,
hasDisplayMode: false,
render: () => <ClashPanel />,
});
// Verlauf ([84]) — Undo-Schritte als Liste, Klick springt zum Schritt. Nicht im Standard-Layout,
// erreichbar über „Bearbeiten > Verlauf" bzw. „Fenster > Panels".
registerPanel({
+65
View File
@@ -0,0 +1,65 @@
// Sitzungszustand der Kollisionsprüfung ([T8]): die Ergebnisse der letzten Prüfung leben ausserhalb des
// Projekts (Marker im Grundriss kommen weiterhin als Zeichnungs-Elemente), damit Liste (ClashPanel) und
// 3D-Hervorhebung (viewportContent) dieselben Treffer zeigen. Kleiner Modul-Speicher wie `bcfSession`.
import { useSyncExternalStore } from "react";
import { clashMarkerOps, runClashCheck, type Clash } from "../analysis/clash";
import { t } from "../i18n";
import { getState } from "../state/appStore";
export interface ClashSession {
clashes: Clash[];
/** Index des gewählten Treffers (Liste/Zoom) oder null. */
selected: number | null;
/** Prüfung läuft. */
running: boolean;
}
let state: ClashSession = { clashes: [], selected: null, running: false };
const listeners = new Set<() => void>();
export const getClashSession = (): ClashSession => state;
export function setClashSession(patch: Partial<ClashSession>): void {
state = { ...state, ...patch };
for (const l of listeners) l();
}
export function useClashSession(): ClashSession {
return useSyncExternalStore(
(cb) => {
listeners.add(cb);
return () => listeners.delete(cb);
},
getClashSession,
);
}
/**
* Prüfung ausführen: Ergebnis in die Sitzung (Liste + 3D-Hervorhebung), Marker in den Grundriss, Meldung.
* Läuft auf dem aktuellen Projektstand des Stores.
*/
export async function runClashAndStore(): Promise<void> {
if (state.running) return;
const st = getState();
setClashSession({ running: true });
try {
const clashes = await runClashCheck(st.project);
st.applyChange((p) => clashMarkerOps(p, clashes, st.activeCategoryCode));
setClashSession({ clashes, selected: null, running: false });
// window.alert ist im Tauri-WKWebView wirkungslos → Toast.
st.notify(
clashes.length === 0
? t("clash.none")
: `${t("clash.found")}: ${clashes.length} — ` +
clashes
.slice(0, 5)
.map((c, k) => `K${k + 1} ${c.a.kind}↔${c.b.kind}${c.volume !== null ? ` ${c.volume.toFixed(3)} m³` : ""}`)
.join(", "),
clashes.length === 0 ? "info" : "warning",
);
} catch (err) {
setClashSession({ running: false });
st.notify(`${t("clash.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error");
}
}
+29
View File
@@ -5,6 +5,8 @@ import { afterEach, describe, expect, it } from "vitest";
import { projectToModel3d, sampleProject } from "../core";
import {
FOV_Y,
focusCamera,
focusedCamera,
camera3dFromViewCamera,
captureSnapshot,
getCamera,
@@ -153,6 +155,25 @@ describe("Schnittebene", () => {
});
});
describe("Fokus auf einen Punkt (Kollisionsliste)", () => {
it("zentriert das Ziel auf den Modellpunkt, behält die Blickrichtung, Abstand folgt dem Radius", () => {
const cam = orbitCamera({ yaw: 0.4, pitch: 0.3, dist: 15, target: [1, 2, 3], ortho: false, orthoHalfHeight: 8 });
const f = focusedCamera(cam, [4, 5, 6], 2);
close(f.target, modelToWorld([4, 5, 6]));
const d = (c: Camera3d) => {
const v = [c.target[0] - c.eye[0], c.target[1] - c.eye[1], c.target[2] - c.eye[2]];
const l = Math.hypot(...v);
return v.map((x) => x / l);
};
close(d(f), d(cam));
const near = Math.hypot(...f.target.map((t, i) => t - f.eye[i]));
expect(near).toBeGreaterThan(2);
expect(near).toBeLessThan(15);
const ortho = focusedCamera({ ...cam, perspective: false, orthoHalfHeight: 8 }, [0, 0, 0], 2);
expect(ortho.orthoHalfHeight).toBeLessThan(8);
});
});
describe("Registrierung", () => {
function fakeViewport() {
const state = { cam: orbitCamera({ yaw: 0.4, pitch: 0.3, dist: 15, target: [1, 2, 3], ortho: false, orthoHalfHeight: 8 }), written: null as Camera3d | null, section: undefined as unknown };
@@ -181,6 +202,14 @@ describe("Registrierung", () => {
expect(setCamera(vc)).toBe(false);
});
it("focusCamera schreibt die fokussierte Kamera in den Viewport (false ohne Viewport)", () => {
expect(focusCamera([1, 2, 3], 1)).toBe(false);
const { state, a } = fakeViewport();
registerViewportCamera(a);
expect(focusCamera([5, 6, 7], 1)).toBe(true);
close(state.written!.target, modelToWorld([5, 6, 7]));
});
it("getCamera → setCamera am angemeldeten Viewport lässt die Kamera unverändert", () => {
const { state, a } = fakeViewport();
registerViewportCamera(a);
+23
View File
@@ -257,6 +257,29 @@ export function setCamera(cam: ViewCamera, opts: { animate?: boolean } = {}): bo
return c3 ? api.write(c3, opts.animate === true) : false;
}
/**
* Kamera, die einen Modellpunkt (x, y, Höhe) ins Ziel nimmt: gleiche Blickrichtung, Abstand so, dass eine
* Kugel vom Radius `radius` (Meter) bequem ins Bild passt; orthografisch schrumpft die Sichthöhe.
*/
export function focusedCamera(cam: Camera3d, centerModel: readonly number[], radius: number): Camera3d {
const target = modelToWorld(centerModel);
const d = norm(sub(cam.target, cam.eye)) ?? ([0, 0, -1] as V3);
const r = Math.max(radius, 0.5);
const dist = Math.max((r * 2.2) / Math.tan((cam.fovY || FOV_Y) / 2), 1.5);
return {
...cam,
target,
eye: [target[0] - d[0] * dist, target[1] - d[1] * dist, target[2] - d[2] * dist],
orthoHalfHeight: cam.perspective ? cam.orthoHalfHeight : r * 2.2,
};
}
/** Fokus der Live-Kamera auf einen Modellpunkt; `false` ohne Viewport. */
export function focusCamera(centerModel: readonly number[], radius: number, opts: { animate?: boolean } = {}): boolean {
const cur = api?.read();
return api && cur ? api.write(focusedCamera(cur.camera, centerModel, radius), opts.animate !== false) : false;
}
/** PNG des aktuellen 3D-Bildes, oder null (kein Viewport, leeres/nicht lesbares Bild). */
export async function captureSnapshot(opts: { maxEdge?: number } = {}): Promise<Uint8Array | null> {
if (!api) return null;
+16 -1
View File
@@ -37,6 +37,8 @@ import { unitsForLevel } from "../tools/displayUnits";
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync";
import { selectionHighlightLines } from "../core";
import { clashHighlightLines } from "../analysis/clash";
import { useClashSession } from "../panels/clashSession";
import { applyGroupDimmingToPlan } from "../state/groupActions";
import { PlanView } from "./plan/PlanView";
import type {
@@ -61,6 +63,8 @@ import type { DetailLevel, RenderMode, View3d, ViewType } from "../model/viewTyp
* grauen Wand-/Deckenton, dem hellen Hidden-Line-Weiss und dem Bodenraster ab.
*/
const HIGHLIGHT_RGB: [number, number, number] = [1.0, 0.5, 0.1];
/** Rot der Kollisions-Hüllquader im 3D ([T8]). */
const CLASH_RGB: [number, number, number] = [0.88, 0.14, 0.16];
/** Hauptinhalt — abhängig von der aktiven Zeichnungsebene und dem Ansichtstyp. */
export function Content({
@@ -285,7 +289,8 @@ export function Content({
// im WASM-Zweig (Viewport3D reicht sie nur dort an Wasm3DViewport durch);
// die three.js-Sicht hebt die Auswahl weiterhin über ihr eigenes Material
// hervor. Leere Auswahl → null (kein Highlight).
const highlightLines = useMemo(
const clashes = useClashSession().clashes;
const selectionLines = useMemo(
() =>
selectedWallIds.length === 0 &&
selectedCeilingIds.length === 0 &&
@@ -314,6 +319,16 @@ export function Content({
selectedContextObjectIds,
],
);
// Kollisionen der letzten Prüfung: rote Hüllquader zusätzlich zur Auswahl-Hervorhebung.
const highlightLines = useMemo(() => {
if (clashes.length === 0) return selectionLines;
const clashLines = clashHighlightLines(clashes, CLASH_RGB);
if (!selectionLines) return clashLines;
const merged = new Float32Array(selectionLines.length + clashLines.length);
merged.set(selectionLines, 0);
merged.set(clashLines, selectionLines.length);
return merged;
}, [selectionLines, clashes]);
if (level.kind === "section" || level.kind === "elevation") {
return (