[65] Merge: Explosionsaxonometrie im 3D (Geschosse mit einstellbarem Abstand, Picking folgt, CLI --explode)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
16 files changed
+499
-16
No files matched your search
+3
-2
@@ -21,7 +21,7 @@
|
||||
// Bauteile ([B4]); Bericht als JSON auf stdout
|
||||
// dossier-cli <projekt.obp> import-mesh <datei.obj|stl|gltf|glb|ply> [--out neu.obp] [--unit mm|cm|m|inch|foot] [--up z|y|auto]
|
||||
// [--placement center|original] 3D-Modell als Kontext-Meshes; Bericht als JSON
|
||||
// dossier-cli <projekt.obp> model3d [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
|
||||
// dossier-cli <projekt.obp> model3d [--explode 3] [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
|
||||
// dossier-cli pointcloud-info <datei.las|laz|e57|ply|xyz|pts> [--voxel 0.05] [--max 2000000]
|
||||
// Punktwolke lesen ([B9]) und Bericht als JSON (ohne Projekt)
|
||||
// dossier-cli pdf-info <datei.pdf> [--page 1] Vektor-PDF lesen ([76]): Seiten, Pfade, Texte, BBox (pt) als JSON
|
||||
@@ -822,7 +822,8 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
await serveStdio(file);
|
||||
return 0;
|
||||
case "model3d":
|
||||
out(args, JSON.stringify(projectToModel3d(project)), `${project.name || "projekt"}.model3d.json`);
|
||||
// `--explode <m>`: Explosionsaxonometrie ([65]), Geschosse um Index × Abstand angehoben.
|
||||
out(args, JSON.stringify(projectToModel3d(project, { explode: Number(args.flags.get("explode") ?? 0) || 0 })), `${project.name || "projekt"}.model3d.json`);
|
||||
return 0;
|
||||
case "bench": {
|
||||
const runs = Number(args.flags.get("runs") ?? 10);
|
||||
|
||||
@@ -2778,6 +2778,9 @@ export const de = {
|
||||
"WebGPU konnte nicht initialisiert werden. In der Statusleiste auf WebGL2 umschalten, um die 3D-Ansicht weiter zu nutzen.",
|
||||
"viewport3d.grid.show": "Bodenraster einblenden",
|
||||
"viewport3d.grid.hide": "Bodenraster ausblenden",
|
||||
"viewport3d.explode.on": "Explosionsaxonometrie: Geschosse auseinanderziehen",
|
||||
"viewport3d.explode.off": "Explosionsaxonometrie beenden",
|
||||
"viewport3d.explode.gap": "Abstand zwischen den Geschossen (m)",
|
||||
"viewport3d.section.label": "Schnittebene",
|
||||
"viewport3d.section.show": "Schnittebene ein",
|
||||
"viewport3d.section.hide": "Schnittebene aus",
|
||||
|
||||
@@ -2765,6 +2765,9 @@ export const en: Record<TranslationKey, string> = {
|
||||
"WebGPU could not be initialized. Switch to WebGL2 in the status bar to keep using the 3D view.",
|
||||
"viewport3d.grid.show": "Show ground grid",
|
||||
"viewport3d.grid.hide": "Hide ground grid",
|
||||
"viewport3d.explode.on": "Exploded axonometric: pull storeys apart",
|
||||
"viewport3d.explode.off": "End exploded axonometric",
|
||||
"viewport3d.explode.gap": "Gap between storeys (m)",
|
||||
"viewport3d.section.label": "Section plane",
|
||||
"viewport3d.section.show": "Section plane on",
|
||||
"viewport3d.section.hide": "Section plane off",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* [65] Explosionsaxonometrie: Fassade `projectToModel3d({ explode })`, `pickGeometry(…, explode)` und
|
||||
* `selectionHighlightLines(…, explode)` — Geschosse um Index × Abstand gehoben, 0 = unverändert.
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { projectToModel3d, pickGeometry, selectionHighlightLines } from "./toWalls3d";
|
||||
|
||||
const floors = sampleProject.drawingLevels
|
||||
.filter((l) => l.kind === "floor")
|
||||
.sort((a, b) => (a.baseElevation ?? 0) - (b.baseElevation ?? 0));
|
||||
const index = new Map(floors.map((f, i) => [f.id, i]));
|
||||
const wallIndex = (id: string) => index.get(sampleProject.walls.find((w) => w.id === id)!.floorId) ?? 0;
|
||||
|
||||
describe("Explosionsaxonometrie", () => {
|
||||
it("Abstand 0 ändert nichts", () => {
|
||||
expect(JSON.stringify(projectToModel3d(sampleProject, { explode: 0 }))).toBe(JSON.stringify(projectToModel3d(sampleProject)));
|
||||
expect(JSON.stringify(pickGeometry(sampleProject, 0))).toBe(JSON.stringify(pickGeometry(sampleProject)));
|
||||
});
|
||||
|
||||
it("Wände heben sich um Geschoss-Index × Abstand, Modell und Pick stimmen überein", () => {
|
||||
expect(floors.length).toBeGreaterThan(1);
|
||||
const base = projectToModel3d(sampleProject);
|
||||
const ex = projectToModel3d(sampleProject, { explode: 3 });
|
||||
const pick = pickGeometry(sampleProject, 3);
|
||||
expect(ex.walls.length).toBe(base.walls.length);
|
||||
let lifted = 0;
|
||||
ex.walls.forEach((w, i) => {
|
||||
const dz = wallIndex(w.wallId) * 3;
|
||||
expect(w.baseElevation - base.walls[i].baseElevation).toBeCloseTo(dz, 9);
|
||||
if (dz > 0) lifted++;
|
||||
});
|
||||
expect(lifted).toBeGreaterThan(0);
|
||||
pick.walls.forEach((w, i) => expect(w.baseElevation).toBeCloseTo(ex.walls[i].baseElevation, 9));
|
||||
});
|
||||
|
||||
it("Hervorhebung folgt dem Versatz", () => {
|
||||
const w = sampleProject.walls.find((x) => wallIndex(x.id) > 0)!;
|
||||
const a = selectionHighlightLines(sampleProject, [w.id], [], [1, 0, 0]);
|
||||
const b = selectionHighlightLines(sampleProject, [w.id], [], [1, 0, 0], [], [], [], [], 2);
|
||||
expect(b.length).toBe(a.length);
|
||||
expect(b[1] - a[1]).toBeCloseTo(2 * wallIndex(w.id), 4);
|
||||
});
|
||||
});
|
||||
+23
-5
@@ -137,6 +137,12 @@ export interface Model3dOptions {
|
||||
* `toWalls3d/voids3d.ts`). Schnitt/Ansicht/Export behandeln Abzugskörper selbst.
|
||||
*/
|
||||
voids?: boolean;
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Abstand (m) zwischen den Geschossen; 0/fehlt = aus. Jedes
|
||||
* Geschoss hebt sich um Index × Abstand (Kern `explode3d.rs`); Kontext bleibt stehen.
|
||||
* Mit Explosion keine Abzugskörper (die truck-Ergebnisse lägen am alten Ort).
|
||||
*/
|
||||
explode?: number;
|
||||
}
|
||||
|
||||
/** Das volle 3D-Modell: Wände (mit Öffnungen) + Deckenplatten + Kontext-Meshes. */
|
||||
@@ -144,14 +150,15 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
const layered = opts.layeredWalls ?? true;
|
||||
const detail = opts.detail ?? "fein";
|
||||
// Mit `voids` liefert der Kern zusätzlich die getroffenen Wände/Decken als truck-Spezifikationen.
|
||||
const voids = !!opts.voids && typeof window !== "undefined";
|
||||
const explode = explodeGap(opts.explode);
|
||||
const voids = !!opts.voids && typeof window !== "undefined" && explode === 0;
|
||||
const parts = documentFor(project).query<Model3dParts>(
|
||||
"model3dParts",
|
||||
[layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0],
|
||||
[layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, explode],
|
||||
);
|
||||
// Die truck-Körper (asynchron, mit Cache) kommen zwischen Kontext-Meshes und Stützen.
|
||||
const meshes: RMesh[] = [...parts.contextMeshes];
|
||||
for (const m of emitExtrudedSolids(project)) meshes.push(m);
|
||||
for (const m of emitExtrudedSolids(project, parts.floorOffsets)) meshes.push(m);
|
||||
for (const m of parts.columnMeshes) meshes.push(m);
|
||||
for (const m of parts.openingMeshes) meshes.push(m);
|
||||
for (const m of parts.stairMeshes) meshes.push(m);
|
||||
@@ -183,6 +190,13 @@ interface Model3dParts {
|
||||
roofLayers: RModel3d["roofLayers"];
|
||||
/** Nur mit Abzugskörpern: (Index im Modell, Bauteil − Körper) je getroffene Wand/Decke. */
|
||||
voidCuts?: VoidCuts;
|
||||
/** Nur mit Explosion: Versatz (m) je Geschoss-id (für die truck-Extrusionen). */
|
||||
floorOffsets?: Record<string, number>;
|
||||
}
|
||||
|
||||
/** Explosionsabstand bereinigt: endlich und > 0, sonst 0 (= aus). */
|
||||
function explodeGap(v: number | undefined): number {
|
||||
return typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0;
|
||||
}
|
||||
|
||||
const DETAIL_CODE: Record<string, number> = { grob: 0, mittel: 1, fein: 2 };
|
||||
@@ -200,6 +214,8 @@ const DETAIL_CODE: Record<string, number> = { grob: 0, mittel: 1, fein: 2 };
|
||||
*/
|
||||
export function pickGeometry(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]) wie bei {@link projectToModel3d}; 0 = aus. */
|
||||
explode = 0,
|
||||
): {
|
||||
walls: RWall[];
|
||||
slabs: RSlab[];
|
||||
@@ -209,7 +225,7 @@ export function pickGeometry(
|
||||
contextMeshes: PickContextMesh[];
|
||||
drawings: PickDrawingSeg[];
|
||||
} {
|
||||
return documentFor(project).query("pickGeometry");
|
||||
return documentFor(project).query("pickGeometry", [explodeGap(explode)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,11 +265,13 @@ export function selectionHighlightLines(
|
||||
stairIds: string[] = [],
|
||||
roofIds: string[] = [],
|
||||
contextObjectIds: string[] = [],
|
||||
/** Explosionsabstand ([65]); 0 = aus. */
|
||||
explode = 0,
|
||||
): Float32Array {
|
||||
const sel = { walls: wallIds, ceilings: ceilingIds, openings: openingIds, stairs: stairIds, roofs: roofIds, context: contextObjectIds };
|
||||
if (Object.values(sel).every((l) => l.length === 0)) return new Float32Array(0);
|
||||
// Gerechnet im Kern (`highlight3d.rs`); Antwort f32-LE.
|
||||
const b = documentFor(project).queryBin("selectionHighlight", [], JSON.stringify({ ...sel, rgb }));
|
||||
const b = documentFor(project).queryBin("selectionHighlight", [], JSON.stringify({ ...sel, rgb, explode: explodeGap(explode) }));
|
||||
return new Float32Array(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,11 @@ function extrudedSolidSignature(solid: ExtrudedSolid): string {
|
||||
return `${solid.baseOffset ?? 0}|${solid.height}|${solid.taper ?? 0}|${solid.cornerRadius ?? 0}|${solid.chamfer ?? 0}|${brep}|${solid.points.map((p) => `${p.x},${p.y}`).join(";")}`;
|
||||
}
|
||||
|
||||
export function emitExtrudedSolids(project: Project): RMesh[] {
|
||||
export function emitExtrudedSolids(
|
||||
project: Project,
|
||||
/** Explosionsaxonometrie ([65]): Versatz (m) je Geschoss-id; der Cache bleibt unverschoben. */
|
||||
floorOffsets?: Record<string, number>,
|
||||
): RMesh[] {
|
||||
if (typeof window === "undefined") return [];
|
||||
const out: RMesh[] = [];
|
||||
// Cache-Einträge gelöschter/nicht mehr existierender Körper verwerfen (sonst
|
||||
@@ -94,7 +98,9 @@ export function emitExtrudedSolids(project: Project): RMesh[] {
|
||||
})
|
||||
.catch((e) => console.warn("truck-Extrusion fehlgeschlagen:", e));
|
||||
}
|
||||
if (entry.mesh) out.push(entry.mesh);
|
||||
if (!entry.mesh) continue;
|
||||
const dz = floorOffsets?.[solid.levelId] ?? 0;
|
||||
out.push(dz === 0 ? entry.mesh : { ...entry.mesh, positions: entry.mesh.positions.map((v, i) => (i % 3 === 2 ? v + dz : v)) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -37,6 +37,10 @@ export interface ViewSlice {
|
||||
// im Nordstern/WASM-Pfad — die three.js-Sicht zeigt ihr Raster unveraendert
|
||||
// immer; s. Wasm3DViewport.tsx).
|
||||
grid3dVisible: boolean;
|
||||
// Explosionsaxonometrie im 3D ([65]): Geschosse senkrecht auseinandergezogen (nur Ansicht,
|
||||
// nicht im Projekt) und der Abstand je Geschoss in Metern.
|
||||
explode3d: boolean;
|
||||
explode3dGap: number;
|
||||
// Farb-Modus des Grundrisses: "color" = Kategorie-/Element-Farben (heute),
|
||||
// "mono" = reiner Schwarz-Weiss-Plan (Tinte, keine Farb-/Schraffurfarben).
|
||||
planColorMode: "color" | "mono";
|
||||
@@ -65,6 +69,8 @@ export interface ViewSlice {
|
||||
setView3d: (v: View3d) => void;
|
||||
setFov: (n: number) => void;
|
||||
setGrid3dVisible: (b: boolean) => void;
|
||||
setExplode3d: (b: boolean) => void;
|
||||
setExplode3dGap: (m: number) => void;
|
||||
setPlanColorMode: (m: "color" | "mono") => void;
|
||||
setReferenceLines: (b: boolean) => void;
|
||||
setLineMode: (m: "display" | "print") => void;
|
||||
@@ -89,6 +95,8 @@ export function createViewSlice(api: StoreApi<ViewSlice>): ViewSlice {
|
||||
view3d: "perspective",
|
||||
fov: 50,
|
||||
grid3dVisible: true,
|
||||
explode3d: false,
|
||||
explode3dGap: 3,
|
||||
planColorMode: "color",
|
||||
referenceLines: false,
|
||||
lineMode: "display",
|
||||
@@ -114,6 +122,10 @@ export function createViewSlice(api: StoreApi<ViewSlice>): ViewSlice {
|
||||
setView3d: (v) => set({ view3d: v }),
|
||||
setFov: (n) => set({ fov: n }),
|
||||
setGrid3dVisible: (b) => set({ grid3dVisible: b }),
|
||||
setExplode3d: (b) => set({ explode3d: b }),
|
||||
setExplode3dGap: (m) => {
|
||||
if (Number.isFinite(m) && m > 0) set({ explode3dGap: Math.min(m, 100) });
|
||||
},
|
||||
setPlanColorMode: (m) => set({ planColorMode: m }),
|
||||
setReferenceLines: (b) => set({ referenceLines: b }),
|
||||
setLineMode: (m) => set({ lineMode: m }),
|
||||
|
||||
@@ -65,6 +65,7 @@ import type { Vec3 } from "../core";
|
||||
import { drawingGripVertices, drawingMoveAnchor } from "./drawingGrips";
|
||||
import { pointCloudSyncItems } from "./pointCloudSync";
|
||||
import { usePointClouds } from "../state/pointCloudStore";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { projectGeoOrigin } from "../core";
|
||||
import {
|
||||
FOV_Y,
|
||||
@@ -562,6 +563,14 @@ export function Wasm3DViewport({
|
||||
groundElevationRef.current = groundElevation;
|
||||
const detailRef = useRef(detail);
|
||||
detailRef.current = detail;
|
||||
// Explosionsaxonometrie ([65], Ansichtszustand): Abstand je Geschoss, 0 = aus.
|
||||
const explodeOn = useStore((s) => s.explode3d);
|
||||
const explodeGap = useStore((s) => s.explode3dGap);
|
||||
const setExplodeOn = useStore((s) => s.setExplode3d);
|
||||
const setExplodeGap = useStore((s) => s.setExplode3dGap);
|
||||
const explode = explodeOn ? explodeGap : 0;
|
||||
const explodeRef = useRef(explode);
|
||||
explodeRef.current = explode;
|
||||
const {
|
||||
render,
|
||||
updateModel,
|
||||
@@ -606,9 +615,9 @@ export function Wasm3DViewport({
|
||||
// Snapshot) — nur das `view3d`-Effekt unten springt aktiv auf ein Praeset.
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
updateModel(project, detail);
|
||||
updateModel(project, detail, explode);
|
||||
redrawRef.current();
|
||||
}, [ready, project, detail, updateModel]);
|
||||
}, [ready, project, detail, explode, updateModel]);
|
||||
|
||||
// Punktwolken abgleichen (neu/umgestellt/entfernt) und neu zeichnen, wenn sich etwas tat.
|
||||
useEffect(() => {
|
||||
@@ -633,7 +642,7 @@ export function Wasm3DViewport({
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
const onMeshReady = () => {
|
||||
updateModel(projectRef.current, detailRef.current);
|
||||
updateModel(projectRef.current, detailRef.current, explodeRef.current);
|
||||
redrawRef.current();
|
||||
};
|
||||
window.addEventListener(TRUCK_MESH_READY_EVENT, onMeshReady);
|
||||
@@ -1371,6 +1380,7 @@ export function Wasm3DViewport({
|
||||
const ray = cameraRay(orbitCamera(o), ndc.ndcX, ndc.ndcY, ndc.aspect);
|
||||
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings } = pickGeometry(
|
||||
projectRef.current,
|
||||
explodeRef.current,
|
||||
);
|
||||
// Erweiterter Pick inkl. Öffnungen (Fenster/Türen) + Treppen + Kontext-
|
||||
// Meshes + freie 2D-Zeichnungen (Linie/Polylinie/Rechteck, s.
|
||||
@@ -1853,6 +1863,56 @@ export function Wasm3DViewport({
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
{/* Explosionsaxonometrie ([65]): Umschalter links neben dem Raster-Knopf, aktiv mit Abstandsfeld. */}
|
||||
<div style={{ position: "absolute", right: onToggleGrid ? 48 : 10, bottom: 10, display: "flex", gap: 4, alignItems: "center" }}>
|
||||
{explodeOn && (
|
||||
<input
|
||||
type="number"
|
||||
min={0.5}
|
||||
max={100}
|
||||
step={0.5}
|
||||
value={explodeGap}
|
||||
aria-label={t("viewport3d.explode.gap")}
|
||||
title={t("viewport3d.explode.gap")}
|
||||
onChange={(e) => setExplodeGap(Number(e.target.value))}
|
||||
style={{
|
||||
width: 56,
|
||||
height: 30,
|
||||
boxSizing: "border-box",
|
||||
borderRadius: 7,
|
||||
border: "1px solid rgba(255,255,255,0.14)",
|
||||
background: "rgba(20,20,24,0.65)",
|
||||
color: "#f2f2f2",
|
||||
padding: "0 6px",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
data-testid="explode3d-toggle"
|
||||
onClick={() => setExplodeOn(!explodeOn)}
|
||||
title={t(explodeOn ? "viewport3d.explode.off" : "viewport3d.explode.on")}
|
||||
aria-pressed={explodeOn}
|
||||
style={{
|
||||
width: 30,
|
||||
height: 30,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: 0,
|
||||
borderRadius: 7,
|
||||
border: "1px solid rgba(255,255,255,0.14)",
|
||||
background: explodeOn ? "rgba(255,255,255,0.14)" : "rgba(20,20,24,0.65)",
|
||||
color: explodeOn ? "#f2f2f2" : "#9a9a9a",
|
||||
cursor: "pointer",
|
||||
backdropFilter: "blur(4px)",
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-outlined" aria-hidden="true" style={{ fontSize: 18 }}>
|
||||
{explodeOn ? "unfold_less" : "unfold_more"}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
{failed && (
|
||||
<div className="viewport-fallback">
|
||||
<strong>{t("viewport3d.engineUnavailable")}</strong>
|
||||
|
||||
@@ -231,11 +231,11 @@ export function useWasm3dRenderer(
|
||||
|
||||
/** Modell bei Projektänderung neu setzen (re-extrudiert in Rust). `detail`
|
||||
* steuert den Öffnungs-Detailgrad (grob/mittel/fein) im 3D wie im Grundriss. */
|
||||
const updateModel = useCallback((project: Project, detail?: DetailLevel) => {
|
||||
const updateModel = useCallback((project: Project, detail?: DetailLevel, explode = 0) => {
|
||||
const r = rendererRef.current;
|
||||
if (!r || !project) return;
|
||||
try {
|
||||
r.set_model(JSON.stringify(projectToModel3d(project, { detail, voids: true })));
|
||||
r.set_model(JSON.stringify(projectToModel3d(project, { detail, voids: true, explode })));
|
||||
} catch (e) {
|
||||
console.warn("render3d set_model fehlgeschlagen:", e);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import { selectionHighlightLines } from "../core";
|
||||
import { clashHighlightLines } from "../analysis/clash";
|
||||
import { useClashSession } from "../panels/clashSession";
|
||||
import { applyGroupDimmingToPlan } from "../state/groupActions";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { PlanView } from "./plan/PlanView";
|
||||
import type {
|
||||
GripHandlers,
|
||||
@@ -293,6 +294,8 @@ export const Content = memo(function Content({
|
||||
// die three.js-Sicht hebt die Auswahl weiterhin über ihr eigenes Material
|
||||
// hervor. Leere Auswahl → null (kein Highlight).
|
||||
const clashes = useClashSession().clashes;
|
||||
// Explosionsaxonometrie ([65]): Hervorhebung folgt dem auseinandergezogenen 3D-Modell.
|
||||
const explode = useStore((s) => (s.explode3d ? s.explode3dGap : 0));
|
||||
const selectionLines = useMemo(
|
||||
() =>
|
||||
selectedWallIds.length === 0 &&
|
||||
@@ -311,9 +314,11 @@ export const Content = memo(function Content({
|
||||
selectedStairIds,
|
||||
selectedRoofIds,
|
||||
selectedContextObjectIds,
|
||||
explode,
|
||||
),
|
||||
[
|
||||
project,
|
||||
explode,
|
||||
selectedWallIds,
|
||||
selectedCeilingIds,
|
||||
selectedOpeningIds,
|
||||
|
||||
Reference in new issue
Block a user