Enhance duplication logic with transform session handling
This commit is contained in:
@@ -2811,13 +2811,40 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
try {
|
try {
|
||||||
store.executeCommand(createDuplicateSelectionCommand());
|
store.executeCommand(createDuplicateSelectionCommand());
|
||||||
|
|
||||||
const duplicatedSelection = store.getState().selection;
|
const duplicatedState = store.getState();
|
||||||
|
const duplicatedSelection = duplicatedState.selection;
|
||||||
const canGrabDuplicatedSelection =
|
const canGrabDuplicatedSelection =
|
||||||
(duplicatedSelection.kind === "brushes" || duplicatedSelection.kind === "entities" || duplicatedSelection.kind === "modelInstances") &&
|
(duplicatedSelection.kind === "brushes" || duplicatedSelection.kind === "entities" || duplicatedSelection.kind === "modelInstances") &&
|
||||||
duplicatedSelection.ids.length === 1;
|
duplicatedSelection.ids.length === 1;
|
||||||
|
|
||||||
if (canGrabDuplicatedSelection) {
|
if (canGrabDuplicatedSelection) {
|
||||||
beginTransformOperation("translate", "keyboard");
|
const transformSourcePanelId = layoutMode === "quad" ? hoveredViewportPanelId ?? activePanelId : activePanelId;
|
||||||
|
const transformTargetResult = resolveTransformTarget(duplicatedState.document, duplicatedSelection, whiteboxSelectionMode);
|
||||||
|
const transformTarget = transformTargetResult.target;
|
||||||
|
|
||||||
|
if (transformTarget === null) {
|
||||||
|
setStatusMessage(transformTargetResult.message ?? "Duplicated selection, but could not start move transform.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duplicatedState.activeViewportPanelId !== transformSourcePanelId) {
|
||||||
|
store.setActiveViewportPanel(transformSourcePanelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
store.setTransformSession(
|
||||||
|
createTransformSession({
|
||||||
|
source: "keyboard",
|
||||||
|
sourcePanelId: transformSourcePanelId,
|
||||||
|
operation: "translate",
|
||||||
|
target: transformTarget
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
setStatusMessage(
|
||||||
|
`Move ${getTransformTargetLabel(transformTarget).toLowerCase()} in ${getViewportPanelLabel(
|
||||||
|
transformSourcePanelId
|
||||||
|
)}. Move the pointer, press X/Y/Z to constrain, click or press Enter to commit, Escape cancels.`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setStatusMessage("Duplicated selection.");
|
setStatusMessage("Duplicated selection.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user