MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / openPreview

Function openPreview

preview.js:113–171  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

111 const value = Number(studioEl(id)?.value);
112 return Number.isFinite(value) ? value : fallback;
113 }
114
115 function studioChipValue(groupId, dataAttr, fallback) {
116 return studioEl(groupId)?.querySelector('.active')?.dataset[dataAttr] || fallback;
117 }
118
119 function syncStudioChips(groupId, dataAttr, value) {
120 const group = studioEl(groupId);
121 if (!group) return;
122 group.querySelectorAll(`[data-${dataAttr}]`).forEach((button) => {
123 const active = button.dataset[dataAttr] === value;
124 button.classList.toggle('active', active);
125 button.setAttribute('aria-checked', active ? 'true' : 'false');
126 });
127 }
128
129 function readStudioForm() {
130 const panel = studioEl('preview-studio-panel');
131 return {
132 color: studioEl('preview-studio-color')?.value || STUDIO_DEFAULTS.color,
133 finish: studioChipValue('preview-studio-finish', 'finish', STUDIO_DEFAULTS.finish),
134 finishIntensity: studioNum('preview-studio-finish-intensity', STUDIO_DEFAULTS.finishIntensity),
135 edges: !!studioEl('preview-studio-edges')?.checked,
136 wireframe: !!studioEl('preview-studio-wireframe')?.checked,
137 autoRotate: !!studioEl('preview-studio-autorotate')?.checked,
138 rotateSpeed: studioNum('preview-studio-rotate-speed', STUDIO_DEFAULTS.rotateSpeed),
139 background: studioChipValue('preview-studio-bg', 'bg', STUDIO_DEFAULTS.background),
140 backdrop: studioChipValue('preview-studio-backdrop', 'backdrop', STUDIO_DEFAULTS.backdrop),
141 customBg: studioEl('preview-studio-custom-bg')?.value || STUDIO_DEFAULTS.customBg,
142 boxSize: studioNum('preview-studio-box-size', STUDIO_DEFAULTS.boxSize),
143 reflection: studioNum('preview-studio-reflection', STUDIO_DEFAULTS.reflection),
144 reflectionGap: studioNum('preview-studio-reflection-gap', STUDIO_DEFAULTS.reflectionGap),
145 shadow: studioNum('preview-studio-shadow', STUDIO_DEFAULTS.shadow),
146 shadowSmooth: studioNum('preview-studio-shadow-smooth', STUDIO_DEFAULTS.shadowSmooth),
147 lightRot: studioNum('preview-studio-light-rot', STUDIO_DEFAULTS.lightRot),
148 lightHeight: studioNum('preview-studio-light-height', STUDIO_DEFAULTS.lightHeight),
149 light: studioNum('preview-studio-light', STUDIO_DEFAULTS.light),
150 even: !!studioEl('preview-studio-even')?.checked,
151 grid: !!studioEl('preview-studio-grid')?.checked,
152 transparent: !!studioEl('preview-studio-transparent')?.checked,
153 fov: studioNum('preview-studio-fov', STUDIO_DEFAULTS.fov),
154 panelOpen: !!(panel && !panel.classList.contains('hidden'))
155 };
156 }
157
158 function hydrateStudioForm(settings) {
159 const s = settings || loadStudioSettings();
160 const assign = (id, value, checked) => {
161 const el = studioEl(id);
162 if (!el) return;
163 if (checked != null) el.checked = !!checked;
164 else el.value = String(value);
165 };
166 assign('preview-studio-color', s.color);
167 syncStudioChips('preview-studio-finish', 'finish', s.finish);
168 assign('preview-studio-finish-intensity', s.finishIntensity);
169 assign('preview-studio-edges', null, s.edges);
170 assign('preview-studio-wireframe', null, s.wireframe);

Callers 1

previewCallbackFunction · 0.85

Calls 2

initPreviewSceneFunction · 0.85
loadPreviewModelFunction · 0.85

Tested by

no test coverage detected