convertToFlatShadedMesh making mesh disappear situationally?


I can not figure out for the life of me why one of my imported meshes wont let me convert it to flat shaded without disappearing. Its setup the exact same way as other meshes that will let me do it, and if I dont parse the element prior to it “Wall-Mound” then it works just fine. Its only once the other element is parsed that the “convertToFlatShaded” breaks the other mesh.

This is really odd, they dont share geometry that I am aware of and are setup essentially the same way. All other meshes in my template file work great its just this one keeps disappearing.

It seems to be directly related to the convert to flat shaded.

boiling down the problem.
even if you do mesh.setIndices(Array.from(mesh.getIndices())) on the mesh, it diss a pears.

In this PG:

(changes from line 93, check console for logs)

we see that in the indices that mesh already has, it’s referencing upto 29th vertex to make the mesh.

we only have 20 positions available so that doesn’t make sense.

the anomaly here is that it managed to get rendered in the first place since the vertex data of the mesh already looks like it’s malformed. : /

if I dont parse the element prior to it “Wall-Mound” then it works just fine. Its only once the other element is parsed that the “convertToFlatShaded” breaks the other mesh.

If you don’t parse Wall-Mound, try commenting it out, it throws an error in the console and the max index referenced for the problematic mesh becomes 19, which is fine.

So ig that’s why it doesn’t cause a problem then.

as to why not parsing Wall mound and it throwing an error midway is causing the indices of the next mesh to break, I do not know : O

Edit:
yeah so I just added wallMound.makeGeometryUnique(); and the whole problem went away the mesh no longer disappears. so the meshes do share geometry somehow.

as for exactly how and where, idk

1 Like

Hmm. Thanks for digging on on that. I ended up doing a whole different set of models and the problem went away, I wonder if somehow that one was getting messed up during my export process. I make them in C4D then export as an fbx to export from blender as a glb. So maybe something got messed up.

1 Like

glad it worked out! : D