Add functions to handle single selected model instance and check if a model instance is selected
This commit is contained in:
@@ -56,6 +56,14 @@ export function getSingleSelectedEntityId(selection: EditorSelection): string |
|
|||||||
return selection.ids[0];
|
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 {
|
export function isBrushSelected(selection: EditorSelection, brushId: string): boolean {
|
||||||
return (
|
return (
|
||||||
(selection.kind === "brushes" && selection.ids.includes(brushId)) ||
|
(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 {
|
export function isBrushFaceSelected(selection: EditorSelection, brushId: string, faceId: BoxFaceId): boolean {
|
||||||
return selection.kind === "brushFace" && selection.brushId === brushId && selection.faceId === faceId;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user