[333] 3D-Griffe: Treppe, Öffnung, Stütze; Plan: nächster Griff gewinnt
check / check (push) Canceled after 0s
check / licenses (push) Canceled after 0s
check / e2e (push) Canceled after 0s
macos / native (push) Canceled after 0s

Treppe (Bewegpunkt + Parameter-Griffe), Wandöffnung (Gleit-Griff auf Brüstungshöhe) und Stütze (Mitte, Ecken) haben 3D-Griffe mit denselben Kern-Anfragen wie im Plan. Plan-Treffer: nächster Griff statt erster im Radius (kleine Stütze: Ecke statt Mitte).
This commit is contained in:
Claude committed 2026-11-27 05:47:54 +00:00
1 parent 228921a193
commit 516eaf16be
16 files changed
+416 -19

No files matched your search

+13 -1
View File
@@ -44,6 +44,10 @@ type DerivedContentProps =
| "edit3dDrawings"
| "edit3dCeilings"
| "edit3dRoofs"
| "edit3dStairs"
| "edit3dOpenings"
| "edit3dColumns"
| "onEdit3dElement"
| "onEdit3dVertex"
| "onEdit3dBody"
| "onEdit3dEdge"
@@ -191,9 +195,13 @@ export function ViewportCenter(props: {
moveGripOf: pa.moveGripOf,
moveElementByOf: pa.moveElementByOf,
updateWall: pa.updateWall,
moveStairBy: pa.moveStairBy,
dragStairParam: pa.dragStairParam,
slideOpening: pa.slideOpening,
moveColumnGrip: pa.moveColumnGrip,
});
const {
edit3dWalls, edit3dDrawings, edit3dCeilings, edit3dRoofs, onEdit3dVertex, onEdit3dBody, onEdit3dEdge,
edit3dWalls, edit3dDrawings, edit3dCeilings, edit3dRoofs, edit3dStairs, edit3dOpenings, edit3dColumns, onEdit3dElement, onEdit3dVertex, onEdit3dBody, onEdit3dEdge,
onEdit3dRoofPitch, onEdit3dWallTop, onEdit3dEnd, cycleGrip3dEditField, cancelGrip3dEdit,
} = grip3d;
@@ -232,6 +240,10 @@ export function ViewportCenter(props: {
edit3dDrawings={edit3dDrawings}
edit3dCeilings={edit3dCeilings}
edit3dRoofs={edit3dRoofs}
edit3dStairs={edit3dStairs}
edit3dOpenings={edit3dOpenings}
edit3dColumns={edit3dColumns}
onEdit3dElement={onEdit3dElement}
onEdit3dVertex={onEdit3dVertex}
onEdit3dBody={onEdit3dBody}
onEdit3dEdge={onEdit3dEdge}
+22
View File
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { pickGripIndex } from "./gripPick";
// Stütze 12 cm: Mitte (Index 0) und Ecke (Index 1) nur 7 px auseinander.
const col = [{ x: 100, y: 100 }, { x: 107, y: 100 }, { x: 93, y: 100 }];
describe("pickGripIndex", () => {
it("Klick auf die Ecke trifft die Ecke, nicht die Mitte", () => {
expect(pickGripIndex(col, 107, 100, 9)).toBe(1);
expect(pickGripIndex(col, 93, 101, 9)).toBe(2);
});
it("Klick auf die Mitte trifft die Mitte", () => {
expect(pickGripIndex(col, 100, 100, 9)).toBe(0);
});
it("praktisch gleich nah: Ecke (höherer Index) vor Mitte", () => {
expect(pickGripIndex(col, 103.5, 100, 9)).toBe(1);
});
it("ausserhalb des Radius: null", () => {
expect(pickGripIndex(col, 140, 100, 9)).toBeNull();
expect(pickGripIndex([], 0, 0, 9)).toBeNull();
});
});
+21
View File
@@ -0,0 +1,21 @@
// Griff-Treffer im Plan ([333]): der NÄCHSTE Griff gewinnt, nicht der erste im Radius. Bei einer kleinen Stütze
// (12 cm) liegen die Eck-Griffe nur etwa 7 px vom Mittelgriff; die Liste führt den Mittel-/Verschiebe-Griff an
// Index 0, die Ecken folgen — der alte „erster Treffer"-Test nahm deshalb auch beim Klick auf eine Ecke die Mitte.
/** Abstand (px), innerhalb dessen zwei Griffe als gleich nah gelten (dann gewinnt der spätere: Ecke statt Mitte). */
export const GRIP_TIE_PX = 2;
/**
* Index des Griffs, dessen Mittelpunkt dem Zeiger am nächsten liegt und höchstens `hitPx` entfernt ist; sonst null.
* Liegen mehrere Griffe praktisch gleich nah (Unterschied ≤ {@link GRIP_TIE_PX}), gilt der mit dem höheren Index —
* die Listen der Bauteile führen den Verschiebe-Griff (Mitte) vorn, Ecken/Eckpunkte dahinter.
*/
export function pickGripIndex(centers: readonly { x: number; y: number }[], px: number, py: number, hitPx: number): number | null {
const d = centers.map((c) => Math.hypot(c.x - px, c.y - py));
let minD = Infinity;
for (const x of d) if (x <= hitPx && x < minD) minD = x;
if (!Number.isFinite(minD)) return null;
let best: number | null = null;
for (let i = 0; i < d.length; i++) if (d[i] <= hitPx && d[i] <= minD + GRIP_TIE_PX) best = i;
return best;
}
+11 -6
View File
@@ -8,6 +8,7 @@ import type { ViewBox__plan_planView_geometry as ViewBox, ClientMap } from "../.
import type { Vec2, EdgeGrip } from "../../../model/types";
import type { BodyTarget } from "./types";
import { GRIP_HIT_PX } from "./constants";
import { pickGripIndex } from "./gripPick";
import { createCursorStore } from "../../../state/cursorStore";
import type { GripHandlers } from "./types";
import type { PlanViewHandle } from "./types";
@@ -302,12 +303,16 @@ export function usePlanCoords(inp: UsePlanCoordsArgs) {
// Index des Griffs unter dem Cursor (Bildschirm-Pixel) oder null.
const gripAt = (clientX: number, clientY: number): number | null => {
if (!grips) return null;
for (let i = 0; i < grips.length; i++) {
const vb = toScreen(grips[i]);
const c = vbToClient(vb.x, vb.y);
if (Math.hypot(c.x - clientX, c.y - clientY) <= GRIP_HIT_PX) return i;
}
return null;
// [333] Nächster Griff gewinnt (kleine Stütze: Ecke statt Mitte), s. `gripPick.ts`.
return pickGripIndex(
grips.map((g) => {
const vb = toScreen(g);
return vbToClient(vb.x, vb.y);
}),
clientX,
clientY,
GRIP_HIT_PX,
);
};
// Bildschirm-Versatz (viewBox-Einheiten) eines Kanten-Anfassers entlang seiner
// Normale: das Dreieck sitzt etwas AUSSERHALB der Kante. Y wird gespiegelt
+16
View File
@@ -20,6 +20,9 @@ import type {
Layout,
Project,
Roof,
Stair,
Opening,
Column,
Vec2,
Wall,
} from "../model/types";
@@ -139,6 +142,10 @@ export const Content = memo(function Content({
edit3dDrawings,
edit3dCeilings,
edit3dRoofs,
edit3dStairs,
edit3dOpenings,
edit3dColumns,
onEdit3dElement,
onEdit3dVertex,
onEdit3dBody,
onEdit3dEdge,
@@ -247,6 +254,11 @@ export const Content = memo(function Content({
/** Alle gewählten Decken — 3D-Eckpunkt-/Kanten-/Verschiebe-Griffe. */
edit3dCeilings: Ceiling[];
edit3dRoofs: Roof[];
/** [333] Gewählte Treppen/Wandöffnungen/Stützen — 3D-Griffe (Kern-Anfragen wie im Plan). */
edit3dStairs: Stair[];
edit3dOpenings: Opening[];
edit3dColumns: Column[];
onEdit3dElement: (target: { stairId?: string; openingId?: string; columnId?: string }, index: number, pt: Vec2) => void;
onEdit3dVertex: (
target: { wallId?: string; drawingId?: string; ceilingId?: string; roofId?: string },
index: number,
@@ -358,6 +370,10 @@ export const Content = memo(function Content({
editDrawings={edit3dDrawings}
editCeilings={edit3dCeilings}
editRoofs={edit3dRoofs}
editStairs={edit3dStairs}
editOpenings={edit3dOpenings}
editColumns={edit3dColumns}
onEditElement={onEdit3dElement}
onEditVertex={onEdit3dVertex}
onEditBody={onEdit3dBody}
onEditEdge={onEdit3dEdge}