Improve rotation handles and clean repo root

This commit is contained in:
Formsmith
2026-06-08 22:06:30 +03:00
parent 34f601f37d
commit 4b222f9884
8 changed files with 302 additions and 108 deletions
View File
+3 -3
View File
@@ -213,7 +213,7 @@ src/lib/ Small shared utilities
public/assets/ Static image, icon, logo, and shape assets public/assets/ Static image, icon, logo, and shape assets
public/manifold.* Manifold runtime files used by geometry tooling public/manifold.* Manifold runtime files used by geometry tooling
docs/media/ README screenshots and future demo videos docs/media/ README screenshots and future demo videos
.github/ Issue templates and pull request template .github/ Issue templates, community health files, and pull request template
``` ```
## Local Data ## Local Data
@@ -302,11 +302,11 @@ Good areas to help:
- accessibility improvements - accessibility improvements
- performance work for larger scenes - performance work for larger scenes
Before opening a pull request, read [CONTRIBUTING.md](CONTRIBUTING.md). Before opening a pull request, read [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md).
## Security ## Security
Please do not open public issues for security-sensitive reports. Read [SECURITY.md](SECURITY.md) for the reporting process. Please do not open public issues for security-sensitive reports. Read [.github/SECURITY.md](.github/SECURITY.md) for the reporting process.
## License ## License
View File
-11
View File
@@ -1,11 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url=out/index.html" />
<title>Open SketchForge</title>
</head>
<body>
<a href="out/index.html">Open SketchForge</a>
</body>
</html>
+83 -6
View File
@@ -166,6 +166,46 @@ function canonicalizeShape(shape: WorkplaneShape): WorkplaneShape {
return next; return next;
} }
function workplaneShapesEqual(a: WorkplaneShape, b: WorkplaneShape) {
return (
a.id === b.id &&
a.name === b.name &&
a.kind === b.kind &&
a.color === b.color &&
a.hole === b.hole &&
a.x === b.x &&
a.z === b.z &&
a.elevation === b.elevation &&
a.size === b.size &&
a.width === b.width &&
a.depth === b.depth &&
a.height === b.height &&
a.rotation === b.rotation &&
a.rotationX === b.rotationX &&
a.rotationZ === b.rotationZ &&
a.mirrorX === b.mirrorX &&
a.mirrorY === b.mirrorY &&
a.mirrorZ === b.mirrorZ &&
a.radius === b.radius &&
a.steps === b.steps &&
a.sides === b.sides &&
a.bevel === b.bevel &&
a.segments === b.segments &&
a.topRadius === b.topRadius &&
a.baseRadius === b.baseRadius &&
a.text === b.text &&
a.font === b.font &&
a.importedMesh === b.importedMesh &&
a.imagePlate === b.imagePlate &&
a.groupedShapes === b.groupedShapes &&
a.groupedBaseWidth === b.groupedBaseWidth &&
a.groupedBaseDepth === b.groupedBaseDepth &&
a.groupedBaseHeight === b.groupedBaseHeight &&
a.locked === b.locked &&
a.hidden === b.hidden
);
}
function serializeShapesForSync(shapes: WorkplaneShape[]) { function serializeShapesForSync(shapes: WorkplaneShape[]) {
return JSON.stringify(shapes.map(canonicalizeShape)); return JSON.stringify(shapes.map(canonicalizeShape));
} }
@@ -4047,9 +4087,12 @@ export function SketchForgeEditor({
const fileInputRef = useRef<HTMLInputElement | null>(null); const fileInputRef = useRef<HTMLInputElement | null>(null);
const booleanAutomationRunRef = useRef<string | null>(null); const booleanAutomationRunRef = useRef<string | null>(null);
const projectHydratingRef = useRef(false); const projectHydratingRef = useRef(false);
const projectInteractionActiveRef = useRef(false);
const pendingProjectShapesRef = useRef<WorkplaneShape[] | null>(null);
const projectSyncTimerRef = useRef<number | null>(null); const projectSyncTimerRef = useRef<number | null>(null);
const lastProjectShapesSyncRef = useRef(""); const lastProjectShapesSyncRef = useRef("");
const projectSnapshotRunRef = useRef(0); const projectSnapshotRunRef = useRef(0);
const [projectInteractionActive, setProjectInteractionActive] = useState(false);
useEffect(() => { useEffect(() => {
const applyTitles = () => { const applyTitles = () => {
@@ -4115,6 +4158,9 @@ export function SketchForgeEditor({
if (!projectId || !onProjectSnapshot || typeof window === "undefined") { if (!projectId || !onProjectSnapshot || typeof window === "undefined") {
return; return;
} }
if (projectInteractionActive) {
return;
}
const runId = projectSnapshotRunRef.current + 1; const runId = projectSnapshotRunRef.current + 1;
projectSnapshotRunRef.current = runId; projectSnapshotRunRef.current = runId;
@@ -4134,7 +4180,7 @@ export function SketchForgeEditor({
window.clearTimeout(firstTimer); window.clearTimeout(firstTimer);
window.clearTimeout(secondTimer); window.clearTimeout(secondTimer);
}; };
}, [onProjectSnapshot, projectId, shapes]); }, [onProjectSnapshot, projectId, projectInteractionActive, shapes]);
useEffect(() => { useEffect(() => {
if (selectedShapes.length < 2) { if (selectedShapes.length < 2) {
@@ -4157,6 +4203,14 @@ export function SketchForgeEditor({
if (!projectId || !onProjectShapesChange) { if (!projectId || !onProjectShapesChange) {
return; return;
} }
if (projectInteractionActiveRef.current) {
pendingProjectShapesRef.current = nextShapes.map(canonicalizeShape);
if (projectSyncTimerRef.current !== null) {
window.clearTimeout(projectSyncTimerRef.current);
projectSyncTimerRef.current = null;
}
return;
}
const canonicalNext = nextShapes.map(canonicalizeShape); const canonicalNext = nextShapes.map(canonicalizeShape);
const serialized = projectShapesFingerprint(canonicalNext); const serialized = projectShapesFingerprint(canonicalNext);
if (lastProjectShapesSyncRef.current === serialized) { if (lastProjectShapesSyncRef.current === serialized) {
@@ -4174,6 +4228,21 @@ export function SketchForgeEditor({
[onProjectShapesChange, projectId], [onProjectShapesChange, projectId],
); );
useEffect(() => {
if (projectInteractionActive || !pendingProjectShapesRef.current) {
return;
}
const pendingShapes = pendingProjectShapesRef.current;
pendingProjectShapesRef.current = null;
const timer = window.setTimeout(() => syncProjectShapes(pendingShapes), 180);
return () => window.clearTimeout(timer);
}, [projectInteractionActive, syncProjectShapes]);
const updateProjectInteractionActive = useCallback((active: boolean) => {
projectInteractionActiveRef.current = active;
setProjectInteractionActive((current) => (current === active ? current : active));
}, []);
const commitShapes = useCallback( const commitShapes = useCallback(
(next: WorkplaneShape[], nextSelection: string | string[] | null = selectedIds, message?: string) => { (next: WorkplaneShape[], nextSelection: string | string[] | null = selectedIds, message?: string) => {
const canonicalNext = next.map(canonicalizeShape); const canonicalNext = next.map(canonicalizeShape);
@@ -4246,16 +4315,23 @@ export function SketchForgeEditor({
const updateShape = useCallback((id: string, patch: Partial<WorkplaneShape>) => { const updateShape = useCallback((id: string, patch: Partial<WorkplaneShape>) => {
const cleanedPatch = cleanShapePatch(patch); const cleanedPatch = cleanShapePatch(patch);
setShapes((current) => setShapes((current) => {
current.map((shape) => { let changed = false;
const next = current.map((shape) => {
if (shape.id !== id) { if (shape.id !== id) {
return shape; return shape;
} }
const patched = { ...shape, ...cleanedPatch }; const patched = { ...shape, ...cleanedPatch };
return canonicalizeShape("hole" in cleanedPatch ? withHoleMode(patched, Boolean(cleanedPatch.hole), cleanedPatch.color) : patched); const canonical = canonicalizeShape("hole" in cleanedPatch ? withHoleMode(patched, Boolean(cleanedPatch.hole), cleanedPatch.color) : patched);
}), if (workplaneShapesEqual(shape, canonical)) {
); return shape;
}
changed = true;
return canonical;
});
return changed ? next : current;
});
}, []); }, []);
const deleteSelected = useCallback(() => { const deleteSelected = useCallback(() => {
@@ -5275,6 +5351,7 @@ export function SketchForgeEditor({
onMirrorSelection={mirrorSelectionAcross} onMirrorSelection={mirrorSelectionAcross}
onSelectShape={selectShape} onSelectShape={selectShape}
onSetPlacementElevation={setPlacementWorkplane} onSetPlacementElevation={setPlacementWorkplane}
onInteractionActiveChange={updateProjectInteractionActive}
onUpdateShape={updateShape} onUpdateShape={updateShape}
onWorkplaneModeChange={setWorkplaneMode} onWorkplaneModeChange={setWorkplaneMode}
/> />
+216 -88
View File
@@ -121,6 +121,7 @@ type WorkplaneViewportProps = {
onMirrorSelection: (axis: AlignAxis) => void; onMirrorSelection: (axis: AlignAxis) => void;
onSelectShape: (id: string | string[] | null, mode?: "replace" | "toggle") => void; onSelectShape: (id: string | string[] | null, mode?: "replace" | "toggle") => void;
onSetPlacementElevation: (elevation: number, source: "shape" | "base") => void; onSetPlacementElevation: (elevation: number, source: "shape" | "base") => void;
onInteractionActiveChange?: (active: boolean) => void;
onUpdateShape: (id: string, patch: Partial<WorkplaneShape>) => void; onUpdateShape: (id: string, patch: Partial<WorkplaneShape>) => void;
onWorkplaneModeChange: (active: boolean) => void; onWorkplaneModeChange: (active: boolean) => void;
}; };
@@ -143,6 +144,7 @@ type ThreeState = {
wasCameraMoving: boolean; wasCameraMoving: boolean;
lastOverlaySync: number; lastOverlaySync: number;
lastViewCubeSync: number; lastViewCubeSync: number;
rotationHandleSides: RotationHandleSides | null;
disposeInteractionListeners: () => void; disposeInteractionListeners: () => void;
resize: () => void; resize: () => void;
}; };
@@ -190,6 +192,8 @@ type MarqueeState = {
type TransformHandleKind = "scale" | "height" | "lift" | "rotate"; type TransformHandleKind = "scale" | "height" | "lift" | "rotate";
type RotationAxis = "x" | "y" | "z"; type RotationAxis = "x" | "y" | "z";
type RotationHandleSide = "near" | "right" | "far" | "left";
type RotationHandleSides = Record<RotationAxis, RotationHandleSide>;
type TransformDragState = { type TransformDragState = {
id: string; id: string;
ids: string[]; ids: string[];
@@ -210,6 +214,7 @@ type TransformDragState = {
scalePlaneY: number; scalePlaneY: number;
rotationAxisVector?: THREE.Vector3; rotationAxisVector?: THREE.Vector3;
rotationPivot?: THREE.Vector3; rotationPivot?: THREE.Vector3;
rotationPlaneCenter?: THREE.Vector3;
rotationStartVector?: THREE.Vector3; rotationStartVector?: THREE.Vector3;
rotationScreenCenter?: { x: number; y: number }; rotationScreenCenter?: { x: number; y: number };
rotationScreenSign?: number; rotationScreenSign?: number;
@@ -234,6 +239,8 @@ type TransformOverlayState = {
rotateHandles: Array<{ key: string; className: string; x: number; y: number; angle: number }>; rotateHandles: Array<{ key: string; className: string; x: number; y: number; angle: number }>;
dimensions: Record<string, DimensionMark[]>; dimensions: Record<string, DimensionMark[]>;
rotationWheel: { x: number; y: number; radius: number } | null; rotationWheel: { x: number; y: number; radius: number } | null;
rotationWheels: Record<RotationAxis, { x: number; y: number; radius: number }>;
rotationPlaneCenters: Record<RotationAxis, { x: number; y: number; z: number }>;
rotationPlanes: Record<RotationAxis, RotationPlaneView>; rotationPlanes: Record<RotationAxis, RotationPlaneView>;
}; };
@@ -331,10 +338,6 @@ function isVerticalMeasureHandleKind(kind: TransformHandleKind) {
return kind === "height" || kind === "lift"; return kind === "height" || kind === "lift";
} }
function isHeightMeasureKey(key: string | null) {
return key === "top-height" || key === "bottom-height";
}
function getElevationMeasureKey(overlay: TransformOverlayState | null) { function getElevationMeasureKey(overlay: TransformOverlayState | null) {
return ( return (
Object.values(overlay?.dimensions ?? {}) Object.values(overlay?.dimensions ?? {})
@@ -344,7 +347,13 @@ function getElevationMeasureKey(overlay: TransformOverlayState | null) {
} }
function measureKeyForHandle(kind: TransformHandleKind, handleKey: string, overlay: TransformOverlayState | null) { function measureKeyForHandle(kind: TransformHandleKind, handleKey: string, overlay: TransformOverlayState | null) {
return isVerticalMeasureHandleKind(kind) ? (getElevationMeasureKey(overlay) ?? handleKey) : handleKey; if (kind === "lift") {
return getElevationMeasureKey(overlay) ?? handleKey;
}
if (kind === "height") {
return null;
}
return handleKey;
} }
function previewShapesForDrag(shapes: WorkplaneShape[], drag: DragState | null) { function previewShapesForDrag(shapes: WorkplaneShape[], drag: DragState | null) {
@@ -444,10 +453,10 @@ function unwrapRadians(value: number) {
} }
function rotationAxisForHandle(handleKey: string): RotationAxis { function rotationAxisForHandle(handleKey: string): RotationAxis {
if (handleKey.endsWith("-x") || handleKey === "rotate-right") { if (handleKey.endsWith("-x") || handleKey === "rotate-left") {
return "x"; return "x";
} }
if (handleKey.endsWith("-z") || handleKey === "rotate-left") { if (handleKey.endsWith("-z") || handleKey === "rotate-right") {
return "z"; return "z";
} }
return "y"; return "y";
@@ -648,8 +657,10 @@ function boundsIntersectRect(bounds: NonNullable<ReturnType<typeof shapeScreenBo
return bounds.maxX >= rect.left && bounds.minX <= rect.right && bounds.maxY >= rect.top && bounds.minY <= rect.bottom; return bounds.maxX >= rect.left && bounds.minX <= rect.right && bounds.maxY >= rect.top && bounds.minY <= rect.bottom;
} }
function rotationAxisVectorForFrame(handleKey: string, _frame: SelectionFrame) { function rotationAxisVectorForFrame(handleKey: string, frame: SelectionFrame) {
return rotationAxisVector(rotationAxisForHandle(handleKey)); const axis = rotationAxisForHandle(handleKey);
void frame;
return rotationAxisVector(axis);
} }
function rayPointOnRotationPlane(state: ThreeState, clientX: number, clientY: number, pivot: THREE.Vector3, axis: THREE.Vector3) { function rayPointOnRotationPlane(state: ThreeState, clientX: number, clientY: number, pivot: THREE.Vector3, axis: THREE.Vector3) {
@@ -671,6 +682,68 @@ function screenVectorAngle(from: { x: number; y: number }, to: { x: number; y: n
return THREE.MathUtils.radToDeg(Math.atan2(to.y - from.y, to.x - from.x)); return THREE.MathUtils.radToDeg(Math.atan2(to.y - from.y, to.x - from.x));
} }
const ROTATION_HANDLE_SIDE_HYSTERESIS = 0.22;
const ROTATION_HANDLE_DOMINANCE_HYSTERESIS = 0.18;
function signedRotationSide(value: number, previous: RotationHandleSide | undefined, positiveSide: RotationHandleSide, negativeSide: RotationHandleSide) {
if (previous === positiveSide && value > -ROTATION_HANDLE_SIDE_HYSTERESIS) {
return previous;
}
if (previous === negativeSide && value < ROTATION_HANDLE_SIDE_HYSTERESIS) {
return previous;
}
return value >= 0 ? positiveSide : negativeSide;
}
function rotationSideScore(side: RotationHandleSide, viewX: number, viewZ: number) {
if (side === "right") {
return viewX;
}
if (side === "left") {
return -viewX;
}
if (side === "near") {
return viewZ;
}
return -viewZ;
}
function dominantRotationSide(viewX: number, viewZ: number, previous: RotationHandleSide | undefined) {
const sides: RotationHandleSide[] = ["near", "right", "far", "left"];
const best = sides.reduce(
(current, side) => {
const score = rotationSideScore(side, viewX, viewZ);
return score > current.score ? { side, score } : current;
},
{ side: "near" as RotationHandleSide, score: Number.NEGATIVE_INFINITY },
);
if (previous && rotationSideScore(previous, viewX, viewZ) >= best.score - ROTATION_HANDLE_DOMINANCE_HYSTERESIS) {
return previous;
}
return best.side;
}
function rotationHandleSidesForCamera(state: ThreeState, center: THREE.Vector3) {
const view = state.camera.position.clone().sub(center);
view.y = 0;
const length = view.length();
if (length < 0.0001) {
return state.rotationHandleSides ?? { x: "right", y: "near", z: "near" };
}
const viewX = view.x / length;
const viewZ = view.z / length;
const previous = state.rotationHandleSides ?? undefined;
const next: RotationHandleSides = {
x: signedRotationSide(viewX, previous?.x, "right", "left"),
y: dominantRotationSide(viewX, viewZ, previous?.y),
z: signedRotationSide(viewZ, previous?.z, "near", "far"),
};
state.rotationHandleSides = next;
return next;
}
function projectedWorldYForScreenY(state: ThreeState, shape: WorkplaneShape, targetScreenY: number, startWorldY: number) { function projectedWorldYForScreenY(state: ThreeState, shape: WorkplaneShape, targetScreenY: number, startWorldY: number) {
let nextWorldY = startWorldY; let nextWorldY = startWorldY;
for (let index = 0; index < 8; index += 1) { for (let index = 0; index < 8; index += 1) {
@@ -842,6 +915,7 @@ export function WorkplaneViewport({
onMirrorSelection, onMirrorSelection,
onSelectShape, onSelectShape,
onSetPlacementElevation, onSetPlacementElevation,
onInteractionActiveChange,
onUpdateShape, onUpdateShape,
onWorkplaneModeChange, onWorkplaneModeChange,
}: WorkplaneViewportProps) { }: WorkplaneViewportProps) {
@@ -1167,20 +1241,28 @@ export function WorkplaneViewport({
const yStart = handlesLowerSide ? yBounds.min : yBounds.max; const yStart = handlesLowerSide ? yBounds.min : yBounds.max;
const liftOffset = kind === "lift" ? Math.max(2, yBounds.height * 0.08) * (handlesLowerSide ? -1 : 1) : 0; const liftOffset = kind === "lift" ? Math.max(2, yBounds.height * 0.08) * (handlesLowerSide ? -1 : 1) : 0;
const startWorldY = yStart + liftOffset; const startWorldY = yStart + liftOffset;
const wheel = transformOverlayRef.current?.rotationWheel ?? undefined; const overlay = transformOverlayRef.current;
const wheel = kind === "rotate" ? (overlay?.rotationWheels[rotationAxis] ?? overlay?.rotationWheel ?? undefined) : undefined;
const rotationPlaneCenterData = kind === "rotate" ? overlay?.rotationPlaneCenters[rotationAxis] : undefined;
const rotationPlaneCenter = rotationPlaneCenterData
? new THREE.Vector3(rotationPlaneCenterData.x, rotationPlaneCenterData.y, rotationPlaneCenterData.z)
: frame.center.clone();
const rect = state?.renderer.domElement.getBoundingClientRect(); const rect = state?.renderer.domElement.getBoundingClientRect();
const localClientX = rect ? event.clientX - rect.left : event.clientX; const localClientX = rect ? event.clientX - rect.left : event.clientX;
const localClientY = rect ? event.clientY - rect.top : event.clientY; const localClientY = rect ? event.clientY - rect.top : event.clientY;
const axisVector = rotationAxisVectorForFrame(handleKey, frame); const axisVector = rotationAxisVectorForFrame(handleKey, frame);
const pivot = frame.center.clone(); const pivot = frame.center.clone();
const rotationCenter = kind === "rotate" ? wheel ?? (state ? projectToScreen(pivot, state) : { x: localClientX, y: localClientY }) : undefined; const rotationCenter = kind === "rotate" ? wheel ?? (state ? projectToScreen(pivot, state) : { x: localClientX, y: localClientY }) : undefined;
const rotationStartPoint = kind === "rotate" && state ? rayPointOnRotationPlane(state, event.clientX, event.clientY, pivot, axisVector) : null; const rotationStartPoint = kind === "rotate" && state ? rayPointOnRotationPlane(state, event.clientX, event.clientY, rotationPlaneCenter, axisVector) : null;
const rotationStartVector = rotationStartPoint ? rotationStartPoint.sub(pivot) : undefined; const rotationStartVector = rotationStartPoint ? rotationStartPoint.sub(rotationPlaneCenter) : undefined;
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
event.currentTarget.setPointerCapture(event.pointerId); event.currentTarget.setPointerCapture(event.pointerId);
setEditingRotation(null); setEditingRotation(null);
setPinnedMeasureKey(measureKeyForHandle(kind, handleKey, transformOverlayRef.current)); setPinnedMeasureKey(measureKeyForHandle(kind, handleKey, transformOverlayRef.current));
if (kind === "height") {
setHoverMeasureKey(null);
}
setActiveRotationWheel(kind === "rotate"); setActiveRotationWheel(kind === "rotate");
setActiveTransformKind(kind); setActiveTransformKind(kind);
if (kind === "rotate") { if (kind === "rotate") {
@@ -1214,6 +1296,7 @@ export function WorkplaneViewport({
scalePlaneY: kind === "scale" ? yBounds.min : 0, scalePlaneY: kind === "scale" ? yBounds.min : 0,
rotationAxisVector: kind === "rotate" ? axisVector : undefined, rotationAxisVector: kind === "rotate" ? axisVector : undefined,
rotationPivot: kind === "rotate" ? pivot : undefined, rotationPivot: kind === "rotate" ? pivot : undefined,
rotationPlaneCenter: kind === "rotate" ? rotationPlaneCenter : undefined,
rotationStartVector: kind === "rotate" ? rotationStartVector : undefined, rotationStartVector: kind === "rotate" ? rotationStartVector : undefined,
rotationScreenCenter: rotationCenter, rotationScreenCenter: rotationCenter,
rotationScreenSign: kind === "rotate" && state ? rotationScreenSign(axisVector, state.camera) : 1, rotationScreenSign: kind === "rotate" && state ? rotationScreenSign(axisVector, state.camera) : 1,
@@ -1241,8 +1324,9 @@ export function WorkplaneViewport({
if (state) { if (state) {
state.controls.enabled = false; state.controls.enabled = false;
} }
onInteractionActiveChange?.(true);
}, },
[], [onInteractionActiveChange],
); );
const updateTransform = useCallback( const updateTransform = useCallback(
@@ -1351,10 +1435,11 @@ export function WorkplaneViewport({
const localClientY = clientY - rect.top; const localClientY = clientY - rect.top;
const axisVector = (transform.rotationAxisVector ?? rotationAxisVectorForFrame(transform.handleKey, transform.selectionFrame)).clone().normalize(); const axisVector = (transform.rotationAxisVector ?? rotationAxisVectorForFrame(transform.handleKey, transform.selectionFrame)).clone().normalize();
const pivot = transform.rotationPivot ?? transform.selectionFrame.center; const pivot = transform.rotationPivot ?? transform.selectionFrame.center;
const currentPoint = rayPointOnRotationPlane(state, clientX, clientY, pivot, axisVector); const planeCenter = transform.rotationPlaneCenter ?? pivot;
const currentPoint = rayPointOnRotationPlane(state, clientX, clientY, planeCenter, axisVector);
const rawDelta = const rawDelta =
currentPoint && transform.rotationStartVector && transform.rotationStartVector.lengthSq() > 0.000001 currentPoint && transform.rotationStartVector && transform.rotationStartVector.lengthSq() > 0.000001
? THREE.MathUtils.radToDeg(signedAngleAroundAxis(transform.rotationStartVector, currentPoint.sub(pivot), axisVector)) ? THREE.MathUtils.radToDeg(signedAngleAroundAxis(transform.rotationStartVector, currentPoint.sub(planeCenter), axisVector))
: THREE.MathUtils.radToDeg(unwrapRadians(screenAngle(localClientX, localClientY, rotationCenter) - transform.startScreenAngle)) * (transform.rotationScreenSign ?? 1); : THREE.MathUtils.radToDeg(unwrapRadians(screenAngle(localClientX, localClientY, rotationCenter) - transform.startScreenAngle)) * (transform.rotationScreenSign ?? 1);
const distance = transform.wheelCenter ? Math.hypot(localClientX - transform.wheelCenter.x, localClientY - transform.wheelCenter.y) : Number.POSITIVE_INFINITY; const distance = transform.wheelCenter ? Math.hypot(localClientX - transform.wheelCenter.x, localClientY - transform.wheelCenter.y) : Number.POSITIVE_INFINITY;
let delta: number; let delta: number;
@@ -1407,8 +1492,11 @@ export function WorkplaneViewport({
if (event.currentTarget.hasPointerCapture(transform.pointerId)) { if (event.currentTarget.hasPointerCapture(transform.pointerId)) {
event.currentTarget.releasePointerCapture(transform.pointerId); event.currentTarget.releasePointerCapture(transform.pointerId);
} }
if (isVerticalMeasureHandleKind(transform.kind)) { if (transform.kind === "lift") {
setPinnedMeasureKey(getElevationMeasureKey(transformOverlayRef.current)); setPinnedMeasureKey(getElevationMeasureKey(transformOverlayRef.current));
} else if (transform.kind === "height") {
setPinnedMeasureKey(null);
setHoverMeasureKey(null);
} }
if (transform.kind === "lift" && transform.hasMoved) { if (transform.kind === "lift" && transform.hasMoved) {
suppressLiftEditAfterDrag(); suppressLiftEditAfterDrag();
@@ -1420,7 +1508,8 @@ export function WorkplaneViewport({
if (threeRef.current) { if (threeRef.current) {
threeRef.current.controls.enabled = true; threeRef.current.controls.enabled = true;
} }
}, [suppressLiftEditAfterDrag]); onInteractionActiveChange?.(false);
}, [onInteractionActiveChange, suppressLiftEditAfterDrag]);
const beginDimensionEdit = useCallback((mark: DimensionMark) => { const beginDimensionEdit = useCallback((mark: DimensionMark) => {
if (mark.axis === "height") { if (mark.axis === "height") {
@@ -1633,19 +1722,27 @@ export function WorkplaneViewport({
const yStart = handlesLowerSide ? yBounds.min : yBounds.max; const yStart = handlesLowerSide ? yBounds.min : yBounds.max;
const liftOffset = handle.kind === "lift" ? Math.max(2, yBounds.height * 0.08) * (handlesLowerSide ? -1 : 1) : 0; const liftOffset = handle.kind === "lift" ? Math.max(2, yBounds.height * 0.08) * (handlesLowerSide ? -1 : 1) : 0;
const startWorldY = yStart + liftOffset; const startWorldY = yStart + liftOffset;
const wheel = transformOverlayRef.current?.rotationWheel ?? undefined; const overlay = transformOverlayRef.current;
const rotationAxis = rotationAxisForHandle(handle.handleKey); const rotationAxis = rotationAxisForHandle(handle.handleKey);
const wheel = handle.kind === "rotate" ? (overlay?.rotationWheels[rotationAxis] ?? overlay?.rotationWheel ?? undefined) : undefined;
const rotationPlaneCenterData = handle.kind === "rotate" ? overlay?.rotationPlaneCenters[rotationAxis] : undefined;
const rotationPlaneCenter = rotationPlaneCenterData
? new THREE.Vector3(rotationPlaneCenterData.x, rotationPlaneCenterData.y, rotationPlaneCenterData.z)
: frame.center.clone();
const localClientX = event.clientX - rect.left; const localClientX = event.clientX - rect.left;
const localClientY = event.clientY - rect.top; const localClientY = event.clientY - rect.top;
const axisVector = rotationAxisVectorForFrame(handle.handleKey, frame); const axisVector = rotationAxisVectorForFrame(handle.handleKey, frame);
const pivot = frame.center.clone(); const pivot = frame.center.clone();
const rotationCenter = handle.kind === "rotate" ? wheel ?? projectToScreen(pivot, state) : undefined; const rotationCenter = handle.kind === "rotate" ? wheel ?? projectToScreen(pivot, state) : undefined;
const rotationStartPoint = handle.kind === "rotate" ? rayPointOnRotationPlane(state, event.clientX, event.clientY, pivot, axisVector) : null; const rotationStartPoint = handle.kind === "rotate" ? rayPointOnRotationPlane(state, event.clientX, event.clientY, rotationPlaneCenter, axisVector) : null;
const rotationStartVector = rotationStartPoint ? rotationStartPoint.sub(pivot) : undefined; const rotationStartVector = rotationStartPoint ? rotationStartPoint.sub(rotationPlaneCenter) : undefined;
event.preventDefault(); event.preventDefault();
event.currentTarget.setPointerCapture(event.pointerId); event.currentTarget.setPointerCapture(event.pointerId);
setEditingRotation(null); setEditingRotation(null);
setPinnedMeasureKey(measureKeyForHandle(handle.kind, handle.handleKey, transformOverlayRef.current)); setPinnedMeasureKey(measureKeyForHandle(handle.kind, handle.handleKey, transformOverlayRef.current));
if (handle.kind === "height") {
setHoverMeasureKey(null);
}
setActiveRotationWheel(handle.kind === "rotate"); setActiveRotationWheel(handle.kind === "rotate");
setActiveTransformKind(handle.kind); setActiveTransformKind(handle.kind);
if (handle.kind === "rotate") { if (handle.kind === "rotate") {
@@ -1679,6 +1776,7 @@ export function WorkplaneViewport({
scalePlaneY: handle.kind === "scale" ? handle.planeY : 0, scalePlaneY: handle.kind === "scale" ? handle.planeY : 0,
rotationAxisVector: handle.kind === "rotate" ? axisVector : undefined, rotationAxisVector: handle.kind === "rotate" ? axisVector : undefined,
rotationPivot: handle.kind === "rotate" ? pivot : undefined, rotationPivot: handle.kind === "rotate" ? pivot : undefined,
rotationPlaneCenter: handle.kind === "rotate" ? rotationPlaneCenter : undefined,
rotationStartVector: handle.kind === "rotate" ? rotationStartVector : undefined, rotationStartVector: handle.kind === "rotate" ? rotationStartVector : undefined,
rotationScreenCenter: rotationCenter, rotationScreenCenter: rotationCenter,
rotationScreenSign: handle.kind === "rotate" ? rotationScreenSign(axisVector, state.camera) : 1, rotationScreenSign: handle.kind === "rotate" ? rotationScreenSign(axisVector, state.camera) : 1,
@@ -1702,6 +1800,7 @@ export function WorkplaneViewport({
setRotationReadout(null); setRotationReadout(null);
} }
state.controls.enabled = false; state.controls.enabled = false;
onInteractionActiveChange?.(true);
return; return;
} }
@@ -1723,6 +1822,7 @@ export function WorkplaneViewport({
}; };
setMarqueeFromState(marqueeRef.current); setMarqueeFromState(marqueeRef.current);
state.controls.enabled = false; state.controls.enabled = false;
onInteractionActiveChange?.(true);
return; return;
} }
@@ -1787,8 +1887,20 @@ export function WorkplaneViewport({
items, items,
}; };
state.controls.enabled = false; state.controls.enabled = false;
onInteractionActiveChange?.(true);
}, },
[onAlignAnchorChange, onSelectShape, onSetPlacementElevation, onWorkplaneModeChange, pickShape, pickTransformHandle, setMarqueeFromState, toPlanePoint, toPlanePointAtY], [
onAlignAnchorChange,
onInteractionActiveChange,
onSelectShape,
onSetPlacementElevation,
onWorkplaneModeChange,
pickShape,
pickTransformHandle,
setMarqueeFromState,
toPlanePoint,
toPlanePointAtY,
],
); );
const handlePointerMove = useCallback( const handlePointerMove = useCallback(
@@ -1869,8 +1981,11 @@ export function WorkplaneViewport({
if (event.currentTarget.hasPointerCapture(transform.pointerId)) { if (event.currentTarget.hasPointerCapture(transform.pointerId)) {
event.currentTarget.releasePointerCapture(transform.pointerId); event.currentTarget.releasePointerCapture(transform.pointerId);
} }
if (isVerticalMeasureHandleKind(transform.kind)) { if (transform.kind === "lift") {
setPinnedMeasureKey(getElevationMeasureKey(transformOverlayRef.current)); setPinnedMeasureKey(getElevationMeasureKey(transformOverlayRef.current));
} else if (transform.kind === "height") {
setPinnedMeasureKey(null);
setHoverMeasureKey(null);
} }
if (transform.kind === "lift" && transform.hasMoved) { if (transform.kind === "lift" && transform.hasMoved) {
suppressLiftEditAfterDrag(); suppressLiftEditAfterDrag();
@@ -1882,6 +1997,7 @@ export function WorkplaneViewport({
if (state) { if (state) {
state.controls.enabled = true; state.controls.enabled = true;
} }
onInteractionActiveChange?.(false);
return; return;
} }
@@ -1917,6 +2033,7 @@ export function WorkplaneViewport({
if (state) { if (state) {
state.controls.enabled = true; state.controls.enabled = true;
} }
onInteractionActiveChange?.(false);
return; return;
} }
@@ -1943,8 +2060,9 @@ export function WorkplaneViewport({
if (state) { if (state) {
state.controls.enabled = true; state.controls.enabled = true;
} }
onInteractionActiveChange?.(false);
}, },
[onSelectShape, onUpdateShape, setMarqueeFromState, shapesInMarquee, suppressLiftEditAfterDrag], [onInteractionActiveChange, onSelectShape, onUpdateShape, setMarqueeFromState, shapesInMarquee, suppressLiftEditAfterDrag],
); );
const handleDrop = useCallback( const handleDrop = useCallback(
@@ -2071,10 +2189,9 @@ export function WorkplaneViewport({
rotationReadout={rotationReadout} rotationReadout={rotationReadout}
showRotationWheel={activeRotationWheel} showRotationWheel={activeRotationWheel}
hideDimensionMarks={ hideDimensionMarks={
activeTransformKind === "scale" ||
activeTransformKind === "height" || activeTransformKind === "height" ||
activeTransformKind === "lift" || editingDimension?.axis === "height"
editingDimension?.axis === "height" ||
editingDimension?.axis === "elevation"
} }
rotationWheelAxis={rotationWheelAxis} rotationWheelAxis={rotationWheelAxis}
onBeginTransform={beginTransform} onBeginTransform={beginTransform}
@@ -2453,10 +2570,10 @@ function TransformOverlay({
.filter((mark) => mark.axis === "elevation"); .filter((mark) => mark.axis === "elevation");
const elevationHandleKey = elevationMarks[0]?.handleKey; const elevationHandleKey = elevationMarks[0]?.handleKey;
const rawMarks = measureKey ? (box.dimensions[measureKey] ?? []) : []; const rawMarks = measureKey ? (box.dimensions[measureKey] ?? []) : [];
const requestedHeightMeasurement = isHeightMeasureKey(measureKey) || rawMarks.some((mark) => mark.axis === "height"); const requestedHeightMeasurement = rawMarks.some((mark) => mark.axis === "height");
const resolvedMeasureKey = requestedHeightMeasurement && elevationHandleKey ? elevationHandleKey : measureKey; const resolvedMeasureKey = requestedHeightMeasurement && elevationHandleKey ? elevationHandleKey : measureKey;
const marks = resolvedMeasureKey ? (box.dimensions[resolvedMeasureKey] ?? []) : []; const marks = resolvedMeasureKey ? (box.dimensions[resolvedMeasureKey] ?? []) : [];
const visibleMarks = (hideDimensionMarks || requestedHeightMeasurement ? elevationMarks : marks).filter( const visibleMarks = (hideDimensionMarks ? [] : requestedHeightMeasurement ? elevationMarks : marks).filter(
(mark) => mark.axis !== "height" && mark.key !== editingDimension?.key, (mark) => mark.axis !== "height" && mark.key !== editingDimension?.key,
); );
const handleMeasureKey = (handle: TransformOverlayState["handles"][number]) => measureKeyForHandle(handle.kind, handle.key, box); const handleMeasureKey = (handle: TransformOverlayState["handles"][number]) => measureKeyForHandle(handle.kind, handle.key, box);
@@ -2482,9 +2599,10 @@ function TransformOverlay({
y: Math.sin(activeRadians) * 92, y: Math.sin(activeRadians) * 92,
}; };
const plane = box.rotationPlanes[rotationWheelAxis]; const plane = box.rotationPlanes[rotationWheelAxis];
const wheel = box.rotationWheels[rotationWheelAxis] ?? box.rotationWheel;
return ( return (
<div className="transform-overlay" aria-hidden="true"> <div className="transform-overlay" aria-hidden="true">
{showRotationWheel && box.rotationWheel && plane ? ( {showRotationWheel && wheel && plane ? (
<svg <svg
className={`rotation-protractor-plane axis-${rotationWheelAxis}`} className={`rotation-protractor-plane axis-${rotationWheelAxis}`}
viewBox={`0 0 ${box.width} ${box.height}`} viewBox={`0 0 ${box.width} ${box.height}`}
@@ -2590,7 +2708,7 @@ function TransformOverlay({
className={`transform-handle ${handle.className}`} className={`transform-handle ${handle.className}`}
style={{ "--overlay-x": `${handle.x}px`, "--overlay-y": `${handle.y}px` } as CSSProperties} style={{ "--overlay-x": `${handle.x}px`, "--overlay-y": `${handle.y}px` } as CSSProperties}
title={handle.title} title={handle.title}
onPointerEnter={() => onHoverMeasure(handleMeasureKey(handle))} onPointerEnter={() => onHoverMeasure(handle.kind === "lift" ? null : handleMeasureKey(handle))}
onPointerLeave={() => onHoverMeasure(null)} onPointerLeave={() => onHoverMeasure(null)}
onPointerDown={(event) => { onPointerDown={(event) => {
onPinMeasure(handleMeasureKey(handle)); onPinMeasure(handleMeasureKey(handle));
@@ -3195,6 +3313,7 @@ function createThreeScene(host: HTMLDivElement): ThreeState {
wasCameraMoving: false, wasCameraMoving: false,
lastOverlaySync: 0, lastOverlaySync: 0,
lastViewCubeSync: 0, lastViewCubeSync: 0,
rotationHandleSides: null,
disposeInteractionListeners: () => {}, disposeInteractionListeners: () => {},
resize, resize,
}; };
@@ -3448,6 +3567,18 @@ function makeDimensionMark(
}; };
} }
function updateTransformOverlayIfChanged(
overlayRef: MutableRefObject<TransformOverlayState | null>,
setOverlay: Dispatch<SetStateAction<TransformOverlayState | null>>,
next: TransformOverlayState,
) {
if (overlayRef.current && JSON.stringify(overlayRef.current) === JSON.stringify(next)) {
return;
}
overlayRef.current = next;
setOverlay(next);
}
function syncTransformOverlay( function syncTransformOverlay(
state: ThreeState, state: ThreeState,
shapes: WorkplaneShape[], shapes: WorkplaneShape[],
@@ -3520,7 +3651,9 @@ function syncTransformOverlay(
const worldMinZ = Math.min(...corners.map((corner) => corner.z)); const worldMinZ = Math.min(...corners.map((corner) => corner.z));
const worldMaxZ = Math.max(...corners.map((corner) => corner.z)); const worldMaxZ = Math.max(...corners.map((corner) => corner.z));
const worldCenterX = (worldMinX + worldMaxX) / 2; const worldCenterX = (worldMinX + worldMaxX) / 2;
const worldCenterY = (worldMinY + worldMaxY) / 2;
const worldCenterZ = (worldMinZ + worldMaxZ) / 2; const worldCenterZ = (worldMinZ + worldMaxZ) / 2;
const worldCenter = new THREE.Vector3(worldCenterX, worldCenterY, worldCenterZ);
const worldHeight = Math.max(MIN_SHAPE_SIZE, worldMaxY - worldMinY); const worldHeight = Math.max(MIN_SHAPE_SIZE, worldMaxY - worldMinY);
const liftOffset = Math.max(2, worldHeight * 0.08); const liftOffset = Math.max(2, worldHeight * 0.08);
const verticalBase = new THREE.Vector3(worldCenterX, worldMinY, worldCenterZ); const verticalBase = new THREE.Vector3(worldCenterX, worldMinY, worldCenterZ);
@@ -3532,6 +3665,7 @@ function syncTransformOverlay(
// bounding box. Do not switch this to screen-space bounds or the object's // bounding box. Do not switch this to screen-space bounds or the object's
// tilted local bottom face; both make tilted shapes look disconnected. // tilted local bottom face; both make tilted shapes look disconnected.
const xFootAxis = new THREE.Vector3(1, 0, 0); const xFootAxis = new THREE.Vector3(1, 0, 0);
const yFootAxis = new THREE.Vector3(0, 1, 0);
const zFootAxis = new THREE.Vector3(0, 0, 1); const zFootAxis = new THREE.Vector3(0, 0, 1);
const footprintWorld = { const footprintWorld = {
nearLeft: new THREE.Vector3(worldMinX, worldMinY, worldMaxZ), nearLeft: new THREE.Vector3(worldMinX, worldMinY, worldMaxZ),
@@ -3549,18 +3683,6 @@ function syncTransformOverlay(
farRight: project(footprintWorld.farRight), farRight: project(footprintWorld.farRight),
farLeft: project(footprintWorld.farLeft), farLeft: project(footprintWorld.farLeft),
}; };
const topWorld = {
nearLeft: new THREE.Vector3(worldMinX, worldMaxY, worldMaxZ),
nearRight: new THREE.Vector3(worldMaxX, worldMaxY, worldMaxZ),
farRight: new THREE.Vector3(worldMaxX, worldMaxY, worldMinZ),
farLeft: new THREE.Vector3(worldMinX, worldMaxY, worldMinZ),
};
const top = {
nearLeft: project(topWorld.nearLeft),
nearRight: project(topWorld.nearRight),
farRight: project(topWorld.farRight),
farLeft: project(topWorld.farLeft),
};
const mid = { const mid = {
near: project(footprintWorld.near), near: project(footprintWorld.near),
right: project(footprintWorld.right), right: project(footprintWorld.right),
@@ -3571,7 +3693,7 @@ function syncTransformOverlay(
const topPoint = project(verticalTop); const topPoint = project(verticalTop);
const heightPoint = project(heightHandle); const heightPoint = project(heightHandle);
const liftPoint = project(liftHandle); const liftPoint = project(liftHandle);
const centerPoint = project(frame.center); const centerPoint = project(worldCenter);
const footprintGuides = [ const footprintGuides = [
{ x1: bottom.nearLeft.x, y1: bottom.nearLeft.y, x2: bottom.nearRight.x, y2: bottom.nearRight.y }, { x1: bottom.nearLeft.x, y1: bottom.nearLeft.y, x2: bottom.nearRight.x, y2: bottom.nearRight.y },
{ x1: bottom.nearRight.x, y1: bottom.nearRight.y, x2: bottom.farRight.x, y2: bottom.farRight.y }, { x1: bottom.nearRight.x, y1: bottom.nearRight.y, x2: bottom.farRight.x, y2: bottom.farRight.y },
@@ -3623,58 +3745,63 @@ function syncTransformOverlay(
y: point.y + (dy / length) * distance, y: point.y + (dy / length) * distance,
}; };
}; };
const screenMidpoint = (a: { x: number; y: number }, b: { x: number; y: number }) => ({ const rotationSides = rotationHandleSidesForCamera(state, worldCenter);
x: (a.x + b.x) / 2, const sidePoint = (side: RotationHandleSide, y: number) => {
y: (a.y + b.y) / 2, if (side === "right") {
}); return new THREE.Vector3(worldMaxX, y, worldCenterZ);
const topCornerScreens = [top.nearLeft, top.nearRight, top.farRight, top.farLeft] }
.slice() if (side === "left") {
.sort((a, b) => a.y - b.y) return new THREE.Vector3(worldMinX, y, worldCenterZ);
.slice(0, 2) }
.sort((a, b) => a.x - b.x); if (side === "near") {
const topEdgeCenter = topCornerScreens.length === 2 ? screenMidpoint(topCornerScreens[0], topCornerScreens[1]) : screenMidpoint(top.farLeft, top.farRight); return new THREE.Vector3(worldCenterX, y, worldMaxZ);
const verticalEdgeCenters = [ }
screenMidpoint(top.nearLeft, bottom.nearLeft), return new THREE.Vector3(worldCenterX, y, worldMinZ);
screenMidpoint(top.nearRight, bottom.nearRight), };
screenMidpoint(top.farRight, bottom.farRight), const rotateLeft = screenOffsetFromCenter(project(sidePoint(rotationSides.x, worldMaxY)), 24);
screenMidpoint(top.farLeft, bottom.farLeft), const rotateRight = screenOffsetFromCenter(project(sidePoint(rotationSides.z, worldMaxY)), 28);
]; const rotateBottom = screenOffsetFromCenter(project(sidePoint(rotationSides.y, worldMinY)), 34);
const rightEdgeCenter = verticalEdgeCenters.reduce((rightmost, point) => (point.x > rightmost.x ? point : rightmost)); const xFaceCenter = sidePoint(rotationSides.x, worldCenterY);
const bottomEdgeCenters = [ const zFaceCenter = sidePoint(rotationSides.z, worldCenterY);
screenMidpoint(bottom.nearLeft, bottom.nearRight), const yFaceCenter = sidePoint(rotationSides.y, worldMinY);
screenMidpoint(bottom.nearRight, bottom.farRight), const planeRadius = 154;
screenMidpoint(bottom.farRight, bottom.farLeft),
screenMidpoint(bottom.farLeft, bottom.nearLeft),
];
const lowerEdgeCenter = bottomEdgeCenters.reduce((lowest, point) => (point.y > lowest.y ? point : lowest));
const rotateLeft = screenOffsetFromCenter(topEdgeCenter, 24);
const rotateRight = screenOffsetFromCenter(rightEdgeCenter, 26);
const rotateBottom = screenOffsetFromCenter(lowerEdgeCenter, 34);
const planeRadius = 112;
const planeWorldStep = Math.max(12, Math.max(frame.width, frame.depth, frame.height) * 0.78); const planeWorldStep = Math.max(12, Math.max(frame.width, frame.depth, frame.height) * 0.78);
const worldXAxis = new THREE.Vector3(1, 0, 0); const makePlaneView = (centerWorld: THREE.Vector3, uAxis: THREE.Vector3, vAxis: THREE.Vector3): RotationPlaneView => {
const worldYAxis = new THREE.Vector3(0, 1, 0); const screenCenter = project(centerWorld);
const worldZAxis = new THREE.Vector3(0, 0, 1); const u = project(centerWorld.clone().add(uAxis.clone().multiplyScalar(planeWorldStep)));
const makePlaneView = (uAxis: THREE.Vector3, vAxis: THREE.Vector3): RotationPlaneView => { const v = project(centerWorld.clone().add(vAxis.clone().multiplyScalar(planeWorldStep)));
const u = project(frame.center.clone().add(uAxis.clone().multiplyScalar(planeWorldStep))); const du = { x: u.x - screenCenter.x, y: u.y - screenCenter.y };
const v = project(frame.center.clone().add(vAxis.clone().multiplyScalar(planeWorldStep))); const dv = { x: v.x - screenCenter.x, y: v.y - screenCenter.y };
const du = { x: u.x - centerPoint.x, y: u.y - centerPoint.y };
const dv = { x: v.x - centerPoint.x, y: v.y - centerPoint.y };
const longest = Math.max(12, Math.hypot(du.x, du.y), Math.hypot(dv.x, dv.y)); const longest = Math.max(12, Math.hypot(du.x, du.y), Math.hypot(dv.x, dv.y));
const scale = planeRadius / longest / 100; const scale = planeRadius / longest / 100;
return { return {
x: centerPoint.x, x: screenCenter.x,
y: centerPoint.y, y: screenCenter.y,
a: du.x * scale, a: du.x * scale,
b: du.y * scale, b: du.y * scale,
c: dv.x * scale, c: dv.x * scale,
d: dv.y * scale, d: dv.y * scale,
}; };
}; };
const rotationPlanes = { const makeWheel = (centerWorld: THREE.Vector3) => {
x: makePlaneView(worldZAxis, worldYAxis), const screenCenter = project(centerWorld);
y: makePlaneView(worldXAxis, worldZAxis), return { x: screenCenter.x, y: screenCenter.y, radius: planeRadius };
z: makePlaneView(worldXAxis, worldYAxis), };
const makeWorldPoint = (point: THREE.Vector3) => ({ x: point.x, y: point.y, z: point.z });
const rotationWheels: Record<RotationAxis, { x: number; y: number; radius: number }> = {
x: makeWheel(xFaceCenter),
y: makeWheel(yFaceCenter),
z: makeWheel(zFaceCenter),
};
const rotationPlaneCenters: Record<RotationAxis, { x: number; y: number; z: number }> = {
x: makeWorldPoint(xFaceCenter),
y: makeWorldPoint(yFaceCenter),
z: makeWorldPoint(zFaceCenter),
};
const rotationPlanes: Record<RotationAxis, RotationPlaneView> = {
x: makePlaneView(xFaceCenter, zFootAxis, yFootAxis),
y: makePlaneView(yFaceCenter, xFootAxis, zFootAxis),
z: makePlaneView(zFaceCenter, xFootAxis, yFootAxis),
}; };
const next = { const next = {
@@ -3703,12 +3830,13 @@ function syncTransformOverlay(
{ key: "rotate-bottom", className: "screen-bottom", x: rotateBottom.x, y: rotateBottom.y, angle: screenVectorAngle(centerPoint, rotateBottom) + 90 }, { key: "rotate-bottom", className: "screen-bottom", x: rotateBottom.x, y: rotateBottom.y, angle: screenVectorAngle(centerPoint, rotateBottom) + 90 },
], ],
dimensions: dimensionMarks, dimensions: dimensionMarks,
rotationWheel: { x: centerPoint.x, y: centerPoint.y, radius: 112 }, rotationWheel: rotationWheels.y,
rotationWheels,
rotationPlaneCenters,
rotationPlanes, rotationPlanes,
}; };
overlayRef.current = next; updateTransformOverlayIfChanged(overlayRef, setOverlay, next);
setOverlay(next);
} }
function syncAlignOverlay( function syncAlignOverlay(