Skip to content

feat: add settings preset save/load#53

Open
henleyb wants to merge 1 commit intoCNCKitchen:mainfrom
henleyb:feature/presets
Open

feat: add settings preset save/load#53
henleyb wants to merge 1 commit intoCNCKitchen:mainfrom
henleyb:feature/presets

Conversation

@henleyb
Copy link
Copy Markdown

@henleyb henleyb commented Apr 22, 2026

Summary

Adds a Presets section to the sidebar for saving, loading, exporting, and importing named settings presets. Presets are stored in localStorage under the key bumpmesh_presets_v1. Export/import as JSON allows sharing between devices.

What's captured

  • All sliders: amplitude, scale U/V, offset U/V, rotation, texture smoothing, seam blend, seam band width, cap angle, boundary falloff, bottom/top angle limits, resolution, output triangles
  • Mapping mode (Triplanar, Cubic, Cylindrical, etc.)
  • Scale lock state
  • Symmetric displacement toggle
  • Active built-in texture name (restored by clicking the matching swatch)

What's intentionally out of scope

  • Surface paint masks (complex geometry data, not worth serialising in v1)
  • Custom uploaded textures (can't serialise binary image data cleanly to JSON)

Implementation notes

  • New js/presets.js module — UI + localStorage, decoupled from app internals via getState/applyState callbacks
  • main.js: hoists _applyScaleV to module scope (was an inline closure) so the preset restore path can use it directly; adds getSettingsSnapshot/applySettingsSnapshot and the initPresets call after wireEvents()
  • index.html: adds an empty <section id="presets-section"> placeholder populated at runtime
  • style.css: preset UI styles using the existing CSS variables (--accent, --surface2, --border, --radius)
  • i18n: English + German translations added. The other 6 languages fall back to English via the existing fallback mechanism — happy to add more translations if preferred

Testing

Tested locally in Brave and Chrome on Windows. Verified:

  • Save/load round-trip restores all captured settings correctly (including the log-scale transform on scale U/V)
  • Scale lock state restores before scale values, preventing lock-toggle side effects
  • Export downloads a readable JSON file; import merges with existing presets
  • Rotation gizmo and all other upstream features continue to work unchanged

Adds a Presets section to the sidebar for saving, loading, exporting, and importing named settings presets. Presets are stored in localStorage under 'bumpmesh_presets_v1'. Export/import as JSON enables sharing between devices.

Scope: captures all slider/select/checkbox settings plus the active built-in texture name. Surface paint masks and custom uploaded textures are intentionally out of scope.

- New js/presets.js module (UI + localStorage, decoupled from app internals)
- main.js: hoists _applyScaleV, adds getSettingsSnapshot/applySettingsSnapshot, wires initPresets
- index.html: empty panel-section placeholder populated at runtime
- style.css: preset UI styles matching existing variable set
- i18n: en + de translations added; other 6 languages fall back to en
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant