Update commands and core to support generic brushes

This commit is contained in:
2026-04-15 07:46:58 +02:00
parent d80b32408d
commit 1fbe979eae
4 changed files with 150 additions and 60 deletions

View File

@@ -1,7 +1,7 @@
import { createOpaqueId } from "../core/ids"; import { createOpaqueId } from "../core/ids";
import type { EditorSelection } from "../core/selection"; import type { EditorSelection } from "../core/selection";
import type { ToolMode } from "../core/tool-mode"; import type { ToolMode } from "../core/tool-mode";
import { cloneBoxBrush, type BoxBrush } from "../document/brushes"; import { cloneBrush, type Brush } from "../document/brushes";
import { cloneSelectionForCommand, removeBrush } from "./brush-command-helpers"; import { cloneSelectionForCommand, removeBrush } from "./brush-command-helpers";
import type { EditorCommand } from "./command"; import type { EditorCommand } from "./command";
@@ -15,7 +15,7 @@ function selectionIncludesBrush(selection: EditorSelection, brushId: string): bo
} }
export function createDeleteBoxBrushCommand(brushId: string): EditorCommand { export function createDeleteBoxBrushCommand(brushId: string): EditorCommand {
let previousBrush: BoxBrush | null = null; let previousBrush: Brush | null = null;
let previousSelection: EditorSelection | null = null; let previousSelection: EditorSelection | null = null;
let previousToolMode: ToolMode | null = null; let previousToolMode: ToolMode | null = null;
@@ -31,7 +31,7 @@ export function createDeleteBoxBrushCommand(brushId: string): EditorCommand {
} }
if (previousBrush === null) { if (previousBrush === null) {
previousBrush = cloneBoxBrush(currentBrush); previousBrush = cloneBrush(currentBrush);
} }
if (previousSelection === null) { if (previousSelection === null) {
@@ -63,7 +63,7 @@ export function createDeleteBoxBrushCommand(brushId: string): EditorCommand {
...currentDocument, ...currentDocument,
brushes: { brushes: {
...currentDocument.brushes, ...currentDocument.brushes,
[previousBrush.id]: cloneBoxBrush(previousBrush) [previousBrush.id]: cloneBrush(previousBrush)
} }
}); });

View File

@@ -1,6 +1,6 @@
import type { ToolMode } from "../core/tool-mode"; import type { ToolMode } from "../core/tool-mode";
import { DEFAULT_GRID_SIZE, snapPositiveSizeToGrid } from "../geometry/grid-snapping"; import { DEFAULT_GRID_SIZE, snapPositiveSizeToGrid } from "../geometry/grid-snapping";
import { cloneBoxBrushGeometry, scaleBoxBrushGeometryToSize } from "../document/brushes"; import { cloneBrushGeometry, scaleBrushGeometryToSize } from "../document/brushes";
import { createOpaqueId } from "../core/ids"; import { createOpaqueId } from "../core/ids";
import type { EditorSelection } from "../core/selection"; import type { EditorSelection } from "../core/selection";
@@ -22,7 +22,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption
options.snapToGrid === false ? options.size : snapPositiveSizeToGrid(options.size, options.gridSize ?? DEFAULT_GRID_SIZE); options.snapToGrid === false ? options.size : snapPositiveSizeToGrid(options.size, options.gridSize ?? DEFAULT_GRID_SIZE);
let previousSize: Vec3 | null = null; let previousSize: Vec3 | null = null;
let previousGeometry: ReturnType<typeof cloneBoxBrushGeometry> | null = null; let previousGeometry: ReturnType<typeof cloneBrushGeometry> | null = null;
let previousSelection: EditorSelection | null = null; let previousSelection: EditorSelection | null = null;
let previousToolMode: ToolMode | null = null; let previousToolMode: ToolMode | null = null;
@@ -37,7 +37,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption
previousSize = { previousSize = {
...brush.size ...brush.size
}; };
previousGeometry = cloneBoxBrushGeometry(brush.geometry); previousGeometry = cloneBrushGeometry(brush.geometry);
} }
if (previousSelection === null) { if (previousSelection === null) {
@@ -48,7 +48,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption
previousToolMode = context.getToolMode(); previousToolMode = context.getToolMode();
} }
const nextGeometry = scaleBoxBrushGeometryToSize(brush.geometry, resolvedSize); const nextGeometry = scaleBrushGeometryToSize(brush.geometry, resolvedSize);
context.setDocument( context.setDocument(
replaceBrush(currentDocument, { replaceBrush(currentDocument, {
@@ -76,7 +76,7 @@ export function createResizeBoxBrushCommand(options: ResizeBoxBrushCommandOption
size: { size: {
...previousSize ...previousSize
}, },
geometry: cloneBoxBrushGeometry(previousGeometry) geometry: cloneBrushGeometry(previousGeometry)
}) })
); );

View File

@@ -3,7 +3,15 @@ import type { ToolMode } from "../core/tool-mode";
import { createOpaqueId } from "../core/ids"; import { createOpaqueId } from "../core/ids";
import type { EditorSelection } from "../core/selection"; import type { EditorSelection } from "../core/selection";
import type { Vec3 } from "../core/vector"; import type { Vec3 } from "../core/vector";
import { cloneBoxBrushGeometry, deriveBoxBrushSizeFromGeometry, scaleBoxBrushGeometryToSize, type BoxBrushGeometry } from "../document/brushes"; import {
cloneBrushGeometry,
deriveBrushSizeFromGeometry,
scaleBrushGeometryToSize,
type BrushGeometry,
type WhiteboxEdgeId,
type WhiteboxFaceId,
type WhiteboxVertexId
} from "../document/brushes";
import { import {
cloneSelectionForCommand, cloneSelectionForCommand,
@@ -15,20 +23,19 @@ import {
setSingleBrushVertexSelection setSingleBrushVertexSelection
} from "./brush-command-helpers"; } from "./brush-command-helpers";
import type { EditorCommand } from "./command"; import type { EditorCommand } from "./command";
import type { BoxEdgeId, BoxFaceId, BoxVertexId } from "../document/brushes";
type BrushTransformCommandSelection = type BrushTransformCommandSelection =
| { kind: "brush"; brushId: string } | { kind: "brush"; brushId: string }
| { kind: "brushFace"; brushId: string; faceId: BoxFaceId } | { kind: "brushFace"; brushId: string; faceId: WhiteboxFaceId }
| { kind: "brushEdge"; brushId: string; edgeId: BoxEdgeId } | { kind: "brushEdge"; brushId: string; edgeId: WhiteboxEdgeId }
| { kind: "brushVertex"; brushId: string; vertexId: BoxVertexId }; | { kind: "brushVertex"; brushId: string; vertexId: WhiteboxVertexId };
interface SetBoxBrushTransformCommandOptions { interface SetBoxBrushTransformCommandOptions {
selection: BrushTransformCommandSelection; selection: BrushTransformCommandSelection;
center: Vec3; center: Vec3;
rotationDegrees: Vec3; rotationDegrees: Vec3;
size: Vec3; size: Vec3;
geometry?: BoxBrushGeometry; geometry?: BrushGeometry;
label?: string; label?: string;
} }
@@ -36,7 +43,7 @@ interface BrushTransformSnapshot {
center: Vec3; center: Vec3;
rotationDegrees: Vec3; rotationDegrees: Vec3;
size: Vec3; size: Vec3;
geometry: ReturnType<typeof cloneBoxBrushGeometry>; geometry: ReturnType<typeof cloneBrushGeometry>;
} }
function cloneVec3(vector: Vec3): Vec3 { function cloneVec3(vector: Vec3): Vec3 {
@@ -94,7 +101,7 @@ export function createSetBoxBrushTransformCommand(options: SetBoxBrushTransformC
center: cloneVec3(brush.center), center: cloneVec3(brush.center),
rotationDegrees: cloneVec3(brush.rotationDegrees), rotationDegrees: cloneVec3(brush.rotationDegrees),
size: cloneVec3(brush.size), size: cloneVec3(brush.size),
geometry: cloneBoxBrushGeometry(brush.geometry) geometry: cloneBrushGeometry(brush.geometry)
}; };
} }
@@ -106,8 +113,8 @@ export function createSetBoxBrushTransformCommand(options: SetBoxBrushTransformC
previousToolMode = context.getToolMode(); previousToolMode = context.getToolMode();
} }
const nextGeometry = options.geometry === undefined ? scaleBoxBrushGeometryToSize(brush.geometry, options.size) : cloneBoxBrushGeometry(options.geometry); const nextGeometry = options.geometry === undefined ? scaleBrushGeometryToSize(brush.geometry, options.size) : cloneBrushGeometry(options.geometry);
const nextSize = deriveBoxBrushSizeFromGeometry(nextGeometry); const nextSize = deriveBrushSizeFromGeometry(nextGeometry);
assertPositiveSize(nextSize); assertPositiveSize(nextSize);
@@ -138,7 +145,7 @@ export function createSetBoxBrushTransformCommand(options: SetBoxBrushTransformC
center: cloneVec3(previousSnapshot.center), center: cloneVec3(previousSnapshot.center),
rotationDegrees: cloneVec3(previousSnapshot.rotationDegrees), rotationDegrees: cloneVec3(previousSnapshot.rotationDegrees),
size: cloneVec3(previousSnapshot.size), size: cloneVec3(previousSnapshot.size),
geometry: cloneBoxBrushGeometry(previousSnapshot.geometry) geometry: cloneBrushGeometry(previousSnapshot.geometry)
}) })
); );

View File

@@ -3,15 +3,16 @@ import type { EditorSelection } from "./selection";
import type { WhiteboxSelectionMode } from "./whitebox-selection-mode"; import type { WhiteboxSelectionMode } from "./whitebox-selection-mode";
import type { Vec3 } from "./vector"; import type { Vec3 } from "./vector";
import { import {
BOX_VERTEX_IDS, cloneBrushGeometry,
BOX_EDGE_LABELS, createBoxBrush,
BOX_FACE_LABELS, createRadialPrismBrush,
BOX_VERTEX_LABELS, createWedgeBrush,
cloneBoxBrushGeometry, type Brush,
type BoxBrushGeometry, type BrushGeometry,
type BoxEdgeId, type BrushKind,
type BoxFaceId, type WhiteboxEdgeId,
type BoxVertexId type WhiteboxFaceId,
type WhiteboxVertexId
} from "../document/brushes"; } from "../document/brushes";
import { getScenePathPoint } from "../document/paths"; import { getScenePathPoint } from "../document/paths";
import type { SceneDocument } from "../document/scene-document"; import type { SceneDocument } from "../document/scene-document";
@@ -26,6 +27,13 @@ import {
getModelInstanceKindLabel getModelInstanceKindLabel
} from "../assets/model-instances"; } from "../assets/model-instances";
import type { ViewportPanelId } from "../viewport-three/viewport-layout"; import type { ViewportPanelId } from "../viewport-three/viewport-layout";
import {
getBrushEdgeLabel,
getBrushFaceLabel,
getBrushKindLabel,
getBrushVertexIds,
getBrushVertexLabel
} from "../geometry/whitebox-topology";
export type TransformOperation = "translate" | "rotate" | "scale"; export type TransformOperation = "translate" | "rotate" | "scale";
export type TransformAxis = "x" | "y" | "z"; export type TransformAxis = "x" | "y" | "z";
@@ -54,40 +62,48 @@ export type EntityTransformRotationState =
export interface BrushTransformTarget { export interface BrushTransformTarget {
kind: "brush"; kind: "brush";
brushId: string; brushId: string;
brushKind: BrushKind;
sideCount?: number;
initialCenter: Vec3; initialCenter: Vec3;
initialRotationDegrees: Vec3; initialRotationDegrees: Vec3;
initialSize: Vec3; initialSize: Vec3;
initialGeometry: BoxBrushGeometry; initialGeometry: BrushGeometry;
} }
export interface BrushFaceTransformTarget { export interface BrushFaceTransformTarget {
kind: "brushFace"; kind: "brushFace";
brushId: string; brushId: string;
faceId: BoxFaceId; brushKind: BrushKind;
sideCount?: number;
faceId: WhiteboxFaceId;
initialCenter: Vec3; initialCenter: Vec3;
initialRotationDegrees: Vec3; initialRotationDegrees: Vec3;
initialSize: Vec3; initialSize: Vec3;
initialGeometry: BoxBrushGeometry; initialGeometry: BrushGeometry;
} }
export interface BrushEdgeTransformTarget { export interface BrushEdgeTransformTarget {
kind: "brushEdge"; kind: "brushEdge";
brushId: string; brushId: string;
edgeId: BoxEdgeId; brushKind: BrushKind;
sideCount?: number;
edgeId: WhiteboxEdgeId;
initialCenter: Vec3; initialCenter: Vec3;
initialRotationDegrees: Vec3; initialRotationDegrees: Vec3;
initialSize: Vec3; initialSize: Vec3;
initialGeometry: BoxBrushGeometry; initialGeometry: BrushGeometry;
} }
export interface BrushVertexTransformTarget { export interface BrushVertexTransformTarget {
kind: "brushVertex"; kind: "brushVertex";
brushId: string; brushId: string;
vertexId: BoxVertexId; brushKind: BrushKind;
sideCount?: number;
vertexId: WhiteboxVertexId;
initialCenter: Vec3; initialCenter: Vec3;
initialRotationDegrees: Vec3; initialRotationDegrees: Vec3;
initialSize: Vec3; initialSize: Vec3;
initialGeometry: BoxBrushGeometry; initialGeometry: BrushGeometry;
} }
export interface ModelInstanceTransformTarget { export interface ModelInstanceTransformTarget {
@@ -128,17 +144,24 @@ export interface BrushTransformPreview {
center: Vec3; center: Vec3;
rotationDegrees: Vec3; rotationDegrees: Vec3;
size: Vec3; size: Vec3;
geometry: BoxBrushGeometry; geometry: BrushGeometry;
} }
function areBrushGeometriesEqual( function areBrushGeometriesEqual(
left: BoxBrushGeometry, left: BrushGeometry,
right: BoxBrushGeometry right: BrushGeometry
): boolean { ): boolean {
return BOX_VERTEX_IDS.every((vertexId) => { const leftVertexIds = Object.keys(left.vertices);
const rightVertexIds = Object.keys(right.vertices);
if (leftVertexIds.length !== rightVertexIds.length) {
return false;
}
return leftVertexIds.every((vertexId) => {
const leftVertex = left.vertices[vertexId]; const leftVertex = left.vertices[vertexId];
const rightVertex = right.vertices[vertexId]; const rightVertex = right.vertices[vertexId];
return areVec3Equal(leftVertex, rightVertex); return rightVertex !== undefined && areVec3Equal(leftVertex, rightVertex);
}); });
} }
@@ -218,6 +241,42 @@ function cloneEntityTransformRotationState(
} }
} }
function createBrushSnapshotFromTarget(
target:
| BrushTransformTarget
| BrushFaceTransformTarget
| BrushEdgeTransformTarget
| BrushVertexTransformTarget
): Brush {
switch (target.brushKind) {
case "box":
return createBoxBrush({
id: target.brushId,
center: target.initialCenter,
rotationDegrees: target.initialRotationDegrees,
size: target.initialSize,
geometry: target.initialGeometry
});
case "wedge":
return createWedgeBrush({
id: target.brushId,
center: target.initialCenter,
rotationDegrees: target.initialRotationDegrees,
size: target.initialSize,
geometry: target.initialGeometry
});
case "radialPrism":
return createRadialPrismBrush({
id: target.brushId,
center: target.initialCenter,
rotationDegrees: target.initialRotationDegrees,
size: target.initialSize,
sideCount: target.sideCount,
geometry: target.initialGeometry
});
}
}
function areEntityTransformRotationsEqual( function areEntityTransformRotationsEqual(
left: EntityTransformRotationState, left: EntityTransformRotationState,
right: EntityTransformRotationState right: EntityTransformRotationState
@@ -251,40 +310,48 @@ export function cloneTransformTarget(target: TransformTarget): TransformTarget {
return { return {
kind: "brush", kind: "brush",
brushId: target.brushId, brushId: target.brushId,
brushKind: target.brushKind,
sideCount: target.sideCount,
initialCenter: cloneVec3(target.initialCenter), initialCenter: cloneVec3(target.initialCenter),
initialRotationDegrees: cloneVec3(target.initialRotationDegrees), initialRotationDegrees: cloneVec3(target.initialRotationDegrees),
initialSize: cloneVec3(target.initialSize), initialSize: cloneVec3(target.initialSize),
initialGeometry: cloneBoxBrushGeometry(target.initialGeometry) initialGeometry: cloneBrushGeometry(target.initialGeometry)
}; };
case "brushFace": case "brushFace":
return { return {
kind: "brushFace", kind: "brushFace",
brushId: target.brushId, brushId: target.brushId,
brushKind: target.brushKind,
sideCount: target.sideCount,
faceId: target.faceId, faceId: target.faceId,
initialCenter: cloneVec3(target.initialCenter), initialCenter: cloneVec3(target.initialCenter),
initialRotationDegrees: cloneVec3(target.initialRotationDegrees), initialRotationDegrees: cloneVec3(target.initialRotationDegrees),
initialSize: cloneVec3(target.initialSize), initialSize: cloneVec3(target.initialSize),
initialGeometry: cloneBoxBrushGeometry(target.initialGeometry) initialGeometry: cloneBrushGeometry(target.initialGeometry)
}; };
case "brushEdge": case "brushEdge":
return { return {
kind: "brushEdge", kind: "brushEdge",
brushId: target.brushId, brushId: target.brushId,
brushKind: target.brushKind,
sideCount: target.sideCount,
edgeId: target.edgeId, edgeId: target.edgeId,
initialCenter: cloneVec3(target.initialCenter), initialCenter: cloneVec3(target.initialCenter),
initialRotationDegrees: cloneVec3(target.initialRotationDegrees), initialRotationDegrees: cloneVec3(target.initialRotationDegrees),
initialSize: cloneVec3(target.initialSize), initialSize: cloneVec3(target.initialSize),
initialGeometry: cloneBoxBrushGeometry(target.initialGeometry) initialGeometry: cloneBrushGeometry(target.initialGeometry)
}; };
case "brushVertex": case "brushVertex":
return { return {
kind: "brushVertex", kind: "brushVertex",
brushId: target.brushId, brushId: target.brushId,
brushKind: target.brushKind,
sideCount: target.sideCount,
vertexId: target.vertexId, vertexId: target.vertexId,
initialCenter: cloneVec3(target.initialCenter), initialCenter: cloneVec3(target.initialCenter),
initialRotationDegrees: cloneVec3(target.initialRotationDegrees), initialRotationDegrees: cloneVec3(target.initialRotationDegrees),
initialSize: cloneVec3(target.initialSize), initialSize: cloneVec3(target.initialSize),
initialGeometry: cloneBoxBrushGeometry(target.initialGeometry) initialGeometry: cloneBrushGeometry(target.initialGeometry)
}; };
case "modelInstance": case "modelInstance":
return { return {
@@ -325,7 +392,7 @@ export function cloneTransformPreview(
center: cloneVec3(preview.center), center: cloneVec3(preview.center),
rotationDegrees: cloneVec3(preview.rotationDegrees), rotationDegrees: cloneVec3(preview.rotationDegrees),
size: cloneVec3(preview.size), size: cloneVec3(preview.size),
geometry: cloneBoxBrushGeometry(preview.geometry) geometry: cloneBrushGeometry(preview.geometry)
}; };
case "modelInstance": case "modelInstance":
return { return {
@@ -405,6 +472,8 @@ function areTransformTargetsEqual(
return ( return (
right.kind === "brush" && right.kind === "brush" &&
left.brushId === right.brushId && left.brushId === right.brushId &&
left.brushKind === right.brushKind &&
left.sideCount === right.sideCount &&
areVec3Equal(left.initialCenter, right.initialCenter) && areVec3Equal(left.initialCenter, right.initialCenter) &&
areVec3Equal( areVec3Equal(
left.initialRotationDegrees, left.initialRotationDegrees,
@@ -417,6 +486,8 @@ function areTransformTargetsEqual(
return ( return (
right.kind === "brushFace" && right.kind === "brushFace" &&
left.brushId === right.brushId && left.brushId === right.brushId &&
left.brushKind === right.brushKind &&
left.sideCount === right.sideCount &&
left.faceId === right.faceId && left.faceId === right.faceId &&
areVec3Equal(left.initialCenter, right.initialCenter) && areVec3Equal(left.initialCenter, right.initialCenter) &&
areVec3Equal( areVec3Equal(
@@ -430,6 +501,8 @@ function areTransformTargetsEqual(
return ( return (
right.kind === "brushEdge" && right.kind === "brushEdge" &&
left.brushId === right.brushId && left.brushId === right.brushId &&
left.brushKind === right.brushKind &&
left.sideCount === right.sideCount &&
left.edgeId === right.edgeId && left.edgeId === right.edgeId &&
areVec3Equal(left.initialCenter, right.initialCenter) && areVec3Equal(left.initialCenter, right.initialCenter) &&
areVec3Equal( areVec3Equal(
@@ -443,6 +516,8 @@ function areTransformTargetsEqual(
return ( return (
right.kind === "brushVertex" && right.kind === "brushVertex" &&
left.brushId === right.brushId && left.brushId === right.brushId &&
left.brushKind === right.brushKind &&
left.sideCount === right.sideCount &&
left.vertexId === right.vertexId && left.vertexId === right.vertexId &&
areVec3Equal(left.initialCenter, right.initialCenter) && areVec3Equal(left.initialCenter, right.initialCenter) &&
areVec3Equal( areVec3Equal(
@@ -557,7 +632,7 @@ export function createTransformPreviewFromTarget(
center: cloneVec3(target.initialCenter), center: cloneVec3(target.initialCenter),
rotationDegrees: cloneVec3(target.initialRotationDegrees), rotationDegrees: cloneVec3(target.initialRotationDegrees),
size: cloneVec3(target.initialSize), size: cloneVec3(target.initialSize),
geometry: cloneBoxBrushGeometry(target.initialGeometry) geometry: cloneBrushGeometry(target.initialGeometry)
}; };
case "modelInstance": case "modelInstance":
return { return {
@@ -668,13 +743,13 @@ export function getTransformAxisSpaceLabel(
export function getTransformTargetLabel(target: TransformTarget): string { export function getTransformTargetLabel(target: TransformTarget): string {
switch (target.kind) { switch (target.kind) {
case "brush": case "brush":
return "Whitebox Box"; return getBrushKindLabel(createBrushSnapshotFromTarget(target));
case "brushFace": case "brushFace":
return `Whitebox Face (${BOX_FACE_LABELS[target.faceId]})`; return `Whitebox Face (${getBrushFaceLabel(createBrushSnapshotFromTarget(target), target.faceId)})`;
case "brushEdge": case "brushEdge":
return `Whitebox Edge (${BOX_EDGE_LABELS[target.edgeId]})`; return `Whitebox Edge (${getBrushEdgeLabel(createBrushSnapshotFromTarget(target), target.edgeId)})`;
case "brushVertex": case "brushVertex":
return `Whitebox Vertex (${BOX_VERTEX_LABELS[target.vertexId]})`; return `Whitebox Vertex (${getBrushVertexLabel(createBrushSnapshotFromTarget(target), target.vertexId)})`;
case "modelInstance": case "modelInstance":
return getModelInstanceKindLabel(); return getModelInstanceKindLabel();
case "pathPoint": case "pathPoint":
@@ -856,10 +931,10 @@ function createBrushTransformTarget(
): TransformTargetResolution { ): TransformTargetResolution {
const brush = document.brushes[brushId]; const brush = document.brushes[brushId];
if (brush === undefined || brush.kind !== "box") { if (brush === undefined) {
return { return {
target: null, target: null,
message: "Select a supported whitebox box before transforming it." message: "Select a supported whitebox solid before transforming it."
}; };
} }
@@ -867,10 +942,12 @@ function createBrushTransformTarget(
target: { target: {
kind: "brush", kind: "brush",
brushId: brush.id, brushId: brush.id,
brushKind: brush.kind,
sideCount: brush.kind === "radialPrism" ? brush.sideCount : undefined,
initialCenter: cloneVec3(brush.center), initialCenter: cloneVec3(brush.center),
initialRotationDegrees: cloneVec3(brush.rotationDegrees), initialRotationDegrees: cloneVec3(brush.rotationDegrees),
initialSize: cloneVec3(brush.size), initialSize: cloneVec3(brush.size),
initialGeometry: cloneBoxBrushGeometry(brush.geometry) initialGeometry: cloneBrushGeometry(brush.geometry)
}, },
message: null message: null
}; };
@@ -879,7 +956,7 @@ function createBrushTransformTarget(
function createBrushFaceTransformTarget( function createBrushFaceTransformTarget(
document: SceneDocument, document: SceneDocument,
brushId: string, brushId: string,
faceId: BoxFaceId faceId: WhiteboxFaceId
): TransformTargetResolution { ): TransformTargetResolution {
const brushResolution = createBrushTransformTarget(document, brushId); const brushResolution = createBrushTransformTarget(document, brushId);
@@ -894,13 +971,15 @@ function createBrushFaceTransformTarget(
target: { target: {
kind: "brushFace", kind: "brushFace",
brushId, brushId,
brushKind: brushResolution.target.brushKind,
sideCount: brushResolution.target.sideCount,
faceId, faceId,
initialCenter: cloneVec3(brushResolution.target.initialCenter), initialCenter: cloneVec3(brushResolution.target.initialCenter),
initialRotationDegrees: cloneVec3( initialRotationDegrees: cloneVec3(
brushResolution.target.initialRotationDegrees brushResolution.target.initialRotationDegrees
), ),
initialSize: cloneVec3(brushResolution.target.initialSize), initialSize: cloneVec3(brushResolution.target.initialSize),
initialGeometry: cloneBoxBrushGeometry( initialGeometry: cloneBrushGeometry(
brushResolution.target.initialGeometry brushResolution.target.initialGeometry
) )
}, },
@@ -911,7 +990,7 @@ function createBrushFaceTransformTarget(
function createBrushEdgeTransformTarget( function createBrushEdgeTransformTarget(
document: SceneDocument, document: SceneDocument,
brushId: string, brushId: string,
edgeId: BoxEdgeId edgeId: WhiteboxEdgeId
): TransformTargetResolution { ): TransformTargetResolution {
const brushResolution = createBrushTransformTarget(document, brushId); const brushResolution = createBrushTransformTarget(document, brushId);
@@ -926,13 +1005,15 @@ function createBrushEdgeTransformTarget(
target: { target: {
kind: "brushEdge", kind: "brushEdge",
brushId, brushId,
brushKind: brushResolution.target.brushKind,
sideCount: brushResolution.target.sideCount,
edgeId, edgeId,
initialCenter: cloneVec3(brushResolution.target.initialCenter), initialCenter: cloneVec3(brushResolution.target.initialCenter),
initialRotationDegrees: cloneVec3( initialRotationDegrees: cloneVec3(
brushResolution.target.initialRotationDegrees brushResolution.target.initialRotationDegrees
), ),
initialSize: cloneVec3(brushResolution.target.initialSize), initialSize: cloneVec3(brushResolution.target.initialSize),
initialGeometry: cloneBoxBrushGeometry( initialGeometry: cloneBrushGeometry(
brushResolution.target.initialGeometry brushResolution.target.initialGeometry
) )
}, },
@@ -943,7 +1024,7 @@ function createBrushEdgeTransformTarget(
function createBrushVertexTransformTarget( function createBrushVertexTransformTarget(
document: SceneDocument, document: SceneDocument,
brushId: string, brushId: string,
vertexId: BoxVertexId vertexId: WhiteboxVertexId
): TransformTargetResolution { ): TransformTargetResolution {
const brushResolution = createBrushTransformTarget(document, brushId); const brushResolution = createBrushTransformTarget(document, brushId);
@@ -958,13 +1039,15 @@ function createBrushVertexTransformTarget(
target: { target: {
kind: "brushVertex", kind: "brushVertex",
brushId, brushId,
brushKind: brushResolution.target.brushKind,
sideCount: brushResolution.target.sideCount,
vertexId, vertexId,
initialCenter: cloneVec3(brushResolution.target.initialCenter), initialCenter: cloneVec3(brushResolution.target.initialCenter),
initialRotationDegrees: cloneVec3( initialRotationDegrees: cloneVec3(
brushResolution.target.initialRotationDegrees brushResolution.target.initialRotationDegrees
), ),
initialSize: cloneVec3(brushResolution.target.initialSize), initialSize: cloneVec3(brushResolution.target.initialSize),
initialGeometry: cloneBoxBrushGeometry( initialGeometry: cloneBrushGeometry(
brushResolution.target.initialGeometry brushResolution.target.initialGeometry
) )
}, },