Error when applying convertToFlatShadedMesh to terrain

Hello

I notice this error when I tried to call convertToFlatShadedMesh() on a ground mesh generated by MeshBuilder.CreateGroundFromHeightMap. The error can be reproduced in the following PG by uncommenting line 31.

https://playground.babylonjs.com/#0BU6YC#6

This is because the CreateGroundFromHeightMap function is asynchronous as it needs to load the image first,

Just move your code in the callback offered as a parameter of the function (options.onReady)

2 Likes