3D: Schraffur der Wand-Oberseite folgt wie im 2D der Wandachse (topAngle; Daemmung nicht mehr 90 Grad verdreht)
This commit is contained in:
1 parent
6b980d224e
commit
7db634d7d5
7 files changed
+69
-9
No files matched your search
@@ -168,7 +168,7 @@ mod tests {
|
||||
/// `wall_x` mit gesetzter Bauteil-Schraffur (Voraussetzung fuer die Kappen).
|
||||
fn wall_x_hatched(len: f32, thickness: f32, height: f32) -> WallInput {
|
||||
WallInput {
|
||||
hatch: Some(Hatch { pattern: 3, angle: 45.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 3, angle: 45.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
..wall_x(len, thickness, height)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,7 +989,7 @@ pub fn build_free_wall_end_caps(walls: &[WallInput]) -> Vec<f32> {
|
||||
let c = |p: Point2| -> [f32; 9] {
|
||||
[
|
||||
p[0], y, p[1], p[0], p[1],
|
||||
hatch.pattern as f32, hatch.angle.to_radians(), hatch.scale.max(0.05),
|
||||
hatch.pattern as f32, hatch.top_angle.unwrap_or(hatch.angle).to_radians(), hatch.scale.max(0.05),
|
||||
hatch.line_weight.max(0.0),
|
||||
]
|
||||
};
|
||||
|
||||
@@ -304,6 +304,7 @@ mod tests {
|
||||
angle: 90.0,
|
||||
scale: 2.0,
|
||||
line_weight: 0.5,
|
||||
top_angle: None,
|
||||
}),
|
||||
cut: None,
|
||||
};
|
||||
@@ -377,7 +378,7 @@ mod tests {
|
||||
layers: None,
|
||||
holes: vec![],
|
||||
material_index: None,
|
||||
hatch: Some(Hatch { pattern: 2, angle: 0.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 2, angle: 0.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: Some(CutBandMeta {
|
||||
join_priority: Some(50),
|
||||
component_id: Some("brick".into()),
|
||||
@@ -393,7 +394,7 @@ mod tests {
|
||||
z_bottom: 2.0,
|
||||
z_top: 2.4,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
hatch: Some(Hatch { pattern: 1, angle: 0.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 1, angle: 0.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: Some(CutBandMeta {
|
||||
join_priority: Some(100),
|
||||
component_id: Some("concrete".into()),
|
||||
@@ -451,7 +452,7 @@ mod tests {
|
||||
layers: None,
|
||||
holes: vec![],
|
||||
material_index: None,
|
||||
hatch: Some(Hatch { pattern: 2, angle: 0.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 2, angle: 0.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: Some(CutBandMeta {
|
||||
join_priority: Some(50),
|
||||
component_id: Some("brick".into()),
|
||||
@@ -467,7 +468,7 @@ mod tests {
|
||||
z_bottom: 1.0,
|
||||
z_top: 1.06,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
hatch: Some(Hatch { pattern: 3, angle: 0.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 3, angle: 0.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: Some(CutBandMeta {
|
||||
join_priority: Some(30),
|
||||
component_id: Some("screed".into()),
|
||||
@@ -482,7 +483,7 @@ mod tests {
|
||||
z_bottom: 0.96,
|
||||
z_top: 1.0,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
hatch: Some(Hatch { pattern: 4, angle: 0.0, scale: 1.0, line_weight: 0.13 }),
|
||||
hatch: Some(Hatch { pattern: 4, angle: 0.0, scale: 1.0, line_weight: 0.13, top_angle: None }),
|
||||
cut: Some(CutBandMeta {
|
||||
join_priority: Some(20),
|
||||
component_id: Some("insulation".into()),
|
||||
|
||||
@@ -47,6 +47,11 @@ pub struct Hatch {
|
||||
/// `thin` 0.13 mm). Default 0.13 (Alt-Verhalten/Haarlinie).
|
||||
#[serde(default = "default_hatch_line_weight", rename = "lineWeight")]
|
||||
pub line_weight: f32,
|
||||
/// Musterdrehung (Grad, Modell-Winkel gegen den Uhrzeigersinn) fuer die Wand-OBERSEITE
|
||||
/// (Draufsicht, Weltkoordinaten x/z): wie im 2D-Grundriss relativ zur Wandachse. Fehlt
|
||||
/// es, gilt `angle`.
|
||||
#[serde(default, rename = "topAngle")]
|
||||
pub top_angle: Option<f32>,
|
||||
}
|
||||
|
||||
fn default_hatch_scale() -> f32 {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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 } : {}),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user