Experience-Monks / cube-face-name

gets a name like "px" or "pz" for a cube map face

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cube-face-name

stable

Gets a human readable name like 'px' or 'py' for the specified index into a 3D cube, intended to be used alongside cube map manipulation in OpenGL applications. The order is the same as in DDS and OpenGL, see below.

Example

var direction = require('cube-face-name')
var range = require('array-range')

var images = range(6)
  .map(direction)
  .map(x => 'assets/skyboxes/cloudy-${x}.png')

Result:

[
  'assets/skyboxes/cloudy-px.png',
  'assets/skyboxes/cloudy-nx.png',
  'assets/skyboxes/cloudy-py.png',
  'assets/skyboxes/cloudy-ny.png',
  'assets/skyboxes/cloudy-pz.png',
  'assets/skyboxes/cloudy-nz.png'
]

Usage

NPM

name = cubeFace(slot)

Returns a human-readable name for the given slot in a cube map, using the same ordering as OpenGL and various texture formats: px, nx, py, ny, pz, nz.

slot is between 0 (inclusive) and 6 (exclusive).

See Also

License

MIT, see LICENSE.md for details.

About

gets a name like "px" or "pz" for a cube map face

License:MIT License


Languages

Language:JavaScript 100.0%