atlaspack icon indicating copy to clipboard operation
atlaspack copied to clipboard

improve uv docs

Open nickdesaulniers opened this issue 11 years ago • 3 comments

currently the docs for atlas.uv() state:

var uvmap = atlas.uv();
/* {
              TOP   RIGHT  BOTTOM  LEFT
  'name':  [ [0,0], [1,0], [1,1], [0,1] ],
} */

When I think of a quad, I think of four pairs of points, so instead of TOP, RIGHT, BOTTOM, and LEFT, I would expect something more like TOP-LEFT, TOP-RIGHT, BOTTOM-LEFT, BOTTOM-RIGHT.

nickdesaulniers avatar Jul 24 '14 05:07 nickdesaulniers

The order looks to me like BOTTOM-LEFT, BOTTOM-RIGHT, TOP-RIGHT, TOP-LEFT. I assume you're using uv coordinates where the origin is in the bottom left most corner? Because the existing docs don't suggest that either are correct?

nickdesaulniers avatar Jul 24 '14 05:07 nickdesaulniers

Assuming the origin is implied to be in the top left, which I guess makes sense for canvas 2d, then the order is TOP-LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT. That's really going to trip up someone looking for uv coordinates if they're assuming uv coordinate system.

nickdesaulniers avatar Jul 24 '14 05:07 nickdesaulniers

This library was originally written for use in voxel-texture. The coordinates are based on what is used in voxel.js and three.js. I'm happy to take a patch for improvements though. Thanks!

shama avatar Jul 24 '14 05:07 shama