From f8a388b0f4fb1a938cc9c91b1475078e530bba89 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 4 Apr 2026 20:08:10 +0200 Subject: [PATCH] Extend brush command helpers and update delete command --- src/commands/brush-command-helpers.ts | 25 +++++++++++++++++++++++- src/commands/delete-box-brush-command.ts | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/commands/brush-command-helpers.ts b/src/commands/brush-command-helpers.ts index d17a16b3..90c447bf 100644 --- a/src/commands/brush-command-helpers.ts +++ b/src/commands/brush-command-helpers.ts @@ -1,5 +1,12 @@ import { cloneEditorSelection, type EditorSelection } from "../core/selection"; -import { cloneFaceUvState, type BoxBrush, type BoxFaceId, type BrushFace } from "../document/brushes"; +import { + cloneFaceUvState, + type BoxBrush, + type BoxEdgeId, + type BoxFaceId, + type BoxVertexId, + type BrushFace +} from "../document/brushes"; import type { SceneDocument } from "../document/scene-document"; export function getBoxBrushOrThrow(document: SceneDocument, brushId: string): BoxBrush { @@ -31,6 +38,22 @@ export function setSingleBrushFaceSelection(brushId: string, faceId: BoxFaceId): }; } +export function setSingleBrushEdgeSelection(brushId: string, edgeId: BoxEdgeId): EditorSelection { + return { + kind: "brushEdge", + brushId, + edgeId + }; +} + +export function setSingleBrushVertexSelection(brushId: string, vertexId: BoxVertexId): EditorSelection { + return { + kind: "brushVertex", + brushId, + vertexId + }; +} + export function cloneSelectionForCommand(selection: EditorSelection): EditorSelection { return cloneEditorSelection(selection); } diff --git a/src/commands/delete-box-brush-command.ts b/src/commands/delete-box-brush-command.ts index 56b75155..41695c3c 100644 --- a/src/commands/delete-box-brush-command.ts +++ b/src/commands/delete-box-brush-command.ts @@ -9,7 +9,8 @@ import type { EditorCommand } from "./command"; function selectionIncludesBrush(selection: EditorSelection, brushId: string): boolean { return ( (selection.kind === "brushes" && selection.ids.includes(brushId)) || - (selection.kind === "brushFace" && selection.brushId === brushId) + ((selection.kind === "brushFace" || selection.kind === "brushEdge" || selection.kind === "brushVertex") && + selection.brushId === brushId) ); }