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.

273K
  • 29,503
  • 10
  • 41
  • 64
Hesamoy
  • 301
  • 1
  • 20
  • 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. http://stackoverflow.com/questions/27022160/three-js-can-i-apply-position-rotation-and-scale-to-the-geometry – fmacdee Mar 21 '17 at 23:44

2 Answers2

1

You can convert you BufferGeometries to Geometry like so:

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

then you can export to STL format.

leota
  • 1,636
  • 2
  • 13
  • 33
  • 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. – Hesamoy Apr 30 '16 at 21:16
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' );
Mrluobo
  • 85
  • 8