[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:
Claude committed 2026-11-04 17:27:32 +00:00
commit 2cbc9085ed
16 files changed
+499 -16

No files matched your search

+44
View File
@@ -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
View File
@@ -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));
}
+8 -2
View File
@@ -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;
}