[K4] S3: Transformation und 2D-Editier-Befehle im Kern (cmd_transform.rs, cmd_edit.rs)
Verschieben/Drehen/Spiegeln/Skalieren/Reihe (alle Elementarten, Vorschau je Mausschritt), Ausrichten/Verteilen, Block definieren, Trim, Extend, Verrunden, Fasen, Bruch, Offset, Join, Auflösen rechnen Treffer, Vorschau und Ops im Kern; TS behält die Zustandsautomaten. cmdMutation + doc_cmd_commit: rechnen und anwenden in einem Kern-Aufruf. Gelöscht: geometry/geomTransform.ts, tools/drawingPreview.ts, transformSolid, joinDrawings und die nicht mehr benutzten Kernel-Fassaden samt Bindungen. Gleichheit über Zufallsprojekte (temporäre Tests, gelöscht) s. TODO.md.
This commit is contained in:
45 files changed
+2612
-2620
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// Brücke der Befehle/Werkzeuge zum Kern ([K4] S3, `src-tauri/core/src/commands.rs`): Vorschau-Formen
|
||||
// aus flachen Puffern lesen und Abfragen zwischen den Schritten (Treffer, Vorschau) stellen. Die
|
||||
// Zustandsautomaten bleiben in den Befehlen; gerechnet wird im Kern.
|
||||
|
||||
import type { Project, Vec2 } from "../model/types";
|
||||
import type { DraftShape } from "./types";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
/** Punkt als Paar (Anfragen an den Kern). */
|
||||
export const pair = (p: Vec2): [number, number] => [p.x, p.y];
|
||||
|
||||
/**
|
||||
* Vorschau-Puffer des Kerns → Formen: je Form `[art, n, x0, y0, …]`, art 0 = Linie (n = 2),
|
||||
* 1 = geschlossenes Polygon, 2 = offener Linienzug.
|
||||
*/
|
||||
export function decodeShapes(f: ArrayLike<number>): DraftShape[] {
|
||||
const out: DraftShape[] = [];
|
||||
let i = 0;
|
||||
while (i + 1 < f.length) {
|
||||
const kind = f[i];
|
||||
const n = f[i + 1];
|
||||
i += 2;
|
||||
const pts: Vec2[] = new Array(n);
|
||||
for (let k = 0; k < n; k++, i += 2) pts[k] = { x: f[i], y: f[i + 1] };
|
||||
out.push(kind === 0 ? { kind: "line", a: pts[0], b: pts[1] } : { kind: "poly", pts, closed: kind === 1 });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Abfrage eines Befehls zwischen den Schritten (`cmd_edit::query`), auf dem Dokument von `project`. */
|
||||
export function cmdQuery<T>(project: Project, req: { q: string } & Record<string, unknown>): T {
|
||||
return documentFor(project).cmdQuery<T>(req);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Drawing2D, Project } from "../model/types";
|
||||
import { drawingPreviewShapes, primitivesToDraftShapes } from "./drawingPreview";
|
||||
import type { Primitive } from "../plan/generatePlan";
|
||||
|
||||
const project = { lineStyles: [], hatches: [], layers: [], drawings2d: [], blocks: [] } as unknown as Project;
|
||||
const base = { id: "d", levelId: "L", categoryCode: "10" } as unknown as Drawing2D;
|
||||
|
||||
describe("Verschiebe-Vorschau für alle 2D-Formen", () => {
|
||||
it("Kreis → Liniensegmente rundum", () => {
|
||||
const s = drawingPreviewShapes(project, { ...base, geom: { shape: "circle", center: { x: 0, y: 0 }, r: 1 } } as Drawing2D);
|
||||
expect(s.length).toBeGreaterThan(10);
|
||||
expect(s.every((x) => x.kind === "line")).toBe(true);
|
||||
});
|
||||
it("Polylinie mit Bogen-Segment → Bogen abgetastet (nicht nur die Sehne)", () => {
|
||||
const s = drawingPreviewShapes(project, {
|
||||
...base,
|
||||
geom: { shape: "polyline", pts: [{ x: 0, y: 0 }, { x: 2, y: 0 }], closed: false, bulge: [0.5] },
|
||||
} as Drawing2D);
|
||||
expect(s.length).toBeGreaterThan(3);
|
||||
});
|
||||
it("Text → Rahmen-Polygon", () => {
|
||||
const p = { kind: "drawingText", at: { x: 0, y: 0 }, text: "Hallo", heightM: 1, angle: 0, color: "#000" } as unknown as Primitive;
|
||||
const s = primitivesToDraftShapes([p]);
|
||||
expect(s).toHaveLength(1);
|
||||
expect(s[0].kind).toBe("poly");
|
||||
});
|
||||
});
|
||||
@@ -1,89 +0,0 @@
|
||||
// Vorschau-Formen eines (transformierten) 2D-Elements für Verschieben/Kopieren/
|
||||
// Drehen/Spiegeln/Skalieren: das Element läuft durch DIESELBE Primitiv-Erzeugung
|
||||
// wie der Plan (Kern, `drawingPrimitives`), die Primitive werden in einfache Vorschau-Formen
|
||||
// (Linien/Polygone) übersetzt. So hat JEDE Form eine Vorschau — Kreis, Bogen,
|
||||
// Spline, Text, Bemassung, Kote, Block, Polylinien-Bögen … (vorher nur Linie/
|
||||
// Polylinie/Rechteck/Bild, alles andere war beim Verschieben unsichtbar).
|
||||
|
||||
import type { Drawing2D, Project, Vec2 } from "../model/types";
|
||||
import type { Primitive } from "../core";
|
||||
import { drawingPrimitives } from "../core";
|
||||
import { textFrameCorners } from "../text/textFrame";
|
||||
import type { DraftShape } from "./types";
|
||||
|
||||
/** Obergrenze je Element (Schraffur-Muster u. Ä. können sehr viele Linien erzeugen). */
|
||||
const MAX_SHAPES_PER_ITEM = 4000;
|
||||
|
||||
function ringLines(center: Vec2, r: number, a0: number, a1: number, out: DraftShape[]): void {
|
||||
const sweep = a1 - a0;
|
||||
const n = Math.max(8, Math.ceil((Math.abs(sweep) / (Math.PI * 2)) * 48));
|
||||
let prev = { x: center.x + r * Math.cos(a0), y: center.y + r * Math.sin(a0) };
|
||||
for (let i = 1; i <= n; i++) {
|
||||
const a = a0 + (sweep * i) / n;
|
||||
const p = { x: center.x + r * Math.cos(a), y: center.y + r * Math.sin(a) };
|
||||
out.push({ kind: "line", a: prev, b: p });
|
||||
prev = p;
|
||||
}
|
||||
}
|
||||
|
||||
/** Plan-Primitive → Vorschau-Formen. */
|
||||
export function primitivesToDraftShapes(prims: readonly Primitive[]): DraftShape[] {
|
||||
const out: DraftShape[] = [];
|
||||
for (const p of prims) {
|
||||
if (out.length >= MAX_SHAPES_PER_ITEM) break;
|
||||
switch (p.kind) {
|
||||
case "line":
|
||||
out.push({ kind: "line", a: p.a, b: p.b });
|
||||
break;
|
||||
case "polygon":
|
||||
if (p.pts.length >= 2) out.push({ kind: "poly", pts: p.pts, closed: true });
|
||||
break;
|
||||
case "drawingCircle":
|
||||
ringLines(p.center, p.r, 0, Math.PI * 2, out);
|
||||
break;
|
||||
case "drawingArc": {
|
||||
const TAU = Math.PI * 2;
|
||||
const sweep = (((p.a1 - p.a0) % TAU) + TAU) % TAU || TAU;
|
||||
ringLines(p.center, p.r, p.a0, p.a0 + sweep, out);
|
||||
break;
|
||||
}
|
||||
case "arc": {
|
||||
const a0 = Math.atan2(p.from.y - p.center.y, p.from.x - p.center.x);
|
||||
const a1 = Math.atan2(p.to.y - p.center.y, p.to.x - p.center.x);
|
||||
let d = a1 - a0;
|
||||
while (d <= -Math.PI) d += 2 * Math.PI;
|
||||
while (d > Math.PI) d -= 2 * Math.PI;
|
||||
const r = Math.hypot(p.from.x - p.center.x, p.from.y - p.center.y);
|
||||
ringLines(p.center, r, a0, a0 + d, out);
|
||||
break;
|
||||
}
|
||||
case "drawingText":
|
||||
out.push({ kind: "poly", pts: textFrameCorners(p), closed: true });
|
||||
break;
|
||||
case "drawingTextPath":
|
||||
for (let i = 0; i + 1 < p.pathPts.length; i++) out.push({ kind: "line", a: p.pathPts[i], b: p.pathPts[i + 1] });
|
||||
break;
|
||||
case "drawingImage":
|
||||
out.push({
|
||||
kind: "poly",
|
||||
pts: [p.min, { x: p.max.x, y: p.min.y }, p.max, { x: p.min.x, y: p.max.y }],
|
||||
closed: true,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Vorschau-Formen eines 2D-Elements (Geometrie bereits transformiert). */
|
||||
export function drawingPreviewShapes(project: Project, d: Drawing2D, scaleDenominator?: number): DraftShape[] {
|
||||
let prims: Primitive[];
|
||||
try {
|
||||
prims = drawingPrimitives(project, d, scaleDenominator);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
return primitivesToDraftShapes(prims);
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { commitTransform, rotateGizmoShapes } from "./transform";
|
||||
import { commitTransform, rotateGizmoShapes, transformPreview } from "./transform";
|
||||
import type { TransformSelection } from "./transform";
|
||||
import type { Ceiling, Drawing2D, ExtrudedSolid, Project, Roof, Room, Stair } from "../model/types";
|
||||
|
||||
@@ -469,3 +469,45 @@ describe("rotateGizmoShapes — Dreh-Darstellung (Referenz-/Winkel-Strahl + Radi
|
||||
expect(rotateGizmoShapes({ x: 1, y: 1 }, { x: 1, y: 1 }, { x: 5, y: 5 })).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("transformPreview — Vorschau für alle 2D-Formen (Kern, Plan-Primitive)", () => {
|
||||
const sel = (id: string): TransformSelection => ({ wallIds: [], drawingId: id });
|
||||
const at = (geom: Drawing2D["geom"]) => project([{ ...line("d", 0), geom }]);
|
||||
const move = [{ x: 0, y: 0 }, { x: 1, y: 0 }];
|
||||
it("Kreis → Liniensegmente rundum", () => {
|
||||
const s = transformPreview(at({ shape: "circle", center: { x: 0, y: 0 }, r: 1 }), sel("d"), "move", move, "move", 1);
|
||||
expect(s.length).toBeGreaterThan(10);
|
||||
expect(s.every((x) => x.kind === "line")).toBe(true);
|
||||
});
|
||||
it("Polylinie mit Bogen-Segment → Bogen abgetastet (nicht nur die Sehne)", () => {
|
||||
const g = { shape: "polyline", pts: [{ x: 0, y: 0 }, { x: 2, y: 0 }], closed: false, bulge: [0.5] } as Drawing2D["geom"];
|
||||
expect(transformPreview(at(g), sel("d"), "move", move, "move", 1).length).toBeGreaterThan(3);
|
||||
});
|
||||
it("Text → Rahmen-Polygon, verschoben", () => {
|
||||
const s = transformPreview(at({ shape: "text", at: { x: 0, y: 0 }, text: "Hallo", height: 1, angle: 0 }), sel("d"), "move", move, "move", 1);
|
||||
expect(s).toHaveLength(1);
|
||||
expect(s[0].kind).toBe("poly");
|
||||
if (s[0].kind === "poly") expect(s[0].pts[0].x).toBeCloseTo(1, 9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("commitTransform — B-Rep-Körper (Spezifikation als transform gewickelt)", () => {
|
||||
const body = {
|
||||
id: "b", type: "extrudedSolid", points: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 1 }, { x: 0, y: 1 }], height: 3,
|
||||
brep: { spec: { kind: "cuboid", min: [0, 0, 0], max: [2, 1, 3] }, origin: { x: 0, y: 0 } },
|
||||
} as unknown as ExtrudedSolid;
|
||||
const p = { ...project([]), extrudedSolids: [body] } as Project;
|
||||
const sel: TransformSelection = { wallIds: [], drawingId: null, extrudedSolidId: "b" };
|
||||
it("Drehung um 90°", () => {
|
||||
const r = commitTransform(p, sel, "rotate", [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }], "move", 1).extrudedSolids![0];
|
||||
const sp = r.brep!.spec as { kind: string; m: number[] };
|
||||
expect(sp.kind).toBe("transform");
|
||||
expect(sp.m[0]).toBeCloseTo(0, 12);
|
||||
expect(sp.m[1]).toBeCloseTo(-1, 12);
|
||||
expect(r.brep!.origin).toEqual(r.points[0]);
|
||||
});
|
||||
it("Skalierung skaliert auch die Höhe", () => {
|
||||
const r = commitTransform(p, sel, "scale", [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }], "move", 1).extrudedSolids![0];
|
||||
expect(r.height).toBe(6);
|
||||
});
|
||||
});
|
||||
+62
-478
@@ -6,36 +6,19 @@
|
||||
// O array — Original bleibt + N Kopien, je um den vollen Schritt versetzt.
|
||||
// P distribute — Original bleibt + N Kopien gleichmäßig zwischen Original und Ziel.
|
||||
//
|
||||
// Bezeichner englisch, UI-Text via t() (CONVENTIONS.md). Reine Funktionen + Geometrie;
|
||||
// die App hält den State und wendet die Ops aus `transformOps` an ([K4] S3).
|
||||
// Die Rechnung (Abbildung, alle Elementarten, Kopien, Vorschau-Formen) steht im Kern
|
||||
// (`src-tauri/core/src/cmd_transform.rs`, [K4] S3); hier die Typen, die Fassade und das Dreh-Gizmo.
|
||||
|
||||
import { transformSolid } from "../core";
|
||||
import type {
|
||||
Ceiling,
|
||||
Column,
|
||||
Drawing2D,
|
||||
Drawing2DGeom,
|
||||
ExtrudedSolid,
|
||||
Project,
|
||||
Roof,
|
||||
Room,
|
||||
Stair,
|
||||
Vec2,
|
||||
Wall,
|
||||
} from "../model/types";
|
||||
import { wallTypeThickness } from "../model/types";
|
||||
import { wallCorners } from "../model/geometry";
|
||||
import { columnFootprint } from "../core";
|
||||
import { stairOutline } from "../core";
|
||||
import type { Project, Vec2 } from "../model/types";
|
||||
import type { DraftShape } from "./types";
|
||||
import { drawingPreviewShapes } from "./drawingPreview";
|
||||
import { mvGeom, reversesOrientation, scaleFactor, scaleGeom } from "../core";
|
||||
import { uniqueId } from "./types";
|
||||
import { uniqueStamp } from "./types";
|
||||
import { decodeShapes, pair } from "./coreCmd";
|
||||
import type { CommandSelection } from "../commands/types";
|
||||
import { applyOps } from "../core";
|
||||
import type { CoreOp } from "../core";
|
||||
import { addItems, opsMutation, patchItems } from "../core";
|
||||
import type { ProjectMutation } from "../core";
|
||||
import type { CoreOp, ProjectMutation } from "../core";
|
||||
import { cmdMutation, documentFor } from "../core/document";
|
||||
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
|
||||
import { contentFontBaselineFromTop, TEXT_LINE_HEIGHT_MULT } from "../text/fontMetrics";
|
||||
|
||||
export type TransformOp = "move" | "rotate" | "mirror" | "scale";
|
||||
export type CopyMode = "move" | "copy" | "array" | "distribute"; // U / I / O / P
|
||||
@@ -101,344 +84,61 @@ export function hasTransformSelection(sel: CommandSelection): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
/** Vereinigt `drawingId`/`drawingIds` zu einer eindeutigen ID-Menge (dedupliziert). */
|
||||
function drawingIdSet(sel: TransformSelection): Set<string> {
|
||||
const ids = new Set(sel.drawingIds ?? []);
|
||||
if (sel.drawingId) ids.add(sel.drawingId);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/** Wie viele Klickpunkte die Operation braucht (Drehen = 3, sonst 2). */
|
||||
export const requiredPoints = (op: TransformOp): number => (op === "rotate" ? 3 : 2);
|
||||
|
||||
/**
|
||||
* Punkt-Transformation einer Operation bei „Anteil" t (0..1 oder Vielfache):
|
||||
* • move — Verschiebung um t·Vektor (pts[0]→pts[1]).
|
||||
* • rotate — Drehung um pts[0] um t·(Winkel(pts[2]) − Winkel(pts[1])).
|
||||
* • mirror — Spiegelung an der Achse pts[0]→pts[1] (t wird ignoriert).
|
||||
*/
|
||||
export function transformFn(op: TransformOp, pts: Vec2[], t: number): (p: Vec2) => Vec2 {
|
||||
if (op === "move") {
|
||||
const vx = (pts[1].x - pts[0].x) * t;
|
||||
const vy = (pts[1].y - pts[0].y) * t;
|
||||
return (p) => ({ x: p.x + vx, y: p.y + vy });
|
||||
}
|
||||
if (op === "rotate") {
|
||||
const c = pts[0];
|
||||
const a0 = Math.atan2(pts[1].y - c.y, pts[1].x - c.x);
|
||||
const a1 = Math.atan2(pts[2].y - c.y, pts[2].x - c.x);
|
||||
const ang = (a1 - a0) * t;
|
||||
const cos = Math.cos(ang), sin = Math.sin(ang);
|
||||
return (p) => {
|
||||
const dx = p.x - c.x, dy = p.y - c.y;
|
||||
return { x: c.x + dx * cos - dy * sin, y: c.y + dx * sin + dy * cos };
|
||||
};
|
||||
}
|
||||
if (op === "scale") {
|
||||
// Gleichmässige Skalierung um pts[0]; der Faktor ist das Längenverhältnis
|
||||
// Referenz→Ziel (getippter Faktor wird vom Befehl in solche Punkte
|
||||
// übersetzt). `t` interpoliert für die Vorschau/Reihen-Kopien.
|
||||
const c = pts[0];
|
||||
const f = scaleFactor(pts, t);
|
||||
return (p) => ({ x: c.x + (p.x - c.x) * f, y: c.y + (p.y - c.y) * f });
|
||||
}
|
||||
// mirror: Spiegelung an der Geraden pts[0]→pts[1].
|
||||
const a = pts[0], b = pts[1];
|
||||
const dx = b.x - a.x, dy = b.y - a.y;
|
||||
const len2 = dx * dx + dy * dy || 1;
|
||||
return (p) => {
|
||||
// Projektion von p auf die Achse, dann gespiegelt.
|
||||
const tt = ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2;
|
||||
const fx = a.x + dx * tt, fy = a.y + dy * tt;
|
||||
return { x: 2 * fx - p.x, y: 2 * fy - p.y };
|
||||
const pairs = (pts: readonly Vec2[]): [number, number][] => pts.map(pair);
|
||||
|
||||
/** Vorschau-Formen einer Transformation aus dem Kern (Zeichnungen über die Plan-Primitive). */
|
||||
function previewShapes(
|
||||
project: Project,
|
||||
sel: TransformSelection,
|
||||
op: TransformOp,
|
||||
pts: readonly Vec2[],
|
||||
mode: CopyMode,
|
||||
count: number,
|
||||
opts: { ignoreLock?: boolean; scale?: number } = {},
|
||||
): DraftShape[] {
|
||||
const req = {
|
||||
cmd: "transform",
|
||||
sel,
|
||||
op,
|
||||
pts: pairs(pts),
|
||||
mode,
|
||||
count,
|
||||
ignoreLock: !!opts.ignoreLock,
|
||||
scale: opts.scale ?? DEFAULT_SCALE_DENOMINATOR,
|
||||
top: contentFontBaselineFromTop(TEXT_LINE_HEIGHT_MULT),
|
||||
};
|
||||
return decodeShapes(documentFor(project).cmdPreview(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* Die „Anteile" t der KOPIEN (ohne Original) je Modus. Beim Spiegeln ergeben
|
||||
* Array/Verteilen keine Reihe (Spiegelung ist selbstinvers) → genau eine Kopie.
|
||||
*/
|
||||
export function copyTs(op: TransformOp, mode: CopyMode, count: number): number[] {
|
||||
if (mode === "move") return [];
|
||||
if (op === "mirror") return [1]; // copy/array/distribute → eine gespiegelte Kopie
|
||||
if (mode === "copy") return [1];
|
||||
const n = Math.max(1, Math.floor(count));
|
||||
if (mode === "array") return Array.from({ length: n }, (_, k) => k + 1);
|
||||
// distribute: n Kopien gleichmäßig zwischen Original (0) und Ziel (1).
|
||||
return Array.from({ length: n }, (_, k) => (k + 1) / n);
|
||||
}
|
||||
|
||||
/** Wird beim Modus „move" (U) das Original selbst transformiert? */
|
||||
export const movesOriginal = (mode: CopyMode): boolean => mode === "move";
|
||||
|
||||
// ── Geometrie einer Auswahl ─────────────────────────────────────────────────
|
||||
|
||||
interface SelItem {
|
||||
kind: "wall";
|
||||
wall: Wall;
|
||||
}
|
||||
interface SelDrawingItem {
|
||||
kind: "drawing";
|
||||
drawing: Drawing2D;
|
||||
}
|
||||
interface SelExtrudedItem {
|
||||
kind: "extrudedSolid";
|
||||
solid: ExtrudedSolid;
|
||||
}
|
||||
interface SelColumnItem {
|
||||
kind: "column";
|
||||
column: Column;
|
||||
}
|
||||
interface SelCeilingItem {
|
||||
kind: "ceiling";
|
||||
ceiling: Ceiling;
|
||||
}
|
||||
interface SelRoofItem {
|
||||
kind: "roof";
|
||||
roof: Roof;
|
||||
}
|
||||
interface SelStairItem {
|
||||
kind: "stair";
|
||||
stair: Stair;
|
||||
}
|
||||
interface SelRoomItem {
|
||||
kind: "room";
|
||||
room: Room;
|
||||
}
|
||||
type AnyItem =
|
||||
| SelItem
|
||||
| SelDrawingItem
|
||||
| SelExtrudedItem
|
||||
| SelColumnItem
|
||||
| SelCeilingItem
|
||||
| SelRoofItem
|
||||
| SelStairItem
|
||||
| SelRoomItem;
|
||||
|
||||
// Dach: s. Doku bei TransformSelection.roofIds — Rotate/Mirror ausgenommen
|
||||
// (Umriss-Achsen-Invariante). EINZIGE Stelle, die das entscheidet — sowohl
|
||||
// `gatherItems` als auch der „Original bewegen"-Zweig in `commitTransform`
|
||||
// (der NICHT über `items` läuft, s. dort) müssen dieselbe Funktion befragen,
|
||||
// sonst bricht die Ausnahme an einer der beiden Stellen unbemerkt wieder.
|
||||
function roofTransformAllowed(op: TransformOp): boolean {
|
||||
return op !== "rotate" && op !== "mirror";
|
||||
}
|
||||
|
||||
function gatherItems(project: Project, sel: TransformSelection, op: TransformOp): AnyItem[] {
|
||||
const items: AnyItem[] = [];
|
||||
// Objekt-Sperre (`locked`, s. state/objectLock.ts): gesperrte Elemente
|
||||
// bleiben anwählbar, aber move/copy/mirror/rotate/scale/array lassen sie
|
||||
// unangetastet — dieselbe Semantik wie beim Griff-Ziehen (moveGrip/
|
||||
// moveElementBy in projectSlice.ts).
|
||||
const ids = new Set(sel.wallIds);
|
||||
for (const w of project.walls) if (ids.has(w.id) && !w.locked) items.push({ kind: "wall", wall: w });
|
||||
const drawIds = drawingIdSet(sel);
|
||||
for (const d of project.drawings2d)
|
||||
if (drawIds.has(d.id) && !d.locked) items.push({ kind: "drawing", drawing: d });
|
||||
if (sel.extrudedSolidId) {
|
||||
const s = (project.extrudedSolids ?? []).find((x) => x.id === sel.extrudedSolidId);
|
||||
if (s) items.push({ kind: "extrudedSolid", solid: s });
|
||||
}
|
||||
if (sel.columnId) {
|
||||
const c = (project.columns ?? []).find((x) => x.id === sel.columnId);
|
||||
if (c && !c.locked) items.push({ kind: "column", column: c });
|
||||
}
|
||||
const ceilingIds = new Set(sel.ceilingIds ?? []);
|
||||
for (const c of project.ceilings ?? [])
|
||||
if (ceilingIds.has(c.id) && !c.locked) items.push({ kind: "ceiling", ceiling: c });
|
||||
if (roofTransformAllowed(op)) {
|
||||
const roofIds = new Set(sel.roofIds ?? []);
|
||||
for (const r of project.roofs ?? [])
|
||||
if (roofIds.has(r.id) && !r.locked) items.push({ kind: "roof", roof: r });
|
||||
}
|
||||
const stairIds = new Set(sel.stairIds ?? []);
|
||||
for (const s of project.stairs ?? [])
|
||||
if (stairIds.has(s.id) && !s.locked) items.push({ kind: "stair", stair: s });
|
||||
const roomIds = new Set(sel.roomIds ?? []);
|
||||
for (const r of project.rooms ?? [])
|
||||
if (roomIds.has(r.id) && !r.locked) items.push({ kind: "room", room: r });
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformiert eine Stütze unter einer affinen Punkt-Abbildung `fn`
|
||||
* (Verschiebung/Drehung/Spiegelung): der Einfügepunkt wandert mit; die Profil-
|
||||
* Drehung folgt der Abbildung, indem ein Richtungsvektor (Länge 1 unter dem
|
||||
* aktuellen Winkel) mit-transformiert und der neue Winkel daraus gemessen wird
|
||||
* — das ergibt für alle drei Operationen die korrekte neue Ausrichtung.
|
||||
*/
|
||||
function mvColumn(col: Column, fn: (p: Vec2) => Vec2): Column {
|
||||
const base = col.position;
|
||||
const rot = col.rotation ?? 0;
|
||||
const tip = { x: base.x + Math.cos(rot), y: base.y + Math.sin(rot) };
|
||||
const nb = fn(base);
|
||||
const nt = fn(tip);
|
||||
return { ...col, position: nb, rotation: Math.atan2(nt.y - nb.y, nt.x - nb.x) };
|
||||
}
|
||||
|
||||
/** Bildet Umriss + Aussparungen einer Decke unter `fn` ab. */
|
||||
function mvCeiling(c: Ceiling, fn: (p: Vec2) => Vec2): Ceiling {
|
||||
return {
|
||||
...c,
|
||||
outline: c.outline.map(fn),
|
||||
...(c.openings ? { openings: c.openings.map((hole) => hole.map(fn)) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildet den Umriss eines Dachs unter `fn` ab. NUR für Move/Scale aufgerufen
|
||||
* (s. `TransformSelection.roofIds`) — beide erhalten die Rechteck-/Achsen-
|
||||
* Invariante des Umrisses, daher genügt reines Punkte-Mapping.
|
||||
*/
|
||||
function mvRoof(r: Roof, fn: (p: Vec2) => Vec2): Roof {
|
||||
return { ...r, outline: r.outline.map(fn) };
|
||||
}
|
||||
|
||||
/** Bildet Umriss + Stempel-Anker eines Raums unter `fn` ab. */
|
||||
function mvRoom(r: Room, fn: (p: Vec2) => Vec2): Room {
|
||||
return {
|
||||
...r,
|
||||
boundary: r.boundary.map(fn),
|
||||
...(r.stampAnchor ? { stampAnchor: fn(r.stampAnchor) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformiert eine Treppe unter `fn` (Skalierungsfaktor `f`, wie bei
|
||||
* {@link scaleGeom}): Antritt (+ Wendel-Zentrum) wandert mit; die Laufrichtung
|
||||
* folgt wie bei {@link mvColumn} über einen mit-transformierten Richtungs-
|
||||
* punkt. `turn` (L-Treppe) und `sweep` (Wendel) sind umlaufsinn-abhängig und
|
||||
* kippen daher unter einer Spiegelung ({@link reversesOrientation}), bleiben
|
||||
* aber unter Drehung/Verschiebung/Skalierung unverändert. Lauflänge/-breite/
|
||||
* Radius skalieren mit `f`; `totalRise` (eine Gebäudehöhe, Z) bleibt unberührt.
|
||||
*/
|
||||
function mvStair(s: Stair, fn: (p: Vec2) => Vec2, f: number): Stair {
|
||||
const start = fn(s.start);
|
||||
const tip = fn({ x: s.start.x + s.dir.x, y: s.start.y + s.dir.y });
|
||||
const dx = tip.x - start.x, dy = tip.y - start.y;
|
||||
const len = Math.hypot(dx, dy) || 1;
|
||||
const flips = reversesOrientation(fn);
|
||||
return {
|
||||
...s,
|
||||
start,
|
||||
dir: { x: dx / len, y: dy / len },
|
||||
runLength: s.runLength * f,
|
||||
width: s.width * f,
|
||||
...(s.run2Length !== undefined ? { run2Length: s.run2Length * f } : {}),
|
||||
...(s.turn !== undefined ? { turn: (flips ? -s.turn : s.turn) as 1 | -1 } : {}),
|
||||
...(s.center ? { center: fn(s.center) } : {}),
|
||||
...(s.radius !== undefined ? { radius: s.radius * f } : {}),
|
||||
...(s.sweep !== undefined ? { sweep: flips ? -s.sweep : s.sweep } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschau-Umriss einer Treppe unter `fn`. Gerade/L nutzen den echten
|
||||
* `stairOutline`-Kern; Wendel liefert dort Bogensegmente statt eines
|
||||
* Polygons — für die Live-Vorschau genügt ein grob abgetasteter Innen-/
|
||||
* Aussenring (kein Anspruch auf die exakte Stufenkontur).
|
||||
*/
|
||||
function stairPreviewShapes(stair: Stair, fn: (p: Vec2) => Vec2): DraftShape[] {
|
||||
if (stair.shape !== "spiral") {
|
||||
const { polygon } = stairOutline(stair, 0);
|
||||
return polygon ? [{ kind: "poly", pts: polygon.map(fn), closed: true }] : [];
|
||||
}
|
||||
const center = stair.center ?? stair.start;
|
||||
const rIn = Math.max(0, stair.radius ?? 0);
|
||||
const rOut = rIn + stair.width;
|
||||
const sweepDeg = stair.sweep ?? 360;
|
||||
const a0 = Math.atan2(stair.start.y - center.y, stair.start.x - center.x);
|
||||
const steps = Math.max(4, Math.round(Math.abs(sweepDeg) / 15));
|
||||
const outer: Vec2[] = [], inner: Vec2[] = [];
|
||||
for (let i = 0; i <= steps; i++) {
|
||||
const a = a0 + ((sweepDeg * Math.PI) / 180) * (i / steps);
|
||||
outer.push(fn({ x: center.x + Math.cos(a) * rOut, y: center.y + Math.sin(a) * rOut }));
|
||||
inner.push(fn({ x: center.x + Math.cos(a) * rIn, y: center.y + Math.sin(a) * rIn }));
|
||||
}
|
||||
return [{ kind: "poly", pts: [...outer, ...inner.reverse()], closed: true }];
|
||||
}
|
||||
|
||||
/** Vorschau-Formen für ein Element unter der Punkt-Transformation `fn`. */
|
||||
/** Vorschau eines einzelnen Flächen-Elements (Decke/Raum/Treppe) unter einer Verschiebung. */
|
||||
/** Vorschau eines einzelnen Elements unter einer Verschiebung (Griff-Vorschau; Sperre ohne Wirkung). */
|
||||
export function areaMovePreview(
|
||||
project: Project,
|
||||
kind: "ceiling" | "room" | "stair" | "wall",
|
||||
id: string,
|
||||
delta: Vec2,
|
||||
): DraftShape[] {
|
||||
const fn = (p: Vec2): Vec2 => ({ x: p.x + delta.x, y: p.y + delta.y });
|
||||
if (kind === "wall") {
|
||||
const w = project.walls.find((x) => x.id === id);
|
||||
return w ? itemPreview(project, { kind: "wall", wall: w } as AnyItem, fn) : [];
|
||||
}
|
||||
if (kind === "ceiling") {
|
||||
const c = (project.ceilings ?? []).find((x) => x.id === id);
|
||||
return c ? itemPreview(project, { kind: "ceiling", ceiling: c } as AnyItem, fn) : [];
|
||||
}
|
||||
if (kind === "room") {
|
||||
const r = (project.rooms ?? []).find((x) => x.id === id);
|
||||
return r ? itemPreview(project, { kind: "room", room: r } as AnyItem, fn) : [];
|
||||
}
|
||||
const st = (project.stairs ?? []).find((x) => x.id === id);
|
||||
return st ? itemPreview(project, { kind: "stair", stair: st } as AnyItem, fn) : [];
|
||||
const sel: TransformSelection = { wallIds: kind === "wall" ? [id] : [], drawingId: null };
|
||||
if (kind === "ceiling") sel.ceilingIds = [id];
|
||||
if (kind === "room") sel.roomIds = [id];
|
||||
if (kind === "stair") sel.stairIds = [id];
|
||||
return previewShapes(project, sel, "move", [{ x: 0, y: 0 }, delta], "move", 1, { ignoreLock: true });
|
||||
}
|
||||
|
||||
function itemPreview(project: Project, item: AnyItem, fn: (p: Vec2) => Vec2): DraftShape[] {
|
||||
if (item.kind === "wall") {
|
||||
const w = item.wall;
|
||||
const wt = project.wallTypes.find((t) => t.id === w.wallTypeId);
|
||||
const th = wt ? wallTypeThickness(wt) : 0.2;
|
||||
const a = fn(w.start), b = fn(w.end);
|
||||
return [
|
||||
{ kind: "poly", pts: wallCorners(a, b, th), closed: true },
|
||||
{ kind: "line", a, b },
|
||||
];
|
||||
}
|
||||
if (item.kind === "extrudedSolid") {
|
||||
return [{ kind: "poly", pts: item.solid.points.map(fn), closed: true }];
|
||||
}
|
||||
if (item.kind === "column") {
|
||||
return [{ kind: "poly", pts: columnFootprint(item.column).map(fn), closed: true }];
|
||||
}
|
||||
if (item.kind === "ceiling") {
|
||||
return [{ kind: "poly", pts: item.ceiling.outline.map(fn), closed: true }];
|
||||
}
|
||||
if (item.kind === "roof") {
|
||||
return [{ kind: "poly", pts: item.roof.outline.map(fn), closed: true }];
|
||||
}
|
||||
if (item.kind === "room") {
|
||||
return [{ kind: "poly", pts: item.room.boundary.map(fn), closed: true }];
|
||||
}
|
||||
if (item.kind === "stair") {
|
||||
return stairPreviewShapes(item.stair, fn);
|
||||
}
|
||||
const g = mvGeom(item.drawing.geom, fn);
|
||||
// Allgemein: dieselbe Primitiv-Erzeugung wie im Plan (alle Formen, inkl. Bögen
|
||||
// in Polylinien, Text, Bemassung, Kreis …). Fallback unten nur, falls daraus
|
||||
// nichts entsteht.
|
||||
const generic = drawingPreviewShapes(project, { ...item.drawing, geom: g });
|
||||
if (generic.length) return generic;
|
||||
switch (g.shape) {
|
||||
case "line":
|
||||
return [{ kind: "line", a: g.a, b: g.b }];
|
||||
case "polyline": {
|
||||
const out: DraftShape[] = [];
|
||||
for (let i = 0; i < g.pts.length - 1; i++) out.push({ kind: "line", a: g.pts[i], b: g.pts[i + 1] });
|
||||
if (g.closed && g.pts.length > 2) out.push({ kind: "line", a: g.pts[g.pts.length - 1], b: g.pts[0] });
|
||||
return out;
|
||||
}
|
||||
case "rect":
|
||||
case "image":
|
||||
return [{ kind: "poly", pts: [g.min, { x: g.max.x, y: g.min.y }, g.max, { x: g.min.x, y: g.max.y }], closed: true }];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
/** Vorschau einer verschobenen Zeichnung (aufgeschobenes Körper-Verschieben beim Griff-Ziehen). */
|
||||
export function drawingMovePreview(project: Project, id: string, delta: Vec2, scaleDenominator?: number): DraftShape[] {
|
||||
return previewShapes(project, { wallIds: [], drawingId: id }, "move", [{ x: 0, y: 0 }, delta], "move", 1, {
|
||||
ignoreLock: true,
|
||||
scale: scaleDenominator,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschau aller transformierten Instanzen (bewegtes Original bei U + alle
|
||||
* Kopien). `pts` sind die bisher gesetzten Punkte inkl. Cursor (Länge =
|
||||
* requiredPoints). Liefert die Stütz-/Basis-Punkte separat für Marker.
|
||||
* requiredPoints).
|
||||
*/
|
||||
export function transformPreview(
|
||||
project: Project,
|
||||
@@ -448,15 +148,7 @@ export function transformPreview(
|
||||
mode: CopyMode,
|
||||
count: number,
|
||||
): DraftShape[] {
|
||||
const items = gatherItems(project, sel, op);
|
||||
const shapes: DraftShape[] = [];
|
||||
const instances: number[] = [...copyTs(op, mode, count)];
|
||||
if (movesOriginal(mode)) instances.push(1); // U: Original an Endlage zeigen
|
||||
for (const t of instances) {
|
||||
const fn = transformFn(op, pts, t);
|
||||
for (const item of items) shapes.push(...itemPreview(project, item, fn));
|
||||
}
|
||||
return shapes;
|
||||
return previewShapes(project, sel, op, pts, mode, count);
|
||||
}
|
||||
|
||||
/** Anzahl Segmente des Radius-Kreises in {@link rotateGizmoShapes} — grob
|
||||
@@ -501,9 +193,21 @@ export function rotateGizmoShapes(center: Vec2, refPoint: Vec2, cursor: Vec2): D
|
||||
|
||||
// ── Commit ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/** Kern-Anfrage einer Transformation (neue ids: `prefix-Stempel-k`). */
|
||||
const transformReq = (sel: TransformSelection, op: TransformOp, pts: readonly Vec2[], mode: CopyMode, count: number) => ({
|
||||
cmd: "transform",
|
||||
sel,
|
||||
op,
|
||||
pts: pairs(pts),
|
||||
mode,
|
||||
count,
|
||||
stamp: uniqueStamp(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Die Transformation als Ops ([K4] S3): `replace` je bewegtem Original (nur bei „move"), `add` der
|
||||
* Kopien je Liste. Liest nur die gewählten Elemente — keine Projekt-Differenz über alle Wände.
|
||||
* Die Transformation als Ops ([K4] S3, Kern `cmd_transform::transform_ops`): `replace` je bewegtem
|
||||
* Original (nur bei „move"), `add` der Kopien je Liste. Gesperrte Elemente bleiben unberührt; Dächer
|
||||
* nur bei Verschieben/Skalieren.
|
||||
*/
|
||||
export function transformOps(
|
||||
project: Project,
|
||||
@@ -513,127 +217,7 @@ export function transformOps(
|
||||
mode: CopyMode,
|
||||
count: number,
|
||||
): CoreOp[] {
|
||||
const items = gatherItems(project, sel, op);
|
||||
if (items.length === 0) return [];
|
||||
const wallIds = new Set(sel.wallIds);
|
||||
// Bei einer Skalierung müssen auch Grössenfelder (Radius/Schrifthöhe/…)
|
||||
// mitziehen — dafür `scaleGeom` statt `mvGeom` (s. dort); analog für
|
||||
// Treppen `mvStair` mit dem Skalierungsfaktor statt Faktor 1.
|
||||
const geomAt = (geom: Drawing2DGeom, fn: (p: Vec2) => Vec2, t: number): Drawing2DGeom =>
|
||||
op === "scale" ? scaleGeom(geom, fn, scaleFactor(pts, t)) : mvGeom(geom, fn);
|
||||
const stairAt = (s: Stair, fn: (p: Vec2) => Vec2, t: number): Stair =>
|
||||
mvStair(s, fn, op === "scale" ? scaleFactor(pts, t) : 1);
|
||||
|
||||
const ceilingIds = new Set(sel.ceilingIds ?? []);
|
||||
const roofIds = new Set(sel.roofIds ?? []);
|
||||
const stairIds = new Set(sel.stairIds ?? []);
|
||||
const roomIds = new Set(sel.roomIds ?? []);
|
||||
const ops: CoreOp[] = [];
|
||||
|
||||
// U (move): Original an die Endlage (t=1) transformieren. Objekt-Sperre
|
||||
// (`locked`) überall mitgeprüft — dieselbe Semantik wie `gatherItems`
|
||||
// oben (das hier ist ein SEPARATER Pfad, der `items` nicht durchläuft,
|
||||
// s. Kommentar bei `roofTransformAllowed`-Nutzung als Präzedenzfall für
|
||||
// genau diese Art von Doppel-Pflege).
|
||||
if (movesOriginal(mode)) {
|
||||
const fn = transformFn(op, pts, 1);
|
||||
ops.push(
|
||||
...patchItems(project, "walls", (w) => wallIds.has(w.id) && !w.locked, (w) => ({
|
||||
...w,
|
||||
start: fn(w.start),
|
||||
end: fn(w.end),
|
||||
})),
|
||||
);
|
||||
const moveDrawIds = drawingIdSet(sel);
|
||||
if (moveDrawIds.size > 0) {
|
||||
ops.push(
|
||||
...patchItems(project, "drawings2d", (d) => moveDrawIds.has(d.id) && !d.locked, (d) => ({
|
||||
...d,
|
||||
geom: geomAt(d.geom, fn, 1),
|
||||
})),
|
||||
);
|
||||
}
|
||||
if (sel.extrudedSolidId) {
|
||||
// Skalierung: `points` (2D-Tesselierung fürs Grundriss-Polygon) UND der
|
||||
// echte Radius `circle.r` (den `toWalls3d.ts` für die runde 3D-Extrusion
|
||||
// nutzt) müssen mitziehen — sonst weicht das 3D-Volumen sichtbar von
|
||||
// der Grundriss-Kontur ab (nur `center` mitzuführen genügt nicht).
|
||||
const f1 = op === "scale" ? scaleFactor(pts, 1) : 1;
|
||||
const solidId = sel.extrudedSolidId;
|
||||
ops.push(...patchItems(project, "extrudedSolids", (s) => s.id === solidId, (s) => transformSolid(s, fn, f1)));
|
||||
}
|
||||
if (sel.columnId) {
|
||||
const columnId = sel.columnId;
|
||||
ops.push(...patchItems(project, "columns", (c) => c.id === columnId && !c.locked, (c) => mvColumn(c, fn)));
|
||||
}
|
||||
if (ceilingIds.size > 0)
|
||||
ops.push(...patchItems(project, "ceilings", (c) => ceilingIds.has(c.id) && !c.locked, (c) => mvCeiling(c, fn)));
|
||||
if (roofIds.size > 0 && roofTransformAllowed(op))
|
||||
ops.push(...patchItems(project, "roofs", (r) => roofIds.has(r.id) && !r.locked, (r) => mvRoof(r, fn)));
|
||||
if (stairIds.size > 0)
|
||||
ops.push(...patchItems(project, "stairs", (s) => stairIds.has(s.id) && !s.locked, (s) => stairAt(s, fn, 1)));
|
||||
if (roomIds.size > 0)
|
||||
ops.push(...patchItems(project, "rooms", (r) => roomIds.has(r.id) && !r.locked, (r) => mvRoom(r, fn)));
|
||||
}
|
||||
|
||||
// Kopien anhängen (I/O/P bzw. mirror copy).
|
||||
const newWalls: Wall[] = [];
|
||||
const newDrawings: Drawing2D[] = [];
|
||||
const newSolids: ExtrudedSolid[] = [];
|
||||
const newColumns: Column[] = [];
|
||||
const newCeilings: Ceiling[] = [];
|
||||
const newRoofs: Roof[] = [];
|
||||
const newStairs: Stair[] = [];
|
||||
const newRooms: Room[] = [];
|
||||
for (const t of copyTs(op, mode, count)) {
|
||||
const fn = transformFn(op, pts, t);
|
||||
for (const item of items) {
|
||||
switch (item.kind) {
|
||||
case "wall": {
|
||||
const w = item.wall;
|
||||
newWalls.push({ ...w, id: uniqueId("W"), start: fn(w.start), end: fn(w.end) });
|
||||
break;
|
||||
}
|
||||
case "drawing": {
|
||||
const d = item.drawing;
|
||||
newDrawings.push({ ...d, id: uniqueId("dr2d"), geom: geomAt(d.geom, fn, t) });
|
||||
break;
|
||||
}
|
||||
case "column":
|
||||
newColumns.push({ ...mvColumn(item.column, fn), id: uniqueId("column") });
|
||||
break;
|
||||
case "ceiling":
|
||||
newCeilings.push({ ...mvCeiling(item.ceiling, fn), id: uniqueId("C") });
|
||||
break;
|
||||
case "roof":
|
||||
newRoofs.push({ ...mvRoof(item.roof, fn), id: uniqueId("RF") });
|
||||
break;
|
||||
case "stair":
|
||||
newStairs.push({ ...stairAt(item.stair, fn, t), id: uniqueId("ST") });
|
||||
break;
|
||||
case "room":
|
||||
newRooms.push({ ...mvRoom(item.room, fn), id: uniqueId("RM") });
|
||||
break;
|
||||
case "extrudedSolid": {
|
||||
const s = item.solid;
|
||||
const f = op === "scale" ? scaleFactor(pts, t) : 1;
|
||||
newSolids.push({ ...transformSolid(s, fn, f), id: uniqueId("extrude") });
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ops.push(
|
||||
...addItems("walls", newWalls),
|
||||
...addItems("drawings2d", newDrawings),
|
||||
...addItems("extrudedSolids", newSolids),
|
||||
...addItems("columns", newColumns),
|
||||
...addItems("ceilings", newCeilings),
|
||||
...addItems("roofs", newRoofs),
|
||||
...addItems("stairs", newStairs),
|
||||
...addItems("rooms", newRooms),
|
||||
);
|
||||
return ops;
|
||||
return documentFor(project).cmdOps(transformReq(sel, op, pts, mode, count));
|
||||
}
|
||||
|
||||
/** Wendet die Transformation immutabel auf das Projekt an (Original + Kopien), über {@link transformOps}. */
|
||||
@@ -659,5 +243,5 @@ export function transformMutation(
|
||||
mode: CopyMode,
|
||||
count: number,
|
||||
): ProjectMutation {
|
||||
return opsMutation((p) => transformOps(p, sel, op, pts, mode, count));
|
||||
return cmdMutation(transformReq(sel, op, pts, mode, count));
|
||||
}
|
||||
@@ -372,3 +372,12 @@ export function uniqueId(prefix: string): string {
|
||||
idCounter += 1;
|
||||
return `${prefix}-${Date.now()}-${idCounter}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stempel für ids, die der Kern vergibt (Befehle mit mehreren neuen Elementen, [K4] S3): der Kern
|
||||
* hängt je Element `-k` an (`prefix-Zeit-Zähler-k`, s. `cmd_transform::IdGen`).
|
||||
*/
|
||||
export function uniqueStamp(): string {
|
||||
idCounter += 1;
|
||||
return `${Date.now()}-${idCounter}`;
|
||||
}
|
||||
Reference in new issue
Block a user