function updateMapMaterialFromData(materialName, dataName, shader, data) {
  var el = shader.el;
  var material = shader.material;
  var rendererSystem = el.sceneEl.systems.renderer;
  var src = data[dataName];

  // Because a single material / shader may have multiple textures,
  // we need to remember the source value for this data property
  // to avoid redundant operations which can be expensive otherwise
  // (e.g. video texture loads).
  if (!shader.materialSrcs) {
    shader.materialSrcs = {};
  }
  if (!src) {
    // Forget the prior material src.
    delete shader.materialSrcs[materialName];
    // Remove the texture from the material.
    setMap(null);
    return;
  }

  // If material src hasn't changed, and we already have a texture,
  // just update properties, but don't reload the texture.
  if (src === shader.materialSrcs[materialName] && material[materialName]) {
    setTextureProperties(material[materialName], data);
    return;
  }

  // Remember the new src for this texture (there may be multiple).
  shader.materialSrcs[materialName] = src;

  // If the new material src is already a texture, just use it.
  if (src instanceof three__WEBPACK_IMPORTED_MODULE_2__.Texture) {
    setMap(src);
  } else {
    // Load texture source for the new material src.
    // (And check if we should still use it once available in callback.)
    el.sceneEl.systems.material.loadTextureSource(src, updateTexture);
  }
  function updateTexture(source) {
    // If the source has been changed, don't use loaded texture.
    if (shader.materialSrcs[materialName] !== src) {
      return;
    }
    var texture = material[materialName];

    // Handle removal or texture type change
    if (texture && (source === null || !isCompatibleTexture(texture, source))) {
      texture = null;
    }

    // Create texture if needed
    if (!texture && source) {
      texture = createCompatibleTexture(source);
    }

    // Update texture source and properties
    if (texture) {
      if (texture.source !== source) {
        texture.source = source;
        texture.needsUpdate = true;
      }
      if (COLOR_MAPS.has(materialName)) {
        rendererSystem.applyColorCorrection(texture);
      }
      setTextureProperties(texture, data);
    }

    // Set map property on the material
    setMap(texture);
  }
  function setMap(texture) {
    // Nothing to do if texture is the same
    if (material[materialName] === texture) {
      return;
    }

    // Dispose old texture if present
    if (material[materialName]) {
      material[materialName].dispose();
    }
    material[materialName] = texture;
    material.needsUpdate = true;
    handleTextureEvents(el, texture);
  }
}
Update `material` texture property (usually but not always `map`)
from `data` property (usually but not always `src`).

@param {string} materialName
@param {string} dataName
@param {object} shader - A-Frame shader instance.
@param {object} data