Didn't write what code today, mainly look at the potential generation algorithm. This algorithm is called Real-Time Optimal Adapting Mesh. Its thinking uses the equilateral right triangle to indicate the degree of the terrain of two equal angular triangles. If you want to indicate the surface of the high detail, you can decompose into more right-angle triangles, if it is not required to be as many detail, focusing on the speed, you can decompose the three-equivalent right angle triangle less.
This algorithm is called the ROAM algorithm.