(object, id)
| 72 | : await fetchText(url); |
| 73 | const object = loader.parse(text); |
| 74 | processObject(object, id); |
| 75 | } else { |
| 76 | throw new Error(`Unsupported file type: ${fileExtension}`); |
| 77 | } |
| 78 | } catch (error) { |
| 79 | self.postMessage({ id, success: false, error: workerErrorMessage(error) }); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | const THUMBNAIL_3MF_TARGET_TRIANGLES = 200000; |
| 84 | const FAST_3MF_XML_BYTES = 2 * 1024 * 1024; |
| 85 | |
| 86 | function decodeZipText(bytes) { |
| 87 | if (typeof THREE !== 'undefined' && THREE.LoaderUtils && typeof THREE.LoaderUtils.decodeText === 'function') { |
| 88 | return THREE.LoaderUtils.decodeText(bytes); |
| 89 | } |
| 90 | return new TextDecoder().decode(bytes); |
| 91 | } |
| 92 | |
| 93 | function zipKeys(zip) { |
| 94 | return zip ? Object.keys(zip) : []; |
| 95 | } |
| 96 | |
| 97 | function shouldUseFast3mfExtract(zip) { |
| 98 | const names = zipKeys(zip); |
| 99 | const extract = self.ThreeMFMeshExtract; |
| 100 | if (extract && typeof extract.zipHasSplitModelParts === 'function' && extract.zipHasSplitModelParts(names)) { |
| 101 | return true; |
| 102 | } |
| 103 | let modelBytes = 0; |
no test coverage detected