Geometry Export Error

Hello Everybody

So I was trying to export Lathegeometry from three v. 107 but the end result doesnot come out to be what I expected. When I import the exported model in Blender, the faces of the mesh are not attached to each other. Here is the picture of the default LatheGeometry face being moved (it completely cuts off from the geometry:

But if you see the tree obj file provided with threejs here is how it looks when we move a face :

I am not extruding the geometry , I am just moving the face.

Here are the exported files of the LatheGeom :
wobj.mtl (224 Bytes) wobj.obj (46.3 KB)

For the code I directly integrated the export code in Threejs LatheGeometry docs page and stripped off everything . You can run it using any local server and going inside geometry-browser.html to view it : (3.9 MB)

It would be great to know how can I make my geometry uniformly integrated like the one in tree geometry or is there a bug in three.js ?

Thanks in advance!

No, it’s not a bug. LatheGeometry is defined as a so called non-indexed geometry. That means no vertices are shared between faces. Or in other words: Each face has its own set of vertices.

Defining geometries without an index is totally valid. Have you tried to merge vertices in Blender?

@Mugen87 Can I merge vertices before I export ? I need that for my geometry.

The LatheGeometry is indexed as I can see inside the three.js implementation or am I missing something ? :

 // build geometry

this.setIndex( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

I tried merging vertices using geometry.mergeVertices() but with no luck

You’re totally right! I’ve mixed LatheGeometry with PolyhedronGeometry, sorry.

Instead of using OBJExporter, can you please give GLTFExporter a try?

@Mugen87 : I have already tried both and included both in the provided code above. Both of them don’t work :frowning:

Um, I’ve exported the predefined LatheGeoemtry from the three.js editor to OBJ and imported it into Blender. The triangles are actually connected.

Can you please make a test with the following OBJ file? model.obj (27.1 KB)

@Mugen87 Yup the above obj works fine but the given code :

var points = [];
for ( var i = 0; i < 10; i ++ ) {
   points.push( new Vector2( Math.sin( i * 0.2 ) * 10 + 5, ( i - 5 ) * 2 ) );
var geometry = new LatheGeometry( points,10,0,6.3)

The last console log always gives undefined . Could you please tell me why ? This is certainly the cause of hinderence when I try to save the geometry with a material in mesh with OBJ or GLTF exporter.

I see you are using LatheGeometry. Can you please use LatheBufferGeometry? The problem is that instances of Geometry are internally converted to a non-indexed BufferGeometry. This could be the reason why you see unconnected triangles.

BTW: The editor uses LatheBufferGeometry and it seems to work fine.

1 Like