[K4][6][8] Aktionen erzeugen Ops direkt statt Projekt → Projekt + diffToOps
- Store `applyChange(ops | (p) => ops, coalesceKey?)` geht ohne Differenz an den Kern; `setProject` erkennt `opsMutation`-Funktionen und nimmt deren Ops. - Umgestellt: Griffe (moveGripOf/moveElementByOf/moveEdgeOf, Decke/Dach/Treppe/Raum), Objekt-Info (updateWall/-Ceiling/-Opening/-Roof/-Stair/-Room/-Drawing2D, Farbe, Füllung, Vorder-/Hintergrund, Resize, Wand-/Deckendicke, Polylinien-Punkte), Auswahl verschieben/ kopieren/drehen (`transformOps`), Löschen der Auswahl (+ Schnittlinien, eine Gruppe), Ebenen/Sichtbarkeit/Kategorien, Text-Tippen, Panel-Zeichnungs-Eigenschaften und die Zeichenbefehle (Wand, Decke, Raum, Treppe, Öffnung, Dach, Stütze, Extrusion, alle 2D-Zeichenbefehle, move/copy/mirror/rotate/scale/array). Gruppen-Zuordnung beim Zeichnen in einer Gruppe über `activeGroupOps`. - Griff-Zug mit mitgeführten Ecken: je Mausschritt eine Gruppe mit Schlüssel → ein Undo-Schritt für den ganzen Zug; aufgeschobene Commits beim Loslassen als Gruppe. - Tests: Store-Zufallsfolgen (Leseansicht = Kern, Aktion = applyOps(vorher, ihre Ops), Undo bis Anfang/Redo bis Ende exakt), activeGroupOps = addNewElementsToActiveGroup; beim Umbau zusätzlich 2400 Zufallsschritte gegen die alte setProject-Fassung und 400 Transformationen gegen das alte commitTransform geprüft (gleiches Projekt bis auf erzeugte ids und fehlend/leere Listen). - Messung (vitest, 3000 Wände): Griff ziehen 3,3 → 0,2–0,3 ms/Schritt, Auswahl (300 Wände) verschieben 30 → 6–7 ms, Eigenschaft tippen 3 → 0,03 ms. Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
49 files changed
+1001
-750
No files matched your search
@@ -20,10 +20,11 @@ import type {
|
||||
CommandState,
|
||||
CmdOption,
|
||||
DraftShape,
|
||||
Project,
|
||||
ToolDraft,
|
||||
Vec2,
|
||||
} from "../types";
|
||||
import { addItems, opsMutation } from "../../core";
|
||||
import type { CoreOp } from "../../core";
|
||||
|
||||
/** Default-Ebene (Kategorie) für Dächer („31 Dächer"). */
|
||||
const ROOF_CATEGORY = "31";
|
||||
@@ -93,10 +94,10 @@ function roofDraft(a: Vec2, cursor: Vec2 | null): ToolDraft {
|
||||
}
|
||||
|
||||
/** Hängt ein Dach ans Projekt (immutabel). Entartete Rechtecke werden verworfen. */
|
||||
function appendRoof(p: Project, a: Vec2, b: Vec2, shape: RoofShape, ctx: CommandContext): Project {
|
||||
function appendRoof(a: Vec2, b: Vec2, shape: RoofShape, ctx: CommandContext): CoreOp[] {
|
||||
const w = Math.abs(b.x - a.x);
|
||||
const d = Math.abs(b.y - a.y);
|
||||
if (w < 0.1 || d < 0.1) return p;
|
||||
if (w < 0.1 || d < 0.1) return [];
|
||||
const roof: Roof = {
|
||||
id: uniqueId("RF"),
|
||||
type: "roof",
|
||||
@@ -111,8 +112,7 @@ function appendRoof(p: Project, a: Vec2, b: Vec2, shape: RoofShape, ctx: Command
|
||||
ridgeAxis: w >= d ? "x" : "y",
|
||||
thickness: 0.2,
|
||||
};
|
||||
const roofs = p.roofs ? [...p.roofs, roof] : [roof];
|
||||
return { ...p, roofs };
|
||||
return addItems("roofs", [roof]);
|
||||
}
|
||||
|
||||
const idle = (shape: RoofShape = "sattel"): [CommandState, CommandResult] => [
|
||||
@@ -157,7 +157,7 @@ export const roofCommand: Command = {
|
||||
const shape = s.shape;
|
||||
return [
|
||||
{ phase: "start", shape, lastPoint: null } as RoofIdle,
|
||||
{ draft: null, done: true, commit: (p) => appendRoof(p, a, b, shape, ctx) },
|
||||
{ draft: null, done: true, commit: opsMutation(() => appendRoof(a, b, shape, ctx)) },
|
||||
];
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user