Smooth edge for glb models

Hello,

I have an imported glb file, the edges are hard. I’ve looked it up and found that glb separate the vertices when exporting (using Blender), so is there a way to smooth edges for a glb file?

Currently I’m trying to merge vertices then smooth normals, but I can’t figure that’s out! I’m using BufferGeometryUtils to .mergeVertices(geometry) then computeVertexNormals() but I’m not getting anywhere!

Thanks.

I’m in the same boat, this does not work any more (I think it used to, so why not now?) so I had to do this instead.

1 Like

So it never did. What used to work was the other geometry class method.

For smoothing by normal vectors at vertices → there is a topic in this forum about something similar and the solution was to smooth the object in Blender and reexport the model:

Striped shadows on OBJ/MTL model


Off-topic: I like @makc3d’s 4-points controls. I remember in the past I wanted to do something similar for one AR project, but I messed the math up and failed. I wish I knew this lib two years ago.

1 Like

opencv :sweat_smile: (well, there are like 10 different ways to do it, you basically only need to slice a pyramid by a plane. if you messed up one of them, you could always try another)

2 Likes

@makc3d yea I think this does not work anymore!

Thanks, I’ll check it out! for now I just switched to fbx. my concern at the moment is the file size, but fortunately when I switched the size didn’t get impacted that much!

@PavelBoytchev as it say in the title, they are using OBJ not glTF, and I think the problem was just not smoothing the mesh correctly from the 3D tool. I’ll look more into it.

turns out I was wrong here, it kinda did. e.g. this

        function fixDuckingNormals( o ) {
            if( o.geometry ) {
                delete o.geometry.attributes.normal; // <== important! lol
                o.geometry = mergeVertices( o.geometry );
                o.geometry.computeVertexNormals();
            }
        }

worked for me. but that;s because the duck has very special uv map - a single island connecting to itself on the other (mirrored) side - so it had no seams. any “normal” uv map will generate a ton of seams like that.

1 Like

Thanks! I’ll try it.

@makc3d So I’ve tried your solution and it gives an error saying mergeVertices is not defined …

But here’s the odd thing, I’ve exported a simple low poly sphere as glb from blender with smooth edges, after adding it, it runs smooth! without doing anything … the mesh I’m using is a photogrammetry scan but I edit it in blender, I’ll look it up some other time.
but thanks for your help

oh that the one from BufferGeometryUtils:

        import { mergeVertices } from 'https://threejs.org/examples/jsm/utils/BufferGeometryUtils.js'

(adjust the path to your threejs)

well of course, if you export good normals layer it just works.