Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 62 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import PreviewActions from './components/PreviewActions';
import { useDropzone } from './hooks/useDropzone';
import { exportObjectToStlBlob } from './lib/exportStl';
import { exportObjectTo3MFBlob } from './lib/export3mf';
import { buildMultiHeadSchedule } from './lib/multiHeadSchedule';
import { useAppHandlers, type ExportProgressStep } from './hooks/useAppHandlers';
import { useProcessingState } from './hooks/useProcessingState';
import { useBuildWarning } from './hooks/useBuildWarning';
Expand Down Expand Up @@ -80,6 +81,9 @@ type AutoPaintPersisted = Pick<
| 'heightDithering'
| 'ditherLineWidth'
| 'flatPaint'
| 'multiHeadMode'
| 'multiHeadCount'
| 'multiHeadSearchDepth'
>;

const loadAutoPaintPersisted = (): AutoPaintPersisted | null => {
Expand Down Expand Up @@ -107,6 +111,9 @@ const loadAutoPaintPersisted = (): AutoPaintPersisted | null => {
heightDithering: parsed.heightDithering ?? false,
ditherLineWidth: parsed.ditherLineWidth,
flatPaint: parsed.flatPaint ?? false,
multiHeadMode: parsed.multiHeadMode ?? false,
multiHeadCount: parsed.multiHeadCount ?? 4,
multiHeadSearchDepth: parsed.multiHeadSearchDepth ?? 'balanced',
};
} catch {
return null;
Expand Down Expand Up @@ -245,6 +252,9 @@ function App(): React.ReactElement | null {
heightDithering: autopaintHydrated.heightDithering ?? prev.heightDithering,
ditherLineWidth: autopaintHydrated.ditherLineWidth ?? prev.ditherLineWidth,
flatPaint: autopaintHydrated.flatPaint ?? prev.flatPaint,
multiHeadMode: autopaintHydrated.multiHeadMode ?? prev.multiHeadMode,
multiHeadCount: autopaintHydrated.multiHeadCount ?? prev.multiHeadCount,
multiHeadSearchDepth: autopaintHydrated.multiHeadSearchDepth ?? prev.multiHeadSearchDepth,
}));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -264,6 +274,9 @@ function App(): React.ReactElement | null {
heightDithering: threeDState.heightDithering,
ditherLineWidth: threeDState.ditherLineWidth,
flatPaint: threeDState.flatPaint,
multiHeadMode: threeDState.multiHeadMode,
multiHeadCount: threeDState.multiHeadCount,
multiHeadSearchDepth: threeDState.multiHeadSearchDepth,
});
}, [
threeDState.filaments,
Expand All @@ -276,6 +289,9 @@ function App(): React.ReactElement | null {
threeDState.heightDithering,
threeDState.ditherLineWidth,
threeDState.flatPaint,
threeDState.multiHeadMode,
threeDState.multiHeadCount,
threeDState.multiHeadSearchDepth,
]);

// No auto-build on tab switch — the user must click "Build 3D Model" / "Apply Changes".
Expand Down Expand Up @@ -424,8 +440,27 @@ function App(): React.ReactElement | null {
firstLayerHeight: builtModelState.slicerFirstLayerHeight,
layerFilamentColors:
builtModelAutoPaint
? builtModelState.autoPaintFilamentSwatches?.map((s) => s.hex)
? (builtModelState.patchedSliceData?.swatches
?? builtModelState.autoPaintFilamentSwatches)?.map((s) => s.hex)
: undefined,
extruderCount: builtModelState.multiHeadMode
? builtModelState.multiHeadCount
: undefined,
// Head Schedule swap checkpoints -> pause markers at those layers.
swapLayers: builtModelState.multiHeadMode
? buildMultiHeadSchedule({
multiHeadWindows: builtModelState.multiHeadWindows,
nozzleAssignments: builtModelState.nozzleAssignments,
windowRunFilaments: builtModelState.windowRunFilaments,
nonWindowedRanges: builtModelState.nonWindowedRanges,
filaments: builtModelState.filaments,
})
?.filter((e) => e.startLayer > 0 && e.swapCount > 0)
?.map((e) => ({
layer: e.startLayer,
color: e.nozzles.find((n) => n.changed)?.filamentHex,
}))
: undefined,
onProgress,
onZipProgress,
}),
Expand Down Expand Up @@ -665,20 +700,39 @@ function App(): React.ReactElement | null {
slicerFirstLayerHeight={
builtModelState.slicerFirstLayerHeight
}
colorSliceHeights={builtModelState.colorSliceHeights}
colorOrder={builtModelState.colorOrder}
swatches={builtModelState.filteredSwatches}
colorSliceHeights={
builtModelState.patchedSliceData?.colorSliceHeights ??
builtModelState.colorSliceHeights
}
colorOrder={
builtModelState.patchedSliceData?.colorOrder ??
builtModelState.colorOrder
}
swatches={
builtModelAutoPaint && builtModelState.patchedSliceData
? builtModelState.patchedSliceData.swatches
: builtModelState.filteredSwatches
}
filamentSwatches={
builtModelAutoPaint
builtModelAutoPaint && !builtModelState.patchedSliceData
? builtModelState.autoPaintFilamentSwatches
: undefined
}
pixelSize={builtModelState.pixelSize}
rebuildSignal={threeDBuildSignal}
autoPaintEnabled={builtModelAutoPaint}
autoPaintTotalHeight={
builtModelState.autoPaintResult?.totalHeight
perColorLayerColors={
builtModelAutoPaint
? builtModelState.perColorLayerColors
: undefined
}
multiHeadWindows={builtModelState.multiHeadWindows}
colorLayerFilaments={builtModelState.colorLayerFilaments}
windowRunFilaments={builtModelState.windowRunFilaments}
nozzleAssignments={builtModelState.nozzleAssignments}
nonWindowedRanges={builtModelState.nonWindowedRanges}
filamentIds={builtModelState.filaments?.map((f) => f.id)}
autoPaintEnabled={builtModelAutoPaint}
autoPaintTotalHeight={builtModelState.autoPaintResult?.totalHeight}
autoPaintFilamentOrder={
builtModelState.autoPaintResult?.filamentOrder
}
Expand Down
Loading