src/textures.js
function loadTextureFromUrl(gl, tex, options, callback) {
  callback = callback || noop;
  options = options || defaults.textureOptions;
  setTextureTo1PixelColor(gl, tex, options);
  // Because it's async we need to copy the options.
  options = Object.assign({}, options);
  const img = loadAndUseImage(options.src, options.crossOrigin, function(err, img) {
    if (err) {
      callback(err, tex, img);
    } else {
      setTextureFromElement(gl, tex, img, options);
      callback(null, tex, img);
    }
  });
  return img;
}
function loadTextureFromUrl(gl, tex, options, callback) {
  callback = callback || noop;
  options = options || defaults.textureOptions;
  setTextureTo1PixelColor(gl, tex, options);
  // Because it's async we need to copy the options.
  options = Object.assign({}, options);
  const img = loadAndUseImage(options.src, options.crossOrigin, function(err, img) {
    if (err) {
      callback(err, tex, img);
    } else {
      setTextureFromElement(gl, tex, img, options);
      callback(null, tex, img);
    }
  });
  return img;
}
function loadTextureFromUrl ( gl , tex , options , callback ) { callback = callback || noop ; options = options || defaults . textureOptions ; setTextureTo1PixelColor ( gl , tex , options ) ; // Because it's async we need to copy the options. options = Object . assign ( { } , options ) ; const img = loadAndUseImage ( options . src , options . crossOrigin , function ( err , img ) { if ( err ) { callback ( err , tex , img ) ; } else { setTextureFromElement ( gl , tex , img , options ) ; callback ( null , tex , img ) ; } } ) ; return img ; }
A callback for when an image finished downloading and been uploaded into a texture
@callback ThreeDReadyCallback
@param {*} err If truthy there was an error.
@param {WebGLTexture} tex the texture.
@param {HTMLImageElement[]} imgs the images for each slice.
@memberOf module:twgl
 
Loads a texture from an image from a Url as specified in `options.src`
If `options.color !== false` will set the texture to a 1x1 pixel color so that the texture is
immediately useable. It will be updated with the contents of the image once the image has finished
downloading. Filtering options will be set as approriate for image unless `options.auto === false`.
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@param {WebGLTexture} tex the WebGLTexture to set parameters for
@param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
@param {module:twgl.TextureReadyCallback} [callback] A function to be called when the image has finished loading. err will
be non null if there was an error.
@return {HTMLImageElement} the image being downloaded.
@memberOf module:twgl/textures
A callback for when an image finished downloading and been uploaded into a texture