MCPcopy Create free account
hub / github.com/CNCKitchen/stlTexturizer / importProject

Function importProject

js/main.js:5467–5562  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

5465 if ('cylinderRadius' in snap) settings.cylinderRadius = snap.cylinderRadius;
5466 if ('cylinderPanelMinimized' in snap) {
5467 settings.cylinderPanelMinimized = !!snap.cylinderPanelMinimized;
5468 cylinderPanel.classList.toggle('minimized', settings.cylinderPanelMinimized);
5469 }
5470 updateCylinderUIVisibility();
5471}
5472
5473/**
5474 * Find a preset by name and activate it. By default, suppresses preset defaults
5475 * (resetTextureSmoothing + defaultScale override) so a just-restored snapshot
5476 * isn't clobbered. Pass applyDefaults=true for fresh user-initiated picks.
5477 */
5478function _selectPresetByName(name, applyDefaults = false) {
5479 if (!name) return false;
5480 const idx = IMAGE_PRESETS.findIndex(p => p.name === name);
5481 if (idx < 0) return false;
5482 const swatch = _presetSwatches[idx];
5483 if (!swatch) return false;
5484 selectPreset(idx, swatch, applyDefaults);
5485 return true;
5486}
5487
5488// ── localStorage auto-save ───────────────────────────────────────────────────
5489
5490let _autoSaveTimer = null;
5491let _autoSavePaused = false;
5492function _autoSaveSettings() {
5493 if (_autoSavePaused) return;
5494 clearTimeout(_autoSaveTimer);
5495 _autoSaveTimer = setTimeout(() => {
5496 try {
5497 const payload = { version: PROJECT_VERSION, ...getSettingsSnapshot() };
5498 sessionStorage.setItem(PROJECT_STORAGE_KEY, JSON.stringify(payload));
5499 } catch { /* quota exceeded or disabled — ignore */ }
5500 }, 300);
5501}
5502
5503function _restoreSessionSettings() {
5504 let raw;
5505 try { raw = sessionStorage.getItem(PROJECT_STORAGE_KEY); }
5506 catch { return; }
5507 if (!raw) return;
5508 let data;
5509 try { data = JSON.parse(raw); } catch { return; }
5510 if (!data || typeof data !== 'object') return;
5511 applySettingsSnapshot(data);
5512 // Preset activation is handled by the thumbnail-load auto-select path —
5513 // it reads activeMapName from sessionStorage and suppresses defaults so
5514 // the user's saved scaleU / textureSmoothing survive.
5515}
5516
5517// Delegate auto-save to input/change bubbling in the settings panel —
5518// covers every slider, number input, select, and checkbox in one shot.
5519const _settingsPanel = document.getElementById('settings-panel');
5520if (_settingsPanel) {
5521 _settingsPanel.addEventListener('input', _autoSaveSettings);
5522 _settingsPanel.addEventListener('change', _autoSaveSettings);
5523}
5524// The lock-scale button doesn't emit input/change — catch it separately.

Callers 2

wireEventsFunction · 0.85
main.jsFile · 0.85

Calls 11

handleModelFileFunction · 0.85
promptLoadModeFunction · 0.85
_flushUndoCaptureFunction · 0.85
_rotateGeometryFunction · 0.85
_rotateFinalizeFunction · 0.85
applySettingsSnapshotFunction · 0.85
_restoreMaskFunction · 0.85
_applyImportedTextureFunction · 0.85
_autoSaveSettingsFunction · 0.85
_clearUndoStacksFunction · 0.85
_commitUndoCaptureFunction · 0.85

Tested by

no test coverage detected