You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
First color's height drifts by a layer when swatches are recomputed #164
When the first-layer height isn't a multiple of the layer height, the first color's height can jump up or down by one layer whenever the swatch list is recomputed, even though the user didn't change it.
The first color's valid heights are max(layerHeight, firstLayer) + n × layerHeight. In src/hooks/useColorSlicing.ts, two effects disagree about that:
The reconcile effect that runs when filtered changes snaps every height, including the first, to a plain multiple of layerHeight.
The alignment effect then snaps the first color back onto the first-layer lattice, rounding from the already-moved value.
Running the two snaps in sequence on valid starting heights (same arithmetic as the hooks):
Layer / first layer
Start
After 1st recompute
After 2nd
After 3rd
0.08 / 0.20
0.28
0.36
0.44
0.44
0.08 / 0.20
0.52
0.60
0.68
0.76
0.20 / 0.30
0.70
0.50
0.50
0.50
0.10 / 0.25
0.35
0.25
0.25
0.25
Combinations where the first layer is a multiple of the layer height (for example 0.08 / 0.24 or 0.2 / 0.2) are not affected.
How to trigger it: set a 0.2 mm first layer and 0.08 mm layers, set the first color to 0.28 mm, then make any image change that recomputes the swatches but keeps the same colors (such as a crop, or undo and redo in 2D). The first color should come back as 0.36 mm. This was found from the code and a small simulation, and still needs confirming in the app.
Fix
In the reconcile effect, snap the first color in display order to minimum + round((h − minimum) / layerHeight) × layerHeight, where minimum = max(layerHeight, firstLayerHeight), the same rule the alignment effect uses. Leave the other colors unchanged. #156 contains this change.
Acceptance
A node:test regression: repeated reconciliation leaves a valid first-layer height unchanged for first-layer heights that are not a multiple of the layer height.
The swap plan (useSwapPlan) still lines up with the snapped heights.
Activity
vycdev commentedon Nov 19, 2026
Fixed by #178, merged into
develop.