From e4f03e17fc5884797e58a1f2d2eadd4ad933d6b4 Mon Sep 17 00:00:00 2001 From: iammojogo-sudo Date: Wed, 10 Jun 2026 11:57:35 -0400 Subject: [PATCH] Update GeneratePage.tsx --- src/areas/generate/GeneratePage.tsx | 53 +++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/areas/generate/GeneratePage.tsx b/src/areas/generate/GeneratePage.tsx index 6ea1844..30d2783 100644 --- a/src/areas/generate/GeneratePage.tsx +++ b/src/areas/generate/GeneratePage.tsx @@ -47,7 +47,7 @@ function ExportDropdown({ } // --------------------------------------------------------------------------- -// ToolButton — icon-only toolbar button with tooltip + active state +// ToolButton - icon-only toolbar button with tooltip + active state // --------------------------------------------------------------------------- function ToolButton({ @@ -147,7 +147,7 @@ function DecimatePopover({ - Processing… + Processing... ) : 'Apply'} @@ -174,6 +174,34 @@ export const DEFAULT_LIGHT_SETTINGS: LightSettings = { fillColor: '#ffffff', } +// Persist the lighting panel settings so they stay put across generations, +// tab switches, and app restarts (until the user changes or resets them). +const LIGHT_SETTINGS_KEY = 'modly.lightSettings' + +function loadLightSettings(): LightSettings { + try { + const raw = localStorage.getItem(LIGHT_SETTINGS_KEY) + if (!raw) return DEFAULT_LIGHT_SETTINGS + const parsed = JSON.parse(raw) + return { + mainIntensity: typeof parsed.mainIntensity === 'number' ? parsed.mainIntensity : DEFAULT_LIGHT_SETTINGS.mainIntensity, + mainColor: typeof parsed.mainColor === 'string' ? parsed.mainColor : DEFAULT_LIGHT_SETTINGS.mainColor, + fillIntensity: typeof parsed.fillIntensity === 'number' ? parsed.fillIntensity : DEFAULT_LIGHT_SETTINGS.fillIntensity, + fillColor: typeof parsed.fillColor === 'string' ? parsed.fillColor : DEFAULT_LIGHT_SETTINGS.fillColor, + } + } catch { + return DEFAULT_LIGHT_SETTINGS + } +} + +function saveLightSettings(s: LightSettings) { + try { + localStorage.setItem(LIGHT_SETTINGS_KEY, JSON.stringify(s)) + } catch { + // ignore storage write errors + } +} + function LightPopover({ settings, onChange, @@ -260,7 +288,7 @@ function SmoothPopover({

Smooth mesh

- + - Processing… + Processing... ) : 'Apply'} @@ -307,13 +335,18 @@ export default function GeneratePage(): JSX.Element { const [unloadStatus, setUnloadStatus] = useState<'idle' | 'done'>('idle') const [panelWidth, setPanelWidth] = useState(DEFAULT_WIDTH) const [openPanel, setOpenPanel] = useState<'export' | 'decimate' | 'smooth' | 'import' | 'light' | null>(null) - const [lightSettings, setLightSettings] = useState(DEFAULT_LIGHT_SETTINGS) + const [lightSettings, setLightSettings] = useState(loadLightSettings) const [decimating, setDecimating] = useState(false) const [smoothing, setSmoothing] = useState(false) const [importing, setImporting] = useState(false) const [gizmoMode, setGizmoMode] = useState<'translate' | 'rotate' | 'scale' | null>(null) const dragging = useRef(false) + // Persist lighting settings whenever they change, so they survive restarts. + useEffect(() => { + saveLightSettings(lightSettings) + }, [lightSettings]) + const isGenerating = useAppStore((s) => s.currentJob?.status === 'uploading' || s.currentJob?.status === 'generating' ) @@ -530,7 +563,7 @@ export default function GeneratePage(): JSX.Element { )} - {importing ? 'Importing…' : 'Import'} + {importing ? 'Importing...' : 'Import'} {!importing && ( @@ -608,7 +641,7 @@ export default function GeneratePage(): JSX.Element { )} - {smoothing ? 'Processing…' : 'Smooth'} + {smoothing ? 'Processing...' : 'Smooth'} {openPanel === 'smooth' && ( )} - {decimating ? 'Processing…' : 'Decimate'} + {decimating ? 'Processing...' : 'Decimate'} {openPanel === 'decimate' && ( )} - {/* Light — always visible, pushed to the right */} + {/* Light - always visible, pushed to the right */}
- {/* Tools bar — always visible; transform tools appear once a mesh is selected */} + {/* Tools bar - always visible; transform tools appear once a mesh is selected */}
{hasModel && meshSelected && ( <>