Need help with CityJSON Viewer - Remove flickering/shakiness of buildings

So I have this extracted CityJSON building (B-201391183935-6B8EA1920647) from the Montreal dataset found at Datasets - CityJSON.

I am able to visualize it but when I move the camera around (rotation, zoom in, zoom out) it starts flickering/shaking.

I think I have the right faces and vertices passed to the babylon functions. I tried using a custom mesh and the CreatePolyhedron functionality but both result in the same flickering.

What can I try to fix it? What are the possible reasons this happens?

Here is an example playground with one simple and one complex building (just uncomment the one you are going to use). When you run it just zoom out and you should see the building.
https://www.babylonjs-playground.com/#79KYCL#21

Hello and welcome!!

I think your scene precision is the problem. A lot of meshes are coplanar and this generates a lot of depth fighting

You can try to turn on logarithmic depth buffer to see if this helps

Damn, first answer and it already solved my issue.

I will do some testing with more buildings and I hope it work out well with all of them.

Thanks a lot!!!

1 Like

https://www.babylonjs-playground.com/#79KYCL#25

I updated the playground and switched the extracted cityjson building with the entire cityjson dataset which contains all buildings, not just the extracted one.

When I try to render just the extracted one (or any other building or rendering all buildings for that matter) I get the following error:
[.WebGL-0x7fa6157fe000]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 0

Please, could you give me any insights on why this happens and how I can fix it?

PS: I decided that I might not need to create another question for that.

Yes please