Ground getHeightAtCoordinates returns NaN values when subdivisions is != 100

I think I found the problem: the optimize function changes the ground’s _subdivisionsX and _subdivisionsY to the provided chunksCount parameter, which is the number of submeshes to create — while those variables actually represent the number of quads the ground is subdivided into.

Could you try if setting _subdivisionsX and _subdivisionsY to their original value after you called the optimize function solved your problem?