Update getSelectedPath to use getSingleSelectedPathOwnerId and add getSelectedPathPointState function
This commit is contained in:
@@ -902,7 +902,7 @@ function getSelectedPath(
|
|||||||
selection: EditorSelection,
|
selection: EditorSelection,
|
||||||
paths: ScenePath[]
|
paths: ScenePath[]
|
||||||
): ScenePath | null {
|
): ScenePath | null {
|
||||||
const selectedPathId = getSingleSelectedPathId(selection);
|
const selectedPathId = getSingleSelectedPathOwnerId(selection);
|
||||||
|
|
||||||
if (selectedPathId === null) {
|
if (selectedPathId === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -911,6 +911,28 @@ function getSelectedPath(
|
|||||||
return paths.find((path) => path.id === selectedPathId) ?? null;
|
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 {
|
function isModelAsset(asset: ProjectAssetRecord): asset is ModelAssetRecord {
|
||||||
return asset.kind === "model";
|
return asset.kind === "model";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user