release: improve rendering architecture and dark mode

This commit is contained in:
Formsmith
2026-07-28 14:52:59 +03:00
parent 33671c1aae
commit edbb11c97d
32 changed files with 3944 additions and 310 deletions
+13 -9
View File
@@ -3,11 +3,6 @@ import type { WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchf
const MIN_VISIBLE_GRID_STEP = 1;
const MAX_VISIBLE_GRID_STEP = 200;
export type GridFootprintBounds = {
minX: number;
minZ: number;
};
function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value));
}
@@ -21,6 +16,13 @@ export function visibleGridStep(workspace: WorkplaneWorkspaceSettings) {
return clamp(workspace.gridBlockSize, MIN_VISIBLE_GRID_STEP, MAX_VISIBLE_GRID_STEP);
}
export type GridFootprintBounds = {
minX: number;
maxX: number;
minZ: number;
maxZ: number;
};
function nearestVisibleGridLine(value: number, workspaceSize: number, step: number) {
const gridOrigin = -workspaceSize / 2;
return gridOrigin + Math.round((value - gridOrigin) / step) * step;
@@ -32,11 +34,13 @@ export function snapShapeFootprintToVisibleGrid(
workspace: WorkplaneWorkspaceSettings,
) {
const step = visibleGridStep(workspace);
const snappedMinX = nearestVisibleGridLine(bounds.minX, workspace.width, step);
const snappedMinZ = nearestVisibleGridLine(bounds.minZ, workspace.depth, step);
const xOffsets = [bounds.minX, bounds.maxX].map((value) => nearestVisibleGridLine(value, workspace.width, step) - value);
const zOffsets = [bounds.minZ, bounds.maxZ].map((value) => nearestVisibleGridLine(value, workspace.depth, step) - value);
const deltaX = xOffsets.reduce((best, value) => Math.abs(value) < Math.abs(best) ? value : best);
const deltaZ = zOffsets.reduce((best, value) => Math.abs(value) < Math.abs(best) ? value : best);
return {
...shape,
x: cleanCoordinate(shape.x + snappedMinX - bounds.minX),
z: cleanCoordinate(shape.z + snappedMinZ - bounds.minZ),
x: cleanCoordinate(shape.x + deltaX),
z: cleanCoordinate(shape.z + deltaZ),
};
}