STLExported - exporting a large sized file

I have a glb model that is the size of around 7mb I am using STLExporter to convert it into stl and then export it, but the issue is that the size increases to 90 mb after export.

Can anyone help me regarding this, here is the code I am using:

function handleExportModel() {
    document.getElementById('loader-container').style.display = 'flex';

    setTimeout(() => {
        const exporter = new STLExporter();
        const stlString = exporter.parse(mesh);

        const blob = new Blob([stlString], { type: 'text/plain' });
        const link = document.createElement('a');
        link.style.display = 'none';
        document.body.appendChild(link);

        link.href = URL.createObjectURL(blob);
        link.download = 'model.stl';
        link.click();

        document.body.removeChild(link);
        URL.revokeObjectURL(link.href);

        document.getElementById('loader-container').style.display = 'none';
    }, 0);
}

I would try exporting with the binary STL option if size is a concern, as three.js supports writing both ASCII and binary STL files. See the STLExporter docs. If that doesn’t help, may need to share the file to get help reducing its size.

1 Like

That did work for me it reduced the size from 90mb straight to 19mb, is there anything more I am missing out since the actual size of the glb is around 7mb.

Thanks for the help!

Maybe you could try doing .mergeVertices() before exporting, to make sure there are no duplicate vertices. But STL is not really a runtime/transmission oriented format like GLB and doesn’t support the sorts of compression that GLB does, so in general GLB can be optimized much farther.

1 Like

Done that too, thanks for the help!