I am trying to merge a lot of meshes into one. I’ve had no issues when using an index, i can store millions of triangles. Im seeing issues now when im trying to use just a triangle soup.
My first 1000 meshes, i start to see some of these streched triangles:
Log/inspect the index buffer, look for NaNs… or values >= attribute.count
Make sure the index buffer isn’t 16 bit uint… but 32 bit… or Number
Try doing it on the main thread, see if the result changes…
An idea for debugging: when you render the first 1000 meshes, there are a few bad triangles. You can do binary search until you find one specific bad mesh. Once it is isolated, you can check its vertices - what data are sent and what data are rendered. This might give a clue what is wrong.
If you can reproduce the issue with just a few triangles, then it is not a problem with buffer sizes, but most likely with how the data are prepared in the worker.
When i use indexes i use Float32Array for the positions Uint32Array for indexes. This works with several million triangles and vertices. When using just Float32Array (triangle soup) these issues happen.
The thing thats confusing, if i were to render 0-500, 500-100, i see no issues, it seems to happen after a certain number of triangles, and it seems like its related to 65536.
That sure sounds like there is a 16 bit indexbuffer in play.
Make sure the geometry you’re stuffing into doesn’t have one?
Chrome debugger is your friend.
Also if you want to get real funky… export the broken mesh as GLTF and load it in blender, or drag it in here and we can take a look…