3D: Schraffur der Wand-Oberseite folgt wie im 2D der Wandachse (topAngle; Daemmung nicht mehr 90 Grad verdreht)

This commit is contained in:
karim committed 2026-10-23 11:49:04 +02:00
1 parent 6b980d224e
commit 7db634d7d5
7 files changed
+69 -9

No files matched your search

+21
View File
@@ -2763,3 +2763,24 @@ describe("emitStairs — gerade Betontreppe im Schnitt: glatte Soffit-Untersicht
}
});
});
describe("Wand-Schraffur in der Draufsicht (topAngle)", () => {
it("relativeToWall-Muster folgt der Wandachse: Wand längs x → 0°, längs y → 90°", () => {
const p: Project = {
...sampleProject,
hatches: sampleProject.hatches.map((h) =>
h.id === "sia-insulation" ? { ...h, angle: 0, relativeToWall: true } : h,
),
};
const { walls } = projectToModel3d(p);
const ins = walls.filter((w) => w.hatch && w.hatch.pattern === 2 && w.hatch.relativeToWall && w.hatch.baseAngle === 0);
const along = (w: (typeof walls)[number], axis: 0 | 1) =>
Math.abs(w.end[axis] - w.start[axis]) > Math.abs(w.end[1 - axis] - w.start[1 - axis]);
const alongX = ins.filter((w) => along(w, 0));
const alongY = ins.filter((w) => along(w, 1));
expect(alongX.length).toBeGreaterThan(0);
expect(alongY.length).toBeGreaterThan(0);
for (const w of alongX) expect(Math.abs(((w.hatch!.topAngle ?? 99) + 360) % 180)).toBeLessThan(1e-6);
for (const w of alongY) expect(Math.abs((((w.hatch!.topAngle ?? 0) % 180) + 180) % 180 - 90)).toBeLessThan(1e-6);
});
});
+13 -1
View File
@@ -182,6 +182,18 @@ function resolveWallBands(project: Project, wall: Wall, layered = true): WallBan
}
}
/**
* Setzt `topAngle` (Draufsicht): wie der 2D-Grundriss — das Muster folgt der Wandachse
* (`relativeToWall`), `resolveHatch` zieht den Wandwinkel ab (SVG-Konvention, y nach unten);
* render3d rechnet in Modell-Winkeln (gegen den Uhrzeigersinn), daher das Vorzeichen.
*/
function withTopAngle(h: RHatch, dx: number, dy: number): RHatch {
if (h.baseAngle === undefined) return h;
const wallAngle = (Math.atan2(dy, dx) * 180) / Math.PI;
const svgAngle = h.relativeToWall ? h.baseAngle - wallAngle : h.baseAngle;
return { ...h, topAngle: -svgAngle };
}
/**
* Hängt eine Wand-Schicht-Box an: das Achsenstück [from..to] (Meter ab
* Wand-Startpunkt) über den Höhenbereich [zBottom..zTop], quer um `normalOffset`
@@ -245,7 +257,7 @@ function pushSegment(
color,
layers: [],
wallId,
...(hatch ? { hatch } : {}),
...(hatch ? { hatch: withTopAngle(hatch, dx, dy) } : {}),
...(materialIndex != null ? { materialIndex } : {}),
...(holes && holes.length > 0 ? { holes } : {}),
...(cut ? { cut } : {}),
+22 -1
View File
@@ -47,6 +47,17 @@ export interface RHatch {
* Schraffur einstellbar ist (z. B. SIA `hatch-hair` 0.02 mm vs. `thin` 0.13 mm).
*/
lineWeight?: number;
/**
* Nur TS-intern: Grundwinkel der Schraffur (SVG-Konvention, vor Wandbezug) und ob das Muster
* der Wandachse folgt (`relativeToWall`). `pushSegment` leitet daraus {@link topAngle} ab.
*/
baseAngle?: number;
relativeToWall?: boolean;
/**
* Musterdrehung (Grad, Modell-Winkel gegen den Uhrzeigersinn) für die Wand-OBERSEITE in der
* Draufsicht — wie im 2D-Grundriss relativ zur Wandachse (render3d::Hatch.topAngle).
*/
topAngle?: number;
}
/** Bildet ein 2D-{@link HatchPattern} auf die Muster-Id von {@link RHatch}/CAP_WGSL ab. */
@@ -89,7 +100,17 @@ export function resolveComponentHatch(
// (`HatchRender.angle`, bereits relativeToWall-korrigiert) UND die Musterlinien-
// Stärke (`lineWeight`, aus dem LineStyle) — nicht mehr den rohen Hatch-Winkel.
const hr = resolveHatch(project, comp.hatchId, axisAngleDeg);
return { pattern: hatchPatternId(hr.pattern), angle: hr.angle, scale: hr.scale, lineWeight: hr.lineWeight };
// Wandbezug für die Draufsicht: Grundwinkel + ob das Muster der Wandachse folgt.
const abs = resolveHatch(project, comp.hatchId, undefined);
const relativeToWall = resolveHatch(project, comp.hatchId, 90).angle !== abs.angle;
return {
pattern: hatchPatternId(hr.pattern),
angle: hr.angle,
scale: hr.scale,
lineWeight: hr.lineWeight,
baseAngle: abs.angle,
relativeToWall,
};
} catch {
return undefined;
}