auto-git:
[change] src/core/transform-session.ts
This commit is contained in:
@@ -31,9 +31,13 @@ import {
|
|||||||
getBrushEdgeLabel,
|
getBrushEdgeLabel,
|
||||||
getBrushFaceLabel,
|
getBrushFaceLabel,
|
||||||
getBrushKindLabel,
|
getBrushKindLabel,
|
||||||
getBrushVertexIds,
|
|
||||||
getBrushVertexLabel
|
getBrushVertexLabel
|
||||||
} from "../geometry/whitebox-topology";
|
} from "../geometry/whitebox-topology";
|
||||||
|
import {
|
||||||
|
getBrushEdgeAxis,
|
||||||
|
getBrushEdgeScaleAxes,
|
||||||
|
getBrushFaceAxis
|
||||||
|
} from "../geometry/whitebox-brush";
|
||||||
|
|
||||||
export type TransformOperation = "translate" | "rotate" | "scale";
|
export type TransformOperation = "translate" | "rotate" | "scale";
|
||||||
export type TransformAxis = "x" | "y" | "z";
|
export type TransformAxis = "x" | "y" | "z";
|
||||||
@@ -255,7 +259,7 @@ function createBrushSnapshotFromTarget(
|
|||||||
center: target.initialCenter,
|
center: target.initialCenter,
|
||||||
rotationDegrees: target.initialRotationDegrees,
|
rotationDegrees: target.initialRotationDegrees,
|
||||||
size: target.initialSize,
|
size: target.initialSize,
|
||||||
geometry: target.initialGeometry
|
geometry: target.initialGeometry as Parameters<typeof createBoxBrush>[0]["geometry"]
|
||||||
});
|
});
|
||||||
case "wedge":
|
case "wedge":
|
||||||
return createWedgeBrush({
|
return createWedgeBrush({
|
||||||
@@ -263,7 +267,7 @@ function createBrushSnapshotFromTarget(
|
|||||||
center: target.initialCenter,
|
center: target.initialCenter,
|
||||||
rotationDegrees: target.initialRotationDegrees,
|
rotationDegrees: target.initialRotationDegrees,
|
||||||
size: target.initialSize,
|
size: target.initialSize,
|
||||||
geometry: target.initialGeometry
|
geometry: target.initialGeometry as Parameters<typeof createWedgeBrush>[0]["geometry"]
|
||||||
});
|
});
|
||||||
case "radialPrism":
|
case "radialPrism":
|
||||||
return createRadialPrismBrush({
|
return createRadialPrismBrush({
|
||||||
@@ -272,7 +276,10 @@ function createBrushSnapshotFromTarget(
|
|||||||
rotationDegrees: target.initialRotationDegrees,
|
rotationDegrees: target.initialRotationDegrees,
|
||||||
size: target.initialSize,
|
size: target.initialSize,
|
||||||
sideCount: target.sideCount,
|
sideCount: target.sideCount,
|
||||||
geometry: target.initialGeometry
|
geometry:
|
||||||
|
target.initialGeometry as Parameters<
|
||||||
|
typeof createRadialPrismBrush
|
||||||
|
>[0]["geometry"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -790,6 +797,14 @@ export function supportsTransformAxisConstraint(
|
|||||||
session: ActiveTransformSession,
|
session: ActiveTransformSession,
|
||||||
axis: TransformAxis
|
axis: TransformAxis
|
||||||
): boolean {
|
): 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) {
|
switch (session.operation) {
|
||||||
case "translate":
|
case "translate":
|
||||||
return true;
|
return true;
|
||||||
@@ -809,26 +824,21 @@ export function supportsTransformAxisConstraint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushFace") {
|
if (session.target.kind === "brushFace") {
|
||||||
const normalAxis =
|
if (brushTarget === null) {
|
||||||
session.target.faceId === "posX" || session.target.faceId === "negX"
|
return false;
|
||||||
? "x"
|
}
|
||||||
: session.target.faceId === "posY" ||
|
|
||||||
session.target.faceId === "negY"
|
return axis === getBrushFaceAxis(brushTarget, session.target.faceId);
|
||||||
? "y"
|
|
||||||
: "z";
|
|
||||||
return axis === normalAxis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushEdge") {
|
if (session.target.kind === "brushEdge") {
|
||||||
if (session.target.edgeId.startsWith("edgeX_")) {
|
if (brushTarget === null) {
|
||||||
return axis !== "x";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.edgeId.startsWith("edgeY_")) {
|
return getBrushEdgeScaleAxes(brushTarget, session.target.edgeId).includes(
|
||||||
return axis !== "y";
|
axis
|
||||||
}
|
);
|
||||||
|
|
||||||
return axis !== "z";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -841,26 +851,19 @@ export function supportsTransformAxisConstraint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushFace") {
|
if (session.target.kind === "brushFace") {
|
||||||
const normalAxis =
|
if (brushTarget === null) {
|
||||||
session.target.faceId === "posX" || session.target.faceId === "negX"
|
return false;
|
||||||
? "x"
|
}
|
||||||
: session.target.faceId === "posY" ||
|
|
||||||
session.target.faceId === "negY"
|
return axis === getBrushFaceAxis(brushTarget, session.target.faceId);
|
||||||
? "y"
|
|
||||||
: "z";
|
|
||||||
return axis === normalAxis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushEdge") {
|
if (session.target.kind === "brushEdge") {
|
||||||
if (session.target.edgeId.startsWith("edgeX_")) {
|
if (brushTarget === null) {
|
||||||
return axis === "x";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.edgeId.startsWith("edgeY_")) {
|
return axis === getBrushEdgeAxis(brushTarget, session.target.edgeId);
|
||||||
return axis === "y";
|
|
||||||
}
|
|
||||||
|
|
||||||
return axis === "z";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.target.kind === "brushVertex") {
|
if (session.target.kind === "brushVertex") {
|
||||||
@@ -1200,7 +1203,8 @@ export function resolveTransformTarget(
|
|||||||
if (whiteboxSelectionMode !== "object") {
|
if (whiteboxSelectionMode !== "object") {
|
||||||
return {
|
return {
|
||||||
target: null,
|
target: null,
|
||||||
message: "Switch to Object mode to transform the whole whitebox box."
|
message:
|
||||||
|
"Switch to Object mode to transform the whole whitebox solid."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user