STL export causes cloned meshes to move

So i’ve noticed that if I try to use STL export on meshes cloned more than once the position of the meshes changes and the meshes floats away into space.
You can see this in the following example:

Another example where i don’t clone the mesh mesh and it doesn’t break the positioning when exporting:

This feels like a bug, or am i missing something?

When exporting to stl the info are baked into the mesh cause there is no scene graph per se in stl so the only way is to bake parent info in the vertices.

There is a flag to prevent it at the end of the createStl function https://www.babylonjs-playground.com/#8XUNI#12

This will nevertheless won t export the right position.

In your case as you clone, all buffer are shared which when baking breaks the other meshes, so you d want to clone without sharing buffers.

makeGeometryUnique will do just that:

2 Likes

Thank you, i felt like i was missing some tiny piece of information. This solved all the issues i had!

1 Like

Very Nice ! When trying to do similar things in one of our projects :stlObj = BABYLON.STLExport.CreateSTL([_this.Sheet], true , “output”, false, false); I get unfortunately a runtime error: Uncaught TypeError: Cannot read properties of undefined (reading ‘CreateSTL’). Any idea ?

Looks like you do not reference the serializers script https://preview.babylonjs.com/serializers/babylonjs.serializers.min.js ?

Really fast, Many thanks, it works perfectly.

1 Like