@@ -3221,6 +3299,9 @@ function rebuildWorkplane(state: ThreeState | null, workspace: WorkspaceSettings
opacity: 0.68,
roughness: 0.92,
side: THREE.FrontSide,
+ polygonOffset: true,
+ polygonOffsetFactor: 1,
+ polygonOffsetUnits: 1,
}),
);
base.name = "WorkplaneBase";
@@ -3235,9 +3316,10 @@ function rebuildWorkplane(state: ThreeState | null, workspace: WorkspaceSettings
function createGridLines(width = WORKPLANE_WIDTH, depth = WORKPLANE_DEPTH, blockSize = DEFAULT_WORKSPACE.gridBlockSize) {
const group = new THREE.Group();
- const minor = new THREE.LineBasicMaterial({ color: "#91dff0", transparent: true, opacity: 0.55 });
- const major = new THREE.LineBasicMaterial({ color: "#4bbddf", transparent: true, opacity: 0.7 });
- const axis = new THREE.LineBasicMaterial({ color: "#34aad2", transparent: true, opacity: 0.88 });
+ const palette = workplaneGridPalette();
+ const minor = new THREE.LineBasicMaterial({ ...palette.minor, transparent: true, depthWrite: false });
+ const major = new THREE.LineBasicMaterial({ ...palette.major, transparent: true, depthWrite: false });
+ const axis = new THREE.LineBasicMaterial({ ...palette.axis, transparent: true, depthWrite: false });
const minorPoints: number[] = [];
const majorPoints: number[] = [];
const axisPoints: number[] = [];
@@ -3247,28 +3329,21 @@ function createGridLines(width = WORKPLANE_WIDTH, depth = WORKPLANE_DEPTH, block
};
const step = clamp(blockSize, MIN_GRID_BLOCK_SIZE, MAX_GRID_BLOCK_SIZE);
const majorEvery = 4;
- const xCount = Math.floor(width / step);
- const zCount = Math.floor(depth / step);
-
- for (let index = 0; index <= xCount; index += 1) {
- const x = -width / 2 + index * step;
- const centeredX = Math.abs(x) < 0.0001 ? 0 : x;
+ for (const { coordinate: centeredX, index } of interiorWorkplaneGridCoordinates(width, step)) {
const points = centeredX === 0 ? axisPoints : index % majorEvery === 0 ? majorPoints : minorPoints;
- pushLine(points, [centeredX, 0.04, -depth / 2], [centeredX, 0.04, depth / 2]);
+ pushLine(points, [centeredX, WORKPLANE_LINE_ELEVATION, -depth / 2], [centeredX, WORKPLANE_LINE_ELEVATION, depth / 2]);
}
- for (let index = 0; index <= zCount; index += 1) {
- const z = -depth / 2 + index * step;
- const centeredZ = Math.abs(z) < 0.0001 ? 0 : z;
+ for (const { coordinate: centeredZ, index } of interiorWorkplaneGridCoordinates(depth, step)) {
const points = centeredZ === 0 ? axisPoints : index % majorEvery === 0 ? majorPoints : minorPoints;
- pushLine(points, [-width / 2, 0.04, centeredZ], [width / 2, 0.04, centeredZ]);
+ pushLine(points, [-width / 2, WORKPLANE_LINE_ELEVATION, centeredZ], [width / 2, WORKPLANE_LINE_ELEVATION, centeredZ]);
}
- const border = new THREE.LineBasicMaterial({ color: "#58c5e6", transparent: true, opacity: 0.9 });
- pushLine(borderPoints, [-width / 2, 0.08, -depth / 2], [width / 2, 0.08, -depth / 2]);
- pushLine(borderPoints, [width / 2, 0.08, -depth / 2], [width / 2, 0.08, depth / 2]);
- pushLine(borderPoints, [width / 2, 0.08, depth / 2], [-width / 2, 0.08, depth / 2]);
- pushLine(borderPoints, [-width / 2, 0.08, depth / 2], [-width / 2, 0.08, -depth / 2]);
+ const border = new THREE.LineBasicMaterial({ ...palette.border, transparent: true, depthWrite: false });
+ pushLine(borderPoints, [-width / 2, WORKPLANE_LINE_ELEVATION, -depth / 2], [width / 2, WORKPLANE_LINE_ELEVATION, -depth / 2]);
+ pushLine(borderPoints, [width / 2, WORKPLANE_LINE_ELEVATION, -depth / 2], [width / 2, WORKPLANE_LINE_ELEVATION, depth / 2]);
+ pushLine(borderPoints, [width / 2, WORKPLANE_LINE_ELEVATION, depth / 2], [-width / 2, WORKPLANE_LINE_ELEVATION, depth / 2]);
+ pushLine(borderPoints, [-width / 2, WORKPLANE_LINE_ELEVATION, depth / 2], [-width / 2, WORKPLANE_LINE_ELEVATION, -depth / 2]);
group.add(linesFromPoints(minorPoints, minor));
group.add(linesFromPoints(majorPoints, major));
@@ -3281,7 +3356,9 @@ function createGridLines(width = WORKPLANE_WIDTH, depth = WORKPLANE_DEPTH, block
function linesFromPoints(points: number[], material: THREE.LineBasicMaterial) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(points, 3));
- return new THREE.LineSegments(geometry, material);
+ const lines = new THREE.LineSegments(geometry, material);
+ lines.renderOrder = 1;
+ return lines;
}
type CutPreviewShapeFrame = {
@@ -4437,7 +4514,7 @@ function createShapeObject(shape: WorkplaneShape, showEdges = false, onTextureRe
opacity: shape.hole ? (shape.importedMesh ? 0.34 : 0.52) : 1,
roughness: shape.hole ? 0.88 : 0.57,
metalness: 0.02,
- side: shape.importedMesh?.sourceFormat === "json" || shape.importedMesh?.sourceFormat === "svg" || mirroredAxisCount(shape) % 2 === 1 ? THREE.DoubleSide : THREE.FrontSide,
+ side: shape.importedMesh?.sourceFormat === "json" || mirroredAxisCount(shape) % 2 === 1 ? THREE.DoubleSide : THREE.FrontSide,
});
const width = shapeWidth(shape);
diff --git a/apps/web/src/components/workplane/EdgeModifierPanel.tsx b/apps/web/src/components/workplane/EdgeModifierPanel.tsx
index eeda9ed..19c924a 100644
--- a/apps/web/src/components/workplane/EdgeModifierPanel.tsx
+++ b/apps/web/src/components/workplane/EdgeModifierPanel.tsx
@@ -4,6 +4,7 @@ import { useEffect, useState, type CSSProperties } from "react";
import { Check, LoaderCircle, Minus, Plus, RotateCcw, X } from "lucide-react";
import { displayStepFromMillimeters, displayToMillimeters, formatMeasurementNumber, lengthDisplayUnit, millimetersToDisplay } from "@/lib/measurementUnits";
import type { CadModifierKind, CadModifierQuality } from "@/lib/cadModifierTypes";
+import { edgeModifierSelectionStatus } from "@/lib/cadModifierRuntime";
import type { WorkplaneWorkspaceSettings } from "@/types/sketchforge";
const MIN_EDGE_MODIFIER_AMOUNT = 0.001;
@@ -34,6 +35,7 @@ function EdgeModifierSlider({
unit,
workspace,
length = false,
+ disabled = false,
onChange,
}: {
label: string;
@@ -44,6 +46,7 @@ function EdgeModifierSlider({
unit?: string;
workspace: WorkplaneWorkspaceSettings;
length?: boolean;
+ disabled?: boolean;
onChange: (value: number) => void;
}) {
const safeMin = Number.isFinite(min) ? min : 0;
@@ -92,6 +95,7 @@ function EdgeModifierSlider({
step={controlStep}
value={editing ? draft : formatSliderValue(controlValue, workspace.accuracy, controlStep)}
inputMode="decimal"
+ disabled={disabled}
onFocus={() => {
setDraft(formatSliderValue(controlValue, workspace.accuracy, controlStep));
setEditing(true);
@@ -117,6 +121,7 @@ function EdgeModifierSlider({
max={controlMax}
step={controlStep}
value={sliderValue}
+ disabled={disabled}
onChange={(event) => handleSliderChange(Number(event.currentTarget.value))}
/>
@@ -142,6 +147,7 @@ export function EdgeModifierPanel({
selectedCount,
availableCount,
busy,
+ prepared,
error,
onAmountChange,
onChamferAngleChange,
@@ -172,6 +178,7 @@ export function EdgeModifierPanel({
selectedCount: number;
availableCount: number;
busy: boolean;
+ prepared: boolean;
error: string | null;
onAmountChange: (value: number) => void;
onChamferAngleChange: (value: number) => void;
@@ -194,7 +201,7 @@ export function EdgeModifierPanel({