From 1f572cc7fede37f83ca951cdce4822cda8f51f7b Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 5 Apr 2026 02:58:30 +0200 Subject: [PATCH] Modify set-box-brush-transform-command.js for geometry handling --- src/commands/set-box-brush-transform-command.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commands/set-box-brush-transform-command.js b/src/commands/set-box-brush-transform-command.js index c3878cb9..135242fd 100644 --- a/src/commands/set-box-brush-transform-command.js +++ b/src/commands/set-box-brush-transform-command.js @@ -1,5 +1,5 @@ import { createOpaqueId } from "../core/ids"; -import { cloneBoxBrushGeometry, scaleBoxBrushGeometryToSize } from "../document/brushes"; +import { cloneBoxBrushGeometry, deriveBoxBrushSizeFromGeometry, scaleBoxBrushGeometryToSize } from "../document/brushes"; import { cloneSelectionForCommand, getBoxBrushOrThrow, replaceBrush, setSingleBrushEdgeSelection, setSingleBrushFaceSelection, setSingleBrushSelection, setSingleBrushVertexSelection } from "./brush-command-helpers"; function cloneVec3(vector) { return { @@ -57,12 +57,14 @@ export function createSetBoxBrushTransformCommand(options) { if (previousToolMode === null) { previousToolMode = context.getToolMode(); } - const nextGeometry = scaleBoxBrushGeometryToSize(brush.geometry, options.size); + const nextGeometry = options.geometry === undefined ? scaleBoxBrushGeometryToSize(brush.geometry, options.size) : cloneBoxBrushGeometry(options.geometry); + const nextSize = deriveBoxBrushSizeFromGeometry(nextGeometry); + assertPositiveSize(nextSize); context.setDocument(replaceBrush(currentDocument, { ...brush, center: cloneVec3(options.center), rotationDegrees: cloneVec3(options.rotationDegrees), - size: cloneVec3(options.size), + size: nextSize, geometry: nextGeometry })); context.setSelection(selectionToEditorSelection(options.selection));