Skip to content

Experience-Monks/cube-face-vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cube-face-vector

stable

Gets a unit vector 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-vector')
var range = require('array-range')

var faces = range(6).map(i => direction(i))

Results in:

[
  [1,  0, 0],
  [-1, 0, 0],
  [0,  1, 0],
  [0, -1, 0],
  [0,  0, 1],
  [0,  0, -1]
]

Usage

NPM

vector = direction(slot)

Returns a unit vector 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 unit vector for a given cubemap face

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published