3D: Fenster-/Tuerrahmen ohne ueberlappende Profile (Eckverbindung Pfosten/Riegel/Gehrung waehlbar), Dachflaechen am First/Grat auf Gehrung statt Durchdringung
This commit is contained in:
1 parent
5d1d3ba3f7
commit
44c21caf89
9 files changed
+340
-54
No files matched your search
@@ -562,6 +562,10 @@ export const de = {
|
||||
"oed.f.frameThickness": "Rahmenstärke quer (m)",
|
||||
"oed.f.frameDepth": "Rahmentiefe (m)",
|
||||
"oed.f.frameWidth": "Rahmenbreite Ansicht (m)",
|
||||
"oed.f.cornerJoin": "Rahmen-Ecken",
|
||||
"oed.cornerJoin.vertikal": "Pfosten durchlaufend",
|
||||
"oed.cornerJoin.horizontal": "Riegel durchlaufend",
|
||||
"oed.cornerJoin.gehrung": "Gehrung",
|
||||
"oed.f.transomHeight": "Oberlichthöhe (m)",
|
||||
"oed.f.mullionRows": "Kämpfer-/Sprossenzeilen",
|
||||
"oed.f.mullionCols": "Sprossen-Spalten",
|
||||
|
||||
@@ -561,6 +561,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"oed.f.frameThickness": "Frame depth across (m)",
|
||||
"oed.f.frameDepth": "Frame depth (m)",
|
||||
"oed.f.frameWidth": "Frame face width (m)",
|
||||
"oed.f.cornerJoin": "Frame corners",
|
||||
"oed.cornerJoin.vertikal": "Stiles through",
|
||||
"oed.cornerJoin.horizontal": "Rails through",
|
||||
"oed.cornerJoin.gehrung": "Mitre",
|
||||
"oed.f.transomHeight": "Transom height (m)",
|
||||
"oed.f.mullionRows": "Transom/muntin rows",
|
||||
"oed.f.mullionCols": "Muntin columns",
|
||||
|
||||
@@ -451,6 +451,9 @@ export interface BlockDef {
|
||||
* `kind: "door"`. Bündelt Bauart, Blattausführung und Standardmaße. Werte am
|
||||
* einzelnen Element (Breite/Höhe/Anschlag) übersteuern die Typ-Defaults.
|
||||
*/
|
||||
/** Eckverbindung von Rahmenprofilen (s. `WindowType.frameCornerJoin`). */
|
||||
export type FrameCornerJoin = "vertikal" | "horizontal" | "gehrung";
|
||||
|
||||
export interface DoorType {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -488,6 +491,14 @@ export interface DoorType {
|
||||
* gilt ein schmaler Default (~0.06 m). Steuert 2D-Rahmenkontur + 3D-Rahmen.
|
||||
*/
|
||||
frameWidth?: number;
|
||||
/**
|
||||
* Eckverbindung der Rahmen (Blend- und Flügelrahmen) in der Ansicht:
|
||||
* "vertikal" (Pfosten laufen durch, Riegel dazwischen — Default),
|
||||
* "horizontal" (Riegel laufen durch) oder "gehrung" (45°-Stoss). Wirkt im
|
||||
* 3D; vorher überlappten die Flügelrahmen-Profile an den Ecken (doppelte
|
||||
* Kanten bei „Schattiert mit Kanten").
|
||||
*/
|
||||
frameCornerJoin?: FrameCornerJoin;
|
||||
/**
|
||||
* Schichteinzug: Abstand der Rahmen-Vorderkante von einer Wandfläche (Meter).
|
||||
* 0/fehlt ⇒ bündig. > 0 ⇒ der Rahmen sitzt um diesen Betrag in die Wand
|
||||
@@ -592,6 +603,14 @@ export interface WindowType {
|
||||
* 2D-Rahmen-/Sprossenkontur und den 3D-Rahmen.
|
||||
*/
|
||||
frameWidth?: number;
|
||||
/**
|
||||
* Eckverbindung der Rahmen (Blend- und Flügelrahmen) in der Ansicht:
|
||||
* "vertikal" (Pfosten laufen durch, Riegel dazwischen — Default),
|
||||
* "horizontal" (Riegel laufen durch) oder "gehrung" (45°-Stoss). Wirkt im
|
||||
* 3D; vorher überlappten die Flügelrahmen-Profile an den Ecken (doppelte
|
||||
* Kanten bei „Schattiert mit Kanten").
|
||||
*/
|
||||
frameCornerJoin?: FrameCornerJoin;
|
||||
/**
|
||||
* Schichteinzug: Abstand der Rahmen-Vorderkante von einer Wandfläche (Meter).
|
||||
* 0/fehlt ⇒ bündig; > 0 ⇒ der Rahmen sitzt zurückgesetzt (klassisch hinter der
|
||||
|
||||
@@ -2365,11 +2365,12 @@ describe("emitRoofs (Dachflächen + Giebel als Meshes)", () => {
|
||||
expect(roofMeshes.length).toBe(1);
|
||||
const m = roofMeshes[0];
|
||||
expect(m.positions.every((v) => Number.isFinite(v))).toBe(true);
|
||||
// Walm hat KEINE Giebel (gables: []). Jede Fläche ist jetzt ein SOLIDER Slab
|
||||
// (Oberseite + Unterseite + Seitenwände): Quader-Fläche (4 Ecken) = 2+2+8 =
|
||||
// 12 Dreiecke, Dreiecks-Fläche (3 Ecken) = 1+1+6 = 8 Dreiecke.
|
||||
// 2 Quader × 12 + 2 Dreiecke × 8 = 40 Dreiecke = 120 Indizes.
|
||||
expect(m.indices.length).toBe(120);
|
||||
// Walm hat KEINE Giebel (gables: []). Jede Fläche ist ein SOLIDER Slab
|
||||
// (Oberseite + Unterseite + Stirnflächen NUR an freien Kanten — First/Grate
|
||||
// stossen auf Gehrung, s. mitredRoofOffsets): Quader-Fläche = 2+2+2 (nur
|
||||
// Traufe) = 6 Dreiecke, Dreiecks-Fläche = 1+1+2 = 4 Dreiecke.
|
||||
// 2 × 6 + 2 × 4 = 20 Dreiecke = 60 Indizes.
|
||||
expect(m.indices.length).toBe(60);
|
||||
const vcount = m.positions.length / 3;
|
||||
expect(m.indices.every((idx) => idx >= 0 && idx < vcount)).toBe(true);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { FrameCornerJoin } from "../../model/types";
|
||||
import { frameRingQuads } from "./openings";
|
||||
|
||||
type Q = ReturnType<typeof frameRingQuads>[number];
|
||||
// Eckenfolge (from,UK),(to,UK),(from,OK),(to,OK) → als Ring 0,1,3,2.
|
||||
const ring = (q: Q) => [q[0], q[1], q[3], q[2]];
|
||||
const area = (q: Q) => {
|
||||
const r = ring(q);
|
||||
let a = 0;
|
||||
for (let i = 0; i < 4; i++) a += r[i][0] * r[(i + 1) % 4][1] - r[(i + 1) % 4][0] * r[i][1];
|
||||
return Math.abs(a) / 2;
|
||||
};
|
||||
|
||||
describe("frameRingQuads", () => {
|
||||
const modes: FrameCornerJoin[] = ["vertikal", "horizontal", "gehrung"];
|
||||
for (const mode of modes) {
|
||||
it(`${mode}: Profile decken genau den Ring ab (keine Überlappung)`, () => {
|
||||
const qs = frameRingQuads(0, 1.2, 0.9, 2.1, 0.06, mode, true);
|
||||
expect(qs.length).toBe(4);
|
||||
const total = qs.reduce((a, q) => a + area(q), 0);
|
||||
const ringArea = 1.2 * 1.2 - (1.2 - 0.12) * (1.2 - 0.12);
|
||||
expect(total).toBeCloseTo(ringArea, 9);
|
||||
});
|
||||
it(`${mode}: ohne Schwelle (Tür) drei Profile`, () => {
|
||||
const qs = frameRingQuads(0, 1.0, 0, 2.1, 0.06, mode, false);
|
||||
expect(qs.length).toBe(3);
|
||||
const total = qs.reduce((a, q) => a + area(q), 0);
|
||||
expect(total).toBeCloseTo(1.0 * 2.1 - (1.0 - 0.12) * (2.1 - 0.06), 9);
|
||||
});
|
||||
}
|
||||
it("vertikal: Pfosten laufen durch, Riegel dazwischen", () => {
|
||||
const [left] = frameRingQuads(0, 1, 0, 1, 0.1, "vertikal", true);
|
||||
expect(left[0]).toEqual([0, 0]);
|
||||
expect(left[3]).toEqual([0.1, 1]);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
// und der Rollladen-/Sonnenschutzkasten typisierter Tür-/Fensteröffnungen — das
|
||||
// 3D-Pendant zu `generatePlan/openings.ts`.
|
||||
|
||||
import type { Opening, Project, SashDef, Wall } from "../../model/types";
|
||||
import type { FrameCornerJoin, Opening, Project, SashDef, Wall } from "../../model/types";
|
||||
import { getDoorType, getWindowType, glazingPanesOf, openingsOfWall } from "../../model/types";
|
||||
import { openingInterval, openingVerticalExtent } from "../../geometry/opening";
|
||||
import { wallVerticalExtent } from "../../model/wall";
|
||||
@@ -129,6 +129,84 @@ function openingAxisBox(
|
||||
return { positions, indices: [...OPENING_BOX_TRIS], kind: "extrusion", color };
|
||||
}
|
||||
|
||||
/**
|
||||
* Prisma mit beliebigem konvexem VIERECK als Ansichts-Querschnitt (in der
|
||||
* Öffnungsebene: u entlang der Wand, h = Welthöhe), extrudiert über
|
||||
* `[nMin,nMax]` quer zur Wand — für Gehrungs-Stösse (Trapez-Profile). Eckenfolge
|
||||
* wie {@link OPENING_BOX_TRIS}: q[0]=(from,UK), q[1]=(to,UK), q[2]=(from,OK),
|
||||
* q[3]=(to,OK) im Sinne der Topologie.
|
||||
*/
|
||||
function openingPlaneQuad(
|
||||
wall: Wall,
|
||||
q: [[number, number], [number, number], [number, number], [number, number]],
|
||||
nMin: number,
|
||||
nMax: number,
|
||||
color: RRgb,
|
||||
): RMesh | null {
|
||||
if (Math.abs(nMax - nMin) <= EPS) return null;
|
||||
const dx = wall.end.x - wall.start.x;
|
||||
const dy = wall.end.y - wall.start.y;
|
||||
const len = Math.hypot(dx, dy);
|
||||
if (len < 1e-9) return null;
|
||||
const ux = dx / len;
|
||||
const uy = dy / len;
|
||||
const nx = uy; // dieselbe (rechte) Normale wie openingAxisBox
|
||||
const ny = -ux;
|
||||
const positions: number[] = [];
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const [s, z] = q[i & 3];
|
||||
const t = i & 4 ? nMax : nMin;
|
||||
positions.push(wall.start.x + ux * s + nx * t, wall.start.y + uy * s + ny * t, z);
|
||||
}
|
||||
return { positions, indices: [...OPENING_BOX_TRIS], kind: "extrusion", color };
|
||||
}
|
||||
|
||||
/**
|
||||
* Rahmen-Ring (Pfosten links/rechts, Riegel oben, Riegel unten nur bei
|
||||
* `bottom`) über das Feld `[from,to]×[zB,zT]` mit Profilbreite `w`, OHNE
|
||||
* überlappende Profile: `join` entscheidet, welche Glieder an den Ecken
|
||||
* durchlaufen ("vertikal"/"horizontal") oder ob auf Gehrung gestossen wird.
|
||||
* Liefert die Glieder als (u,h)-Vierecke (Reihenfolge s. {@link openingPlaneQuad}).
|
||||
*/
|
||||
export function frameRingQuads(
|
||||
from: number,
|
||||
to: number,
|
||||
zB: number,
|
||||
zT: number,
|
||||
w: number,
|
||||
join: FrameCornerJoin,
|
||||
bottom: boolean,
|
||||
): Array<[[number, number], [number, number], [number, number], [number, number]]> {
|
||||
type Q = [[number, number], [number, number], [number, number], [number, number]];
|
||||
const box = (u0: number, u1: number, h0: number, h1: number): Q => [[u0, h0], [u1, h0], [u0, h1], [u1, h1]];
|
||||
const out: Q[] = [];
|
||||
if (to - from <= 2 * w + EPS || zT - zB <= (bottom ? 2 : 1) * w + EPS) {
|
||||
// Zu klein für einen Ring: ein Vollprofil.
|
||||
out.push(box(from, to, zB, zT));
|
||||
return out;
|
||||
}
|
||||
const bz = bottom ? zB + w : zB; // Unterkante des Innenfelds
|
||||
if (join === "horizontal") {
|
||||
out.push(box(from, to, zT - w, zT)); // Sturz-Riegel durchlaufend
|
||||
if (bottom) out.push(box(from, to, zB, zB + w));
|
||||
out.push(box(from, from + w, bz, zT - w));
|
||||
out.push(box(to - w, to, bz, zT - w));
|
||||
} else if (join === "gehrung") {
|
||||
// Oben: Trapez, Innenkante um w eingerückt.
|
||||
out.push([[from + w, zT - w], [to - w, zT - w], [from, zT], [to, zT]]);
|
||||
if (bottom) out.push([[from, zB], [to, zB], [from + w, zB + w], [to - w, zB + w]]);
|
||||
// Pfosten: aussen volle Höhe, innen bis an die Gehrung.
|
||||
out.push([[from, zB], [from + w, bz], [from, zT], [from + w, zT - w]]);
|
||||
out.push([[to - w, bz], [to, zB], [to - w, zT - w], [to, zT]]);
|
||||
} else {
|
||||
out.push(box(from, from + w, zB, zT)); // Pfosten durchlaufend (Default)
|
||||
out.push(box(to - w, to, zB, zT));
|
||||
out.push(box(from + w, to - w, zT - w, zT));
|
||||
if (bottom) out.push(box(from + w, to - w, zB, zB + w));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut EIN sehr dünnes Prisma mit FREI orientierter Längsachse IN der Öffnungs-
|
||||
* ebene — die diagonale Schwester von {@link openingAxisBox}. Die Längsachse
|
||||
@@ -316,6 +394,8 @@ interface OpeningFrameParams {
|
||||
/** Kassetten-Raster horizontal/vertikal (nur bei {@link panelled} relevant). */
|
||||
panelCols: number;
|
||||
panelRows: number;
|
||||
/** Eckverbindung von Blend- und Flügelrahmen (s. `WindowType.frameCornerJoin`). */
|
||||
cornerJoin: FrameCornerJoin;
|
||||
}
|
||||
|
||||
function resolveOpeningFrame(project: Project, wall: Wall, op: Opening): OpeningFrameParams | null {
|
||||
@@ -332,6 +412,7 @@ function resolveOpeningFrame(project: Project, wall: Wall, op: Opening): Opening
|
||||
dt.insetFace ?? "aussen",
|
||||
);
|
||||
return {
|
||||
cornerJoin: dt.frameCornerJoin ?? "vertikal",
|
||||
frameWidth: dt.frameWidth ?? DEFAULT_FRAME_WIDTH,
|
||||
acrossWallDepth,
|
||||
nMin,
|
||||
@@ -384,6 +465,7 @@ function resolveOpeningFrame(project: Project, wall: Wall, op: Opening): Opening
|
||||
}
|
||||
const wingCount = Math.max(1, sashes.filter((s) => s.kind === "fluegel").length);
|
||||
return {
|
||||
cornerJoin: wt.frameCornerJoin ?? "vertikal",
|
||||
frameWidth: wt.frameWidth ?? DEFAULT_FRAME_WIDTH,
|
||||
acrossWallDepth,
|
||||
nMin,
|
||||
@@ -454,13 +536,12 @@ function frameMeshesForOpening(
|
||||
// Blendrahmen-Riegel (volles Rahmen-Quer-Band nMin..nMax, Rahmenfarbe).
|
||||
const push = (from: number, to: number, zBottom: number, zTop: number): void =>
|
||||
pushC(from, to, zBottom, zTop, params.nMin, params.nMax, FRAME_RGB);
|
||||
// Pfosten (Laibungsseiten), über die volle Öffnungshöhe durchlaufend.
|
||||
push(iv.from, iv.from + fw, vert.zBottom, vert.zTop);
|
||||
push(iv.to - fw, iv.to, vert.zBottom, vert.zTop);
|
||||
// Sturz (oberer Riegel).
|
||||
push(iv.from + fw, iv.to - fw, vert.zTop - fw, vert.zTop);
|
||||
// Schwelle: Fenster immer, Tür nur mit Bodenanschlag (threshold).
|
||||
if (params.hasSill) push(iv.from + fw, iv.to - fw, vert.zBottom, vert.zBottom + fw);
|
||||
// Blendrahmen-Ring: Pfosten (Laibungsseiten), Sturz und — Fenster immer, Tür
|
||||
// nur mit Bodenanschlag (threshold) — Schwelle; Eckstoss je `cornerJoin`.
|
||||
for (const q of frameRingQuads(iv.from, iv.to, vert.zBottom, vert.zTop, fw, params.cornerJoin, params.hasSill)) {
|
||||
const mesh = openingPlaneQuad(wall, q, params.nMin, params.nMax, FRAME_RGB);
|
||||
if (mesh) out.push(mesh);
|
||||
}
|
||||
// Echtes Schwellenprofil (Tür, `threshold`): eine dünne, farblich abgesetzte
|
||||
// Leiste ÜBER DIE GANZE WANDDICKE am Fussboden (nicht nur die Rahmentiefe
|
||||
// wie der Blendrahmen-Riegel oben) — analog zur Fensterbank-Leiste
|
||||
@@ -542,8 +623,6 @@ function frameMeshesForOpening(
|
||||
const glassFrontN = params.nMax - 0.02;
|
||||
const symBackN = glassFrontN;
|
||||
const symFrontN = glassFrontN + 0.003;
|
||||
const pushSash = (from: number, to: number, zB: number, zT: number): void =>
|
||||
pushC(from, to, zB, zT, sashBackN, sashFrontN, FRAME_RGB);
|
||||
const pushSymbol = (u0: number, h0: number, u1: number, h1: number): void => {
|
||||
const mesh = openingPlaneBox(wall, u0, h0, u1, h1, SYMBOL_HALF_WIDTH, symFrontN, symBackN, SYMBOL_RGB);
|
||||
if (mesh) out.push(mesh);
|
||||
@@ -558,10 +637,12 @@ function frameMeshesForOpening(
|
||||
const bz = sashBottom;
|
||||
const tz = sashTop;
|
||||
if (ct - cf <= EPS || tz - bz <= EPS) continue;
|
||||
pushSash(cf, cf + sfw, bz, tz); // linker Flügelholm
|
||||
pushSash(ct - sfw, ct, bz, tz); // rechter Flügelholm
|
||||
pushSash(cf, ct, tz - sfw, tz); // oberer Flügelriegel
|
||||
pushSash(cf, ct, bz, bz + sfw); // unterer Flügelriegel
|
||||
// Flügelrahmen-Ring (Holme + Riegel) ohne Überlappung an den Ecken —
|
||||
// vorher liefen Holme UND Riegel über die volle Länge (doppelte Kanten).
|
||||
for (const q of frameRingQuads(cf, ct, bz, tz, sfw, params.cornerJoin, true)) {
|
||||
const mesh = openingPlaneQuad(wall, q, sashBackN, sashFrontN, FRAME_RGB);
|
||||
if (mesh) out.push(mesh);
|
||||
}
|
||||
// SIA-Öffnungssymbole (nur „fein") auf dem Glasfeld INNERHALB des Flügel-
|
||||
// rahmens — exakt wie in der 2D-Ansicht (s. toElevation): Dreh = V mit
|
||||
// Spitze am Bandseiten-Mittel des Glasfelds, Kipp = V mit Spitze oben Mitte.
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Vec3 } from "../../geometry/roof";
|
||||
import { mitredRoofOffsets } from "./roofs";
|
||||
|
||||
// Walmdach 12×7 m: zwei Trapeze + zwei Walm-Dreiecke, First (3,3)-(8,3).
|
||||
const planes: Vec3[][] = [
|
||||
[[-0.5, -0.5, 5.2], [11.5, -0.5, 5.2], [8, 3, 7.061], [3, 3, 7.061]],
|
||||
[[-0.5, 6.5, 5.2], [11.5, 6.5, 5.2], [8, 3, 7.061], [3, 3, 7.061]],
|
||||
[[-0.5, -0.5, 5.2], [-0.5, 6.5, 5.2], [3, 3, 7.061]],
|
||||
[[11.5, -0.5, 5.2], [11.5, 6.5, 5.2], [8, 3, 7.061]],
|
||||
];
|
||||
|
||||
const near = (a: Vec3, b: Vec3) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]) < 1e-6;
|
||||
|
||||
describe("mitredRoofOffsets", () => {
|
||||
const m = mitredRoofOffsets(planes);
|
||||
it("erkennt First und Grate als geteilte Kanten, Traufen als frei", () => {
|
||||
expect(m.shared[0]).toEqual([false, true, true, true]); // Traufe, Grat, First, Grat
|
||||
expect(m.shared[2]).toEqual([false, true, true]);
|
||||
});
|
||||
it("Unterseiten treffen sich am First-Apex in EINEM Punkt (Gehrung statt Durchdringung)", () => {
|
||||
const d = 0.27;
|
||||
const apexA = m.at(0, d)[3]; // (3,3) der Trapezfläche
|
||||
const apexB = m.at(1, d)[3];
|
||||
const apexC = m.at(2, d)[2]; // Walm-Spitze
|
||||
expect(near(apexA, apexB)).toBe(true);
|
||||
expect(near(apexA, apexC)).toBe(true);
|
||||
expect(apexA[2]).toBeLessThan(7.061);
|
||||
});
|
||||
it("Versatz 0 = Originalfläche, freie Traufecke bleibt senkrecht versetzt", () => {
|
||||
expect(m.at(0, 0)).toEqual(planes[0]);
|
||||
const eaves = m.at(0, 0.2)[0];
|
||||
// Traufecke (−0.5,−0.5) teilt den Grat mit dem Walm → gehrt, aber Höhe unter der Traufe.
|
||||
expect(eaves[2]).toBeLessThan(5.2);
|
||||
});
|
||||
});
|
||||
+117
-35
@@ -57,35 +57,119 @@ function planeNormalUp(pts: RoofVec3[]): [number, number, number] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Dachfläche als SOLIDER Slab (Oberseite + um `thickness` entlang der
|
||||
* Normalen nach unten versetzte Unterseite + umlaufende Seitenwände) — gibt dem
|
||||
* Dach eine echte Materialdicke statt einer papierdünnen Fläche. render3d
|
||||
* rendert doppelseitig, Winding ist unerheblich.
|
||||
* Gehrte Versatz-Ecken für ALLE Dachflächen eines Daches: liefert je Fläche die
|
||||
* um `d` (Meter, entlang der Flächennormalen nach innen) versetzten Ecken —
|
||||
* aber an Kanten, die sich zwei Flächen teilen (First/Grat/Knick), NICHT
|
||||
* stur entlang der EIGENEN Normalen, sondern auf der Gehrung: die Ecke liegt im
|
||||
* Schnitt der versetzten Ebenen beider Flächen. Vorher durchdrangen sich die
|
||||
* Slabs benachbarter Flächen am First, ihre Stirnflächen lagen deckungsgleich
|
||||
* auf der Nachbar-Oberseite (Störtriangle am First-Apex im „Schattiert mit
|
||||
* Kanten"-Modus). Freie Kanten (Traufe/Ortgang) behalten die senkrechte
|
||||
* Stirnfläche. `shared[i][k]` = Kante k→k+1 von Fläche i ist geteilt.
|
||||
*/
|
||||
function pushRoofSlab(
|
||||
export function mitredRoofOffsets(planes: RoofVec3[][]): {
|
||||
at: (i: number, d: number) => RoofVec3[];
|
||||
shared: boolean[][];
|
||||
} {
|
||||
const r = (v: number) => Math.round(v * 1e5);
|
||||
const pk = (p: RoofVec3) => `${r(p[0])},${r(p[1])},${r(p[2])}`;
|
||||
const ek = (a: RoofVec3, b: RoofVec3) => {
|
||||
const ka = pk(a);
|
||||
const kb = pk(b);
|
||||
return ka < kb ? `${ka}|${kb}` : `${kb}|${ka}`;
|
||||
};
|
||||
const edgeOwners = new Map<string, number[]>();
|
||||
planes.forEach((pts, i) => {
|
||||
for (let k = 0; k < pts.length; k++) {
|
||||
const key = ek(pts[k], pts[(k + 1) % pts.length]);
|
||||
const list = edgeOwners.get(key);
|
||||
if (list) list.push(i);
|
||||
else edgeOwners.set(key, [i]);
|
||||
}
|
||||
});
|
||||
const normals = planes.map((pts) => planeNormalUp(pts));
|
||||
const neighbor = planes.map((pts, i) =>
|
||||
pts.map((p, k) => {
|
||||
const owners = edgeOwners.get(ek(p, pts[(k + 1) % pts.length])) ?? [];
|
||||
const j = owners.find((o) => o !== i);
|
||||
return j === undefined ? -1 : j;
|
||||
}),
|
||||
);
|
||||
const shared = neighbor.map((row) => row.map((j) => j >= 0));
|
||||
const dot = (a: RoofVec3, b: RoofVec3) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||
const cross = (a: RoofVec3, b: RoofVec3): RoofVec3 => [
|
||||
a[1] * b[2] - a[2] * b[1],
|
||||
a[2] * b[0] - a[0] * b[2],
|
||||
a[0] * b[1] - a[1] * b[0],
|
||||
];
|
||||
// Ebene (Normale m, Abstand c: m·x = c) der Kante k→k+1 von Fläche i beim Versatz d:
|
||||
// geteilt → versetzte Nachbarebene (Gehrung), frei → senkrechte Stirnebene.
|
||||
const edgePlane = (i: number, k: number, d: number): [RoofVec3, number] => {
|
||||
const pts = planes[i];
|
||||
const a = pts[k];
|
||||
const b = pts[(k + 1) % pts.length];
|
||||
const j = neighbor[i][k];
|
||||
if (j >= 0) return [normals[j], dot(normals[j], planes[j][0]) - d];
|
||||
const dir: RoofVec3 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
||||
const m = cross(dir, normals[i]);
|
||||
return [m, dot(m, a)];
|
||||
};
|
||||
// Schnittpunkt dreier Ebenen (Cramer über Kreuzprodukte), null wenn entartet.
|
||||
const solve = (rows: Array<[RoofVec3, number]>): RoofVec3 | null => {
|
||||
const [[a, ca], [b, cb], [c, cc]] = rows;
|
||||
const bc = cross(b, c);
|
||||
const det = dot(a, bc);
|
||||
if (Math.abs(det) < 1e-9) return null;
|
||||
const cxa = cross(c, a);
|
||||
const axb = cross(a, b);
|
||||
return [
|
||||
(ca * bc[0] + cb * cxa[0] + cc * axb[0]) / det,
|
||||
(ca * bc[1] + cb * cxa[1] + cc * axb[1]) / det,
|
||||
(ca * bc[2] + cb * cxa[2] + cc * axb[2]) / det,
|
||||
];
|
||||
};
|
||||
const at = (i: number, d: number): RoofVec3[] => {
|
||||
const pts = planes[i];
|
||||
const n = normals[i];
|
||||
if (d <= EPS) return pts.map((p) => [p[0], p[1], p[2]]);
|
||||
const own: [RoofVec3, number] = [n, dot(n, pts[0]) - d];
|
||||
return pts.map((p, k) => {
|
||||
const prev = (k + pts.length - 1) % pts.length;
|
||||
const fallback: RoofVec3 = [p[0] - n[0] * d, p[1] - n[1] * d, p[2] - n[2] * d];
|
||||
if (!shared[i][prev] && !shared[i][k]) return fallback;
|
||||
const q = solve([own, edgePlane(i, prev, d), edgePlane(i, k, d)]);
|
||||
// Ausreisser (fast parallele Ebenen) abfangen: nicht weiter als ein paar
|
||||
// Dicken von der senkrechten Lösung entfernt.
|
||||
if (!q || Math.hypot(q[0] - fallback[0], q[1] - fallback[1], q[2] - fallback[2]) > 4 * d + 0.5) {
|
||||
return fallback;
|
||||
}
|
||||
return q;
|
||||
});
|
||||
};
|
||||
return { at, shared };
|
||||
}
|
||||
|
||||
/**
|
||||
* Slab einer Dachfläche zwischen fertigen Ober-/Unterseiten-Ecken (gleiche
|
||||
* Reihenfolge). Stirnflächen nur an FREIEN Kanten (`shared[k]` = false) — an
|
||||
* geteilten Kanten stossen die Nachbarflächen auf Gehrung, eine Stirnfläche
|
||||
* läge dort im Inneren des Dachs.
|
||||
*/
|
||||
function pushRoofSlabBetween(
|
||||
positions: number[],
|
||||
indices: number[],
|
||||
pts: RoofVec3[],
|
||||
thickness: number,
|
||||
top: RoofVec3[],
|
||||
bottom: RoofVec3[],
|
||||
shared: boolean[],
|
||||
): void {
|
||||
if (pts.length < 3 || thickness <= EPS) {
|
||||
pushFanTriangles(positions, indices, pts);
|
||||
return;
|
||||
}
|
||||
const nrm = planeNormalUp(pts);
|
||||
const bottom: RoofVec3[] = pts.map((p) => [
|
||||
p[0] - nrm[0] * thickness,
|
||||
p[1] - nrm[1] * thickness,
|
||||
p[2] - nrm[2] * thickness,
|
||||
]);
|
||||
pushFanTriangles(positions, indices, pts); // Oberseite
|
||||
pushFanTriangles(positions, indices, bottom); // Unterseite
|
||||
// Seitenwände: je Kante ein Quad (zwei Dreiecke) zwischen Ober- und Unterseite.
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
const j = (i + 1) % pts.length;
|
||||
pushFanTriangles(positions, indices, top);
|
||||
pushFanTriangles(positions, indices, bottom);
|
||||
for (let i = 0; i < top.length; i++) {
|
||||
if (shared[i]) continue;
|
||||
const j = (i + 1) % top.length;
|
||||
const base = positions.length / 3;
|
||||
positions.push(pts[i][0], pts[i][1], pts[i][2]);
|
||||
positions.push(pts[j][0], pts[j][1], pts[j][2]);
|
||||
positions.push(top[i][0], top[i][1], top[i][2]);
|
||||
positions.push(top[j][0], top[j][1], top[j][2]);
|
||||
positions.push(bottom[j][0], bottom[j][1], bottom[j][2]);
|
||||
positions.push(bottom[i][0], bottom[i][1], bottom[i][2]);
|
||||
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
||||
@@ -115,6 +199,7 @@ export function emitRoofs(project: Project): RMesh[] {
|
||||
// vorige gestapelt. Leere componentId (einschichtige thickness-Fallback) ⇒
|
||||
// Default-Dachfarbe. Eine Roof.color-Übersteuerung gilt für alle Schichten.
|
||||
const layers = roofLayers(project, roof);
|
||||
const mitre = mitredRoofOffsets(g.planes.map((pl) => pl.pts));
|
||||
layers.reduce((offsetAbove, layer) => {
|
||||
const t = Math.max(0, layer.thickness);
|
||||
if (t <= EPS) return offsetAbove;
|
||||
@@ -130,17 +215,14 @@ export function emitRoofs(project: Project): RMesh[] {
|
||||
: undefined;
|
||||
const positions: number[] = [];
|
||||
const indices: number[] = [];
|
||||
for (const plane of g.planes) {
|
||||
// Oberseite dieser Schicht = Dachfläche um `offsetAbove` entlang der
|
||||
// Normalen nach innen versetzt; Slab-Dicke = Schichtdicke.
|
||||
const nrm = planeNormalUp(plane.pts);
|
||||
const top: RoofVec3[] = plane.pts.map((p) => [
|
||||
p[0] - nrm[0] * offsetAbove,
|
||||
p[1] - nrm[1] * offsetAbove,
|
||||
p[2] - nrm[2] * offsetAbove,
|
||||
]);
|
||||
pushRoofSlab(positions, indices, top, t);
|
||||
}
|
||||
g.planes.forEach((plane, i) => {
|
||||
// Oberseite dieser Schicht = Dachfläche um `offsetAbove` nach innen
|
||||
// versetzt, Unterseite um `offsetAbove + t` — an First/Grat gehrt.
|
||||
if (plane.pts.length < 3) return;
|
||||
const top = mitre.at(i, offsetAbove);
|
||||
const bottom = mitre.at(i, offsetAbove + t);
|
||||
pushRoofSlabBetween(positions, indices, top, bottom, mitre.shared[i]);
|
||||
});
|
||||
if (indices.length > 0) out.push({ positions, indices, kind: "extrusion", color, materialIndex });
|
||||
return offsetAbove + t;
|
||||
}, 0);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { useEffect, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type {
|
||||
DoorType,
|
||||
FrameCornerJoin,
|
||||
Opening,
|
||||
OpeningKind,
|
||||
Project,
|
||||
@@ -453,6 +454,12 @@ function RahmenPanel({
|
||||
min={0}
|
||||
onCommit={(n) => patchDt({ frameWidth: n })}
|
||||
/>
|
||||
<SelField<FrameCornerJoin>
|
||||
label={t("oed.f.cornerJoin")}
|
||||
value={dt.frameCornerJoin ?? "vertikal"}
|
||||
options={cornerJoinOptions()}
|
||||
onChange={(v) => patchDt({ frameCornerJoin: v })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -477,12 +484,27 @@ function RahmenPanel({
|
||||
min={0}
|
||||
onCommit={(n) => patchWt({ frameWidth: n })}
|
||||
/>
|
||||
<SelField<FrameCornerJoin>
|
||||
label={t("oed.f.cornerJoin")}
|
||||
value={wt.frameCornerJoin ?? "vertikal"}
|
||||
options={cornerJoinOptions()}
|
||||
onChange={(v) => patchWt({ frameCornerJoin: v })}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Auswahl der Rahmen-Eckverbindung (s. `WindowType.frameCornerJoin`). */
|
||||
function cornerJoinOptions(): { value: FrameCornerJoin; label: string }[] {
|
||||
return [
|
||||
{ value: "vertikal", label: t("oed.cornerJoin.vertikal") },
|
||||
{ value: "horizontal", label: t("oed.cornerJoin.horizontal") },
|
||||
{ value: "gehrung", label: t("oed.cornerJoin.gehrung") },
|
||||
];
|
||||
}
|
||||
|
||||
/** Flügeleinteilung: Tabelle mit Flügel/Pfosten, Öffnungsart + Anschlag je Zeile. */
|
||||
function FluegelPanel({
|
||||
wt,
|
||||
|
||||
Reference in new issue
Block a user