texture2cube
v1.0.2
Published
Generate a cube like image from three textures without canvas, which could allow a server side system to do this work.
Downloads
4
Readme
Texure2Cube
Generate a cube like image from three textures without canvas, which could allow a server side system to do this work.
Texture2Cube
uses ndarray to load image data, then use this data to transform the textures.
usage
Install and import it as a module.
npm i texture2cube
Here shows a basic example:
var CubeImage = require('texture2cube');
var cubeImage = new CubeImage({
top: 'texture_top.png',
left: 'texture_left.png',
rignt: 'texture_right.png',
})
cubeImage.toPng('./cube.png');
API
Constructor
constructor accepts five inputs:
left
: left textureright
: right texturetop
: top texturescale
: (optional)scale the output imageinfo
: (optional)can pass some data and get bycubeImage.getPixels
Output
cubeImage.toCanvas(element)
: append a canvas to element.cubeImage.toCanvas()
: append a canvas to bodycubeImage.toPng('result.png')
output to a png filecubeImage.getPixels(callback(pixels, info))
: pixels are the ndarray type of the result image data, info is the data from constructor.