Skip to content

Instantly share code, notes, and snippets.

@Broxzier
Created August 3, 2023 14:45
Show Gist options
  • Save Broxzier/9a0797a7922a1689f1ba6a3ff52400b3 to your computer and use it in GitHub Desktop.
Save Broxzier/9a0797a7922a1689f1ba6a3ff52400b3 to your computer and use it in GitHub Desktop.
A javascript function to quickly generate a grid of UV coordinates for an .obj file
function generateVT(w, h) {
var vt = "";
for (var y = 1; y <= h; y++)
for (var x = 1; x <= w; x++)
vt += `vt ${((x-1)/(w-1)).toFixed(6)} ${((h-y)/(h-1)).toFixed(6)}\n`;
return vt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment