STL exporter for BufferGeometry in THREE.js
Asked Answered
C

2

6

I have a number of BufferGeometries, which consist a scene, and their meshes have been transferred to different positions. I was wondering if there is a way to export this scene, from meshes, containing BufferGeometries to STL file. Thank you very much.

Carnival answered 29/4, 2016 at 17:30 Comment(1)
This answer handles applying a transform matrix directly to geometries to modify them, so if you do what @leota suggested and get the geometry from the BufferGeometry you should be able to then apply the transform and export the modified geometry. #27022660Indoctrinate
H
1

You can convert you BufferGeometries to Geometry like so:

var geometry = new THREE.Geometry().fromBufferGeometry( bufferGeometry );

then you can export to STL format.

Heptavalent answered 29/4, 2016 at 19:35 Comment(1)
Thank you @leota. Since they are still geometries, they do not have the transformation, I made to their meshes. I need to export the meshes, containing BufferGeometries to STL file.Carnival
L
1

just try:

scene.traverse(function(child){
    child.updateMatrix();
    child.applyMatrix(child.matrix);
});
var exporter = new THREE.STLExporter();
exporter.parse( scene );
function saveString( text, filename ) {
		save( new Blob( [ text ], { type: 'text/plain' } ), filename );
}
saveString( exporter.parse( editor.scene ), 'model.stl' );
Lungan answered 23/3, 2017 at 16:23 Comment(1)
This doesn't seem to preserve the transformations stored in a BufferGeometry.Maltose

© 2022 - 2024 — McMap. All rights reserved.