| 1273 | .replace(/\)/g, '%29') |
| 1274 | .replace(/'/g, '%27') |
| 1275 | .replace(/\[/g, '%5B') |
| 1276 | .replace(/\]/g, '%5D'); |
| 1277 | } catch (error) { |
| 1278 | console.error('Error encoding non-Windows file path:', error); |
| 1279 | // Super simple fallback |
| 1280 | encodedFilePath = `file://${actualFilePath.replace(/#/g, '%23')}`; |
| 1281 | } |
| 1282 | console.log('loadModel: Encoded Unix path:', encodedFilePath); |
| 1283 | } |
| 1284 | |
| 1285 | // If no embedded image found, proceed with 3D loading using Web Worker |
| 1286 | if (fileExtension !== 'stl' && fileExtension !== '3mf' && fileExtension !== 'obj') { |
| 1287 | throw new Error(`Unsupported file type: ${fileExtension}`); |
| 1288 | } |
| 1289 | |
| 1290 | // Read file bytes via main process (same as 3D preview) — avoids fragile file:// fetch in the worker. |
| 1291 | let modelArrayBuffer = null; |
| 1292 | if (window.electron && typeof window.electron.readModelFile === 'function') { |