diff --git a/src/core/selection.ts b/src/core/selection.ts index d07b17b0..8042feb5 100644 --- a/src/core/selection.ts +++ b/src/core/selection.ts @@ -56,6 +56,14 @@ export function getSingleSelectedEntityId(selection: EditorSelection): string | return selection.ids[0]; } +export function getSingleSelectedModelInstanceId(selection: EditorSelection): string | null { + if (selection.kind !== "modelInstances" || selection.ids.length !== 1) { + return null; + } + + return selection.ids[0]; +} + export function isBrushSelected(selection: EditorSelection, brushId: string): boolean { return ( (selection.kind === "brushes" && selection.ids.includes(brushId)) || @@ -66,3 +74,7 @@ export function isBrushSelected(selection: EditorSelection, brushId: string): bo export function isBrushFaceSelected(selection: EditorSelection, brushId: string, faceId: BoxFaceId): boolean { return selection.kind === "brushFace" && selection.brushId === brushId && selection.faceId === faceId; } + +export function isModelInstanceSelected(selection: EditorSelection, modelInstanceId: string): boolean { + return selection.kind === "modelInstances" && selection.ids.includes(modelInstanceId); +}