How to generate uv attribute for buffer geometry (mesh)

Generating UVs can be useful for procedural/generated geometries (the same as with defining UVs for Three’s out-of-the-box geometries).

There isn’t quite enough documentation on what the rules are for the UV attribute (indexed vs non-indexed geometry), so I made a thread on that: