Update getSelectedPath to use getSingleSelectedPathOwnerId and add getSelectedPathPointState function

This commit is contained in:
2026-04-13 22:27:40 +02:00
parent 9cb6c57791
commit d0bbc9741d

View File

@@ -902,7 +902,7 @@ function getSelectedPath(
selection: EditorSelection,
paths: ScenePath[]
): ScenePath | null {
const selectedPathId = getSingleSelectedPathId(selection);
const selectedPathId = getSingleSelectedPathOwnerId(selection);
if (selectedPathId === null) {
return null;
@@ -911,6 +911,28 @@ function getSelectedPath(
return paths.find((path) => path.id === selectedPathId) ?? null;
}
function getSelectedPathPointState(
selection: EditorSelection,
path: ScenePath | null
): { point: ScenePathPoint; index: number } | null {
const selectedPathPoint = getSingleSelectedPathPoint(selection);
if (selectedPathPoint === null || path === null || selectedPathPoint.pathId !== path.id) {
return null;
}
const pointIndex = getScenePathPointIndex(path, selectedPathPoint.pointId);
if (pointIndex === -1) {
return null;
}
return {
point: path.points[pointIndex],
index: pointIndex
};
}
function isModelAsset(asset: ProjectAssetRecord): asset is ModelAssetRecord {
return asset.kind === "model";
}