Update selection logic to include path points and adjust transform messages
This commit is contained in:
@@ -6,7 +6,10 @@ import { cloneScenePath, type ScenePath } from "../document/paths";
|
||||
import type { EditorCommand } from "./command";
|
||||
|
||||
function selectionIncludesPath(selection: EditorSelection, pathId: string): boolean {
|
||||
return selection.kind === "paths" && selection.ids.includes(pathId);
|
||||
return (
|
||||
(selection.kind === "paths" && selection.ids.includes(pathId)) ||
|
||||
(selection.kind === "pathPoint" && selection.pathId === pathId)
|
||||
);
|
||||
}
|
||||
|
||||
export function createDeletePathCommand(pathId: string): EditorCommand {
|
||||
|
||||
@@ -1067,7 +1067,7 @@ export function resolveTransformTarget(
|
||||
return {
|
||||
target: null,
|
||||
message:
|
||||
"Select a single brush, entity, or model instance before transforming it."
|
||||
"Select a single brush, path point, entity, or model instance before transforming it."
|
||||
};
|
||||
case "brushFace":
|
||||
if (whiteboxSelectionMode !== "face") {
|
||||
@@ -1138,7 +1138,7 @@ export function resolveTransformTarget(
|
||||
return {
|
||||
target: null,
|
||||
message:
|
||||
"Path transforms are not available in this slice. Edit path points in the Inspector."
|
||||
"Select a path point before transforming a path."
|
||||
};
|
||||
case "pathPoint":
|
||||
return createPathPointTransformTarget(
|
||||
|
||||
@@ -2,7 +2,8 @@ import {
|
||||
getSingleSelectedBrushId,
|
||||
getSingleSelectedEntityId,
|
||||
getSingleSelectedModelInstanceId,
|
||||
getSingleSelectedPathId,
|
||||
getSingleSelectedPathOwnerId,
|
||||
getSingleSelectedPathPoint,
|
||||
type EditorSelection
|
||||
} from "../core/selection";
|
||||
import type { Vec3 } from "../core/vector";
|
||||
@@ -246,6 +247,22 @@ function createPathFocusTarget(path: ScenePath): ViewportFocusTarget | null {
|
||||
return finishBounds(bounds);
|
||||
}
|
||||
|
||||
function createPathPointFocusTarget(position: Vec3): ViewportFocusTarget {
|
||||
return createBoundsFocusTarget(
|
||||
{
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z
|
||||
},
|
||||
{
|
||||
x: 0.25,
|
||||
y: 0.25,
|
||||
z: 0.25
|
||||
},
|
||||
0.5
|
||||
);
|
||||
}
|
||||
|
||||
function includeSphereEntity(bounds: FocusBoundsAccumulator, position: Vec3, radius: number) {
|
||||
includeBounds(
|
||||
bounds,
|
||||
@@ -417,7 +434,20 @@ export function resolveViewportFocusTarget(document: SceneDocument, selection: E
|
||||
}
|
||||
}
|
||||
|
||||
const selectedPathId = getSingleSelectedPathId(selection);
|
||||
const selectedPathPoint = getSingleSelectedPathPoint(selection);
|
||||
|
||||
if (selectedPathPoint !== null) {
|
||||
const path = document.paths[selectedPathPoint.pathId];
|
||||
const point = path?.points.find(
|
||||
(candidatePoint) => candidatePoint.id === selectedPathPoint.pointId
|
||||
);
|
||||
|
||||
if (point !== undefined) {
|
||||
return createPathPointFocusTarget(point.position);
|
||||
}
|
||||
}
|
||||
|
||||
const selectedPathId = getSingleSelectedPathOwnerId(selection);
|
||||
|
||||
if (selectedPathId !== null) {
|
||||
const path = document.paths[selectedPathId];
|
||||
|
||||
Reference in New Issue
Block a user