Aufgestauter Arbeitsstand: Stiftsätze, Bulge/Bögen, neue 2D-Befehle, Geo/Import-Fixes, Dach-Schnittfugen 3D
Sammel-Commit für mehrere Wochen Arbeit seit dem letzten Commit-Stand (22.8.) — Details je Fund/Feature stehen datiert in PENDENZEN.md. - Stiftsatz-System (ArchiCAD-Stiftsatz-Vorbild): Bauteile/Ebenen/Element- Overrides wahlweise auf freie Farbe oder Stift+Stärke gekoppelt, eigene Palette-UI, 255-Stift-Standardpalette. - Wand-"+"-Kreuzung: vierte Wand an einem Knoten wurde nicht mitverschnitten (model/joins.ts). - 2D-Grundriss: Schnitt-vs-Ansicht-Entscheidung berücksichtigt jetzt wall.bottom/top-Override statt nur der rohen Wandhöhe. - Bulge/Bogensegmente in Polylinien (geometry/bulge.ts) inkl. Trim/Extend/ Offset/Fillet-Unterstützung. - Neue 2D-Befehle: Block/Blockdefinition, Leader, Polygon, Textpfad, Xline. - Kontext-Objekt-Kategorien (Ebenen-Zuordnung für importierte Gebäude/ Terrain-Meshes). - Element-Zwischenablage (Kopieren/Einfügen) für alle 3D-Elementarten. - swissBUILDINGS3D/DXF-Import-Fixes (Polyface-Mesh-Absturz, Georeferenzierung, anwählbare Kontext-Meshes im 3D-Viewport). - Dach-Schnittfugen im 3D-Live-Schnitt (render3d: roof_cut.rs neu). - Diverse kleinere Fixes/Ergänzungen in Grundriss-, Schnitt-, Ansichts- und 3D-Pipeline (siehe PENDENZEN.md für Einzelheiten). Verifiziert: tsc --noEmit sauber, vitest run 117/1206 grün, cargo test --package render3d 96/96 grün.
This commit is contained in:
1 parent
91908b1456
commit
ef40091f6d
136 files changed
+11109
-665
No files matched your search
@@ -95,6 +95,20 @@ function collectSegments(input: SnapInput): Seg[] {
|
||||
if (!input.visibleCodes.has(d.categoryCode)) continue;
|
||||
const g = d.geom;
|
||||
if (g.shape === "line") segs.push([g.a, g.b]);
|
||||
else if (g.shape === "xline") {
|
||||
// Weit verlängert (wie beim Rendern) — Lot-/Nächster-Punkt-Snap soll
|
||||
// entlang der ganzen (optisch unendlichen) Linie greifen, nicht nur
|
||||
// zwischen den beiden gesetzten Punkten.
|
||||
const dx = g.b.x - g.a.x, dy = g.b.y - g.a.y;
|
||||
const len = Math.hypot(dx, dy);
|
||||
if (len > 1e-6) {
|
||||
const ux = dx / len, uy = dy / len, ext = 1000;
|
||||
segs.push([
|
||||
{ x: g.a.x - ux * ext, y: g.a.y - uy * ext },
|
||||
{ x: g.b.x + ux * ext, y: g.b.y + uy * ext },
|
||||
]);
|
||||
}
|
||||
}
|
||||
else if (g.shape === "polyline") {
|
||||
for (let i = 0; i < g.pts.length - 1; i++) segs.push([g.pts[i], g.pts[i + 1]]);
|
||||
if (g.closed && g.pts.length > 2) segs.push([g.pts[g.pts.length - 1], g.pts[0]]);
|
||||
|
||||
@@ -410,6 +410,20 @@ function appendPolyline(project: Project, pts: Vec2[], closed: boolean, ctx: Too
|
||||
return { ...project, drawings2d: [...project.drawings2d, d] };
|
||||
}
|
||||
|
||||
// Konstruktionslinie: Platzhalter-Werkzeug, gekoppelt an den `xline`-Befehl
|
||||
// (zwei Punkte legen die Richtung fest, Rendering/Snapping verlängern weit
|
||||
// darüber hinaus). Nicht floorOnly (freies 2D-Element).
|
||||
const xlineTool: Tool = {
|
||||
id: "xline",
|
||||
labelKey: "tool.xline",
|
||||
hintKey: () => "tool.xline.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
const polylineTool: Tool = {
|
||||
id: "polyline",
|
||||
labelKey: "tool.polyline",
|
||||
@@ -567,6 +581,33 @@ const ellipseTool: Tool = {
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Regelmässiges Vieleck: Platzhalter-Werkzeug, gekoppelt an den `polygon`-
|
||||
// Befehl (Mittelpunkt → Radius, Ecken-Zahl per Inline-Option). Wie Kreis/
|
||||
// Bogen/Ellipse nicht floorOnly; committet als geschlossene Polylinie.
|
||||
const polygonTool: Tool = {
|
||||
id: "polygon",
|
||||
labelKey: "tool.polygon",
|
||||
hintKey: () => "tool.polygon.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Block einfügen: Platzhalter-Werkzeug, gekoppelt an den `block`-Befehl
|
||||
// (Einfügepunkt, aktive Definition per Inline-Option). Nicht floorOnly.
|
||||
const blockTool: Tool = {
|
||||
id: "block",
|
||||
labelKey: "tool.block",
|
||||
hintKey: () => "tool.block.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Spline: Platzhalter-Werkzeug, gekoppelt an den `spline`-Befehl (Wegpunkte,
|
||||
// wie Polylinie, aber geglättet). Nicht floorOnly.
|
||||
const splineTool: Tool = {
|
||||
@@ -632,6 +673,32 @@ const textTool: Tool = {
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Leader: Platzhalter-Werkzeug, gekoppelt an den `leader`-Befehl (Zielpunkt →
|
||||
// Textanker → getippte Zeile, wie Text). Freies 2D-Element (nicht floorOnly).
|
||||
const leaderTool: Tool = {
|
||||
id: "leader",
|
||||
labelKey: "tool.leader",
|
||||
hintKey: () => "tool.leader.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Text-entlang-Pfad: Platzhalter-Werkzeug, gekoppelt an den `textpath`-Befehl
|
||||
// (≥2 Pfadpunkte → getippte Zeile, wie Text). Freies 2D-Element.
|
||||
const textpathTool: Tool = {
|
||||
id: "textpath",
|
||||
labelKey: "tool.textpath",
|
||||
hintKey: () => "tool.textpath.hint",
|
||||
init: () => ({ phase: "idle" }),
|
||||
onClick: (s) => [s, { draft: null }],
|
||||
onMove: (s) => [s, { draft: null }],
|
||||
onCommitGesture: (s) => [s, { draft: null, done: true }],
|
||||
onCancel: (s) => [s, { draft: null, done: true }],
|
||||
};
|
||||
|
||||
// Textspalte: Platzhalter-Werkzeug, gekoppelt an den `textbox`-Befehl (Anker →
|
||||
// Spaltenbreite → getippte Zeile). Freies 2D-Element (nicht floorOnly).
|
||||
const textboxTool: Tool = {
|
||||
@@ -672,16 +739,21 @@ const TOOLS: Record<ToolId, Tool> = {
|
||||
stair: stairTool,
|
||||
room: roomTool,
|
||||
line: lineTool,
|
||||
xline: xlineTool,
|
||||
polyline: polylineTool,
|
||||
rect: rectTool,
|
||||
circle: circleTool,
|
||||
arc: arcTool,
|
||||
ellipse: ellipseTool,
|
||||
polygon: polygonTool,
|
||||
block: blockTool,
|
||||
spline: splineTool,
|
||||
bezier: bezierTool,
|
||||
dimension: dimensionTool,
|
||||
kote: koteTool,
|
||||
text: textTool,
|
||||
leader: leaderTool,
|
||||
textpath: textpathTool,
|
||||
textbox: textboxTool,
|
||||
image: imageTool,
|
||||
};
|
||||
|
||||
@@ -38,6 +38,48 @@ function line(id: string, x: number): Drawing2D {
|
||||
};
|
||||
}
|
||||
|
||||
describe("commitTransform — mirror kehrt das Bulge-Vorzeichen einer Polylinie um", () => {
|
||||
it("Spiegelung an der X-Achse negiert bulge (sonst wandert der Bogen auf die falsche Seite)", () => {
|
||||
const poly: Drawing2D = {
|
||||
id: "d-poly",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: {
|
||||
shape: "polyline",
|
||||
pts: [{ x: 0, y: 2 }, { x: 4, y: 2 }],
|
||||
closed: false,
|
||||
bulge: [0.6],
|
||||
},
|
||||
};
|
||||
const p = project([poly]);
|
||||
const sel: TransformSelection = { wallIds: [], drawingId: "d-poly", drawingIds: ["d-poly"] };
|
||||
// Spiegelachse = X-Achse (y=0).
|
||||
const next = commitTransform(p, sel, "mirror", [{ x: 0, y: 0 }, { x: 1, y: 0 }], "move", 1);
|
||||
const g = next.drawings2d[0].geom;
|
||||
expect(g.shape).toBe("polyline");
|
||||
if (g.shape === "polyline") {
|
||||
expect(g.pts).toEqual([{ x: 0, y: -2 }, { x: 4, y: -2 }]);
|
||||
expect(g.bulge?.[0]).toBeCloseTo(-0.6, 6);
|
||||
}
|
||||
});
|
||||
|
||||
it("reine Verschiebung (move) lässt bulge unverändert (keine Orientierungsumkehr)", () => {
|
||||
const poly: Drawing2D = {
|
||||
id: "d-poly",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "polyline", pts: [{ x: 0, y: 0 }, { x: 4, y: 0 }], closed: false, bulge: [0.6] },
|
||||
};
|
||||
const p = project([poly]);
|
||||
const sel: TransformSelection = { wallIds: [], drawingId: "d-poly", drawingIds: ["d-poly"] };
|
||||
const next = commitTransform(p, sel, "move", [{ x: 0, y: 0 }, { x: 2, y: 3 }], "move", 1);
|
||||
const g = next.drawings2d[0].geom;
|
||||
if (g.shape === "polyline") expect(g.bulge?.[0]).toBeCloseTo(0.6, 6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("commitTransform — Mehrfachauswahl (drawingIds)", () => {
|
||||
it("move: verschiebt ALLE gewählten 2D-Elemente, nicht nur eines", () => {
|
||||
const p = project([line("d1", 0), line("d2", 5), line("d3", 10)]);
|
||||
|
||||
+37
-4
@@ -159,12 +159,27 @@ function mvColumn(col: Column, fn: (p: Vec2) => Vec2): Column {
|
||||
return { ...col, position: nb, rotation: Math.atan2(nt.y - nb.y, nt.x - nb.x) };
|
||||
}
|
||||
|
||||
const mvGeom = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2): Drawing2DGeom => {
|
||||
/** Bildet jeden Punkt einer 2D-Zeichengeometrie unter `fn` ab (Move/Mirror/Rotate/Array + Block-Rendering). */
|
||||
export const mvGeom = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2): Drawing2DGeom => {
|
||||
switch (geom.shape) {
|
||||
case "line":
|
||||
case "xline":
|
||||
return { ...geom, a: fn(geom.a), b: fn(geom.b) };
|
||||
case "polyline":
|
||||
return { ...geom, pts: geom.pts.map(fn) };
|
||||
case "polyline": {
|
||||
const pts = geom.pts.map(fn);
|
||||
if (!geom.bulge) return { ...geom, pts };
|
||||
// Bulge-Vorzeichen ist rein relativ zur Zeichenrichtung definiert (links
|
||||
// von a→b) — eine Spiegelung kehrt die Umlauf-Orientierung um und muss
|
||||
// daher auch jeden Bogen umkehren, sonst wandert er auf die falsche
|
||||
// Seite. Erkannt über die Umlauf-Orientierung eines Test-Dreiecks unter
|
||||
// `fn` (negativ ⇒ `fn` spiegelt) statt eine Spiegel-Op explizit zu
|
||||
// markieren — funktioniert für JEDE Isometrie (Move/Rotate/Mirror sind
|
||||
// alle nur `fn`-Closures, kein eigener Spiegel-Sonderpfad nötig).
|
||||
const p0 = fn({ x: 0, y: 0 }), p1 = fn({ x: 1, y: 0 }), p2 = fn({ x: 0, y: 1 });
|
||||
const signedArea = (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
|
||||
const bulge = signedArea < 0 ? geom.bulge.map((b) => -b) : geom.bulge;
|
||||
return { ...geom, pts, bulge };
|
||||
}
|
||||
case "rect": {
|
||||
// Achsparallel nur bei reiner Verschiebung erhaltbar; sonst → Polylinie.
|
||||
const c = [
|
||||
@@ -202,7 +217,25 @@ const mvGeom = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2): Drawing2DGeom => {
|
||||
case "kote":
|
||||
return { ...geom, at: fn(geom.at) };
|
||||
case "text":
|
||||
return { ...geom, at: fn(geom.at) };
|
||||
// Leader-Ziel bzw. Pfadpunkte (Text-entlang-Pfad) müssen mitwandern,
|
||||
// sonst zeigt der Pfeil/Pfad nach einem Move/Mirror/Rotate/Array auf die
|
||||
// alte Position.
|
||||
return {
|
||||
...geom,
|
||||
at: fn(geom.at),
|
||||
...(geom.leaderTarget ? { leaderTarget: fn(geom.leaderTarget) } : {}),
|
||||
...(geom.pathPts ? { pathPts: geom.pathPts.map(fn) } : {}),
|
||||
};
|
||||
case "block": {
|
||||
// Wie Column: Winkel aus einem transformierten Richtungspunkt zurück-
|
||||
// rechnen, damit Rotate/Mirror auch die Instanz-Ausrichtung mitnehmen
|
||||
// (nicht nur den Einfügepunkt) — reine Translation liesse die Symbole
|
||||
// beim Drehen der Auswahl in der alten Orientierung stehen.
|
||||
const tip = { x: geom.at.x + Math.cos(geom.rotation), y: geom.at.y + Math.sin(geom.rotation) };
|
||||
const nb = fn(geom.at);
|
||||
const nt = fn(tip);
|
||||
return { ...geom, at: nb, rotation: Math.atan2(nt.y - nb.y, nt.x - nb.x) };
|
||||
}
|
||||
case "image": {
|
||||
// Wie Text: nur die Position folgt der Transformation (Zentrum wandert
|
||||
// dorthin, wo `fn` es abbildet); die Box bleibt achsparallel/unverzerrt —
|
||||
|
||||
@@ -17,16 +17,21 @@ export type ToolId =
|
||||
| "stair"
|
||||
| "room"
|
||||
| "line"
|
||||
| "xline"
|
||||
| "polyline"
|
||||
| "rect"
|
||||
| "circle"
|
||||
| "arc"
|
||||
| "ellipse"
|
||||
| "polygon"
|
||||
| "block"
|
||||
| "spline"
|
||||
| "bezier"
|
||||
| "dimension"
|
||||
| "kote"
|
||||
| "text"
|
||||
| "leader"
|
||||
| "textpath"
|
||||
| "textbox"
|
||||
| "image";
|
||||
|
||||
|
||||
Reference in new issue
Block a user