How to control the triangles of a model in scripts?

For example: when a 3d model is far from camera enough, it turns to a Low-Triangles state

and it turns to a Normal-Triangles state while it is close enough to the camera.

How to do this in script?