Merge branch 'worktree-agent-a8430b7822fb50a76' into claude/practical-noether-1hb2s1
# Conflicts: # TODO.md # doc/ARCHITEKTUR.md
This commit is contained in:
27 files changed
+874
-159
No files matched your search
@@ -0,0 +1,82 @@
|
||||
// [180] Klassen im 3D: ausgeblendete Klassen (Ebenen-Baum bzw. Darstellungsmodus `hide`) fehlen im Modell, in den
|
||||
// Teil-Updates des Viewers und in der Pick-Geometrie; Umschalten hält die Einträge des Kern-Caches (nichts neu).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Project } from "../model/types";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { emitSurfacePatternLines, hiddenClassCodes, pickGeometry, projectToModel3d, projectToModel3dParts } from "./toWalls3d";
|
||||
import { documentFor } from "../core/document";
|
||||
import { pickNearest, type Ray } from "../viewport/raycast3d";
|
||||
|
||||
const withLayer = (p: Project, code: string, visible: boolean): Project => ({
|
||||
...p,
|
||||
layers: p.layers.map((c) => (c.code === code ? { ...c, visible } : c)),
|
||||
});
|
||||
|
||||
describe("3D nach Klassen ([180])", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
const roofs = (m: ReturnType<typeof projectToModel3d>) => m.roofLayers.length;
|
||||
|
||||
it("Dächer aus: weder im Modell noch anwählbar; Wände bleiben", () => {
|
||||
const all = projectToModel3d(p);
|
||||
expect(roofs(all)).toBeGreaterThan(0);
|
||||
expect(pickGeometry(p).roofs.length).toBeGreaterThan(0);
|
||||
for (const [q, hide] of [
|
||||
[withLayer(p, "31", false), undefined],
|
||||
[p, ["31"]],
|
||||
] as const) {
|
||||
const m = projectToModel3d(q, { hide });
|
||||
expect(roofs(m)).toBe(0);
|
||||
expect(m.walls.length).toBe(all.walls.length);
|
||||
expect(m.meshes.length).toBeLessThan(all.meshes.length);
|
||||
const g = pickGeometry(q, 0, hide);
|
||||
expect(g.roofs).toHaveLength(0);
|
||||
expect(g.walls.length).toBeGreaterThan(0);
|
||||
// Senkrechter Strahl auf die Dachmitte trifft kein Dach mehr.
|
||||
const t = pickGeometry(p).roofs[0].tris[0];
|
||||
const c = [0, 1, 2].map((i) => (t[0][i] + t[1][i] + t[2][i]) / 3);
|
||||
const ray: Ray = { origin: [c[0], 200, c[2]], dir: [0, -1, 0] };
|
||||
const hit = pickNearest(ray, g.walls, g.slabs, g.openings, g.stairs, g.roofs, g.contextMeshes, g.drawings, g.columns, g.solids, g.openingMeshes, g.stairMeshes, g.drawingMeshes, g.trees);
|
||||
expect(hit?.kind).not.toBe("roof");
|
||||
}
|
||||
});
|
||||
|
||||
it("Wände aus: Wände, ihre Öffnungen und Wandmuster fehlen", () => {
|
||||
const m = projectToModel3d(p, { hide: ["20"] });
|
||||
expect(m.walls).toHaveLength(0);
|
||||
const g = pickGeometry(p, 0, ["20"]);
|
||||
expect(g.walls).toHaveLength(0);
|
||||
expect(g.openings).toHaveLength(0);
|
||||
expect(emitSurfacePatternLines(p, 0, ["20", "30", "31"]).length).toBe(0);
|
||||
});
|
||||
|
||||
it("Teil-Updates: ausgeblendete Wand-Einträge bleiben gehalten, Einblenden schickt sie nicht neu", () => {
|
||||
const doc = documentFor(p);
|
||||
const all = projectToModel3dParts(p)!;
|
||||
const wallParts = all.filter((x) => x.id.startsWith("w"));
|
||||
expect(wallParts.length).toBeGreaterThan(0);
|
||||
const hidden = projectToModel3dParts(p, { hide: ["20"] })!;
|
||||
expect(hidden.filter((x) => x.id.startsWith("w"))).toHaveLength(0);
|
||||
// Wieder ein: dieselben unveränderlichen Teile (gleiche ids), ohne erneutes Ausschreiben im Kern.
|
||||
const spy = doc.queryJson.bind(doc);
|
||||
let delta = "";
|
||||
doc.queryJson = (name, args, text) => {
|
||||
const out = spy(name, args, text);
|
||||
if (name === "model3dPartsDelta") delta = out;
|
||||
return out;
|
||||
};
|
||||
try {
|
||||
const again = projectToModel3dParts(p)!;
|
||||
expect(again.filter((x) => x.id.startsWith("w")).map((x) => x.id)).toEqual(wallParts.map((x) => x.id));
|
||||
expect(JSON.parse(delta).wallNew).toHaveLength(0);
|
||||
} finally {
|
||||
doc.queryJson = spy;
|
||||
}
|
||||
});
|
||||
|
||||
it("hiddenClassCodes: Elternklasse aus ⇒ Kinder aus; hide ergänzt", () => {
|
||||
const s = hiddenClassCodes(withLayer(p, "20", false), ["31"]);
|
||||
expect(s.has("20") && s.has("21") && s.has("31")).toBe(true);
|
||||
expect(s.has("30")).toBe(false);
|
||||
});
|
||||
});
|
||||
+42
-11
@@ -41,6 +41,7 @@
|
||||
// `toWalls3d/` — siehe dort für die konkrete Emissions-Logik je Bauteil.
|
||||
|
||||
import type { Project, Vec2 } from "../model/types";
|
||||
import { collectVisibleCodes, flattenCategories } from "../model/types";
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
import { documentFor } from "../core/document";
|
||||
import { coreEpoch } from "../engine/coreWasm";
|
||||
@@ -72,8 +73,31 @@ export function emitDrawingLineVerts(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]): Spuren heben sich mit ihrem Geschoss; 0 = aus. */
|
||||
explode = 0,
|
||||
/** [180] Zusätzlich ausgeblendete Klassen (Darstellungsmodus), s. {@link Model3dOptions.hide}. */
|
||||
hide?: readonly string[],
|
||||
): Float32Array {
|
||||
return documentFor(project).drawingLineVerts(explodeGap(explode));
|
||||
return documentFor(project).drawingLineVerts(explodeGap(explode), classFilterText(hide));
|
||||
}
|
||||
|
||||
/**
|
||||
* [180] Klassen-Filter der 3D-Abfragen (Kern `model3d::ClassFilter`): der Kern blendet die Klassen aus, die im
|
||||
* Ebenen-Baum aus sind (Ebenen-Panel, Kombinationen, Vorlagen); `hide` ergänzt die, die der Darstellungsmodus
|
||||
* nicht zeichnet (`categoryDisplay(code).render === false`).
|
||||
*/
|
||||
export function classFilterText(hide?: readonly string[], extra?: Record<string, unknown>): string {
|
||||
const h = hide && hide.length ? { hide } : {};
|
||||
return hide?.length || extra ? JSON.stringify({ ...extra, ...h }) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* [180] Ausgeblendete Klassen-Codes (Ebenen-Baum samt Elternklassen, dazu `hide`) — für die TS-seitigen
|
||||
* 3D-Teile (truck-Körper); alles andere filtert der Kern.
|
||||
*/
|
||||
export function hiddenClassCodes(project: Project, hide?: readonly string[]): Set<string> {
|
||||
const out = new Set(hide ?? []);
|
||||
const visible = collectVisibleCodes(project.layers ?? []);
|
||||
for (const c of flattenCategories(project.layers ?? [])) if (!visible.has(c.code)) out.add(c.code);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,8 +117,10 @@ export function emitSurfacePatternLines(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]): Linien heben sich mit dem Geschoss ihres Bauteils; 0 = aus. */
|
||||
explode = 0,
|
||||
/** [180] Zusätzlich ausgeblendete Klassen, s. {@link Model3dOptions.hide}. */
|
||||
hide?: readonly string[],
|
||||
): Float32Array {
|
||||
return documentFor(project).surfacePatternLines(explodeGap(explode));
|
||||
return documentFor(project).surfacePatternLines(explodeGap(explode), classFilterText(hide));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,6 +192,12 @@ export interface Model3dOptions {
|
||||
* Öffnungsdetail, „Handlauf aus" lässt die Handläufe weg. Rechnet ohne den inkrementellen Kern-Cache.
|
||||
*/
|
||||
modelView?: string;
|
||||
/**
|
||||
* [180] Klassen, die zusätzlich zum Ebenen-Baum nicht gezeichnet werden (Darstellungsmodus des Ebenen-Panels).
|
||||
* Ausgeblendete Klassen fehlen im Modell, in der Pick-Geometrie und im Export der Ansicht (Kern filtert nach dem
|
||||
* Cache, Umschalten rechnet keine Wand neu).
|
||||
*/
|
||||
hide?: readonly string[];
|
||||
}
|
||||
|
||||
/** Das volle 3D-Modell: Wände (mit Öffnungen) + Deckenplatten + Kontext-Meshes. */
|
||||
@@ -178,14 +210,11 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
const args = [layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, explode];
|
||||
// Ohne Explosion inkrementell ([58]): nur geänderte Wände reisen aus dem Kern und werden gelesen.
|
||||
const doc = documentFor(project);
|
||||
const parts = opts.modelView
|
||||
? doc.query<Model3dParts>("model3dParts", args, JSON.stringify({ modelView: opts.modelView }))
|
||||
: explode > 0
|
||||
? doc.query<Model3dParts>("model3dParts", args)
|
||||
: doc.model3dParts<Model3dParts>(args);
|
||||
const text = classFilterText(opts.hide, opts.modelView ? { modelView: opts.modelView } : undefined);
|
||||
const parts = opts.modelView || explode > 0 ? doc.query<Model3dParts>("model3dParts", args, text) : doc.model3dParts<Model3dParts>(args, text);
|
||||
// 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, parts.floorOffsets)) meshes.push(m);
|
||||
for (const m of emitExtrudedSolids(project, parts.floorOffsets, hiddenClassCodes(project, opts.hide))) 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);
|
||||
@@ -238,7 +267,7 @@ export function projectToModel3dParts(project: Project, opts: Model3dOptions = {
|
||||
if (explodeGap(opts.explode) > 0) return null;
|
||||
const voids = !!opts.voids && typeof window !== "undefined";
|
||||
const args = [layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, 0];
|
||||
const { parts, keyed } = documentFor(project).model3dPartsKeyed<Model3dParts>(args);
|
||||
const { parts, keyed } = documentFor(project).model3dPartsKeyed<Model3dParts>(args, classFilterText(opts.hide));
|
||||
const wallEntries = keyed.wallEntries as (readonly [number, RWall[]])[];
|
||||
const openingEntries = keyed.openingEntries as (readonly [number, RMesh[][]])[];
|
||||
// Abzugskörper wie im vollen Modell (gleiche Reihenfolge, gleicher truck-Cache); danach zuordnen,
|
||||
@@ -283,7 +312,7 @@ export function projectToModel3dParts(project: Project, opts: Model3dOptions = {
|
||||
const rest = (id: string, p: Omit<Model3dPart, "id" | "fixed">) => out.push({ id, fixed: false, ...p });
|
||||
rest("slabs", { slabs: vm.slabs, meshes: slabMeshes });
|
||||
rest("context", { meshes: parts.contextMeshes });
|
||||
rest("extrusions", { meshes: emitExtrudedSolids(project, parts.floorOffsets) });
|
||||
rest("extrusions", { meshes: emitExtrudedSolids(project, parts.floorOffsets, hiddenClassCodes(project, opts.hide)) });
|
||||
rest("columns", { meshes: parts.columnMeshes });
|
||||
rest("openingTail", { meshes: keyed.openingTail as RMesh[] });
|
||||
rest("stairs", { meshes: [...parts.stairMeshes, ...parts.stairRailings] });
|
||||
@@ -330,6 +359,8 @@ export function pickGeometry(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]) wie bei {@link projectToModel3d}; 0 = aus. */
|
||||
explode = 0,
|
||||
/** [180] Zusätzlich ausgeblendete Klassen (nicht anwählbar), s. {@link Model3dOptions.hide}. */
|
||||
hide?: readonly string[],
|
||||
): {
|
||||
walls: RWall[];
|
||||
slabs: RSlab[];
|
||||
@@ -346,7 +377,7 @@ export function pickGeometry(
|
||||
/** [149] Bäume (Stamm + Krone). */
|
||||
trees: PickTreeMesh[];
|
||||
} {
|
||||
const g = documentFor(project).query("pickGeometry", [explodeGap(explode)]) as ReturnType<typeof pickGeometry>;
|
||||
const g = documentFor(project).query("pickGeometry", [explodeGap(explode)], classFilterText(hide)) as ReturnType<typeof pickGeometry>;
|
||||
// [137] Freie Körper: das geladene truck-Netz (Loft, Rotation, Verjüngung, Rundung) statt der Prisma-Näherung des Kerns.
|
||||
const gap = explodeGap(explode);
|
||||
const offsets = gap > 0 ? explodeFloorOffsets(project, gap) : undefined;
|
||||
|
||||
@@ -44,6 +44,8 @@ export function emitExtrudedSolids(
|
||||
project: Project,
|
||||
/** Explosionsaxonometrie ([65]): Versatz (m) je Geschoss-id; der Cache bleibt unverschoben. */
|
||||
floorOffsets?: Record<string, number>,
|
||||
/** [180] Ausgeblendete Klassen: deren Körper fehlen (Cache bleibt). */
|
||||
hiddenCodes?: ReadonlySet<string>,
|
||||
): RMesh[] {
|
||||
if (typeof window === "undefined") return [];
|
||||
const out: RMesh[] = [];
|
||||
@@ -58,6 +60,7 @@ export function emitExtrudedSolids(
|
||||
if (solid.points.length < 3 || solid.height <= 0) continue;
|
||||
// Abzugskörper sind kein Material (sie wirken über `voids3d.ts`).
|
||||
if (solid.operation === "subtract") continue;
|
||||
if (hiddenCodes?.has(solid.categoryCode)) continue;
|
||||
const signature = extrudedSolidSignature(solid);
|
||||
let entry = truckMeshCache.get(solid.id);
|
||||
if (!entry || entry.signature !== signature) {
|
||||
|
||||
Reference in new issue
Block a user