Skip to content

Instantly share code, notes, and snippets.

@Dav1dde
Created April 11, 2013 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dav1dde/5365095 to your computer and use it in GitHub Desktop.
Save Dav1dde/5365095 to your computer and use it in GitHub Desktop.
xmin = 0
xmax = 0
zmin = 0
zmax = 0
for vertex, i in exports.face.vertices
switch i % 3
when 0
xmin = Math.min xmin, vertex
xmax = Math.max xmax, vertex
when 2
zmin = Math.min zmin, vertex
zmax = Math.max zmax, vertex
xnmax = xmax + Math.abs xmin
znmax = zmax + Math.abs zmin
for vertex, i in exports.face.vertices
switch i % 3
when 0
exports.face.vertices[i] = ((vertex + Math.abs(xmin))/xnmax)*2 - 1
when 1
exports.face.vertices[i] = 0
when 2
exports.face.vertices[i] = ((vertex + Math.abs(zmin))/znmax)*2 - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment