From f64eaa7350ea326305eaaec43d814f57a5ee1ea6 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 4 Apr 2026 19:26:26 +0200 Subject: [PATCH] Add snapToGrid and label options to resize box brush command --- src/commands/resize-box-brush-command.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/commands/resize-box-brush-command.ts b/src/commands/resize-box-brush-command.ts index 9df0c11b..3405556b 100644 --- a/src/commands/resize-box-brush-command.ts +++ b/src/commands/resize-box-brush-command.ts @@ -11,11 +11,14 @@ import type { EditorCommand } from "./command"; interface ResizeBoxBrushCommandOptions { brushId: string; size: Vec3; + snapToGrid?: boolean; gridSize?: number; + label?: string; } export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOptions): EditorCommand { - const snappedSize = snapPositiveSizeToGrid(options.size, options.gridSize ?? DEFAULT_GRID_SIZE); + const resolvedSize = + options.snapToGrid === false ? options.size : snapPositiveSizeToGrid(options.size, options.gridSize ?? DEFAULT_GRID_SIZE); let previousSize: Vec3 | null = null; let previousSelection: EditorSelection | null = null; @@ -23,7 +26,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption return { id: createOpaqueId("command"), - label: "Resize box brush", + label: options.label ?? "Resize box brush", execute(context) { const currentDocument = context.getDocument(); const brush = getBoxBrushOrThrow(currentDocument, options.brushId); @@ -46,7 +49,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption replaceBrush(currentDocument, { ...brush, size: { - ...snappedSize + ...resolvedSize } }) );