Skip to content Skip to sidebar Skip to footer

How To Convert Three.js To .stl Files For 3d Printing?

I found one page link: Convert Three.js to .stl for 3D printing? var exporter = new THREE.STLExporter(); var str = exporter.parse(scene); console.log(str); But when I'm using them

Solution 1:

The STLExporter.parse() will export the specified object to a string. If you wish to save the string as a file you have to perform some more operations. As a simple approach you can use FileSaver.js for saving the string to a file.

First of all you have to download and include FileSaver.js in your code.

Download link:

After exporting the scene using STLExporter, convert the resulting string to a Blob and then save the Blob as a file using FileSaver.js,

var exporter = new THREE.STLExporter();
var str = exporter.parse( scene ); // Export the scenevar blob = new Blob( [str], { type : 'text/plain' } ); // Generate Blob from the string
saveAs( blob, 'file.stl' ); //Save the Blob to file.stl

If you are not familiar with FileSaver.js you can try the following method,

var exporter = newTHREE.STLExporter();
var str = exporter.parse( scene ); // Export the scenevar blob = newBlob( [str], { type : 'text/plain' } ); // Generate Blob from the string//saveAs( blob, 'file.stl' ); //Save the Blob to file.stl//Following code will help you to save the file without FileSaver.jsvar link = document.createElement('a');
link.style.display = 'none';
document.body.appendChild(link);
link.href = URL.createObjectURL(blob);
link.download = 'Scene.stl';
link.click();

Post a Comment for "How To Convert Three.js To .stl Files For 3d Printing?"