Add functions to handle single selected model instance and check if a model instance is selected

This commit is contained in:
2026-03-31 17:36:43 +02:00
parent b1ad68ee06
commit e6cf59f302

View File

@@ -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);
}