lib/loadTexture.js
function loadTexture(texturePath, options) {
    options = defaultValue(options, {});
    options.checkTransparency = defaultValue(options.checkTransparency, false);
    options.decode = defaultValue(options.decode, false);

    return fsExtra.readFile(texturePath)
        .then(function(source) {
            const name = path.basename(texturePath, path.extname(texturePath));
            const extension = path.extname(texturePath).toLowerCase();
            const texture = new Texture();
            texture.source = source;
            texture.name = name;
            texture.extension = extension;
            texture.path = texturePath;

            let decodePromise;
            if (extension === '.png') {
                decodePromise = decodePng(texture, options);
            } else if (extension === '.jpg' || extension === '.jpeg') {
                decodePromise = decodeJpeg(texture, options);
            }

            if (defined(decodePromise)) {
                return decodePromise.thenReturn(texture);
            }

            return texture;
        });
}
function loadTexture(texturePath, options) {
    options = defaultValue(options, {});
    options.checkTransparency = defaultValue(options.checkTransparency, false);
    options.decode = defaultValue(options.decode, false);

    return fsExtra.readFile(texturePath)
        .then(function(source) {
            const name = path.basename(texturePath, path.extname(texturePath));
            const extension = path.extname(texturePath).toLowerCase();
            const texture = new Texture();
            texture.source = source;
            texture.name = name;
            texture.extension = extension;
            texture.path = texturePath;

            let decodePromise;
            if (extension === '.png') {
                decodePromise = decodePng(texture, options);
            } else if (extension === '.jpg' || extension === '.jpeg') {
                decodePromise = decodeJpeg(texture, options);
            }

            if (defined(decodePromise)) {
                return decodePromise.thenReturn(texture);
            }

            return texture;
        });
}
function loadTexture ( texturePath , options ) { options = defaultValue ( options , { } ) ; options . checkTransparency = defaultValue ( options . checkTransparency , false ) ; options . decode = defaultValue ( options . decode , false ) ; return fsExtra . readFile ( texturePath ) . then ( function ( source ) { const name = path . basename ( texturePath , path . extname ( texturePath ) ) ; const extension = path . extname ( texturePath ) . toLowerCase ( ) ; const texture = new Texture ( ) ; texture . source = source ; texture . name = name ; texture . extension = extension ; texture . path = texturePath ; let decodePromise ; if ( extension === '.png' ) { decodePromise = decodePng ( texture , options ) ; } else if ( extension === '.jpg' || extension === '.jpeg' ) { decodePromise = decodeJpeg ( texture , options ) ; } if ( defined ( decodePromise ) ) { return decodePromise . thenReturn ( texture ) ; } return texture ; } ) ; }
Load a texture file.

@param {String} texturePath Path to the texture file.
@param {Object} [options] An object with the following properties:
@param {Boolean} [options.checkTransparency=false] Do a more exhaustive check for texture transparency by looking at the alpha channel of each pixel.
@param {Boolean} [options.decode=false] Whether to decode the texture.
@returns {Promise} A promise resolving to a Texture object.

@private
Load a texture file .