From d929ac05a10b3eebb7130c2e69c50e655e02b4fc Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 15 Apr 2026 07:52:56 +0200 Subject: [PATCH] auto-git: [change] src/core/transform-session.ts --- src/core/transform-session.ts | 74 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/src/core/transform-session.ts b/src/core/transform-session.ts index 403a7ad7..6f062d0a 100644 --- a/src/core/transform-session.ts +++ b/src/core/transform-session.ts @@ -31,9 +31,13 @@ import { getBrushEdgeLabel, getBrushFaceLabel, getBrushKindLabel, - getBrushVertexIds, getBrushVertexLabel } from "../geometry/whitebox-topology"; +import { + getBrushEdgeAxis, + getBrushEdgeScaleAxes, + getBrushFaceAxis +} from "../geometry/whitebox-brush"; export type TransformOperation = "translate" | "rotate" | "scale"; export type TransformAxis = "x" | "y" | "z"; @@ -255,7 +259,7 @@ function createBrushSnapshotFromTarget( center: target.initialCenter, rotationDegrees: target.initialRotationDegrees, size: target.initialSize, - geometry: target.initialGeometry + geometry: target.initialGeometry as Parameters[0]["geometry"] }); case "wedge": return createWedgeBrush({ @@ -263,7 +267,7 @@ function createBrushSnapshotFromTarget( center: target.initialCenter, rotationDegrees: target.initialRotationDegrees, size: target.initialSize, - geometry: target.initialGeometry + geometry: target.initialGeometry as Parameters[0]["geometry"] }); case "radialPrism": return createRadialPrismBrush({ @@ -272,7 +276,10 @@ function createBrushSnapshotFromTarget( rotationDegrees: target.initialRotationDegrees, size: target.initialSize, sideCount: target.sideCount, - geometry: target.initialGeometry + geometry: + target.initialGeometry as Parameters< + typeof createRadialPrismBrush + >[0]["geometry"] }); } } @@ -790,6 +797,14 @@ export function supportsTransformAxisConstraint( session: ActiveTransformSession, axis: TransformAxis ): boolean { + const brushTarget = + session.target.kind === "brush" || + session.target.kind === "brushFace" || + session.target.kind === "brushEdge" || + session.target.kind === "brushVertex" + ? createBrushSnapshotFromTarget(session.target) + : null; + switch (session.operation) { case "translate": return true; @@ -809,26 +824,21 @@ export function supportsTransformAxisConstraint( } if (session.target.kind === "brushFace") { - const normalAxis = - session.target.faceId === "posX" || session.target.faceId === "negX" - ? "x" - : session.target.faceId === "posY" || - session.target.faceId === "negY" - ? "y" - : "z"; - return axis === normalAxis; + if (brushTarget === null) { + return false; + } + + return axis === getBrushFaceAxis(brushTarget, session.target.faceId); } if (session.target.kind === "brushEdge") { - if (session.target.edgeId.startsWith("edgeX_")) { - return axis !== "x"; + if (brushTarget === null) { + return false; } - if (session.target.edgeId.startsWith("edgeY_")) { - return axis !== "y"; - } - - return axis !== "z"; + return getBrushEdgeScaleAxes(brushTarget, session.target.edgeId).includes( + axis + ); } return false; @@ -841,26 +851,19 @@ export function supportsTransformAxisConstraint( } if (session.target.kind === "brushFace") { - const normalAxis = - session.target.faceId === "posX" || session.target.faceId === "negX" - ? "x" - : session.target.faceId === "posY" || - session.target.faceId === "negY" - ? "y" - : "z"; - return axis === normalAxis; + if (brushTarget === null) { + return false; + } + + return axis === getBrushFaceAxis(brushTarget, session.target.faceId); } if (session.target.kind === "brushEdge") { - if (session.target.edgeId.startsWith("edgeX_")) { - return axis === "x"; + if (brushTarget === null) { + return false; } - if (session.target.edgeId.startsWith("edgeY_")) { - return axis === "y"; - } - - return axis === "z"; + return axis === getBrushEdgeAxis(brushTarget, session.target.edgeId); } if (session.target.kind === "brushVertex") { @@ -1200,7 +1203,8 @@ export function resolveTransformTarget( if (whiteboxSelectionMode !== "object") { return { target: null, - message: "Switch to Object mode to transform the whole whitebox box." + message: + "Switch to Object mode to transform the whole whitebox solid." }; }