checkpoint: preserve live viewport previews

This commit is contained in:
Formsmith
2026-07-24 15:51:01 +03:00
parent a1c90b33d0
commit 33671c1aae
2 changed files with 28 additions and 6 deletions
@@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">
<defs>
<linearGradient id="gear-face" x1="20" y1="12" x2="74" y2="83" gradientUnits="userSpaceOnUse">
<stop stop-color="#f0f3f5"/>
<stop offset="1" stop-color="#9aa5ad"/>
</linearGradient>
<filter id="gear-shadow" x="-20%" y="-20%" width="140%" height="150%">
<feDropShadow dx="0" dy="4" stdDeviation="3" flood-color="#34434d" flood-opacity=".28"/>
</filter>
</defs>
<path fill="url(#gear-face)" stroke="#66747e" stroke-width="2.5" stroke-linejoin="round" filter="url(#gear-shadow)" d="M43 8h10l2 10c3 1 6 2 9 4l9-6 7 7-6 9c2 3 3 6 4 9l10 2v10l-10 2c-1 3-2 6-4 9l6 9-7 7-9-6c-3 2-6 3-9 4l-2 10H43l-2-10c-3-1-6-2-9-4l-9 6-7-7 6-9c-2-3-3-6-4-9L8 53V43l10-2c1-3 2-6 4-9l-6-9 7-7 9 6c3-2 6-3 9-4z"/>
<circle cx="48" cy="48" r="21" fill="#d7dde1" stroke="#7a8790" stroke-width="2"/>
<circle cx="48" cy="48" r="9" fill="#f8fafb" stroke="#65737d" stroke-width="3"/>
</svg>

After

Width:  |  Height:  |  Size: 971 B

+14 -6
View File
@@ -401,6 +401,10 @@ function previewShapesForDrag(shapes: WorkplaneShape[], drag: DragState | null)
}); });
} }
function shouldBuildCutPreviews(transform: TransformDragState | null, drag: DragState | null) {
return !drag && (!transform || transform.kind === "scale" || transform.kind === "height");
}
function clamp(value: number, min: number, max: number) { function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value)); return Math.min(max, Math.max(min, value));
} }
@@ -1740,7 +1744,7 @@ export function WorkplaneViewport({
useEffect(() => { useEffect(() => {
shapesRef.current = shapes; shapesRef.current = shapes;
rebuildShapes(threeRef.current, shapes, renderSelectionIds(), !transformRef.current && !dragRef.current); rebuildShapes(threeRef.current, shapes, renderSelectionIds(), shouldBuildCutPreviews(transformRef.current, dragRef.current));
refreshDragPreviewObjects(threeRef.current, dragRef.current); refreshDragPreviewObjects(threeRef.current, dragRef.current);
if (threeRef.current) { if (threeRef.current) {
syncTransformOverlay( syncTransformOverlay(
@@ -1788,7 +1792,7 @@ export function WorkplaneViewport({
setActiveTransformKind(null); setActiveTransformKind(null);
} }
selectedIdsRef.current = selectedIds; selectedIdsRef.current = selectedIds;
rebuildShapes(threeRef.current, shapesRef.current, renderSelectionIds(selectedIds), !transformRef.current && !dragRef.current); rebuildShapes(threeRef.current, shapesRef.current, renderSelectionIds(selectedIds), shouldBuildCutPreviews(transformRef.current, dragRef.current));
refreshDragPreviewObjects(threeRef.current, dragRef.current); refreshDragPreviewObjects(threeRef.current, dragRef.current);
if (threeRef.current) { if (threeRef.current) {
syncTransformOverlay( syncTransformOverlay(
@@ -2477,7 +2481,9 @@ export function WorkplaneViewport({
setRotationReadout(null); setRotationReadout(null);
} }
if (state) { if (state) {
clearCutPreviewOverlays(state); if (kind !== "scale" && kind !== "height") {
clearCutPreviewOverlays(state);
}
state.needsRender = true; state.needsRender = true;
state.controls.enabled = false; state.controls.enabled = false;
} }
@@ -3058,7 +3064,9 @@ export function WorkplaneViewport({
} else { } else {
setRotationReadout(null); setRotationReadout(null);
} }
clearCutPreviewOverlays(state); if (handle.kind !== "scale" && handle.kind !== "height") {
clearCutPreviewOverlays(state);
}
state.needsRender = true; state.needsRender = true;
state.controls.enabled = false; state.controls.enabled = false;
onInteractionActiveChange?.(true); onInteractionActiveChange?.(true);
@@ -3147,7 +3155,6 @@ export function WorkplaneViewport({
primaryStartZ: shape.z, primaryStartZ: shape.z,
items, items,
}; };
clearCutPreviewOverlays(state);
state.needsRender = true; state.needsRender = true;
state.controls.enabled = false; state.controls.enabled = false;
onInteractionActiveChange?.(true); onInteractionActiveChange?.(true);
@@ -3238,6 +3245,7 @@ export function WorkplaneViewport({
workspaceRef.current.accuracy, workspaceRef.current.accuracy,
true, true,
); );
syncCutPreviewOverlays(threeRef.current, previewShapes);
threeRef.current.lastOverlaySync = performance.now(); threeRef.current.lastOverlaySync = performance.now();
threeRef.current.needsRender = true; threeRef.current.needsRender = true;
} }
@@ -3678,7 +3686,7 @@ export function WorkplaneViewport({
rotationReadout={rotationReadout} rotationReadout={rotationReadout}
showRotationWheel={activeRotationWheel} showRotationWheel={activeRotationWheel}
hideSelectionChrome={activeTransformKind === "rotate"} hideSelectionChrome={activeTransformKind === "rotate"}
hideDimensionMarks={activeTransformKind === "scale"} hideDimensionMarks={false}
rotationWheelAxis={rotationWheelAxis} rotationWheelAxis={rotationWheelAxis}
pinnedRotationWheelView={pinnedRotationWheelView} pinnedRotationWheelView={pinnedRotationWheelView}
onBeginCameraDrag={beginCameraDragFromOverlay} onBeginCameraDrag={beginCameraDragFromOverlay}