Description
I have a standard example in Flitter of a translucent rounded box that is constructed by unioning 3 boxes, 12 cylinders and 8 spheres. It looks like this (reference image from Flitter repo):
Or rather, it used to look like that. As of Manifold 3, I've noticed that I'm getting a bunch of visual problems with the model:
Other than the tris that have normals that are clearly in the wrong direction, you can also see in the bottom right corner of the image that there are faces that have become flat shaded.
Flitter is large so it's hard for me to isolate this into a completely standalone test, but I've written a short Python script that uses the Flitter framework to generate the same model for analysis. The code and a script for running it are in this gist.
The code basically generates a sphere, a cylinder and a box and then transforms these into 23 different models and unions them all together. The code that generates the primitive models is designed such that the vertices on them should align perfectly after these transformations are done. Doing the transforms with my own (double-precision) matrix code I get 1170 numerically unique vertices (from a total of 14,544 vertices across the 23 models).
Under the hood the generated meshes of each of the primitives are .merge()
d and made into Manifold()
s, these are .transform()
ed and a Manifold.batch_boolean()
call unions them. I'm then also calling .calculate_normals(0, 30)
on that manifold.
The output of running the script is this:
*** Manifold < 3 ***
rbox contains 1170 unique vertices over 23 models
union has 1224 vertices and 2444 triangles, of which 0 are degenerate
after computing normals, union has 1224 vertices and 2444 triangles
2025-06-10 13:03:30.036 | DEBUG | flitter.render.window.models:<module>:83 - Emptied 33 models from cache in 4 run(s)
*** Manifold > 3 ***
rbox contains 1170 unique vertices over 23 models
union has 1804 vertices and 3604 triangles, of which 968 are degenerate
after computing normals, union has 2831 vertices and 3604 triangles
2025-06-10 13:03:31.036 | DEBUG | flitter.render.window.models:<module>:83 - Emptied 33 models from cache in 4 run(s)
Since Manifold v3, I'm getting a load of degenerate tris (calculated here as one or more sides < 1e-9 in length). I would be fairly relaxed about the these, but it looks like they're impacting the calculation of the normals – as the image and the explosion of vertices shows.
My question is: are there steps that I should be taking, as of v3, that I'm not doing – such as some tolerance setting?