David
David

Reputation: 33

Threejs: Geometry vertices not updated when exported to stl

I'm trying to export an stl from Threejs using this stl exporter

https://gist.github.com/paulkaplan/6513707

When I open the model in meshlab the vertex positions don't seem to keep their rotations from the parent mesh.

The rotations are applied to the mesh, not the geometry. Is there any flag I need to set in order to update the vertex positions?

Here's the code Im using (CS):

geometry = new THREE.CubeGeometry( 10, 10, 10)

mesh = new THREE.Mesh(geometry)
mesh.position.set(10, 10, 10)
mesh.lookAt new THREE.Vector3

scene.add mesh

saveSTL(geometry, 'mesh')

Upvotes: 3

Views: 578

Answers (1)

WestLangley
WestLangley

Reputation: 104833

You need to apply a transform to the geometry directly (instead of the mesh), in order for the exporter you are using to work as you intend.

geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );

Look in Matrix4.js for the other transforms you can construct.

three.js r.62

Upvotes: 2

Related Questions