How to create a "manifold" mesh for 3d printing?

Hi everyone,
this is probably a noob question but please bear with me… :sweat_smile:

I’m trying to create some simple models in BabylonJS to be 3D printed after being exported to OBJ or STL.
Problem is, it seems that you cannot simply create a bunch of “touching” boxes to create a 3D printable model, because the model should be “manifold”.

For example take this simple Playground :

As you can see, the figure is composed by 5 boxes (it’s a sort of table); when exported and opened in a 3d slicer software, they are treated like 5 separated boxes as well, and it says that there are several open edges:

Here’s the question: how should I construct a figure similar to that one, and make sure that is “manifold” ? Is there any helper function in BabylonJS for this ?

Thanks in advance for any help and for this fabulous library :pray:

The are all independent meshes. Try MergeMeshes!

1 Like

I’m not aware of a helper function for this with Babylon.js. Integrating something like this (compiled to WebAssembly) is one way to go if the input geometry is generic.

@elalish maybe can give more info if needed. :slight_smile:

@HiGreg
I have already tried this, but unfortunately it does not work.
Edges of different boxes remain sort of “independent” and the global model is not manifold.

@bghgary
so this is not a trivial task…

But what do you mean by “if input geometry is generic” ?
I mean, I know what I want to accomplish, it’s just a bunch of boxes that can change position dynamically but more or less I know what is happening, as I would do in a CAD software.

Is there maybe another way to create custom meshes which creates manifold models ?

Thanks

FYI on non-manifold . Therefore, if you want to do it at runtime, I would opt for an existing solution because it is quite challenging.

If you can do it at design time: in your picture, you need to merge the double vertices:

Screenshot 2024-10-04 142827

The manifold library posted by @bghgary seems like a really good option. Maybe convert the three.ts interface layer to babylon?

If you know exactly what shapes you have and the shapes are simple, I can imagine the algorithm for getting a manifold be simplified, but I’m no expert in this area.

Thanks for the callout, @bghgary! Indeed, making manifold meshes is a lot harder than it sounds, but this is exactly why I built the Manifold library. I would encourage you to try out our web playground for building and exporting Manifold meshes: https://manifoldcad.org/. If you like it, then @HiGreg is right that it shouldn’t take much to convert our three.js example to a babylon example if you want to.

3 Likes

Thanks to your suggestions I created this:

The PG converts a grayscale image to a 3d printable “voxelized” model (the image is indicated as data uri at the beginning of the script).
The figure is printable even if is not absolutely manifold (see later for details); basically I created a custom mesh facet by facet, using tree traversal (BFS) to detect group of adjacent facets and avoid printing internal edges.

As I said, is printable since the slicer (prusa slicer) does not detect any open edges; but Blender 3D print plugin still report some non manifold edges.
These are easy to see in Blender (highlighted in orange) if we switch to a much smaller greyscale image instead of yoda (uncommenting the data-uri at the top):

They are basically “corner” edges that are shared among two voxels, so this is not manifold because AFAIK one edge cannot be shared by more than 2 facets.

However this seems to be printable anyway, thanks for the help :slight_smile:

claude.ai:

Give me an example for point 1

sure

Mmh… CSG still creates open edges, the example you (the AI) gave me is still not manifold :thinking:

The proposed point 2 seems to be easy to implement.

Here is a pixelation process I made. I hope it can help you.