function loadMaterial(loader, gltfMaterial, frameState) {
  const material = new Material();

  const extensions = gltfMaterial.extensions ?? Frozen.EMPTY_OBJECT;
  const pbrSpecularGlossiness = extensions.KHR_materials_pbrSpecularGlossiness;
  const pbrSpecular = extensions.KHR_materials_specular;
  const pbrAnisotropy = extensions.KHR_materials_anisotropy;
  const pbrClearcoat = extensions.KHR_materials_clearcoat;
  const pbrMetallicRoughness = gltfMaterial.pbrMetallicRoughness;

  material.unlit = defined(extensions.KHR_materials_unlit);

  if (defined(pbrSpecularGlossiness)) {
    material.specularGlossiness = loadSpecularGlossiness(
      loader,
      pbrSpecularGlossiness,
      frameState,
    );
  } else {
    if (defined(pbrMetallicRoughness)) {
      material.metallicRoughness = loadMetallicRoughness(
        loader,
        pbrMetallicRoughness,
        frameState,
      );
    }
    if (defined(pbrSpecular) && !material.unlit) {
      material.specular = loadSpecular(loader, pbrSpecular, frameState);
    }
    if (defined(pbrAnisotropy) && !material.unlit) {
      material.anisotropy = loadAnisotropy(loader, pbrAnisotropy, frameState);
    }
    if (defined(pbrClearcoat) && !material.unlit) {
      material.clearcoat = loadClearcoat(loader, pbrClearcoat, frameState);
    }
  }

  // Top level textures
  if (defined(gltfMaterial.emissiveTexture)) {
    material.emissiveTexture = loadTexture(
      loader,
      gltfMaterial.emissiveTexture,
      frameState,
    );
  }
  // Normals aren't used for classification, so don't load the normal texture.
  if (defined(gltfMaterial.normalTexture) && !loader._loadForClassification) {
    material.normalTexture = loadTexture(
      loader,
      gltfMaterial.normalTexture,
      frameState,
    );
  }
  if (defined(gltfMaterial.occlusionTexture)) {
    material.occlusionTexture = loadTexture(
      loader,
      gltfMaterial.occlusionTexture,
      frameState,
    );
  }
  material.emissiveFactor = fromArray(Cartesian3, gltfMaterial.emissiveFactor);
  material.alphaMode = gltfMaterial.alphaMode;
  material.alphaCutoff = gltfMaterial.alphaCutoff;
  material.doubleSided = gltfMaterial.doubleSided;

  return material;
}
Load textures and parse factors and flags for a glTF material

@param {GltfLoader} loader
@param {object} gltfMaterial An entry from the <code>.materials</code> array in the glTF JSON
@param {FrameState} frameState
@returns {ModelComponents.Material}
@private