Fix 3D model viewer to show when editing existing parts

- Add 3D model request when loading part from database
- Add console logging for debugging model extraction
- Request model for both manual footprint selection and auto-loaded parts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
brentperteet
2026-02-27 13:30:02 -06:00
parent adffdd211c
commit fdfaa7e059

View File

@@ -1288,6 +1288,7 @@
}); });
// Request 3D model // Request 3D model
console.log('Requesting 3D model for:', footprintName, 'at', selectedFootprintLibraryPath);
socket.emit('get_footprint_model', { socket.emit('get_footprint_model', {
library_path: selectedFootprintLibraryPath, library_path: selectedFootprintLibraryPath,
footprint_name: footprintName footprint_name: footprintName
@@ -1302,10 +1303,12 @@
}); });
socket.on('model_result', (data) => { socket.on('model_result', (data) => {
console.log('Received model_result:', data);
const container = document.getElementById('modelViewerContainer'); const container = document.getElementById('modelViewerContainer');
const messageEl = document.getElementById('modelViewerMessage'); const messageEl = document.getElementById('modelViewerMessage');
if (data.has_model) { if (data.has_model) {
console.log('Model found, displaying viewer');
container.style.display = 'block'; container.style.display = 'block';
messageEl.innerHTML = `<strong>3D Model Found:</strong> ${data.name}<br><br>` + messageEl.innerHTML = `<strong>3D Model Found:</strong> ${data.name}<br><br>` +
`<em>Note: STEP file viewing in browser requires conversion to STL/OBJ format.<br>` + `<em>Note: STEP file viewing in browser requires conversion to STL/OBJ format.<br>` +
@@ -1313,6 +1316,7 @@
`<a href="data:application/stp;base64,${data.data}" download="${data.name}" ` + `<a href="data:application/stp;base64,${data.data}" download="${data.name}" ` +
`style="color: #007bff; text-decoration: underline; cursor: pointer;">Download ${data.name}</a>`; `style="color: #007bff; text-decoration: underline; cursor: pointer;">Download ${data.name}</a>`;
} else { } else {
console.log('No model found');
container.style.display = 'none'; container.style.display = 'none';
} }
}); });
@@ -1498,6 +1502,9 @@
setTimeout(() => { setTimeout(() => {
footprintSelect.value = footprintName; footprintSelect.value = footprintName;
socket.emit('render_footprint', { library_path: lib.path, footprint_name: footprintName }); socket.emit('render_footprint', { library_path: lib.path, footprint_name: footprintName });
// Also request 3D model
console.log('Requesting 3D model for loaded part:', footprintName, 'at', lib.path);
socket.emit('get_footprint_model', { library_path: lib.path, footprint_name: footprintName });
}, 500); }, 500);
} }
} }