Add commands and update brush face handling

This commit is contained in:
2026-03-31 02:33:18 +02:00
parent d1ae2499e5
commit 8760b210d4
9 changed files with 513 additions and 15 deletions

View File

@@ -1,6 +1,9 @@
import type { BoxFaceId } from "../document/brushes";
export type EditorSelection =
| { kind: "none" }
| { kind: "brushes"; ids: string[] }
| { kind: "brushFace"; brushId: string; faceId: BoxFaceId }
| { kind: "entities"; ids: string[] }
| { kind: "modelInstances"; ids: string[] };
@@ -11,6 +14,14 @@ export function cloneEditorSelection(selection: EditorSelection): EditorSelectio
};
}
if (selection.kind === "brushFace") {
return {
kind: "brushFace",
brushId: selection.brushId,
faceId: selection.faceId
};
}
return {
kind: selection.kind,
ids: [...selection.ids]
@@ -18,6 +29,10 @@ export function cloneEditorSelection(selection: EditorSelection): EditorSelectio
}
export function getSingleSelectedBrushId(selection: EditorSelection): string | null {
if (selection.kind === "brushFace") {
return selection.brushId;
}
if (selection.kind !== "brushes" || selection.ids.length !== 1) {
return null;
}
@@ -25,6 +40,21 @@ export function getSingleSelectedBrushId(selection: EditorSelection): string | n
return selection.ids[0];
}
export function isBrushSelected(selection: EditorSelection, brushId: string): boolean {
return selection.kind === "brushes" && selection.ids.includes(brushId);
export function getSelectedBrushFaceId(selection: EditorSelection): BoxFaceId | null {
if (selection.kind !== "brushFace") {
return null;
}
return selection.faceId;
}
export function isBrushSelected(selection: EditorSelection, brushId: string): boolean {
return (
(selection.kind === "brushes" && selection.ids.includes(brushId)) ||
(selection.kind === "brushFace" && selection.brushId === brushId)
);
}
export function isBrushFaceSelected(selection: EditorSelection, brushId: string, faceId: BoxFaceId): boolean {
return selection.kind === "brushFace" && selection.brushId === brushId && selection.faceId === faceId;
}

View File

@@ -1,3 +1,8 @@
export interface Vec2 {
x: number;
y: number;
}
export interface Vec3 {
x: number;
y: number;