Skip to content

feat: save/load settings — export, import & auto-save#18

Open
Avatarsia wants to merge 2 commits intoCNCKitchen:mainfrom
Avatarsia:save-settings
Open

feat: save/load settings — export, import & auto-save#18
Avatarsia wants to merge 2 commits intoCNCKitchen:mainfrom
Avatarsia:save-settings

Conversation

@Avatarsia
Copy link
Copy Markdown
Contributor

@Avatarsia Avatarsia commented Apr 6, 2026

Closes #15

Adds the ability to save and restore all BumpMesh settings, so you don't have to recreate them from scratch each time.

How it works

Export — click the download icon in the header. A small dropdown lets you choose what to include:

  • Settings (always) — all sliders, mapping mode, texture selection, angle limits, etc.
  • Model (optional) — the loaded STL as binary, so the recipient gets the exact same mesh
  • Custom texture (optional) — if you uploaded your own displacement map

Everything gets packed into a single .bumpmesh file (ZIP under the hood, using the fflate library that's already in the project for 3MF support).

Import — click the upload icon in the header, or just drag & drop a .bumpmesh file onto the viewport. Settings get restored, sliders update, and if a model or texture was included they get loaded too.

Auto-save — settings are saved to localStorage whenever you change them and restored automatically when you reload the page. No button needed, it just works.

Details

  • Export dialog only shows the "Custom Texture" checkbox when one is actually loaded
  • Import handles partial files gracefully (e.g. settings-only without a model)
  • Unknown keys in imported settings are ignored (forward-compatible)
  • Full i18n support (EN/DE) for all new UI elements
  • Buttons match the existing header style (same size as theme toggle and language buttons)

Rebased onto upstream + hardening fixes

Rebased onto current upstream/main (perspective camera, boundary falloff, i18n lazy-loading, GPLv3).
i18n keys migrated from inline to lazy-loaded js/i18n/en.js / js/i18n/de.js.

Additional fixes in ab86fb1:

  • Auto-save coverage: non-preview sliders (maxTriangles, refineLength) and lockScale toggle now correctly trigger auto-save (previously bypassed updatePreview() and missed the save call)
  • Import order: model is loaded before settings are applied, so handleModelFile() resets (scaleU, offsetU, etc.) get correctly overridden by the imported values
  • State filtering: useDisplacement (transient UI state for 3D preview toggle) is excluded from export and localStorage serialization
  • Import size limit: 500 MB cap on .bumpmesh import to guard against oversized files
  • Boundary falloff sync: _syncUIFromSettings() now includes the boundary-falloff slider for correct restore of upstream's new falloff feature

Avatarsia and others added 2 commits April 7, 2026 14:03
Add preset export/import via .bumpmesh files (ZIP containing settings,
optional model STL, optional custom texture PNG). Two icon buttons in
the header open an export dialog with checkboxes and a file picker.

- Export dialog lets users choose what to include (settings always,
  model and custom texture optionally)
- Import via file picker or drag & drop of .bumpmesh files
- Auto-save to localStorage on every settings change, restore on reload
- Uses fflate (already bundled) for ZIP creation/extraction
- Full i18n support (EN/DE) for all new UI elements
…filtering

- Auto-save now triggers for non-preview sliders (maxTriangles, refineLength)
  and lockScale toggle that previously bypassed updatePreview()
- Import loads model before applying settings so handleModelFile() resets
  get correctly overridden by the imported values
- Filter useDisplacement from export and localStorage (transient UI state)
- Add 500 MB size limit on .bumpmesh import to prevent zip bombs
- Add boundaryFalloff to _syncUIFromSettings() for upstream compatibility
- Move i18n keys for settings export/import to lazy-loaded en.js/de.js

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Save Settings

1 participant