Update selection logic to include path points and adjust transform messages

This commit is contained in:
2026-04-13 22:26:18 +02:00
parent 57522886b1
commit 839314bcc5
3 changed files with 38 additions and 5 deletions

View File

@@ -6,7 +6,10 @@ import { cloneScenePath, type ScenePath } from "../document/paths";
import type { EditorCommand } from "./command"; import type { EditorCommand } from "./command";
function selectionIncludesPath(selection: EditorSelection, pathId: string): boolean { 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 { export function createDeletePathCommand(pathId: string): EditorCommand {

View File

@@ -1067,7 +1067,7 @@ export function resolveTransformTarget(
return { return {
target: null, target: null,
message: 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": case "brushFace":
if (whiteboxSelectionMode !== "face") { if (whiteboxSelectionMode !== "face") {
@@ -1138,7 +1138,7 @@ export function resolveTransformTarget(
return { return {
target: null, target: null,
message: 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": case "pathPoint":
return createPathPointTransformTarget( return createPathPointTransformTarget(

View File

@@ -2,7 +2,8 @@ import {
getSingleSelectedBrushId, getSingleSelectedBrushId,
getSingleSelectedEntityId, getSingleSelectedEntityId,
getSingleSelectedModelInstanceId, getSingleSelectedModelInstanceId,
getSingleSelectedPathId, getSingleSelectedPathOwnerId,
getSingleSelectedPathPoint,
type EditorSelection type EditorSelection
} from "../core/selection"; } from "../core/selection";
import type { Vec3 } from "../core/vector"; import type { Vec3 } from "../core/vector";
@@ -246,6 +247,22 @@ function createPathFocusTarget(path: ScenePath): ViewportFocusTarget | null {
return finishBounds(bounds); 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) { function includeSphereEntity(bounds: FocusBoundsAccumulator, position: Vec3, radius: number) {
includeBounds( includeBounds(
bounds, 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) { if (selectedPathId !== null) {
const path = document.paths[selectedPathId]; const path = document.paths[selectedPathId];