document.getElementById('processModelsBtn').addEventListener('click', function() { var loadingIndicator = document.getElementById('final-loading-indicator'); loadingIndicator.style.display = 'inline-block'; var downloadLinkFinal = document.getElementById('download-link-final'); downloadLinkFinal.style.display = 'none'; downloadLinkFinal.href = ''; downloadLinkFinal.textContent = ''; fetch('/process_3d_models', { method: 'GET' }) .then(response => { if (!response.ok) { throw new Error('Failed to process the 3D models.'); } return response.blob(); }) .then(blob => { var url = window.URL.createObjectURL(blob); downloadLinkFinal.href = url; downloadLinkFinal.download = 'fitted_model.obj'; downloadLinkFinal.style.display = 'block'; downloadLinkFinal.textContent = 'Download Fitted 3D Model'; loadingIndicator.style.display = 'none'; }) .catch(error => { console.error('There was an error:', error); loadingIndicator.style.display = 'none'; }); });