cube_map

Function cube_map 

Source
pub fn cube_map(pos: Vec3, dir: Normal3) -> TexCoord
Expand description

Returns a texture coordinate in a cube map.

A cube map texture is a composite of six subtextures in a 3x2 grid. Each subtexture corresponds to one of the six cardinal directions: right (+x), left (-x), top (+y), bottom (-y), front (+z), back (-z).

The subtexture is chosen based on which component of dir has the greatest absolute value. The texture coordinates within the subtexture are based on the zy, xz, or xy components of pos such that the range [-1.0, 1.0] is transformed to the range of uv values in the appropriate subtexture.

    u
    0     1/3    2/3     1
v 0 +------+------+------+
    |      |      |      |
    |  +x  |  +y  |  +z  |
  1 |      |      |      |
  / +--zy--+--xz--+--xy--+
  2 |      |      |      |
    |  -x  |  -y  |  -z  |
    |      |      |      |
  1 +------+------+------+